@@ -387,6 +387,69 @@ func TestScan(t *testing.T) {
387387 maxDevNum : 1 ,
388388 expectedDevNum : 1 ,
389389 },
390+ {
391+ name : "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), PF with dc capabilities" ,
392+ dpdkDriver : "vfio-pci" ,
393+ kernelVfDrivers : []string {"4xxxvf" },
394+ dirs : []string {
395+ "sys/bus/pci/drivers/4xxx" ,
396+ "sys/bus/pci/drivers/vfio-pci" ,
397+ "sys/devices/pci0000:02/0000:02:00.0" ,
398+ "sys/kernel/debug/qat_4xxx_0000:02:00.0" ,
399+ "sys/bus/pci/devices/0000:02:01.0" ,
400+ },
401+ files : map [string ][]byte {
402+ "sys/devices/pci0000:02/0000:02:00.0/device" : []byte ("0x4940" ),
403+ "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = dc" ),
404+ "sys/bus/pci/devices/0000:02:01.0/device" : []byte ("0x4941" ),
405+ },
406+ symlinks : map [string ]string {
407+ "sys/bus/pci/devices/0000:02:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile" ,
408+ "sys/bus/pci/devices/0000:02:01.0/physfn" : "sys/devices/pci0000:02/0000:02:00.0" ,
409+ "sys/bus/pci/drivers/4xxx/0000:02:00.0" : "sys/devices/pci0000:02/0000:02:00.0" ,
410+ "sys/bus/pci/devices/0000:02:00.0" : "sys/devices/pci0000:02/0000:02:00.0" ,
411+ "sys/devices/pci0000:02/0000:02:00.0/virtfn0" : "sys/bus/pci/devices/0000:02:01.0" ,
412+ },
413+ maxDevNum : 1 ,
414+ expectedDevNum : 1 ,
415+ },
416+ {
417+ name : "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), two PFs with dc and cy capabilities" ,
418+ dpdkDriver : "vfio-pci" ,
419+ kernelVfDrivers : []string {"4xxxvf" },
420+ dirs : []string {
421+ "sys/bus/pci/drivers/4xxx" ,
422+ "sys/bus/pci/drivers/vfio-pci" ,
423+ "sys/devices/pci0000:02/0000:02:00.0" ,
424+ "sys/devices/pci0000:03/0000:03:00.0" ,
425+ "sys/kernel/debug/qat_4xxx_0000:02:00.0" ,
426+ "sys/kernel/debug/qat_4xxx_0000:03:00.0" ,
427+ "sys/bus/pci/devices/0000:02:01.0" ,
428+ "sys/bus/pci/devices/0000:03:01.0" ,
429+ },
430+ files : map [string ][]byte {
431+ "sys/devices/pci0000:02/0000:02:00.0/device" : []byte ("0x4940" ),
432+ "sys/devices/pci0000:03/0000:03:00.0/device" : []byte ("0x4940" ),
433+ "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = dc" ),
434+ "sys/kernel/debug/qat_4xxx_0000:03:00.0/dev_cfg" : []byte ("[GENERAL]\n ServicesEnabled = sym;asym" ),
435+ "sys/bus/pci/devices/0000:02:01.0/device" : []byte ("0x4941" ),
436+ "sys/bus/pci/devices/0000:03:01.0/device" : []byte ("0x4941" ),
437+ },
438+ symlinks : map [string ]string {
439+ "sys/bus/pci/devices/0000:02:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile" ,
440+ "sys/bus/pci/devices/0000:03:01.0/iommu_group" : "sys/kernel/iommu_groups/vfiotestfile2" ,
441+ "sys/bus/pci/devices/0000:02:01.0/physfn" : "sys/devices/pci0000:02/0000:02:00.0" ,
442+ "sys/bus/pci/devices/0000:03:01.0/physfn" : "sys/devices/pci0000:03/0000:03:00.0" ,
443+ "sys/bus/pci/drivers/4xxx/0000:02:00.0" : "sys/devices/pci0000:02/0000:02:00.0" ,
444+ "sys/bus/pci/drivers/4xxx/0000:03:00.0" : "sys/devices/pci0000:03/0000:03:00.0" ,
445+ "sys/bus/pci/devices/0000:02:00.0" : "sys/devices/pci0000:02/0000:02:00.0" ,
446+ "sys/bus/pci/devices/0000:03:00.0" : "sys/devices/pci0000:03/0000:03:00.0" ,
447+ "sys/devices/pci0000:02/0000:02:00.0/virtfn0" : "sys/bus/pci/devices/0000:02:01.0" ,
448+ "sys/devices/pci0000:03/0000:03:00.0/virtfn0" : "sys/bus/pci/devices/0000:03:01.0" ,
449+ },
450+ maxDevNum : 2 ,
451+ expectedDevNum : 2 ,
452+ },
390453 }
391454 for _ , tt := range tcases {
392455 t .Run (tt .name , func (t * testing.T ) {
@@ -419,8 +482,12 @@ func TestScan(t *testing.T) {
419482 if ! tt .expectedErr && err != nil {
420483 t .Errorf ("got unexpected error: %+v" , err )
421484 }
422- if len (fN .tree ["generic" ]) != tt .expectedDevNum {
423- t .Errorf ("expected %d, but got %d devices" , tt .expectedDevNum , len (fN .tree ["generic" ]))
485+ devNum := 0
486+ for _ , resource := range fN .tree {
487+ devNum = devNum + len (resource )
488+ }
489+ if devNum != tt .expectedDevNum {
490+ t .Errorf ("expected %d, but got %d devices" , tt .expectedDevNum , devNum )
424491 }
425492
426493 if err = os .RemoveAll (tmpdir ); err != nil {
0 commit comments