From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 079EB2A9 for ; Tue, 9 Dec 2014 15:55:54 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 09 Dec 2014 06:54:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,545,1413270000"; d="scan'208";a="621014111" Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96]) by orsmga001.jf.intel.com with ESMTP; 09 Dec 2014 06:55:51 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by pgsmsx105.gar.corp.intel.com (10.221.44.96) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 9 Dec 2014 22:55:50 +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; Tue, 9 Dec 2014 22:55:50 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 13/28] eal/pci: Prevent double registration for devargs_list Thread-Index: AQHQE3n9W4x60Ozdg06wQaluKZ3z3A== Date: Tue, 9 Dec 2014 14:55:48 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E203@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-14-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 13/28] eal/pci: Prevent double registration for 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: Tue, 09 Dec 2014 14:55:55 -0000 On 2014/12/9 14:33, Tetsuya Mukawa wrote:=0A= > The patch fixes rte_eal_devargs_add() not to register same device twice.= =0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_common_devargs.c | 35 ++++++++++++++++++++++++= ++++++=0A= > 1 file changed, 35 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..f95a12d 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= > @@ -101,6 +130,12 @@ rte_eal_devargs_add(enum rte_devtype devtype, const = char *devargs_str)=0A= > break;=0A= > }=0A= > =0A= > + /* make sure there is no same entry */=0A= > + if (rte_eal_devargs_find(devtype, &devargs->pci.addr)) {=0A= =0A= Am I miss something? If devtype =3D=3D RTE_DEVTYPE_VIRTUAL, what will happe= n?=0A= =0A= Thanks,=0A= Michael=0A= > + RTE_LOG(ERR, EAL, "device already registered: <%s>\n", buf);=0A= > + return -1;=0A= > + }=0A= > +=0A= > TAILQ_INSERT_TAIL(&devargs_list, devargs, next);=0A= > return 0;=0A= > }=0A= =0A=