@@ -232,9 +232,10 @@ def _reset():
232
232
233
233
NVIDIA_11_VGPU_TYPE = 'nvidia-11'
234
234
NVIDIA_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'
238
239
239
240
os_uname = collections .namedtuple (
240
241
'uname_result' , ['sysname' , 'nodename' , 'release' , 'version' , 'machine' ],
@@ -296,9 +297,9 @@ class FakePCIDevice(object):
296
297
297
298
def __init__ (
298
299
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 ,
302
303
):
303
304
"""Populate pci devices
304
305
@@ -312,6 +313,7 @@ def __init__(
312
313
:param vf_ratio: (int) Ratio of Virtual Functions on Physical. Only
313
314
applicable if ``dev_type`` is one of: ``PF``, ``VF``.
314
315
:param multiple_gpu_types: (bool) Supports different vGPU types.
316
+ :param generic_types: (bool) Support both mlx5 and nvidia-12 types.
315
317
:param parent: (int, int, int) A tuple of bus, slot and function
316
318
corresponding to the parent.
317
319
:param vend_id: (str) The vendor ID.
@@ -329,6 +331,7 @@ def __init__(
329
331
self .numa_node = numa_node
330
332
self .vf_ratio = vf_ratio
331
333
self .multiple_gpu_types = multiple_gpu_types
334
+ self .generic_types = generic_types
332
335
self .parent = parent
333
336
334
337
self .vend_id = vend_id
@@ -414,6 +417,15 @@ def generate_xml(self, skip_capability=False):
414
417
'type_id' : NVIDIA_12_VGPU_TYPE ,
415
418
'instances' : 8 ,
416
419
})
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
+ })
417
429
if not skip_capability :
418
430
capability = self .cap_templ % {
419
431
'cap_type' : MDEV_CAPABLE_CAP_TYPE ,
@@ -457,7 +469,8 @@ class HostPCIDevicesInfo(object):
457
469
TOTAL_NUMA_NODES = 2
458
470
459
471
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 ):
461
474
"""Create a new HostPCIDevicesInfo object.
462
475
463
476
: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,
470
483
devices will be assigned to the specified node else they will be
471
484
split between ``$TOTAL_NUMA_NODES`` nodes.
472
485
:param multiple_gpu_types: (bool) Supports different vGPU types
486
+ :param generic_types: (bool) Supports both nvidia-12 and mlx5 types
473
487
"""
474
488
self .devices = {}
475
489
@@ -509,7 +523,8 @@ def __init__(self, num_pci=0, num_pfs=2, num_vfs=8, num_mdevcap=0,
509
523
function = function ,
510
524
iommu_group = iommu_group ,
511
525
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 )
513
528
514
529
slot += 1
515
530
iommu_group += 1
@@ -555,9 +570,9 @@ def __init__(self, num_pci=0, num_pfs=2, num_vfs=8, num_mdevcap=0,
555
570
556
571
def add_device (
557
572
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 ,
561
576
):
562
577
pci_dev_name = _get_libvirt_nodedev_name (bus , slot , function )
563
578
@@ -572,6 +587,7 @@ def add_device(
572
587
numa_node = numa_node ,
573
588
vf_ratio = vf_ratio ,
574
589
multiple_gpu_types = multiple_gpu_types ,
590
+ generic_types = generic_types ,
575
591
parent = parent ,
576
592
vend_id = vend_id ,
577
593
vend_name = vend_name ,
0 commit comments