fixes and improvements to cnxk crypto PMD
cover fixes and improvements to cnxk crypto PMD
This series adds improvements and support for raw
cryptodev API in cnxk crypto PMD.
Aakash Sasidharan (1):
crypto/cnxk: add support for packets with cipher len zero
Anoob Joseph (4):
crypto/cnxk: clear rptr and dptr fields common/cnxk: set cipher key only for non-null cipher crypto/cnxk: add support for raw APIs test/crypto: enable raw crypto tests for crypto_cn10k
Gowrishankar Muthukrishnan (1):
crypto/cnxk: fix private key length in ECDSA param
Tejasree Kondoj (4):
crypto/cnxk: fix IPsec CCM and GCM capabilities crypto/cnxk: remove pdcp chain bit from capabilities crypto/cnxk: make IV pointers as constant crypto/cnxk: set PDCP chain IV offset based on FVC
Vidya Sagar Velumuri (5):
common/cnxk: update SE context fields to match ucode spec crypto/cnxk: check for sg version in SE engine capabilities crypto/cnxk: fix control flow issues
crypto/cnxk: minor shuffling in the sess structure crypto/cnxk: update the iv from proper param for gmac
app/test/test_cryptodev.c | 8 + drivers/common/cnxk/hw/cpt.h | 7 +- drivers/common/cnxk/roc_se.c | 11 +- drivers/common/cnxk/roc_se.h | 15 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 461 +++++++++++++++ drivers/crypto/cnxk/cnxk_ae.h | 4 +- drivers/crypto/cnxk/cnxk_cryptodev.c | 20 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 10 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 13 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 6 +- drivers/crypto/cnxk/cnxk_se.h | 527 ++++++++++++++---- 11 files changed, 936 insertions(+), 146 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/15 crypto/cnxk: clear rptr and dptr fields
From: Anoob Joseph <[email protected]>
With SG version 2, hw requires valid rptr & dptr values.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 2 ++ drivers/crypto/cnxk/cnxk_se.h | 1 + 2 files changed, 3 insertions(+)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +2 -0
@@ -414,6 +414,8 @@ cn10k_cpt_vec_inst_fill(struct vec_request *vec_req, struct cpt_inst_s *inst, inst->w2.u64 = vec_req->w2; inst->w3.u64 =CNXK_CPT_INST_W3 (1 , infl_req); inst->w4.u64 = w4.u64; + inst->w5.u64 =0 ; + inst->w6.u64 =0 ; inst->w7.u64 = w7.u64; }
drivers/crypto/cnxk/cnxk_se.h +1 -0
@@ -2877,6 +2877,7 @@ fill_passthrough_params(struct rte_crypto_op *cop, struct cpt_inst_s *inst) inst->w0.u64 =0 ; inst->w5.u64 =0 ; + inst->w6.u64 =0 ; inst->w4.u64 = w4.u64;return 0 ;
Signature · 1 line
2.25.1
PATCH 2/15 common/cnxk: update SE context fields to match ucode spec
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
Update the fields in SE context and rename to keep it in sync with microcode spec.
--- drivers/common/cnxk/roc_se.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/common/cnxk/roc_se.h +5 -3
@@ -183,13 +183,15 @@ typedef enum {struct roc_se_enc_context {uint64_t iv_source :1 ;uint64_t aes_key :2 ; -uint64_t rsvd_60 :1 ; +uint64_t rsvd_59 :1 ;uint64_t enc_cipher :4 ;uint64_t auth_input_type :1 ; -uint64_t rsvd_52_54 :3 ; +uint64_t auth_key_src :1 ; +uint64_t rsvd_50_51 :2 ;uint64_t hash_type :4 ;uint64_t mac_len :8 ; -uint64_t rsvd_39_0 :40 ; +uint64_t rsvd_16_39 :24 ; +uint64_t hmac_key_sz :16 ;uint8_t encr_key[32 ];uint8_t encr_iv[16 ]; };
Signature · 1 line
2.25.1
PATCH 3/15 common/cnxk: set cipher key only for non-null cipher
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
Set cipher key only for non-NULL cipher algorithms only.
--- drivers/common/cnxk/roc_se.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/common/cnxk/roc_se.c +4 -7
@@ -58,9 +58,6 @@ cpt_ciph_type_set(roc_se_cipher_type type, struct roc_se_ctx *ctx, uint16_t key_int fc_type =0 ;switch (type) { -case ROC_SE_PASSTHROUGH : - fc_type =ROC_SE_FC_GEN ; -break ;case ROC_SE_DES3_CBC :case ROC_SE_DES3_ECB :case ROC_SE_DES_DOCSISBPI :
@@ -526,6 +523,10 @@ roc_se_ciph_key_set(struct roc_se_ctx *se_ctx, roc_se_cipher_type type, const uiuint8_t *ci_key;int i, ret; +/* For NULL cipher, no processing required. */ +if (type ==ROC_SE_PASSTHROUGH ) +return 0 ; + zs_ch_ctx = &se_ctx->se_ctx.zs_ch_ctx;if (roc_model_is_cn9k ()) {
@@ -555,10 +556,6 @@ roc_se_ciph_key_set(struct roc_se_ctx *se_ctx, roc_se_cipher_type type, const ui }switch (type) { -case ROC_SE_PASSTHROUGH : - se_ctx->enc_cipher =0 ; - fctx->enc.enc_cipher =0 ; - goto success;case ROC_SE_DES3_CBC :/* CPT performs DES using 3DES with the 8B DES-key * replicated 2 more times to match the 24B 3DES-key.
Signature · 1 line
2.25.1
PATCH 4/15 crypto/cnxk: fix private key length in ECDSA param
In reply to Tejasree KondojFrom: Gowrishankar Muthukrishnan <[email protected]>
Fix private key length in ECDSA op param to include alignment, for new microcode.
--- drivers/crypto/cnxk/cnxk_ae.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_ae.h +2 -2
@@ -527,7 +527,7 @@ cnxk_ae_ecdsa_sign_prep(struct rte_crypto_ecdsa_op_param *ecdsa,/* Set write offset for order and private key */ o_offset = prime_len - order_len; - pk_offset = prime_len - pkey_len; + pk_offset = p_align - pkey_len;/* Input buffer */ dptr = meta_buf->vaddr;
@@ -572,7 +572,7 @@ cnxk_ae_ecdsa_sign_prep(struct rte_crypto_ecdsa_op_param *ecdsa, w4.s.opcode_minor =ROC_AE_MINOR_OP_ECDSA_SIGN ; w4.s.param1 = curveid | (message_len <<8 ); - w4.s.param2 = (pkey_len <<8 ) | k_len; + w4.s.param2 = (p_align <<8 ) | k_len; w4.s.dlen = dlen; inst->w4.u64 = w4.u64;
Signature · 1 line
2.25.1
RE: [PATCH 04/15] crypto/cnxk: fix private key length in ECDSA param
Quoted 8 lines
Subject: [PATCH 04/15]
crypto/cnxk: fix private key length in ECDSA paramFrom: Gowrishankar Muthukrishnan <[email protected]>
Fix private key length in ECDSA op param to include alignment, for new microcode.
Signed-off-by Gowrishankar Muthukrishnan <[email protected]>
Add fixes tag.
PATCH 5/15 crypto/cnxk: fix IPsec CCM and GCM capabilities
In reply to Tejasree KondojFix lookaside IPsec AES-CCM and AES-GCM capabilities. The patch to fix AES-CCM capabilities was applied incorrectly which resulted in wrong AES-GCM capabilities. Fix the same and update AES-CCM to correct values.
--- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +4 -4
@@ -1180,8 +1180,8 @@ static const struct rte_cryptodev_capabilities sec_caps_aes[] = { .increment = 4 }, .iv_size = { - .min = 11, - .max = 11, + .min = 12, + .max = 12, .increment = 0 } }, }
@@ -1210,8 +1210,8 @@ static const struct rte_cryptodev_capabilities sec_caps_aes[] = { .increment = 4 }, .iv_size = { - .min = 12, - .max = 12, + .min = 11, + .max = 11, .increment = 0 } }, }
Signature · 1 line
2.25.1
PATCH 6/15 crypto/cnxk: remove pdcp chain bit from capabilities
In reply to Tejasree KondojRemoving pdcp_chain bit from capabilities as it is supported on all platforms.
--- drivers/common/cnxk/hw/cpt.h | 3 +-- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 15 ++++----------- 2 files changed, 5 insertions(+), 13 deletions(-)
drivers/common/cnxk/hw/cpt.h +1 -2
@@ -76,8 +76,7 @@ union cpt_eng_caps { uint64_t __io reserved_15_20 : 6; uint64_t __io sm3 : 1; uint64_t __io sm4 : 1; - uint64_t __io reserved_23_33 : 11; - uint64_t __io pdcp_chain : 1; + uint64_t __io reserved_23_34 : 12; uint64_t __io sg_ver2 : 1; uint64_t __io reserved_36_63 : 28; };
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +4 -11
@@ -484,18 +484,13 @@ is_valid_pdcp_cipher_alg(struct rte_crypto_sym_xform *c_xfrm, }static int -cnxk_sess_fill (struct roc_cpt *roc_cpt,struct rte_crypto_sym_xform *xform, -struct cnxk_se_sess *sess) +cnxk_sess_fill (struct rte_crypto_sym_xform *xform,struct cnxk_se_sess *sess) {struct rte_crypto_sym_xform *aead_xfrm =NULL ;struct rte_crypto_sym_xform *c_xfrm =NULL ;struct rte_crypto_sym_xform *a_xfrm =NULL ; -bool pdcp_chain_supported = false;bool ciph_then_auth = false; -if (roc_cpt->hw_caps[CPT_ENG_TYPE_SE ].pdcp_chain) - pdcp_chain_supported = true; -if (xform ==NULL )return -EINVAL ;
@@ -591,8 +586,7 @@ cnxk_sess_fill(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform,case RTE_CRYPTO_AUTH_SNOW3G_UIA2 :case RTE_CRYPTO_AUTH_ZUC_EIA3 :case RTE_CRYPTO_AUTH_AES_CMAC : -if (!pdcp_chain_supported || - !is_valid_pdcp_cipher_alg (c_xfrm, sess)) +if (!is_valid_pdcp_cipher_alg (c_xfrm, sess))return -ENOTSUP ;break ;default :
@@ -627,8 +621,7 @@ cnxk_sess_fill(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xform,case RTE_CRYPTO_AUTH_SNOW3G_UIA2 :case RTE_CRYPTO_AUTH_ZUC_EIA3 :case RTE_CRYPTO_AUTH_AES_CMAC : -if (!pdcp_chain_supported || - !is_valid_pdcp_cipher_alg (c_xfrm, sess)) +if (!is_valid_pdcp_cipher_alg (c_xfrm, sess))return -ENOTSUP ;break ;default :
@@ -679,7 +672,7 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xforif (is_session_less)memset (sess_priv,0 ,sizeof (struct cnxk_se_sess )); - ret =cnxk_sess_fill (roc_cpt, xform, sess_priv); + ret =cnxk_sess_fill (xform, sess_priv);if (ret) goto priv_put;
Signature · 1 line
2.25.1
PATCH 7/15 crypto/cnxk: check for sg version in SE engine capabilities
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
Check for supported SG version in SE engine capabilities.
--- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +1 -1
@@ -1619,7 +1619,7 @@ static void cn10k_crypto_caps_add(struct rte_cryptodev_capabilities cnxk_caps[], union cpt_eng_caps *hw_caps, int *cur_pos) { - if (hw_caps->sg_ver2) { + if (hw_caps[CPT_ENG_TYPE_SE].sg_ver2) {CPT_CAPS_ADD (cnxk_caps, cur_pos, hw_caps, sm3);CPT_CAPS_ADD (cnxk_caps, cur_pos, hw_caps, sm4); }
Signature · 1 line
2.25.1
PATCH 8/15 crypto/cnxk: fix control flow issues
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
This patch fixes below coverity issues.
Coverity issue: 393678
Coverity issue: 393679
--- drivers/crypto/cnxk/cnxk_se.h | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +5 -17
@@ -1070,7 +1070,6 @@ cpt_sm_prep(uint32_t flags, uint64_t d_offs, uint64_t d_lens, struct roc_se_fc_p iv_len =0 ; encr_offset += iv_len; - enc_dlen = encr_data_len + encr_offset; enc_dlen =RTE_ALIGN_CEIL (encr_data_len,8 ) + encr_offset; inputlen = enc_dlen;
@@ -2543,11 +2542,6 @@ fill_sm_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,char src[SRC_IOV_SIZE ];char dst[SRC_IOV_SIZE ];void *mdata =NULL ; -#ifdef CPT_ALWAYS_USE_SG_MODE -uint8_t inplace =0 ; -#else -uint8_t inplace =1 ; -#endif uint32_t flags =0 ;int ret;
@@ -2577,11 +2571,9 @@ fill_sm_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, fc_params.ctx = &sess->roc_se_ctx; -if (likely (!m_dst && inplace)) { +if (m_dst ==NULL ) { fc_params.dst_iov = fc_params.src_iov = (void *)src; -prepare_iov_from_pkt_inplace (m_src, &fc_params, &flags); - }else {/* Out of place processing */ fc_params.src_iov = (void *)src;
@@ -2594,14 +2586,10 @@ fill_sm_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, goto err_exit; } -if (unlikely (m_dst !=NULL )) { -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); - ret = -EINVAL ; - goto err_exit; - } - }else { - fc_params.dst_iov = (void *)src; +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); + ret = -EINVAL ; + goto err_exit; } }
Signature · 1 line
2.25.1
PATCH 9/15 crypto/cnxk: make IV pointers as constant
In reply to Tejasree KondojMake IV pointers as constant.
drivers/common/cnxk/roc_se.h | 4 +- drivers/crypto/cnxk/cnxk_se.h | 140 +++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 64 deletions(-)
drivers/common/cnxk/roc_se.h +2 -2
@@ -360,8 +360,8 @@ struct roc_se_fc_params {struct roc_se_iov_ptr *dst_iov; }; }; -void *iv_buf; -void *auth_iv_buf; +const void *iv_buf; +const void *auth_iv_buf;struct roc_se_ctx *ctx;struct roc_se_buf_ptr meta_buf;uint8_t cipher_iv_len;
drivers/crypto/cnxk/cnxk_se.h +78 -62
299 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 10/15 crypto/cnxk: set PDCP chain IV offset based on FVC
In reply to Tejasree KondojSet PDCP chain IV offset based on zuc 256 firmware
--- drivers/common/cnxk/hw/cpt.h | 4 +++- drivers/common/cnxk/roc_se.h | 3 +++ drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 10 ++++++++-- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 5 +++-- drivers/crypto/cnxk/cnxk_se.h | 16 ++++++++++------ 5 files changed, 27 insertions(+), 11 deletions(-)
drivers/common/cnxk/hw/cpt.h +3 -1
@@ -78,7 +78,9 @@ union cpt_eng_caps { uint64_t __io sm4 : 1; uint64_t __io reserved_23_34 : 12; uint64_t __io sg_ver2 : 1; - uint64_t __io reserved_36_63 : 28; + uint64_t __io reserved36 : 1; + uint64_t __io pdcp_chain_zuc256 : 1; + uint64_t __io reserved_38_63 : 26; }; };
drivers/common/cnxk/roc_se.h +3 -0
@@ -323,6 +323,8 @@ struct roc_se_ctx { uint64_t ciph_then_auth : 1; uint64_t auth_then_ciph : 1; uint64_t eia2 : 1; +/* auth_iv_offset passed to PDCP_CHAIN opcode based on FVC bit */ +uint8_t pdcp_iv_offset;union cpt_inst_w4 template_w4;/* Below fields are accessed by hardware */ struct se_ctx_s {
@@ -366,6 +368,7 @@ struct roc_se_fc_params {struct roc_se_buf_ptr meta_buf;uint8_t cipher_iv_len;uint8_t auth_iv_len; +uint8_t pdcp_iv_offset;struct roc_se_buf_ptr aad_buf;struct roc_se_buf_ptr mac_buf;
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +8 -2
@@ -484,13 +484,19 @@ is_valid_pdcp_cipher_alg(struct rte_crypto_sym_xform *c_xfrm, }static int -cnxk_sess_fill (struct rte_crypto_sym_xform *xform,struct cnxk_se_sess *sess) +cnxk_sess_fill (struct roc_cpt *roc_cpt,struct rte_crypto_sym_xform *xform, +struct cnxk_se_sess *sess) {struct rte_crypto_sym_xform *aead_xfrm =NULL ;struct rte_crypto_sym_xform *c_xfrm =NULL ;struct rte_crypto_sym_xform *a_xfrm =NULL ;bool ciph_then_auth = false; +if (roc_cpt->hw_caps[CPT_ENG_TYPE_SE ].pdcp_chain_zuc256) + sess->roc_se_ctx.pdcp_iv_offset =24 ; +else + sess->roc_se_ctx.pdcp_iv_offset =16 ; +if (xform ==NULL )return -EINVAL ;
@@ -672,7 +678,7 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xforif (is_session_less)memset (sess_priv,0 ,sizeof (struct cnxk_se_sess )); - ret =cnxk_sess_fill (xform, sess_priv); + ret =cnxk_sess_fill (roc_cpt, xform, sess_priv);if (ret) goto priv_put;
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +3 -2
@@ -16,8 +16,9 @@#include "roc_errata.h" #include "roc_se.h" -#define CNXK_CPT_MIN_HEADROOM_REQ 32 -#define CNXK_CPT_MIN_TAILROOM_REQ 102 +/* Space for ctrl_word(8B), IV(48B), passthrough alignment(8B) */ +#define CNXK_CPT_MIN_HEADROOM_REQ 64 +#define CNXK_CPT_MIN_TAILROOM_REQ 102/* Default command timeout in seconds */ #define DEFAULT_COMMAND_TIMEOUT 4
drivers/crypto/cnxk/cnxk_se.h +10 -6
@@ -892,7 +892,7 @@ pdcp_chain_sg1_prep(struct roc_se_fc_params *params, struct roc_se_ctx *cpt_ctx,pdcp_iv_copy (iv_d, cipher_iv, pdcp_ci_alg, pack_iv);/* Auth IV */ - iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN +16 ); + iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN + params->pdcp_iv_offset);pdcp_iv_copy (iv_d, auth_iv, pdcp_auth_alg, pack_iv);/* input data */
@@ -998,7 +998,7 @@ pdcp_chain_sg2_prep(struct roc_se_fc_params *params, struct roc_se_ctx *cpt_ctx,pdcp_iv_copy (iv_d, cipher_iv, pdcp_ci_alg, pack_iv);/* Auth IV */ - iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN +16 ); + iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN + params->pdcp_iv_offset);pdcp_iv_copy (iv_d, auth_iv, pdcp_auth_alg, pack_iv);/* input data */
@@ -1490,11 +1490,12 @@ 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 ;const uint8_t *auth_iv =NULL , *cipher_iv =NULL ; +uint8_t pdcp_iv_off = params->pdcp_iv_offset; +const int iv_len = pdcp_iv_off *2 ;uint8_t pdcp_ci_alg, pdcp_auth_alg;union cpt_inst_w4 cpt_inst_w4;struct roc_se_ctx *se_ctx;uint64_t *offset_vaddr; -const int iv_len =32 ;uint64_t offset_ctrl;uint8_t pack_iv =0 ;int32_t inputlen;
@@ -1576,7 +1577,7 @@ cpt_pdcp_chain_alg_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN );pdcp_iv_copy (iv_d, cipher_iv, pdcp_ci_alg, pack_iv); - iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN +16 ); + iv_d = ((uint8_t *)offset_vaddr +ROC_SE_OFF_CTRL_LEN + pdcp_iv_off);pdcp_iv_copy (iv_d, auth_iv, pdcp_auth_alg, pack_iv); inst->w4.u64 = cpt_inst_w4.u64;
@@ -2909,6 +2910,7 @@ fill_pdcp_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, fc_params.auth_iv_len =0 ; fc_params.iv_buf =NULL ; fc_params.auth_iv_buf =NULL ; + fc_params.pdcp_iv_offset = sess->roc_se_ctx.pdcp_iv_offset;if (likely (sess->iv_length)) fc_params.iv_buf = rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset);
@@ -2995,6 +2997,7 @@ fill_pdcp_chain_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, fc_params.auth_iv_len = sess->auth_iv_length; fc_params.iv_buf =NULL ; fc_params.auth_iv_buf =NULL ; + fc_params.pdcp_iv_offset = sess->roc_se_ctx.pdcp_iv_offset; m_src = sym_op->m_src; m_dst = sym_op->m_dst;
@@ -3197,8 +3200,9 @@ fill_digest_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess, d_offs = auth_range_off; auth_range_off =0 ; params.auth_iv_len = sess->auth_iv_length; - params.auth_iv_buf =rte_crypto_op_ctod_offset ( - cop, uint8_t *, sess->auth_iv_offset); + params.auth_iv_buf = + rte_crypto_op_ctod_offset(cop, uint8_t *, sess->auth_iv_offset); + params.pdcp_iv_offset = sess->roc_se_ctx.pdcp_iv_offset;if (sess->zsk_flag ==ROC_SE_K_F9 ) {uint32_t length_in_bits, num_bytes;uint8_t *src, direction =0 ;
Signature · 1 line
2.25.1
PATCH 11/15 crypto/cnxk: minor shuffling in the sess structure
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
Shuffle the fields in the session structure to make the fields byte aligned
--- drivers/crypto/cnxk/cnxk_se.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +16 -16
@@ -31,30 +31,30 @@ enum cpt_dp_thread_type {struct cnxk_se_sess {struct rte_cryptodev_sym_session rte_sess; -uint16_t cpt_op :4 ; -uint16_t zsk_flag :4 ; -uint16_t aes_gcm :1 ; -uint16_t aes_ccm :1 ; -uint16_t aes_ctr :1 ; -uint16_t chacha_poly :1 ; -uint16_t is_null :1 ; -uint16_t is_gmac :1 ; -uint16_t chained_op :1 ; -uint16_t auth_first :1 ; -uint16_t aes_ctr_eea2 :1 ; -uint16_t zs_cipher :4 ; -uint16_t zs_auth :4 ; -uint16_t dp_thr_type :8 ; -uint16_t aad_length; +uint8_t aes_gcm :1 ; +uint8_t aes_ccm :1 ; +uint8_t aes_ctr :1 ; +uint8_t chacha_poly :1 ; +uint8_t is_null :1 ; +uint8_t is_gmac :1 ; +uint8_t chained_op :1 ; +uint8_t auth_first :1 ; +uint8_t aes_ctr_eea2 :1 ;uint8_t is_sha3 :1 ;uint8_t short_iv :1 ;uint8_t is_sm3 :1 ;uint8_t passthrough :1 ;uint8_t is_sm4 :1 ; -uint8_t rsvd :3 ; +uint8_t rsvd :2 ; +uint8_t cpt_op :4 ; +uint8_t zsk_flag :4 ; +uint8_t zs_cipher :4 ; +uint8_t zs_auth :4 ; +uint8_t dp_thr_type;uint8_t mac_len;uint8_t iv_length;uint8_t auth_iv_length; +uint16_t aad_length;uint16_t iv_offset;uint16_t auth_iv_offset;uint32_t salt;
Signature · 1 line
2.25.1
PATCH 12/15 crypto/cnxk: add support for packets with cipher len zero
In reply to Tejasree KondojFrom: Aakash Sasidharan <[email protected]>
For cipher only zero length packets, submit it to CPT with passthrough opcode.
--- drivers/crypto/cnxk/cnxk_se.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_se.h +14 -2
@@ -45,7 +45,8 @@ struct cnxk_se_sess { uint8_t is_sm3 : 1; uint8_t passthrough : 1; uint8_t is_sm4 : 1; - uint8_t rsvd : 2; + uint8_t cipher_only : 1; + uint8_t rsvd : 1; uint8_t cpt_op : 4; uint8_t zsk_flag : 4; uint8_t zs_cipher : 4;
@@ -2192,6 +2193,7 @@ fill_sess_cipher(struct rte_crypto_sym_xform *xform, struct cnxk_se_sess *sess) } } + sess->cipher_only =1 ; sess->zsk_flag = zsk_flag; sess->zs_cipher = zs_cipher; sess->aes_gcm =0 ;
@@ -3308,9 +3310,19 @@ static __rte_always_inline int __rte_hot cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, struct cnxk_se_sess *sess, struct cpt_inflight_req *infl_req, struct cpt_inst_s *inst, const bool is_sg_ver2) { + enum cpt_dp_thread_type dp_thr_type;int ret; -switch (sess->dp_thr_type) { + dp_thr_type = sess->dp_thr_type; + +/* +* With cipher only, microcode expects that cipher length is non-zero. To accept such +* instructions, send to CPT as passthrough. +*/ +if (unlikely (sess->cipher_only && op->sym->cipher.data.length ==0 )) + dp_thr_type =CPT_DP_THREAD_TYPE_PT ; + +switch (dp_thr_type) {case CPT_DP_THREAD_TYPE_PT : ret =fill_passthrough_params (op, inst);break ;
Signature · 1 line
2.25.1
PATCH 13/15 crypto/cnxk: add support for raw APIs
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
Add crypto RAW API support in cnxk PMD
Enable the flag to allow execution of raw test suite.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 459 ++++++++++++++++++++++ drivers/crypto/cnxk/cnxk_cryptodev.c | 20 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 1 + drivers/crypto/cnxk/cnxk_se.h | 293 ++++++++++++++ 4 files changed, 760 insertions(+), 13 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +459 -0
@@ -1066,6 +1066,461 @@ cn10k_cpt_dev_info_get(struct rte_cryptodev *dev, } } +static inline int +cn10k_cpt_raw_fill_inst (struct cnxk_iov *iov,struct cnxk_cpt_qp *qp, +struct cnxk_sym_dp_ctx *dp_ctx,struct cpt_inst_s inst[], +struct cpt_inflight_req *infl_req,void *opaque,const bool is_sg_ver2) +{ +struct cnxk_se_sess *sess; +int ret; + +const union cpt_res_s res = { + .cn10k.compcode =CPT_COMP_NOT_DONE , + }; + + inst[0 ].w0.u64 =0 ; + inst[0 ].w2.u64 =0 ; + inst[0 ].w3.u64 =0 ; + + sess = dp_ctx->sess; + +switch (sess->dp_thr_type) { +case CPT_DP_THREAD_TYPE_PT : + ret =fill_raw_passthrough_params (iov, inst); +break ; +case CPT_DP_THREAD_TYPE_FC_CHAIN : + ret =fill_raw_fc_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], false, + false, is_sg_ver2); +break ; +case CPT_DP_THREAD_TYPE_FC_AEAD : + ret =fill_raw_fc_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], false, true, + is_sg_ver2); +break ; +case CPT_DP_THREAD_AUTH_ONLY : + ret =fill_raw_digest_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], + is_sg_ver2); +break ; +default : + ret = -EINVAL ; + } + +if (unlikely (ret)) +return 0 ; + + inst[0 ].res_addr = (uint64_t )&infl_req->res; +__atomic_store_n (&infl_req->res.u64[0 ], res.u64[0 ], __ATOMIC_RELAXED); + infl_req->opaque = opaque; + + inst[0 ].w7.u64 = sess->cpt_inst_w7; + +return 1 ; +} + +static uint32_t +cn10k_cpt_raw_enqueue_burst (void *qpair,uint8_t *drv_ctx,struct rte_crypto_sym_vec *vec, +union rte_crypto_sym_ofs ofs,void *user_data[],int *enqueue_status, +const bool is_sgv2) +{ +uint16_t lmt_id, nb_allowed, nb_ops = vec->num; +uint64_t lmt_base, lmt_arg, io_addr, head; +struct cpt_inflight_req *infl_req; +struct cnxk_cpt_qp *qp = qpair; +struct cnxk_sym_dp_ctx *dp_ctx; +struct pending_queue *pend_q; +uint32_t count =0 , index; +union cpt_fc_write_s fc; +struct cpt_inst_s *inst; +uint64_t *fc_addr; +int ret, i; + + pend_q = &qp->pend_q; +const uint64_t pq_mask = pend_q->pq_mask; + + head = pend_q->head; + nb_allowed =pending_queue_free_cnt (head, pend_q->tail, pq_mask); + nb_ops =RTE_MIN (nb_ops, nb_allowed); + +if (unlikely (nb_ops ==0 )) +return 0 ; + + lmt_base = qp->lmtline.lmt_base; + io_addr = qp->lmtline.io_addr; + fc_addr = qp->lmtline.fc_addr; + +const uint32_t fc_thresh = qp->lmtline.fc_thresh; + +ROC_LMT_BASE_ID_GET (lmt_base, lmt_id); + inst = (struct cpt_inst_s *)lmt_base; + + dp_ctx = (struct cnxk_sym_dp_ctx *)drv_ctx; +again: + fc.u64[0 ] =__atomic_load_n (fc_addr, __ATOMIC_RELAXED); +if (unlikely (fc.s.qsize > fc_thresh)) { + i =0 ; + goto pend_q_commit; + } + +for (i =0 ; i <RTE_MIN (PKTS_PER_LOOP , nb_ops); i++) { +struct cnxk_iov iov; + + index = count + i; + infl_req = &pend_q->req_queue[head]; + infl_req->op_flags =0 ; + +cnxk_raw_burst_to_iov (vec, &ofs, index, &iov); + ret =cn10k_cpt_raw_fill_inst (&iov, qp, dp_ctx, &inst[2 * i], infl_req, + user_data[index], is_sgv2); +if (unlikely (ret !=1 )) { +plt_dp_err ("Could not process vec: %d" , index); +if (i ==0 && count ==0 ) +return -1 ; +else if (i ==0 ) + goto pend_q_commit; +else +break ; + } +pending_queue_advance (&head, pq_mask); + } + +if (i >PKTS_PER_STEORL ) { + lmt_arg =ROC_CN10K_CPT_LMT_ARG | (PKTS_PER_STEORL -1 ) <<12 | (uint64_t )lmt_id; +roc_lmt_submit_steorl (lmt_arg, io_addr); + lmt_arg =ROC_CN10K_CPT_LMT_ARG | (i -PKTS_PER_STEORL -1 ) <<12 | + (uint64_t )(lmt_id +PKTS_PER_STEORL ); +roc_lmt_submit_steorl (lmt_arg, io_addr); + }else { + lmt_arg =ROC_CN10K_CPT_LMT_ARG | (i -1 ) <<12 | (uint64_t )lmt_id; +roc_lmt_submit_steorl (lmt_arg, io_addr); + } + +rte_io_wmb (); + +if (nb_ops - i >0 && i ==PKTS_PER_LOOP ) { + nb_ops -= i; + count += i; + goto again; + } + +pend_q_commit: +rte_atomic_thread_fence (__ATOMIC_RELEASE); + + pend_q->head = head; + pend_q->time_out =rte_get_timer_cycles () +DEFAULT_COMMAND_TIMEOUT *rte_get_timer_hz (); + + *enqueue_status =1 ; +return count + i; +} + +static uint32_t +cn10k_cpt_raw_enqueue_burst_sgv2 (void *qpair,uint8_t *drv_ctx,struct rte_crypto_sym_vec *vec, +union rte_crypto_sym_ofs ofs,void *user_data[], +int *enqueue_status) +{ +return cn10k_cpt_raw_enqueue_burst (qpair, drv_ctx, vec, ofs, user_data, enqueue_status, + true); +} + +static uint32_t +cn10k_cpt_raw_enqueue_burst_sgv1 (void *qpair,uint8_t *drv_ctx,struct rte_crypto_sym_vec *vec, +union rte_crypto_sym_ofs ofs,void *user_data[], +int *enqueue_status) +{ +return cn10k_cpt_raw_enqueue_burst (qpair, drv_ctx, vec, ofs, user_data, enqueue_status, + false); +} + +static int +cn10k_cpt_raw_enqueue (void *qpair,uint8_t *drv_ctx,struct rte_crypto_vec *data_vec, +uint16_t n_data_vecs,union rte_crypto_sym_ofs ofs, +struct rte_crypto_va_iova_ptr *iv,struct rte_crypto_va_iova_ptr *digest, +struct rte_crypto_va_iova_ptr *aad_or_auth_iv,void *user_data, +const bool is_sgv2) +{ +uint64_t lmt_base, lmt_arg, io_addr, head; +struct cpt_inflight_req *infl_req; +struct cnxk_cpt_qp *qp = qpair; +struct cnxk_sym_dp_ctx *dp_ctx; +uint16_t lmt_id, nb_allowed; +struct cpt_inst_s *inst; +union cpt_fc_write_s fc; +struct cnxk_iov iov; +uint64_t *fc_addr; +int ret; + +struct pending_queue *pend_q = &qp->pend_q; +const uint64_t pq_mask = pend_q->pq_mask; +const uint32_t fc_thresh = qp->lmtline.fc_thresh; + + head = pend_q->head; + nb_allowed =pending_queue_free_cnt (head, pend_q->tail, pq_mask); + +if (unlikely (nb_allowed ==0 )) +return -1 ; + +cnxk_raw_to_iov (data_vec, n_data_vecs, &ofs, iv, digest, aad_or_auth_iv, &iov); + + lmt_base = qp->lmtline.lmt_base; + io_addr = qp->lmtline.io_addr; + fc_addr = qp->lmtline.fc_addr; + +ROC_LMT_BASE_ID_GET (lmt_base, lmt_id); + inst = (struct cpt_inst_s *)lmt_base; + + fc.u64[0 ] =__atomic_load_n (fc_addr, __ATOMIC_RELAXED); +if (unlikely (fc.s.qsize > fc_thresh)) +return -1 ; + + dp_ctx = (struct cnxk_sym_dp_ctx *)drv_ctx; + infl_req = &pend_q->req_queue[head]; + infl_req->op_flags =0 ; + + ret =cn10k_cpt_raw_fill_inst (&iov, qp, dp_ctx, &inst[0 ], infl_req, user_data, is_sgv2); +if (unlikely (ret !=1 )) { +plt_dp_err ("Could not process vec" ); +return -1 ; + } + +pending_queue_advance (&head, pq_mask); + + lmt_arg =ROC_CN10K_CPT_LMT_ARG | (uint64_t )lmt_id; +roc_lmt_submit_steorl (lmt_arg, io_addr); + +rte_io_wmb (); + + pend_q->head = head; + pend_q->time_out =rte_get_timer_cycles () +DEFAULT_COMMAND_TIMEOUT *rte_get_timer_hz (); + +return 1 ; +} + +static int +cn10k_cpt_raw_enqueue_sgv2 (void *qpair,uint8_t *drv_ctx,struct rte_crypto_vec *data_vec, +uint16_t n_data_vecs,union rte_crypto_sym_ofs ofs, +struct rte_crypto_va_iova_ptr *iv,struct rte_crypto_va_iova_ptr *digest, +struct rte_crypto_va_iova_ptr *aad_or_auth_iv,void *user_data) +{ +return cn10k_cpt_raw_enqueue (qpair, drv_ctx, data_vec, n_data_vecs, ofs, iv, digest, + aad_or_auth_iv, user_data, true); +} + +static int +cn10k_cpt_raw_enqueue_sgv1 (void *qpair,uint8_t *drv_ctx,struct rte_crypto_vec *data_vec, +uint16_t n_data_vecs,union rte_crypto_sym_ofs ofs, +struct rte_crypto_va_iova_ptr *iv,struct rte_crypto_va_iova_ptr *digest, +struct rte_crypto_va_iova_ptr *aad_or_auth_iv,void *user_data) +{ +return cn10k_cpt_raw_enqueue (qpair, drv_ctx, data_vec, n_data_vecs, ofs, iv, digest, + aad_or_auth_iv, user_data, false); +} + +static inline int +cn10k_cpt_raw_dequeue_post_process (struct cpt_cn10k_res_s *res) +{ +const uint8_t uc_compcode = res->uc_compcode; +const uint8_t compcode = res->compcode; +int ret =1 ; + +if (likely (compcode ==CPT_COMP_GOOD )) { +if (unlikely (uc_compcode)) +plt_dp_info ("Request failed with microcode error: 0x%x" , res->uc_compcode); +else + ret =0 ; + } + +return ret; +} + +static uint32_t +cn10k_cpt_sym_raw_dequeue_burst (void *qptr,uint8_t *drv_ctx, +rte_cryptodev_raw_get_dequeue_count_t get_dequeue_count, +uint32_t max_nb_to_dequeue, +rte_cryptodev_raw_post_dequeue_t post_dequeue,void **out_user_data, +uint8_t is_user_data_array,uint32_t *n_success, +int *dequeue_status) +{ +struct cpt_inflight_req *infl_req; +struct cnxk_cpt_qp *qp = qptr; +struct pending_queue *pend_q; +uint64_t infl_cnt, pq_tail; +union cpt_res_s res; +int is_op_success; +uint16_t nb_ops; +void *opaque; +int i =0 ; + + pend_q = &qp->pend_q; + +const uint64_t pq_mask = pend_q->pq_mask; + +RTE_SET_USED (drv_ctx); + pq_tail = pend_q->tail; + infl_cnt =pending_queue_infl_cnt (pend_q->head, pq_tail, pq_mask); + +/* Ensure infl_cnt isn't read before data lands */ +rte_atomic_thread_fence (__ATOMIC_ACQUIRE); + + infl_req = &pend_q->req_queue[pq_tail]; + + opaque = infl_req->opaque; +if (get_dequeue_count) + nb_ops =get_dequeue_count (opaque); +else + nb_ops = max_nb_to_dequeue; + nb_ops =RTE_MIN (nb_ops, infl_cnt); + +for (i =0 ; i < nb_ops; i++) { + is_op_success =0 ; + infl_req = &pend_q->req_queue[pq_tail]; + + res.u64[0 ] =__atomic_load_n (&infl_req->res.u64[0 ], __ATOMIC_RELAXED); + +if (unlikely (res.cn10k.compcode ==CPT_COMP_NOT_DONE )) { +if (unlikely (rte_get_timer_cycles () > pend_q->time_out)) { +plt_err ("Request timed out" ); +cnxk_cpt_dump_on_err (qp); + pend_q->time_out =rte_get_timer_cycles () + +DEFAULT_COMMAND_TIMEOUT *rte_get_timer_hz (); + } +break ; + } + +pending_queue_advance (&pq_tail, pq_mask); + +if (!cn10k_cpt_raw_dequeue_post_process (&res.cn10k)) { + is_op_success =1 ; + *n_success +=1 ; + } + +if (is_user_data_array) { + out_user_data[i] = infl_req->opaque; +post_dequeue (out_user_data[i], i, is_op_success); + }else { +if (i ==0 ) + out_user_data[0 ] = opaque; +post_dequeue (out_user_data[0 ], i, is_op_success); + } + +if (unlikely (infl_req->op_flags &CPT_OP_FLAGS_METABUF )) +rte_mempool_put (qp->meta_info.pool, infl_req->mdata); + } + + pend_q->tail = pq_tail; + *dequeue_status =1 ; + +return i; +} + +static void * +cn10k_cpt_sym_raw_dequeue (void *qptr,uint8_t *drv_ctx,int *dequeue_status, +enum rte_crypto_op_status *op_status) +{ +struct cpt_inflight_req *infl_req; +struct cnxk_cpt_qp *qp = qptr; +struct pending_queue *pend_q; +uint64_t pq_tail; +union cpt_res_s res; +void *opaque =NULL ; + + pend_q = &qp->pend_q; + +const uint64_t pq_mask = pend_q->pq_mask; + +RTE_SET_USED (drv_ctx); + + pq_tail = pend_q->tail; + +rte_atomic_thread_fence (__ATOMIC_ACQUIRE); + + infl_req = &pend_q->req_queue[pq_tail]; + + res.u64[0 ] =__atomic_load_n (&infl_req->res.u64[0 ], __ATOMIC_RELAXED); + +if (unlikely (res.cn10k.compcode ==CPT_COMP_NOT_DONE )) { +if (unlikely (rte_get_timer_cycles () > pend_q->time_out)) { +plt_err ("Request timed out" ); +cnxk_cpt_dump_on_err (qp); + pend_q->time_out =rte_get_timer_cycles () + +DEFAULT_COMMAND_TIMEOUT *rte_get_timer_hz (); + } + goto exit; + } + +pending_queue_advance (&pq_tail, pq_mask); + + opaque = infl_req->opaque; + +if (!cn10k_cpt_raw_dequeue_post_process (&res.cn10k)) + *op_status =RTE_CRYPTO_OP_STATUS_SUCCESS ; +else + *op_status =RTE_CRYPTO_OP_STATUS_ERROR ; + +if (unlikely (infl_req->op_flags &CPT_OP_FLAGS_METABUF )) +rte_mempool_put (qp->meta_info.pool, infl_req->mdata); + + *dequeue_status =1 ; +exit: +return opaque; +} + +static int +cn10k_sym_get_raw_dp_ctx_size(struct rte_cryptodev *dev __rte_unused) +{ +return sizeof (struct cnxk_sym_dp_ctx ); +} + +static int +cn10k_sym_configure_raw_dp_ctx (struct rte_cryptodev *dev,uint16_t qp_id, +struct rte_crypto_raw_dp_ctx *raw_dp_ctx, +enum rte_crypto_op_sess_type sess_type, +union rte_cryptodev_session_ctx session_ctx,uint8_t is_update) +{ +struct cnxk_se_sess *sess = (struct cnxk_se_sess *)session_ctx.crypto_sess; +struct cnxk_sym_dp_ctx *dp_ctx; + +if (sess_type !=RTE_CRYPTO_OP_WITH_SESSION ) +return -ENOTSUP ; + +if (sess ==NULL ) +return -EINVAL ; + +if ((sess->dp_thr_type ==CPT_DP_THREAD_TYPE_PDCP ) || + (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_PDCP_CHAIN ) || + (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_KASUMI )) +return -ENOTSUP ; + +if ((sess->dp_thr_type ==CPT_DP_THREAD_AUTH_ONLY ) && + ((sess->roc_se_ctx.fc_type ==ROC_SE_KASUMI ) || + (sess->roc_se_ctx.fc_type ==ROC_SE_PDCP ))) +return -ENOTSUP ; + +if ((sess->roc_se_ctx.hash_type ==ROC_SE_GMAC_TYPE ) || + (sess->roc_se_ctx.hash_type ==ROC_SE_SHA1_TYPE )) +return -ENOTSUP ; + + dp_ctx = (struct cnxk_sym_dp_ctx *)raw_dp_ctx->drv_ctx_data; + dp_ctx->sess = sess; + +if (!is_update) { +struct cnxk_cpt_vf *vf; + + raw_dp_ctx->qp_data = (struct cnxk_cpt_qp *)dev->data->queue_pairs[qp_id]; + raw_dp_ctx->dequeue = cn10k_cpt_sym_raw_dequeue; + raw_dp_ctx->dequeue_burst = cn10k_cpt_sym_raw_dequeue_burst; + + vf = dev->data->dev_private; +if (vf->cpt.hw_caps[CPT_ENG_TYPE_SE ].sg_ver2 && + vf->cpt.hw_caps[CPT_ENG_TYPE_IE ].sg_ver2) { + raw_dp_ctx->enqueue = cn10k_cpt_raw_enqueue_sgv2; + raw_dp_ctx->enqueue_burst = cn10k_cpt_raw_enqueue_burst_sgv2; + }else { + raw_dp_ctx->enqueue = cn10k_cpt_raw_enqueue_sgv1; + raw_dp_ctx->enqueue_burst = cn10k_cpt_raw_enqueue_burst_sgv1; + } + } + +return 0 ; +} +struct rte_cryptodev_ops cn10k_cpt_ops = {/* Device control ops */ .dev_configure = cnxk_cpt_dev_config,
@@ -1092,4 +1547,8 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {/* Event crypto ops */ .session_ev_mdata_set = cn10k_cpt_crypto_adapter_ev_mdata_set, .queue_pair_event_error_query = cnxk_cpt_queue_pair_event_error_query, + +/* Raw data-path API related operations */ + .sym_get_raw_dp_ctx_size = cn10k_sym_get_raw_dp_ctx_size, + .sym_configure_raw_dp_ctx = cn10k_sym_configure_raw_dp_ctx, };
drivers/crypto/cnxk/cnxk_cryptodev.c +7 -13
@@ -13,22 +13,16 @@uint64_t cnxk_cpt_default_ff_get (void ) { -uint64_t ff =RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | -RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO | -RTE_CRYPTODEV_FF_HW_ACCELERATED | -RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT | +uint64_t ff =RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO | +RTE_CRYPTODEV_FF_HW_ACCELERATED |RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT |RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP | -RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING | -RTE_CRYPTODEV_FF_IN_PLACE_SGL | -RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT | -RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT | -RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT | -RTE_CRYPTODEV_FF_SYM_SESSIONLESS | -RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED | -RTE_CRYPTODEV_FF_SECURITY ; +RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |RTE_CRYPTODEV_FF_IN_PLACE_SGL | +RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT | +RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |RTE_CRYPTODEV_FF_SYM_SESSIONLESS | +RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED |RTE_CRYPTODEV_FF_SECURITY ;if (roc_model_is_cn10k ()) - ff |=RTE_CRYPTODEV_FF_SECURITY_INNER_CSUM ; + ff |=RTE_CRYPTODEV_FF_SECURITY_INNER_CSUM |RTE_CRYPTODEV_FF_SYM_RAW_DP ;return ff; }
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +1 -0
@@ -45,6 +45,7 @@ struct cpt_qp_meta_info {struct cpt_inflight_req {union cpt_res_s res;union { +void *opaque;struct rte_crypto_op *cop;struct rte_event_vector *vec; };
drivers/crypto/cnxk/cnxk_se.h +293 -0
303 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH 13/15] crypto/cnxk: add support for raw APIs
Quoted 57 lines
Subject: [PATCH 13/15]
crypto/cnxk: add support for raw APIsFrom: Anoob Joseph <[email protected]>
Add crypto RAW API support in cnxk PMD
Enable the flag to allow execution of raw test suite.Signed-off-by Vidya Sagar Velumuri <[email protected]>Signed-off-by Anoob Joseph <[email protected]>--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 459 ++++++++++++++++++++++ drivers/crypto/cnxk/cnxk_cryptodev.c | 20 +- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 1 + drivers/crypto/cnxk/cnxk_se.h | 293 ++++++++++++++ 4 files changed, 760 insertions(+), 13 deletions(-)drivers/crypto/cnxk/cnxk_cryptodev.c +1
-4@@ -13,22 +13,16 @@uint64_t cnxk_cpt_default_ff_get (void ) { -uint64_t ff =RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO | -RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO | -RTE_CRYPTODEV_FF_HW_ACCELERATED | - RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT | + uint64_t ff = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO|drivers/crypto/cnxk/cnxk_cryptodev.c +1
-0+ RTE_CRYPTODEV_FF_HW_ACCELERATED |
RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT|drivers/crypto/cnxk/cnxk_cryptodev.c +1
-8RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP | -RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING | -RTE_CRYPTODEV_FF_IN_PLACE_SGL | -RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT | -RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT | -RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT | -RTE_CRYPTODEV_FF_SYM_SESSIONLESS | -RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED | -RTE_CRYPTODEV_FF_SECURITY ; + RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
RTE_CRYPTODEV_FF_IN_PLACE_SGL|drivers/crypto/cnxk/cnxk_cryptodev.c +1
-0+ RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT|drivers/crypto/cnxk/cnxk_cryptodev.c +1
-0+ RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
RTE_CRYPTODEV_FF_SYM_SESSIONLESS|drivers/crypto/cnxk/cnxk_cryptodev.c +1
-0+ RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED |
RTE_CRYPTODEV_FF_SECURITY;drivers/crypto/cnxk/cnxk_cryptodev.c +1
-1if (roc_model_is_cn10k ()) - ff |=RTE_CRYPTODEV_FF_SECURITY_INNER_CSUM ; + ff |= RTE_CRYPTODEV_FF_SECURITY_INNER_CSUM |
RTE_CRYPTODEV_FF_SYM_RAW_DP;
Quoted 2 lines
return ff;
}
Update cnxk.ini file accordingly.
PATCH 14/15 crypto/cnxk: update the iv from proper param for gmac
In reply to Tejasree KondojFrom: Vidya Sagar Velumuri <[email protected]>
In raw crypto, aad and auth iv are provided in same param. Update the auth_iv from proper param in case of GMAC. Skip the raw for SM ciphers and auths
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 6 +++--- drivers/crypto/cnxk/cnxk_se.h | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +3 -3
@@ -1485,7 +1485,8 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,if ((sess->dp_thr_type ==CPT_DP_THREAD_TYPE_PDCP ) || (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_PDCP_CHAIN ) || - (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_KASUMI )) + (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_KASUMI ) || + (sess->dp_thr_type ==CPT_DP_THREAD_TYPE_SM ))return -ENOTSUP ; if ((sess->dp_thr_type == CPT_DP_THREAD_AUTH_ONLY) &&
@@ -1493,8 +1494,7 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id, (sess->roc_se_ctx.fc_type == ROC_SE_PDCP)))return -ENOTSUP ; -if ((sess->roc_se_ctx.hash_type ==ROC_SE_GMAC_TYPE ) || - (sess->roc_se_ctx.hash_type ==ROC_SE_SHA1_TYPE )) +if (sess->roc_se_ctx.hash_type ==ROC_SE_SHA1_TYPE )return -ENOTSUP ; dp_ctx = (struct cnxk_sym_dp_ctx *)raw_dp_ctx->drv_ctx_data;
drivers/crypto/cnxk/cnxk_se.h +15 -6
@@ -3499,14 +3499,23 @@ fill_raw_fc_params(struct cnxk_iov *iov, struct cnxk_se_sess *sess, struct cpt_q fc_params.mac_buf.vaddr =0 ; fc_params.iv_buf =NULL ; -if (likely (is_kasumi || sess->iv_length)) { +if (likely (sess->iv_length)) { flags |=ROC_SE_VALID_IV_BUF ; - fc_params.iv_buf = iov->iv_buf; -if (sess->short_iv) { -memcpy ((uint8_t *)iv_buf, iov->iv_buf,12 ); - iv_buf[3 ] =rte_cpu_to_be_32 (0x1 ); - fc_params.iv_buf = iv_buf; +if (sess->is_gmac) { + fc_params.iv_buf = iov->aad_buf; +if (sess->short_iv) { +memcpy ((void *)iv_buf, iov->aad_buf,12 ); + iv_buf[3 ] =rte_cpu_to_be_32 (0x1 ); + fc_params.iv_buf = iv_buf; + } + }else { + fc_params.iv_buf = iov->iv_buf; +if (sess->short_iv) { +memcpy ((void *)iv_buf, iov->iv_buf,12 ); + iv_buf[3 ] =rte_cpu_to_be_32 (0x1 ); + fc_params.iv_buf = iv_buf; + } }if (sess->aes_ccm) {
Signature · 1 line
2.25.1
PATCH 15/15 test/crypto: enable raw crypto tests for crypto_cn10k
In reply to Tejasree KondojFrom: Anoob Joseph <[email protected]>
Enable raw crypto tests with crypto_cn10k.
--- app/test/test_cryptodev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
app/test/test_cryptodev.c +8 -0
@@ -17721,6 +17721,12 @@ test_cryptodev_cn10k(void)return run_cryptodev_testsuite (RTE_STR (CRYPTODEV_NAME_CN10K_PMD )); } +static int +test_cryptodev_cn10k_raw_api (void ) +{ +return run_cryptodev_raw_testsuite (RTE_STR (CRYPTODEV_NAME_CN10K_PMD )); +} +static int test_cryptodev_dpaa2_sec_raw_api (void ) {
@@ -17733,6 +17739,8 @@ test_cryptodev_dpaa_sec_raw_api(void)return run_cryptodev_raw_testsuite (RTE_STR (CRYPTODEV_NAME_DPAA_SEC_PMD )); } +REGISTER_TEST_COMMAND (cryptodev_cn10k_raw_api_autotest, + test_cryptodev_cn10k_raw_api);REGISTER_TEST_COMMAND (cryptodev_dpaa2_sec_raw_api_autotest, test_cryptodev_dpaa2_sec_raw_api); REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
Signature · 1 line
2.25.1