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 E7A653F9 for ; Tue, 9 Dec 2014 16:51:59 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 09 Dec 2014 07:50:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,545,1413270000"; d="scan'208";a="650998747" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by orsmga002.jf.intel.com with ESMTP; 09 Dec 2014 07:51:57 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 9 Dec 2014 23:51:55 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.5]) with mapi id 14.03.0195.001; Tue, 9 Dec 2014 23:51:53 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3 15/28] eal/pci: Add probe and close function for virtual drivers Thread-Index: AQHQE3oM9Qr7KSdGLkOcpi64JB9SSA== Date: Tue, 9 Dec 2014 15:51:53 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9E24E@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-16-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 15/28] eal/pci: Add probe and close function for virtual drivers 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 15:52:00 -0000 On 2014/12/9 14:33, Tetsuya Mukawa wrote:=0A= > The patch adds rte_eal_dev_init_one() and rte_eal_dev_close_one().=0A= > These are used for attaching and detaching virtual devices.=0A= >=0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/common/eal_common_dev.c | 66 +++++++++++++++++++++++++++= ++++++=0A= > lib/librte_eal/common/include/rte_dev.h | 6 +++=0A= > lib/librte_eal/linuxapp/eal/Makefile | 1 +=0A= > 3 files changed, 73 insertions(+)=0A= >=0A= > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/comm= on/eal_common_dev.c=0A= > index eae5656..f573a54 100644=0A= > --- a/lib/librte_eal/common/eal_common_dev.c=0A= > +++ b/lib/librte_eal/common/eal_common_dev.c=0A= > @@ -32,10 +32,13 @@=0A= > * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE= .=0A= > */=0A= > =0A= > +#include =0A= > +#include =0A= > #include =0A= > #include =0A= > #include =0A= > =0A= > +#include =0A= > #include =0A= > #include =0A= > #include =0A= > @@ -107,3 +110,66 @@ rte_eal_dev_init(void)=0A= > }=0A= > return 0;=0A= > }=0A= > +=0A= > +/* So far, linux only supports DPDK hotplug function. */=0A= =0A= Sorry, I don't know if I get your point, should be "only linux" right?=0A= =0A= > +#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)= =0A= > +=0A= > +#define INVOKE_PROBE (0)=0A= > +#define INVOKE_CLOSE (1)=0A= > +=0A= > +static void=0A= > +rte_eal_dev_invoke(struct rte_driver *driver,=0A= > + struct rte_devargs *devargs, int type)=0A= > +{=0A= > + if ((driver =3D=3D NULL) || (devargs =3D=3D NULL))=0A= > + return;=0A= > +=0A= > + switch (type) {=0A= > + case INVOKE_PROBE:=0A= > + driver->init(devargs->virtual.drv_name, devargs->args);=0A= > + break;=0A= > + case INVOKE_CLOSE:=0A= > + driver->close(devargs->virtual.drv_name, devargs->args);=0A= > + break;=0A= > + }=0A= > +}=0A= > +=0A= > +static int=0A= > +rte_eal_dev_find_and_invoke(const char *name, int type)=0A= > +{=0A= > + struct rte_devargs *devargs;=0A= > + struct rte_driver *driver;=0A= > +=0A= > + if (name =3D=3D NULL)=0A= > + return -EINVAL;=0A= > +=0A= > + /* call the init function for each virtual device */=0A= > + TAILQ_FOREACH(devargs, &devargs_list, next) {=0A= > +=0A= > + if (devargs->type !=3D RTE_DEVTYPE_VIRTUAL)=0A= > + continue;=0A= > +=0A= > + if (strncmp(name, devargs->virtual.drv_name, strlen(name)))=0A= > + continue;=0A= > +=0A= > + TAILQ_FOREACH(driver, &dev_driver_list, next) {=0A= > + if (driver->type !=3D PMD_VDEV)=0A= > + continue;=0A= > +=0A= > + /* search a driver prefix in virtual device name */=0A= > + if (!strncmp(driver->name, devargs->virtual.drv_name,=0A= > + strlen(driver->name))) {=0A= > + rte_eal_dev_invoke(driver, devargs, type);=0A= > + break;=0A= > + }=0A= > + }=0A= > +=0A= > + if (driver =3D=3D NULL) {=0A= > + RTE_LOG(WARNING, EAL, "no driver found for %s\n",=0A= > + devargs->virtual.drv_name);=0A= > + }=0A= > + return 0;=0A= > + }=0A= > + return 1;=0A= > +}=0A= > +#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */=0A= > diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/com= mon/include/rte_dev.h=0A= > index f7e3a10..71d40c3 100644=0A= > --- a/lib/librte_eal/common/include/rte_dev.h=0A= > +++ b/lib/librte_eal/common/include/rte_dev.h=0A= > @@ -57,6 +57,11 @@ TAILQ_HEAD(rte_driver_list, rte_driver);=0A= > typedef int (rte_dev_init_t)(const char *name, const char *args);=0A= > =0A= > /**=0A= > + * Close function called for each device driver once.=0A= > + */=0A= > +typedef int (rte_dev_close_t)(const char *name, const char *args);=0A= > +=0A= > +/**=0A= > * Driver type enumeration=0A= > */=0A= > enum pmd_type {=0A= > @@ -72,6 +77,7 @@ struct rte_driver {=0A= > enum pmd_type type; /**< PMD Driver type */=0A= > const char *name; /**< Driver name. */=0A= > rte_dev_init_t *init; /**< Device init. function. */=0A= > + rte_dev_close_t *close; /**< Device close. function. */=0A= > };=0A= > =0A= > /**=0A= > diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxa= pp/eal/Makefile=0A= > index 72ecf3a..0ec83b5 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/Makefile=0A= > +++ b/lib/librte_eal/linuxapp/eal/Makefile=0A= > @@ -41,6 +41,7 @@ CFLAGS +=3D -I$(RTE_SDK)/lib/librte_eal/common/include= =0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_ring=0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_mempool=0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_malloc=0A= > +CFLAGS +=3D -I$(RTE_SDK)/lib/librte_mbuf=0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_ether=0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_ivshmem=0A= > CFLAGS +=3D -I$(RTE_SDK)/lib/librte_pmd_ring=0A= =0A=