From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0074.outbound.protection.outlook.com [104.47.2.74]) by dpdk.org (Postfix) with ESMTP id 31C8C58D8 for ; Fri, 16 Sep 2016 11:34:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rUeROvSDa5e1CsLN1QZdx30pdESSwyPyhmiq+K7oqpw=; b=u/6vzpilKclpwZc2n7BWiXGx4LUWFgeKqcF/AjCw6cjilrD0QXD5qJjUugvEc/Qj7PSsdNoUhmb/Dp1spxyKh/NJi65aGgjKgF3R2+/kQdl+DMjIS+0FucAzMKIKD19vpZMm5H4mzL4qfc/xMB5F7oDjGCdbukHHpK/BWAmxjDc= Received: from DB5PR04MB1605.eurprd04.prod.outlook.com (10.164.38.147) by DB5PR04MB1608.eurprd04.prod.outlook.com (10.164.38.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.6; Fri, 16 Sep 2016 09:34:01 +0000 Received: from DB5PR04MB1605.eurprd04.prod.outlook.com ([10.164.38.147]) by DB5PR04MB1605.eurprd04.prod.outlook.com ([10.164.38.147]) with mapi id 15.01.0629.006; Fri, 16 Sep 2016 09:34:01 +0000 From: Hemant Agrawal To: "Hunt, David" , "olivier.matz@6wind.com" CC: "dev@dpdk.org" , "jerin.jacob@caviumnetworks.com" Thread-Topic: [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability Thread-Index: AQHSD0XhFlLNpDsT2U+Sj2bEM80pLqB71qaAgAAFiYA= Date: Fri, 16 Sep 2016 09:34:01 +0000 Message-ID: References: <1473346213-6038-1-git-send-email-hemant.agrawal@nxp.com> <1473959607-1951-1-git-send-email-hemant.agrawal@nxp.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-originating-ip: [192.88.169.1] x-ms-office365-filtering-correlation-id: b3f2a3b6-f1f7-4cd6-4778-08d3de1497eb x-microsoft-exchange-diagnostics: 1; DB5PR04MB1608; 6:9MyfAkRgkYdWu+5hk459WLjgoCCZcyrwCZJ/inQSlfag4zXJvxSNSZoPuXw7YTgs8zNXonZrEhPuxY1VdFgLfik0024ze77CRgBapJMn0MCEto6E9RqTLgFAnqB9REpBWldzvhdiQeolUxOTa1IINcdPS7IZU1VItP8OuBU9fkmzbzPtrkr1r/t9GhwRDI4I7HVntA86Qw1rsPyOT8pQWnUSk+xGFMqDG/hllxEVy/XTbFtVkGqjwK+BCQqsD0NDKXHL2crdC9upYoFjl4151CmGxhh51SJ0QKGfVvDWyZrFmdc6clzzsZ19tirnD9aBoDC3QPZqjGQmC1QmeYJEWA==; 5:pOUfHBpmDsFkg61rkSCdlvmoWGV4u2HiDYQ7y0dqLfM5MYb90jTeClRx20a7MMsfUo83w/3Qa2AExJfBFA8CoCry9DC/6OkTxyRi5iW3Hbv6dqAYiptAiQYPn8VJqRtr1gv8ZjWQuGpw7aIX5cIwVA==; 24:CgC0MlOT7Z94Re3A26ESmHFRS+7i86KooOcEI9rT6VU6LjedQpivAqAM2OEwPH+xJhsXd217gOVGdF/9HdRhC71zXzHChAJZmAMOe3n8Fzc=; 7:fO06OdhZoO34kMfx6kxeUCH8dtzRdKO/NNusoyetjoG3Vjt3EWWRoRbyN3phaXRxmPE5zLL20NmfOL630hjvXW+KrRkWTjrpojtWQEeSlmTcwNIBzZKTFw0TnTqCUhSQxeMPhc+PA/iq+Sw5F0Frbzhj5j/v7CJbko6dNoe838RK6HO0XDlWSB91A2C4Ty9p/p6AbQ+dD3vx1/0eOF2AxQ3vm2YODxpB7UWKcnwdhGC0WwJDRIkkflb+7MZNUD+0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR04MB1608; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DB5PR04MB1608; BCL:0; PCL:0; RULEID:; SRVR:DB5PR04MB1608; x-forefront-prvs: 0067A8BA2A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(377454003)(199003)(51444003)(189002)(24454002)(13464003)(10400500002)(68736007)(11100500001)(33656002)(101416001)(106356001)(50986999)(105586002)(76176999)(9686002)(4326007)(54356999)(106116001)(3280700002)(76576001)(74316002)(3660700001)(81166006)(7696004)(7736002)(305945005)(122556002)(5002640100001)(81156014)(8936002)(66066001)(77096005)(2906002)(5001770100001)(5660300001)(2900100001)(8676002)(97736004)(86362001)(7846002)(586003)(102836003)(2501003)(189998001)(2950100001)(87936001)(3846002)(92566002)(19580395003)(6116002)(19580405001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1608; H:DB5PR04MB1605.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2016 09:34:01.6841 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1608 Subject: Re: [dpdk-dev] [PATCH v2 1/2] eal/mempool: introduce check for external mempool availability 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, 16 Sep 2016 09:34:03 -0000 HI David, > -----Original Message----- > From: Hunt, David [mailto:david.hunt@intel.com] > Sent: Friday, September 16, 2016 2:44 PM > To: Hemant Agrawal ; olivier.matz@6wind.com > Cc: dev@dpdk.org; jerin.jacob@caviumnetworks.com > Subject: Re: [PATCH v2 1/2] eal/mempool: introduce check for external > mempool availability >=20 > Hi Hemant, >=20 > On 15/9/2016 6:13 PM, Hemant Agrawal wrote: > > External offloaded mempool may not be available always. This check > > enables run time verification of the presence of external mempool > > before the mempool ops are installed. > > > > An application built with a specific external mempool may work fine on > > host. But, may not work on VM, specificaly if non-hw specific > > interfaces are used e.g. virtio-net. > > > > This is required to make sure that same application can work in all > > environment for a given hw platform. > > > > The solution proposed here is that rte_mempool_set_ops_byname should > > return specific error in case the current execution environment is not > > supporting the given mempool. Thereby allowing it to fallback on > > software mempool implementation e.g. "ring_mp_mc" > > > > This patch introduces new optional "pool_verify" as mempool ops > > function to check if external mempool instance is available or not. >=20 > I've a small suggestion around the naming of the new functions. It seems = to me > that this patch is more about mempool handler 'support' than 'verificatio= n'. > Could I suggest a different name for this new function? I think maybe > "supported" may be more appropriate than "pool_verify". The return code t= hat's > returned when a mempool handler is not available is -EOPNOTSUPP, which is > what suggested the word "supported" to me. I think that: >=20 > if (ops->supported) > return ops->supported(mp); >=20 > makes for slightly easier reading. The wrapper function would logically t= hen be > called rte_mempool_ops_supported(). [Hemant] Good suggestion. I will update it in next version.=20 >=20 >=20 > > Signed-off-by: Hemant Agrawal > > --- > > Changes in v2: > > * fixed the pool_verify copy in rte_mempool_register_ops > > --- > > lib/librte_mempool/rte_mempool.h | 21 +++++++++++++++++++++ > > lib/librte_mempool/rte_mempool_ops.c | 19 +++++++++++++++++++ > > lib/librte_mempool/rte_mempool_ring.c | 4 ++++ > > lib/librte_mempool/rte_mempool_stack.c | 3 ++- > > 4 files changed, 46 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_mempool/rte_mempool.h > b/lib/librte_mempool/rte_mempool.h > > index 0243f9e..8599df1 100644 > > --- a/lib/librte_mempool/rte_mempool.h > > +++ b/lib/librte_mempool/rte_mempool.h > > @@ -387,6 +387,12 @@ typedef int (*rte_mempool_dequeue_t)(struct > rte_mempool *mp, > > */ > > typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool > *mp); > > > > +/** > > + * Return if the given external mempool is available for this instance= . > > + * it is optional to implement for mempools > > + */ > > +typedef int (*rte_mempool_pool_verify)(const struct rte_mempool *mp); > > + > > /** Structure defining mempool operations structure */ > > struct rte_mempool_ops { > > char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool > ops struct. */ > > @@ -395,6 +401,8 @@ struct rte_mempool_ops { > > rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ > > rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ > > rte_mempool_get_count get_count; /**< Get qty of available objs. */ > > + rte_mempool_pool_verify pool_verify; > > + /**< Verify if external mempool is available for usages*/ > > } __rte_cache_aligned; > > > > #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs > */ > > @@ -516,6 +524,18 @@ void > > rte_mempool_ops_free(struct rte_mempool *mp); > > > > /** > > + * @internal wrapper to verify the external mempool availability > > + * > > + * @param mp > > + * Pointer to the memory pool. > > + * @return > > + * 0: Success; external mempool instance is available > > + * - <0: Error; external mempool instance is not available > > + */ > > +int > > +rte_mempool_ops_pool_verify(const struct rte_mempool *mp); > > + > > +/** > > * Set the ops of a mempool. > > * > > * This can only be done on a mempool that is not populated, i.e. jus= t after > > @@ -531,6 +551,7 @@ rte_mempool_ops_free(struct rte_mempool *mp); > > * - 0: Success; the mempool is now using the requested ops functio= ns. > > * - -EINVAL - Invalid ops struct name provided. > > * - -EEXIST - mempool already has an ops struct assigned. > > + * - -EOPNOTSUPP - mempool instance not available. > > */ > > int > > rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, > > diff --git a/lib/librte_mempool/rte_mempool_ops.c > b/lib/librte_mempool/rte_mempool_ops.c > > index 5f24de2..c2e765f 100644 > > --- a/lib/librte_mempool/rte_mempool_ops.c > > +++ b/lib/librte_mempool/rte_mempool_ops.c > > @@ -85,6 +85,7 @@ rte_mempool_register_ops(const struct > rte_mempool_ops *h) > > ops->enqueue =3D h->enqueue; > > ops->dequeue =3D h->dequeue; > > ops->get_count =3D h->get_count; > > + ops->pool_verify =3D h->pool_verify; > > > > rte_spinlock_unlock(&rte_mempool_ops_table.sl); > > > > @@ -123,6 +124,18 @@ rte_mempool_ops_get_count(const struct > rte_mempool *mp) > > return ops->get_count(mp); > > } > > > > +/* wrapper to check if given external mempool is available for this > instance.*/ > > +int > > +rte_mempool_ops_pool_verify(const struct rte_mempool *mp) > > +{ > > + struct rte_mempool_ops *ops; > > + > > + ops =3D rte_mempool_get_ops(mp->ops_index); > > + if (ops->pool_verify) > > + return ops->pool_verify(mp); > > + return 0; > > +} > > + > > /* sets mempool ops previously registered by rte_mempool_register_ops= . */ > > int > > rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, > > @@ -146,6 +159,12 @@ rte_mempool_set_ops_byname(struct rte_mempool > *mp, const char *name, > > if (ops =3D=3D NULL) > > return -EINVAL; > > > > + /*verify if the given mempool is available for this instance */ > > + if (ops->pool_verify) { > > + if (ops->pool_verify(mp)) > > + return -EOPNOTSUPP; > > + } > > + > > mp->ops_index =3D i; > > mp->pool_config =3D pool_config; > > return 0; > > diff --git a/lib/librte_mempool/rte_mempool_ring.c > b/lib/librte_mempool/rte_mempool_ring.c > > index b9aa64d..d86d5e0 100644 > > --- a/lib/librte_mempool/rte_mempool_ring.c > > +++ b/lib/librte_mempool/rte_mempool_ring.c > > @@ -126,6 +126,7 @@ static const struct rte_mempool_ops ops_mp_mc =3D { > > .enqueue =3D common_ring_mp_enqueue, > > .dequeue =3D common_ring_mc_dequeue, > > .get_count =3D common_ring_get_count, > > + .pool_verify =3D NULL, > > }; > > > > static const struct rte_mempool_ops ops_sp_sc =3D { > > @@ -135,6 +136,7 @@ static const struct rte_mempool_ops ops_sp_sc =3D { > > .enqueue =3D common_ring_sp_enqueue, > > .dequeue =3D common_ring_sc_dequeue, > > .get_count =3D common_ring_get_count, > > + .pool_verify =3D NULL, > > }; > > > > static const struct rte_mempool_ops ops_mp_sc =3D { > > @@ -144,6 +146,7 @@ static const struct rte_mempool_ops ops_mp_sc =3D { > > .enqueue =3D common_ring_mp_enqueue, > > .dequeue =3D common_ring_sc_dequeue, > > .get_count =3D common_ring_get_count, > > + .pool_verify =3D NULL, > > }; > > > > static const struct rte_mempool_ops ops_sp_mc =3D { > > @@ -153,6 +156,7 @@ static const struct rte_mempool_ops ops_sp_mc =3D { > > .enqueue =3D common_ring_sp_enqueue, > > .dequeue =3D common_ring_mc_dequeue, > > .get_count =3D common_ring_get_count, > > + .pool_verify =3D NULL, > > }; > > > > MEMPOOL_REGISTER_OPS(ops_mp_mc); > > diff --git a/lib/librte_mempool/rte_mempool_stack.c > b/lib/librte_mempool/rte_mempool_stack.c > > index 5fd8af2..0198b70 100644 > > --- a/lib/librte_mempool/rte_mempool_stack.c > > +++ b/lib/librte_mempool/rte_mempool_stack.c > > @@ -141,7 +141,8 @@ static struct rte_mempool_ops ops_stack =3D { > > .free =3D stack_free, > > .enqueue =3D stack_enqueue, > > .dequeue =3D stack_dequeue, > > - .get_count =3D stack_get_count > > + .get_count =3D stack_get_count, > > + .pool_verify =3D NULL, > > }; > > > > MEMPOOL_REGISTER_OPS(ops_stack); >=20 > Regards, > Dave.