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 DA2DD9A8C for ; Fri, 13 Mar 2015 16:10:35 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 13 Mar 2015 08:04:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,395,1422950400"; d="scan'208";a="698321979" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by orsmga002.jf.intel.com with ESMTP; 13 Mar 2015 08:10:08 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.218]) by IRSMSX151.ger.corp.intel.com ([169.254.4.7]) with mapi id 14.03.0195.001; Fri, 13 Mar 2015 15:10:07 +0000 From: "Iremonger, Bernard" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [PATCH v2 12/15] eal: Consolidate pci_map/unmap_device() of linuxapp and bsdapp Thread-Index: AQHQXK3yoqDNnZY/L0i2Cwc1Togo650ahVaA Date: Fri, 13 Mar 2015 15:10:07 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C2049F2A00@IRSMSX108.ger.corp.intel.com> References: <1425438703-18895-1-git-send-email-mukawa@igel.co.jp> <1426155474-1596-1-git-send-email-mukawa@igel.co.jp> <1426155474-1596-13-git-send-email-mukawa@igel.co.jp> In-Reply-To: <1426155474-1596-13-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.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 12/15] eal: Consolidate pci_map/unmap_device() of linuxapp and bsdapp 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: Fri, 13 Mar 2015 15:10:36 -0000 > -----Original Message----- > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp] > Sent: Thursday, March 12, 2015 10:18 AM > To: dev@dpdk.org > Cc: Iremonger, Bernard; Richardson, Bruce; Tetsuya Mukawa > Subject: [PATCH v2 12/15] eal: Consolidate pci_map/unmap_device() of linu= xapp and bsdapp >=20 > The patch consolidates below functions, and implemented in common eal cod= e. > - pci_map_device() > - pci_unmap_device() >=20 > Signed-off-by: Tetsuya Mukawa > --- > lib/librte_eal/bsdapp/eal/eal_pci.c | 12 +++---- > lib/librte_eal/common/eal_common_pci.c | 57 +++++++++++++++++++++++++++= ++++++ > lib/librte_eal/common/eal_private.h | 4 +-- > lib/librte_eal/common/include/rte_pci.h | 1 + > lib/librte_eal/linuxapp/eal/eal_pci.c | 55 ---------------------------= ---- > lib/librte_ether/rte_ethdev.c | 1 + > 6 files changed, 65 insertions(+), 65 deletions(-) >=20 > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/= eal/eal_pci.c > index 3778763..1e42e42 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c > @@ -280,7 +280,7 @@ fail: > } >=20 > /* map the PCI resource of a PCI device in virtual memory */ -static int > +int > pci_uio_map_resource(struct rte_pci_device *dev) { > int i, map_idx, ret; > @@ -364,6 +364,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) > /* FreeBSD has no NUMA support (yet) */ > dev->numa_node =3D 0; >=20 > + /* FreeBSD has only one pass through driver */ > + dev->pt_driver =3D RTE_PT_NIC_UIO; > + > /* parse resources */ > switch (conf->pc_hdr & PCIM_HDRTYPE) { > case PCIM_HDRTYPE_NORMAL: > @@ -429,13 +432,6 @@ skipdev: > return 0; > } >=20 > -/* Map pci device */ > -int > -pci_map_device(struct rte_pci_device *dev) -{ > - return pci_uio_map_resource(dev); > -} > - > /* > * Scan the content of the PCI bus, and add the devices in the devices > * list. Call pci_scan_one() for each pci entry found. > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/comm= on/eal_common_pci.c > index 538b2d9..726026f 100644 > --- a/lib/librte_eal/common/eal_common_pci.c > +++ b/lib/librte_eal/common/eal_common_pci.c > @@ -98,6 +98,63 @@ static struct rte_devargs *pci_devargs_lookup(struct r= te_pci_device *dev) > return NULL; > } >=20 > +/* Map pci device */ > +static int > +pci_map_device(struct rte_pci_device *dev) { > + int ret =3D -1; > + > + /* try mapping the NIC resources using VFIO if it exists */ > + switch (dev->pt_driver) { > + case RTE_PT_VFIO: > +#ifdef VFIO_PRESENT > + if (pci_vfio_is_enabled()) > + ret =3D pci_vfio_map_resource(dev); > +#endif > + break; > + case RTE_PT_IGB_UIO: > + case RTE_PT_UIO_GENERIC: > + case RTE_PT_NIC_UIO: > + /* map resources for devices that use uio */ > + ret =3D pci_uio_map_resource(dev); > + break; > + default: > + RTE_LOG(DEBUG, EAL, " Not managed by known pt driver," > + " skipped\n"); > + ret =3D 1; > + break; > + } > + > + return ret; > +} > + > +#ifdef RTE_LIBRTE_EAL_HOTPLUG Hi Tetsuya, Can #ifdef RTE_LIBRTE_EAL_HOTPLUG be removed as code is now in eal_common_= pci.c ? Regards, Bernard. > +/* Unmap pci device */ > +static void > +pci_unmap_device(struct rte_pci_device *dev) { > + if (dev =3D=3D NULL) > + return; > + > + /* try unmapping the NIC resources using VFIO if it exists */ > + switch (dev->pt_driver) { > + case RTE_PT_VFIO: > + RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n"); > + break; > + case RTE_PT_IGB_UIO: > + case RTE_PT_UIO_GENERIC: > + case RTE_PT_NIC_UIO: > + /* unmap resources for devices that use uio */ > + pci_uio_unmap_resource(dev); > + break; > + default: > + RTE_LOG(DEBUG, EAL, " Not managed by known pt driver," > + " skipped\n"); > + break; > + } > +} > +#endif /* RTE_LIBRTE_EAL_HOTPLUG */ Hi Tetsuya, Can #endif be removed too as code is now in eal_common_pci.c ? Regards, Bernard. > + > /* > * If vendor/device ID match, call the devinit() function of the > * driver. > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/= eal_private.h > index fe2c596..badb55c 100644 > --- a/lib/librte_eal/common/eal_private.h > +++ b/lib/librte_eal/common/eal_private.h > @@ -171,14 +171,14 @@ int pci_unbind_kernel_driver(struct rte_pci_device = *dev); > * @return > * 0 on success, negative on error > */ > -int pci_map_device(struct rte_pci_device *dev); > +int pci_uio_map_resource(struct rte_pci_device *dev); >=20 > /** > * Unmap this device > * > * This function is private to EAL. > */ > -void pci_unmap_device(struct rte_pci_device *dev); > +void pci_uio_unmap_resource(struct rte_pci_device *dev); >=20 > /** > * Init tail queues for non-EAL library structures. This is to allow dif= f --git > a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include= /rte_pci.h > index fc64601..47345b8 100644 > --- a/lib/librte_eal/common/include/rte_pci.h > +++ b/lib/librte_eal/common/include/rte_pci.h > @@ -147,6 +147,7 @@ enum rte_pt_driver { > RTE_PT_IGB_UIO =3D 1, > RTE_PT_VFIO =3D 2, > RTE_PT_UIO_GENERIC =3D 3, > + RTE_PT_NIC_UIO =3D 4, > }; >=20 > /** > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linux= app/eal/eal_pci.c > index dbc2548..6a8153c 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c > @@ -565,61 +565,6 @@ pci_config_space_set(struct rte_pci_device *dev) } = #endif >=20 > -/* Map pci device */ > -int > -pci_map_device(struct rte_pci_device *dev) -{ > - int ret =3D -1; > - > - /* try mapping the NIC resources using VFIO if it exists */ > - switch (dev->pt_driver) { > - case RTE_PT_VFIO: > -#ifdef VFIO_PRESENT > - if (pci_vfio_is_enabled()) > - ret =3D pci_vfio_map_resource(dev); > -#endif > - break; > - case RTE_PT_IGB_UIO: > - case RTE_PT_UIO_GENERIC: > - /* map resources for devices that use uio */ > - ret =3D pci_uio_map_resource(dev); > - break; > - default: > - RTE_LOG(DEBUG, EAL, " Not managed by known pt driver," > - " skipped\n"); > - ret =3D 1; > - break; > - } > - > - return ret; > -} > - > -#ifdef RTE_LIBRTE_EAL_HOTPLUG > -/* Unmap pci device */ > -void > -pci_unmap_device(struct rte_pci_device *dev) -{ > - if (dev =3D=3D NULL) > - return; > - > - /* try unmapping the NIC resources using VFIO if it exists */ > - switch (dev->pt_driver) { > - case RTE_PT_VFIO: > - RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n"); > - break; > - case RTE_PT_IGB_UIO: > - case RTE_PT_UIO_GENERIC: > - /* unmap resources for devices that use uio */ > - pci_uio_unmap_resource(dev); > - break; > - default: > - RTE_LOG(DEBUG, EAL, " Not managed by known pt driver," > - " skipped\n"); > - break; > - } > -} > -#endif /* RTE_LIBRTE_EAL_HOTPLUG */ > - > /* Init the PCI EAL subsystem */ > int > rte_eal_pci_init(void) > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c index 03fce08..e23d7da > 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -515,6 +515,7 @@ rte_eth_dev_is_detachable(uint8_t port_id) > switch (rte_eth_devices[port_id].pci_dev->pt_driver) { > case RTE_PT_IGB_UIO: > case RTE_PT_UIO_GENERIC: > + case RTE_PT_NIC_UIO: > break; > case RTE_PT_VFIO: > default: > -- > 1.9.1