diff mbox series

mbuf: pktmbuf pool create helper for specific mempool ops

Message ID 1513942211-8314-1-git-send-email-hemant.agrawal@nxp.com
State Superseded
Headers show
Series mbuf: pktmbuf pool create helper for specific mempool ops | expand

Commit Message

Hemant Agrawal Dec. 22, 2017, 11:30 a.m. UTC
Introduce a new helper for pktmbuf pool, which will allow
the application to optionally specify the mempool ops name
as well.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
This change was discussed in the 
"doc: announce ABI change for pktmbuf pool create API"
http://dpdk.org/dev/patchwork/patch/32306/

 lib/librte_mbuf/rte_mbuf.c | 24 ++++++++++++++++++------
 lib/librte_mbuf/rte_mbuf.h | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 6 deletions(-)

-- 
2.7.4

Comments

Wiles, Keith Dec. 22, 2017, 1:53 p.m. UTC | #1
> On Dec 22, 2017, at 5:30 AM, Hemant Agrawal <hemant.agrawal@nxp.com> wrote:

> 

> Introduce a new helper for pktmbuf pool, which will allow

> the application to optionally specify the mempool ops name

> as well.

> 

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

> ---

> This change was discussed in the 

> "doc: announce ABI change for pktmbuf pool create API"

> http://dpdk.org/dev/patchwork/patch/32306/

> 

> lib/librte_mbuf/rte_mbuf.c | 24 ++++++++++++++++++------

> lib/librte_mbuf/rte_mbuf.h | 42 ++++++++++++++++++++++++++++++++++++++++++

> 2 files changed, 60 insertions(+), 6 deletions(-)

> 


This patch looks good to me, but you forgot the MAP file patch to add the new API.

Regards,
Keith
Olivier Matz Jan. 16, 2018, 2:52 p.m. UTC | #2
On Fri, Dec 22, 2017 at 05:00:11PM +0530, Hemant Agrawal wrote:
> Introduce a new helper for pktmbuf pool, which will allow

> the application to optionally specify the mempool ops name

> as well.

> 

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

> ---


Hi Hemant,

It looks this patch is now in another patchset:
http://dpdk.org/dev/patchwork/patch/33719/

Can it be marked as superseeded in patchwork?

Thanks
Wiles, Keith Jan. 16, 2018, 2:59 p.m. UTC | #3
> On Jan 16, 2018, at 8:52 AM, Olivier Matz <olivier.matz@6wind.com> wrote:

> 

> On Fri, Dec 22, 2017 at 05:00:11PM +0530, Hemant Agrawal wrote:

>> Introduce a new helper for pktmbuf pool, which will allow

>> the application to optionally specify the mempool ops name

>> as well.

>> 

>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

>> ---

> 

> Hi Hemant,

> 

> It looks this patch is now in another patchset:

> http://dpdk.org/dev/patchwork/patch/33719/

> 

> Can it be marked as superseeded in patchwork?


I can mark my patch.
> 

> Thanks


Regards,
Keith
Hemant Agrawal Jan. 17, 2018, 5:29 a.m. UTC | #4
On 1/16/2018 8:22 PM, Olivier Matz wrote:
> On Fri, Dec 22, 2017 at 05:00:11PM +0530, Hemant Agrawal wrote:

>> Introduce a new helper for pktmbuf pool, which will allow

>> the application to optionally specify the mempool ops name

>> as well.

>>

>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

>> ---

>

> Hi Hemant,

>

> It looks this patch is now in another patchset:

> http://dpdk.org/dev/patchwork/patch/33719/

>

> Can it be marked as superseeded in patchwork?


done.

>

> Thanks

>
diff mbox series

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 7543662..9cc861b 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -148,15 +148,15 @@  rte_pktmbuf_init(struct rte_mempool *mp,
 	m->next = NULL;
 }
 
-/* helper to create a mbuf pool */
+/* helper to create a mbuf pool with given mempool ops*/
 struct rte_mempool *
-rte_pktmbuf_pool_create(const char *name, unsigned n,
-	unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
-	int socket_id)
+rte_pktmbuf_pool_create_specific(const char *name, unsigned int n,
+	unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size,
+	int socket_id, const char *ops_name)
 {
 	struct rte_mempool *mp;
 	struct rte_pktmbuf_pool_private mbp_priv;
-	const char *mp_ops_name;
+	const char *mp_ops_name = ops_name;
 	unsigned elt_size;
 	int ret;
 
@@ -176,7 +176,9 @@  rte_pktmbuf_pool_create(const char *name, unsigned n,
 	if (mp == NULL)
 		return NULL;
 
-	mp_ops_name = rte_eal_mbuf_default_mempool_ops();
+	if (!mp_ops_name)
+		mp_ops_name = rte_eal_mbuf_default_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");
@@ -198,6 +200,16 @@  rte_pktmbuf_pool_create(const char *name, unsigned n,
 	return mp;
 }
 
+/* helper to create a mbuf pool */
+struct rte_mempool *
+rte_pktmbuf_pool_create(const char *name, unsigned int n,
+	unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size,
+	int socket_id)
+{
+	return rte_pktmbuf_pool_create_specific(name, n, cache_size, priv_size,
+			data_room_size, socket_id, NULL);
+}
+
 /* do some sanity checks on a mbuf: panic if it fails */
 void
 rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ce8a05d..d4681fd 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1081,6 +1081,48 @@  rte_pktmbuf_pool_create(const char *name, unsigned n,
 	int socket_id);
 
 /**
+ * Create a mbuf pool with specific mempool ops
+ *
+ * This function creates and initializes a packet mbuf pool. It is
+ * a wrapper to rte_mempool functions.
+ *
+ * @param name
+ *   The name of the mbuf pool.
+ * @param n
+ *   The number of elements in the mbuf pool. The optimum size (in terms
+ *   of memory usage) for a mempool is when n is a power of two minus one:
+ *   n = (2^q - 1).
+ * @param cache_size
+ *   Size of the per-core object cache. See rte_mempool_create() for
+ *   details.
+ * @param priv_size
+ *   Size of application private are between the rte_mbuf structure
+ *   and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN.
+ * @param data_room_size
+ *   Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM.
+ * @param socket_id
+ *   The socket identifier where the memory should be allocated. The
+ *   value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the
+ *   reserved zone.
+ * @param ops_name
+ *   The mempool ops name to be used for this mempool instead of
+ *   default mempool. The value can be *NULL* to use default mempool.
+ * @return
+ *   The pointer to the new allocated mempool, on success. NULL on error
+ *   with rte_errno set appropriately. Possible rte_errno values include:
+ *    - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
+ *    - E_RTE_SECONDARY - function was called from a secondary process instance
+ *    - EINVAL - cache size provided is too large, or priv_size is not aligned.
+ *    - ENOSPC - the maximum number of memzones has already been allocated
+ *    - EEXIST - a memzone with the same name already exists
+ *    - ENOMEM - no appropriate memory area found in which to create memzone
+ */
+struct rte_mempool *
+rte_pktmbuf_pool_create_specific(const char *name, unsigned int n,
+	unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size,
+	int socket_id, 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