]> git.droids-corp.org - dpdk.git/commitdiff
crypto/dpaa2_sec: fix chained FD length in raw datapath
authorGagandeep Singh <g.singh@nxp.com>
Thu, 28 Apr 2022 11:47:23 +0000 (17:17 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 29 Apr 2022 09:27:35 +0000 (11:27 +0200)
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>
Acked-by: Akhil Goyal <gakhil@marvell.com>
drivers/crypto/dpaa2_sec/dpaa2_sec_raw_dp.c

index 74f204563726b3a0221c0a564ce28461888266a4..e68a4875dd8e14a53524c791e602cfadb1bccf08 100644 (file)
@@ -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) {