[PATCH 16/16] crypto/cnxk: size CN20K IPsec SA by context length
Tejasree Kondoj
ktejasree at marvell.com
Mon Oct 19 15:07:57 CEST 2026
From: Rupesh Chiluka <rchiluka at 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 at marvell.com>
Signed-off-by: Rupesh Chiluka <rchiluka at 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
More information about the dev
mailing list