On 12/9/2014 2:33 PM, Tetsuya Mukawa wrote: > The function tries to find a driver for the specified device, and then > close the driver. > > Signed-off-by: Tetsuya Mukawa <mukawa at igel.co.jp> > --- > lib/librte_eal/common/eal_common_pci.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_pci.c > b/lib/librte_eal/common/eal_common_pci.c > index 1e3efea..b404ee0 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -100,6 +100,7 @@ static struct rte_devargs *pci_devargs_lookup(struct > rte_pci_device *dev) > } > > #define INVOKE_PROBE (0) > +#define INVOKE_CLOSE (1) > > static int > pci_invoke_all_drivers(struct rte_pci_device *dev, int type) > @@ -112,6 +113,11 @@ pci_invoke_all_drivers(struct rte_pci_device *dev, int > type) > case INVOKE_PROBE: > rc = rte_eal_pci_probe_one_driver(dr, dev); > break; > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP) > + case INVOKE_CLOSE: > + rc = rte_eal_pci_close_one_driver(dr, dev); > + break; > +#endif
Here comments as below :) > } > if (rc < 0) > /* negative value is an error */ > @@ -135,6 +141,19 @@ pci_probe_all_drivers(struct rte_pci_device *dev) > return pci_invoke_all_drivers(dev, INVOKE_PROBE); > } > > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP) > +/* > + * If vendor/device ID match, call the devclose() function of all > + * registered driver for the given device. Return -1 if initialization > + * failed, return 1 if no driver is found for this device. > + */ > +static int > +pci_close_all_drivers(struct rte_pci_device *dev) > +{ > + return pci_invoke_all_drivers(dev, INVOKE_CLOSE); > +} > +#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */ If we do not just use #endif here, instead we could use: +#else +static inline int +pci_close_all_drivers(struct rte_pci_device *dev) { return -1; } +#endif Then we do not need to do macros check when calling this function. This could be apply to other patch in your patch set. But just as one advice. *__* Thomas, I don't know why *dpdk* has lots of "#if defined ---> #endif" within a function. It is so ugly, we can avoid this, and do it in header files. I just format on patch of vfio to avoid this. Since every place will do VFIO_PRESENT checking before calling pci_vfio_is_enabled(). I see one of Tetsuya's patch also do this check. Thanks, Michael > + > /* > * Scan the content of the PCI bus, and call the devinit() function for > * all registered drivers that have a matching entry in its id_table