* [dpdk-dev] [PATCH v1] app/regex: add job context
@ 2020-10-22 7:11 guyk
2020-10-27 9:20 ` Guy Kaneti
0 siblings, 1 reply; 4+ messages in thread
From: guyk @ 2020-10-22 7:11 UTC (permalink / raw)
To: orika; +Cc: thomas, guyk, smadarf, dovrat, dev
From: Guy Kaneti <guyk@marvell.com>
Store mbuf pointer associated with that job.
Signed-off-by: Guy Kaneti <guyk@marvell.com>
---
app/test-regex/main.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index e6080b44b..f869d754b 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -35,6 +35,10 @@ enum app_args {
ARG_NUM_OF_ITERATIONS,
};
+struct job_ctx {
+ struct rte_mbuf *mbuf;
+};
+
static void
usage(const char *prog_name)
{
@@ -266,6 +270,7 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
time_t start;
time_t end;
double time;
+ struct job_ctx *jobs_ctx;
shinfo.free_cb = extbuf_free_cb;
@@ -275,6 +280,12 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
return -ENOMEM;
}
+ jobs_ctx = rte_malloc(NULL, sizeof(struct job_ctx)*nb_jobs, 0);
+ if (!jobs_ctx) {
+ printf("Error, can't allocate memory for jobs_ctx.\n");
+ return -ENOMEM;
+ }
+
/* Allocate the jobs and assign each job with an mbuf. */
for (i = 0; i < nb_jobs; i++) {
ops[i] = rte_malloc(NULL, sizeof(*ops[0]) + nb_max_matches *
@@ -317,6 +328,7 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
long act_job_len = RTE_MIN(job_len, buf_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;
@@ -386,13 +398,13 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
}
end:
for (i = 0; i < actual_jobs; i++) {
- if (ops[i]) {
- if (ops[i]->mbuf)
- rte_pktmbuf_free(ops[i]->mbuf);
+ if (ops[i])
rte_free(ops[i]);
- }
+ if (jobs_ctx[i].mbuf)
+ rte_pktmbuf_free(jobs_ctx[i].mbuf);
}
rte_free(ops);
+ rte_free(jobs_ctx);
if (buf)
rte_free(buf);
return res;
--
2.28.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v1] app/regex: add job context
2020-10-22 7:11 [dpdk-dev] [PATCH v1] app/regex: add job context guyk
@ 2020-10-27 9:20 ` Guy Kaneti
2020-10-28 7:37 ` Ori Kam
0 siblings, 1 reply; 4+ messages in thread
From: Guy Kaneti @ 2020-10-27 9:20 UTC (permalink / raw)
To: orika; +Cc: thomas, Smadar Fuks, Dovrat Zifroni, dev, Guy Kaneti
Hi,
> -----Original Message-----
> From: guyk@marvell.com <guyk@marvell.com>
> Sent: Thursday, October 22, 2020 10:11 AM
> To: orika@nvidia.com
> Cc: thomas@monjalon.net; Guy Kaneti <guyk@marvell.com>; Smadar Fuks
> <smadarf@marvell.com>; Dovrat Zifroni <dovrat@marvell.com>;
> dev@dpdk.org
> Subject: [PATCH v1] app/regex: add job context
>
> From: Guy Kaneti <guyk@marvell.com>
>
> Store mbuf pointer associated with that job.
>
> Signed-off-by: Guy Kaneti <guyk@marvell.com>
> ---
> app/test-regex/main.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/app/test-regex/main.c b/app/test-regex/main.c index
> e6080b44b..f869d754b 100644
> --- a/app/test-regex/main.c
> +++ b/app/test-regex/main.c
> @@ -35,6 +35,10 @@ enum app_args {
> ARG_NUM_OF_ITERATIONS,
> };
>
> +struct job_ctx {
> + struct rte_mbuf *mbuf;
> +};
> +
> static void
> usage(const char *prog_name)
> {
> @@ -266,6 +270,7 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t
> nb_jobs,
> time_t start;
> time_t end;
> double time;
> + struct job_ctx *jobs_ctx;
>
> shinfo.free_cb = extbuf_free_cb;
>
> @@ -275,6 +280,12 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t
> nb_jobs,
> return -ENOMEM;
> }
>
> + jobs_ctx = rte_malloc(NULL, sizeof(struct job_ctx)*nb_jobs, 0);
> + if (!jobs_ctx) {
> + printf("Error, can't allocate memory for jobs_ctx.\n");
> + return -ENOMEM;
> + }
> +
> /* Allocate the jobs and assign each job with an mbuf. */
> for (i = 0; i < nb_jobs; i++) {
> ops[i] = rte_malloc(NULL, sizeof(*ops[0]) +
> nb_max_matches * @@ -317,6 +328,7 @@ run_regex(struct rte_mempool
> *mbuf_mp, uint32_t nb_jobs,
> long act_job_len = RTE_MIN(job_len, buf_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;
> @@ -386,13 +398,13 @@ run_regex(struct rte_mempool *mbuf_mp,
> uint32_t nb_jobs,
> }
> end:
> for (i = 0; i < actual_jobs; i++) {
> - if (ops[i]) {
> - if (ops[i]->mbuf)
> - rte_pktmbuf_free(ops[i]->mbuf);
> + if (ops[i])
> rte_free(ops[i]);
> - }
> + if (jobs_ctx[i].mbuf)
> + rte_pktmbuf_free(jobs_ctx[i].mbuf);
> }
> rte_free(ops);
> + rte_free(jobs_ctx);
> if (buf)
> rte_free(buf);
> return res;
> --
> 2.28.0
Kind reminder to all maintainers, please review and ack/comment.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v1] app/regex: add job context
2020-10-27 9:20 ` Guy Kaneti
@ 2020-10-28 7:37 ` Ori Kam
2020-11-03 0:48 ` Thomas Monjalon
0 siblings, 1 reply; 4+ messages in thread
From: Ori Kam @ 2020-10-28 7:37 UTC (permalink / raw)
To: Guy Kaneti; +Cc: NBU-Contact-Thomas Monjalon, Smadar Fuks, Dovrat Zifroni, dev
Hi
> -----Original Message-----
> From: Guy Kaneti <guyk@marvell.com>
> Sent: Tuesday, October 27, 2020 11:20 AM
> Subject: RE: [PATCH v1] app/regex: add job context
>
> Hi,
>
> > -----Original Message-----
> > From: guyk@marvell.com <guyk@marvell.com>
> > Sent: Thursday, October 22, 2020 10:11 AM
> > To: orika@nvidia.com
> > Cc: thomas@monjalon.net; Guy Kaneti <guyk@marvell.com>; Smadar Fuks
> > <smadarf@marvell.com>; Dovrat Zifroni <dovrat@marvell.com>;
> > dev@dpdk.org
> > Subject: [PATCH v1] app/regex: add job context
> >
> > From: Guy Kaneti <guyk@marvell.com>
> >
> > Store mbuf pointer associated with that job.
> >
> > Signed-off-by: Guy Kaneti <guyk@marvell.com>
> > ---
> > app/test-regex/main.c | 20 ++++++++++++++++----
> > 1 file changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/app/test-regex/main.c b/app/test-regex/main.c index
> > e6080b44b..f869d754b 100644
> > --- a/app/test-regex/main.c
> > +++ b/app/test-regex/main.c
> > @@ -35,6 +35,10 @@ enum app_args {
> > ARG_NUM_OF_ITERATIONS,
> > };
> >
> > +struct job_ctx {
> > + struct rte_mbuf *mbuf;
> > +};
> > +
> > static void
> > usage(const char *prog_name)
> > {
> > @@ -266,6 +270,7 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t
> > nb_jobs,
> > time_t start;
> > time_t end;
> > double time;
> > + struct job_ctx *jobs_ctx;
> >
> > shinfo.free_cb = extbuf_free_cb;
> >
> > @@ -275,6 +280,12 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t
> > nb_jobs,
> > return -ENOMEM;
> > }
> >
> > + jobs_ctx = rte_malloc(NULL, sizeof(struct job_ctx)*nb_jobs, 0);
> > + if (!jobs_ctx) {
> > + printf("Error, can't allocate memory for jobs_ctx.\n");
> > + return -ENOMEM;
> > + }
> > +
> > /* Allocate the jobs and assign each job with an mbuf. */
> > for (i = 0; i < nb_jobs; i++) {
> > ops[i] = rte_malloc(NULL, sizeof(*ops[0]) +
> > nb_max_matches * @@ -317,6 +328,7 @@ run_regex(struct rte_mempool
> > *mbuf_mp, uint32_t nb_jobs,
> > long act_job_len = RTE_MIN(job_len, buf_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;
> > @@ -386,13 +398,13 @@ run_regex(struct rte_mempool *mbuf_mp,
> > uint32_t nb_jobs,
> > }
> > end:
> > for (i = 0; i < actual_jobs; i++) {
> > - if (ops[i]) {
> > - if (ops[i]->mbuf)
> > - rte_pktmbuf_free(ops[i]->mbuf);
> > + if (ops[i])
> > rte_free(ops[i]);
> > - }
> > + if (jobs_ctx[i].mbuf)
> > + rte_pktmbuf_free(jobs_ctx[i].mbuf);
> > }
> > rte_free(ops);
> > + rte_free(jobs_ctx);
> > if (buf)
> > rte_free(buf);
> > return res;
> > --
> > 2.28.0
>
> Kind reminder to all maintainers, please review and ack/comment.
Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v1] app/regex: add job context
2020-10-28 7:37 ` Ori Kam
@ 2020-11-03 0:48 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2020-11-03 0:48 UTC (permalink / raw)
To: Guy Kaneti; +Cc: dev, Smadar Fuks, Dovrat Zifroni, Ori Kam
> > > From: Guy Kaneti <guyk@marvell.com>
> > >
> > > Store mbuf pointer associated with that job.
> > >
> > > Signed-off-by: Guy Kaneti <guyk@marvell.com>
> >
> > Kind reminder to all maintainers, please review and ack/comment.
>
> Acked-by: Ori Kam <orika@nvidia.com>
Applied, thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-03 0:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-22 7:11 [dpdk-dev] [PATCH v1] app/regex: add job context guyk
2020-10-27 9:20 ` Guy Kaneti
2020-10-28 7:37 ` Ori Kam
2020-11-03 0:48 ` Thomas Monjalon
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).