From: Suanming Mou <suanmingm@nvidia.com>
To: orika@nvidia.com
Cc: dev@dpdk.org, viacheslavo@nvidia.com, matan@nvidia.com,
rasland@nvidia.com
Subject: [dpdk-dev] [PATCH v2 3/4] app/test-regex: support scattered mbuf input
Date: Thu, 25 Mar 2021 06:32:35 +0200 [thread overview]
Message-ID: <20210325043236.964312-4-suanmingm@nvidia.com> (raw)
In-Reply-To: <20210325043236.964312-1-suanmingm@nvidia.com>
This commits adds the scattered mbuf input support.
Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
app/test-regex/main.c | 134 ++++++++++++++++++++++++++++++++++--------
1 file changed, 109 insertions(+), 25 deletions(-)
diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index aea4fa6b88..82cffaacfa 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -35,6 +35,7 @@ enum app_args {
ARG_NUM_OF_ITERATIONS,
ARG_NUM_OF_QPS,
ARG_NUM_OF_LCORES,
+ ARG_NUM_OF_MBUF_SEGS,
};
struct job_ctx {
@@ -70,6 +71,7 @@ struct regex_conf {
char *data_buf;
long data_len;
long job_len;
+ uint32_t nb_segs;
};
static void
@@ -82,14 +84,15 @@ usage(const char *prog_name)
" --perf N: only outputs the performance data\n"
" --nb_iter N: number of iteration to run\n"
" --nb_qps N: number of queues to use\n"
- " --nb_lcores N: number of lcores to use\n",
+ " --nb_lcores N: number of lcores to use\n"
+ " --nb_segs N: number of mbuf segments\n",
prog_name);
}
static void
args_parse(int argc, char **argv, char *rules_file, char *data_file,
uint32_t *nb_jobs, bool *perf_mode, uint32_t *nb_iterations,
- uint32_t *nb_qps, uint32_t *nb_lcores)
+ uint32_t *nb_qps, uint32_t *nb_lcores, uint32_t *nb_segs)
{
char **argvopt;
int opt;
@@ -111,6 +114,8 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file,
{ "nb_qps", 1, 0, ARG_NUM_OF_QPS},
/* Number of lcores. */
{ "nb_lcores", 1, 0, ARG_NUM_OF_LCORES},
+ /* Number of mbuf segments. */
+ { "nb_segs", 1, 0, ARG_NUM_OF_MBUF_SEGS},
/* End of options */
{ 0, 0, 0, 0 }
};
@@ -150,6 +155,9 @@ args_parse(int argc, char **argv, char *rules_file, char *data_file,
case ARG_NUM_OF_LCORES:
*nb_lcores = atoi(optarg);
break;
+ case ARG_NUM_OF_MBUF_SEGS:
+ *nb_segs = atoi(optarg);
+ break;
case ARG_HELP:
usage("RegEx test app");
break;
@@ -302,11 +310,75 @@ extbuf_free_cb(void *addr __rte_unused, void *fcb_opaque __rte_unused)
{
}
+static inline struct rte_mbuf *
+regex_create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
+ int nb_segs, void *buf) {
+
+ struct rte_mbuf *m = NULL, *mbuf = NULL;
+ uint8_t *dst;
+ char *src = buf;
+ int data_len = 0;
+ int i, size;
+ int t_len;
+
+ if (pkt_len < 1) {
+ printf("Packet size must be 1 or more (is %d)\n", pkt_len);
+ return NULL;
+ }
+
+ if (nb_segs < 1) {
+ printf("Number of segments must be 1 or more (is %d)\n",
+ nb_segs);
+ return NULL;
+ }
+
+ t_len = pkt_len >= nb_segs ? (pkt_len / nb_segs +
+ !!(pkt_len % nb_segs)) : 1;
+ size = pkt_len;
+
+ /* Create chained mbuf_src and fill it with buf data */
+ for (i = 0; size > 0; i++) {
+
+ m = rte_pktmbuf_alloc(mbuf_pool);
+ if (i == 0)
+ mbuf = m;
+
+ if (m == NULL) {
+ printf("Cannot create segment for source mbuf");
+ goto fail;
+ }
+
+ data_len = size > t_len ? t_len : size;
+ memset(rte_pktmbuf_mtod(m, uint8_t *), 0,
+ rte_pktmbuf_tailroom(m));
+ memcpy(rte_pktmbuf_mtod(m, uint8_t *), src, data_len);
+ dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
+ if (dst == NULL) {
+ printf("Cannot append %d bytes to the mbuf\n",
+ data_len);
+ goto fail;
+ }
+
+ if (mbuf != m)
+ rte_pktmbuf_chain(mbuf, m);
+ src += data_len;
+ size -= data_len;
+
+ }
+ return mbuf;
+
+fail:
+ if (mbuf)
+ rte_pktmbuf_free(mbuf);
+ return NULL;
+}
+
static int
run_regex(void *args)
{
struct regex_conf *rgxc = args;
uint32_t nb_jobs = rgxc->nb_jobs;
+ uint32_t nb_segs = rgxc->nb_segs;
uint32_t nb_iterations = rgxc->nb_iterations;
uint8_t nb_max_matches = rgxc->nb_max_matches;
uint32_t nb_qps = rgxc->nb_qps;
@@ -338,8 +410,12 @@ run_regex(void *args)
snprintf(mbuf_pool,
sizeof(mbuf_pool),
"mbuf_pool_%2u", qp_id_base);
- mbuf_mp = rte_pktmbuf_pool_create(mbuf_pool, nb_jobs * nb_qps, 0,
- 0, MBUF_SIZE, rte_socket_id());
+ mbuf_mp = rte_pktmbuf_pool_create(mbuf_pool,
+ rte_align32pow2(nb_jobs * nb_qps * nb_segs),
+ 0, 0, (nb_segs == 1) ? MBUF_SIZE :
+ (rte_align32pow2(job_len) / nb_segs +
+ RTE_PKTMBUF_HEADROOM),
+ rte_socket_id());
if (mbuf_mp == NULL) {
printf("Error, can't create memory pool\n");
return -ENOMEM;
@@ -375,8 +451,19 @@ run_regex(void *args)
goto end;
}
+ if (clone_buf(data_buf, &buf, data_len)) {
+ printf("Error, can't clone buf.\n");
+ res = -EXIT_FAILURE;
+ goto end;
+ }
+
+ /* Assign each mbuf with the data to handle. */
+ actual_jobs = 0;
+ pos = 0;
/* Allocate the jobs and assign each job with an mbuf. */
- for (i = 0; i < nb_jobs; i++) {
+ for (i = 0; (pos < data_len) && (i < nb_jobs) ; i++) {
+ long act_job_len = RTE_MIN(job_len, data_len - pos);
+
ops[i] = rte_malloc(NULL, sizeof(*ops[0]) +
nb_max_matches *
sizeof(struct rte_regexdev_match), 0);
@@ -386,30 +473,26 @@ run_regex(void *args)
res = -ENOMEM;
goto end;
}
- ops[i]->mbuf = rte_pktmbuf_alloc(mbuf_mp);
+ if (nb_segs > 1) {
+ ops[i]->mbuf = regex_create_segmented_mbuf
+ (mbuf_mp, act_job_len,
+ nb_segs, &buf[pos]);
+ } else {
+ ops[i]->mbuf = rte_pktmbuf_alloc(mbuf_mp);
+ if (ops[i]->mbuf) {
+ rte_pktmbuf_attach_extbuf(ops[i]->mbuf,
+ &buf[pos], 0, act_job_len, &shinfo);
+ ops[i]->mbuf->data_len = job_len;
+ ops[i]->mbuf->pkt_len = act_job_len;
+ }
+ }
if (!ops[i]->mbuf) {
- printf("Error, can't attach mbuf.\n");
+ printf("Error, can't add mbuf.\n");
res = -ENOMEM;
goto end;
}
- }
- if (clone_buf(data_buf, &buf, data_len)) {
- printf("Error, can't clone buf.\n");
- res = -EXIT_FAILURE;
- goto end;
- }
-
- /* Assign each mbuf with the data to handle. */
- actual_jobs = 0;
- pos = 0;
- for (i = 0; (pos < data_len) && (i < nb_jobs) ; i++) {
- long act_job_len = RTE_MIN(job_len, data_len - pos);
- rte_pktmbuf_attach_extbuf(ops[i]->mbuf, &buf[pos], 0,
- act_job_len, &shinfo);
jobs_ctx[i].mbuf = ops[i]->mbuf;
- ops[i]->mbuf->data_len = job_len;
- ops[i]->mbuf->pkt_len = act_job_len;
ops[i]->user_id = i;
ops[i]->group_id0 = 1;
pos += act_job_len;
@@ -612,7 +695,7 @@ main(int argc, char **argv)
char *data_buf;
long data_len;
long job_len;
- uint32_t nb_lcores = 1;
+ uint32_t nb_lcores = 1, nb_segs = 1;
struct regex_conf *rgxc;
uint32_t i;
struct qps_per_lcore *qps_per_lcore;
@@ -626,7 +709,7 @@ main(int argc, char **argv)
if (argc > 1)
args_parse(argc, argv, rules_file, data_file, &nb_jobs,
&perf_mode, &nb_iterations, &nb_qps,
- &nb_lcores);
+ &nb_lcores, &nb_segs);
if (nb_qps == 0)
rte_exit(EXIT_FAILURE, "Number of QPs must be greater than 0\n");
@@ -656,6 +739,7 @@ main(int argc, char **argv)
for (i = 0; i < nb_lcores; i++) {
rgxc[i] = (struct regex_conf){
.nb_jobs = nb_jobs,
+ .nb_segs = nb_segs,
.perf_mode = perf_mode,
.nb_iterations = nb_iterations,
.nb_max_matches = nb_max_matches,
--
2.25.1
next prev parent reply other threads:[~2021-03-25 4:32 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 23:57 [dpdk-dev] [PATCH 0/3] regex/mlx5: support scattered mbuf Suanming Mou
2021-03-09 23:57 ` [dpdk-dev] [PATCH 1/3] common/mlx5: add user memory registration bits Suanming Mou
2021-03-09 23:57 ` [dpdk-dev] [PATCH 2/3] regex/mlx5: add data path scattered mbuf process Suanming Mou
2021-03-09 23:57 ` [dpdk-dev] [PATCH 3/3] app/test-regex: support scattered mbuf input Suanming Mou
2021-03-24 21:14 ` [dpdk-dev] [PATCH 0/3] regex/mlx5: support scattered mbuf Thomas Monjalon
2021-03-25 4:32 ` [dpdk-dev] [PATCH v2 0/4] " Suanming Mou
2021-03-25 4:32 ` [dpdk-dev] [PATCH v2 1/4] common/mlx5: add user memory registration bits Suanming Mou
2021-03-29 9:29 ` Ori Kam
2021-03-25 4:32 ` [dpdk-dev] [PATCH v2 2/4] regex/mlx5: add data path scattered mbuf process Suanming Mou
2021-03-29 9:34 ` Ori Kam
2021-03-29 9:52 ` Suanming Mou
2021-03-25 4:32 ` Suanming Mou [this message]
2021-03-29 9:27 ` [dpdk-dev] [PATCH v2 3/4] app/test-regex: support scattered mbuf input Ori Kam
2021-03-25 4:32 ` [dpdk-dev] [PATCH v2 4/4] regex/mlx5: prevent wrong calculation of free sqs in umr mode Suanming Mou
2021-03-29 9:35 ` Ori Kam
2021-03-30 1:39 ` [dpdk-dev] [PATCH v3 0/4] regex/mlx5: support scattered mbuf Suanming Mou
2021-03-30 1:39 ` [dpdk-dev] [PATCH v3 1/4] common/mlx5: add user memory registration bits Suanming Mou
2021-03-30 1:39 ` [dpdk-dev] [PATCH v3 2/4] regex/mlx5: add data path scattered mbuf process Suanming Mou
2021-03-30 8:05 ` Slava Ovsiienko
2021-03-30 9:00 ` Suanming Mou
2021-03-30 1:39 ` [dpdk-dev] [PATCH v3 3/4] app/test-regex: support scattered mbuf input Suanming Mou
2021-03-30 1:39 ` [dpdk-dev] [PATCH v3 4/4] regex/mlx5: prevent wrong calculation of free sqs in umr mode Suanming Mou
2021-04-06 16:22 ` Thomas Monjalon
2021-04-07 1:00 ` Suanming Mou
2021-04-07 7:11 ` Thomas Monjalon
2021-04-07 7:14 ` Suanming Mou
2021-03-31 7:37 ` [dpdk-dev] [PATCH v4 0/4] regex/mlx5: support scattered mbuf Suanming Mou
2021-03-31 7:37 ` [dpdk-dev] [PATCH v4 1/4] common/mlx5: add user memory registration bits Suanming Mou
2021-03-31 7:37 ` [dpdk-dev] [PATCH v4 2/4] regex/mlx5: add data path scattered mbuf process Suanming Mou
2021-03-31 7:37 ` [dpdk-dev] [PATCH v4 3/4] app/test-regex: support scattered mbuf input Suanming Mou
2021-03-31 7:37 ` [dpdk-dev] [PATCH v4 4/4] regex/mlx5: prevent wrong calculation of free sqs in umr mode Suanming Mou
2021-04-07 7:21 ` [dpdk-dev] [PATCH v5 0/3] regex/mlx5: support scattered mbuf Suanming Mou
2021-04-07 7:21 ` [dpdk-dev] [PATCH v5 1/3] common/mlx5: add user memory registration bits Suanming Mou
2021-04-07 7:21 ` [dpdk-dev] [PATCH v5 2/3] regex/mlx5: add data path scattered mbuf process Suanming Mou
2021-04-07 7:21 ` [dpdk-dev] [PATCH v5 3/3] app/test-regex: support scattered mbuf input Suanming Mou
2021-04-08 20:53 ` [dpdk-dev] [PATCH v5 0/3] regex/mlx5: support scattered mbuf Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210325043236.964312-4-suanmingm@nvidia.com \
--to=suanmingm@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).