crypto/qat: align the the vector address

Message ID 20251202105731.851124-1-radu.nicolau@intel.com (mailing list archive)
State New
Delegated to: akhil goyal
Headers
Series crypto/qat: align the the vector address |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/github-robot-post success github post: success
ci/aws-unit-testing success Unit Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Radu Nicolau Dec. 2, 2025, 10:57 a.m. UTC
Align the vector address rather than computed source address to
make sure the alignment is properly propagated.

Fixes: 253174309ff7 ("crypto/qat: fix source buffer alignment")
Cc: stable@dpdk.org

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 33 +++++++++-----------
 1 file changed, 15 insertions(+), 18 deletions(-)
  

Comments

Ji, Kai Dec. 4, 2025, 12:18 p.m. UTC | #1
Acked-by: Kai Ji <kai.ji@intel.com>
  

Patch

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 67dc889b50..22ee0fe4fe 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -443,6 +443,21 @@  qat_sym_build_req_set_data(struct icp_qat_fw_la_bulk_req *req,
 			n_dst > QAT_SYM_SGL_MAX_NUMBER))
 		return -1;
 
+	/* For crypto API only: try to align the in-place buffers*/
+	if (op != NULL && likely(n_dst == 0) && likely(!is_sgl)) {
+		rte_iova_t offset = src_vec[0].iova & RTE_CACHE_LINE_MASK;
+		if (offset) {
+			rte_iova_t buff_addr = rte_mbuf_iova_get(op->sym->m_src);
+			/* make sure src_data_start is still within the buffer */
+			if (src_vec[0].iova - offset >= buff_addr) {
+				src_vec[0].iova -= offset;
+				src_vec[0].len += offset;
+				ofs->ofs.auth.head += offset;
+				ofs->ofs.cipher.head += offset;
+			}
+		}
+	}
+
 	if (likely(!is_sgl)) {
 		src_data_start = src_vec[0].iova;
 		tl_src = total_len_src =
@@ -503,24 +518,6 @@  qat_sym_build_req_set_data(struct icp_qat_fw_la_bulk_req *req,
 			dst_data_start = src_data_start;
 	}
 
-	/* For crypto API only try to align the in-place buffers*/
-	if (op != NULL && likely(n_dst == 0)) {
-		uint16_t offset = src_data_start & RTE_CACHE_LINE_MASK;
-		if (offset) {
-			rte_iova_t buff_addr = rte_mbuf_iova_get(op->sym->m_src);
-			/* make sure src_data_start is still within the buffer */
-			if (src_data_start - offset >= buff_addr) {
-				src_data_start -= offset;
-				dst_data_start = src_data_start;
-				ofs->ofs.auth.head += offset;
-				ofs->ofs.cipher.head += offset;
-				tl_src += offset;
-				total_len_src = tl_src;
-				total_len_dst = tl_src;
-			}
-		}
-	}
-
 	req->comn_mid.src_data_addr = src_data_start;
 	req->comn_mid.dest_data_addr = dst_data_start;
 	req->comn_mid.src_length = total_len_src;