From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0CBDA04DD; Thu, 22 Oct 2020 09:12:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D92E55AB9; Thu, 22 Oct 2020 09:12:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id A5EE64C94 for ; Thu, 22 Oct 2020 09:12:42 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09M75HNi013053; Thu, 22 Oct 2020 00:12:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=8iiR7fvMXbieKIfDafSFQja8ZrkInT1aQF2whmjTKOg=; b=TBvO4968o2o70aY3h6HPex20xejnu/9meZYkmAim9BWVtzw3C2nbxL+FchtFVZGwrqaq LeJHwILeUkr4CLyAabsgAZPd5ESCDZY+4eVIJltzWCZnQCy4RZJYrTLbKLYzyFSYjHej vcoWUDxvwaxeHVxMuP1eeW/0tWdRAEX0/L4GpsgIlG9wgDH0AD/aymOIFDOnYSVpSHFf iPlwRIOUIh5704TQpJFrARyYe2GySmNm3r3gbVnXOkKH74p+/PZCm4Ta88dJAuNfERjG c5KE/jzuDqPaSfs90qSpqZkTkWIsZoF8AxOtbc7D3Kqk3yaEymjWv02sOXufFHqLB3wo IA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 34asbe28uj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 22 Oct 2020 00:12:40 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 22 Oct 2020 00:12:39 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 22 Oct 2020 00:12:39 -0700 Received: from vvenus124.il.marvell.com (unknown [10.5.116.64]) by maili.marvell.com (Postfix) with ESMTP id 06A5E3F7041; Thu, 22 Oct 2020 00:12:37 -0700 (PDT) From: To: CC: , , , , Date: Thu, 22 Oct 2020 10:11:11 +0300 Message-ID: <20201022071111.2933-1-guyk@marvell.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.737 definitions=2020-10-22_02:2020-10-20, 2020-10-22 signatures=0 Subject: [dpdk-dev] [PATCH v1] app/regex: add job context X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Guy Kaneti Store mbuf pointer associated with that job. Signed-off-by: Guy Kaneti --- 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