fixes and improvements to cnxk crypto PMD
Subsystems (2)
cover fixes and improvements to cnxk crypto PMD
This series adds improvements and support for 103XX CPT, PDCP AAD, DES and MD5 algorithms in cnxk crypto PMD.
Anoob Joseph (3):
crypto/cnxk: switch to SG when metabuf is allocated crypto/cnxk: verify IV length during session create crypto/cnxk: remove dead code
Tejasree Kondoj (5):
crypto/cnxk: fix length of AES-CMAC algo common/cnxk: set inplace bit of lookaside IPsec crypto/cnxk: change capabilities as per firmware common/cnxk: support 103XX CPT crypto/cnxk: support PDCP AAD in CPT PMD
Vidya Sagar Velumuri (5):
common/cnxk: support custom UDP port values crypto/cnxk: update rlen calculation for lookaside mode crypto/cnxk: add support for DES and MD5 common/cnxk: add opad ipad gen for md5 crypto/cnxk: acquire lock while updating antireplay
drivers/common/cnxk/cnxk_security.c | 75 +- drivers/common/cnxk/hw/cpt.h | 26 +- drivers/common/cnxk/roc_cpt.c | 95 - drivers/common/cnxk/roc_cpt.h | 3 - drivers/common/cnxk/roc_hash.c | 155 ++ drivers/common/cnxk/roc_hash.h | 1 + drivers/common/cnxk/roc_ie_on.h | 3 +- drivers/common/cnxk/roc_ie_ot.h | 2 + drivers/common/cnxk/roc_mbox.h | 5 +- drivers/common/cnxk/roc_nix_inl.c | 6 - drivers/common/cnxk/roc_se.h | 11 + drivers/common/cnxk/version.map | 2 +- drivers/crypto/cnxk/cn10k_cryptodev.c | 2 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 67 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.h | 9 +- drivers/crypto/cnxk/cn10k_ipsec.c | 4 +- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 2 - drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 6 +- drivers/crypto/cnxk/cn9k_ipsec.c | 53 +- drivers/crypto/cnxk/cn9k_ipsec_la_ops.h | 13 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 2 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 42 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 14 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 4 +- drivers/crypto/cnxk/cnxk_ipsec.h | 9 + drivers/crypto/cnxk/cnxk_se.h | 1734 +++++++++-------- drivers/crypto/cnxk/version.map | 3 +- drivers/event/cnxk/cn10k_eventdev.c | 13 +- drivers/net/cnxk/cn9k_ethdev_sec.c | 8 - 29 files changed, 1248 insertions(+), 1121 deletions(-)
Signature · 1 line
2.25.1
PATCH 8/13 common/cnxk: add opad ipad gen for md5
From: Vidya Sagar Velumuri <[email protected]>
Add support to generate ipad and opad for md5.
Skip the call to additional command WRITE_SA during SA creation. Instead use the software defined function to generate opad and ipad.
--- drivers/common/cnxk/cnxk_security.c | 49 ++++----- drivers/common/cnxk/roc_cpt.c | 95 ----------------- drivers/common/cnxk/roc_cpt.h | 3 - drivers/common/cnxk/roc_hash.c | 155 ++++++++++++++++++++++++++++ drivers/common/cnxk/roc_hash.h | 1 + drivers/common/cnxk/roc_ie_on.h | 2 - drivers/common/cnxk/roc_nix_inl.c | 6 -- drivers/common/cnxk/version.map | 2 +- drivers/crypto/cnxk/cn9k_ipsec.c | 7 -- drivers/net/cnxk/cn9k_ethdev_sec.c | 8 -- 10 files changed, 178 insertions(+), 150 deletions(-)
drivers/common/cnxk/cnxk_security.c +21 -28
@@ -28,6 +28,10 @@ ipsec_hmac_opad_ipad_gen(struct rte_crypto_sym_xform *auth_xform,* per packet computation */ switch (auth_xform->auth.algo) { +case RTE_CRYPTO_AUTH_MD5_HMAC : +roc_hash_md5_gen (opad, (uint32_t *)&hmac_opad_ipad[0 ]); +roc_hash_md5_gen (ipad, (uint32_t *)&hmac_opad_ipad[24 ]); +break ;case RTE_CRYPTO_AUTH_SHA1_HMAC :roc_hash_sha1_gen (opad, (uint32_t *)&hmac_opad_ipad[0 ]);roc_hash_sha1_gen (ipad, (uint32_t *)&hmac_opad_ipad[24 ]);
@@ -1218,9 +1222,7 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,struct roc_ie_on_sa_ctl *ctl;struct rte_ipv6_hdr *ip6;struct rte_ipv4_hdr *ip4; -const uint8_t *auth_key;uint16_t sport, dport; -int auth_key_len =0 ;size_t ctx_len;int ret;
@@ -1343,29 +1345,14 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec, ctx_len +=RTE_ALIGN_CEIL (ctx_len,8 );if (crypto_xform->type !=RTE_CRYPTO_SYM_XFORM_AEAD ) { - auth_key = auth_xform->auth.key.data; - auth_key_len = auth_xform->auth.key.length; +uint8_t *hmac_opad_ipad = (uint8_t *)&out_sa->sha2; -switch (auth_xform->auth.algo) { -case RTE_CRYPTO_AUTH_AES_GMAC : -case RTE_CRYPTO_AUTH_NULL : -break ; -case RTE_CRYPTO_AUTH_MD5_HMAC : -case RTE_CRYPTO_AUTH_SHA1_HMAC : -memcpy (out_sa->sha1.hmac_key, auth_key, auth_key_len); -break ; -case RTE_CRYPTO_AUTH_SHA256_HMAC : -case RTE_CRYPTO_AUTH_SHA384_HMAC : -case RTE_CRYPTO_AUTH_SHA512_HMAC : -memcpy (out_sa->sha2.hmac_key, auth_key, auth_key_len); -break ; -case RTE_CRYPTO_AUTH_AES_XCBC_MAC : -memcpy (out_sa->aes_xcbc.key, auth_key, auth_key_len); -break ; -default : -plt_err ("Unsupported auth algorithm %u" , - auth_xform->auth.algo); -return -ENOTSUP ; +if (auth_xform->auth.algo ==RTE_CRYPTO_AUTH_AES_XCBC_MAC ) { +const uint8_t *auth_key = auth_xform->auth.key.data; + +roc_aes_xcbc_key_derive (auth_key, hmac_opad_ipad); + }else if (auth_xform->auth.algo !=RTE_CRYPTO_AUTH_NULL ) { +ipsec_hmac_opad_ipad_gen (auth_xform, hmac_opad_ipad); } }
@@ -1390,9 +1377,9 @@ cnxk_on_ipsec_inb_sa_create(struct rte_security_ipsec_xform *ipsec,if (crypto_xform->type ==RTE_CRYPTO_SYM_XFORM_AEAD || auth_xform->auth.algo ==RTE_CRYPTO_AUTH_NULL || auth_xform->auth.algo ==RTE_CRYPTO_AUTH_AES_GMAC ) { - ctx_len = offsetof(struct roc_ie_on_inb_sa , - sha1_or_gcm.hmac_key[0]); + ctx_len = offsetof(struct roc_ie_on_inb_sa, sha1_or_gcm.hmac_key[0]); }else { +uint8_t *hmac_opad_ipad = (uint8_t *)&in_sa->sha2; auth_key = auth_xform->auth.key.data; auth_key_len = auth_xform->auth.key.length;
@@ -1419,10 +1406,16 @@ cnxk_on_ipsec_inb_sa_create(struct rte_security_ipsec_xform *ipsec, aes_xcbc.selector);break ;default : -plt_err ("Unsupported auth algorithm %u" , - auth_xform->auth.algo); +plt_err ("Unsupported auth algorithm %u" , auth_xform->auth.algo);return -ENOTSUP ; } +if (auth_xform->auth.algo ==RTE_CRYPTO_AUTH_AES_XCBC_MAC ) { +const uint8_t *auth_key = auth_xform->auth.key.data; + +roc_aes_xcbc_key_derive (auth_key, hmac_opad_ipad); + }else if (auth_xform->auth.algo !=RTE_CRYPTO_AUTH_NULL ) { +ipsec_hmac_opad_ipad_gen (auth_xform, hmac_opad_ipad); + } }return ctx_len;
drivers/common/cnxk/roc_cpt.c +0 -95
98 lines not on this page · raw message
drivers/common/cnxk/roc_cpt.h +0 -3
@@ -174,7 +174,4 @@ int __roc_api roc_cpt_lmtline_init(struct roc_cpt *roc_cpt, void __roc_api roc_cpt_parse_hdr_dump(const struct cpt_parse_hdr_s *cpth); int __roc_api roc_cpt_ctx_write(struct roc_cpt_lf *lf, void *sa_dptr,void *sa_cptr,uint16_t sa_len); - -int __roc_api roc_on_cpt_ctx_write(struct roc_cpt_lf *lf, uint64_t sa, bool inb, -uint16_t ctx_len,uint8_t egrp);#endif /* _ROC_CPT_H_ */
drivers/common/cnxk/roc_hash.c +155 -0
161 lines not on this page · raw message
drivers/common/cnxk/roc_hash.h +1 -0
@@ -9,6 +9,7 @@* Compute a partial hash with the assumption that msg is the first block. * Based on implementation from RFC 3174 */ +void __roc_api roc_hash_md5_gen(uint8_t *msg, uint32_t *hash); void __roc_api roc_hash_sha1_gen(uint8_t *msg, uint32_t *hash); void __roc_api roc_hash_sha256_gen(uint8_t *msg, uint32_t *hash); void __roc_api roc_hash_sha512_gen(uint8_t *msg, uint64_t *hash, int hash_size);
drivers/common/cnxk/roc_ie_on.h +0 -2
@@ -8,8 +8,6 @@/* CN9K IPsec LA */ /* CN9K IPsec LA opcodes */ -#define ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_OUTBOUND 0x20 -#define ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_INBOUND 0x21#define ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x23#define ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC 0x24
drivers/common/cnxk/roc_nix_inl.c +0 -6
@@ -1301,12 +1301,6 @@ roc_nix_inl_ctx_write(struct roc_nix *roc_nix, void *sa_dptr, void *sa_cptr,/* Nothing much to do on cn9k */ if (roc_model_is_cn9k ()) { - nix =roc_nix_to_nix_priv (roc_nix); - outb_lf = nix->cpt_lf_base; - rc =roc_on_cpt_ctx_write (outb_lf, (uint64_t )sa_dptr, inb, - sa_len,ROC_CPT_DFLT_ENG_GRP_SE_IE ); -if (rc) -return rc;return 0 ; }
drivers/common/cnxk/version.map +1 -1
@@ -78,13 +78,13 @@ INTERNAL { roc_cpt_parse_hdr_dump; roc_cpt_rxc_time_cfg; roc_cpt_ctx_write; - roc_on_cpt_ctx_write; roc_dpi_configure; roc_dpi_dev_fini; roc_dpi_dev_init; roc_dpi_disable; roc_dpi_enable; roc_error_msg_get; + roc_hash_md5_gen; roc_hash_sha1_gen; roc_hash_sha256_gen; roc_hash_sha512_gen;
drivers/crypto/cnxk/cn9k_ipsec.c +0 -7
@@ -81,10 +81,6 @@ cn9k_ipsec_outb_sa_create(struct cnxk_cpt_qp *qp, ctx_len = ret; egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_IE ]; - ret =roc_on_cpt_ctx_write (&qp->lf, (uintptr_t )sa, false, ctx_len, egrp); - -if (ret) -return ret; w4.u64 =0 ; w4.s.opcode_major =ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC |ROC_IE_ON_INPLACE_BIT ;
@@ -169,9 +165,6 @@ cn9k_ipsec_inb_sa_create(struct cnxk_cpt_qp *qp, ctx_len = ret; egrp = roc_cpt->eng_grp[CPT_ENG_TYPE_IE ]; - ret =roc_on_cpt_ctx_write (&qp->lf, (uint64_t )sa, true, ctx_len, egrp); -if (ret) -return ret; w4.u64 =0 ; w4.s.opcode_major =ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC |ROC_IE_ON_INPLACE_BIT ;
drivers/net/cnxk/cn9k_ethdev_sec.c +0 -8
@@ -600,14 +600,6 @@ cn9k_eth_sec_session_create(void *device, } ctx_len = rc; - rc =roc_nix_inl_ctx_write (&dev->nix, inb_sa, inb_sa, inbound, - ctx_len); -if (rc) { -snprintf (tbuf,sizeof (tbuf), -"Failed to create inbound sa, rc=%d" , rc); - goto err; - } - inb_priv =roc_nix_inl_on_ipsec_inb_sa_sw_rsvd (inb_sa);/* Back pointer to get eth_sec */ inb_priv->eth_sec = eth_sec;
Signature · 1 line
2.25.1
PATCH 9/13 crypto/cnxk: support PDCP AAD in CPT PMD
In reply to Tejasree KondojAdding support for PDCP AAD in 96xx crypto pmd.
--- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 10 +-- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 4 +- drivers/crypto/cnxk/cnxk_se.h | 86 +++++++++++------------- 3 files changed, 48 insertions(+), 52 deletions(-)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +6 -4
@@ -27,11 +27,13 @@ cnxk_cpt_get_mlen(void) len =2 *sizeof (uint64_t ); len +=ROC_SE_MAX_MAC_LEN *sizeof (uint8_t ); +/* For PDCP_CHAIN passthrough alignment */ + len +=8 ; len +=ROC_SE_OFF_CTRL_LEN +ROC_CPT_AES_CBC_IV_LEN ; - len +=RTE_ALIGN_CEIL ((ROC_SE_SG_LIST_HDR_SIZE + - (RTE_ALIGN_CEIL (ROC_SE_MAX_SG_IN_OUT_CNT ,4 ) >> -2 ) *ROC_SE_SG_ENTRY_SIZE ), -8 ); + len +=RTE_ALIGN_CEIL ( + (ROC_SE_SG_LIST_HDR_SIZE + + (RTE_ALIGN_CEIL (ROC_SE_MAX_SG_IN_OUT_CNT ,4 ) >>2 ) *ROC_SE_SG_ENTRY_SIZE ), +8 );return len; }
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +2 -2
@@ -10,8 +10,8 @@#include "roc_api.h" -#define CNXK_CPT_MIN_HEADROOM_REQ 24 -#define CNXK_CPT_MIN_TAILROOM_REQ 102 +#define CNXK_CPT_MIN_HEADROOM_REQ 32 +#define CNXK_CPT_MIN_TAILROOM_REQ 102/* Default command timeout in seconds */ #define DEFAULT_COMMAND_TIMEOUT 4
drivers/crypto/cnxk/cnxk_se.h +40 -46
173 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 10/13 crypto/cnxk: acquire lock while updating antireplay
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
Acquire locks in antireplay logic to avoid race condition
--- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +2 -0
@@ -500,6 +500,7 @@ ipsec_antireplay_check(struct cn9k_sec_session *sess, uint32_t win_sz,if (unlikely (seq ==0 ))return IPSEC_ANTI_REPLAY_FAILED ; +rte_spinlock_lock (&sess->ar.lock); ret =cnxk_on_anti_replay_check (seq, &sess->ar, win_sz);if (esn && !ret) { esn_low =rte_be_to_cpu_32 (common_sa->seq_t.tl);
@@ -510,6 +511,7 @@ ipsec_antireplay_check(struct cn9k_sec_session *sess, uint32_t win_sz, common_sa->seq_t.th =rte_cpu_to_be_32 (seqh); } } +rte_spinlock_unlock (&sess->ar.lock);return ret; }
Signature · 1 line
2.25.1
PATCH 11/13 crypto/cnxk: switch to SG when metabuf is allocated
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
Metabuf would be allocated only when SG is required. Check the pointer instead of flags.
Coverity issue: 381018
--- drivers/crypto/cnxk/cnxk_se.h | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +6 -27
@@ -1177,14 +1177,7 @@ cpt_enc_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens, offset_ctrl =rte_cpu_to_be_64 (((uint64_t )encr_offset <<16 ) | ((uint64_t )iv_offset <<8 ) | ((uint64_t )auth_offset)); -/* -* In cn9k, cn10k since we have a limitation of -* IV & Offset control word not part of instruction -* and need to be part of Data Buffer, we check if -* head room is there and then only do the Direct mode processing -*/ -if (likely ((flags &ROC_SE_SINGLE_BUF_INPLACE ) && - (flags &ROC_SE_SINGLE_BUF_HEADROOM ))) { +if (likely (fc_params->meta_buf.vaddr ==NULL )) {void *dm_vaddr = fc_params->bufs[0 ].vaddr;/* Use Direct mode */
@@ -1336,13 +1329,7 @@ cpt_dec_hmac_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens, offset_ctrl =rte_cpu_to_be_64 (((uint64_t )encr_offset <<16 ) | ((uint64_t )iv_offset <<8 ) | ((uint64_t )auth_offset)); -/* -* In cn9k, cn10k since we have a limitation of -* IV & Offset control word not part of instruction -* and need to be part of Data Buffer, we check if -* head room is there and then only do the Direct mode processing -*/ -if (likely ((flags &ROC_SE_SINGLE_BUF_INPLACE ) && (flags &ROC_SE_SINGLE_BUF_HEADROOM ))) { +if (likely (fc_params->meta_buf.vaddr ==NULL )) {void *dm_vaddr = fc_params->bufs[0 ].vaddr;/* Use Direct mode */
@@ -1398,6 +1385,7 @@ cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,uint32_t encr_data_len, auth_data_len, aad_len, passthr_len, pad_len, hdr_len;uint32_t encr_offset, auth_offset, iv_offset =0 ;uint8_t *auth_iv =NULL , *cipher_iv =NULL ; +void *m_vaddr = params->meta_buf.vaddr;uint8_t pdcp_ci_alg, pdcp_auth_alg;union cpt_inst_w4 cpt_inst_w4;struct roc_se_ctx *se_ctx;
@@ -1462,8 +1450,7 @@ cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, inputlen += (encr_offset + pad_len); -if (likely (((req_flags &ROC_SE_SINGLE_BUF_INPLACE )) && - ((req_flags &ROC_SE_SINGLE_BUF_HEADROOM )))) { +if (likely (m_vaddr ==NULL )) { dm_vaddr = params->bufs[0 ].vaddr;
@@ -1489,9 +1476,7 @@ cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,pdcp_iv_copy (iv_d, auth_iv, pdcp_auth_alg, pack_iv); }else { -struct roc_se_sglist_comp *scatter_comp, *gather_comp; -void *m_vaddr = params->meta_buf.vaddr;uint32_t i, g_size_bytes, s_size_bytes;uint8_t *in_buffer;uint32_t size;
@@ -1711,14 +1696,7 @@ cpt_pdcp_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, cpt_inst_w4.s.param1 = encr_data_len; cpt_inst_w4.s.param2 = auth_data_len; -/* -* In cn9k, cn10k since we have a limitation of -* IV & Offset control word not part of instruction -* and need to be part of Data Buffer, we check if -* head room is there and then only do the Direct mode processing -*/ -if (likely ((req_flags &ROC_SE_SINGLE_BUF_INPLACE ) && - (req_flags &ROC_SE_SINGLE_BUF_HEADROOM ))) { +if (likely (params->meta_buf.vaddr ==NULL )) {void *dm_vaddr = params->bufs[0 ].vaddr;/* Use Direct mode */
@@ -2889,6 +2867,7 @@ fill_pdcp_chain_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, } } + fc_params.meta_buf.vaddr =NULL ;if (unlikely (!((flags &ROC_SE_SINGLE_BUF_INPLACE ) && (flags &ROC_SE_SINGLE_BUF_HEADROOM )))) { mdata =alloc_op_meta (&fc_params.meta_buf, m_info->mlen, m_info->pool, infl_req);
Signature · 1 line
2.25.1
RE: [PATCH 11/13] crypto/cnxk: switch to SG when metabuf is allocated
Quoted 5 lines
Subject: [PATCH 11/13]
crypto/cnxk: switch to SG when metabuf is allocatedFrom: Anoob Joseph <[email protected]>
Quoted 7 lines
Metabuf would be allocated only when SG is required. Check the pointer instead of flags.
Coverity issue: 381018
Fixes d3bff77cc371 ("crypto/cnxk: separate out PDCP chain datapath")Signed-off-by Anoob Joseph <[email protected]>
This patch is removed from the dpdk-next-crypto as it is causing build failures on RHEL 7/8. Please resubmit after fixing.
PATCH 12/13 crypto/cnxk: verify IV length during session create
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
For Kasumi cipher operation, IV is a must. Verify the arg provided in session creation and remove datapath check.
Coverity issue: 381020 381019
--- drivers/crypto/cnxk/cnxk_se.h | 44 ++++++++++++++--------------------- 1 file changed, 17 insertions(+), 27 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +17 -27
@@ -1753,35 +1753,17 @@ cpt_kasumi_enc_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, auth_data_len =ROC_SE_AUTH_DLEN (d_lens); se_ctx = params->ctx; + iv_s = params->iv_buf; flags = se_ctx->zsk_flags; mac_len = se_ctx->mac_len; -if (flags ==0x0 ) - iv_s = params->iv_buf; -else - iv_s = params->auth_iv_buf; - dir = iv_s[8 ] &0x1 ; - cpt_inst_w4.s.opcode_major =ROC_SE_MAJOR_OP_KASUMI |ROC_SE_DMA_MODE ; - -/* indicates ECB/CBC, direction, ctx from cptr, iv from dptr */ - cpt_inst_w4.s.opcode_minor = ((1 <<6 ) | (se_ctx->k_ecb <<5 ) | - (dir <<4 ) | (0 <<3 ) | (flags &0x7 )); - -/* -* GP op header, lengths are expected in bits. -*/ - cpt_inst_w4.s.param1 = encr_data_len; - cpt_inst_w4.s.param2 = auth_data_len; - -/* consider iv len */ if (flags ==0x0 ) { +/* Consider IV len */ encr_offset += iv_len; auth_offset += iv_len; - } -if (flags ==0x0 ) { inputlen = encr_offset + (RTE_ALIGN (encr_data_len,8 ) /8 ); outputlen = inputlen;/* iv offset is 0 */
@@ -1803,6 +1785,15 @@ cpt_kasumi_enc_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, } } + cpt_inst_w4.s.opcode_major =ROC_SE_MAJOR_OP_KASUMI |ROC_SE_DMA_MODE ; + +/* Indicate ECB/CBC, direction, CTX from CPTR, IV from DPTR */ + cpt_inst_w4.s.opcode_minor = + ((1 <<6 ) | (se_ctx->k_ecb <<5 ) | (dir <<4 ) | (0 <<3 ) | (flags &0x7 )); + + cpt_inst_w4.s.param1 = encr_data_len; + cpt_inst_w4.s.param2 = auth_data_len; + inst->w4.u64 = cpt_inst_w4.u64;if (is_sg_ver2) sg2_inst_prep(params, inst, offset_ctrl, iv_s, iv_len, 0, 0, inputlen, outputlen, 0,
@@ -2017,6 +2008,8 @@ fill_sess_cipher(struct rte_crypto_sym_xform *xform, struct cnxk_se_sess *sess)case RTE_CRYPTO_CIPHER_KASUMI_F8 :if (sess->chained_op)return -ENOTSUP ; +if (c_form->iv.length !=8 ) +return -EINVAL ; enc_type =ROC_SE_KASUMI_F8_ECB ; cipher_key_len =16 ; zsk_flag =ROC_SE_K_F8 ;
@@ -2433,15 +2426,12 @@ fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, fc_params.mac_buf.size =0 ; fc_params.mac_buf.vaddr =0 ; -if (likely (sess->iv_length)) { +if (likely (is_kasumi || sess->iv_length)) { flags |=ROC_SE_VALID_IV_BUF ; - fc_params.iv_buf = rte_crypto_op_ctod_offset(cop, uint8_t *, - sess->iv_offset); + fc_params.iv_buf = rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset);if (!is_aead && sess->aes_ctr &&unlikely (sess->iv_length !=16 )) {memcpy ((uint8_t *)iv_buf, - rte_crypto_op_ctod_offset(cop, uint8_t *, - sess->iv_offset), -12 ); + rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), 12); iv_buf[3 ] =rte_cpu_to_be_32 (0x1 ); fc_params.iv_buf = iv_buf; }
@@ -3017,7 +3007,7 @@ fill_digest_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,/* Store it at end of auth iv */ iv_buf[8 ] = direction; - params.auth_iv_buf = iv_buf; + params.iv_buf = iv_buf; } }
Signature · 1 line
2.25.1
PATCH 13/13 crypto/cnxk: remove dead code
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
Coverity issue: 381022
--- drivers/crypto/cnxk/cnxk_se.h | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +15 -23
@@ -2675,6 +2675,8 @@ fill_pdcp_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, fc_params.dst_iov = fc_params.src_iov = (void *)src;prepare_iov_from_pkt_inplace (m_src, &fc_params, &flags); }else { +uint32_t pkt_len; +/* Out of place processing */ fc_params.src_iov = (void *)src; fc_params.dst_iov = (void *)dst;
@@ -2686,33 +2688,23 @@ fill_pdcp_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, goto err_exit; } -if (unlikely (m_dst !=NULL )) { -uint32_t pkt_len; - -/* Try to make room as much as src has */ - pkt_len =rte_pktmbuf_pkt_len (m_dst); - -if (unlikely (pkt_len <rte_pktmbuf_pkt_len (m_src))) { - pkt_len =rte_pktmbuf_pkt_len (m_src) - pkt_len; -if (!rte_pktmbuf_append (m_dst, pkt_len)) { -plt_dp_err ("Not enough space in " -"m_dst %p, need %u" -" more" , - m_dst, pkt_len); - ret = -EINVAL ; - goto err_exit; - } - } +/* Try to make room as much as src has */ + pkt_len =rte_pktmbuf_pkt_len (m_dst); -if (prepare_iov_from_pkt (m_dst, fc_params.dst_iov,0 )) { -plt_dp_err ("Prepare dst iov failed for " -"m_dst %p" , - m_dst); +if (unlikely (pkt_len <rte_pktmbuf_pkt_len (m_src))) { + pkt_len =rte_pktmbuf_pkt_len (m_src) - pkt_len; +if (unlikely (rte_pktmbuf_append (m_dst, pkt_len) ==NULL )) { +plt_dp_err ("Not enough space in m_dst %p, need %u more" , m_dst, + pkt_len); ret = -EINVAL ; goto err_exit; } - }else { - fc_params.dst_iov = (void *)src; + } + +if (unlikely (prepare_iov_from_pkt (m_dst, fc_params.dst_iov,0 ))) { +plt_dp_err ("Prepare dst iov failed for m_dst %p" , m_dst); + ret = -EINVAL ; + goto err_exit; } }
Signature · 1 line
2.25.1
Quoted 46 lines
Subject: [PATCH 00/13] fixes and improvements to cnxk crypto PMD
This series adds improvements and support for 103XX CPT, PDCP AAD, DES and MD5 algorithms in cnxk crypto PMD.
Anoob Joseph (3):
crypto/cnxk: switch to SG when metabuf is allocatedcrypto/cnxk: verify IV length during session createcrypto/cnxk: remove dead codeTejasree Kondoj (5):
crypto/cnxk: fix length of AES-CMAC algo common/cnxk: set inplace bit of lookaside IPseccrypto/cnxk: change capabilities as per firmware common/cnxk: support 103XX CPTcrypto/cnxk: support PDCP AAD in CPT PMDVidya Sagar Velumuri (5):
common/cnxk: support custom UDP port valuescrypto/cnxk: update rlen calculation for lookaside modecrypto/cnxk: add support for DES and MD5 common/cnxk: add opad ipad gen for md5crypto/cnxk: acquire lock while updating antireplaydrivers/common/cnxk/cnxk_security.c | 75 +- drivers/common/cnxk/hw/cpt.h | 26 +- drivers/common/cnxk/roc_cpt.c | 95 - drivers/common/cnxk/roc_cpt.h | 3 - drivers/common/cnxk/roc_hash.c | 155 ++ drivers/common/cnxk/roc_hash.h | 1 + drivers/common/cnxk/roc_ie_on.h | 3 +- drivers/common/cnxk/roc_ie_ot.h | 2 + drivers/common/cnxk/roc_mbox.h | 5 +- drivers/common/cnxk/roc_nix_inl.c | 6 - drivers/common/cnxk/roc_se.h | 11 + drivers/common/cnxk/version.map | 2 +- drivers/crypto/cnxk/cn10k_cryptodev.c | 2 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 67 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.h | 9 +- drivers/crypto/cnxk/cn10k_ipsec.c | 4 +- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 2 - drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 6 +- drivers/crypto/cnxk/cn9k_ipsec.c | 53 +- drivers/crypto/cnxk/cn9k_ipsec_la_ops.h | 13 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 2 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 42 +-
Quoted 9 lines
drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 14 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 4 +- drivers/crypto/cnxk/cnxk_ipsec.h | 9 + drivers/crypto/cnxk/cnxk_se.h | 1734 +++++++++-------- drivers/crypto/cnxk/version.map | 3 +- drivers/event/cnxk/cn10k_eventdev.c | 13 +- drivers/net/cnxk/cn9k_ethdev_sec.c | 8 - 29 files changed, 1248 insertions(+), 1121 deletions(-)
Series applied to dpdk-next-crypto
Thanks.