fixes and improvements to cnxk crypto PMD
Subsystems (2)
v3 cover fixes and improvements to cnxk crypto PMD
Adding fixes and improvements to cnxk crypto PMD.
v3:
- Removed redundant code
- Added two patches for fixes.
Nithinsen Kaithakadan (4):
common/cnxk: get context ilen as devarg
crypto/cnxk: fix compilation error and warnings
crypto/cnxk: align cptr to 256B in cn20k
crypto/cnxk: fix tls mbuf sanity failures
Sucharitha Sarananaga (3):
crypto/cnxk: add new API to get fpm tbl address crypto/cnxk: add new API to get EC grp tbl address crypto/cnxk: refactor rsa verification
Tejasree Kondoj (3):
crypto/cnxk: align PDCP API with latest firmware crypto/cnxk: support custom metadata with CN20K common/cnxk: optimize ROC layer
doc/guides/cryptodevs/cnxk.rst | 11 + drivers/common/cnxk/cnxk_security.c | 20 +- drivers/common/cnxk/cnxk_security.h | 25 +- drivers/common/cnxk/hw/cpt.h | 14 +- drivers/common/cnxk/roc_cpt.c | 7 +- drivers/common/cnxk/roc_cpt.h | 5 + drivers/common/cnxk/roc_cpt_sg.h | 1 + drivers/common/cnxk/roc_se.c | 10 +- drivers/common/cnxk/roc_se.h | 37 +- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 56 ++- drivers/crypto/cnxk/cn10k_ipsec.c | 4 +- drivers/crypto/cnxk/cn10k_tls.c | 16 +- drivers/crypto/cnxk/cn20k_cryptodev_ops.c | 59 ++-- drivers/crypto/cnxk/cn20k_ipsec.c | 80 +++-- drivers/crypto/cnxk/cn20k_ipsec.h | 15 +- drivers/crypto/cnxk/cn20k_ipsec_la_ops.h | 41 ++- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 4 +- drivers/crypto/cnxk/cnxk_ae.h | 15 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 1 + drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 49 +++ drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 130 ++++++- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 26 ++ drivers/crypto/cnxk/cnxk_se.h | 340 +++++++++++++------ drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 96 ++++++ drivers/net/cnxk/cn10k_ethdev_sec.c | 14 +- drivers/net/cnxk/cn20k_ethdev_sec.c | 8 +- 26 files changed, 784 insertions(+), 300 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/10 common/cnxk: get context ilen as devarg
From: Nithinsen Kaithakadan <[email protected]>
Receive cpt context ilen as devarg parameter
and configure lf.
--- doc/guides/cryptodevs/cnxk.rst | 11 +++++ drivers/common/cnxk/cnxk_security.c | 20 ++++++-- drivers/common/cnxk/cnxk_security.h | 25 +++++----- drivers/common/cnxk/roc_cpt.c | 8 +++- drivers/common/cnxk/roc_cpt.h | 1 + drivers/crypto/cnxk/cn10k_ipsec.c | 4 +- drivers/crypto/cnxk/cn10k_tls.c | 16 +++++-- drivers/crypto/cnxk/cn20k_ipsec.c | 4 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 1 + drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 49 ++++++++++++++++++++ drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 3 ++ drivers/net/cnxk/cn10k_ethdev_sec.c | 14 +++--- drivers/net/cnxk/cn20k_ethdev_sec.c | 8 ++-- 13 files changed, 126 insertions(+), 38 deletions(-)
doc/guides/cryptodevs/cnxk.rst +11 -0
@@ -200,6 +200,17 @@ Runtime Config Options With the above configuration, QP 20 will be used by the device for Rx injection in security in fallback mechanism scenario. +- ``Context ilen value`` (default ``0``) + + Initial context fetch length value for CPT context. + + For example:: + + -a 0002:20:00.1,ctx_ilen=4 + + With the above configuration, CPT initial context fetch size will be set to + 4+1 128 bytes blocks. + Debugging Options -----------------
drivers/common/cnxk/cnxk_security.c +16 -4
@@ -309,7 +309,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ot_ipsec_inb_sa_fill)int cnxk_ot_ipsec_inb_sa_fill (struct roc_ot_ipsec_inb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen) {uint16_t sport =4500 , dport =4500 ;union roc_ot_ipsec_sa_word2 w2;
@@ -383,6 +383,9 @@ cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa, ROC_CTX_UNIT_128B) -1 ; +if (sa->w0.s.ctx_size < ctx_ilen) + sa->w0.s.ctx_size = ctx_ilen; +/** * CPT MC triggers expiry when counter value changes from 2 to 1. To * mitigate this behaviour add 1 to the life counter values provided.
@@ -419,7 +422,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ot_ipsec_outb_sa_fill)int cnxk_ot_ipsec_outb_sa_fill (struct roc_ot_ipsec_outb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen) {struct rte_security_ipsec_tunnel_param *tunnel = &ipsec_xfrm->tunnel;uint16_t sport =4500 , dport =4500 ;
@@ -541,6 +544,9 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, ROC_CTX_UNIT_128B) -1 ; +if (sa->w0.s.ctx_size < ctx_ilen) + sa->w0.s.ctx_size = ctx_ilen; +/* IPID gen */ sa->w2.s.ipid_gen =1 ;
@@ -1488,7 +1494,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ow_ipsec_inb_sa_fill)int cnxk_ow_ipsec_inb_sa_fill (struct roc_ow_ipsec_inb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen) {uint16_t sport =4500 , dport =4500 ;union roc_ow_ipsec_sa_word2 w2;
@@ -1559,6 +1565,9 @@ cnxk_ow_ipsec_inb_sa_fill(struct roc_ow_ipsec_inb_sa *sa, (PLT_ALIGN_CEIL (ow_ipsec_inb_ctx_size (sa),ROC_CTX_UNIT_128B ) /ROC_CTX_UNIT_128B ) -1 ; +if (sa->w0.s.ctx_size < ctx_ilen) + sa->w0.s.ctx_size = ctx_ilen; +/** * CPT MC triggers expiry when counter value changes from 2 to 1. To * mitigate this behaviour add 1 to the life counter values provided.
@@ -1595,7 +1604,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ow_ipsec_outb_sa_fill)int cnxk_ow_ipsec_outb_sa_fill (struct roc_ow_ipsec_outb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen) {struct rte_security_ipsec_tunnel_param *tunnel = &ipsec_xfrm->tunnel;uint16_t sport =4500 , dport =4500 ;
@@ -1711,6 +1720,9 @@ cnxk_ow_ipsec_outb_sa_fill(struct roc_ow_ipsec_outb_sa *sa,/* IPID gen */ sa->w2.s.ipid_gen =1 ; +if (sa->w0.s.ctx_size < ctx_ilen) + sa->w0.s.ctx_size = ctx_ilen; +/** * CPT MC triggers expiry when counter value changes from 2 to 1. To * mitigate this behaviour add 1 to the life counter values provided.
drivers/common/cnxk/cnxk_security.h +12 -13
@@ -33,19 +33,17 @@ cnxk_ipsec_icvlen_get(enum rte_crypto_cipher_algorithm c_algo,enum rte_crypto_auth_algorithm a_algo, enum rte_crypto_aead_algorithm aead_algo); -uint8_t __roc_api -cnxk_ipsec_outb_roundup_byte (enum rte_crypto_cipher_algorithm c_algo, -enum rte_crypto_aead_algorithm aead_algo); +uint8_t __roc_api cnxk_ipsec_outb_roundup_byte(enum rte_crypto_cipher_algorithm c_algo, +enum rte_crypto_aead_algorithm aead_algo);/* [CN10K] */ -int __roc_api -cnxk_ot_ipsec_inb_sa_fill (struct roc_ot_ipsec_inb_sa *sa, -struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm); -int __roc_api -cnxk_ot_ipsec_outb_sa_fill (struct roc_ot_ipsec_outb_sa *sa, -struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm); +int __roc_api cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa, +struct rte_security_ipsec_xform *ipsec_xfrm, +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen); +int __roc_api cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, +struct rte_security_ipsec_xform *ipsec_xfrm, +struct rte_crypto_sym_xform *crypto_xfrm, +uint8_t ctx_ilen); bool __roc_api cnxk_ot_ipsec_inb_sa_valid(struct roc_ot_ipsec_inb_sa *sa); bool __roc_api cnxk_ot_ipsec_outb_sa_valid(struct roc_ot_ipsec_outb_sa *sa);
@@ -60,10 +58,11 @@ int __roc_api cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipse/* [CN20K, .) */ int __roc_api cnxk_ow_ipsec_inb_sa_fill(struct roc_ow_ipsec_inb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm); +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen); int __roc_api cnxk_ow_ipsec_outb_sa_fill(struct roc_ow_ipsec_outb_sa *sa,struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm); +struct rte_crypto_sym_xform *crypto_xfrm, +uint8_t ctx_ilen); bool __roc_api cnxk_ow_ipsec_inb_sa_valid(struct roc_ow_ipsec_inb_sa *sa); bool __roc_api cnxk_ow_ipsec_outb_sa_valid(struct roc_ow_ipsec_outb_sa *sa);#endif /* _CNXK_SECURITY_H__ */
drivers/common/cnxk/roc_cpt.c +7 -1
@@ -632,10 +632,16 @@ roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf, bool rxc_ena, uint16_t eng_grpmsk = (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_AE ]) | (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_SE ]); -if (roc_errata_cpt_has_ctx_fetch_issue ()) { +if (roc_cpt->ctx_ilen !=0 ) { + ctx_ilen = roc_cpt->ctx_ilen; + ctx_ilen_valid = true; + }else if (roc_errata_cpt_has_ctx_fetch_issue ()) { ctx_ilen_valid = true;/* Inbound SA size is max context size */ ctx_ilen = (PLT_ALIGN (ROC_OT_IPSEC_SA_SZ_MAX ,ROC_ALIGN ) /128 ) -1 ; + }else if (roc_cpt->ctx_ilen !=0 ) { + ctx_ilen = roc_cpt->ctx_ilen; + ctx_ilen_valid = true; } rc = cpt_lfs_alloc(&cpt->dev, eng_grpmsk, blkaddr[blknum], false, ctx_ilen_valid, ctx_ilen,
drivers/common/cnxk/roc_cpt.h +1 -0
@@ -169,6 +169,7 @@ struct roc_cpt {uint16_t nb_lf;uint16_t nb_lf_avail;uintptr_t lmt_base; +uint8_t ctx_ilen;/**< CPT device capabilities */ union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES ];uint8_t eng_grp[CPT_MAX_ENG_TYPES ];
drivers/crypto/cnxk/cn10k_ipsec.c +2 -2
@@ -45,7 +45,7 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =cnxk_ot_ipsec_outb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm); + ret =cnxk_ot_ipsec_outb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill outbound session parameters" ); goto sa_dptr_free;
@@ -176,7 +176,7 @@ cn10k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =cnxk_ot_ipsec_inb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm); + ret =cnxk_ot_ipsec_inb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill inbound session parameters" ); goto sa_dptr_free;
drivers/crypto/cnxk/cn10k_tls.c +12 -4
@@ -327,7 +327,8 @@ tls_read_ctx_size(struct roc_ie_ot_tls_read_sa *sa, enum rte_security_tls_versiostatic int tls_read_sa_fill (struct roc_ie_ot_tls_read_sa *read_sa,struct rte_security_tls_record_xform *tls_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm,struct cn10k_tls_opt *tls_opt) +struct rte_crypto_sym_xform *crypto_xfrm,struct cn10k_tls_opt *tls_opt, +uint8_t ctx_ilen) {enum rte_security_tls_version tls_ver = tls_xfrm->ver;struct rte_crypto_sym_xform *auth_xfrm, *cipher_xfrm;
@@ -470,6 +471,9 @@ tls_read_sa_fill(struct roc_ie_ot_tls_read_sa *read_sa, ROC_CTX_UNIT_128B) -1 ; +if (read_sa->w0.s.ctx_size < ctx_ilen) + read_sa->w0.s.ctx_size = ctx_ilen; +/* Word offset for HW managed CTX field */ read_sa->w0.s.hw_ctx_off = offset /8 ; read_sa->w0.s.ctx_push_size = read_sa->w0.s.hw_ctx_off;
@@ -482,7 +486,7 @@ tls_read_sa_fill(struct roc_ie_ot_tls_read_sa *read_sa,static int tls_write_sa_fill (struct roc_ie_ot_tls_write_sa *write_sa,struct rte_security_tls_record_xform *tls_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) +struct rte_crypto_sym_xform *crypto_xfrm,uint8_t ctx_ilen) {enum rte_security_tls_version tls_ver = tls_xfrm->ver;struct rte_crypto_sym_xform *auth_xfrm, *cipher_xfrm;
@@ -606,6 +610,9 @@ tls_write_sa_fill(struct roc_ie_ot_tls_write_sa *write_sa, write_sa->w0.s.ctx_size -=1 ; } +if (write_sa->w0.s.ctx_size < ctx_ilen) + write_sa->w0.s.ctx_size = ctx_ilen; +/* Word offset for HW managed CTX field */ write_sa->w0.s.hw_ctx_off = offset /8 ; write_sa->w0.s.ctx_push_size = write_sa->w0.s.hw_ctx_off;
@@ -655,7 +662,8 @@ cn10k_tls_read_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =tls_read_sa_fill (sa_dptr, tls_xfrm, crypto_xfrm, &sec_sess->tls_opt); + ret =tls_read_sa_fill (sa_dptr, tls_xfrm, crypto_xfrm, &sec_sess->tls_opt, + roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill read session parameters" ); goto sa_dptr_free;
@@ -745,7 +753,7 @@ cn10k_tls_write_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =tls_write_sa_fill (sa_dptr, tls_xfrm, crypto_xfrm); + ret =tls_write_sa_fill (sa_dptr, tls_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill write session parameters" ); goto sa_dptr_free;
drivers/crypto/cnxk/cn20k_ipsec.c +2 -2
@@ -45,7 +45,7 @@ cn20k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =cnxk_ow_ipsec_outb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm); + ret =cnxk_ow_ipsec_outb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill outbound session parameters" ); goto sa_dptr_free;
@@ -171,7 +171,7 @@ cn20k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, }/* Translate security parameters to SA */ - ret =cnxk_ow_ipsec_inb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm); + ret =cnxk_ow_ipsec_inb_sa_fill (sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);if (ret) {plt_err ("Could not fill inbound session parameters" ); goto sa_dptr_free;
drivers/crypto/cnxk/cnxk_cryptodev.h +1 -0
@@ -36,6 +36,7 @@ struct cnxk_cpt_vf {struct roc_ae_ec_group *ec_grp[ROC_AE_EC_ID_PMAX ];uint16_t max_qps_limit;uint16_t rx_inject_qp; +uint8_t ctx_ilen; };uint64_t cnxk_cpt_default_ff_get (void );
drivers/crypto/cnxk/cnxk_cryptodev_devargs.c +49 -0
84 lines not on this page · raw message
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +3 -0
@@ -819,6 +819,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xforif (hw_ctx_cache_enable ())roc_se_ctx_init (&sess_priv->roc_se_ctx); +if (sess_priv->roc_se_ctx.se_ctx.w0.s.ctx_size < roc_cpt->ctx_ilen) + sess_priv->roc_se_ctx.se_ctx.w0.s.ctx_size = roc_cpt->ctx_ilen; +return 0 ; priv_put:
drivers/net/cnxk/cn10k_ethdev_sec.c +6 -8
@@ -845,10 +845,9 @@ cn10k_eth_sec_session_create(void *device,memset (inb_sa_dptr,0 ,sizeof (struct roc_ot_ipsec_inb_sa ));/* Fill inbound sa params */ - rc =cnxk_ot_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto); + rc =cnxk_ot_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto,0 );if (rc) { -snprintf (tbuf,sizeof (tbuf), -"Failed to init inbound sa, rc=%d" , rc); +snprintf (tbuf,sizeof (tbuf),"Failed to init inbound sa, rc=%d" , rc); goto err; }
@@ -936,10 +935,9 @@ cn10k_eth_sec_session_create(void *device,memset (outb_sa_dptr,0 ,sizeof (struct roc_ot_ipsec_outb_sa ));/* Fill outbound sa params */ - rc =cnxk_ot_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto); + rc =cnxk_ot_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto,0 );if (rc) { -snprintf (tbuf,sizeof (tbuf), -"Failed to init outbound sa, rc=%d" , rc); +snprintf (tbuf,sizeof (tbuf),"Failed to init outbound sa, rc=%d" , rc); rc |=cnxk_eth_outb_sa_idx_put (dev, sa_idx); goto err; }
@@ -1148,7 +1146,7 @@ cn10k_eth_sec_session_update(void *device, struct rte_security_session *sess, inb_sa_dptr = (struct roc_ot_ipsec_inb_sa *)dev->inb.sa_dptr;memset (inb_sa_dptr,0 ,sizeof (struct roc_ot_ipsec_inb_sa )); - rc =cnxk_ot_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto); + rc =cnxk_ot_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto,0 );if (rc) goto err;/* Use cookie for original data */
@@ -1183,7 +1181,7 @@ cn10k_eth_sec_session_update(void *device, struct rte_security_session *sess, outb_sa_dptr = (struct roc_ot_ipsec_outb_sa *)dev->outb.sa_dptr;memset (outb_sa_dptr,0 ,sizeof (struct roc_ot_ipsec_outb_sa )); - rc =cnxk_ot_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto); + rc =cnxk_ot_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto,0 );if (rc) goto err;
drivers/net/cnxk/cn20k_ethdev_sec.c +4 -4
@@ -736,7 +736,7 @@ cn20k_eth_sec_session_create(void *device, struct rte_security_session_conf *conmemset (inb_sa_dptr,0 ,sizeof (struct roc_ow_ipsec_inb_sa ));/* Fill inbound sa params */ - rc =cnxk_ow_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto); + rc =cnxk_ow_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto,0 );if (rc) {snprintf (tbuf,sizeof (tbuf),"Failed to init inbound sa, rc=%d" , rc); goto err;
@@ -814,7 +814,7 @@ cn20k_eth_sec_session_create(void *device, struct rte_security_session_conf *conmemset (outb_sa_dptr,0 ,sizeof (struct roc_ow_ipsec_outb_sa ));/* Fill outbound sa params */ - rc =cnxk_ow_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto); + rc =cnxk_ow_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto,0 );if (rc) {snprintf (tbuf,sizeof (tbuf),"Failed to init outbound sa, rc=%d" , rc); rc |=cnxk_eth_outb_sa_idx_put (dev, sa_idx);
@@ -1000,7 +1000,7 @@ cn20k_eth_sec_session_update(void *device, struct rte_security_session *sess, inb_sa_dptr = (struct roc_ow_ipsec_inb_sa *)dev->inb.sa_dptr;memset (inb_sa_dptr,0 ,sizeof (struct roc_ow_ipsec_inb_sa )); - rc =cnxk_ow_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto); + rc =cnxk_ow_ipsec_inb_sa_fill (inb_sa_dptr, ipsec, crypto,0 );if (rc)return -EINVAL ;/* Use cookie for original data */
@@ -1034,7 +1034,7 @@ cn20k_eth_sec_session_update(void *device, struct rte_security_session *sess, outb_sa_dptr = (struct roc_ow_ipsec_outb_sa *)dev->outb.sa_dptr;memset (outb_sa_dptr,0 ,sizeof (struct roc_ow_ipsec_outb_sa )); - rc =cnxk_ow_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto); + rc =cnxk_ow_ipsec_outb_sa_fill (outb_sa_dptr, ipsec, crypto,0 );if (rc)return -EINVAL ;
Signature · 1 line
2.25.1
PATCH v3 2/10 crypto/cnxk: fix compilation error and warnings
In reply to Tejasree KondojFrom: Nithinsen Kaithakadan <[email protected]>
Remove multiple return statements.
Fix compilation error in debug mode.
--- drivers/crypto/cnxk/cn20k_ipsec.c | 2 -- 1 file changed, 2 deletions(-)
drivers/crypto/cnxk/cn20k_ipsec.c +0 -2
@@ -373,6 +373,4 @@ cn20k_ipsec_session_update(struct cnxk_cpt_vf *vf, struct cnxk_cpt_qp *qp,return cn20k_ipsec_outb_sa_create (roc_cpt, &qp->lf, &conf->ipsec, conf->crypto_xform, (struct cn20k_sec_session *)sess); - -return 0 ; }
Signature · 1 line
2.25.1
PATCH v3 3/10 crypto/cnxk: add new API to get fpm tbl address
In reply to Tejasree KondojFrom: Sucharitha Sarananaga <[email protected]>
This patch introduces a new API to get FPM table host address.
--- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 23 +++++++++++++++++++++++ drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +23 -0
@@ -12,6 +12,7 @@#endif #include <rte_security_driver.h> +#include "roc_ae.h" #include "roc_ae_fpm_tables.h" #include "roc_cpt.h" #include "roc_errata.h"
@@ -995,6 +996,28 @@ rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id)return qptr; } +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_cnxk_ae_fpm_table_get, 25.07) +const uint64_t * +rte_pmd_cnxk_ae_fpm_table_get (uint8_t dev_id) +{ +struct rte_cryptodev *dev; +struct cnxk_cpt_vf *vf; + + dev =rte_cryptodev_pmd_get_dev (dev_id); +if (dev ==NULL ) { +plt_err ("Invalid dev_id %u" , dev_id); +return NULL ; + } + + vf = dev->data->dev_private; +if (vf ==NULL ) { +plt_err ("VF is not initialized" ); +return NULL ; + } + +return vf->cnxk_fpm_iova; +} +static inline void cnxk_crypto_cn10k_submit (struct rte_pmd_cnxk_crypto_qptr *qptr,void *inst,uint16_t nb_inst) {
drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h +18 -0
@@ -213,4 +213,22 @@ __rte_experimentalint rte_pmd_cnxk_crypto_qp_stats_get (struct rte_pmd_cnxk_crypto_qptr *qptr,struct rte_pmd_cnxk_crypto_qp_stats *stats); +/** +* Retrieves the addresses of the AE FPM (Finite Precision Math) tables. +* +* This API should be called only after the cryptodev device has been +* successfully configured. The returned pointer reference memory that is +* valid as long as the device remains configured and is not destroyed or +* reconfigured. If the device is reconfigured or destroyed, the memory +* referenced by the returned pointer becomes invalid and must not be used. +* +* @param dev_id +* Device identifier of cryptodev device. +* @return +* - On success pointer to the AE FPM table addresses. +* - NULL on error. +*/ +__rte_experimental +const uint64_t *rte_pmd_cnxk_ae_fpm_table_get(uint8_t dev_id); +#endif /* _PMD_CNXK_CRYPTO_H_ */
Signature · 1 line
2.25.1
PATCH v3 4/10 crypto/cnxk: add new API to get EC grp tbl address
In reply to Tejasree KondojFrom: Sucharitha Sarananaga <[email protected]>
This patch introduces a new API to get AE EC group table address and added static_assert checks to ensure that each enum value in roc_ae_ec_id matches its expected constant. This helps catch accidental changes or reordering of enum values at compile time.
--- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 47 ++++++++++++++ drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 78 +++++++++++++++++++++++ 2 files changed, 125 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +47 -0
@@ -43,6 +43,29 @@#define CNXK_CPT_MAX_ASYM_OP_MOD_LEN 1024#define CNXK_CPT_META_BUF_MAX_CACHE_SIZE 128 +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P192 == (uint16_t )ROC_AE_EC_ID_P192 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P224 == (uint16_t )ROC_AE_EC_ID_P224 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P256 == (uint16_t )ROC_AE_EC_ID_P256 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P384 == (uint16_t )ROC_AE_EC_ID_P384 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P521 == (uint16_t )ROC_AE_EC_ID_P521 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P160 == (uint16_t )ROC_AE_EC_ID_P160 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P320 == (uint16_t )ROC_AE_EC_ID_P320 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_P512 == (uint16_t )ROC_AE_EC_ID_P512 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_SM2 == (uint16_t )ROC_AE_EC_ID_SM2 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_ED25519 == (uint16_t )ROC_AE_EC_ID_ED25519 , +"Enum value mismatch" ); +static_assert ((uint16_t )RTE_PMD_CNXK_AE_EC_ID_ED448 == (uint16_t )ROC_AE_EC_ID_ED448 , +"Enum value mismatch" ); +static int cnxk_cpt_get_mlen (void ) {
@@ -1018,6 +1041,30 @@ rte_pmd_cnxk_ae_fpm_table_get(uint8_t dev_id)return vf->cnxk_fpm_iova; } +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_cnxk_ae_ec_grp_table_get, 25.07) +const struct rte_pmd_cnxk_crypto_ae_ec_group_params ** +rte_pmd_cnxk_ae_ec_grp_table_get (uint8_t dev_id,uint16_t *nb_max_entries) +{ +struct rte_cryptodev *dev; +struct cnxk_cpt_vf *vf; + + dev =rte_cryptodev_pmd_get_dev (dev_id); +if (dev ==NULL ) { +plt_err ("Invalid dev_id %u" , dev_id); +return NULL ; + } + + vf = dev->data->dev_private; +if (vf ==NULL ) { +plt_err ("VF is not initialized" ); +return NULL ; + } + + *nb_max_entries =ROC_AE_EC_ID_PMAX ; + +return (const struct rte_pmd_cnxk_crypto_ae_ec_group_params **)(void *)vf->ec_grp; +} +static inline void cnxk_crypto_cn10k_submit (struct rte_pmd_cnxk_crypto_qptr *qptr,void *inst,uint16_t nb_inst) {
drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h +78 -0
94 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 5/10 crypto/cnxk: align cptr to 256B in cn20k
In reply to Tejasree KondojFrom: Nithinsen Kaithakadan <[email protected]>
Change the alignment of cptr to 256 bytes from
128 bytes in cn20k.
--- drivers/common/cnxk/roc_cpt.c | 5 +- drivers/common/cnxk/roc_cpt.h | 4 + drivers/common/cnxk/roc_se.h | 37 +++---- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 8 +- drivers/crypto/cnxk/cn20k_cryptodev_ops.c | 8 +- drivers/crypto/cnxk/cn20k_ipsec.c | 74 +++++++++---- drivers/crypto/cnxk/cn20k_ipsec.h | 15 ++- drivers/crypto/cnxk/cn20k_ipsec_la_ops.h | 41 +++++--- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 61 ++++++++--- drivers/crypto/cnxk/cnxk_se.h | 121 ++++++++++++++++------ 10 files changed, 254 insertions(+), 120 deletions(-)
drivers/common/cnxk/roc_cpt.c +1 -4
@@ -632,10 +632,7 @@ roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf, bool rxc_ena, uint16_t eng_grpmsk = (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_AE ]) | (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_SE ]); -if (roc_cpt->ctx_ilen !=0 ) { - ctx_ilen = roc_cpt->ctx_ilen; - ctx_ilen_valid = true; - }else if (roc_errata_cpt_has_ctx_fetch_issue ()) { +if (roc_errata_cpt_has_ctx_fetch_issue ()) { ctx_ilen_valid = true;/* Inbound SA size is max context size */ ctx_ilen = (PLT_ALIGN (ROC_OT_IPSEC_SA_SZ_MAX ,ROC_ALIGN ) /128 ) -1 ;
drivers/common/cnxk/roc_cpt.h +4 -0
@@ -129,6 +129,10 @@ (PLT_ALIGN_CEIL (ROC_AR_WIN_SIZE_MAX ,BITS_PER_LONG_LONG ) / \BITS_PER_LONG_LONG ) +/* ROC CPTR Cache */ +#define ROC_CPTR_CACHE_LINE_SZ 256 +#define ROC_CPTR_ALIGN ROC_CPTR_CACHE_LINE_SZ +enum {ROC_CPT_REVISION_ID_83XX =0 ,ROC_CPT_REVISION_ID_96XX_B0 =1 ,
drivers/common/cnxk/roc_se.h +19 -18
@@ -314,24 +314,6 @@ struct roc_se_iov_ptr {#define ROC_SE_PDCP_CHAIN_CTX_KEY_IV 1 struct roc_se_ctx { - /* Below fields are accessed by sw */ - uint64_t enc_cipher : 8; - uint64_t hash_type : 8; - uint64_t mac_len : 8; - uint64_t auth_key_len : 16; - uint64_t fc_type : 4; - uint64_t hmac : 1; - uint64_t zsk_flags : 3; - uint64_t k_ecb : 1; - uint64_t pdcp_ci_alg : 2; - uint64_t pdcp_auth_alg : 2; - 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; - uint8_t *auth_key; /* Below fields are accessed by hardware */ struct se_ctx_s { /* Word0 */
@@ -356,6 +338,25 @@ struct roc_se_ctx {struct roc_se_sm_context sm_ctx; }; }se_ctx __plt_aligned (ROC_ALIGN ); + +/* Below fields are accessed by sw */ + uint64_t enc_cipher : 8; + uint64_t hash_type : 8; + uint64_t mac_len : 8; + uint64_t auth_key_len : 16; + uint64_t fc_type : 4; + uint64_t hmac : 1; + uint64_t zsk_flags : 3; + uint64_t k_ecb : 1; + uint64_t pdcp_ci_alg : 2; + uint64_t pdcp_auth_alg : 2; + 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; +uint8_t *auth_key; }__plt_aligned (ROC_ALIGN );struct roc_se_fc_params {
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +4 -4
@@ -1928,7 +1928,7 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,if (sess_type !=RTE_CRYPTO_OP_WITH_SESSION )return -ENOTSUP ; -if (sess ==NULL ) +if (sess ==NULL || sess->roc_se_ctx ==NULL )return -EINVAL ; if ((sess->dp_thr_type == CPT_DP_THREAD_TYPE_PDCP) ||
@@ -1938,11 +1938,11 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,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 ))) + ((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_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/cn20k_cryptodev_ops.c +4 -4
@@ -1675,7 +1675,7 @@ cn20k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,if (sess_type !=RTE_CRYPTO_OP_WITH_SESSION )return -ENOTSUP ; -if (sess ==NULL ) +if (sess ==NULL || sess->roc_se_ctx ==NULL )return -EINVAL ; if ((sess->dp_thr_type == CPT_DP_THREAD_TYPE_PDCP) ||
@@ -1685,11 +1685,11 @@ cn20k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,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 ))) + ((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_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/cn20k_ipsec.c +53 -21
199 lines not on this page · raw message
drivers/crypto/cnxk/cn20k_ipsec.h +10 -5
@@ -18,13 +18,18 @@/* Forward declaration */ struct cn20k_sec_session ; -struct __rte_aligned(ROC_ALIGN) cn20k_ipsec_sa +struct __rte_aligned(ROC_CPTR_ALIGN) cn20k_ipsec_sa {union { -/** Inbound SA */ -struct roc_ow_ipsec_inb_sa in_sa; -/** Outbound SA */ -struct roc_ow_ipsec_outb_sa out_sa; +void *sa_ptr; +struct { +union { +/** Inbound SA */ +struct roc_ow_ipsec_inb_sa *in_sa; +/** Outbound SA */ +struct roc_ow_ipsec_outb_sa *out_sa; + }; + }; }; };
drivers/crypto/cnxk/cn20k_ipsec_la_ops.h +25 -16
67 lines not on this page · raw message
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +44 -17
132 lines not on this page · raw message
drivers/crypto/cnxk/cnxk_se.h +90 -31
337 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 6/10 crypto/cnxk: refactor rsa verification
In reply to Tejasree KondojFrom: Sucharitha Sarananaga <[email protected]>
This patch avoid copying the decrypted message into the signature buffer, which is actually an input to the verify operation. This prevents overwriting the input buffer unnecessarily.
--- drivers/crypto/cnxk/cnxk_ae.h | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/crypto/cnxk/cnxk_ae.h +6 -9
@@ -1592,20 +1592,17 @@ cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,case RTE_CRYPTO_ASYM_OP_VERIFY :if (rsa_ctx->padding.type ==RTE_CRYPTO_RSA_PADDING_NONE ) { rsa->sign.length = rsa_ctx->n.length; -memcpy (rsa->sign.data, rptr, rsa->sign.length); +if (memcmp (rptr, rsa->message.data, rsa->message.length)) + cop->status =RTE_CRYPTO_OP_STATUS_ERROR ; }else {/* Get length of signed output */ - rsa->sign.length = -rte_cpu_to_be_16 (*((uint16_t *)rptr)); + rsa->sign.length =rte_cpu_to_be_16 (*((uint16_t *)rptr));/* * Offset output data pointer by length field -* (2 bytes) and copy signed data. +* (2 bytes) and compare signed data. */ -memcpy (rsa->sign.data, rptr +2 , rsa->sign.length); - } -if (memcmp (rsa->sign.data, rsa->message.data, - rsa->message.length)) { - cop->status =RTE_CRYPTO_OP_STATUS_ERROR ; +if (memcmp (rptr +2 , rsa->message.data, rsa->message.length)) + cop->status =RTE_CRYPTO_OP_STATUS_ERROR ; }break ;default :
Signature · 1 line
2.25.1
PATCH v3 7/10 crypto/cnxk: align PDCP API with latest firmware
In reply to Tejasree KondojAligning PDCP API with latest firmware.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 8 +- drivers/crypto/cnxk/cn20k_cryptodev_ops.c | 8 +- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 4 +- drivers/crypto/cnxk/cnxk_se.h | 171 ++++++++++++++-------- 4 files changed, 121 insertions(+), 70 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +5 -3
@@ -206,7 +206,8 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct w7 = sec_sess->inst.w7; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) { sess = (struct cnxk_se_sess *)(sym_op->session); - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], is_sg_ver2); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], is_sg_ver2, + false);if (unlikely (ret))return 0 ; w7 = sess->cpt_inst_w7;
@@ -217,7 +218,8 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], structreturn 0 ; } - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], is_sg_ver2); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], is_sg_ver2, + false);if (unlikely (ret)) {sym_session_clear (op->sym->session, true);rte_mempool_put (qp->sess_mp, op->sym->session);
@@ -1557,7 +1559,7 @@ cn10k_cpt_raw_fill_inst(struct cnxk_iov *iov, struct cnxk_cpt_qp *qp,break ;case CPT_DP_THREAD_AUTH_ONLY : ret =fill_raw_digest_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], - is_sg_ver2); + is_sg_ver2, false);break ;default : ret = -EINVAL ;
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +5 -3
@@ -207,7 +207,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct w7 = sec_sess->inst.w7; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) { sess = (struct cnxk_se_sess *)(sym_op->session); - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], true); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], true, true);if (unlikely (ret))return 0 ; w7 = sess->cpt_inst_w7;
@@ -218,7 +218,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], structreturn 0 ; } - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], true); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, &inst[0 ], true, true);if (unlikely (ret)) {sym_session_clear (op->sym->session, true);rte_mempool_put (qp->sess_mp, op->sym->session);
@@ -278,6 +278,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], structcnxk_cpt_request_data_sgv2_mode_dump ((void *)inst[0 ].dptr,1 , inst[0 ].w5.s.gather_sz);cnxk_cpt_request_data_sgv2_mode_dump ((void *)inst[0 ].rptr,0 , inst[0 ].w6.s.scatter_sz); +#endif return 1 ;
@@ -1342,7 +1343,8 @@ cn20k_cpt_raw_fill_inst(struct cnxk_iov *iov, struct cnxk_cpt_qp *qp, true);break ;case CPT_DP_THREAD_AUTH_ONLY : - ret =fill_raw_digest_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], true); + ret =fill_raw_digest_params (iov, sess, &qp->meta_info, infl_req, &inst[0 ], true, + true);break ;default : ret = -EINVAL ;
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +2 -2
@@ -117,7 +117,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) { sym_op = op->sym; sess = (struct cnxk_se_sess *)sym_op->session; - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, inst, false); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, inst, false, false); inst->w7.u64 = sess->cpt_inst_w7; }else if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) ret =cn9k_cpt_sec_inst_fill (qp, op, infl_req, inst);
@@ -128,7 +128,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,return -1 ; } - ret =cpt_sym_inst_fill (qp, op, sess, infl_req, inst, false); + ret =cpt_sym_inst_fill (qp, op, sess, infl_req, inst, false, false);if (unlikely (ret)) {sym_session_clear (op->sym->session, true);rte_mempool_put (qp->sess_mp, op->sym->session);
drivers/crypto/cnxk/cnxk_se.h +109 -62
454 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 8/10 crypto/cnxk: support custom metadata with CN20K
In reply to Tejasree KondojAdding support for custom metadata in CN20K PMD.
--- drivers/common/cnxk/hw/cpt.h | 14 +++- drivers/crypto/cnxk/cn20k_cryptodev_ops.c | 4 + drivers/crypto/cnxk/cnxk_se.h | 94 +++++++++++++++-------- 3 files changed, 78 insertions(+), 34 deletions(-)
drivers/common/cnxk/hw/cpt.h +12 -2
@@ -247,7 +247,13 @@ struct cpt_inst_s { uint64_t nixtxl : 3; uint64_t doneint : 1; uint64_t nixtx_addr : 60; - } s; + } cn10k; +struct { +uint64_t nixtxl :3 ; +uint64_t doneint :1 ; +uint64_t rsvd :58 ; +uint64_t pkt_ctl :2 ; + } cn20k;struct {uint64_t nixtxl :3 ;uint64_t doneint :1 ;
@@ -260,7 +266,11 @@ struct cpt_inst_s {uint64_t u64; } w0; -uint64_t res_addr; +struct { +uint64_t res_addr :59 ; +uint64_t meta_sz :4 ; +uint64_t cq_ena :1 ; + }; union cpt_inst_w2 { struct {
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +4 -0
@@ -196,6 +196,10 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct inst[0 ].w2.u64 =0 ; inst[0 ].w3.u64 =0 ; + inst[0 ].meta_sz =0 ; + inst[0 ].cq_ena =0 ; + inst[0 ].res_addr =0 ; + sym_op = op->sym;if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {
drivers/crypto/cnxk/cnxk_se.h +62 -32
191 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 9/10 common/cnxk: optimize ROC layer
In reply to Tejasree KondojAdding ROC layer optimizations.
--- drivers/common/cnxk/roc_cpt.c | 4 ++-- drivers/common/cnxk/roc_cpt_sg.h | 1 + drivers/common/cnxk/roc_se.c | 10 +++++++++- 3 files changed, 12 insertions(+), 3 deletions(-)
drivers/common/cnxk/roc_cpt.c +2 -2
@@ -1173,10 +1173,10 @@ roc_cpt_lmtline_init(struct roc_cpt *roc_cpt, struct roc_cpt_lmtline *lmtline, i lmtline->io_addr = lf->io_addr; lmtline->fc_thresh = lf->nb_desc -CPT_LF_FC_MIN_THRESHOLD ; -if (roc_model_is_cn10k ()) { +if (roc_model_is_cn10k () ||roc_model_is_cn20k ()) {if (is_dual) { lmtline->io_addr |=ROC_CN10K_TWO_CPT_INST_DW_M1 <<4 ; - lmtline->fc_thresh = lf->nb_desc -2 *CPT_LF_FC_MIN_THRESHOLD ; + lmtline->fc_thresh = lf->nb_desc -2 *CPT_LF_FC_MIN_THRESHOLD ; }else { lmtline->io_addr |=ROC_CN10K_CPT_INST_DW_M1 <<4 ; }
drivers/common/cnxk/roc_cpt_sg.h +1 -0
@@ -14,6 +14,7 @@#define ROC_SG_ENTRY_SIZE sizeof(struct roc_sglist_comp)#define ROC_SG_MAX_COMP 25#define ROC_SG_MAX_DLEN_SIZE (ROC_SG_LIST_HDR_SIZE + (ROC_SG_MAX_COMP * ROC_SG_ENTRY_SIZE)) +#define ROC_SG2_MAX_PTRS 48#define ROC_SG1_MAX_PTRS 32
drivers/common/cnxk/roc_se.c +9 -1
@@ -268,10 +268,10 @@ int roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uint8_t *key, uint16_t key_len, uint16_t mac_len) { + uint8_t opcode_minor, opcode_major = 0;struct roc_se_kasumi_ctx *k_ctx;struct roc_se_pdcp_ctx *pctx;struct roc_se_context *fctx; -uint8_t opcode_minor;bool chained_op;if (se_ctx ==NULL )
@@ -310,6 +310,7 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uint se_ctx->fc_type =ROC_SE_PDCP ; se_ctx->pdcp_auth_alg =ROC_SE_PDCP_ALG_TYPE_SNOW3G ; se_ctx->zsk_flags =0x1 ; + opcode_major =ROC_SE_MAJOR_OP_PDCP_CHAIN ;break ;case ROC_SE_ZUC_EIA3 :if (unlikely (key_len !=16 )) {
@@ -339,6 +340,7 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uint se_ctx->fc_type =ROC_SE_PDCP ; se_ctx->pdcp_auth_alg =ROC_SE_PDCP_ALG_TYPE_ZUC ; se_ctx->zsk_flags =0x1 ; + opcode_major =ROC_SE_MAJOR_OP_PDCP_CHAIN ;break ;case ROC_SE_AES_CMAC_EIA2 : key_type =cpt_pdcp_chain_key_type_get (key_len);
@@ -356,6 +358,7 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uint se_ctx->pdcp_auth_alg =ROC_SE_PDCP_ALG_TYPE_AES_CMAC ; se_ctx->eia2 =1 ; se_ctx->zsk_flags =0x1 ; + opcode_major =ROC_SE_MAJOR_OP_PDCP_CHAIN ;break ;case ROC_SE_KASUMI_F9_ECB :/* Kasumi ECB mode */
@@ -363,11 +366,13 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uintmemcpy (k_ctx->ci_key, key, key_len); se_ctx->fc_type =ROC_SE_KASUMI ; se_ctx->zsk_flags =0x1 ; + opcode_major =ROC_SE_MAJOR_OP_KASUMI |ROC_DMA_MODE_SG ;break ;case ROC_SE_KASUMI_F9_CBC :memcpy (k_ctx->ci_key, key, key_len); se_ctx->fc_type =ROC_SE_KASUMI ; se_ctx->zsk_flags =0x1 ; + opcode_major =ROC_SE_MAJOR_OP_KASUMI |ROC_DMA_MODE_SG ;break ;default :return -1 ;
@@ -385,6 +390,7 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type, const uintelse opcode_minor = ((1 <<4 ) |1 ); + se_ctx->template_w4.s.opcode_major = opcode_major; se_ctx->template_w4.s.opcode_minor = opcode_minor;return 0 ; }
@@ -587,6 +593,7 @@ roc_se_ciph_key_set(struct roc_se_ctx *se_ctx, roc_se_cipher_type type, const ui success: se_ctx->enc_cipher = type;if (se_ctx->fc_type ==ROC_SE_PDCP_CHAIN ) { + se_ctx->template_w4.s.opcode_major =ROC_SE_MAJOR_OP_PDCP_CHAIN ; se_ctx->template_w4.s.opcode_minor = se_ctx->ciph_then_auth ?2 :3 ; }else if (se_ctx->fc_type ==ROC_SE_PDCP ) {if (roc_model_is_cn9k ())
@@ -594,6 +601,7 @@ roc_se_ciph_key_set(struct roc_se_ctx *se_ctx, roc_se_cipher_type type, const ui ((1 <<7 ) | (se_ctx->pdcp_ci_alg <<5 ) | (se_ctx->zsk_flags &0x7 )); else opcode_minor = ((1 <<4 )); + se_ctx->template_w4.s.opcode_major =ROC_SE_MAJOR_OP_PDCP_CHAIN ; se_ctx->template_w4.s.opcode_minor = opcode_minor; }return 0 ;
Signature · 1 line
2.25.1
PATCH v3 10/10 crypto/cnxk: fix tls mbuf sanity failures
In reply to Tejasree KondojFrom: Nithinsen Kaithakadan <[email protected]>
Fix mbuf sanity check failure by zeroing data_len of each segment from the target len onward and adjusting pkt_len in the head mbuf. Hence by avoiding call to free mbuf from intermediate node.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 40 ++++++++--------------- drivers/crypto/cnxk/cn20k_cryptodev_ops.c | 39 +++++++--------------- drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 26 +++++++++++++++ 3 files changed, 51 insertions(+), 54 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +13 -27
@@ -931,13 +931,13 @@ cn10k_cpt_ipsec_post_process(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *static inline void cn10k_cpt_tls12_trim_mac (struct rte_crypto_op *cop,struct cpt_cn10k_res_s *res,uint8_t mac_len) { -struct rte_mbuf *mac_prev_seg =NULL , *mac_seg =NULL , *seg;uint32_t pad_len, trim_len, mac_offset, pad_offset;struct rte_mbuf *mbuf = cop->sym->m_src; -uint16_t m_len = res->rlen; -uint32_t i, nb_segs =1 ; +uint16_t m_len = res->rlen, len_to_trim; +struct rte_mbuf *seg;uint8_t pad_res =0 ;uint8_t pad_val; +uint32_t i; pad_val = ((res->spi >>16 ) &0xff ); pad_len = pad_val +1 ;
@@ -966,11 +966,8 @@ cn10k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res, seg = mbuf;while (mac_offset >= seg->data_len) { mac_offset -= seg->data_len; - mac_prev_seg = seg; seg = seg->next; - nb_segs++; } - mac_seg = seg; pad_offset = mac_offset + mac_len;while (pad_offset >= seg->data_len) {
@@ -995,17 +992,9 @@ cn10k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res, cop->aux_flags = res->uc_compcode; } - mbuf->pkt_len = m_len - trim_len; -if (mac_offset) { -rte_pktmbuf_free (mac_seg->next); - mac_seg->next =NULL ; - mac_seg->data_len = mac_offset; - mbuf->nb_segs = nb_segs; - }else { -rte_pktmbuf_free (mac_seg); - mac_prev_seg->next =NULL ; - mbuf->nb_segs = nb_segs -1 ; - } + len_to_trim = mbuf->pkt_len - (m_len - trim_len); + +pktmbuf_trim_chain (mbuf, len_to_trim); }/* TLS-1.3:
@@ -1016,11 +1005,11 @@ cn10k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res,static inline void cn10k_cpt_tls13_trim_mac (struct rte_crypto_op *cop,struct cpt_cn10k_res_s *res) { +uint16_t m_len = res->rlen, len_to_trim;struct rte_mbuf *mbuf = cop->sym->m_src;struct rte_mbuf *seg = mbuf; -uint16_t m_len = res->rlen;uint8_t *ptr, type =0x0 ; -int len, i, nb_segs =1 ; +int len, i;while (m_len && !type) { len = m_len;
@@ -1030,7 +1019,6 @@ cn10k_cpt_tls13_trim_mac(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res)while (len > seg->data_len) { len -= seg->data_len; seg = seg->next; - nb_segs++; }/* walkthrough from last until a non zero value is found */
@@ -1043,16 +1031,14 @@ cn10k_cpt_tls13_trim_mac(struct rte_crypto_op *cop, struct cpt_cn10k_res_s *res) m_len -= len; } + len_to_trim = mbuf->pkt_len - i; +if (type) { +pktmbuf_trim_chain (mbuf, len_to_trim); cop->param1.tls_record.content_type = type; - mbuf->pkt_len = m_len + i; - mbuf->nb_segs = nb_segs; - seg->data_len = i; -rte_pktmbuf_free (seg->next); - seg->next =NULL ; - }else { + + }else cop->status =RTE_CRYPTO_OP_STATUS_ERROR ; - } } static inline void
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +12 -27
@@ -896,13 +896,13 @@ cn20k_cpt_ipsec_post_process(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *static inline void cn20k_cpt_tls12_trim_mac (struct rte_crypto_op *cop,struct cpt_cn20k_res_s *res,uint8_t mac_len) { -struct rte_mbuf *mac_prev_seg =NULL , *mac_seg =NULL , *seg;uint32_t pad_len, trim_len, mac_offset, pad_offset;struct rte_mbuf *mbuf = cop->sym->m_src; -uint16_t m_len = res->rlen; -uint32_t i, nb_segs =1 ; +uint16_t m_len = res->rlen, len_to_trim; +struct rte_mbuf *seg;uint8_t pad_res =0 ;uint8_t pad_val; +uint32_t i; pad_val = ((res->spi >>16 ) &0xff ); pad_len = pad_val +1 ;
@@ -931,11 +931,8 @@ cn20k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *res, seg = mbuf;while (mac_offset >= seg->data_len) { mac_offset -= seg->data_len; - mac_prev_seg = seg; seg = seg->next; - nb_segs++; } - mac_seg = seg; pad_offset = mac_offset + mac_len;while (pad_offset >= seg->data_len) {
@@ -960,17 +957,9 @@ cn20k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *res, cop->aux_flags = res->uc_compcode; } - mbuf->pkt_len = m_len - trim_len; -if (mac_offset) { -rte_pktmbuf_free (mac_seg->next); - mac_seg->next =NULL ; - mac_seg->data_len = mac_offset; - mbuf->nb_segs = nb_segs; - }else { -rte_pktmbuf_free (mac_seg); - mac_prev_seg->next =NULL ; - mbuf->nb_segs = nb_segs -1 ; - } + len_to_trim = mbuf->pkt_len - (m_len - trim_len); + +pktmbuf_trim_chain (mbuf, len_to_trim); }/* TLS-1.3:
@@ -981,11 +970,11 @@ cn20k_cpt_tls12_trim_mac(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *res,static inline void cn20k_cpt_tls13_trim_mac (struct rte_crypto_op *cop,struct cpt_cn20k_res_s *res) { +uint16_t m_len = res->rlen, len_to_trim;struct rte_mbuf *mbuf = cop->sym->m_src;struct rte_mbuf *seg = mbuf; -uint16_t m_len = res->rlen;uint8_t *ptr, type =0x0 ; -int len, i, nb_segs =1 ; +int len, i;while (m_len && !type) { len = m_len;
@@ -995,7 +984,6 @@ cn20k_cpt_tls13_trim_mac(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *res)while (len > seg->data_len) { len -= seg->data_len; seg = seg->next; - nb_segs++; }/* walkthrough from last until a non zero value is found */
@@ -1008,16 +996,13 @@ cn20k_cpt_tls13_trim_mac(struct rte_crypto_op *cop, struct cpt_cn20k_res_s *res) m_len -= len; } + len_to_trim = mbuf->pkt_len - i; +if (type) { +pktmbuf_trim_chain (mbuf, len_to_trim); cop->param1.tls_record.content_type = type; - mbuf->pkt_len = m_len + i; - mbuf->nb_segs = nb_segs; - seg->data_len = i; -rte_pktmbuf_free (seg->next); - seg->next =NULL ; - }else { + }else cop->status =RTE_CRYPTO_OP_STATUS_ERROR ; - } } static inline void
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +26 -0
@@ -239,4 +239,30 @@ cnxk_cpt_sec_inst_w7_get(struct roc_cpt *roc_cpt, void *cptr) return w7.u64; } + +static inline void +pktmbuf_trim_chain (struct rte_mbuf *m,uint16_t len) +{ +uint16_t len_so_far =0 , left_over =0 , new_mlen; +struct rte_mbuf *cur = m; + + new_mlen = m->pkt_len - len; + +while (len_so_far < new_mlen) { + left_over = new_mlen - len_so_far; +if (left_over < cur->data_len) +break ; + len_so_far += cur->data_len; + cur = cur->next; + } + + cur->data_len = left_over; + cur = cur->next; +while (cur) { + cur->data_len =0 ; + cur = cur->next; + } + + m->pkt_len = new_mlen; +}#endif /* _CNXK_CRYPTODEV_OPS_H_ */
Signature · 1 line
2.25.1
Quoted 7 lines
Adding fixes and improvements to cnxk crypto PMD.
v3:
- Removed redundant code
- Added two patches for fixes.
Series applied to dpdk-next-crypto
Thanks