[v2,09/12] crypto/cnxk: update sess pointer for next iteration

Message ID 20240624062401.4143606-10-asasidharan@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series fixes and improvements to CNXK crypto PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Aakash Sasidharan June 24, 2024, 6:23 a.m. UTC
From: Anoob Joseph <anoobj@marvell.com>

Update sess pointer while working on next set of packets.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index a3a13c032e..0d5a9ab5ef 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -1460,6 +1460,8 @@  cn10k_cryptodev_sec_inb_rx_inject(void *dev, struct rte_mbuf **pkts,
 
 	vf = cdev->data->dev_private;
 
+	const int nb_pkts_per_loop = 2 * CN10K_PKTS_PER_LOOP;
+
 	lmt_base = vf->rx_inj_lmtline.lmt_base;
 	io_addr = vf->rx_inj_lmtline.io_addr;
 	fc_addr = vf->rx_inj_lmtline.fc_addr;
@@ -1479,7 +1481,7 @@  cn10k_cryptodev_sec_inb_rx_inject(void *dev, struct rte_mbuf **pkts,
 	if (unlikely(fc.s.qsize > fc_thresh))
 		goto exit;
 
-	for (; i < RTE_MIN(2 * CN10K_PKTS_PER_LOOP, nb_pkts); i++) {
+	for (; i < RTE_MIN(nb_pkts_per_loop, nb_pkts); i++) {
 
 		m = pkts[i];
 		sec_sess = (struct cn10k_sec_session *)sess[i];
@@ -1540,10 +1542,11 @@  cn10k_cryptodev_sec_inb_rx_inject(void *dev, struct rte_mbuf **pkts,
 
 	cn10k_cpt_lmtst_dual_submit(&io_addr, lmt_id, &i);
 
-	if (nb_pkts - i > 0 && i == 2 * CN10K_PKTS_PER_LOOP) {
-		nb_pkts -= i;
-		pkts += i;
-		count += i;
+	if (nb_pkts - i > 0 && i == nb_pkts_per_loop) {
+		nb_pkts -= nb_pkts_per_loop;
+		pkts += nb_pkts_per_loop;
+		count += nb_pkts_per_loop;
+		sess += nb_pkts_per_loop;
 		goto again;
 	}