From mboxrd@z Thu Jan 1 00:00:00 1970 From: Santosh Shukla Subject: [PATCH v2 2/6] mempool: get the mempool capability Date: Thu, 13 Jul 2017 09:32:51 +0000 Message-ID: <20170713093255.13986-3-santosh.shukla@caviumnetworks.com> References: <20170621173248.1313-1-santosh.shukla@caviumnetworks.com> <20170713093255.13986-1-santosh.shukla@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, Santosh Shukla To: thomas@monjalon.net, dev@dpdk.org, olivier.matz@6wind.com Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0069.outbound.protection.outlook.com [104.47.32.69]) by dpdk.org (Postfix) with ESMTP id C84445A3E for ; Thu, 13 Jul 2017 11:34:01 +0200 (CEST) In-Reply-To: <20170713093255.13986-1-santosh.shukla@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Allow mempool to advertise its capability. A handler been introduced called rte_mempool_ops_get_capabilities. - Upon ->get_capabilities call, mempool driver will advertise capability by updating to 'mp->flags'. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- v1 -- v2: - Added RTE_FUNC_PTR_OR_ERR_RET - _get_capabilities :: returs 0 : Success and <0 :Error - _get_capabilities :: driver updates mp->flags with their capability value. - _get_capabilites :: Added approriate comment - Fixed _version.map :: replaced DPDK_17.05 with DPDK_16.07 Refer [1]. [1] http://dpdk.org/dev/patchwork/patch/25603/ lib/librte_mempool/rte_mempool.c | 5 +++++ lib/librte_mempool/rte_mempool.h | 20 ++++++++++++++++++++ lib/librte_mempool/rte_mempool_ops.c | 13 +++++++++++++ lib/librte_mempool/rte_mempool_version.map | 7 +++++++ 4 files changed, 45 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 237665c65..34619aafd 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -527,6 +527,11 @@ rte_mempool_populate_default(struct rte_mempool *mp) if (mp->nb_mem_chunks != 0) return -EEXIST; + /* Get mempool capability */ + ret = rte_mempool_ops_get_capabilities(mp); + if (ret) + RTE_LOG(DEBUG, MEMPOOL, "get_capability not supported for %s\n", mp->name); + if (rte_xen_dom0_supported()) { pg_sz = RTE_PGSIZE_2M; pg_shift = rte_bsf32(pg_sz); diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index bd7be2319..0fa571c72 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -389,6 +389,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, */ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); +/** + * Get the mempool capability. + */ +typedef int (*rte_mempool_get_capabilities_t)(struct rte_mempool *mp); + + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -397,6 +403,7 @@ 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_get_capabilities_t get_capabilities; /**< Get capability */ } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -508,6 +515,19 @@ rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned rte_mempool_ops_get_count(const struct rte_mempool *mp); + +/** + * @internal wrapper for mempool_ops get_capabilities callback. + * + * @param mp + * Pointer to the memory pool. + * @return + * - 0: Success; Capability updated to mp->flags + * - <0: Error; code of capability function. + */ +int +rte_mempool_ops_get_capabilities(struct rte_mempool *mp); + /** * @internal wrapper for mempool_ops free callback. * diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index 5f24de250..84b2f8151 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 = h->enqueue; ops->dequeue = h->dequeue; ops->get_count = h->get_count; + ops->get_capabilities = h->get_capabilities; 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 get external mempool capability. */ +int +rte_mempool_ops_get_capabilities(struct rte_mempool *mp) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + + RTE_FUNC_PTR_OR_ERR_RET(ops->get_capabilities, -ENOTSUP); + return ops->get_capabilities(mp); +} + /* sets mempool ops previously registered by rte_mempool_register_ops. */ int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, diff --git a/lib/librte_mempool/rte_mempool_version.map b/lib/librte_mempool/rte_mempool_version.map index f9c079447..392388bef 100644 --- a/lib/librte_mempool/rte_mempool_version.map +++ b/lib/librte_mempool/rte_mempool_version.map @@ -41,3 +41,10 @@ DPDK_16.07 { rte_mempool_set_ops_byname; } DPDK_2.0; + +DPDK_17.08 { + global: + + rte_mempool_ops_get_capabilities; + +} DPDK_16.07; -- 2.13.0