From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4D5C56A87 for ; Thu, 11 Dec 2014 06:24:06 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 10 Dec 2014 21:24:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,555,1413270000"; d="scan'208";a="645867602" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2014 21:24:03 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 11 Dec 2014 13:24:02 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.182]) with mapi id 14.03.0195.001; Thu, 11 Dec 2014 13:24:00 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 22/28] eal/pci: Add pci_close_all_drivers Thread-Index: AQHQE3ocadcR3QefH0yXoQDFPH1RMw== Date: Thu, 11 Dec 2014 05:23:59 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9ECC3@SHSMSX101.ccr.corp.intel.com> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-23-git-send-email-mukawa@igel.co.jp> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "nakajima.yoshihiro@lab.ntt.co.jp" , "menrigh@brocade.com" , "masutani.hitoshi@lab.ntt.co.jp" Subject: Re: [dpdk-dev] [PATCH v3 22/28] eal/pci: Add pci_close_all_drivers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2014 05:24:07 -0000 On 12/9/2014 2:33 PM, Tetsuya Mukawa wrote:=0A= > The function tries to find a driver for the specified device, and then=0A= > close the driver.=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_common_pci.c | 19 +++++++++++++++++++=0A= > 1 file changed, 19 insertions(+)=0A= >=0A= > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/comm= on/eal_common_pci.c=0A= > index 1e3efea..b404ee0 100644=0A= > --- a/lib/librte_eal/common/eal_common_pci.c=0A= > +++ b/lib/librte_eal/common/eal_common_pci.c=0A= > @@ -100,6 +100,7 @@ static struct rte_devargs *pci_devargs_lookup(struct = rte_pci_device *dev)=0A= > }=0A= > =0A= > #define INVOKE_PROBE (0)=0A= > +#define INVOKE_CLOSE (1)=0A= > =0A= > static int=0A= > pci_invoke_all_drivers(struct rte_pci_device *dev, int type)=0A= > @@ -112,6 +113,11 @@ pci_invoke_all_drivers(struct rte_pci_device *dev, i= nt type)=0A= > case INVOKE_PROBE:=0A= > rc =3D rte_eal_pci_probe_one_driver(dr, dev);=0A= > break;=0A= > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)= =0A= > + case INVOKE_CLOSE:=0A= > + rc =3D rte_eal_pci_close_one_driver(dr, dev);=0A= > + break;=0A= > +#endif=0A= =0A= Here comments as below :)=0A= > }=0A= > if (rc < 0)=0A= > /* negative value is an error */=0A= > @@ -135,6 +141,19 @@ pci_probe_all_drivers(struct rte_pci_device *dev)=0A= > return pci_invoke_all_drivers(dev, INVOKE_PROBE);=0A= > }=0A= > =0A= > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)= =0A= > +/*=0A= > + * If vendor/device ID match, call the devclose() function of all=0A= > + * registered driver for the given device. Return -1 if initialization= =0A= > + * failed, return 1 if no driver is found for this device.=0A= > + */=0A= > +static int=0A= > +pci_close_all_drivers(struct rte_pci_device *dev)=0A= > +{=0A= > + return pci_invoke_all_drivers(dev, INVOKE_CLOSE);=0A= > +}=0A= > +#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */=0A= =0A= If we do not just use #endif here, instead we could use:=0A= +#else=0A= +static inline int=0A= +pci_close_all_drivers(struct rte_pci_device *dev) { return -1; }=0A= +#endif=0A= =0A= Then we do not need to do macros check when calling this function.=0A= This could be apply to other patch in your patch set.=0A= =0A= But just as one advice.=0A= =0A= *__*=0A= =0A= Thomas,=0A= =0A= I don't know why *dpdk* has lots of "#if defined ---> #endif" within a=0A= function. It is so ugly, we can avoid this, and do it in header files.=0A= =0A= I just format on patch of vfio to avoid this. Since every place will do=0A= VFIO_PRESENT checking before calling pci_vfio_is_enabled().=0A= I see one of Tetsuya's patch also do this check.=0A= =0A= Thanks,=0A= Michael=0A= > +=0A= > /*=0A= > * Scan the content of the PCI bus, and call the devinit() function for= =0A= > * all registered drivers that have a matching entry in its id_table=0A= =0A=