From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so2.wedos.net (wes1-so2.wedos.net [46.28.106.16]) by dpdk.org (Postfix) with ESMTP id A66813237 for ; Thu, 14 Jul 2016 18:50:14 +0200 (CEST) Received: from jvn (dynamic-109-81-211-32.ipv4.broadband.iol.cz [109.81.211.32]) by wes1-so2.wedos.net (Postfix) with ESMTPSA id 3rr1sL1Xk9zBjW; Thu, 14 Jul 2016 18:50:14 +0200 (CEST) Date: Thu, 14 Jul 2016 18:50:21 +0200 From: Jan Viktorin To: Shreyansh Jain Cc: , , Message-ID: <20160714185021.493910ea@jvn> In-Reply-To: <1468303282-2806-16-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-16-git-send-email-shreyansh.jain@nxp.com> Organization: RehiveTech X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v6 15/17] eal: add hotplug operations for pci and vdev 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: Thu, 14 Jul 2016 16:50:14 -0000 On Tue, 12 Jul 2016 11:31:20 +0530 Shreyansh Jain wrote: > Hotplug which deals with resources should come from the layer that already > handles them, i.e. EAL. >=20 > For both attach and detach operations, 'name' is used to select the bus > that will handle the request. >=20 > Signed-off-by: David Marchand > Signed-off-by: Shreyansh Jain > --- > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ > lib/librte_eal/common/eal_common_dev.c | 47 +++++++++++++++++++= ++++++ > lib/librte_eal/common/include/rte_dev.h | 25 +++++++++++++ > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ > 4 files changed, 76 insertions(+) >=20 > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_e= al/bsdapp/eal/rte_eal_version.map > index 1852c4a..6f9324f 100644 > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > @@ -159,5 +159,7 @@ DPDK_16.07 { > rte_keepalive_mark_sleep; > rte_keepalive_register_relay_callback; > rte_thread_setname; > + rte_eal_dev_attach; > + rte_eal_dev_detach; > =20 > } DPDK_16.04; > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/comm= on/eal_common_dev.c > index a8a4146..14c6cf1 100644 > --- a/lib/librte_eal/common/eal_common_dev.c > +++ b/lib/librte_eal/common/eal_common_dev.c > @@ -150,3 +150,50 @@ rte_eal_vdev_uninit(const char *name) > RTE_LOG(ERR, EAL, "no driver found for %s\n", name); > return -EINVAL; > } > + > +int rte_eal_dev_attach(const char *name, const char *devargs) > +{ > + struct rte_pci_addr addr; > + int ret =3D -1; > + > + if (name =3D=3D NULL || devargs =3D=3D NULL) { > + RTE_LOG(ERR, EAL, "Invalid device arguments provided\n"); > + return ret; > + } > + > + if (eal_parse_pci_DomBDF(name, &addr) =3D=3D 0) { > + if (rte_eal_pci_probe_one(&addr) < 0) > + goto err; > + > + } else { > + if (rte_eal_vdev_init(name, devargs)) > + goto err; > + } > + > + return 0; > + > +err: > + RTE_LOG(ERR, EAL, "Driver cannot attach the device\n"); I think this log can be more specific. We have the name of the device. It might be confusing to the user when the attach fails and there is no simple way how to determine which one. > + return ret; > +} > + > +int rte_eal_dev_detach(const char *name) > +{ > + struct rte_pci_addr addr; > + > + if (name =3D=3D NULL) > + goto err; > + > + if (eal_parse_pci_DomBDF(name, &addr) =3D=3D 0) { > + if (rte_eal_pci_detach(&addr) < 0) > + goto err; > + } else { > + if (rte_eal_vdev_uninit(name)) > + goto err; > + } > + return 0; > + > +err: > + RTE_LOG(ERR, EAL, "Driver cannot detach the device\n"); Same as for attach. > + return -1; > +} > diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/com= mon/include/rte_dev.h > index 994650b..2f0579c 100644 > --- a/lib/librte_eal/common/include/rte_dev.h > +++ b/lib/librte_eal/common/include/rte_dev.h > @@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *= args); > */ > int rte_eal_vdev_uninit(const char *name); > =20 > +/** > + * Attach a resource to a registered driver. =46rom my POV, the term "resource" is not good here. We have rte_pci_resource but we refer to a device here. The function is called rte_eal_DEV_attach. No idea why to call it a resource. > + * > + * @param name > + * The resource name, that refers to a pci resource or some private > + * way of designating a resource for vdev drivers. Based on this > + * resource name, eal will identify a driver capable of handling > + * this resource and pass this resource to the driver probing > + * function. > + * @param devargs > + * Device arguments to be passed to the driver. > + * @return > + * 0 on success, negative on error. > + */ > +int rte_eal_dev_attach(const char *name, const char *devargs); > + > +/** > + * Detach a resource from its driver. Same here for resource. Jan > + * > + * @param name > + * Same description as for rte_eal_dev_attach(). > + * Here, eal will call the driver detaching function. > + */ > +int rte_eal_dev_detach(const char *name); > + > #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[] > =20 > #define DRIVER_EXPORT_NAME(name, idx) \ > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte= _eal/linuxapp/eal/rte_eal_version.map > index a617b9e..db866b8 100644 > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > @@ -163,5 +163,7 @@ DPDK_16.07 { > rte_keepalive_mark_sleep; > rte_keepalive_register_relay_callback; > rte_thread_setname; > + rte_eal_dev_attach; > + rte_eal_dev_detach; > =20 > } DPDK_16.04;