patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 20.11] app/regex: fix number of matches
@ 2022-03-18 15:40 Gerry Gribbon
  0 siblings, 0 replies; only message in thread
From: Gerry Gribbon @ 2022-03-18 15:40 UTC (permalink / raw)
  To: stable; +Cc: ggribbon, Ori Kam

[ upstream commit c1d1b94eec5855b3934791a10125e9db5f15298a ]

Depending on number of jobs specified on command line, part of the
data buffer may not get searched, resulting in incorrect number of
matches being reported.

Additional change to ensure the "All Matches" summary outputs the
correct match start locations in the supplied data buffer.

Fixes: de06137cb295 ("app/regex: add RegEx test application")
Cc: stable@dpdk.org

Signed-off-by: Gerry Gribbon <ggribbon@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 app/test-regex/main.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 6a8eb07ae8..c78f6f36dd 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -254,8 +254,12 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	char *buf = NULL;
 	long buf_len;
 	long job_len;
+	long remainder;
+	long act_job_len = 0;
+	bool last_job = false;
 	uint32_t actual_jobs = 0;
 	uint32_t i;
+	uint32_t job_id;
 	struct rte_regex_ops **ops;
 	uint16_t dev_id = 0;
 	uint16_t qp_id = 0;
@@ -325,12 +329,25 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	}
 
 	/* Assign each mbuf with the data to handle. */
+	remainder = buf_len % nb_jobs;
+
 	for (i = 0; (pos < buf_len) && (i < nb_jobs) ; i++) {
-		long act_job_len = RTE_MIN(job_len, buf_len - pos);
+		act_job_len = RTE_MIN(job_len, buf_len - pos);
+
+		if (i == (nb_jobs - 1)) {
+			last_job = true;
+			act_job_len += remainder;
+		}
+
 		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;
+
+		if (!last_job)
+			ops[i]->mbuf->data_len = job_len;
+		else
+			ops[i]->mbuf->data_len = act_job_len;
+
 		ops[i]->mbuf->pkt_len = act_job_len;
 		ops[i]->user_id = i;
 		ops[i]->group_id0 = 1;
@@ -342,6 +359,8 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	for (i = 0; i < nb_iterations; i++) {
 		total_enqueue = 0;
 		total_dequeue = 0;
+		for (job_id = 0; job_id < actual_jobs; job_id++)
+			ops[job_id]->user_id = job_id;
 		while (total_dequeue < actual_jobs) {
 			struct rte_regex_ops **cur_ops_to_enqueue = ops +
 				total_enqueue;
@@ -360,10 +379,11 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 	}
 	end = clock();
 	time = ((double)end - start) / CLOCKS_PER_SEC;
-	printf("Job len = %ld Bytes\n",  job_len);
+	printf("Job len = %ld Bytes Last Job=%ld Bytes\n", job_len,
+		act_job_len);
 	printf("Time = %lf sec\n",  time);
 	printf("Perf = %lf Gbps\n",
-	       (((double)actual_jobs * job_len * nb_iterations * 8) / time) /
+	       (((double)buf_len * nb_iterations * 8) / time) /
 		1000000000.0);
 
 	if (!perf_mode) {
@@ -390,9 +410,10 @@ run_regex(struct rte_mempool *mbuf_mp, uint32_t nb_jobs,
 			total_matches += nb_matches;
 			match = ops[d_ind % actual_jobs]->matches;
 			for (i = 0; i < nb_matches; i++) {
-				printf("start = %ld, len = %d, rule = %d\n",
-				       match->start_offset + d_ind * job_len,
-				       match->len, match->rule_id);
+				printf("start = %d, len = %d, rule = %d\n",
+					(int)(ops[d_ind % actual_jobs]->user_id
+						* job_len),
+					match->len, match->rule_id);
 				match++;
 			}
 		}
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-18 15:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 15:40 [PATCH 20.11] app/regex: fix number of matches Gerry Gribbon

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).