From mboxrd@z Thu Jan 1 00:00:00 1970 From: Akhil Goyal Subject: [PATCH] examples/ipsec-secgw: improve ipsec dequeue logic Date: Thu, 14 Dec 2017 12:49:23 +0530 Message-ID: <20171214071923.10087-1-akhil.goyal@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , , Akhil Goyal To: Return-path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0045.outbound.protection.outlook.com [104.47.41.45]) by dpdk.org (Postfix) with ESMTP id A5E222030 for ; Thu, 14 Dec 2017 08:23:01 +0100 (CET) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since the processing of crypto operations may take time due to hardware offload, all the packets may not be available in the single dequeue command. So it may happen that there is leakage of cops, and there is nobody to dequeue the packets because dequeue of crypto ops is done only once for a particular queue pair even if it has more packets in flight. This patch dequeue the packets again if the inflight packets are more than the max packet burst. Signed-off-by: Akhil Goyal --- examples/ipsec-secgw/ipsec.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c index 70ed227..69ffc3b 100644 --- a/examples/ipsec-secgw/ipsec.c +++ b/examples/ipsec-secgw/ipsec.c @@ -369,12 +369,10 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa; struct rte_mbuf *pkt; - for (i = 0; i < ipsec_ctx->nb_qps && nb_pkts < max_pkts; i++) { + for (i = 0; i < ipsec_ctx->nb_qps && nb_pkts < max_pkts;) { struct cdev_qp *cqp; - cqp = &ipsec_ctx->tbl[ipsec_ctx->last_qp++]; - if (ipsec_ctx->last_qp == ipsec_ctx->nb_qps) - ipsec_ctx->last_qp %= ipsec_ctx->nb_qps; + cqp = &ipsec_ctx->tbl[ipsec_ctx->last_qp]; while (cqp->ol_pkts_cnt > 0 && nb_pkts < max_pkts) { pkt = cqp->ol_pkts[--cqp->ol_pkts_cnt]; @@ -389,8 +387,13 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, pkts[nb_pkts++] = pkt; } - if (cqp->in_flight == 0) + if (cqp->in_flight == 0) { + ipsec_ctx->last_qp++; + if (ipsec_ctx->last_qp == ipsec_ctx->nb_qps) + ipsec_ctx->last_qp %= ipsec_ctx->nb_qps; + i++; continue; + } nb_cops = rte_cryptodev_dequeue_burst(cqp->id, cqp->qp, cops, max_pkts - nb_pkts); @@ -414,6 +417,12 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx, } } pkts[nb_pkts++] = pkt; + if (cqp->in_flight < max_pkts) { + ipsec_ctx->last_qp++; + if (ipsec_ctx->last_qp == ipsec_ctx->nb_qps) + ipsec_ctx->last_qp %= ipsec_ctx->nb_qps; + i++; + } } } -- 2.9.3