[v2,04/14] crypto/dpaa2_sec: fix length for chain FD in raw sec driver
Checks
Commit Message
DPAA2 sec raw driver is calculating the wrong lengths while
creating the FD for chain.
This patch fixes lengths for chain FD.
Fixes: aa6ec1fd8443 ("crypto/dpaa2_sec: support authenc with raw buffer API")
Cc: stable@dpdk.org
Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2021 NXP
+ * Copyright 2021-2022 NXP
*/
#include <cryptodev_pmd.h>
@@ -44,8 +44,8 @@ build_raw_dp_chain_fd(uint8_t *drv_ctx,
uint16_t auth_hdr_len = ofs.ofs.cipher.head -
ofs.ofs.auth.head;
- uint16_t auth_tail_len = ofs.ofs.auth.tail;
- uint32_t auth_only_len = (auth_tail_len << 16) | auth_hdr_len;
+ uint16_t auth_tail_len;
+ uint32_t auth_only_len;
int icv_len = sess->digest_length;
uint8_t *old_icv;
uint8_t *iv_ptr = iv->va;
@@ -55,6 +55,8 @@ build_raw_dp_chain_fd(uint8_t *drv_ctx,
cipher_len = data_len - ofs.ofs.cipher.head - ofs.ofs.cipher.tail;
auth_len = data_len - ofs.ofs.auth.head - ofs.ofs.auth.tail;
+ auth_tail_len = auth_len - cipher_len - auth_hdr_len;
+ auth_only_len = (auth_tail_len << 16) | auth_hdr_len;
/* first FLE entry used to store session ctxt */
fle = (struct qbman_fle *)rte_malloc(NULL,
FLE_SG_MEM_SIZE(2 * sgl->num),
@@ -104,6 +106,7 @@ build_raw_dp_chain_fd(uint8_t *drv_ctx,
DPAA2_SET_FLE_OFFSET(sge, 0);
sge->length = dest_sgl->vec[i].len;
}
+ sge->length -= ofs.ofs.cipher.tail;
} else {
/* Configure Output SGE for Encap/Decap */
DPAA2_SET_FLE_ADDR(sge, sgl->vec[0].iova);
@@ -117,6 +120,7 @@ build_raw_dp_chain_fd(uint8_t *drv_ctx,
DPAA2_SET_FLE_OFFSET(sge, 0);
sge->length = sgl->vec[i].len;
}
+ sge->length -= ofs.ofs.cipher.tail;
}
if (sess->dir == DIR_ENC) {