From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 9EEC17E23 for ; Wed, 25 Mar 2015 16:27:17 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 25 Mar 2015 08:27:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,465,1422950400"; d="scan'208";a="697630107" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga002.fm.intel.com with ESMTP; 25 Mar 2015 08:27:04 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.49]) by IRSMSX109.ger.corp.intel.com ([163.33.3.23]) with mapi id 14.03.0224.002; Wed, 25 Mar 2015 15:27:04 +0000 From: "Iremonger, Bernard" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [PATCH v2 5/6] eal: Use map_idx in pci_uio_map_resource() of bsdapp to work same as linuxapp Thread-Index: AQHQZempdfACrMcb6U2GXKq/FCb7M50tU17A Date: Wed, 25 Mar 2015 15:27:04 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C204A0245E@IRSMSX108.ger.corp.intel.com> References: <1426584645-28828-7-git-send-email-mukawa@igel.co.jp> <1427170717-13879-1-git-send-email-mukawa@igel.co.jp> <1427170717-13879-6-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1427170717-13879-6-git-send-email-mukawa@igel.co.jp> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 5/6] eal: Use map_idx in pci_uio_map_resource() of bsdapp to work same as linuxapp 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, 25 Mar 2015 15:27:18 -0000 > -----Original Message----- > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp] > Sent: Tuesday, March 24, 2015 4:19 AM > To: dev@dpdk.org > Cc: Iremonger, Bernard; Richardson, Bruce; david.marchand@6wind.com; Tets= uya Mukawa > Subject: [PATCH v2 5/6] eal: Use map_idx in pci_uio_map_resource() of bsd= app to work same as > linuxapp >=20 > This patch changes code that maps pci resources in bsdapp. > Linuxapp has almost same code. To consolidate both, fix implementation of= bsdapp to work same as > linuxapp. >=20 > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_eal/bsdapp/eal/eal_pci.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) >=20 > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/= eal/eal_pci.c > index 85f8671..08b91b4 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c > @@ -195,7 +195,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev) st= atic int > pci_uio_map_resource(struct rte_pci_device *dev) { > - int i, j; > + int i, map_idx; > char devname[PATH_MAX]; /* contains the /dev/uioX */ > void *mapaddr; > uint64_t phaddr; > @@ -247,31 +247,31 @@ pci_uio_map_resource(struct rte_pci_device *dev) > pagesz =3D sysconf(_SC_PAGESIZE); >=20 > maps =3D uio_res->maps; > - for (i =3D uio_res->nb_maps =3D 0; i !=3D PCI_MAX_RESOURCE; i++) { > + for (i =3D 0, map_idx =3D 0; i !=3D PCI_MAX_RESOURCE; i++) { >=20 > - j =3D uio_res->nb_maps; > /* skip empty BAR */ > if ((phaddr =3D dev->mem_resource[i].phys_addr) =3D=3D 0) > continue; >=20 > /* if matching map is found, then use it */ > offset =3D i * pagesz; > - maps[j].offset =3D offset; > - maps[j].phaddr =3D dev->mem_resource[i].phys_addr; > - maps[j].size =3D dev->mem_resource[i].len; > - if (maps[j].addr !=3D NULL || > - (mapaddr =3D pci_map_resource(NULL, devname, (off_t)offset, > - (size_t)maps[j].size) > - ) =3D=3D NULL) { > + maps[map_idx].offset =3D offset; > + maps[map_idx].phaddr =3D dev->mem_resource[i].phys_addr; > + maps[map_idx].size =3D dev->mem_resource[i].len; > + mapaddr =3D pci_map_resource(NULL, devname, (off_t)offset, > + (size_t)maps[map_idx].size); > + if ((maps[map_idx].addr !=3D NULL) || (mapaddr =3D=3D NULL)) { Hi Tetsuya, Should be checking for if (mapaddr =3D=3D MAP_FAILED) here. Seems to be fixed in patch 6/6 though. Regards, Bernard. > rte_free(uio_res); > return -1; > } >=20 > - maps[j].addr =3D mapaddr; > - uio_res->nb_maps++; > + maps[map_idx].addr =3D mapaddr; > + map_idx++; > dev->mem_resource[i].addr =3D mapaddr; > } >=20 > + uio_res->nb_maps =3D map_idx; > + > TAILQ_INSERT_TAIL(uio_res_list, uio_res, next); >=20 > return 0; > -- > 1.9.1