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 0E8216A87 for ; Thu, 11 Dec 2014 06:54:28 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 10 Dec 2014 21:54:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,556,1413270000"; d="scan'208";a="645876338" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2014 21:54:25 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 11 Dec 2014 13:54:24 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001; Thu, 11 Dec 2014 13:54:23 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 23/28] eal/pci: Add rte_eal_pci_probe_one and rte_eal_pci_close_one Thread-Index: AQHQE3oedR9p/XOY2EWRUT0na+clAA== Date: Thu, 11 Dec 2014 05:54:22 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9ECE7@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-24-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" , "masutani.hitoshi@lab.ntt.co.jp" , "menrigh@brocade.com" Subject: Re: [dpdk-dev] [PATCH v3 23/28] eal/pci: Add rte_eal_pci_probe_one and rte_eal_pci_close_one 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:54:29 -0000 On 12/9/2014 2:34 PM, Tetsuya Mukawa wrote:=0A= > The functions are used for probe and close a device.=0A= > First the function tries to find a device that has the specfied PCI addre= ss.=0A= > Then, probe or close the device.=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_common_pci.c | 58 +++++++++++++++++++++++++++= ++++++=0A= > lib/librte_eal/common/include/rte_pci.h | 26 +++++++++++++++=0A= > 2 files changed, 84 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 b404ee0..5ff7b49 100644=0A= > --- a/lib/librte_eal/common/eal_common_pci.c=0A= > +++ b/lib/librte_eal/common/eal_common_pci.c=0A= > @@ -152,6 +152,64 @@ pci_close_all_drivers(struct rte_pci_device *dev)=0A= > {=0A= > return pci_invoke_all_drivers(dev, INVOKE_CLOSE);=0A= > }=0A= > +=0A= > +static int=0A= > +rte_eal_pci_invoke_one(struct rte_pci_addr *addr, int type)=0A= > +{=0A= > + struct rte_pci_device *dev =3D NULL;=0A= > + int ret =3D 0;=0A= > +=0A= > + TAILQ_FOREACH(dev, &pci_device_list, next) {=0A= > + if (eal_compare_pci_addr(&dev->addr, addr))=0A= > + continue;=0A= > +=0A= > + switch (type) {=0A= > + case INVOKE_PROBE:=0A= > + ret =3D pci_probe_all_drivers(dev);=0A= > + break;=0A= > + case INVOKE_CLOSE:=0A= > + ret =3D pci_close_all_drivers(dev);=0A= > + break;=0A= > + }=0A= > + if (ret < 0)=0A= > + goto invoke_err_return;=0A= > + if (type =3D=3D INVOKE_CLOSE)=0A= > + goto remove_dev;=0A= > + return 0;=0A= > + }=0A= > +=0A= > + return -1;=0A= > +=0A= > +invoke_err_return:=0A= > + RTE_LOG(WARNING, EAL, "Requested device " PCI_PRI_FMT=0A= > + " cannot be used\n", dev->addr.domain, dev->addr.bus,=0A= > + dev->addr.devid, dev->addr.function);=0A= > + return -1;=0A= > +=0A= > +remove_dev:=0A= > + TAILQ_REMOVE(&pci_device_list, dev, next);=0A= > + return 0;=0A= > +}=0A= > +=0A= > +/*=0A= > + * Find the pci device specified by pci address, then invoke probe funct= ion of=0A= > + * the driver of the devive.=0A= > + */=0A= > +int=0A= > +rte_eal_pci_probe_one(struct rte_pci_addr *addr)=0A= > +{=0A= > + return rte_eal_pci_invoke_one(addr, INVOKE_PROBE);=0A= > +}=0A= > +=0A= > +/*=0A= > + * Find the pci device specified by pci address, then invoke close funct= ion of=0A= > + * the driver of the devive.=0A= > + */=0A= > +int=0A= > +rte_eal_pci_close_one(struct rte_pci_addr *addr)=0A= > +{=0A= > + return rte_eal_pci_invoke_one(addr, INVOKE_CLOSE);=0A= > +}=0A= > #endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */=0A= > =0A= > /*=0A= > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/com= mon/include/rte_pci.h=0A= > index 74720d1..5a7e06f 100644=0A= > --- a/lib/librte_eal/common/include/rte_pci.h=0A= > +++ b/lib/librte_eal/common/include/rte_pci.h=0A= > @@ -311,6 +311,32 @@ eal_compare_pci_addr(struct rte_pci_addr *addr, stru= ct rte_pci_addr *addr2)=0A= > int rte_eal_pci_probe(void);=0A= > =0A= > /**=0A= > + * Probe the single PCI device.=0A= > + *=0A= > + * Scan the content of the PCI bus, and find the pci device specified by= pci=0A= > + * address, then call the probe() function for registered driver that ha= s a=0A= > + * matching entry in its id_table for discovered device.=0A= > + *=0A= > + * @return=0A= > + * - 0 on success.=0A= > + * - Negative on error.=0A= > + */=0A= > +int rte_eal_pci_probe_one(struct rte_pci_addr *addr);=0A= > +=0A= > +/**=0A= > + * Close the single PCI device.=0A= > + *=0A= > + * Scan the content of the PCI bus, and find the pci device specified by= pci=0A= > + * address, then call the close() function for registered driver that ha= s a=0A= > + * matching entry in its id_table for discovered device.=0A= > + *=0A= > + * @return=0A= > + * - 0 on success.=0A= > + * - Negative on error.=0A= > + */=0A= > +int rte_eal_pci_close_one(struct rte_pci_addr *addr);=0A= > +=0A= =0A= You declare here directly, but implement them with macros=0A= "RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP ".=0A= =0A= =0A= > +/**=0A= > * Dump the content of the PCI bus.=0A= > *=0A= > * @param f=0A= =0A=