DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@nvidia.com>
To: Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>
Subject: [PATCH] crypto/mlx5: add max segment assert
Date: Fri, 1 Mar 2024 20:42:45 +0800	[thread overview]
Message-ID: <20240301124246.1216467-1-suanmingm@nvidia.com> (raw)

Currently, for multi-segment mbuf, before crypto WQE an extra
UMR WQE will be introduced to build the contiguous memory space.
Crypto WQE uses that contiguous memory space key as input.

This commit adds assert for maximum supported segments in debug
mode in case the segments exceed UMR's limitation.

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/crypto/mlx5/mlx5_crypto_gcm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/crypto/mlx5/mlx5_crypto_gcm.c b/drivers/crypto/mlx5/mlx5_crypto_gcm.c
index 8b9953b46d..fc6ade6711 100644
--- a/drivers/crypto/mlx5/mlx5_crypto_gcm.c
+++ b/drivers/crypto/mlx5/mlx5_crypto_gcm.c
@@ -441,6 +441,9 @@ mlx5_crypto_gcm_get_op_info(struct mlx5_crypto_qp *qp,
 	op_info->digest = NULL;
 	op_info->src_addr = aad_addr;
 	if (op->sym->m_dst && op->sym->m_dst != m_src) {
+		/* Add 2 for AAD and digest. */
+		MLX5_ASSERT((uint32_t)(m_dst->nb_segs + m_src->nb_segs + 2) <
+			    qp->priv->max_klm_num);
 		op_info->is_oop = true;
 		m_dst = op->sym->m_dst;
 		dst_addr = rte_pktmbuf_mtod_offset(m_dst, void *, op->sym->aead.data.offset);
@@ -457,6 +460,9 @@ mlx5_crypto_gcm_get_op_info(struct mlx5_crypto_qp *qp,
 			op_info->need_umr = true;
 			return;
 		}
+	} else {
+		/* Add 2 for AAD and digest. */
+		MLX5_ASSERT((uint32_t)(m_src->nb_segs) + 2 < qp->priv->max_klm_num);
 	}
 	if (m_src->nb_segs > 1) {
 		op_info->need_umr = true;
-- 
2.34.1


             reply	other threads:[~2024-03-01 12:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 12:42 Suanming Mou [this message]
2024-03-01 16:09 ` Patrick Robb
2024-03-04 10:01 ` [EXTERNAL] " 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=20240301124246.1216467-1-suanmingm@nvidia.com \
    --to=suanmingm@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.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;
as well as URLs for NNTP newsgroup(s).