crypto/cnxk: align HW accessible field to ROC align
PATCH 1/2 crypto/cnxk: align HW accessible field to ROC align
Hardware accessible memory need to be aligned to ROC. Enforce the same. Move software specific fields to padding space.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 33 ++++------ drivers/crypto/cnxk/cn10k_ipsec.c | 77 +++++++++++------------ drivers/crypto/cnxk/cn10k_ipsec.h | 25 ++++---- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 40 +++++------- 4 files changed, 80 insertions(+), 95 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +13 -20
@@ -72,7 +72,6 @@ cpt_sec_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, struct cn10k_sec_session *sess, struct cpt_inst_s *inst) { struct rte_crypto_sym_op *sym_op = op->sym; -struct cn10k_ipsec_sa *sa;int ret;if (unlikely (sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {
@@ -85,12 +84,10 @@ cpt_sec_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,return -ENOTSUP ; } - sa = &sess->sa; - -if (sa->is_outbound) - ret =process_outb_sa (&qp->lf, op, sa, inst); +if (sess->is_outbound) + ret =process_outb_sa (&qp->lf, op, sess, inst);else - ret =process_inb_sa (op, sa, inst); + ret =process_inb_sa (op, sess, inst);return ret; }
@@ -122,11 +119,11 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { - sec_sess =SECURITY_GET_SESS_PRIV (sym_op->session); + sec_sess = (struct cn10k_sec_session *)(sym_op->session); ret =cpt_sec_inst_fill (qp, op, sec_sess, &inst[0 ]);if (unlikely (ret))return 0 ; - w7 = sec_sess->sa.inst.w7; + w7 = sec_sess->inst.w7; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) { sess =CRYPTODEV_GET_SYM_SESS_PRIV (sym_op->session); ret = cpt_sym_inst_fill(qp, op, sess, infl_req,
@@ -298,13 +295,10 @@ cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,/* Set meta according to session type */ if (op_type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { -struct cn10k_sec_session *priv; -struct cn10k_ipsec_sa *sa; +struct cn10k_sec_session *sec_sess = (struct cn10k_sec_session *)sess; - priv =SECURITY_GET_SESS_PRIV (sess); - sa = &priv->sa; - sa->qp = qp; - sa->inst.w2 = w2; + sec_sess->qp = qp; + sec_sess->inst.w2 = w2; }else if (sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -335,13 +329,12 @@ cn10k_ca_meta_info_extract(struct rte_crypto_op *op, {if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { -struct cn10k_sec_session *priv; -struct cn10k_ipsec_sa *sa; +struct cn10k_sec_session *sec_sess; + + sec_sess = (struct cn10k_sec_session *)op->sym->session; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; - *qp = sa->qp; - *w2 = sa->inst.w2; + *qp = sec_sess->qp; + *w2 = sec_sess->inst.w2; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
drivers/crypto/cnxk/cn10k_ipsec.c +36 -41
201 lines not on this page · raw message
drivers/crypto/cnxk/cn10k_ipsec.h +14 -11
@@ -6,6 +6,7 @@#define __CN10K_IPSEC_H__#include <rte_security.h> +#include <rte_security_driver.h> #include "roc_api.h"
@@ -14,6 +15,19 @@typedef void *CN10K_SA_CONTEXT_MARKER [0 ];struct cn10k_ipsec_sa { +union { +/** Inbound SA */ +struct roc_ot_ipsec_inb_sa in_sa; +/** Outbound SA */ +struct roc_ot_ipsec_outb_sa out_sa; + }; +}__rte_aligned (ROC_ALIGN ); + +struct cn10k_sec_session { +struct rte_security_session rte_sess; + +/** PMD private space */ +/** Pre-populated CPT inst words */ struct cnxk_cpt_inst_tmpl inst;uint16_t max_extended_len;
@@ -26,17 +40,6 @@ struct cn10k_ipsec_sa {/** * End of SW mutable area */ - CN10K_SA_CONTEXT_MARKER sw_area_end __rte_aligned(ROC_ALIGN); - -union { -/** Inbound SA */ -struct roc_ot_ipsec_inb_sa in_sa; -/** Outbound SA */ -struct roc_ot_ipsec_outb_sa out_sa; - }; -}__rte_aligned (ROC_ALIGN ); - -struct cn10k_sec_session {struct cn10k_ipsec_sa sa; }__rte_aligned (ROC_ALIGN );
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h +17 -23
@@ -13,13 +13,12 @@#include "cnxk_cryptodev.h" static inline void -ipsec_po_sa_iv_set (struct cn10k_ipsec_sa *sess,struct rte_crypto_op *cop) +ipsec_po_sa_iv_set (struct cn10k_sec_session *sess,struct rte_crypto_op *cop) { -uint64_t *iv = &sess->out_sa.iv.u64[0 ]; +uint64_t *iv = &sess->sa.out_sa.iv.u64[0 ];uint64_t *tmp_iv; - memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), -16 ); + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), 16); tmp_iv = (uint64_t *)iv; *tmp_iv =rte_be_to_cpu_64 (*tmp_iv);
@@ -28,28 +27,24 @@ ipsec_po_sa_iv_set(struct cn10k_ipsec_sa *sess, struct rte_crypto_op *cop) }static inline void -ipsec_po_sa_aes_gcm_iv_set (struct cn10k_ipsec_sa *sess, -struct rte_crypto_op *cop) +ipsec_po_sa_aes_gcm_iv_set (struct cn10k_sec_session *sess,struct rte_crypto_op *cop) { -uint8_t *iv = &sess->out_sa.iv.s.iv_dbg1[0 ]; +uint8_t *iv = &sess->sa.out_sa.iv.s.iv_dbg1[0 ];uint32_t *tmp_iv; - memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), -4 ); + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), 4); tmp_iv = (uint32_t *)iv; *tmp_iv =rte_be_to_cpu_32 (*tmp_iv); - iv = &sess->out_sa.iv.s.iv_dbg2[0 ]; -memcpy (iv, - rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset + 4), -4 ); + iv = &sess->sa.out_sa.iv.s.iv_dbg2[0 ]; + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset + 4), 4); tmp_iv = (uint32_t *)iv; *tmp_iv =rte_be_to_cpu_32 (*tmp_iv); } static __rte_always_inline int -process_outb_sa (struct roc_cpt_lf *lf,struct rte_crypto_op *cop, -struct cn10k_ipsec_sa *sess,struct cpt_inst_s *inst) +process_outb_sa (struct roc_cpt_lf *lf,struct rte_crypto_op *cop,struct cn10k_sec_session *sess, +struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;
@@ -64,17 +59,17 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop,RTE_SET_USED (lf);#ifdef LA_IPSEC_DEBUG -if (sess->out_sa.w2.s.iv_src ==ROC_IE_OT_SA_IV_SRC_FROM_SA ) { -if (sess->out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_GCM || - sess->out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_CCM || - sess->out_sa.w2.s.auth_type ==ROC_IE_OT_SA_AUTH_AES_GMAC ) +if (sess->sa.out_sa.w2.s.iv_src ==ROC_IE_OT_SA_IV_SRC_FROM_SA ) { +if (sess->sa.out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_GCM || + sess->sa.out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_CCM || + sess->sa.out_sa.w2.s.auth_type ==ROC_IE_OT_SA_AUTH_AES_GMAC )ipsec_po_sa_aes_gcm_iv_set (sess, cop);else ipsec_po_sa_iv_set (sess, cop); }/* Trigger CTX reload to fetch new data from DRAM */ -roc_cpt_lf_ctx_reload (lf, &sess->out_sa); +roc_cpt_lf_ctx_reload (lf, &sess->sa.out_sa);rte_delay_ms (1 );#endif
@@ -94,15 +89,14 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, } static __rte_always_inline int -process_inb_sa (struct rte_crypto_op *cop,struct cn10k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_inb_sa (struct rte_crypto_op *cop,struct cn10k_sec_session *sess,struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;uint64_t dptr;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 |rte_pktmbuf_pkt_len (m_src); + inst->w4.u64 = sess->inst.w4 |rte_pktmbuf_pkt_len (m_src); dptr =rte_pktmbuf_mtod (m_src, uint64_t); inst->dptr = dptr; inst->rptr = dptr;
Signature · 1 line
2.25.1
PATCH 2/2 crypto/cnxk: fix failure from session rework
Post security session rework, CPTR got changed affecting cn9k IPsec functionality. Address the same. Also, move all s/w accessible fastpath fields to rte_security_session cacheline for better perf.
--- drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 46 ++++++++----------- drivers/crypto/cnxk/cn9k_ipsec.c | 56 ++++++++++++------------ drivers/crypto/cnxk/cn9k_ipsec.h | 44 ++++++++++--------- drivers/crypto/cnxk/cn9k_ipsec_la_ops.h | 30 ++++++------- 4 files changed, 84 insertions(+), 92 deletions(-)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +19 -27
@@ -23,12 +23,10 @@ cn9k_cpt_sec_inst_fill(struct rte_crypto_op *op, struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = op->sym; -struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; +struct cn9k_sec_session *sec_sess;int ret; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; + sec_sess = (struct cn9k_sec_session *)(op->sym->session);if (unlikely (sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {plt_dp_err ("Out of place is not supported" );
@@ -40,12 +38,12 @@ cn9k_cpt_sec_inst_fill(struct rte_crypto_op *op,return -ENOTSUP ; } -if (sa->dir ==RTE_SECURITY_IPSEC_SA_DIR_EGRESS ) - ret =process_outb_sa (op, sa, inst); +if (sec_sess->is_outbound) + ret =process_outb_sa (op, sec_sess, inst);else { infl_req->op_flags |=CPT_OP_FLAGS_IPSEC_DIR_INBOUND ; -process_inb_sa (op, sa, inst); -if (unlikely (sa->replay_win_sz)) +process_inb_sa (op, sec_sess, inst); +if (unlikely (sec_sess->replay_win_sz)) infl_req->op_flags |=CPT_OP_FLAGS_IPSEC_INB_REPLAY ; ret =0 ; }
@@ -335,12 +333,10 @@ cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,if (op_type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) {struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; - priv =SECURITY_GET_SESS_PRIV (sess); - sa = &priv->sa; - sa->qp = qp; - sa->inst.w2 = w2; + priv = (struct cn9k_sec_session *)sess; + priv->qp = qp; + priv->inst.w2 = w2; }else if (sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -372,12 +368,10 @@ cn9k_ca_meta_info_extract(struct rte_crypto_op *op,if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) {struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; - *qp = sa->qp; - inst->w2.u64 = sa->inst.w2; + priv = (struct cn9k_sec_session *)(op->sym->session); + *qp = priv->qp; + inst->w2.u64 = priv->inst.w2; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -480,7 +474,8 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t base, struct rte_crypto_op *op) }static inline int -ipsec_antireplay_check (struct cn9k_ipsec_sa *sa,uint32_t win_sz,struct roc_ie_on_inb_hdr *data) +ipsec_antireplay_check (struct cn9k_sec_session *sess,uint32_t win_sz, +struct roc_ie_on_inb_hdr *data) {uint32_t esn_low, esn_hi, seql, seqh =0 ;struct roc_ie_on_common_sa *common_sa;
@@ -489,7 +484,7 @@ ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, struct roc_ie_uint8_t esn;int ret; - in_sa = &sa->in_sa; + in_sa = &sess->sa.in_sa; common_sa = &in_sa->common_sa; esn = common_sa->ctl.esn_en;
@@ -505,7 +500,7 @@ ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, struct roc_ie_if (unlikely (seq ==0 ))return IPSEC_ANTI_REPLAY_FAILED ; - ret =cnxk_on_anti_replay_check (seq, &sa->ar, win_sz); + 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); esn_hi =rte_be_to_cpu_32 (common_sa->seq_t.th);
@@ -526,7 +521,6 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop,struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m = sym_op->m_src;struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa;struct rte_ipv6_hdr *ip6;struct rte_ipv4_hdr *ip;uint16_t m_len =0 ;
@@ -539,12 +533,10 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop, CPT_OP_FLAGS_IPSEC_INB_REPLAY)) {int ret; - priv =SECURITY_GET_SESS_PRIV (sym_op->session); - sa = &priv->sa; + priv = (struct cn9k_sec_session *)(sym_op->session); - ret =ipsec_antireplay_check ( - sa, sa->replay_win_sz, - (struct roc_ie_on_inb_hdr *)data); + ret =ipsec_antireplay_check (priv, priv->replay_win_sz, + (struct roc_ie_on_inb_hdr *)data);if (unlikely (ret)) { cop->status =RTE_CRYPTO_OP_STATUS_ERROR ;return ;
drivers/crypto/cnxk/cn9k_ipsec.c +27 -29
118 lines not on this page · raw message
drivers/crypto/cnxk/cn9k_ipsec.h +24 -20
70 lines not on this page · raw message
drivers/crypto/cnxk/cn9k_ipsec_la_ops.h +14 -16
@@ -13,21 +13,20 @@#include "cnxk_security_ar.h" static __rte_always_inline int32_t -ipsec_po_out_rlen_get (struct cn9k_ipsec_sa *sa,uint32_t plen) +ipsec_po_out_rlen_get (struct cn9k_sec_session *sess,uint32_t plen) {uint32_t enc_payload_len; - enc_payload_len =RTE_ALIGN_CEIL (plen + sa->rlens.roundup_len, - sa->rlens.roundup_byte); + enc_payload_len =RTE_ALIGN_CEIL (plen + sess->rlens.roundup_len, + sess->rlens.roundup_byte); -return sa->custom_hdr_len + sa->rlens.partial_len + enc_payload_len; +return sess->custom_hdr_len + sess->rlens.partial_len + enc_payload_len; } static __rte_always_inline int -process_outb_sa (struct rte_crypto_op *cop,struct cn9k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_outb_sa (struct rte_crypto_op *cop,struct cn9k_sec_session *sess,struct cpt_inst_s *inst) { -const unsigned int hdr_len = sa->custom_hdr_len; +const unsigned int hdr_len = sess->custom_hdr_len;struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;uint32_t dlen, rlen, pkt_len, seq_lo;
@@ -38,7 +37,7 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, pkt_len =rte_pktmbuf_pkt_len (m_src); dlen = pkt_len + hdr_len; - rlen =ipsec_po_out_rlen_get (sa, pkt_len); + rlen =ipsec_po_out_rlen_get (sess, pkt_len); extend_tail = rlen - dlen;if (unlikely (extend_tail >rte_pktmbuf_tailroom (m_src))) {
@@ -61,7 +60,7 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, hdr =PLT_PTR_ADD (m_src->buf_addr, data_off - hdr_len);#ifdef LA_IPSEC_DEBUG -if (sa->inst.w4 &ROC_IE_ON_PER_PKT_IV ) { +if (sess->inst.w4 &ROC_IE_ON_PER_PKT_IV ) { memcpy(&hdr->iv[0], rte_crypto_op_ctod_offset(cop, uint8_t *, sa->cipher_iv_off),
@@ -69,7 +68,7 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, }#endif - esn = ++sa->esn; + esn = ++sess->esn;/* Set ESN seq hi */ hdr->esn =rte_cpu_to_be_32 (esn >>32 );
@@ -82,24 +81,23 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, hdr->ip_id = seq_lo;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 | dlen; + inst->w4.u64 = sess->inst.w4 | dlen; inst->dptr =PLT_U64_CAST (hdr); inst->rptr =PLT_U64_CAST (hdr); - inst->w7.u64 = sa->inst.w7; + inst->w7.u64 = sess->inst.w7;return 0 ; } static __rte_always_inline void -process_inb_sa (struct rte_crypto_op *cop,struct cn9k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_inb_sa (struct rte_crypto_op *cop,struct cn9k_sec_session *sess,struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 |rte_pktmbuf_pkt_len (m_src); + inst->w4.u64 = sess->inst.w4 |rte_pktmbuf_pkt_len (m_src); inst->dptr = inst->rptr =rte_pktmbuf_mtod (m_src, uint64_t); - inst->w7.u64 = sa->inst.w7; + inst->w7.u64 = sess->inst.w7; }#endif /* __CN9K_IPSEC_LA_OPS_H__ */
Signature · 1 line
2.25.1
PATCH v2 1/2 crypto/cnxk: align HW accessible field to ROC align
In reply to Anoob JosephHardware accessible memory need to be aligned to ROC. Enforce the same. Move software specific fields to padding space.
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 33 ++++------ drivers/crypto/cnxk/cn10k_ipsec.c | 77 +++++++++++------------ drivers/crypto/cnxk/cn10k_ipsec.h | 25 ++++---- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 40 +++++------- 4 files changed, 80 insertions(+), 95 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +13 -20
@@ -72,7 +72,6 @@ cpt_sec_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op, struct cn10k_sec_session *sess, struct cpt_inst_s *inst) { struct rte_crypto_sym_op *sym_op = op->sym; -struct cn10k_ipsec_sa *sa;int ret;if (unlikely (sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {
@@ -85,12 +84,10 @@ cpt_sec_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,return -ENOTSUP ; } - sa = &sess->sa; - -if (sa->is_outbound) - ret =process_outb_sa (&qp->lf, op, sa, inst); +if (sess->is_outbound) + ret =process_outb_sa (&qp->lf, op, sess, inst);else - ret =process_inb_sa (op, sa, inst); + ret =process_inb_sa (op, sess, inst);return ret; }
@@ -122,11 +119,11 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { - sec_sess =SECURITY_GET_SESS_PRIV (sym_op->session); + sec_sess = (struct cn10k_sec_session *)(sym_op->session); ret =cpt_sec_inst_fill (qp, op, sec_sess, &inst[0 ]);if (unlikely (ret))return 0 ; - w7 = sec_sess->sa.inst.w7; + w7 = sec_sess->inst.w7; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) { sess =CRYPTODEV_GET_SYM_SESS_PRIV (sym_op->session); ret = cpt_sym_inst_fill(qp, op, sess, infl_req,
@@ -298,13 +295,10 @@ cn10k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,/* Set meta according to session type */ if (op_type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { -struct cn10k_sec_session *priv; -struct cn10k_ipsec_sa *sa; +struct cn10k_sec_session *sec_sess = (struct cn10k_sec_session *)sess; - priv =SECURITY_GET_SESS_PRIV (sess); - sa = &priv->sa; - sa->qp = qp; - sa->inst.w2 = w2; + sec_sess->qp = qp; + sec_sess->inst.w2 = w2; }else if (sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -335,13 +329,12 @@ cn10k_ca_meta_info_extract(struct rte_crypto_op *op, {if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { -struct cn10k_sec_session *priv; -struct cn10k_ipsec_sa *sa; +struct cn10k_sec_session *sec_sess; + + sec_sess = (struct cn10k_sec_session *)op->sym->session; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; - *qp = sa->qp; - *w2 = sa->inst.w2; + *qp = sec_sess->qp; + *w2 = sec_sess->inst.w2; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
drivers/crypto/cnxk/cn10k_ipsec.c +36 -41
201 lines not on this page · raw message
drivers/crypto/cnxk/cn10k_ipsec.h +14 -11
@@ -6,6 +6,7 @@#define __CN10K_IPSEC_H__#include <rte_security.h> +#include <rte_security_driver.h> #include "roc_api.h"
@@ -14,6 +15,19 @@typedef void *CN10K_SA_CONTEXT_MARKER [0 ];struct cn10k_ipsec_sa { +union { +/** Inbound SA */ +struct roc_ot_ipsec_inb_sa in_sa; +/** Outbound SA */ +struct roc_ot_ipsec_outb_sa out_sa; + }; +}__rte_aligned (ROC_ALIGN ); + +struct cn10k_sec_session { +struct rte_security_session rte_sess; + +/** PMD private space */ +/** Pre-populated CPT inst words */ struct cnxk_cpt_inst_tmpl inst;uint16_t max_extended_len;
@@ -26,17 +40,6 @@ struct cn10k_ipsec_sa {/** * End of SW mutable area */ - CN10K_SA_CONTEXT_MARKER sw_area_end __rte_aligned(ROC_ALIGN); - -union { -/** Inbound SA */ -struct roc_ot_ipsec_inb_sa in_sa; -/** Outbound SA */ -struct roc_ot_ipsec_outb_sa out_sa; - }; -}__rte_aligned (ROC_ALIGN ); - -struct cn10k_sec_session {struct cn10k_ipsec_sa sa; }__rte_aligned (ROC_ALIGN );
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h +17 -23
@@ -13,13 +13,12 @@#include "cnxk_cryptodev.h" static inline void -ipsec_po_sa_iv_set (struct cn10k_ipsec_sa *sess,struct rte_crypto_op *cop) +ipsec_po_sa_iv_set (struct cn10k_sec_session *sess,struct rte_crypto_op *cop) { -uint64_t *iv = &sess->out_sa.iv.u64[0 ]; +uint64_t *iv = &sess->sa.out_sa.iv.u64[0 ];uint64_t *tmp_iv; - memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), -16 ); + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), 16); tmp_iv = (uint64_t *)iv; *tmp_iv =rte_be_to_cpu_64 (*tmp_iv);
@@ -28,28 +27,24 @@ ipsec_po_sa_iv_set(struct cn10k_ipsec_sa *sess, struct rte_crypto_op *cop) }static inline void -ipsec_po_sa_aes_gcm_iv_set (struct cn10k_ipsec_sa *sess, -struct rte_crypto_op *cop) +ipsec_po_sa_aes_gcm_iv_set (struct cn10k_sec_session *sess,struct rte_crypto_op *cop) { -uint8_t *iv = &sess->out_sa.iv.s.iv_dbg1[0 ]; +uint8_t *iv = &sess->sa.out_sa.iv.s.iv_dbg1[0 ];uint32_t *tmp_iv; - memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), -4 ); + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset), 4); tmp_iv = (uint32_t *)iv; *tmp_iv =rte_be_to_cpu_32 (*tmp_iv); - iv = &sess->out_sa.iv.s.iv_dbg2[0 ]; -memcpy (iv, - rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset + 4), -4 ); + iv = &sess->sa.out_sa.iv.s.iv_dbg2[0 ]; + memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset + 4), 4); tmp_iv = (uint32_t *)iv; *tmp_iv =rte_be_to_cpu_32 (*tmp_iv); } static __rte_always_inline int -process_outb_sa (struct roc_cpt_lf *lf,struct rte_crypto_op *cop, -struct cn10k_ipsec_sa *sess,struct cpt_inst_s *inst) +process_outb_sa (struct roc_cpt_lf *lf,struct rte_crypto_op *cop,struct cn10k_sec_session *sess, +struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;
@@ -64,17 +59,17 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop,RTE_SET_USED (lf);#ifdef LA_IPSEC_DEBUG -if (sess->out_sa.w2.s.iv_src ==ROC_IE_OT_SA_IV_SRC_FROM_SA ) { -if (sess->out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_GCM || - sess->out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_CCM || - sess->out_sa.w2.s.auth_type ==ROC_IE_OT_SA_AUTH_AES_GMAC ) +if (sess->sa.out_sa.w2.s.iv_src ==ROC_IE_OT_SA_IV_SRC_FROM_SA ) { +if (sess->sa.out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_GCM || + sess->sa.out_sa.w2.s.enc_type ==ROC_IE_OT_SA_ENC_AES_CCM || + sess->sa.out_sa.w2.s.auth_type ==ROC_IE_OT_SA_AUTH_AES_GMAC )ipsec_po_sa_aes_gcm_iv_set (sess, cop);else ipsec_po_sa_iv_set (sess, cop); }/* Trigger CTX reload to fetch new data from DRAM */ -roc_cpt_lf_ctx_reload (lf, &sess->out_sa); +roc_cpt_lf_ctx_reload (lf, &sess->sa.out_sa);rte_delay_ms (1 );#endif
@@ -94,15 +89,14 @@ process_outb_sa(struct roc_cpt_lf *lf, struct rte_crypto_op *cop, } static __rte_always_inline int -process_inb_sa (struct rte_crypto_op *cop,struct cn10k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_inb_sa (struct rte_crypto_op *cop,struct cn10k_sec_session *sess,struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;uint64_t dptr;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 |rte_pktmbuf_pkt_len (m_src); + inst->w4.u64 = sess->inst.w4 |rte_pktmbuf_pkt_len (m_src); dptr =rte_pktmbuf_mtod (m_src, uint64_t); inst->dptr = dptr; inst->rptr = dptr;
Signature · 1 line
2.25.1
PATCH v2 2/2 crypto/cnxk: fix failure from session rework
Post security session rework, CPTR got changed affecting cn9k IPsec functionality. Address the same. Also, move all s/w accessible fast path fields to rte_security_session cacheline for better perf.
---
v2:
* Fixed debug build failure
drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 46 +++++++--------- drivers/crypto/cnxk/cn9k_ipsec.c | 70 ++++++++++++------------ drivers/crypto/cnxk/cn9k_ipsec.h | 44 ++++++++------- drivers/crypto/cnxk/cn9k_ipsec_la_ops.h | 35 ++++++------ 4 files changed, 93 insertions(+), 102 deletions(-)
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +19 -27
@@ -23,12 +23,10 @@ cn9k_cpt_sec_inst_fill(struct rte_crypto_op *op, struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = op->sym; -struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; +struct cn9k_sec_session *sec_sess;int ret; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; + sec_sess = (struct cn9k_sec_session *)(op->sym->session);if (unlikely (sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {plt_dp_err ("Out of place is not supported" );
@@ -40,12 +38,12 @@ cn9k_cpt_sec_inst_fill(struct rte_crypto_op *op,return -ENOTSUP ; } -if (sa->dir ==RTE_SECURITY_IPSEC_SA_DIR_EGRESS ) - ret =process_outb_sa (op, sa, inst); +if (sec_sess->is_outbound) + ret =process_outb_sa (op, sec_sess, inst);else { infl_req->op_flags |=CPT_OP_FLAGS_IPSEC_DIR_INBOUND ; -process_inb_sa (op, sa, inst); -if (unlikely (sa->replay_win_sz)) +process_inb_sa (op, sec_sess, inst); +if (unlikely (sec_sess->replay_win_sz)) infl_req->op_flags |=CPT_OP_FLAGS_IPSEC_INB_REPLAY ; ret =0 ; }
@@ -335,12 +333,10 @@ cn9k_cpt_crypto_adapter_ev_mdata_set(struct rte_cryptodev *dev __rte_unused,if (op_type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) {struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; - priv =SECURITY_GET_SESS_PRIV (sess); - sa = &priv->sa; - sa->qp = qp; - sa->inst.w2 = w2; + priv = (struct cn9k_sec_session *)sess; + priv->qp = qp; + priv->inst.w2 = w2; }else if (sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -372,12 +368,10 @@ cn9k_ca_meta_info_extract(struct rte_crypto_op *op,if (op->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) {struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa; - priv =SECURITY_GET_SESS_PRIV (op->sym->session); - sa = &priv->sa; - *qp = sa->qp; - inst->w2.u64 = sa->inst.w2; + priv = (struct cn9k_sec_session *)(op->sym->session); + *qp = priv->qp; + inst->w2.u64 = priv->inst.w2; }else if (op->sess_type ==RTE_CRYPTO_OP_WITH_SESSION ) {struct cnxk_se_sess *priv;
@@ -480,7 +474,8 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t base, struct rte_crypto_op *op) }static inline int -ipsec_antireplay_check (struct cn9k_ipsec_sa *sa,uint32_t win_sz,struct roc_ie_on_inb_hdr *data) +ipsec_antireplay_check (struct cn9k_sec_session *sess,uint32_t win_sz, +struct roc_ie_on_inb_hdr *data) {uint32_t esn_low, esn_hi, seql, seqh =0 ;struct roc_ie_on_common_sa *common_sa;
@@ -489,7 +484,7 @@ ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, struct roc_ie_uint8_t esn;int ret; - in_sa = &sa->in_sa; + in_sa = &sess->sa.in_sa; common_sa = &in_sa->common_sa; esn = common_sa->ctl.esn_en;
@@ -505,7 +500,7 @@ ipsec_antireplay_check(struct cn9k_ipsec_sa *sa, uint32_t win_sz, struct roc_ie_if (unlikely (seq ==0 ))return IPSEC_ANTI_REPLAY_FAILED ; - ret =cnxk_on_anti_replay_check (seq, &sa->ar, win_sz); + 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); esn_hi =rte_be_to_cpu_32 (common_sa->seq_t.th);
@@ -526,7 +521,6 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop,struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m = sym_op->m_src;struct cn9k_sec_session *priv; -struct cn9k_ipsec_sa *sa;struct rte_ipv6_hdr *ip6;struct rte_ipv4_hdr *ip;uint16_t m_len =0 ;
@@ -539,12 +533,10 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop, CPT_OP_FLAGS_IPSEC_INB_REPLAY)) {int ret; - priv =SECURITY_GET_SESS_PRIV (sym_op->session); - sa = &priv->sa; + priv = (struct cn9k_sec_session *)(sym_op->session); - ret =ipsec_antireplay_check ( - sa, sa->replay_win_sz, - (struct roc_ie_on_inb_hdr *)data); + ret =ipsec_antireplay_check (priv, priv->replay_win_sz, + (struct roc_ie_on_inb_hdr *)data);if (unlikely (ret)) { cop->status =RTE_CRYPTO_OP_STATUS_ERROR ;return ;
drivers/crypto/cnxk/cn9k_ipsec.c +34 -36
141 lines not on this page · raw message
drivers/crypto/cnxk/cn9k_ipsec.h +24 -20
70 lines not on this page · raw message
drivers/crypto/cnxk/cn9k_ipsec_la_ops.h +16 -19
@@ -13,21 +13,20 @@#include "cnxk_security_ar.h" static __rte_always_inline int32_t -ipsec_po_out_rlen_get (struct cn9k_ipsec_sa *sa,uint32_t plen) +ipsec_po_out_rlen_get (struct cn9k_sec_session *sess,uint32_t plen) {uint32_t enc_payload_len; - enc_payload_len =RTE_ALIGN_CEIL (plen + sa->rlens.roundup_len, - sa->rlens.roundup_byte); + enc_payload_len =RTE_ALIGN_CEIL (plen + sess->rlens.roundup_len, + sess->rlens.roundup_byte); -return sa->custom_hdr_len + sa->rlens.partial_len + enc_payload_len; +return sess->custom_hdr_len + sess->rlens.partial_len + enc_payload_len; } static __rte_always_inline int -process_outb_sa (struct rte_crypto_op *cop,struct cn9k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_outb_sa (struct rte_crypto_op *cop,struct cn9k_sec_session *sess,struct cpt_inst_s *inst) { -const unsigned int hdr_len = sa->custom_hdr_len; +const unsigned int hdr_len = sess->custom_hdr_len;struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;uint32_t dlen, rlen, pkt_len, seq_lo;
@@ -38,7 +37,7 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, pkt_len =rte_pktmbuf_pkt_len (m_src); dlen = pkt_len + hdr_len; - rlen =ipsec_po_out_rlen_get (sa, pkt_len); + rlen =ipsec_po_out_rlen_get (sess, pkt_len); extend_tail = rlen - dlen;if (unlikely (extend_tail >rte_pktmbuf_tailroom (m_src))) {
@@ -61,15 +60,14 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, hdr =PLT_PTR_ADD (m_src->buf_addr, data_off - hdr_len);#ifdef LA_IPSEC_DEBUG -if (sa->inst.w4 &ROC_IE_ON_PER_PKT_IV ) { +if (sess->inst.w4 &ROC_IE_ON_PER_PKT_IV ) {memcpy (&hdr->iv[0 ], - rte_crypto_op_ctod_offset(cop, uint8_t *, - sa->cipher_iv_off), - sa->cipher_iv_len); + rte_crypto_op_ctod_offset(cop, uint8_t *, sess->cipher_iv_off), + sess->cipher_iv_len); }#endif - esn = ++sa->esn; + esn = ++sess->esn;/* Set ESN seq hi */ hdr->esn =rte_cpu_to_be_32 (esn >>32 );
@@ -82,24 +80,23 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa, hdr->ip_id = seq_lo;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 | dlen; + inst->w4.u64 = sess->inst.w4 | dlen; inst->dptr =PLT_U64_CAST (hdr); inst->rptr =PLT_U64_CAST (hdr); - inst->w7.u64 = sa->inst.w7; + inst->w7.u64 = sess->inst.w7;return 0 ; } static __rte_always_inline void -process_inb_sa (struct rte_crypto_op *cop,struct cn9k_ipsec_sa *sa, -struct cpt_inst_s *inst) +process_inb_sa (struct rte_crypto_op *cop,struct cn9k_sec_session *sess,struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src;/* Prepare CPT instruction */ - inst->w4.u64 = sa->inst.w4 |rte_pktmbuf_pkt_len (m_src); + inst->w4.u64 = sess->inst.w4 |rte_pktmbuf_pkt_len (m_src); inst->dptr = inst->rptr =rte_pktmbuf_mtod (m_src, uint64_t); - inst->w7.u64 = sa->inst.w7; + inst->w7.u64 = sess->inst.w7; }#endif /* __CN9K_IPSEC_LA_OPS_H__ */
--
2.25.1
RE: [PATCH v2 2/2] crypto/cnxk: fix failure from session rework
Quoted 11 lines
Subject: [PATCH v2 2/2]
crypto/cnxk: fix failure from session reworkPost security session rework, CPTR got changed affecting cn9k IPsec functionality. Address the same. Also, move all s/w accessible fast path fields to
rte_security_sessioncacheline for better perf.Fixes 3f3fc3308bd0 ("security: remove private mempool usage")Signed-off-by Anoob Joseph <[email protected]>---
Series Acked-by: Akhil Goyal <[email protected]>
Applied to dpdk-next-crypto
Thanks.