@@ -232,9 +232,10 @@ def _reset():
232232
233233NVIDIA_11_VGPU_TYPE = 'nvidia-11'
234234NVIDIA_12_VGPU_TYPE = 'nvidia-12'
235- PGPU1_PCI_ADDR = 'pci_0000_81_00_0'
236- PGPU2_PCI_ADDR = 'pci_0000_81_01_0'
237- PGPU3_PCI_ADDR = 'pci_0000_81_02_0'
235+ MLX5_CORE_TYPE = 'mlx5_core'
236+ MDEVCAP_DEV1_PCI_ADDR = 'pci_0000_81_00_0'
237+ MDEVCAP_DEV2_PCI_ADDR = 'pci_0000_81_01_0'
238+ MDEVCAP_DEV3_PCI_ADDR = 'pci_0000_81_02_0'
238239
239240os_uname = collections .namedtuple (
240241 'uname_result' , ['sysname' , 'nodename' , 'release' , 'version' , 'machine' ],
@@ -296,9 +297,9 @@ class FakePCIDevice(object):
296297
297298 def __init__ (
298299 self , dev_type , bus , slot , function , iommu_group , numa_node , * ,
299- vf_ratio = None , multiple_gpu_types = False , parent = None ,
300- vend_id = None , vend_name = None , prod_id = None , prod_name = None ,
301- driver_name = None ,
300+ vf_ratio = None , multiple_gpu_types = False , generic_types = False ,
301+ parent = None , vend_id = None , vend_name = None , prod_id = None ,
302+ prod_name = None , driver_name = None ,
302303 ):
303304 """Populate pci devices
304305
@@ -312,6 +313,7 @@ def __init__(
312313 :param vf_ratio: (int) Ratio of Virtual Functions on Physical. Only
313314 applicable if ``dev_type`` is one of: ``PF``, ``VF``.
314315 :param multiple_gpu_types: (bool) Supports different vGPU types.
316+ :param generic_types: (bool) Support both mlx5 and nvidia-12 types.
315317 :param parent: (int, int, int) A tuple of bus, slot and function
316318 corresponding to the parent.
317319 :param vend_id: (str) The vendor ID.
@@ -329,6 +331,7 @@ def __init__(
329331 self .numa_node = numa_node
330332 self .vf_ratio = vf_ratio
331333 self .multiple_gpu_types = multiple_gpu_types
334+ self .generic_types = generic_types
332335 self .parent = parent
333336
334337 self .vend_id = vend_id
@@ -414,6 +417,15 @@ def generate_xml(self, skip_capability=False):
414417 'type_id' : NVIDIA_12_VGPU_TYPE ,
415418 'instances' : 8 ,
416419 })
420+ if self .generic_types :
421+ types = [self .mdevtypes_templ % {
422+ 'type_id' : MLX5_CORE_TYPE ,
423+ 'instances' : 16 ,
424+ }]
425+ types .append (self .mdevtypes_templ % {
426+ 'type_id' : NVIDIA_12_VGPU_TYPE ,
427+ 'instances' : 8 ,
428+ })
417429 if not skip_capability :
418430 capability = self .cap_templ % {
419431 'cap_type' : MDEV_CAPABLE_CAP_TYPE ,
@@ -457,7 +469,8 @@ class HostPCIDevicesInfo(object):
457469 TOTAL_NUMA_NODES = 2
458470
459471 def __init__ (self , num_pci = 0 , num_pfs = 2 , num_vfs = 8 , num_mdevcap = 0 ,
460- numa_node = None , multiple_gpu_types = False ):
472+ numa_node = None , multiple_gpu_types = False ,
473+ generic_types = False ):
461474 """Create a new HostPCIDevicesInfo object.
462475
463476 :param num_pci: (int) The number of (non-SR-IOV) and (non-MDEV capable)
@@ -470,6 +483,7 @@ def __init__(self, num_pci=0, num_pfs=2, num_vfs=8, num_mdevcap=0,
470483 devices will be assigned to the specified node else they will be
471484 split between ``$TOTAL_NUMA_NODES`` nodes.
472485 :param multiple_gpu_types: (bool) Supports different vGPU types
486+ :param generic_types: (bool) Supports both nvidia-12 and mlx5 types
473487 """
474488 self .devices = {}
475489
@@ -509,7 +523,8 @@ def __init__(self, num_pci=0, num_pfs=2, num_vfs=8, num_mdevcap=0,
509523 function = function ,
510524 iommu_group = iommu_group ,
511525 numa_node = self ._calc_numa_node (dev , numa_node ),
512- multiple_gpu_types = multiple_gpu_types )
526+ multiple_gpu_types = multiple_gpu_types ,
527+ generic_types = generic_types )
513528
514529 slot += 1
515530 iommu_group += 1
@@ -555,9 +570,9 @@ def __init__(self, num_pci=0, num_pfs=2, num_vfs=8, num_mdevcap=0,
555570
556571 def add_device (
557572 self , dev_type , bus , slot , function , iommu_group , numa_node ,
558- vf_ratio = None , multiple_gpu_types = False , parent = None ,
559- vend_id = None , vend_name = None , prod_id = None , prod_name = None ,
560- driver_name = None ,
573+ vf_ratio = None , multiple_gpu_types = False , generic_types = False ,
574+ parent = None , vend_id = None , vend_name = None , prod_id = None ,
575+ prod_name = None , driver_name = None ,
561576 ):
562577 pci_dev_name = _get_libvirt_nodedev_name (bus , slot , function )
563578
@@ -572,6 +587,7 @@ def add_device(
572587 numa_node = numa_node ,
573588 vf_ratio = vf_ratio ,
574589 multiple_gpu_types = multiple_gpu_types ,
590+ generic_types = generic_types ,
575591 parent = parent ,
576592 vend_id = vend_id ,
577593 vend_name = vend_name ,
0 commit comments