> Subject: Re: [PATCH v8 8/9] bus/pci: support Windows with bifurcated
> drivers
> 
> [snip]
> > +           /* kernel driver type is unsupported */
> > +           RTE_LOG(DEBUG, EAL,
> > +                   "kernel driver type for PCI device " PCI_PRI_FMT ","
> > +                   " is unsupported",
> 
> Nit: log messages usually start with a capital.
> 
> > +                   dev->addr.domain, dev->addr.bus,
> > +                   dev->addr.devid, dev->addr.function);
> > +           return -1;
> > +   }
> > +
> > +   return ERROR_SUCCESS;
> > +}
> [snip]
> > +static int
> > +pci_scan_one(HDEVINFO dev_info, PSP_DEVINFO_DATA
> device_info_data) {
> > +   struct rte_pci_device *dev;
> > +   int ret = -1;
> > +
> > +   dev = malloc(sizeof(*dev));
> > +   if (dev == NULL) {
> > +           goto end;
> > +   }
> 
> Braces not needed here. Checkpatch should've complained.
> 
> > +
> > +   memset(dev, 0, sizeof(*dev));
> > +
> > +   char  pci_device_info[PATH_MAX];
> > +   BOOL  res;
> > +   struct rte_pci_addr addr;
> > +   struct rte_pci_id pci_id;
> > +
> > +   /* Retrieve PCI device IDs */
> > +   res = SetupDiGetDeviceRegistryPropertyA(dev_info,
> device_info_data,
> > +                   SPDRP_HARDWAREID, NULL, (BYTE
> *)&pci_device_info,
> > +                   sizeof(pci_device_info), NULL);
> > +   if (!res) {
> > +           RTE_LOG_WIN32_ERR(
> > +
>       "SetupDiGetDeviceRegistryPropertyA(SPDRP_HARDWAREID)");
> > +           goto end;
> > +   }
> > +
> > +   ret = get_pci_hardware_info((const char *)&pci_device_info,
> > +&pci_id);
> 
> What do you think of calling SetupDiGetDeviceRegistryPropertyA from
> get_pci_hardware_info (like other functions in this file work) and renaming
> the latter to something like get_device_pci_id (for what it exactly does)?
> Current get_pci_hardware_info may become parse_pci_id static helper.
> 

Agree, will modify to get_pci_hardware_id and parse_pci_hardware_id in v9
with the rest of your comments.

> [snip]
> > @@ -165,5 +366,44 @@ pci_uio_remap_resource(struct rte_pci_device
> *dev
> > __rte_unused)  int
> >  rte_pci_scan(void)
> >  {
> > +   int   ret = -1;
> > +   DWORD device_index = 0, found_device = 0;
> > +   HDEVINFO dev_info;
> > +   SP_DEVINFO_DATA device_info_data;
> > +
> > +   /* for debug purposes, PCI can be disabled */
> > +   if (!rte_eal_has_pci())
> > +           return 0;
> > +
> > +   dev_info = SetupDiGetClassDevs(&GUID_DEVCLASS_NET,
> TEXT("PCI"), NULL,
> > +                           DIGCF_PRESENT);
> > +   if (dev_info == INVALID_HANDLE_VALUE) {
> > +           RTE_LOG_WIN32_ERR("SetupDiGetClassDevs(pci_scan)");
> > +           RTE_LOG(ERR, EAL, "Unable to enumerate PCI devices.\n");
> > +           goto end;
> > +   }
> > +
> > +   device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
> > +   device_index = 0;
> > +
> > +   while (SetupDiEnumDeviceInfo(dev_info, device_index,
> > +       &device_info_data)) {
> > +           device_index++;
> > +           ret = pci_scan_one(dev_info, &device_info_data);
> > +           if (ret == ERROR_SUCCESS)
> > +                   found_device++;
> > +           else if (ret != ERROR_CONTINUE)
> > +                   goto end;
> > +
> > +           memset(&device_info_data, 0, sizeof(SP_DEVINFO_DATA));
> > +           device_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
> > +   }
> > +
> > +   RTE_LOG(DEBUG, EAL, "PCI scan found %lu devices\n",
> found_device);
> >     return 0;
> 
> "dev_info" leaks here.
> 
> > +end:
> > +   if (dev_info != INVALID_HANDLE_VALUE)
> > +           SetupDiDestroyDeviceInfoList(dev_info);
> > +
> > +   return ret;
> >  }
> [snip]
> 
> --
> Dmitry Kozlyuk

Reply via email to