[5/8] crypto/cnxk: add cn9k IPsec inbound session create function
Checks
Commit Message
Adding logic for IPsec inbound session creation.
Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Signed-off-by: Archana Muniganti <marchana@marvell.com>
Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
---
drivers/crypto/cnxk/cn9k_ipsec.c | 64 +++++++++++++++++++++++++++++---
1 file changed, 59 insertions(+), 5 deletions(-)
@@ -422,12 +422,66 @@ cn9k_ipsec_inb_sa_create(struct cnxk_cpt_qp *qp,
struct rte_crypto_sym_xform *crypto_xform,
struct rte_security_session *sec_sess)
{
- RTE_SET_USED(qp);
- RTE_SET_USED(ipsec);
- RTE_SET_USED(crypto_xform);
- RTE_SET_USED(sec_sess);
+ struct rte_crypto_sym_xform *auth_xform = crypto_xform;
+ struct cnxk_cpt_inst_tmpl *inst_tmpl;
+ struct roc_ie_on_inb_sa *in_sa;
+ struct cn9k_sec_session *sess;
+ struct cn9k_ipsec_sa *sa;
+ const uint8_t *auth_key;
+ union cpt_inst_w4 w4;
+ union cpt_inst_w7 w7;
+ int auth_key_len = 0;
+ size_t ctx_len = 0;
+ int ret;
- return 0;
+ sess = get_sec_session_private_data(sec_sess);
+ sa = &sess->sa;
+ in_sa = &sa->in_sa;
+
+ memset(sa, 0, sizeof(struct cn9k_ipsec_sa));
+
+ sa->dir = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
+
+ ret = fill_ipsec_common_sa(ipsec, crypto_xform, &in_sa->common_sa);
+ if (ret)
+ return ret;
+
+ if (crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+ ctx_len = offsetof(struct roc_ie_on_inb_sa,
+ sha1_or_gcm.hmac_key[0]);
+ } else {
+ auth_key = auth_xform->auth.key.data;
+ auth_key_len = auth_xform->auth.key.length;
+
+ if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC) {
+ memcpy(in_sa->sha1_or_gcm.hmac_key, auth_key,
+ auth_key_len);
+ ctx_len = offsetof(struct roc_ie_on_inb_sa,
+ sha1_or_gcm.selector);
+ } else if (auth_xform->auth.algo ==
+ RTE_CRYPTO_AUTH_SHA256_HMAC) {
+ memcpy(in_sa->sha2.hmac_key, auth_key, auth_key_len);
+ ctx_len = offsetof(struct roc_ie_on_inb_sa,
+ sha2.selector);
+ }
+ }
+
+ inst_tmpl = &sa->inst;
+
+ w4.u64 = 0;
+ w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC;
+ w4.s.opcode_minor = ctx_len >> 3;
+ inst_tmpl->w4 = w4.u64;
+
+ w7.u64 = 0;
+ w7.s.egrp = ROC_CPT_DFLT_ENG_GRP_SE;
+ w7.s.cptr = rte_mempool_virt2iova(in_sa);
+ inst_tmpl->w7 = w7.u64;
+
+ ret = cn9k_cpt_enq_sa_write(
+ sa, qp, ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_INBOUND, ctx_len);
+
+ return ret;
}
static inline int