[dpdk-dev] [PATCH 1/2] mbuf: update default Mempool ops with HW active pool
Hemant Agrawal
hemant.agrawal at nxp.com
Fri Dec 15 11:24:42 CET 2017
With this patch the specific HW mempool are no longer required to be
specified in the config file at compile. A default active hw mempool
can be detected dynamically and published to default mempools ops
config at run time. Only one type of HW mempool can be active default.
Signed-off-by: Hemant Agrawal <hemant.agrawal at nxp.com>
---
lib/librte_mbuf/rte_mbuf.c | 33 ++++++++++++++++++++++++++++++++-
lib/librte_mbuf/rte_mbuf.h | 13 +++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 7543662..e074afa 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -148,6 +148,37 @@ rte_pktmbuf_init(struct rte_mempool *mp,
m->next = NULL;
}
+static const char *active_mbuf_pool_ops_name;
+
+int
+rte_pktmbuf_reg_active_mempool_ops(const char *ops_name)
+{
+ if (active_mbuf_pool_ops_name == NULL) {
+ active_mbuf_pool_ops_name = ops_name;
+ return 0;
+ }
+ RTE_LOG(ERR, MBUF,
+ "%s is already registered as active pktmbuf pool ops\n",
+ active_mbuf_pool_ops_name);
+ return -EACCES;
+}
+
+/* Return mbuf pool ops name */
+static const char *
+rte_pktmbuf_active_mempool_ops(void)
+{
+ const char *default_ops = rte_eal_mbuf_default_mempool_ops();
+
+ /* If mbuf default ops is same as compile time default
+ * Just to be sure that no one has updated it by other means.
+ */
+ if ((strcmp(default_ops, RTE_MBUF_DEFAULT_MEMPOOL_OPS) == 0) &&
+ (active_mbuf_pool_ops_name != NULL))
+ return active_mbuf_pool_ops_name;
+ else
+ return default_ops;
+}
+
/* helper to create a mbuf pool */
struct rte_mempool *
rte_pktmbuf_pool_create(const char *name, unsigned n,
@@ -176,7 +207,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
if (mp == NULL)
return NULL;
- mp_ops_name = rte_eal_mbuf_default_mempool_ops();
+ mp_ops_name = rte_pktmbuf_active_mempool_ops();
ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
if (ret != 0) {
RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ce8a05d..3140a0b 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1081,6 +1081,19 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
int socket_id);
/**
+ * Register the active HW pkt mbuf pool
+ *
+ * Register the active pktmbuf HW pool to overwrite the default pool
+ *
+ * @param pool ops name
+ * @return
+ * - 0: Success
+ * - -EACCES: Active mempool is already registered.
+ */
+int
+rte_pktmbuf_reg_active_mempool_ops(const char *ops_name);
+
+/**
* Get the data room size of mbufs stored in a pktmbuf_pool
*
* The data room size is the amount of data that can be stored in a
--
2.7.4
More information about the dev
mailing list