From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org, gakhil@marvell.com
Cc: Franck LENORMAND <franck.lenormand@nxp.com>
Subject: [dpdk-dev] [PATCH v2 06/11] common/dpaax: caamflib load correct HFN from DESCBUF
Date: Wed, 25 Aug 2021 13:48:32 +0530 [thread overview]
Message-ID: <20210825081837.23830-6-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20210825081837.23830-1-hemant.agrawal@nxp.com>
From: Franck LENORMAND <franck.lenormand@nxp.com>
The offset of the HFn word and Bearer/Dir word is different
depending on type of PDB.
The wrong value was used.
This patch address this issue
Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
---
drivers/common/dpaax/caamflib/desc/pdcp.h | 7 +-
drivers/common/dpaax/caamflib/desc/sdap.h | 96 ++++++++++++++++++-----
2 files changed, 80 insertions(+), 23 deletions(-)
diff --git a/drivers/common/dpaax/caamflib/desc/pdcp.h b/drivers/common/dpaax/caamflib/desc/pdcp.h
index 659e289a45..e97d58cbc1 100644
--- a/drivers/common/dpaax/caamflib/desc/pdcp.h
+++ b/drivers/common/dpaax/caamflib/desc/pdcp.h
@@ -270,6 +270,9 @@ enum pdb_type_e {
PDCP_PDB_TYPE_INVALID
};
+#define REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET 4
+#define FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET 8
+
/**
* rta_inline_pdcp_query() - Provide indications if a key can be passed as
* immediate data or shall be referenced in a
@@ -2564,11 +2567,11 @@ insert_hfn_ov_op(struct program *p,
return 0;
case PDCP_PDB_TYPE_REDUCED_PDB:
- hfn_pdb_offset = 4;
+ hfn_pdb_offset = REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
break;
case PDCP_PDB_TYPE_FULL_PDB:
- hfn_pdb_offset = 8;
+ hfn_pdb_offset = FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
break;
default:
diff --git a/drivers/common/dpaax/caamflib/desc/sdap.h b/drivers/common/dpaax/caamflib/desc/sdap.h
index 6523db1733..f1c49ea3e6 100644
--- a/drivers/common/dpaax/caamflib/desc/sdap.h
+++ b/drivers/common/dpaax/caamflib/desc/sdap.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2020 NXP
+ * Copyright 2020-2021 NXP
*/
#ifndef __DESC_SDAP_H__
@@ -109,12 +109,17 @@ static inline int pdcp_sdap_insert_no_int_op(struct program *p,
bool swap __maybe_unused,
struct alginfo *cipherdata,
unsigned int dir,
- enum pdcp_sn_size sn_size)
+ enum pdcp_sn_size sn_size,
+ enum pdb_type_e pdb_type)
{
int op;
uint32_t sn_mask = 0;
uint32_t length = 0;
uint32_t offset = 0;
+ int hfn_bearer_dir_offset_in_descbuf =
+ (pdb_type == PDCP_PDB_TYPE_FULL_PDB) ?
+ FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET :
+ REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
if (pdcp_sdap_get_sn_parameters(sn_size, swap, &offset, &length,
&sn_mask))
@@ -137,7 +142,8 @@ static inline int pdcp_sdap_insert_no_int_op(struct program *p,
SEQSTORE(p, MATH0, offset, length, 0);
MATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);
- MOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);
+ MOVEB(p, DESCBUF, hfn_bearer_dir_offset_in_descbuf,
+ MATH2, 0, 8, WAITCOMP | IMMED);
MATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);
MATHB(p, SEQINSZ, SUB, MATH3, VSEQINSZ, 4, 0);
@@ -190,9 +196,14 @@ pdcp_sdap_insert_enc_only_op(struct program *p, bool swap __maybe_unused,
struct alginfo *cipherdata,
struct alginfo *authdata __maybe_unused,
unsigned int dir, enum pdcp_sn_size sn_size,
- unsigned char era_2_sw_hfn_ovrd __maybe_unused)
+ unsigned char era_2_sw_hfn_ovrd __maybe_unused,
+ enum pdb_type_e pdb_type)
{
uint32_t offset = 0, length = 0, sn_mask = 0;
+ int hfn_bearer_dir_offset_in_descbuf =
+ (pdb_type == PDCP_PDB_TYPE_FULL_PDB) ?
+ FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET :
+ REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
if (pdcp_sdap_get_sn_parameters(sn_size, swap, &offset, &length,
&sn_mask))
@@ -217,7 +228,8 @@ pdcp_sdap_insert_enc_only_op(struct program *p, bool swap __maybe_unused,
/* Word (32 bit) swap */
MATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);
/* Load words from PDB: word 02 (HFN) + word 03 (bearer_dir)*/
- MOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);
+ MOVEB(p, DESCBUF, hfn_bearer_dir_offset_in_descbuf,
+ MATH2, 0, 8, WAITCOMP | IMMED);
/* Create basic IV */
MATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);
@@ -309,13 +321,18 @@ static inline int
pdcp_sdap_insert_snoop_op(struct program *p, bool swap __maybe_unused,
struct alginfo *cipherdata, struct alginfo *authdata,
unsigned int dir, enum pdcp_sn_size sn_size,
- unsigned char era_2_sw_hfn_ovrd __maybe_unused)
+ unsigned char era_2_sw_hfn_ovrd __maybe_unused,
+ enum pdb_type_e pdb_type)
{
uint32_t offset = 0, length = 0, sn_mask = 0;
uint32_t int_op_alg = 0;
uint32_t int_op_aai = 0;
uint32_t cipher_op_alg = 0;
uint32_t cipher_op_aai = 0;
+ int hfn_bearer_dir_offset_in_descbuf =
+ (pdb_type == PDCP_PDB_TYPE_FULL_PDB) ?
+ FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET :
+ REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
if (authdata->algtype == PDCP_CIPHER_TYPE_ZUC) {
if (rta_sec_era < RTA_SEC_ERA_5) {
@@ -362,11 +379,13 @@ pdcp_sdap_insert_snoop_op(struct program *p, bool swap __maybe_unused,
/* Load the HFN / Beare / Dir from the PDB
* CAAM word are 32bit hence loading 8 byte loads 2 words:
- * - The HFN at offset 8
- * - The Bearer / Dir at offset 12
+ * - The HFN at offset hfn_bearer_dir_offset_in_descbuf
+ * - The Bearer / Dir at next word
*/
- MOVEB(p, DESCBUF, 8, MATH2, 0, 8, WAITCOMP | IMMED);
- /* Create the 4 first byte of the ICV by oring the math registers */
+ MOVEB(p, DESCBUF, hfn_bearer_dir_offset_in_descbuf,
+ MATH2, 0, 8, WAITCOMP | IMMED);
+
+ /* Create the 4 first byte of the ICV by or-ing the math registers */
MATHB(p, MATH1, OR, MATH2, MATH1, 8, 0);
/* Set the IV of class 1 CHA */
@@ -562,11 +581,16 @@ pdcp_sdap_insert_snoop_op(struct program *p, bool swap __maybe_unused,
static inline int pdcp_sdap_insert_no_snoop_op(
struct program *p, bool swap __maybe_unused, struct alginfo *cipherdata,
struct alginfo *authdata, unsigned int dir, enum pdcp_sn_size sn_size,
- unsigned char era_2_sw_hfn_ovrd __maybe_unused)
+ unsigned char era_2_sw_hfn_ovrd __maybe_unused,
+ enum pdb_type_e pdb_type)
{
uint32_t offset = 0, length = 0, sn_mask = 0;
uint32_t cipher_alg_op = 0;
uint32_t cipher_alg_aai = 0;
+ int hfn_bearer_dir_offset_in_descbuf =
+ (pdb_type == PDCP_PDB_TYPE_FULL_PDB) ?
+ FULL_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET :
+ REDUCED_PDB_DESCBUF_HFN_BEARER_DIR_OFFSET;
if (authdata->algtype == PDCP_CIPHER_TYPE_ZUC) {
if (rta_sec_era < RTA_SEC_ERA_5) {
@@ -592,7 +616,8 @@ static inline int pdcp_sdap_insert_no_snoop_op(
#endif
MATHB(p, MATH1, SHLD, MATH1, MATH1, 8, 0);
- MOVEB(p, DESCBUF, 8, MATH2, 0, 0x08, WAITCOMP | IMMED);
+ MOVEB(p, DESCBUF, hfn_bearer_dir_offset_in_descbuf,
+ MATH2, 0, 0x08, WAITCOMP | IMMED);
MATHB(p, MATH1, OR, MATH2, MATH2, 8, 0);
SEQSTORE(p, MATH0, offset, length, 0);
@@ -753,22 +778,51 @@ static inline int pdcp_sdap_insert_no_snoop_op(
return 0;
}
+static inline int
+pdcp_sdap_insert_cplane_null_op(struct program *p,
+ bool swap __maybe_unused,
+ struct alginfo *cipherdata,
+ struct alginfo *authdata,
+ unsigned int dir,
+ enum pdcp_sn_size sn_size,
+ unsigned char era_2_sw_hfn_ovrd,
+ enum pdb_type_e pdb_type __maybe_unused)
+{
+ return pdcp_insert_cplane_int_only_op(p, swap, cipherdata, authdata,
+ dir, sn_size, era_2_sw_hfn_ovrd);
+}
+
+static inline int
+pdcp_sdap_insert_cplane_int_only_op(struct program *p,
+ bool swap __maybe_unused,
+ struct alginfo *cipherdata,
+ struct alginfo *authdata,
+ unsigned int dir,
+ enum pdcp_sn_size sn_size,
+ unsigned char era_2_sw_hfn_ovrd,
+ enum pdb_type_e pdb_type __maybe_unused)
+{
+ return pdcp_insert_cplane_int_only_op(p, swap, cipherdata, authdata,
+ dir, sn_size, era_2_sw_hfn_ovrd);
+}
+
static int pdcp_sdap_insert_with_int_op(
struct program *p, bool swap __maybe_unused, struct alginfo *cipherdata,
struct alginfo *authdata, enum pdcp_sn_size sn_size,
- unsigned char era_2_sw_hfn_ovrd, unsigned int dir)
+ unsigned char era_2_sw_hfn_ovrd, unsigned int dir,
+ enum pdb_type_e pdb_type)
{
static int (
*pdcp_cp_fp[PDCP_CIPHER_TYPE_INVALID][PDCP_AUTH_TYPE_INVALID])(
struct program *, bool swap, struct alginfo *, struct alginfo *,
unsigned int, enum pdcp_sn_size,
- unsigned char __maybe_unused) = {
+ unsigned char __maybe_unused, enum pdb_type_e pdb_type) = {
{
/* NULL */
- pdcp_insert_cplane_null_op, /* NULL */
- pdcp_insert_cplane_int_only_op, /* SNOW f9 */
- pdcp_insert_cplane_int_only_op, /* AES CMAC */
- pdcp_insert_cplane_int_only_op /* ZUC-I */
+ pdcp_sdap_insert_cplane_null_op, /* NULL */
+ pdcp_sdap_insert_cplane_int_only_op, /* SNOW f9 */
+ pdcp_sdap_insert_cplane_int_only_op, /* AES CMAC */
+ pdcp_sdap_insert_cplane_int_only_op /* ZUC-I */
},
{
/* SNOW f8 */
@@ -796,7 +850,7 @@ static int pdcp_sdap_insert_with_int_op(
err = pdcp_cp_fp[cipherdata->algtype]
[authdata->algtype](p, swap, cipherdata, authdata, dir,
- sn_size, era_2_sw_hfn_ovrd);
+ sn_size, era_2_sw_hfn_ovrd, pdb_type);
if (err)
return err;
@@ -948,7 +1002,7 @@ cnstr_shdsc_pdcp_sdap_u_plane(uint32_t *descbuf,
} else {
err = pdcp_sdap_insert_no_int_op(p, swap, cipherdata,
caps_mode,
- sn_size);
+ sn_size, pdb_type);
if (err) {
pr_err("Fail pdcp_sdap_insert_no_int_op\n");
return err;
@@ -958,7 +1012,7 @@ cnstr_shdsc_pdcp_sdap_u_plane(uint32_t *descbuf,
err = pdcp_sdap_insert_with_int_op(p, swap, cipherdata,
authdata, sn_size,
era_2_sw_hfn_ovrd,
- caps_mode);
+ caps_mode, pdb_type);
if (err) {
pr_err("Fail pdcp_sdap_insert_with_int_op\n");
return err;
--
2.17.1
next prev parent reply other threads:[~2021-08-25 8:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 7:39 [dpdk-dev] [PATCH 1/5] crypto/dpaa2_sec: fix to check next null for auth only case Hemant Agrawal
2021-07-21 7:39 ` [dpdk-dev] [PATCH 2/5] crypto/dpaa_sec: support DES-CBC Hemant Agrawal
2021-07-21 7:39 ` [dpdk-dev] [PATCH 3/5] crypto/dpaa_sec: support non-HMAC auth algos Hemant Agrawal
2021-07-21 7:39 ` [dpdk-dev] [PATCH 4/5] crypto/dpaa_sec: support AES-XCBC-MAC Hemant Agrawal
2021-07-21 7:39 ` [dpdk-dev] [PATCH 5/5] crypto/dpaa_sec: add support for AES CMAC integrity check Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 01/11] crypto/dpaa2_sec: fix to check next null for auth only case Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 02/11] crypto/dpaa_sec: support DES-CBC Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 03/11] crypto/dpaa_sec: support non-HMAC auth algos Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 04/11] crypto/dpaa_sec: support AES-XCBC-MAC Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 05/11] crypto/dpaa_sec: add support for AES CMAC integrity check Hemant Agrawal
2021-09-02 13:46 ` [dpdk-dev] [EXT] " Akhil Goyal
2021-08-25 8:18 ` Hemant Agrawal [this message]
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 07/11] common/dpaax: caamflib do not clear DPOVRD Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 08/11] common/dpaax: enhance caamflib with inline keys Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 09/11] common/dpaax: fix IV value for shortMAC-I for SNOW algo Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 10/11] crypto/dpaa_sec: force inline of the keys to save space Hemant Agrawal
2021-08-25 8:18 ` [dpdk-dev] [PATCH v2 11/11] crypto/dpaa2_sec: add error packet counters Hemant Agrawal
2021-09-02 12:46 ` [dpdk-dev] [EXT] [PATCH v2 01/11] crypto/dpaa2_sec: fix to check next null for auth only case Akhil Goyal
2021-09-02 13:48 ` Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 01/10] crypto/dpaa_sec: support DES-CBC Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 02/10] crypto/dpaa_sec: support non-HMAC auth algos Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 03/10] crypto/dpaa_sec: support AES-XCBC-MAC Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 04/10] crypto/dpaa_sec: add support for AES CMAC integrity check Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 05/10] common/dpaax: caamflib load correct HFN from DESCBUF Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 06/10] common/dpaax: caamflib do not clear DPOVRD Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 07/10] common/dpaax: enhance caamflib with inline keys Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 08/10] common/dpaax: fix IV value for shortMAC-I for SNOW algo Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 09/10] crypto/dpaa_sec: force inline of the keys to save space Hemant Agrawal
2021-09-07 8:39 ` [dpdk-dev] [PATCH v3 10/10] crypto/dpaa2_sec: add error packet counters Hemant Agrawal
2021-09-07 11:47 ` [dpdk-dev] [EXT] [PATCH v3 01/10] crypto/dpaa_sec: support DES-CBC Akhil Goyal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 " Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 02/10] crypto/dpaa_sec: support non-HMAC auth algos Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 03/10] crypto/dpaa_sec: support AES-XCBC-MAC Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 04/10] crypto/dpaa_sec: add support for AES CMAC integrity check Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 05/10] common/dpaax: caamflib load correct HFN from DESCBUF Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 06/10] common/dpaax: caamflib do not clear DPOVRD Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 07/10] common/dpaax: enhance caamflib with inline keys Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 08/10] common/dpaax: fix IV value for shortMAC-I for SNOW algo Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 09/10] crypto/dpaa_sec: force inline of the keys to save space Hemant Agrawal
2021-09-08 6:59 ` [dpdk-dev] [PATCH v4 10/10] crypto/dpaa2_sec: add error packet counters Hemant Agrawal
2021-09-08 10:13 ` [dpdk-dev] [EXT] [PATCH v4 01/10] crypto/dpaa_sec: support DES-CBC Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210825081837.23830-6-hemant.agrawal@nxp.com \
--to=hemant.agrawal@nxp.com \
--cc=dev@dpdk.org \
--cc=franck.lenormand@nxp.com \
--cc=gakhil@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).