add lookaside IPsec additional features
Subsystems (2)
v2 cover add lookaside IPsec additional features
This series adds cn10k lookaside IPsec AES-CBC-HMAC-SHA1, UDP encapsulation and transport mode support along with common cnxk pmd changes. The functionality has been tested with ipsec-secgw application running in lookaside protocol offload mode.
v2:
* Fixed release notes
Archana Muniganti (2):
crypto/cnxk: make IPsec verify functions common
common/cnxk: make IPsec defines common
Tejasree Kondoj (6):
common/cnxk: add hash generation APIs crypto/cnxk: add lookaside IPsec AES-CBC-HMAC-SHA1 support crypto/cnxk: remove redundant code
crypto/cnxk: use rlen from CPT result with lookaside crypto/cnxk: support cn10k transport mode crypto/cnxk: support UDP encap with lookaside IPsec
doc/guides/cryptodevs/cnxk.rst | 3 + doc/guides/rel_notes/release_21_11.rst | 6 + drivers/common/cnxk/cnxk_security.c | 92 +++++- drivers/common/cnxk/meson.build | 1 + drivers/common/cnxk/roc_api.h | 4 + drivers/common/cnxk/roc_hash.c | 275 ++++++++++++++++++ drivers/common/cnxk/roc_hash.h | 16 + drivers/common/cnxk/roc_ie.h | 33 ++- drivers/common/cnxk/roc_ie_on.h | 26 -- drivers/common/cnxk/roc_ie_ot.h | 26 -- drivers/common/cnxk/version.map | 3 + drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 44 +-- drivers/crypto/cnxk/cn10k_ipsec.c | 64 +--- drivers/crypto/cnxk/cn10k_ipsec.h | 6 +- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 28 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 2 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 79 ++++- drivers/crypto/cnxk/cnxk_ipsec.h | 114 ++++++++ 18 files changed, 620 insertions(+), 202 deletions(-) create mode 100644 drivers/common/cnxk/roc_hash.c create mode 100644 drivers/common/cnxk/roc_hash.h
Signature · 1 line
2.27.0
PATCH v2 1/8 common/cnxk: add hash generation APIs
Adding functions for hash generation that can be used in hmac opad/ipad calculation.
--- drivers/common/cnxk/meson.build | 1 + drivers/common/cnxk/roc_api.h | 3 + drivers/common/cnxk/roc_hash.c | 275 ++++++++++++++++++++++++++++++++ drivers/common/cnxk/roc_hash.h | 16 ++ drivers/common/cnxk/version.map | 3 + 5 files changed, 298 insertions(+) create mode 100644 drivers/common/cnxk/roc_hash.c create mode 100644 drivers/common/cnxk/roc_hash.h
drivers/common/cnxk/meson.build +1 -0
@@ -19,6 +19,7 @@ sources = files( 'roc_cpt.c', 'roc_cpt_debug.c', 'roc_dev.c', + 'roc_hash.c', 'roc_idev.c', 'roc_irq.c', 'roc_mbox.c',
drivers/common/cnxk/roc_api.h +3 -0
@@ -125,4 +125,7 @@#include "roc_ie_ot.h" #include "roc_se.h" +/* HASH computation */ +#include "roc_hash.h" +#endif /* _ROC_API_H_ */
drivers/common/cnxk/roc_hash.c new file +275 -0
275 lines not on this page · raw message
drivers/common/cnxk/roc_hash.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 2021 Marvell. +*/ + +#ifndef _ROC_HASH_H_ +#define _ROC_HASH_H_ + +/* +* Compute a partial hash with the assumption that msg is the first block. +* Based on implementation from RFC 3174 +*/ +void __roc_api roc_hash_sha1_gen(uint8_t *msg, uint32_t *hash); +void __roc_api roc_hash_sha256_gen(uint8_t *msg, uint32_t *hash); +void __roc_api roc_hash_sha512_gen(uint8_t *msg, uint64_t *hash, int hash_size); + +#endif /* _ROC_HASH_H_ */
drivers/common/cnxk/version.map +3 -0
@@ -64,6 +64,9 @@ INTERNAL { roc_cpt_lmtline_init; roc_cpt_rxc_time_cfg; roc_error_msg_get; + roc_hash_sha1_gen; + roc_hash_sha256_gen; + roc_hash_sha512_gen; roc_idev_cpt_get; roc_idev_cpt_set; roc_idev_lmt_base_addr_get;
Signature · 1 line
2.27.0
PATCH v2 2/8 crypto/cnxk: add lookaside IPsec AES-CBC-HMAC-SHA1 support
In reply to Tejasree KondojAdding lookaside IPsec AES-CBC-HMAC-SHA1 support to cnxk driver.
--- doc/guides/cryptodevs/cnxk.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 4 ++ drivers/common/cnxk/cnxk_security.c | 68 ++++++++++++++++++- drivers/crypto/cnxk/cn10k_ipsec.c | 63 ++++++++++++++++- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 44 ++++++++++++ 5 files changed, 176 insertions(+), 4 deletions(-)
doc/guides/cryptodevs/cnxk.rst +1 -0
@@ -231,6 +231,7 @@ Features supported * ESP * Tunnel mode * AES-128/192/256-GCM +* AES-128/192/256-CBC-SHA1-HMAC Limitations -----------
doc/guides/rel_notes/release_21_11.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Marvell cn10k_crypto PMD.** + + * Added aes-cbc sha1-hmac in lookaside protocol (IPsec). + Removed Items -------------
drivers/common/cnxk/cnxk_security.c +65 -3
107 lines not on this page · raw message
drivers/crypto/cnxk/cn10k_ipsec.c +62 -1
81 lines not on this page · raw message
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +44 -0
56 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 3/8 crypto/cnxk: remove redundant code
In reply to Tejasree KondojRemoving redundant code in cn10k lookaside IPsec.
--- drivers/crypto/cnxk/cn10k_ipsec.c | 5 ----- drivers/crypto/cnxk/cn10k_ipsec.h | 2 -- drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 2 -- 3 files changed, 9 deletions(-)
drivers/crypto/cnxk/cn10k_ipsec.c +0 -5
@@ -270,9 +270,6 @@ cn10k_sec_session_create(void *device, struct rte_security_session_conf *conf,if (conf->action_type !=RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL )return -EINVAL ; -if (rte_security_dynfield_register () <0 ) -return -ENOTSUP ; -if (rte_mempool_get (mempool, (void **)&priv)) {plt_err ("Could not allocate security session private data" );return -ENOMEM ;
@@ -280,8 +277,6 @@ cn10k_sec_session_create(void *device, struct rte_security_session_conf *conf,set_sec_session_private_data (sess, priv); - priv->userdata = conf->userdata; -if (conf->protocol !=RTE_SECURITY_PROTOCOL_IPSEC ) { ret = -ENOTSUP ; goto mempool_put;
drivers/crypto/cnxk/cn10k_ipsec.h +0 -2
@@ -27,8 +27,6 @@ struct cn10k_ipsec_sa {struct cn10k_sec_session {struct cn10k_ipsec_sa sa; -void *userdata; -/**< Userdata registered by the application */ } __rte_cache_aligned;void cn10k_sec_ops_override (void );
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +0 -2
@@ -810,7 +810,6 @@ static const struct rte_security_capability sec_caps_templ[] = { .options = { 0 } }, .crypto_capabilities = NULL, - .ol_flags = RTE_SECURITY_TX_OLOAD_NEED_MDATA }, {/* IPsec Lookaside Protocol ESP Tunnel Egress */ .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
@@ -822,7 +821,6 @@ static const struct rte_security_capability sec_caps_templ[] = { .options = { 0 } }, .crypto_capabilities = NULL, - .ol_flags =RTE_SECURITY_TX_OLOAD_NEED_MDATA }, { .action = RTE_SECURITY_ACTION_TYPE_NONE
Signature · 1 line
2.27.0
PATCH v2 4/8 crypto/cnxk: use rlen from CPT result with lookaside
In reply to Tejasree KondojUse rlen from CPT result with lookaside operations
--- drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 40 ++++++----------------- drivers/crypto/cnxk/cn10k_ipsec.c | 4 +-- drivers/crypto/cnxk/cn10k_ipsec.h | 4 +-- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 28 ++-------------- 4 files changed, 15 insertions(+), 61 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +10 -30
@@ -48,7 +48,7 @@ cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op) static __rte_always_inline int __rte_hotcpt_sec_inst_fill (struct rte_crypto_op *op,struct cn10k_sec_session *sess, -struct cpt_inflight_req *infl_req,struct cpt_inst_s *inst) +struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = op->sym;union roc_ot_ipsec_sa_word2 *w2;
@@ -70,10 +70,8 @@ cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess,if (w2->s.dir ==ROC_IE_OT_SA_DIR_OUTBOUND ) ret =process_outb_sa (op, sa, inst); -else { - infl_req->op_flags |=CPT_OP_FLAGS_IPSEC_DIR_INBOUND ; +else ret =process_inb_sa (op, sa, inst); - }return ret; }
@@ -122,8 +120,7 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],if (op->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { sec_sess =get_sec_session_private_data ( sym_op->sec_session); - ret =cpt_sec_inst_fill (op, sec_sess, infl_req, - &inst[0 ]); + ret =cpt_sec_inst_fill (op, sec_sess, &inst[0 ]);if (unlikely (ret))return 0 ; w7 = sec_sess->sa.inst.w7;
@@ -334,30 +331,13 @@ cn10k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)static inline void cn10k_cpt_sec_post_process (struct rte_crypto_op *cop, -struct cpt_inflight_req *infl_req) +struct cpt_cn10k_res_s *res) { -struct rte_crypto_sym_op *sym_op = cop->sym; -struct rte_mbuf *m = sym_op->m_src; -struct rte_ipv6_hdr *ip6; -struct rte_ipv4_hdr *ip; -uint16_t m_len; - -if (infl_req->op_flags &CPT_OP_FLAGS_IPSEC_DIR_INBOUND ) { - ip = (struct rte_ipv4_hdr *)rte_pktmbuf_mtod(m, char *); - -if (((ip->version_ihl &0xf0 ) >>RTE_IPV4_IHL_MULTIPLIER ) == -IPVERSION ) { - m_len =rte_be_to_cpu_16 (ip->total_length); - }else { -PLT_ASSERT (((ip->version_ihl &0xf0 ) >> -RTE_IPV4_IHL_MULTIPLIER ) ==6 ); - ip6 = (struct rte_ipv6_hdr *)ip; - m_len =rte_be_to_cpu_16 (ip6->payload_len) + -sizeof (struct rte_ipv6_hdr ); - } - m->data_len = m_len; - m->pkt_len = m_len; - } +struct rte_mbuf *m = cop->sym->m_src; +const uint16_t m_len = res->rlen; + + m->data_len = m_len; + m->pkt_len = m_len; } static inline void
@@ -385,7 +365,7 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, cop->status =RTE_CRYPTO_OP_STATUS_SUCCESS ;if (cop->type ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) {if (cop->sess_type ==RTE_CRYPTO_OP_SECURITY_SESSION ) { -cn10k_cpt_sec_post_process (cop, infl_req); +cn10k_cpt_sec_post_process (cop, res);return ; }
drivers/crypto/cnxk/cn10k_ipsec.c +1 -3
@@ -176,9 +176,7 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt,if (ret)return ret; - sa->partial_len = rlens.partial_len; - sa->roundup_byte = rlens.roundup_byte; - sa->roundup_len = rlens.roundup_len; + sa->max_extended_len = rlens.max_extended_len;/* pre-populate CPT INST word 4 */ inst_w4.u64 =0 ;
drivers/crypto/cnxk/cn10k_ipsec.h +1 -3
@@ -20,9 +20,7 @@ struct cn10k_ipsec_sa { };/** Pre-populated CPT inst words */ struct cnxk_cpt_inst_tmpl inst; -uint8_t partial_len; -uint8_t roundup_len; -uint8_t roundup_byte; +uint16_t max_extended_len; };struct cn10k_sec_session {
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h +3 -25
@@ -12,40 +12,21 @@#include "cn10k_ipsec.h" #include "cnxk_cryptodev.h" -static __rte_always_inline int32_t -ipsec_po_out_rlen_get (struct cn10k_ipsec_sa *sess,uint32_t plen) -{ -uint32_t enc_payload_len; - - enc_payload_len = -RTE_ALIGN_CEIL (plen + sess->roundup_len, sess->roundup_byte); - -return sess->partial_len + enc_payload_len; -} - static __rte_always_inline intprocess_outb_sa (struct rte_crypto_op *cop,struct cn10k_ipsec_sa *sess,struct cpt_inst_s *inst) {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src; -uint32_t dlen, rlen, extend_tail; -char *mdata; - - dlen =rte_pktmbuf_pkt_len (m_src); - rlen =ipsec_po_out_rlen_get (sess, dlen); - extend_tail = rlen - dlen; - - mdata =rte_pktmbuf_append (m_src, extend_tail); -if (unlikely (mdata ==NULL )) { +if (unlikely (rte_pktmbuf_tailroom (m_src) < sess->max_extended_len)) {plt_dp_err ("Not enough tail room" );return -ENOMEM ; }/* Prepare CPT instruction */ inst->w4.u64 = sess->inst.w4; - inst->w4.s.dlen = dlen; + inst->w4.s.dlen =rte_pktmbuf_pkt_len (m_src); inst->dptr =rte_pktmbuf_iova (m_src); inst->rptr = inst->dptr;
@@ -58,13 +39,10 @@ process_inb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sa, {struct rte_crypto_sym_op *sym_op = cop->sym;struct rte_mbuf *m_src = sym_op->m_src; -uint32_t dlen; - - dlen =rte_pktmbuf_pkt_len (m_src);/* Prepare CPT instruction */ inst->w4.u64 = sa->inst.w4; - inst->w4.s.dlen = dlen; + inst->w4.s.dlen =rte_pktmbuf_pkt_len (m_src); inst->dptr =rte_pktmbuf_iova (m_src); inst->rptr = inst->dptr;
Signature · 1 line
2.27.0
PATCH v2 5/8 crypto/cnxk: make IPsec verify functions common
In reply to Tejasree KondojFrom: Archana Muniganti <[email protected]>
IPsec verify functions can be made common
--- drivers/crypto/cnxk/cn10k_ipsec.c | 116 +----------------------------- drivers/crypto/cnxk/cnxk_ipsec.h | 113 +++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 115 deletions(-)
drivers/crypto/cnxk/cn10k_ipsec.c +1 -115
@@ -17,120 +17,6 @@#include "roc_api.h" -static int -ipsec_xform_cipher_verify (struct rte_crypto_sym_xform *xform) -{ -if (xform->cipher.algo ==RTE_CRYPTO_CIPHER_AES_CBC ) { -switch (xform->cipher.key.length) { -case 16 : -case 24 : -case 32 : -break ; -default : -return -ENOTSUP ; - } -return 0 ; - } - -return -ENOTSUP ; -} - -static int -ipsec_xform_auth_verify (struct rte_crypto_sym_xform *xform) -{ -uint16_t keylen = xform->auth.key.length; - -if (xform->auth.algo ==RTE_CRYPTO_AUTH_SHA1_HMAC ) { -if (keylen >=20 && keylen <=64 ) -return 0 ; - } - -return -ENOTSUP ; -} - -static int -ipsec_xform_aead_verify (struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) -{ -if (ipsec_xfrm->direction ==RTE_SECURITY_IPSEC_SA_DIR_EGRESS && - crypto_xfrm->aead.op !=RTE_CRYPTO_AEAD_OP_ENCRYPT ) -return -EINVAL ; - -if (ipsec_xfrm->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS && - crypto_xfrm->aead.op !=RTE_CRYPTO_AEAD_OP_DECRYPT ) -return -EINVAL ; - -if (crypto_xfrm->aead.algo ==RTE_CRYPTO_AEAD_AES_GCM ) { -switch (crypto_xfrm->aead.key.length) { -case ROC_CPT_AES128_KEY_LEN : -case ROC_CPT_AES192_KEY_LEN : -case ROC_CPT_AES256_KEY_LEN : -break ; -default : -return -EINVAL ; - } -return 0 ; - } - -return -ENOTSUP ; -} - -static int -cn10k_ipsec_xform_verify (struct rte_security_ipsec_xform *ipsec_xfrm, -struct rte_crypto_sym_xform *crypto_xfrm) -{ -struct rte_crypto_sym_xform *auth_xform, *cipher_xform; -int ret; - -if ((ipsec_xfrm->direction !=RTE_SECURITY_IPSEC_SA_DIR_INGRESS ) && - (ipsec_xfrm->direction !=RTE_SECURITY_IPSEC_SA_DIR_EGRESS )) -return -EINVAL ; - -if ((ipsec_xfrm->proto !=RTE_SECURITY_IPSEC_SA_PROTO_ESP ) && - (ipsec_xfrm->proto !=RTE_SECURITY_IPSEC_SA_PROTO_AH )) -return -EINVAL ; - -if ((ipsec_xfrm->mode !=RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT ) && - (ipsec_xfrm->mode !=RTE_SECURITY_IPSEC_SA_MODE_TUNNEL )) -return -EINVAL ; - -if ((ipsec_xfrm->tunnel.type !=RTE_SECURITY_IPSEC_TUNNEL_IPV4 ) && - (ipsec_xfrm->tunnel.type !=RTE_SECURITY_IPSEC_TUNNEL_IPV6 )) -return -EINVAL ; - -if (crypto_xfrm->type ==RTE_CRYPTO_SYM_XFORM_AEAD ) -return ipsec_xform_aead_verify (ipsec_xfrm, crypto_xfrm); - -if (crypto_xfrm->next ==NULL ) -return -EINVAL ; - -if (ipsec_xfrm->direction ==RTE_SECURITY_IPSEC_SA_DIR_INGRESS ) { -/* Ingress */ -if (crypto_xfrm->type !=RTE_CRYPTO_SYM_XFORM_AUTH || - crypto_xfrm->next->type !=RTE_CRYPTO_SYM_XFORM_CIPHER ) -return -EINVAL ; - auth_xform = crypto_xfrm; - cipher_xform = crypto_xfrm->next; - }else { -/* Egress */ -if (crypto_xfrm->type !=RTE_CRYPTO_SYM_XFORM_CIPHER || - crypto_xfrm->next->type !=RTE_CRYPTO_SYM_XFORM_AUTH ) -return -EINVAL ; - cipher_xform = crypto_xfrm; - auth_xform = crypto_xfrm->next; - } - - ret =ipsec_xform_cipher_verify (cipher_xform); -if (ret) -return ret; - - ret =ipsec_xform_auth_verify (auth_xform); -if (ret) -return ret; - -return 0 ; -} -static uint64_t ipsec_cpt_inst_w7_get (struct roc_cpt *roc_cpt,void *sa) {
@@ -245,7 +131,7 @@ cn10k_ipsec_session_create(void *dev,return -EPERM ; } - ret =cn10k_ipsec_xform_verify (ipsec_xfrm, crypto_xfrm); + ret =cnxk_ipsec_xform_verify (ipsec_xfrm, crypto_xfrm);if (ret)return ret;
drivers/crypto/cnxk/cnxk_ipsec.h +113 -0
117 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v2 6/8 crypto/cnxk: support cn10k transport mode
In reply to Tejasree KondojAdding support for cn10k lookaside IPsec transport mode.
--- doc/guides/cryptodevs/cnxk.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 1 + drivers/crypto/cnxk/cnxk_cryptodev.h | 2 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 22 +++++++++++++++++++ drivers/crypto/cnxk/cnxk_ipsec.h | 3 ++- 5 files changed, 27 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/cnxk.rst +1 -0
@@ -230,6 +230,7 @@ Features supported * IPv4 * ESP * Tunnel mode +* Transport mode * AES-128/192/256-GCM * AES-128/192/256-CBC-SHA1-HMAC
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -58,6 +58,7 @@ New Features * **Updated Marvell cn10k_crypto PMD.** * Added aes-cbc sha1-hmac in lookaside protocol (IPsec). + * Added transport mode in lookaside protocol (IPsec). Removed Items
drivers/crypto/cnxk/cnxk_cryptodev.h +1 -1
@@ -12,7 +12,7 @@#define CNXK_CPT_MAX_CAPS 34#define CNXK_SEC_CRYPTO_MAX_CAPS 4 -#define CNXK_SEC_MAX_CAPS 3 +#define CNXK_SEC_MAX_CAPS 5#define CNXK_AE_EC_ID_MAX 8/** * Device private data
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +22 -0
@@ -822,6 +822,28 @@ static const struct rte_security_capability sec_caps_templ[] = { }, .crypto_capabilities = NULL, }, + {/* IPsec Lookaside Protocol ESP Transport Ingress */ + .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, + .protocol = RTE_SECURITY_PROTOCOL_IPSEC, + .ipsec = { + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, + .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS, + .options = { 0 }, + }, + .crypto_capabilities = NULL, + }, + { /* IPsec Lookaside Protocol ESP Transport Egress */ + .action = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, + .protocol = RTE_SECURITY_PROTOCOL_IPSEC, + .ipsec = { + .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP, + .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT, + .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS, + .options = { 0 }, + }, + .crypto_capabilities = NULL, + }, { .action = RTE_SECURITY_ACTION_TYPE_NONE }
drivers/crypto/cnxk/cnxk_ipsec.h +2 -1
@@ -98,7 +98,8 @@ cnxk_ipsec_xform_verify(struct rte_security_ipsec_xform *ipsec_xform, (ipsec_xform->mode != RTE_SECURITY_IPSEC_SA_MODE_TUNNEL))return -EINVAL ; -if ((ipsec_xform->tunnel.type !=RTE_SECURITY_IPSEC_TUNNEL_IPV4 ) && +if ((ipsec_xform->mode ==RTE_SECURITY_IPSEC_SA_MODE_TUNNEL ) && + (ipsec_xform->tunnel.type !=RTE_SECURITY_IPSEC_TUNNEL_IPV4 ) && (ipsec_xform->tunnel.type !=RTE_SECURITY_IPSEC_TUNNEL_IPV6 ))return -EINVAL ;
Signature · 1 line
2.27.0
PATCH v2 7/8 crypto/cnxk: support UDP encap with lookaside IPsec
In reply to Tejasree KondojAdding support for UDP encapsulation in lookaside IPsec.
--- doc/guides/cryptodevs/cnxk.rst | 1 + doc/guides/rel_notes/release_21_11.rst | 1 + drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/cnxk.rst +1 -0
@@ -231,6 +231,7 @@ Features supported * ESP * Tunnel mode * Transport mode +* UDP Encapsulation * AES-128/192/256-GCM * AES-128/192/256-CBC-SHA1-HMAC
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -59,6 +59,7 @@ New Features * Added aes-cbc sha1-hmac in lookaside protocol (IPsec). * Added transport mode in lookaside protocol (IPsec). + * Added UDP encapsulation in lookaside protocol (IPsec). Removed Items
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +10 -1
@@ -907,6 +907,12 @@ sec_crypto_caps_populate(struct rte_cryptodev_capabilities cnxk_caps[],sec_caps_add (cnxk_caps, &cur_pos, caps_end,RTE_DIM (caps_end)); } +static void +cnxk_sec_caps_update (struct rte_security_capability *sec_cap) +{ + sec_cap->ipsec.options.udp_encap =1 ; +} +void cnxk_cpt_caps_populate (struct cnxk_cpt_vf *vf) {
@@ -918,8 +924,11 @@ cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf)PLT_STATIC_ASSERT (RTE_DIM (sec_caps_templ) <=RTE_DIM (vf->sec_caps));memcpy (vf->sec_caps, sec_caps_templ,sizeof (sec_caps_templ)); -for (i =0 ; i <RTE_DIM (sec_caps_templ) -1 ; i++) +for (i =0 ; i <RTE_DIM (sec_caps_templ) -1 ; i++) { vf->sec_caps[i].crypto_capabilities = vf->sec_crypto_caps; + +cnxk_sec_caps_update (&vf->sec_caps[i]); + } } const struct rte_security_capability *
Signature · 1 line
2.27.0
PATCH v2 8/8 common/cnxk: make IPsec defines common
In reply to Tejasree KondojFrom: Archana Muniganti <[email protected]>
Make IPsec defines common and remove redundant macros.
--- drivers/common/cnxk/cnxk_security.c | 24 +++++++++-------- drivers/common/cnxk/roc_api.h | 1 + drivers/common/cnxk/roc_ie.h | 33 ++++++++++++++++------- drivers/common/cnxk/roc_ie_on.h | 26 ------------------ drivers/common/cnxk/roc_ie_ot.h | 26 ------------------ drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 4 ++- 6 files changed, 41 insertions(+), 73 deletions(-)
drivers/common/cnxk/cnxk_security.c +13 -11
@@ -6,6 +6,8 @@#include "cnxk_security.h" +#include "roc_api.h" +static void ipsec_hmac_opad_ipad_gen (struct rte_crypto_sym_xform *auth_xform,uint8_t *hmac_opad_ipad)
@@ -51,12 +53,12 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2,/* Set direction */ switch (ipsec_xfrm->direction) {case RTE_SECURITY_IPSEC_SA_DIR_INGRESS : - w2->s.dir =ROC_IE_OT_SA_DIR_INBOUND ; + w2->s.dir =ROC_IE_SA_DIR_INBOUND ; auth_xfrm = crypto_xfrm; cipher_xfrm = crypto_xfrm->next;break ;case RTE_SECURITY_IPSEC_SA_DIR_EGRESS : - w2->s.dir =ROC_IE_OT_SA_DIR_OUTBOUND ; + w2->s.dir =ROC_IE_SA_DIR_OUTBOUND ; cipher_xfrm = crypto_xfrm; auth_xfrm = crypto_xfrm->next;break ;
@@ -67,10 +69,10 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2,/* Set protocol - ESP vs AH */ switch (ipsec_xfrm->proto) {case RTE_SECURITY_IPSEC_SA_PROTO_ESP : - w2->s.protocol =ROC_IE_OT_SA_PROTOCOL_ESP ; + w2->s.protocol =ROC_IE_SA_PROTOCOL_ESP ;break ;case RTE_SECURITY_IPSEC_SA_PROTO_AH : - w2->s.protocol =ROC_IE_OT_SA_PROTOCOL_AH ; + w2->s.protocol =ROC_IE_SA_PROTOCOL_AH ;break ;default :return -EINVAL ;
@@ -79,10 +81,10 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2,/* Set mode - transport vs tunnel */ switch (ipsec_xfrm->mode) {case RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT : - w2->s.mode =ROC_IE_OT_SA_MODE_TRANSPORT ; + w2->s.mode =ROC_IE_SA_MODE_TRANSPORT ;break ;case RTE_SECURITY_IPSEC_SA_MODE_TUNNEL : - w2->s.mode =ROC_IE_OT_SA_MODE_TUNNEL ; + w2->s.mode =ROC_IE_SA_MODE_TUNNEL ;break ;default :return -EINVAL ;
@@ -147,13 +149,13 @@ ot_ipsec_sa_common_param_fill(union roc_ot_ipsec_sa_word2 *w2,switch (length) {case ROC_CPT_AES128_KEY_LEN : - w2->s.aes_key_len =ROC_IE_OT_SA_AES_KEY_LEN_128 ; + w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_128 ;break ;case ROC_CPT_AES192_KEY_LEN : - w2->s.aes_key_len =ROC_IE_OT_SA_AES_KEY_LEN_192 ; + w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_192 ;break ;case ROC_CPT_AES256_KEY_LEN : - w2->s.aes_key_len =ROC_IE_OT_SA_AES_KEY_LEN_256 ; + w2->s.aes_key_len =ROC_IE_SA_AES_KEY_LEN_256 ;break ;default :return -EINVAL ;
@@ -271,7 +273,7 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,/* Tunnel header info */ switch (tunnel->type) {case RTE_SECURITY_IPSEC_TUNNEL_IPV4 : - sa->w2.s.outer_ip_ver =ROC_IE_OT_SA_IP_VERSION_4 ; + sa->w2.s.outer_ip_ver =ROC_IE_SA_IP_VERSION_4 ;memcpy (&sa->outer_hdr.ipv4.src_addr, &tunnel->ipv4.src_ip,sizeof (struct in_addr )); memcpy(&sa->outer_hdr.ipv4.dst_addr, &tunnel->ipv4.dst_ip,
@@ -302,7 +304,7 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa, }break ;case RTE_SECURITY_IPSEC_TUNNEL_IPV6 : - sa->w2.s.outer_ip_ver =ROC_IE_OT_SA_IP_VERSION_6 ; + sa->w2.s.outer_ip_ver =ROC_IE_SA_IP_VERSION_6 ;memcpy (&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr,sizeof (struct in6_addr )); memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr,
drivers/common/cnxk/roc_api.h +1 -0
@@ -121,6 +121,7 @@/* CPT microcode */ #include "roc_ae.h" #include "roc_ae_fpm_tables.h" +#include "roc_ie.h" #include "roc_ie_on.h" #include "roc_ie_ot.h" #include "roc_se.h"
drivers/common/cnxk/roc_ie.h +24 -9
@@ -5,15 +5,30 @@#ifndef __ROC_IE_H__#define __ROC_IE_H__ -/* CNXK IPSEC helper macros */ -#define ROC_IE_AH_HDR_LEN 12 -#define ROC_IE_AES_GCM_IV_LEN 8 -#define ROC_IE_AES_GCM_MAC_LEN 16 -#define ROC_IE_AES_CBC_IV_LEN 16 -#define ROC_IE_SHA1_HMAC_LEN 12 -#define ROC_IE_AUTH_KEY_LEN_MAX 64 +enum { +ROC_IE_SA_DIR_INBOUND =0 , +ROC_IE_SA_DIR_OUTBOUND =1 , +}; -#define ROC_IE_AES_GCM_ROUNDUP_BYTE_LEN 4 -#define ROC_IE_AES_CBC_ROUNDUP_BYTE_LEN 16 +enum { +ROC_IE_SA_IP_VERSION_4 =0 , +ROC_IE_SA_IP_VERSION_6 =1 , +}; + +enum { +ROC_IE_SA_MODE_TRANSPORT =0 , +ROC_IE_SA_MODE_TUNNEL =1 , +}; + +enum { +ROC_IE_SA_PROTOCOL_AH =0 , +ROC_IE_SA_PROTOCOL_ESP =1 , +}; + +enum { +ROC_IE_SA_AES_KEY_LEN_128 =1 , +ROC_IE_SA_AES_KEY_LEN_192 =2 , +ROC_IE_SA_AES_KEY_LEN_256 =3 , +};#endif /* __ROC_IE_H__ */
drivers/common/cnxk/roc_ie_on.h +0 -26
@@ -18,32 +18,6 @@/* Ucode completion codes */ #define ROC_IE_ONF_UCC_SUCCESS 0 -enum { -ROC_IE_ON_SA_DIR_INBOUND =0 , -ROC_IE_ON_SA_DIR_OUTBOUND =1 , -}; - -enum { -ROC_IE_ON_SA_IP_VERSION_4 =0 , -ROC_IE_ON_SA_IP_VERSION_6 =1 , -}; - -enum { -ROC_IE_ON_SA_MODE_TRANSPORT =0 , -ROC_IE_ON_SA_MODE_TUNNEL =1 , -}; - -enum { -ROC_IE_ON_SA_PROTOCOL_AH =0 , -ROC_IE_ON_SA_PROTOCOL_ESP =1 , -}; - -enum { -ROC_IE_ON_SA_AES_KEY_LEN_128 =1 , -ROC_IE_ON_SA_AES_KEY_LEN_192 =2 , -ROC_IE_ON_SA_AES_KEY_LEN_256 =3 , -}; -enum {ROC_IE_ON_SA_ENC_NULL =0 ,ROC_IE_ON_SA_ENC_DES_CBC =1 ,
drivers/common/cnxk/roc_ie_ot.h +0 -26
@@ -97,32 +97,6 @@ enum { ROC_IE_OT_SA_INNER_PKT_L4_CSUM_DISABLE = 1, }; -enum { -ROC_IE_OT_SA_DIR_INBOUND =0 , -ROC_IE_OT_SA_DIR_OUTBOUND =1 , -}; - -enum { -ROC_IE_OT_SA_IP_VERSION_4 =0 , -ROC_IE_OT_SA_IP_VERSION_6 =1 , -}; - -enum { -ROC_IE_OT_SA_MODE_TRANSPORT =0 , -ROC_IE_OT_SA_MODE_TUNNEL =1 , -}; - -enum { -ROC_IE_OT_SA_PROTOCOL_AH =0 , -ROC_IE_OT_SA_PROTOCOL_ESP =1 , -}; - -enum { -ROC_IE_OT_SA_AES_KEY_LEN_128 =1 , -ROC_IE_OT_SA_AES_KEY_LEN_192 =2 , -ROC_IE_OT_SA_AES_KEY_LEN_256 =3 , -}; -enum {ROC_IE_OT_SA_ENC_NULL =0 ,ROC_IE_OT_SA_ENC_3DES_CBC =2 ,
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +3 -1
@@ -16,6 +16,8 @@#include "cnxk_cryptodev_ops.h" #include "cnxk_se.h" +#include "roc_api.h" +static inline struct cnxk_se_sess *cn10k_cpt_sym_temp_sess_create (struct cnxk_cpt_qp *qp,struct rte_crypto_op *op) {
@@ -68,7 +70,7 @@ cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess, sa = &sess->sa; w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2; -if (w2->s.dir ==ROC_IE_OT_SA_DIR_OUTBOUND ) +if (w2->s.dir ==ROC_IE_SA_DIR_OUTBOUND ) ret =process_outb_sa (op, sa, inst);else ret =process_inb_sa (op, sa, inst);
Signature · 1 line
2.27.0
Akhil Goyal
AppliedQuoted 34 lines
This series adds cn10k lookaside IPsec AES-CBC-HMAC-SHA1, UDP encapsulation
and transport mode support along with common cnxk pmd changes. The functionality has been tested with ipsec-secgw application running in lookaside protocol offload mode.v2:
* Fixed release notesArchana Muniganti (2):
crypto/cnxk: make IPsec verify functions common
common/cnxk: make IPsec defines commonTejasree Kondoj (6):
common/cnxk: add hash generation APIscrypto/cnxk: add lookaside IPsec AES-CBC-HMAC-SHA1 supportcrypto/cnxk: remove redundant code
crypto/cnxk: use rlen from CPT result with lookasidecrypto/cnxk: support cn10k transport modecrypto/cnxk: support UDP encap with lookaside IPsecdoc/guides/cryptodevs/cnxk.rst | 3 + doc/guides/rel_notes/release_21_11.rst | 6 + drivers/common/cnxk/cnxk_security.c | 92 +++++- drivers/common/cnxk/meson.build | 1 + drivers/common/cnxk/roc_api.h | 4 + drivers/common/cnxk/roc_hash.c | 275 ++++++++++++++++++ drivers/common/cnxk/roc_hash.h | 16 + drivers/common/cnxk/roc_ie.h | 33 ++- drivers/common/cnxk/roc_ie_on.h | 26 -- drivers/common/cnxk/roc_ie_ot.h | 26 -- drivers/common/cnxk/version.map | 3 + drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 44 +-- drivers/crypto/cnxk/cn10k_ipsec.c | 64 +---
Quoted 9 lines
drivers/crypto/cnxk/cn10k_ipsec.h | 6 +- drivers/crypto/cnxk/cn10k_ipsec_la_ops.h | 28 +- drivers/crypto/cnxk/cnxk_cryptodev.h | 2 +- .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 79 ++++- drivers/crypto/cnxk/cnxk_ipsec.h | 114 ++++++++ 18 files changed, 620 insertions(+), 202 deletions(-) create mode 100644 drivers/common/cnxk/roc_hash.c create mode 100644 drivers/common/cnxk/roc_hash.h
Series Acked-by: Akhil Goyal <[email protected]>
Applied to dpdk-next-crypto
Thanks.