bus/pci: support allow/block lists on Windows
authorKhoa To <khot@microsoft.com>
Mon, 1 Mar 2021 06:52:41 +0000 (22:52 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 16 Mar 2021 21:27:25 +0000 (22:27 +0100)
EAL -a and -b options are used to specify which PCI devices are
explicitly allowed or blocked during PCI bus scan.  This evaluation
is missing in the Windows implementation of rte_pci_scan.

This patch provides this missing functionality, so that apps can specify
which devices to ignore during PCI bus scan.

Signed-off-by: Khoa To <khot@microsoft.com>
Acked-by: Ranjit Menon <ranjit.menon@intel.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
drivers/bus/pci/windows/pci.c

index 2237bdf..8f90609 100644 (file)
@@ -331,17 +331,24 @@ set_kernel_driver_type(PSP_DEVINFO_DATA device_info_data,
 static int
 pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
 {
-       struct rte_pci_device *dev;
+       struct rte_pci_device *dev = NULL;
        int ret = -1;
        char  pci_device_info[REGSTR_VAL_MAX_HCID_LEN];
        struct rte_pci_addr addr;
        struct rte_pci_id pci_id;
 
-       dev = malloc(sizeof(*dev));
-       if (dev == NULL)
+       ret = get_device_pci_address(dev_info, device_info_data, &addr);
+       if (ret != 0)
                goto end;
 
-       memset(dev, 0, sizeof(*dev));
+       if (rte_pci_ignore_device(&addr)) {
+               /*
+                * We won't add this device, but we want to continue
+                * looking for supported devices
+                */
+               ret = ERROR_CONTINUE;
+               goto end;
+       }
 
        ret = get_pci_hardware_id(dev_info, device_info_data,
                pci_device_info, sizeof(pci_device_info));
@@ -358,10 +365,12 @@ pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA device_info_data)
                goto end;
        }
 
-       ret = get_device_pci_address(dev_info, device_info_data, &addr);
-       if (ret != 0)
+       dev = malloc(sizeof(*dev));
+       if (dev == NULL)
                goto end;
 
+       memset(dev, 0, sizeof(*dev));
+
        dev->device.bus = &rte_pci_bus.bus;
        dev->addr = addr;
        dev->id = pci_id;
@@ -441,7 +450,7 @@ rte_pci_scan(void)
                device_index++;
                /* we only want to enumerate net & netuio class devices */
                if (IsEqualGUID(&(device_info_data.ClassGuid),
-                   &GUID_DEVCLASS_NET) ||
+                           &GUID_DEVCLASS_NET) ||
                        IsEqualGUID(&(device_info_data.ClassGuid),
                            &GUID_DEVCLASS_NETUIO)) {
                        ret = pci_scan_one(dev_info, &device_info_data);