From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C277F1288 for ; Wed, 21 Jan 2015 03:55:28 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 20 Jan 2015 18:49:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,439,1418112000"; d="scan'208";a="664992479" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by fmsmga002.fm.intel.com with ESMTP; 20 Jan 2015 18:55:26 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 21 Jan 2015 10:55:25 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.64]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.192]) with mapi id 14.03.0195.001; Wed, 21 Jan 2015 10:55:24 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 07/11] eal/pci: Add a function to remove the entry of devargs list Thread-Index: AQHQM9SlnlP92h18yUWNX+QWCzyfqw== Date: Wed, 21 Jan 2015 02:55:24 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286CB7F7B@SHSMSX101.ccr.corp.intel.com> References: <1418106629-22227-2-git-send-email-mukawa@igel.co.j> <1421664027-17971-1-git-send-email-mukawa@igel.co.jp> <1421664027-17971-8-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 Subject: Re: [dpdk-dev] [PATCH v4 07/11] eal/pci: Add a function to remove the entry of devargs list 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: Wed, 21 Jan 2015 02:55:29 -0000 On 1/19/2015 6:42 PM, Tetsuya Mukawa wrote:=0A= > The function removes the specified devargs entry from devargs_list.=0A= > Also the patch adds sanity checking to rte_eal_devargs_add().=0A= >=0A= > v4:=0A= > - Fix sanity check code=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_common_devargs.c | 57 +++++++++++++++++++++++= ++++++=0A= > lib/librte_eal/common/include/rte_devargs.h | 18 +++++++++=0A= > 2 files changed, 75 insertions(+)=0A= >=0A= > diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/= common/eal_common_devargs.c=0A= > index 4c7d11a..a360a85 100644=0A= > --- a/lib/librte_eal/common/eal_common_devargs.c=0A= > +++ b/lib/librte_eal/common/eal_common_devargs.c=0A= > @@ -44,6 +44,35 @@=0A= > struct rte_devargs_list devargs_list =3D=0A= > TAILQ_HEAD_INITIALIZER(devargs_list);=0A= > =0A= > +=0A= > +/* find a entry specified by pci address or device name */=0A= > +static struct rte_devargs *=0A= > +rte_eal_devargs_find(enum rte_devtype devtype, void *args)=0A= > +{=0A= > + struct rte_devargs *devargs;=0A= > +=0A= > + if (args =3D=3D NULL)=0A= > + return NULL;=0A= > +=0A= > + TAILQ_FOREACH(devargs, &devargs_list, next) {=0A= > + switch (devtype) {=0A= > + case RTE_DEVTYPE_WHITELISTED_PCI:=0A= > + case RTE_DEVTYPE_BLACKLISTED_PCI:=0A= > + if (eal_compare_pci_addr(&devargs->pci.addr, args) =3D=3D 0)=0A= > + goto found;=0A= > + break;=0A= > + case RTE_DEVTYPE_VIRTUAL:=0A= > + if (memcmp(&devargs->virtual.drv_name, args,=0A= > + strlen((char *)args)) =3D=3D 0)=0A= > + goto found;=0A= > + break;=0A= > + }=0A= > + }=0A= > + return NULL;=0A= > +found:=0A= > + return devargs;=0A= > +}=0A= > +=0A= > /* store a whitelist parameter for later parsing */=0A= > int=0A= > rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str)= =0A= > @@ -87,6 +116,12 @@ rte_eal_devargs_add(enum rte_devtype devtype, const c= har *devargs_str)=0A= > free(devargs);=0A= > return -1;=0A= > }=0A= > + /* make sure there is no same entry */=0A= > + if (rte_eal_devargs_find(devtype, &devargs->pci.addr)) {=0A= > + RTE_LOG(ERR, EAL,=0A= > + "device already registered: <%s>\n", buf);=0A= > + return -1;=0A= > + }=0A= > break;=0A= > case RTE_DEVTYPE_VIRTUAL:=0A= > /* save driver name */=0A= > @@ -98,6 +133,12 @@ rte_eal_devargs_add(enum rte_devtype devtype, const c= har *devargs_str)=0A= > free(devargs);=0A= > return -1;=0A= > }=0A= > + /* make sure there is no same entry */=0A= > + if (rte_eal_devargs_find(devtype, &devargs->virtual.drv_name)) {=0A= > + RTE_LOG(ERR, EAL,=0A= > + "device already registered: <%s>\n", buf);=0A= > + return -1;=0A= > + }=0A= > break;=0A= > }=0A= > =0A= > @@ -105,6 +146,22 @@ rte_eal_devargs_add(enum rte_devtype devtype, const = char *devargs_str)=0A= > return 0;=0A= > }=0A= > =0A= > +/* remove it from the devargs_list */=0A= > +void=0A= > +rte_eal_devargs_remove(enum rte_devtype devtype, void *args)=0A= > +{=0A= > + struct rte_devargs *devargs;=0A= > +=0A= > + if (args =3D=3D NULL)=0A= > + return;=0A= > +=0A= > + devargs =3D rte_eal_devargs_find(devtype, args);=0A= > + if (devargs =3D=3D NULL)=0A= =0A= If devargs =3D=3D NULL, means not found, does it reasonable to ignore? Som= e=0A= error happens I think, at least you should print out some logs.=0A= =0A= Thanks,=0A= Michael=0A= > + return;=0A= > +=0A= > + TAILQ_REMOVE(&devargs_list, devargs, next);=0A= > +}=0A= > +=0A= > /* count the number of devices of a specified type */=0A= > unsigned int=0A= > rte_eal_devargs_type_count(enum rte_devtype devtype)=0A= > diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal= /common/include/rte_devargs.h=0A= > index 9f9c98f..1066efd 100644=0A= > --- a/lib/librte_eal/common/include/rte_devargs.h=0A= > +++ b/lib/librte_eal/common/include/rte_devargs.h=0A= > @@ -123,6 +123,24 @@ extern struct rte_devargs_list devargs_list;=0A= > int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_st= r);=0A= > =0A= > /**=0A= > + * Remove a device from the user device list=0A= > + *=0A= > + * For PCI devices, the format of arguments string is "PCI_ADDR". It sho= uldn't=0A= > + * involves parameters for the device. Example: "08:00.1".=0A= > + *=0A= > + * For virtual devices, the format of arguments string is "DRIVER_NAME*"= . It=0A= > + * shouldn't involves parameters for the device. Example: "eth_ring". Th= e=0A= > + * validity of the driver name is not checked by this function, it is do= ne=0A= > + * when closing the drivers.=0A= > + *=0A= > + * @param devtype=0A= > + * The type of the device.=0A= > + * @param name=0A= > + * The name of the device.=0A= > + */=0A= > +void rte_eal_devargs_remove(enum rte_devtype devtype, void *args);=0A= > +=0A= > +/**=0A= > * Count the number of user devices of a specified type=0A= > *=0A= > * @param devtype=0A= =0A=