DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tejasree Kondoj <ktejasree@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: Rupesh Chiluka <rchiluka@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	 Vidya Sagar Velumuri <vvelumuri@marvell.com>,
	Ankur Dwivedi <adwivedi@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>, <dev@dpdk.org>
Subject: [PATCH 16/16] crypto/cnxk: size CN20K IPsec SA by context length
Date: Mon, 19 Oct 2026 18:37:57 +0530	[thread overview]
Message-ID: <20261019130759.2181566-17-ktejasree@marvell.com> (raw)
In-Reply-To: <20261019130759.2181566-1-ktejasree@marvell.com>

From: Rupesh Chiluka <rchiluka@marvell.com>

Allocate the CN20K inbound/outbound IPsec SA with a size of at least
(ctx_ilen + 1) * 128 bytes when ctx_ilen is set, so larger contexts
such as a 1 KiB SA are supported. Zero the full allocation instead of
only the default SA size.

Also advertise ctx_ilen in the PMD param string.

Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Signed-off-by: Rupesh Chiluka <rchiluka@marvell.com>
---
 drivers/crypto/cnxk/cn20k_ipsec.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/cnxk/cn20k_ipsec.c b/drivers/crypto/cnxk/cn20k_ipsec.c
index b2cab4ff5f..c7fe670724 100644
--- a/drivers/crypto/cnxk/cn20k_ipsec.c
+++ b/drivers/crypto/cnxk/cn20k_ipsec.c
@@ -31,12 +31,17 @@ cn20k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	struct cnxk_ipsec_outb_rlens rlens;
 	struct cn20k_ipsec_sa *sa;
 	union cpt_inst_w4 inst_w4;
+	size_t out_sa_sz;
 	void *out_sa;
 	int ret = 0;
 
 	sa = &sec_sess->sa;
 
-	out_sa = rte_zmalloc("cn20k_cpt", sizeof(struct roc_ow_ipsec_outb_sa), ROC_CPTR_ALIGN);
+	out_sa_sz = sizeof(struct roc_ow_ipsec_outb_sa);
+	if (roc_cpt->ctx_ilen)
+		out_sa_sz = PLT_MAX(out_sa_sz, (size_t)(roc_cpt->ctx_ilen + 1) * ROC_CTX_UNIT_128B);
+
+	out_sa = rte_zmalloc("cn20k_cpt", out_sa_sz, ROC_CPTR_ALIGN);
 	if (out_sa == NULL) {
 		plt_err("Couldn't allocate memory for outbound SA");
 		return -ENOMEM;
@@ -124,7 +129,7 @@ cn20k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 		sa_dptr->w0.s.count_glb_octets = 1;
 	}
 
-	memset(out_sa, 0, sizeof(struct roc_ow_ipsec_outb_sa));
+	memset(out_sa, 0, out_sa_sz);
 
 	/* Copy word0 from sa_dptr to populate ctx_push_sz ctx_size fields */
 	memcpy(out_sa, sa_dptr, 8);
@@ -161,12 +166,17 @@ cn20k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	struct roc_ow_ipsec_inb_sa *sa_dptr;
 	struct cn20k_ipsec_sa *sa;
 	union cpt_inst_w4 inst_w4;
+	size_t in_sa_sz;
 	void *in_sa;
 	int ret = 0;
 
 	sa = &sec_sess->sa;
 
-	in_sa = rte_zmalloc("cn20k_cpt", sizeof(struct roc_ow_ipsec_inb_sa), ROC_CPTR_ALIGN);
+	in_sa_sz = sizeof(struct roc_ow_ipsec_inb_sa);
+	if (roc_cpt->ctx_ilen)
+		in_sa_sz = PLT_MAX(in_sa_sz, (size_t)(roc_cpt->ctx_ilen + 1) * ROC_CTX_UNIT_128B);
+
+	in_sa = rte_zmalloc("cn20k_cpt", in_sa_sz, ROC_CPTR_ALIGN);
 	if (in_sa == NULL) {
 		plt_err("Couldn't allocate memory for inbound SA");
 		return -ENOMEM;
@@ -231,7 +241,7 @@ cn20k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 		sa_dptr->w0.s.count_glb_octets = 1;
 	}
 
-	memset(in_sa, 0, sizeof(struct roc_ow_ipsec_inb_sa));
+	memset(in_sa, 0, in_sa_sz);
 
 	/* Copy word0 from sa_dptr to populate ctx_push_sz ctx_size fields */
 	memcpy(in_sa, sa_dptr, 8);
-- 
2.43.0


  parent reply	other threads:[~2026-10-19 13:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 13:07 [PATCH 00/16] fixes and improvements to cnxk crypto PMD Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 01/16] common/cnxk: use context invalidate for cn20k Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 02/16] crypto/cnxk: return HW CPTR from cptr_get " Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 03/16] crypto/cnxk: enable cq_all and allocate extra CQ line Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 04/16] common/cnxk: validate cipher key length in IPsec SA fill Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 05/16] crypto/cnxk: reject truncated TLS records in decrypt Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 06/16] crypto/cnxk: fix CN20K CPT error recovery Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 07/16] crypto/cnxk: validate TLS xform and keys before SA key copy Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 08/16] crypto/cnxk: reject oversized SG vectors in raw datapath Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 09/16] crypto/cnxk: guard trim len bounds in TLS 1.2 MAC trim Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 10/16] crypto/cnxk: enable ctx cache for cn20k crypto Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 11/16] crypto/cnxk: guard trim len in TLS 1.2 MAC trim for CN20K Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 12/16] crypto/cnxk: validate TLS 1.2 MAC trim lengths Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 13/16] crypto/cnxk: bound SG segment count in packet iov builders Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 14/16] crypto/cnxk: bound SG iovec index in mbuf walk Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 15/16] crypto/cnxk: add cq_ena devarg for CPT CQ mode Tejasree Kondoj
2026-10-19 13:07 ` Tejasree Kondoj [this message]
2026-10-22 18:46 ` [PATCH 00/16] fixes and improvements to cnxk crypto PMD Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261019130759.2181566-17-ktejasree@marvell.com \
    --to=ktejasree@marvell.com \
    --cc=adwivedi@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rchiluka@marvell.com \
    --cc=vvelumuri@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox