Dastin Wilski | 2f132ef | 2022-03-30 14:19:00 +0200 | [diff] [blame] | 1 | From 013a095d6b348afddceaa5ea710ef6309566dc85 Mon Sep 17 00:00:00 2001 |
| 2 | From: Kai Ji <kai.ji@intel.com> |
| 3 | Date: Fri, 25 Mar 2022 19:22:07 +0800 |
| 4 | Subject: [PATCH] crypto/qat: fix of cipher offset and length assignment |
| 5 | |
| 6 | This patch fix the cipher offset and length values when convert |
| 7 | mbuf to vector chain for QAT build op. |
| 8 | |
| 9 | Fixes: a815a04cea05 ("crypto/qat: support symmetric build op request") |
| 10 | |
| 11 | Signed-off-by: Kai Ji <kai.ji@intel.com> |
| 12 | --- |
| 13 | drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 12 ++++++------ |
| 14 | 1 file changed, 6 insertions(+), 6 deletions(-) |
| 15 | |
| 16 | diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h |
| 17 | index 50a9c5ad5b..dc473e0624 100644 |
| 18 | --- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h |
| 19 | +++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h |
| 20 | @@ -395,12 +395,12 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op, |
| 21 | ret = qat_cipher_is_len_in_bits(ctx, op); |
| 22 | switch (ret) { |
| 23 | case 1: |
| 24 | - cipher_len = op->sym->aead.data.length >> 3; |
| 25 | - cipher_ofs = op->sym->aead.data.offset >> 3; |
| 26 | + cipher_len = op->sym->cipher.data.length >> 3; |
| 27 | + cipher_ofs = op->sym->cipher.data.offset >> 3; |
| 28 | break; |
| 29 | case 0: |
| 30 | - cipher_len = op->sym->aead.data.length; |
| 31 | - cipher_ofs = op->sym->aead.data.offset; |
| 32 | + cipher_len = op->sym->cipher.data.length; |
| 33 | + cipher_ofs = op->sym->cipher.data.offset; |
| 34 | break; |
| 35 | default: |
| 36 | QAT_DP_LOG(ERR, |
| 37 | @@ -426,7 +426,6 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op, |
| 38 | return -EINVAL; |
| 39 | } |
| 40 | |
| 41 | - min_ofs = cipher_ofs < auth_ofs ? cipher_ofs : auth_ofs; |
| 42 | max_len = RTE_MAX(cipher_ofs + cipher_len, auth_ofs + auth_len); |
| 43 | |
| 44 | /* digest in buffer check. Needed only for wireless algos */ |
| 45 | @@ -463,7 +462,8 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op, |
| 46 | ctx->digest_length); |
| 47 | } |
| 48 | |
| 49 | - n_src = rte_crypto_mbuf_to_vec(op->sym->m_src, min_ofs, max_len, |
| 50 | + /* Passing 0 as cipher & auth offsets are assigned into ofs later */ |
| 51 | + n_src = rte_crypto_mbuf_to_vec(op->sym->m_src, 0, max_len, |
| 52 | in_sgl->vec, QAT_SYM_SGL_MAX_NUMBER); |
| 53 | if (unlikely(n_src < 0 || n_src > op->sym->m_src->nb_segs)) { |
| 54 | op->status = RTE_CRYPTO_OP_STATUS_ERROR; |
| 55 | -- |
| 56 | 2.25.1 |
| 57 | |