From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9C7BD3F9 for ; Thu, 11 Dec 2014 04:43:13 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 10 Dec 2014 19:41:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,555,1413270000"; d="scan'208";a="651995856" Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96]) by orsmga002.jf.intel.com with ESMTP; 10 Dec 2014 19:43:10 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by pgsmsx105.gar.corp.intel.com (10.221.44.96) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 11 Dec 2014 11:41:08 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by shsmsx102.ccr.corp.intel.com ([169.254.2.216]) with mapi id 14.03.0195.001; Thu, 11 Dec 2014 11:41:07 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 20/28] eal/pci: Add rte_eal_pci_close_one_driver Thread-Index: AQHQE3oTWCnEJLC/aE+T0P5g9WM5kw== Date: Thu, 11 Dec 2014 03:41:06 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9EC20@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-21-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 20/28] eal/pci: Add rte_eal_pci_close_one_driver 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 03:43:14 -0000 On 12/9/2014 2:33 PM, Tetsuya Mukawa wrote:=0A= > The function is used for closing the specified driver and device.=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_private.h | 15 +++++++++=0A= > lib/librte_eal/linuxapp/eal/eal_pci.c | 61 +++++++++++++++++++++++++++++= ++++++=0A= > 2 files changed, 76 insertions(+)=0A= >=0A= > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/= eal_private.h=0A= > index a1127ab..f892ac4 100644=0A= > --- a/lib/librte_eal/common/eal_private.h=0A= > +++ b/lib/librte_eal/common/eal_private.h=0A= > @@ -176,6 +176,21 @@ int rte_eal_pci_probe_one_driver(struct rte_pci_driv= er *dr,=0A= > struct rte_pci_device *dev);=0A= > =0A= > /**=0A= > + * Munmap memory for single PCI device=0A= > + *=0A= > + * This function is private to EAL.=0A= > + *=0A= > + * @param dr=0A= > + * The pointer to the pci driver structure=0A= > + * @param dev=0A= > + * The pointer to the pci device structure=0A= > + * @return=0A= > + * 0 on success, negative on error=0A= > + */=0A= > +int rte_eal_pci_close_one_driver(struct rte_pci_driver *dr,=0A= > + struct rte_pci_device *dev);=0A= > +=0A= > +/**=0A= > * Init tail queues for non-EAL library structures. This is to allow=0A= > * the rings, mempools, etc. lists to be shared among multiple processes= =0A= > *=0A= > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linux= app/eal/eal_pci.c=0A= > index 8d683f5..93456f3 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > @@ -616,6 +616,67 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *= dr, struct rte_pci_device *d=0A= > return 1;=0A= > }=0A= > =0A= > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)= =0A= > +/*=0A= > + * If vendor/device ID match, call the devshutdown() function of the=0A= > + * driver.=0A= > + */=0A= > +int=0A= > +rte_eal_pci_close_one_driver(struct rte_pci_driver *dr,=0A= > + struct rte_pci_device *dev)=0A= > +{=0A= > + struct rte_pci_id *id_table;=0A= > +=0A= > + if ((dr =3D=3D NULL) || (dev =3D=3D NULL))=0A= > + return -EINVAL;=0A= > +=0A= > + for (id_table =3D dr->id_table ; id_table->vendor_id !=3D 0; id_table++= ) {=0A= > +=0A= > + /* check if device's identifiers match the driver's ones */=0A= > + if (id_table->vendor_id !=3D dev->id.vendor_id &&=0A= > + id_table->vendor_id !=3D PCI_ANY_ID)=0A= =0A= Here and below, it is better to make indentation like this:=0A= =0A= + if (id_table->vendor_id !=3D dev->id.vendor_id &&=0A= + id_table->vendor_id !=3D PCI_ANY_ID)=0A= =0A= But I don't know if there are any strict rule of dpdk community :)=0A= =0A= > + continue;=0A= > + if (id_table->device_id !=3D dev->id.device_id &&=0A= > + id_table->device_id !=3D PCI_ANY_ID)=0A= > + continue;=0A= > + if (id_table->subsystem_vendor_id !=3D=0A= > + dev->id.subsystem_vendor_id &&=0A= > + id_table->subsystem_vendor_id !=3D PCI_ANY_ID)=0A= > + continue;=0A= > + if (id_table->subsystem_device_id !=3D=0A= > + dev->id.subsystem_device_id &&=0A= > + id_table->subsystem_device_id !=3D PCI_ANY_ID)=0A= > + continue;=0A= > +=0A= > + struct rte_pci_addr *loc =3D &dev->addr;=0A= > +=0A= > + RTE_LOG(DEBUG, EAL,=0A= > + "PCI device "PCI_PRI_FMT" on NUMA socket %i\n",=0A= > + loc->domain, loc->bus, loc->devid,=0A= > + loc->function, dev->numa_node);=0A= > +=0A= > + RTE_LOG(DEBUG, EAL, " remove driver: %x:%x %s\n",=0A= > + dev->id.vendor_id, dev->id.device_id,=0A= > + dr->name);=0A= > +=0A= > + /* call the driver devshutdown() function */=0A= > + if (dr->devshutdown && (dr->devshutdown(dr, dev) < 0))=0A= > + return -1; /* negative value is an error */=0A= > +=0A= > + /* clear driver structure */=0A= > + dev->driver =3D NULL;=0A= > +=0A= > + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)=0A= > + /* unmap resources for devices that use igb_uio */=0A= > + pci_unmap_device(dev);=0A= > +=0A= > + return 0;=0A= > + }=0A= > + /* return positive value if driver is not found */=0A= > + return 1;=0A= > +}=0A= > +#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */=0A= > +=0A= > /* Init the PCI EAL subsystem */=0A= > int=0A= > rte_eal_pci_init(void)=0A= =0A=