[04/12] crypto/cnxk: avoid branches in datapath

Message ID 20240314083844.3319506-5-vvelumuri@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series Add TLS features |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Vidya Sagar Velumuri March 14, 2024, 8:38 a.m. UTC
  From: Anoob Joseph <anoobj@marvell.com>

Avoid branches in datapath.

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

Patch

diff --git a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
index a30b8e413d..4e95fbb6eb 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
@@ -73,12 +73,10 @@  process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, struct cn10k_s
 	roc_cpt_lf_ctx_reload(lf, &sess->sa.out_sa);
 	rte_delay_ms(1);
 #endif
+	const uint64_t ol_flags = m_src->ol_flags;
 
-	if (m_src->ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
-		inst_w4_u64 &= ~BIT_ULL(33);
-
-	if (m_src->ol_flags & RTE_MBUF_F_TX_L4_MASK)
-		inst_w4_u64 &= ~BIT_ULL(32);
+	inst_w4_u64 &= ~(((uint64_t)(!!(ol_flags & RTE_MBUF_F_TX_IP_CKSUM)) << 33) |
+			 ((uint64_t)(!!(ol_flags & RTE_MBUF_F_TX_L4_MASK)) << 32));
 
 	if (likely(m_src->next == NULL)) {
 		if (unlikely(rte_pktmbuf_tailroom(m_src) < sess->max_extended_len)) {