|
1 | | -// Copyright 2018 Intel Corporation. All Rights Reserved. |
| 1 | +// Copyright 2018-2022 Intel Corporation. All Rights Reserved. |
2 | 2 | // |
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | // you may not use this file except in compliance with the License. |
@@ -428,6 +428,69 @@ func TestScan(t *testing.T) { |
428 | 428 | maxDevNum: 1, |
429 | 429 | expectedDevNum: 1, |
430 | 430 | }, |
| 431 | + { |
| 432 | + name: "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), PF with dc capabilities", |
| 433 | + dpdkDriver: "vfio-pci", |
| 434 | + kernelVfDrivers: []string{"4xxxvf"}, |
| 435 | + dirs: []string{ |
| 436 | + "sys/bus/pci/drivers/4xxx", |
| 437 | + "sys/bus/pci/drivers/vfio-pci", |
| 438 | + "sys/devices/pci0000:02/0000:02:00.0", |
| 439 | + "sys/kernel/debug/qat_4xxx_0000:02:00.0", |
| 440 | + "sys/bus/pci/devices/0000:02:01.0", |
| 441 | + }, |
| 442 | + files: map[string][]byte{ |
| 443 | + "sys/devices/pci0000:02/0000:02:00.0/device": []byte("0x4940"), |
| 444 | + "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg": []byte("[GENERAL]\nServicesEnabled = dc"), |
| 445 | + "sys/bus/pci/devices/0000:02:01.0/device": []byte("0x4941"), |
| 446 | + }, |
| 447 | + symlinks: map[string]string{ |
| 448 | + "sys/bus/pci/devices/0000:02:01.0/iommu_group": "sys/kernel/iommu_groups/vfiotestfile", |
| 449 | + "sys/bus/pci/devices/0000:02:01.0/physfn": "sys/devices/pci0000:02/0000:02:00.0", |
| 450 | + "sys/bus/pci/drivers/4xxx/0000:02:00.0": "sys/devices/pci0000:02/0000:02:00.0", |
| 451 | + "sys/bus/pci/devices/0000:02:00.0": "sys/devices/pci0000:02/0000:02:00.0", |
| 452 | + "sys/devices/pci0000:02/0000:02:00.0/virtfn0": "sys/bus/pci/devices/0000:02:01.0", |
| 453 | + }, |
| 454 | + maxDevNum: 1, |
| 455 | + expectedDevNum: 1, |
| 456 | + }, |
| 457 | + { |
| 458 | + name: "vfio-pci DPDKdriver with no kernel bound driver and where vfdevID is equal to qatDevId (4941), two PFs with dc and cy capabilities", |
| 459 | + dpdkDriver: "vfio-pci", |
| 460 | + kernelVfDrivers: []string{"4xxxvf"}, |
| 461 | + dirs: []string{ |
| 462 | + "sys/bus/pci/drivers/4xxx", |
| 463 | + "sys/bus/pci/drivers/vfio-pci", |
| 464 | + "sys/devices/pci0000:02/0000:02:00.0", |
| 465 | + "sys/devices/pci0000:03/0000:03:00.0", |
| 466 | + "sys/kernel/debug/qat_4xxx_0000:02:00.0", |
| 467 | + "sys/kernel/debug/qat_4xxx_0000:03:00.0", |
| 468 | + "sys/bus/pci/devices/0000:02:01.0", |
| 469 | + "sys/bus/pci/devices/0000:03:01.0", |
| 470 | + }, |
| 471 | + files: map[string][]byte{ |
| 472 | + "sys/devices/pci0000:02/0000:02:00.0/device": []byte("0x4940"), |
| 473 | + "sys/devices/pci0000:03/0000:03:00.0/device": []byte("0x4940"), |
| 474 | + "sys/kernel/debug/qat_4xxx_0000:02:00.0/dev_cfg": []byte("[GENERAL]\nServicesEnabled = dc"), |
| 475 | + "sys/kernel/debug/qat_4xxx_0000:03:00.0/dev_cfg": []byte("[GENERAL]\nServicesEnabled = sym;asym"), |
| 476 | + "sys/bus/pci/devices/0000:02:01.0/device": []byte("0x4941"), |
| 477 | + "sys/bus/pci/devices/0000:03:01.0/device": []byte("0x4941"), |
| 478 | + }, |
| 479 | + symlinks: map[string]string{ |
| 480 | + "sys/bus/pci/devices/0000:02:01.0/iommu_group": "sys/kernel/iommu_groups/vfiotestfile", |
| 481 | + "sys/bus/pci/devices/0000:03:01.0/iommu_group": "sys/kernel/iommu_groups/vfiotestfile2", |
| 482 | + "sys/bus/pci/devices/0000:02:01.0/physfn": "sys/devices/pci0000:02/0000:02:00.0", |
| 483 | + "sys/bus/pci/devices/0000:03:01.0/physfn": "sys/devices/pci0000:03/0000:03:00.0", |
| 484 | + "sys/bus/pci/drivers/4xxx/0000:02:00.0": "sys/devices/pci0000:02/0000:02:00.0", |
| 485 | + "sys/bus/pci/drivers/4xxx/0000:03:00.0": "sys/devices/pci0000:03/0000:03:00.0", |
| 486 | + "sys/bus/pci/devices/0000:02:00.0": "sys/devices/pci0000:02/0000:02:00.0", |
| 487 | + "sys/bus/pci/devices/0000:03:00.0": "sys/devices/pci0000:03/0000:03:00.0", |
| 488 | + "sys/devices/pci0000:02/0000:02:00.0/virtfn0": "sys/bus/pci/devices/0000:02:01.0", |
| 489 | + "sys/devices/pci0000:03/0000:03:00.0/virtfn0": "sys/bus/pci/devices/0000:03:01.0", |
| 490 | + }, |
| 491 | + maxDevNum: 2, |
| 492 | + expectedDevNum: 2, |
| 493 | + }, |
431 | 494 | } |
432 | 495 | for _, tt := range tcases { |
433 | 496 | t.Run(tt.name, func(t *testing.T) { |
@@ -461,8 +524,12 @@ func TestScan(t *testing.T) { |
461 | 524 | if !tt.expectedErr && err != nil { |
462 | 525 | t.Errorf("got unexpected error: %+v", err) |
463 | 526 | } |
464 | | - if len(fN.tree["generic"]) != tt.expectedDevNum { |
465 | | - t.Errorf("expected %d, but got %d devices", tt.expectedDevNum, len(fN.tree["generic"])) |
| 527 | + devNum := 0 |
| 528 | + for _, resource := range fN.tree { |
| 529 | + devNum = devNum + len(resource) |
| 530 | + } |
| 531 | + if devNum != tt.expectedDevNum { |
| 532 | + t.Errorf("expected %d, but got %d devices", tt.expectedDevNum, devNum) |
466 | 533 | } |
467 | 534 |
|
468 | 535 | if err = os.RemoveAll(tmpdir); err != nil { |
|
0 commit comments