[11/13] crypto/cnxk: switch to SG when metabuf is allocated

Message ID 20221020111453.1982947-5-ktejasree@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series fixes and improvements to cnxk crypto PMD |

Commit Message

Tejasree Kondoj Oct. 20, 2022, 11:14 a.m. UTC
  From: Anoob Joseph <anoobj@marvell.com>

Metabuf would be allocated only when SG is required. Check the pointer
instead of flags.

Coverity issue: 381018
Fixes: d3bff77cc371 ("crypto/cnxk: separate out PDCP chain datapath")

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
 drivers/crypto/cnxk/cnxk_se.h | 33 ++++++---------------------------
 1 file changed, 6 insertions(+), 27 deletions(-)
  

Comments

Akhil Goyal Oct. 25, 2022, 7:21 a.m. UTC | #1
> Subject: [PATCH 11/13] crypto/cnxk: switch to SG when metabuf is allocated
> 
> From: Anoob Joseph <anoobj@marvell.com>
> 
> Metabuf would be allocated only when SG is required. Check the pointer
> instead of flags.
> 
> Coverity issue: 381018
> Fixes: d3bff77cc371 ("crypto/cnxk: separate out PDCP chain datapath")
> 
> Signed-off-by: Anoob Joseph <anoobj@marvell.com>
This patch is removed from the dpdk-next-crypto as it is causing build failures on RHEL 7/8.
Please resubmit after fixing.
  

Patch

diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index abb9965d3e..ac97b864b9 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -1177,14 +1177,7 @@  cpt_enc_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 	offset_ctrl = rte_cpu_to_be_64(((uint64_t)encr_offset << 16) | ((uint64_t)iv_offset << 8) |
 				       ((uint64_t)auth_offset));
 
-	/*
-	 * In cn9k, cn10k since we have a limitation of
-	 * IV & Offset control word not part of instruction
-	 * and need to be part of Data Buffer, we check if
-	 * head room is there and then only do the Direct mode processing
-	 */
-	if (likely((flags & ROC_SE_SINGLE_BUF_INPLACE) &&
-		   (flags & ROC_SE_SINGLE_BUF_HEADROOM))) {
+	if (likely(fc_params->meta_buf.vaddr == NULL)) {
 		void *dm_vaddr = fc_params->bufs[0].vaddr;
 
 		/* Use Direct mode */
@@ -1336,13 +1329,7 @@  cpt_dec_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens,
 	offset_ctrl = rte_cpu_to_be_64(((uint64_t)encr_offset << 16) | ((uint64_t)iv_offset << 8) |
 				       ((uint64_t)auth_offset));
 
-	/*
-	 * In cn9k, cn10k since we have a limitation of
-	 * IV & Offset control word not part of instruction
-	 * and need to be part of Data Buffer, we check if
-	 * head room is there and then only do the Direct mode processing
-	 */
-	if (likely((flags & ROC_SE_SINGLE_BUF_INPLACE) && (flags & ROC_SE_SINGLE_BUF_HEADROOM))) {
+	if (likely(fc_params->meta_buf.vaddr == NULL)) {
 		void *dm_vaddr = fc_params->bufs[0].vaddr;
 
 		/* Use Direct mode */
@@ -1398,6 +1385,7 @@  cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 	uint32_t encr_data_len, auth_data_len, aad_len, passthr_len, pad_len, hdr_len;
 	uint32_t encr_offset, auth_offset, iv_offset = 0;
 	uint8_t *auth_iv = NULL, *cipher_iv = NULL;
+	void *m_vaddr = params->meta_buf.vaddr;
 	uint8_t pdcp_ci_alg, pdcp_auth_alg;
 	union cpt_inst_w4 cpt_inst_w4;
 	struct roc_se_ctx *se_ctx;
@@ -1462,8 +1450,7 @@  cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 
 	inputlen += (encr_offset + pad_len);
 
-	if (likely(((req_flags & ROC_SE_SINGLE_BUF_INPLACE)) &&
-		   ((req_flags & ROC_SE_SINGLE_BUF_HEADROOM)))) {
+	if (likely(m_vaddr == NULL)) {
 
 		dm_vaddr = params->bufs[0].vaddr;
 
@@ -1489,9 +1476,7 @@  cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 		pdcp_iv_copy(iv_d, auth_iv, pdcp_auth_alg, pack_iv);
 
 	} else {
-
 		struct roc_se_sglist_comp *scatter_comp, *gather_comp;
-		void *m_vaddr = params->meta_buf.vaddr;
 		uint32_t i, g_size_bytes, s_size_bytes;
 		uint8_t *in_buffer;
 		uint32_t size;
@@ -1711,14 +1696,7 @@  cpt_pdcp_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,
 	cpt_inst_w4.s.param1 = encr_data_len;
 	cpt_inst_w4.s.param2 = auth_data_len;
 
-	/*
-	 * In cn9k, cn10k since we have a limitation of
-	 * IV & Offset control word not part of instruction
-	 * and need to be part of Data Buffer, we check if
-	 * head room is there and then only do the Direct mode processing
-	 */
-	if (likely((req_flags & ROC_SE_SINGLE_BUF_INPLACE) &&
-		   (req_flags & ROC_SE_SINGLE_BUF_HEADROOM))) {
+	if (likely(params->meta_buf.vaddr == NULL)) {
 		void *dm_vaddr = params->bufs[0].vaddr;
 
 		/* Use Direct mode */
@@ -2889,6 +2867,7 @@  fill_pdcp_chain_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,
 		}
 	}
 
+	fc_params.meta_buf.vaddr = NULL;
 	if (unlikely(!((flags & ROC_SE_SINGLE_BUF_INPLACE) &&
 		       (flags & ROC_SE_SINGLE_BUF_HEADROOM)))) {
 		mdata = alloc_op_meta(&fc_params.meta_buf, m_info->mlen, m_info->pool, infl_req);