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 485B12A9 for ; Tue, 9 Dec 2014 15:22:40 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 09 Dec 2014 06:21:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,545,1413270000"; d="scan'208";a="650950140" Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96]) by orsmga002.jf.intel.com with ESMTP; 09 Dec 2014 06:22:34 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) 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:22:32 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.67]) with mapi id 14.03.0195.001; Tue, 9 Dec 2014 22:22:32 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 03/28] eal/pci: Replace pci address comparison code by eal_compare_pci_addr Thread-Index: AQHQE3nrteqsLGTUzUWEk1Xyut6mMA== Date: Tue, 9 Dec 2014 14:22:31 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E1CB@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-4-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 03/28] eal/pci: Replace pci address comparison code by eal_compare_pci_addr 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:22:42 -0000 On 2014/12/9 14:32, Tetsuya Mukawa wrote:=0A= > This patch replaces pci_addr_comparison() and memcmp() of pci addresses b= y=0A= > eal_compare_pci_addr().=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/bsdapp/eal/eal_pci.c | 16 +---------------=0A= > lib/librte_eal/common/eal_common_pci.c | 2 +-=0A= > lib/librte_eal/common/include/rte_pci.h | 29 +++++++++++++++++++++++++= ++++=0A= > lib/librte_eal/linuxapp/eal/eal_pci.c | 16 +---------------=0A= > lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-=0A= > 5 files changed, 33 insertions(+), 32 deletions(-)=0A= >=0A= > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/= eal/eal_pci.c=0A= > index 74ecce7..7eda513 100644=0A= > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c=0A= > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c=0A= > @@ -270,20 +270,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)=0A= > return (0);=0A= > }=0A= > =0A= > -/* Compare two PCI device addresses. */=0A= > -static int=0A= > -pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr= 2)=0A= > -{=0A= > - uint64_t dev_addr =3D (addr->domain << 24) + (addr->bus << 16) + (addr-= >devid << 8) + addr->function;=0A= > - uint64_t dev_addr2 =3D (addr2->domain << 24) + (addr2->bus << 16) + (ad= dr2->devid << 8) + addr2->function;=0A= > -=0A= > - if (dev_addr > dev_addr2)=0A= > - return 1;=0A= > - else=0A= > - return 0;=0A= > -}=0A= > -=0A= > -=0A= > /* Scan one pci sysfs entry, and fill the devices list from it. */=0A= > static int=0A= > pci_scan_one(int dev_pci_fd, struct pci_conf *conf)=0A= > @@ -358,7 +344,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)= =0A= > struct rte_pci_device *dev2 =3D NULL;=0A= > =0A= > TAILQ_FOREACH(dev2, &pci_device_list, next) {=0A= > - if (pci_addr_comparison(&dev->addr, &dev2->addr))=0A= > + if (eal_compare_pci_addr(&dev->addr, &dev2->addr))=0A= > continue;=0A= > else {=0A= > TAILQ_INSERT_BEFORE(dev2, dev, next);=0A= > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/comm= on/eal_common_pci.c=0A= > index f3c7f71..f01f258 100644=0A= > --- a/lib/librte_eal/common/eal_common_pci.c=0A= > +++ b/lib/librte_eal/common/eal_common_pci.c=0A= > @@ -93,7 +93,7 @@ static struct rte_devargs *pci_devargs_lookup(struct rt= e_pci_device *dev)=0A= > if (devargs->type !=3D RTE_DEVTYPE_BLACKLISTED_PCI &&=0A= > devargs->type !=3D RTE_DEVTYPE_WHITELISTED_PCI)=0A= > continue;=0A= > - if (!memcmp(&dev->addr, &devargs->pci.addr, sizeof(dev->addr)))=0A= > + if (eal_compare_pci_addr(&dev->addr, &devargs->pci.addr))=0A= > return devargs;=0A= > }=0A= > return NULL;=0A= > diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/com= mon/include/rte_pci.h=0A= > index b819539..fe374a8 100644=0A= > --- a/lib/librte_eal/common/include/rte_pci.h=0A= > +++ b/lib/librte_eal/common/include/rte_pci.h=0A= > @@ -261,6 +261,35 @@ eal_parse_pci_DomBDF(const char *input, struct rte_p= ci_addr *dev_addr)=0A= > }=0A= > #undef GET_PCIADDR_FIELD=0A= > =0A= > +/* Compare two PCI device addresses. */=0A= > +/**=0A= > + * Utility function to compare two PCI device addresses.=0A= > + *=0A= > + * @param addr=0A= > + * The PCI Bus-Device-Function address to compare=0A= > + * @param addr2=0A= > + * The PCI Bus-Device-Function address to compare=0A= > + * @return=0A= > + * 0 on equal PCI address.=0A= > + * Positive on addr is greater than addr2.=0A= > + * Negative on addr is less than addr2.=0A= > + */=0A= > +static inline int=0A= > +eal_compare_pci_addr(struct rte_pci_addr *addr, struct rte_pci_addr *add= r2)=0A= > +{=0A= > + uint64_t dev_addr =3D (addr->domain << 24) + (addr->bus << 16) +=0A= > + (addr->devid << 8) + addr->function;=0A= > + uint64_t dev_addr2 =3D (addr2->domain << 24) + (addr2->bus << 16) +=0A= > + (addr2->devid << 8) + addr2->function;=0A= > +=0A= =0A= Here I prefer:=0A= =0A= uint64_t dev_addr =3D (addr->domain << 24) | (addr->bus << 16) | (addr->dev= id << 8) | addr->function;=0A= =0A= Thanks,=0A= Michael=0A= > + if (dev_addr > dev_addr2)=0A= > + return 1;=0A= > + else if (dev_addr < dev_addr2)=0A= > + return -1;=0A= > + else=0A= > + return 0;=0A= > +}=0A= > +=0A= > /**=0A= > * Probe the PCI bus for registered drivers.=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 b5f5410..23a69e9 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > @@ -200,20 +200,6 @@ error:=0A= > return -1;=0A= > }=0A= > =0A= > -/* Compare two PCI device addresses. */=0A= > -static int=0A= > -pci_addr_comparison(struct rte_pci_addr *addr, struct rte_pci_addr *addr= 2)=0A= > -{=0A= > - uint64_t dev_addr =3D (addr->domain << 24) + (addr->bus << 16) + (addr-= >devid << 8) + addr->function;=0A= > - uint64_t dev_addr2 =3D (addr2->domain << 24) + (addr2->bus << 16) + (ad= dr2->devid << 8) + addr2->function;=0A= > -=0A= > - if (dev_addr > dev_addr2)=0A= > - return 1;=0A= > - else=0A= > - return 0;=0A= > -}=0A= > -=0A= > -=0A= > /* Scan one pci sysfs entry, and fill the devices list from it. */=0A= > static int=0A= > pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,=0A= > @@ -306,7 +292,7 @@ pci_scan_one(const char *dirname, uint16_t domain, ui= nt8_t bus,=0A= > struct rte_pci_device *dev2 =3D NULL;=0A= > =0A= > TAILQ_FOREACH(dev2, &pci_device_list, next) {=0A= > - if (pci_addr_comparison(&dev->addr, &dev2->addr))=0A= > + if (eal_compare_pci_addr(&dev->addr, &dev2->addr) !=3D 0)=0A= > continue;=0A= > else {=0A= > TAILQ_INSERT_BEFORE(dev2, dev, next);=0A= > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/l= inuxapp/eal/eal_pci_uio.c=0A= > index e53f06b..1da3507 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c=0A= > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c=0A= > @@ -123,7 +123,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)=0A= > TAILQ_FOREACH(uio_res, pci_res_list, next) {=0A= > =0A= > /* skip this element if it doesn't match our PCI address */=0A= > - if (memcmp(&uio_res->pci_addr, &dev->addr, sizeof(dev->addr)))=0A= > + if (eal_compare_pci_addr(&uio_res->pci_addr, &dev->addr))=0A= > continue;=0A= > =0A= > for (i =3D 0; i !=3D uio_res->nb_maps; i++) {=0A= =0A=