From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 190F8A0547; Thu, 28 Oct 2021 12:18:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E209D40DDB; Thu, 28 Oct 2021 12:18:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2B1034067B; Thu, 28 Oct 2021 12:18:02 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19SA5VuE021918; Thu, 28 Oct 2021 03:18:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=Utoe2z2kmU1PCsh1ru8nrHXmQ9BGnghdj9t5bNT6TaE=; b=EofVQf0N6BjPCT8qlzoTqnDMQqqtvtPRBvrs4mZs5mTKumdsHun62Dh/9a4s0+Nmh6Gn 0BPoYSpX1Ma+rJ/23fJBgJ5kIRRd/nin3drtnwEBwyD7xQvc/Im9a0GJdKr8L7GHGEEe 965HzrCTdpJDM1/QV80f6xIaJs0gkd7zESbxNwXoqZYXkcswt+pgge0mF4zVyP/Z8ml8 vJthsorqObtKDdeSmq+WqPtJLsJ2DiWSFhCGgZDld6Efw2l1xNOUP3Ok4jflRdbky51N KJBgagXXf1XRPQi5THxyT4iGoKskaAH4wvimBNxlkAEkCSKmzQbtI5K3AniyV0PnWqAo oQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3byd2fathn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 03:18:01 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 28 Oct 2021 03:17:59 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 28 Oct 2021 03:17:59 -0700 Received: from hyd1554T5810.caveonetworks.com.com (unknown [10.29.57.11]) by maili.marvell.com (Postfix) with ESMTP id 6A40E3F705F; Thu, 28 Oct 2021 03:17:56 -0700 (PDT) From: Tejasree Kondoj To: Akhil Goyal CC: Tejasree Kondoj , Anoob Joseph , , Date: Thu, 28 Oct 2021 16:41:11 +0530 Message-ID: <20211028111111.6501-1-ktejasree@marvell.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: mk5Da5ehKcdPgCTYUotemxHC32Yxzsq- X-Proofpoint-GUID: mk5Da5ehKcdPgCTYUotemxHC32Yxzsq- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-28_01,2021-10-26_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] crypto/octeontx2: fix lookaside IPsec IPv6 support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fixing IPv6 mixed tunnel mode support by updating inputs to firmware. Fixes: 4edede7bc6ee ("crypto/octeontx2: support lookaside IPsec IPv6") Cc: stable@dpdk.org Signed-off-by: Tejasree Kondoj --- drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 9 ++++---- drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 22 +++++++------------ drivers/crypto/octeontx2/otx2_cryptodev_sec.h | 2 -- drivers/crypto/octeontx2/otx2_ipsec_po.h | 8 ------- drivers/crypto/octeontx2/otx2_ipsec_po_ops.h | 10 +++------ 5 files changed, 15 insertions(+), 36 deletions(-) diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c index e6274bea42..e0ae3e161e 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c @@ -993,13 +993,12 @@ otx2_cpt_sec_post_process(struct rte_crypto_op *cop, uintptr_t *rsp) if (word0->s.opcode.major == OTX2_IPSEC_PO_PROCESS_IPSEC_INB) { data = rte_pktmbuf_mtod(m, char *); + ip = (struct rte_ipv4_hdr *)(data + + OTX2_IPSEC_PO_INB_RPTR_HDR); - if (rsp[4] == OTX2_IPSEC_PO_TRANSPORT || - rsp[4] == OTX2_IPSEC_PO_TUNNEL_IPV4) { - ip = (struct rte_ipv4_hdr *)(data + - OTX2_IPSEC_PO_INB_RPTR_HDR); + if ((ip->version_ihl >> 4) == 4) { m_len = rte_be_to_cpu_16(ip->total_length); - } else if (rsp[4] == OTX2_IPSEC_PO_TUNNEL_IPV6) { + } else { ip6 = (struct rte_ipv6_hdr *)(data + OTX2_IPSEC_PO_INB_RPTR_HDR); m_len = rte_be_to_cpu_16(ip6->payload_len) + diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_sec.c b/drivers/crypto/octeontx2/otx2_cryptodev_sec.c index a5db40047d..9a4f84f8d8 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_sec.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_sec.c @@ -194,9 +194,6 @@ set_session_misc_attributes(struct otx2_sec_session_ipsec_lp *sess, sess->auth_iv_length = auth_xform->auth.iv.length; sess->mac_len = auth_xform->auth.digest_length; } - - sess->ucmd_param1 = OTX2_IPSEC_PO_PER_PKT_IV; - sess->ucmd_param2 = 0; } static int @@ -232,7 +229,6 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, memset(sa, 0, sizeof(struct otx2_ipsec_po_out_sa)); /* Initialize lookaside ipsec private data */ - lp->mode_type = OTX2_IPSEC_PO_TRANSPORT; lp->ip_id = 0; lp->seq_lo = 1; lp->seq_hi = 0; @@ -285,7 +281,6 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, if (ipsec->mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) { if (ipsec->tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV4) { - lp->mode_type = OTX2_IPSEC_PO_TUNNEL_IPV4; ip->version_ihl = RTE_IPV4_VHL_DEF; ip->time_to_live = ipsec->tunnel.ipv4.ttl; ip->type_of_service |= (ipsec->tunnel.ipv4.dscp << 2); @@ -298,7 +293,6 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, } else if (ipsec->tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV6) { - lp->mode_type = OTX2_IPSEC_PO_TUNNEL_IPV6; if (ctl->enc_type == OTX2_IPSEC_PO_SA_ENC_AES_GCM) { template = &sa->aes_gcm.template; ctx_len = offsetof(struct otx2_ipsec_po_out_sa, @@ -387,6 +381,10 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, lp->ucmd_opcode = (lp->ctx_len << 8) | (OTX2_IPSEC_PO_PROCESS_IPSEC_OUTB); + /* Set per packet IV and IKEv2 bits */ + lp->ucmd_param1 = BIT(11) | BIT(9); + lp->ucmd_param2 = 0; + set_session_misc_attributes(lp, crypto_xform, auth_xform, cipher_xform); @@ -429,20 +427,12 @@ crypto_sec_ipsec_inb_session_create(struct rte_cryptodev *crypto_dev, if (ret) return ret; - lp->mode_type = OTX2_IPSEC_PO_TRANSPORT; - auth_xform = crypto_xform; cipher_xform = crypto_xform->next; cipher_key_len = 0; auth_key_len = 0; - if (ipsec->mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) - lp->mode_type = (ipsec->tunnel.type == - RTE_SECURITY_IPSEC_TUNNEL_IPV4) ? - OTX2_IPSEC_PO_TUNNEL_IPV4 : - OTX2_IPSEC_PO_TUNNEL_IPV6; - if (crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) { if (crypto_xform->aead.algo == RTE_CRYPTO_AEAD_AES_GCM) memcpy(sa->iv.gcm.nonce, &ipsec->salt, 4); @@ -482,6 +472,10 @@ crypto_sec_ipsec_inb_session_create(struct rte_cryptodev *crypto_dev, lp->cpt_inst_w7 = inst.u64[7]; lp->ucmd_opcode = (lp->ctx_len << 8) | (OTX2_IPSEC_PO_PROCESS_IPSEC_INB); + lp->ucmd_param1 = 0; + + /* Set IKEv2 bit */ + lp->ucmd_param2 = BIT(12); set_session_misc_attributes(lp, crypto_xform, auth_xform, cipher_xform); diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_sec.h b/drivers/crypto/octeontx2/otx2_cryptodev_sec.h index 87f55c97fe..ff3329c9c1 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_sec.h +++ b/drivers/crypto/octeontx2/otx2_cryptodev_sec.h @@ -55,8 +55,6 @@ struct otx2_sec_session_ipsec_lp { uint8_t iv_length; /** Auth IV length in bytes */ uint8_t auth_iv_length; - /** IPsec mode and tunnel type */ - enum otx2_ipsec_po_mode_type mode_type; }; int otx2_crypto_sec_ctx_create(struct rte_cryptodev *crypto_dev); diff --git a/drivers/crypto/octeontx2/otx2_ipsec_po.h b/drivers/crypto/octeontx2/otx2_ipsec_po.h index b61c5e0c04..695f552644 100644 --- a/drivers/crypto/octeontx2/otx2_ipsec_po.h +++ b/drivers/crypto/octeontx2/otx2_ipsec_po.h @@ -11,8 +11,6 @@ #define OTX2_IPSEC_PO_AES_GCM_INB_CTX_LEN 0x09 -#define OTX2_IPSEC_PO_PER_PKT_IV BIT(11) - #define OTX2_IPSEC_PO_WRITE_IPSEC_OUTB 0x20 #define OTX2_IPSEC_PO_WRITE_IPSEC_INB 0x21 #define OTX2_IPSEC_PO_PROCESS_IPSEC_OUTB 0x23 @@ -20,12 +18,6 @@ #define OTX2_IPSEC_PO_INB_RPTR_HDR 0x8 -enum otx2_ipsec_po_mode_type { - OTX2_IPSEC_PO_TRANSPORT = 1, - OTX2_IPSEC_PO_TUNNEL_IPV4, - OTX2_IPSEC_PO_TUNNEL_IPV6, -}; - enum otx2_ipsec_po_comp_e { OTX2_IPSEC_PO_CC_SUCCESS = 0x00, OTX2_IPSEC_PO_CC_AUTH_UNSUPPORTED = 0xB0, diff --git a/drivers/crypto/octeontx2/otx2_ipsec_po_ops.h b/drivers/crypto/octeontx2/otx2_ipsec_po_ops.h index 25ee10f342..c3abf02187 100644 --- a/drivers/crypto/octeontx2/otx2_ipsec_po_ops.h +++ b/drivers/crypto/octeontx2/otx2_ipsec_po_ops.h @@ -25,8 +25,7 @@ otx2_ipsec_po_out_rlen_get(struct otx2_sec_session_ipsec_lp *sess, } static __rte_always_inline struct cpt_request_info * -alloc_request_struct(char *maddr, void *cop, int mdata_len, - enum otx2_ipsec_po_mode_type mode_type) +alloc_request_struct(char *maddr, void *cop, int mdata_len) { struct cpt_request_info *req; struct cpt_meta_info *meta; @@ -48,7 +47,6 @@ alloc_request_struct(char *maddr, void *cop, int mdata_len, op[1] = (uintptr_t)cop; op[2] = (uintptr_t)req; op[3] = mdata_len; - op[4] = mode_type; return req; } @@ -86,8 +84,7 @@ process_outb_sa(struct rte_crypto_op *cop, } mdata += extend_tail; /* mdata follows encrypted data */ - req = alloc_request_struct(mdata, (void *)cop, mdata_len, - sess->mode_type); + req = alloc_request_struct(mdata, (void *)cop, mdata_len); data = rte_pktmbuf_prepend(m_src, extend_head); if (unlikely(data == NULL)) { @@ -153,8 +150,7 @@ process_inb_sa(struct rte_crypto_op *cop, goto exit; } - req = alloc_request_struct(mdata, (void *)cop, mdata_len, - sess->mode_type); + req = alloc_request_struct(mdata, (void *)cop, mdata_len); /* Prepare CPT instruction */ word0.u64 = sess->ucmd_w0; -- 2.27.0