[PATCH 05/40] crypto/cnxk: add check for max supported gather entries
Tejasree Kondoj
ktejasree at marvell.com
Fri May 23 15:50:36 CEST 2025
From: Vidya Sagar Velumuri <vvelumuri at marvell.com>
Add check for max supported gather entries.
Signed-off-by: Vidya Sagar Velumuri <vvelumuri at marvell.com>
---
drivers/common/cnxk/roc_cpt_sg.h | 1 +
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 10 ++++++++++
drivers/crypto/cnxk/cn10k_tls_ops.h | 10 ++++++++++
3 files changed, 21 insertions(+)
diff --git a/drivers/common/cnxk/roc_cpt_sg.h b/drivers/common/cnxk/roc_cpt_sg.h
index c12187144f..e7e01cd29a 100644
--- a/drivers/common/cnxk/roc_cpt_sg.h
+++ b/drivers/common/cnxk/roc_cpt_sg.h
@@ -14,6 +14,7 @@
#define ROC_SG_ENTRY_SIZE sizeof(struct roc_sglist_comp)
#define ROC_SG_MAX_COMP 25
#define ROC_SG_MAX_DLEN_SIZE (ROC_SG_LIST_HDR_SIZE + (ROC_SG_MAX_COMP * ROC_SG_ENTRY_SIZE))
+#define ROC_SG2_MAX_PTRS 48
struct roc_sglist_comp {
union {
diff --git a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
index 2c500afbca..87442c2a1f 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
@@ -159,6 +159,11 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, struct cn10k_s
return -ENOMEM;
}
+ if (unlikely(m_src->nb_segs > ROC_SG2_MAX_PTRS)) {
+ plt_dp_err("Exceeds max supported components. Reduce segments");
+ return -1;
+ }
+
m_data = alloc_op_meta(NULL, m_info->mlen, m_info->pool, infl_req);
if (unlikely(m_data == NULL)) {
plt_dp_err("Error allocating meta buffer for request");
@@ -259,6 +264,11 @@ process_inb_sa(struct rte_crypto_op *cop, struct cn10k_sec_session *sess, struct
void *m_data;
int i;
+ if (unlikely(m_src->nb_segs > ROC_SG2_MAX_PTRS)) {
+ plt_dp_err("Exceeds max supported components. Reduce segments");
+ return -1;
+ }
+
m_data = alloc_op_meta(NULL, m_info->mlen, m_info->pool, infl_req);
if (unlikely(m_data == NULL)) {
plt_dp_err("Error allocating meta buffer for request");
diff --git a/drivers/crypto/cnxk/cn10k_tls_ops.h b/drivers/crypto/cnxk/cn10k_tls_ops.h
index c5ef3027ac..427c31425c 100644
--- a/drivers/crypto/cnxk/cn10k_tls_ops.h
+++ b/drivers/crypto/cnxk/cn10k_tls_ops.h
@@ -174,6 +174,11 @@ process_tls_write(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, struct cn10k
return -ENOMEM;
}
+ if (unlikely(m_src->nb_segs > ROC_SG2_MAX_PTRS)) {
+ plt_dp_err("Exceeds max supported components. Reduce segments");
+ return -1;
+ }
+
m_data = alloc_op_meta(NULL, m_info->mlen, m_info->pool, infl_req);
if (unlikely(m_data == NULL)) {
plt_dp_err("Error allocating meta buffer for request");
@@ -305,6 +310,11 @@ process_tls_read(struct rte_crypto_op *cop, struct cn10k_sec_session *sess,
uint32_t g_size_bytes;
int i;
+ if (unlikely(m_src->nb_segs > ROC_SG2_MAX_PTRS)) {
+ plt_dp_err("Exceeds max supported components. Reduce segments");
+ return -1;
+ }
+
m_data = alloc_op_meta(NULL, m_info->mlen, m_info->pool, infl_req);
if (unlikely(m_data == NULL)) {
plt_dp_err("Error allocating meta buffer for request");
--
2.25.1
More information about the dev
mailing list