[dpdk-dev,v3] examples/ipsec-secgw: limit inflight packets count

Message ID 1525856321-27612-1-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Radu Nicolau May 9, 2018, 8:58 a.m. UTC
  Revert previous patch that introduce a performance
degradation in certain scenarios and add a configurable
limit for number inflight packets.

Revert
commit 84d4b5e4ec48 ("examples/ipsec-secgw: improve IPsec dequeue logic")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
v3: updated enqueue size trim computation

 examples/ipsec-secgw/ipsec.c | 32 +++++++++++++++-----------------
 examples/ipsec-secgw/ipsec.h |  1 +
 2 files changed, 16 insertions(+), 17 deletions(-)
  

Comments

Akhil Goyal May 9, 2018, 12:02 p.m. UTC | #1
On 5/9/2018 2:28 PM, Radu Nicolau wrote:
> Revert previous patch that introduce a performance
> degradation in certain scenarios and add a configurable
> limit for number inflight packets.
>
> Revert
> commit 84d4b5e4ec48 ("examples/ipsec-secgw: improve IPsec dequeue logic")
> Cc: stable@dpdk.org
>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
> v3: updated enqueue size trim computation
>
>  examples/ipsec-secgw/ipsec.c | 32 +++++++++++++++-----------------
>  examples/ipsec-secgw/ipsec.h |  1 +
>  2 files changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
> index ee24973..1929752 100644
> --- a/examples/ipsec-secgw/ipsec.c
> +++ b/examples/ipsec-secgw/ipsec.c
> @@ -348,13 +348,19 @@ create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
>  static inline void
>  enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
>  {
> -	int32_t ret, i;
> +	int32_t ret = 0, i;
>
>  	cqp->buf[cqp->len++] = cop;
>
>  	if (cqp->len == MAX_PKT_BURST) {
> -		ret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp,
> -				cqp->buf, cqp->len);
> +		int enq_size = cqp->len;
> +		if ((cqp->in_flight + enq_size) >= MAX_INFLIGHT)

This should be ((cqp->in_flight + enq_size) > MAX_INFLIGHT). there Will 
be one extra operation in case it is equal.

Otherwise,
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  
De Lara Guarch, Pablo May 9, 2018, 3:02 p.m. UTC | #2
> -----Original Message-----
> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
> Sent: Wednesday, May 9, 2018 1:02 PM
> To: Nicolau, Radu <radu.nicolau@intel.com>; dev@dpdk.org
> Cc: akhil.goyal@nxp.com; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3] examples/ipsec-secgw: limit inflight packets
> count
> 
> On 5/9/2018 2:28 PM, Radu Nicolau wrote:
> > Revert previous patch that introduce a performance degradation in
> > certain scenarios and add a configurable limit for number inflight
> > packets.
> >
> > Revert
> > commit 84d4b5e4ec48 ("examples/ipsec-secgw: improve IPsec dequeue
> > logic")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> > ---
> > v3: updated enqueue size trim computation
> >
> >  examples/ipsec-secgw/ipsec.c | 32 +++++++++++++++-----------------
> > examples/ipsec-secgw/ipsec.h |  1 +
> >  2 files changed, 16 insertions(+), 17 deletions(-)
> >
> > diff --git a/examples/ipsec-secgw/ipsec.c
> > b/examples/ipsec-secgw/ipsec.c index ee24973..1929752 100644
> > --- a/examples/ipsec-secgw/ipsec.c
> > +++ b/examples/ipsec-secgw/ipsec.c
> > @@ -348,13 +348,19 @@ create_session(struct ipsec_ctx *ipsec_ctx,
> > struct ipsec_sa *sa)  static inline void  enqueue_cop(struct cdev_qp
> > *cqp, struct rte_crypto_op *cop)  {
> > -	int32_t ret, i;
> > +	int32_t ret = 0, i;
> >
> >  	cqp->buf[cqp->len++] = cop;
> >
> >  	if (cqp->len == MAX_PKT_BURST) {
> > -		ret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp,
> > -				cqp->buf, cqp->len);
> > +		int enq_size = cqp->len;
> > +		if ((cqp->in_flight + enq_size) >= MAX_INFLIGHT)
> 
> This should be ((cqp->in_flight + enq_size) > MAX_INFLIGHT). there Will be one
> extra operation in case it is equal.
> 
> Otherwise,
> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>

Applied to dpdk-next-crypto, with change requested.
Thanks,

Pablo
  

Patch

diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index ee24973..1929752 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -348,13 +348,19 @@  create_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa)
 static inline void
 enqueue_cop(struct cdev_qp *cqp, struct rte_crypto_op *cop)
 {
-	int32_t ret, i;
+	int32_t ret = 0, i;
 
 	cqp->buf[cqp->len++] = cop;
 
 	if (cqp->len == MAX_PKT_BURST) {
-		ret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp,
-				cqp->buf, cqp->len);
+		int enq_size = cqp->len;
+		if ((cqp->in_flight + enq_size) >= MAX_INFLIGHT)
+			enq_size -=
+			    (int)((cqp->in_flight + enq_size) - MAX_INFLIGHT);
+
+		if (enq_size > 0)
+			ret = rte_cryptodev_enqueue_burst(cqp->id, cqp->qp,
+					cqp->buf, enq_size);
 		if (ret < cqp->len) {
 			RTE_LOG_DP(DEBUG, IPSEC, "Cryptodev %u queue %u:"
 					" enqueued %u crypto ops out of %u\n",
@@ -489,9 +495,12 @@  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;) {
+	for (i = 0; i < ipsec_ctx->nb_qps && nb_pkts < max_pkts; i++) {
 		struct cdev_qp *cqp;
-		cqp = &ipsec_ctx->tbl[ipsec_ctx->last_qp];
+
+		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;
 
 		while (ipsec_ctx->ol_pkts_cnt > 0 && nb_pkts < max_pkts) {
 			pkt = ipsec_ctx->ol_pkts[--ipsec_ctx->ol_pkts_cnt];
@@ -506,13 +515,8 @@  ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 			pkts[nb_pkts++] = pkt;
 		}
 
-		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++;
+		if (cqp->in_flight == 0)
 			continue;
-		}
 
 		nb_cops = rte_cryptodev_dequeue_burst(cqp->id, cqp->qp,
 				cops, max_pkts - nb_pkts);
@@ -536,12 +540,6 @@  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++;
-			}
 		}
 	}
 
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index c1450f6..9b87278 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -17,6 +17,7 @@ 
 #define RTE_LOGTYPE_IPSEC_IPIP  RTE_LOGTYPE_USER3
 
 #define MAX_PKT_BURST 32
+#define MAX_INFLIGHT 128
 #define MAX_QP_PER_LCORE 256
 
 #define MAX_DIGEST_SIZE 32 /* Bytes -- 256 bits */