@@ -192,72 +192,88 @@ parse_table_entry(struct rte_swx_ctl_pipeline *p,
}
static const char cmd_mempool_help[] =
-"mempool <mempool_name>\n"
-" buffer <buffer_size>\n"
-" pool <pool_size>\n"
-" cache <cache_size>\n"
-" cpu <cpu_id>\n";
+"mempool <mempool_name> "
+"meta <mbuf_private_size> "
+"pkt <pkt_buffer_size> "
+"pool <pool_size> "
+"cache <cache_size> "
+"numa <numa_node>\n";
static void
cmd_mempool(char **tokens,
- uint32_t n_tokens,
- char *out,
- size_t out_size,
- void *obj)
+ uint32_t n_tokens,
+ char *out,
+ size_t out_size,
+ void *obj __rte_unused)
{
- struct mempool_params p;
- char *name;
- struct mempool *mempool;
+ struct rte_mempool *mp;
+ char *mempool_name;
+ uint32_t mbuf_private_size, pkt_buffer_size, pool_size, cache_size, numa_node;
- if (n_tokens != 10) {
+ if (n_tokens != 12) {
snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
return;
}
- name = tokens[1];
+ mempool_name = tokens[1];
+
+ if (strcmp(tokens[2], "meta")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "meta");
+ return;
+ }
- if (strcmp(tokens[2], "buffer") != 0) {
- snprintf(out, out_size, MSG_ARG_NOT_FOUND, "buffer");
+ if (parser_read_uint32(&mbuf_private_size, tokens[3])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "mbuf_private_size");
return;
}
- if (parser_read_uint32(&p.buffer_size, tokens[3]) != 0) {
- snprintf(out, out_size, MSG_ARG_INVALID, "buffer_size");
+ if (strcmp(tokens[4], "pkt")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pkt");
return;
}
- if (strcmp(tokens[4], "pool") != 0) {
+ if (parser_read_uint32(&pkt_buffer_size, tokens[5])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "pkt_buffer_size");
+ return;
+ }
+
+ if (strcmp(tokens[6], "pool")) {
snprintf(out, out_size, MSG_ARG_NOT_FOUND, "pool");
return;
}
- if (parser_read_uint32(&p.pool_size, tokens[5]) != 0) {
+ if (parser_read_uint32(&pool_size, tokens[7])) {
snprintf(out, out_size, MSG_ARG_INVALID, "pool_size");
return;
}
- if (strcmp(tokens[6], "cache") != 0) {
+ if (strcmp(tokens[8], "cache")) {
snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cache");
return;
}
- if (parser_read_uint32(&p.cache_size, tokens[7]) != 0) {
+ if (parser_read_uint32(&cache_size, tokens[9])) {
snprintf(out, out_size, MSG_ARG_INVALID, "cache_size");
return;
}
- if (strcmp(tokens[8], "cpu") != 0) {
- snprintf(out, out_size, MSG_ARG_NOT_FOUND, "cpu");
+ if (strcmp(tokens[10], "numa")) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "numa");
return;
}
- if (parser_read_uint32(&p.cpu_id, tokens[9]) != 0) {
- snprintf(out, out_size, MSG_ARG_INVALID, "cpu_id");
+ if (parser_read_uint32(&numa_node, tokens[11])) {
+ snprintf(out, out_size, MSG_ARG_INVALID, "numa_node");
return;
}
- mempool = mempool_create(obj, name, &p);
- if (mempool == NULL) {
+ mp = rte_pktmbuf_pool_create(mempool_name,
+ pool_size,
+ cache_size,
+ mbuf_private_size,
+ pkt_buffer_size,
+ numa_node);
+ if (!mp) {
snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
return;
}
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/fib.c /tmp/fib.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/hash_func.c /tmp/hash_func.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/l2fwd.c /tmp/l2fwd.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/l2fwd_macswp.c /tmp/l2fwd_macswp.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/l2fwd_macswp.c /tmp/l2fwd_macswp.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
;
; List of pipelines.
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/l2fwd.c /tmp/l2fwd.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
;
; List of pipelines.
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/learner.c /tmp/learner.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/meter.c /tmp/meter.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/mirroring.c /tmp/mirroring.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/recirculation.c /tmp/recirculation.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/registers.c /tmp/registers.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/selector.c /tmp/selector.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/varbit.c /tmp/varbit.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/vxlan.c /tmp/vxlan.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
ethdev 0000:18:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:18:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
ethdev 0000:3b:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
@@ -18,7 +18,7 @@ pipeline libbuild /tmp/vxlan.c /tmp/vxlan.so
;
; Note: Customize the parameters below to match your setup.
;
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
+mempool MEMPOOL0 meta 0 pkt 2176 pool 32K cache 256 numa 0
;
; List of pipelines.
@@ -13,18 +13,12 @@
#include <fcntl.h>
#include <unistd.h>
-#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_ethdev.h>
#include <rte_swx_ctl.h>
#include "obj.h"
-/*
- * mempool
- */
-TAILQ_HEAD(mempool_list, mempool);
-
/*
* link
*/
@@ -39,75 +33,10 @@ TAILQ_HEAD(ring_list, ring);
* obj
*/
struct obj {
- struct mempool_list mempool_list;
struct link_list link_list;
struct ring_list ring_list;
};
-/*
- * mempool
- */
-#define BUFFER_SIZE_MIN (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
-
-struct mempool *
-mempool_create(struct obj *obj, const char *name, struct mempool_params *params)
-{
- struct mempool *mempool;
- struct rte_mempool *m;
-
- /* Check input params */
- if ((name == NULL) ||
- mempool_find(obj, name) ||
- (params == NULL) ||
- (params->buffer_size < BUFFER_SIZE_MIN) ||
- (params->pool_size == 0))
- return NULL;
-
- /* Resource create */
- m = rte_pktmbuf_pool_create(
- name,
- params->pool_size,
- params->cache_size,
- 0,
- params->buffer_size - sizeof(struct rte_mbuf),
- params->cpu_id);
-
- if (m == NULL)
- return NULL;
-
- /* Node allocation */
- mempool = calloc(1, sizeof(struct mempool));
- if (mempool == NULL) {
- rte_mempool_free(m);
- return NULL;
- }
-
- /* Node fill in */
- strlcpy(mempool->name, name, sizeof(mempool->name));
- mempool->m = m;
- mempool->buffer_size = params->buffer_size;
-
- /* Node add to list */
- TAILQ_INSERT_TAIL(&obj->mempool_list, mempool, node);
-
- return mempool;
-}
-
-struct mempool *
-mempool_find(struct obj *obj, const char *name)
-{
- struct mempool *mempool;
-
- if (!obj || !name)
- return NULL;
-
- TAILQ_FOREACH(mempool, &obj->mempool_list, node)
- if (strcmp(mempool->name, name) == 0)
- return mempool;
-
- return NULL;
-}
-
/*
* link
*/
@@ -171,7 +100,7 @@ link_create(struct obj *obj, const char *name, struct link_params *params)
struct rte_eth_conf port_conf;
struct link *link;
struct link_params_rss *rss;
- struct mempool *mempool;
+ struct rte_mempool *mempool;
uint32_t cpu_id, i;
int status;
uint16_t port_id = 0;
@@ -193,8 +122,8 @@ link_create(struct obj *obj, const char *name, struct link_params *params)
if (rte_eth_dev_info_get(port_id, &port_info) != 0)
return NULL;
- mempool = mempool_find(obj, params->rx.mempool_name);
- if (mempool == NULL)
+ mempool = rte_mempool_lookup(params->rx.mempool_name);
+ if (!mempool)
return NULL;
rss = params->rx.rss;
@@ -251,7 +180,7 @@ link_create(struct obj *obj, const char *name, struct link_params *params)
params->rx.queue_size,
cpu_id,
NULL,
- mempool->m);
+ mempool);
if (status < 0)
return NULL;
@@ -421,7 +350,6 @@ obj_init(void)
if (!obj)
return NULL;
- TAILQ_INIT(&obj->mempool_list);
TAILQ_INIT(&obj->link_list);
TAILQ_INIT(&obj->ring_list);
@@ -8,7 +8,6 @@
#include <stdint.h>
#include <sys/queue.h>
-#include <rte_mempool.h>
#include <rte_swx_pipeline.h>
#include <rte_swx_ctl.h>
@@ -24,32 +23,6 @@ struct obj;
struct obj *
obj_init(void);
-/*
- * mempool
- */
-struct mempool_params {
- uint32_t buffer_size;
- uint32_t pool_size;
- uint32_t cache_size;
- uint32_t cpu_id;
-};
-
-struct mempool {
- TAILQ_ENTRY(mempool) node;
- char name[NAME_SIZE];
- struct rte_mempool *m;
- uint32_t buffer_size;
-};
-
-struct mempool *
-mempool_create(struct obj *obj,
- const char *name,
- struct mempool_params *params);
-
-struct mempool *
-mempool_find(struct obj *obj,
- const char *name);
-
/*
* link
*/