aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/l4fwd/README1
-rw-r--r--examples/l4fwd/main.c2
-rw-r--r--examples/l4fwd/netbe.h1
-rw-r--r--examples/l4fwd/parse.c14
-rw-r--r--examples/l4fwd/port.h12
5 files changed, 21 insertions, 9 deletions
diff --git a/examples/l4fwd/README b/examples/l4fwd/README
index dc3dc67..328f7ef 100644
--- a/examples/l4fwd/README
+++ b/examples/l4fwd/README
@@ -139,6 +139,7 @@
-K | --seckey <string> /* 16 character long secret key used by */ \
/* hash algorithms to generate the */ \
/* sequence number. */ \
+ -M | --mbuf-num <num> /* other than default number of mbufs per pool. */ \
<port0_params> <port1_params> ... <portN_params>
Note that: options -U and -T cannot be used together.
diff --git a/examples/l4fwd/main.c b/examples/l4fwd/main.c
index 469776f..57e9cfd 100644
--- a/examples/l4fwd/main.c
+++ b/examples/l4fwd/main.c
@@ -61,7 +61,7 @@ RTE_DEFINE_PER_LCORE(struct netfe_lcore *, _fe);
static volatile int force_quit;
-static struct netbe_cfg becfg;
+static struct netbe_cfg becfg = {.mpool_buf_num=MPOOL_NB_BUF};
static struct rte_mempool *mpool[RTE_MAX_NUMA_NODES + 1];
static struct rte_mempool *frag_mpool[RTE_MAX_NUMA_NODES + 1];
static char proto_name[3][10] = {"udp", "tcp", ""};
diff --git a/examples/l4fwd/netbe.h b/examples/l4fwd/netbe.h
index 6d9aa35..661cdcb 100644
--- a/examples/l4fwd/netbe.h
+++ b/examples/l4fwd/netbe.h
@@ -151,6 +151,7 @@ struct netbe_cfg {
uint32_t arp;
uint32_t prt_num;
uint32_t cpu_num;
+ uint32_t mpool_buf_num;
struct netbe_port *prt;
struct netbe_lcore *cpu;
};
diff --git a/examples/l4fwd/parse.c b/examples/l4fwd/parse.c
index 40adee4..a1e7917 100644
--- a/examples/l4fwd/parse.c
+++ b/examples/l4fwd/parse.c
@@ -45,6 +45,9 @@ static const struct {
#define OPT_SHORT_PROMISC 'P'
#define OPT_LONG_PROMISC "promisc"
+#define OPT_SHORT_MBUFNUM 'M'
+#define OPT_LONG_MBUFNUM "mbuf-num"
+
#define OPT_SHORT_RBUFS 'R'
#define OPT_LONG_RBUFS "rbufs"
@@ -95,6 +98,7 @@ static const struct option long_opt[] = {
{OPT_LONG_SBULK, 1, 0, OPT_SHORT_SBULK},
{OPT_LONG_CTXFLAGS, 1, 0, OPT_SHORT_CTXFLAGS},
{OPT_LONG_PROMISC, 0, 0, OPT_SHORT_PROMISC},
+ {OPT_LONG_MBUFNUM, 1, 0, OPT_SHORT_MBUFNUM},
{OPT_LONG_RBUFS, 1, 0, OPT_SHORT_RBUFS},
{OPT_LONG_SBUFS, 1, 0, OPT_SHORT_SBUFS},
{OPT_LONG_BECFG, 1, 0, OPT_SHORT_BECFG},
@@ -816,7 +820,7 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
optind = 0;
optarg = NULL;
- while ((opt = getopt_long(argc, argv, "aB:C:c:LPR:S:TUb:f:s:v:H:K:W:w:",
+ while ((opt = getopt_long(argc, argv, "aB:C:c:LPR:S:M:TUb:f:s:v:H:K:W:w:",
long_opt, &opt_idx)) != EOF) {
if (opt == OPT_SHORT_ARP) {
cfg->arp = 1;
@@ -834,7 +838,13 @@ parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
"for option: \'%c\'\n",
__func__, optarg, opt);
ctx_prm->flags = v;
- } else if (opt == OPT_SHORT_PROMISC) {
+ } else if (opt == OPT_SHORT_MBUFNUM) {
+ rc = parse_uint_val(NULL, optarg, &v);
+ if (rc < 0)
+ rte_exit(EXIT_FAILURE, "%s: invalid value: %s "
+ "for option: \'%c\'\n",
+ __func__, optarg, opt);
+ cfg->mpool_buf_num = v;
} else if (opt == OPT_SHORT_PROMISC) {
cfg->promisc = 1;
} else if (opt == OPT_SHORT_RBUFS) {
diff --git a/examples/l4fwd/port.h b/examples/l4fwd/port.h
index a154844..8c1a899 100644
--- a/examples/l4fwd/port.h
+++ b/examples/l4fwd/port.h
@@ -316,14 +316,14 @@ log_netbe_cfg(const struct netbe_cfg *ucfg)
}
static int
-pool_init(uint32_t sid)
+pool_init(uint32_t sid, uint32_t mpool_buf_num)
{
int32_t rc;
struct rte_mempool *mp;
char name[RTE_MEMPOOL_NAMESIZE];
snprintf(name, sizeof(name), "MP%u", sid);
- mp = rte_pktmbuf_pool_create(name, MPOOL_NB_BUF, MPOOL_CACHE_SIZE, 0,
+ mp = rte_pktmbuf_pool_create(name, mpool_buf_num, MPOOL_CACHE_SIZE, 0,
RTE_MBUF_DEFAULT_BUF_SIZE, sid - 1);
if (mp == NULL) {
rc = -rte_errno;
@@ -337,14 +337,14 @@ pool_init(uint32_t sid)
}
static int
-frag_pool_init(uint32_t sid)
+frag_pool_init(uint32_t sid, uint32_t mpool_buf_num)
{
int32_t rc;
struct rte_mempool *frag_mp;
char frag_name[RTE_MEMPOOL_NAMESIZE];
snprintf(frag_name, sizeof(frag_name), "frag_MP%u", sid);
- frag_mp = rte_pktmbuf_pool_create(frag_name, MPOOL_NB_BUF,
+ frag_mp = rte_pktmbuf_pool_create(frag_name, mpool_buf_num,
MPOOL_CACHE_SIZE, 0, FRAG_MBUF_BUF_SIZE, sid - 1);
if (frag_mp == NULL) {
rc = -rte_errno;
@@ -406,13 +406,13 @@ netbe_port_init(struct netbe_cfg *cfg)
assert(sid < RTE_DIM(mpool));
if (mpool[sid] == NULL) {
- rc = pool_init(sid);
+ rc = pool_init(sid, cfg->mpool_buf_num);
if (rc != 0)
return rc;
}
if (frag_mpool[sid] == NULL) {
- rc = frag_pool_init(sid);
+ rc = frag_pool_init(sid, cfg->mpool_buf_num);
if (rc != 0)
return rc;
}