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 D387F45A74; Tue, 1 Oct 2024 08:02:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CDCC40DD0; Tue, 1 Oct 2024 08:01:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5008740A7F for ; Tue, 1 Oct 2024 08:01:37 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4914DbnQ023533 for ; Mon, 30 Sep 2024 23:01:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=s bQmBKjEngKv5weuPtUfrqlQRG+BKt3O+a+9R7C6cY0=; b=WcQAoUGklqDzYlNRL OMVMCUQzsPMHu0wKT7laWExG8nqjv2dKmQmejkT9j8aVDiPpCk5wDJMJDFViIKcH rfLo7Hlm+k1E4fsw6iRe0Veww8T/zXRFgDV05xih0DQS+QUlBPSb4pwruYTsR8QQ Co8HcICdTRMHx7TaGpcn6kxXUbrOovqcubA+Hka0boVFFXd/jNEqEWV5HSWqaaJG ZZzyy6Ntil45y3Vyr2L4i1pas5099UR3GTrhkUuKstWt2zWxRrL1pjuvxbSI1Nbi lZatagg6I91yswDMS7SGC5UhUFBf3WBFRCCJC8ciUWBEhyTlXa/XX58x5bzcYePR Esqdw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41xf5m2erm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 30 Sep 2024 23:01:36 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 30 Sep 2024 23:01:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 30 Sep 2024 23:01:35 -0700 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id C08AB3F7066; Mon, 30 Sep 2024 23:01:31 -0700 (PDT) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao , Harman Kalra CC: , Srujana Challa Subject: [PATCH v2 11/17] net/cnxk: add PMD APIs for IPsec SA base and flush Date: Tue, 1 Oct 2024 11:30:49 +0530 Message-ID: <20241001060055.3747591-11-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241001060055.3747591-1-ndabilpuram@marvell.com> References: <20241001060055.3747591-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: KIzoElJ1yLJDzhtoSWjBLE2x8zakoSuU X-Proofpoint-GUID: KIzoElJ1yLJDzhtoSWjBLE2x8zakoSuU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 From: Srujana Challa Introduces new PMD APIs for Inline IPsec, including hardware SA flush and obtaining the base address for the inline device sa table. This allows applications to directly manage IPsec SAs. This patch also updates the rte_pmd_cnxk_hw_sa_read|write() API's to get use portid instead of device pointer as input. Signed-off-by: Srujana Challa --- drivers/common/cnxk/roc_nix_inl.c | 9 +++++ drivers/net/cnxk/cnxk_ethdev_sec.c | 64 ++++++++++++++++++++---------- drivers/net/cnxk/rte_pmd_cnxk.h | 48 +++++++++++++++++++--- drivers/net/cnxk/version.map | 2 + 4 files changed, 97 insertions(+), 26 deletions(-) diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c index d0328921a7..23ffd4391a 100644 --- a/drivers/common/cnxk/roc_nix_inl.c +++ b/drivers/common/cnxk/roc_nix_inl.c @@ -1685,6 +1685,7 @@ roc_nix_inl_sa_sync(struct roc_nix *roc_nix, void *sa, bool inb, struct roc_cpt_lf *outb_lf = NULL; union cpt_lf_ctx_reload reload; union cpt_lf_ctx_flush flush; + union cpt_lf_ctx_err err; bool get_inl_lf = true; uintptr_t rbase; struct nix *nix; @@ -1726,6 +1727,14 @@ roc_nix_inl_sa_sync(struct roc_nix *roc_nix, void *sa, bool inb, case ROC_NIX_INL_SA_OP_FLUSH: flush.s.cptr = ((uintptr_t)sa) >> 7; plt_write64(flush.u, rbase + CPT_LF_CTX_FLUSH); + plt_atomic_thread_fence(__ATOMIC_ACQ_REL); + /* Read a CSR to ensure that the FLUSH operation is complete */ + err.u = plt_read64(rbase + CPT_LF_CTX_ERR); + + if (err.s.flush_st_flt) { + plt_warn("CTX flush could not complete"); + return -EIO; + } break; case ROC_NIX_INL_SA_OP_RELOAD: reload.s.cptr = ((uintptr_t)sa) >> 7; diff --git a/drivers/net/cnxk/cnxk_ethdev_sec.c b/drivers/net/cnxk/cnxk_ethdev_sec.c index cdd5656817..ec129b6584 100644 --- a/drivers/net/cnxk/cnxk_ethdev_sec.c +++ b/drivers/net/cnxk/cnxk_ethdev_sec.c @@ -297,47 +297,71 @@ cnxk_eth_sec_sess_get_by_sess(struct cnxk_eth_dev *dev, return NULL; } +union rte_pmd_cnxk_ipsec_hw_sa * +rte_pmd_cnxk_hw_session_base_get(uint16_t portid, bool inb) +{ + struct rte_eth_dev *eth_dev = &rte_eth_devices[portid]; + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + uintptr_t sa_base; + + if (inb) + sa_base = roc_nix_inl_inb_sa_base_get(&dev->nix, dev->inb.inl_dev); + else + sa_base = roc_nix_inl_outb_sa_base_get(&dev->nix); + + return (union rte_pmd_cnxk_ipsec_hw_sa *)sa_base; +} + +int +rte_pmd_cnxk_sa_flush(uint16_t portid, union rte_pmd_cnxk_ipsec_hw_sa *sess, bool inb) +{ + struct rte_eth_dev *eth_dev = &rte_eth_devices[portid]; + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + + return roc_nix_inl_sa_sync(&dev->nix, sess, inb, ROC_NIX_INL_SA_OP_FLUSH); +} + int -rte_pmd_cnxk_hw_sa_read(void *device, void *__sess, union rte_pmd_cnxk_ipsec_hw_sa *data, - uint32_t len) +rte_pmd_cnxk_hw_sa_read(uint16_t portid, void *sess, union rte_pmd_cnxk_ipsec_hw_sa *data, + uint32_t len, bool inb) { - struct rte_security_session *sess = __sess; - struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device; + struct rte_eth_dev *eth_dev = &rte_eth_devices[portid]; struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); struct cnxk_eth_sec_sess *eth_sec; + void *sa; int rc; eth_sec = cnxk_eth_sec_sess_get_by_sess(dev, sess); - if (eth_sec == NULL) - return -EINVAL; + if (eth_sec) + sa = eth_sec->sa; + else + sa = sess; - rc = roc_nix_inl_sa_sync(&dev->nix, eth_sec->sa, eth_sec->inb, ROC_NIX_INL_SA_OP_FLUSH); + rc = roc_nix_inl_sa_sync(&dev->nix, sa, inb, ROC_NIX_INL_SA_OP_FLUSH); if (rc) return -EINVAL; - rte_delay_ms(1); - memcpy(data, eth_sec->sa, len); + + memcpy(data, sa, len); return 0; } int -rte_pmd_cnxk_hw_sa_write(void *device, void *__sess, union rte_pmd_cnxk_ipsec_hw_sa *data, - uint32_t len) +rte_pmd_cnxk_hw_sa_write(uint16_t portid, void *sess, union rte_pmd_cnxk_ipsec_hw_sa *data, + uint32_t len, bool inb) { - struct rte_security_session *sess = __sess; - struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device; + struct rte_eth_dev *eth_dev = &rte_eth_devices[portid]; struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); struct cnxk_eth_sec_sess *eth_sec; - int rc = -EINVAL; + void *sa; eth_sec = cnxk_eth_sec_sess_get_by_sess(dev, sess); - if (eth_sec == NULL) - return rc; - rc = roc_nix_inl_ctx_write(&dev->nix, data, eth_sec->sa, eth_sec->inb, len); - if (rc) - return rc; + if (eth_sec) + sa = eth_sec->sa; + else + sa = sess; - return 0; + return roc_nix_inl_ctx_write(&dev->nix, data, sa, inb, len); } union rte_pmd_cnxk_cpt_res_s * diff --git a/drivers/net/cnxk/rte_pmd_cnxk.h b/drivers/net/cnxk/rte_pmd_cnxk.h index 70f2f96fd4..ecd112e881 100644 --- a/drivers/net/cnxk/rte_pmd_cnxk.h +++ b/drivers/net/cnxk/rte_pmd_cnxk.h @@ -492,7 +492,7 @@ union rte_pmd_cnxk_cpt_res_s { /** * Read HW SA context from session. * - * @param device + * @param portid * Port identifier of Ethernet device. * @param sess * Handle of the security session as void *. @@ -500,17 +500,19 @@ union rte_pmd_cnxk_cpt_res_s { * Destination pointer to copy SA context for application. * @param len * Length of SA context to copy into data parameter. + * @param inb + * Determines the type of specified SA. * * @return * 0 on success, a negative errno value otherwise. */ __rte_experimental -int rte_pmd_cnxk_hw_sa_read(void *device, void *sess, - union rte_pmd_cnxk_ipsec_hw_sa *data, uint32_t len); +int rte_pmd_cnxk_hw_sa_read(uint16_t portid, void *sess, union rte_pmd_cnxk_ipsec_hw_sa *data, + uint32_t len, bool inb); /** * Write HW SA context to session. * - * @param device + * @param portid * Port identifier of Ethernet device. * @param sess * Handle of the security session as void *. @@ -518,13 +520,15 @@ int rte_pmd_cnxk_hw_sa_read(void *device, void *sess, * Source data pointer from application to copy SA context into session. * @param len * Length of SA context to copy from data parameter. + * @param inb + * Determines the type of specified SA. * * @return * 0 on success, a negative errno value otherwise. */ __rte_experimental -int rte_pmd_cnxk_hw_sa_write(void *device, void *sess, - union rte_pmd_cnxk_ipsec_hw_sa *data, uint32_t len); +int rte_pmd_cnxk_hw_sa_write(uint16_t portid, void *sess, union rte_pmd_cnxk_ipsec_hw_sa *data, + uint32_t len, bool inb); /** * Get pointer to CPT result info for inline inbound processed pkt. @@ -542,4 +546,36 @@ int rte_pmd_cnxk_hw_sa_write(void *device, void *sess, */ __rte_experimental union rte_pmd_cnxk_cpt_res_s *rte_pmd_cnxk_inl_ipsec_res(struct rte_mbuf *mbuf); + +/** + * Get pointer to the Inline Inbound or Outbound SA table base. + * + * @param portid + * Port identifier of Ethernet device. + * @param inb + * Determines the type of SA base to be returned. + * When inb is true, the method returns the Inbound SA base. + * When inb is false, the method returns the Outbound SA base. + * + * @return + * Pointer to Inbound or Outbound SA base. + */ +__rte_experimental +union rte_pmd_cnxk_ipsec_hw_sa *rte_pmd_cnxk_hw_session_base_get(uint16_t portid, bool inb); + +/** + * Executes a CPT flush on the specified session. + * + * @param portid + * Port identifier of Ethernet device. + * @param sess + * Handle of the session on which the CPT flush will be executed. + * @param inb + * Determines the type of SA to be flushed, Inbound or Outbound. + * + * @return + * 0 upon success, a negative errno value otherwise. + */ +__rte_experimental +int rte_pmd_cnxk_sa_flush(uint16_t portid, union rte_pmd_cnxk_ipsec_hw_sa *sess, bool inb); #endif /* _PMD_CNXK_H_ */ diff --git a/drivers/net/cnxk/version.map b/drivers/net/cnxk/version.map index 1ad0616bdf..7e8703df5c 100644 --- a/drivers/net/cnxk/version.map +++ b/drivers/net/cnxk/version.map @@ -10,7 +10,9 @@ EXPERIMENTAL { rte_pmd_cnxk_hw_sa_write; # added in 23.11 + rte_pmd_cnxk_hw_session_base_get; rte_pmd_cnxk_inl_ipsec_res; + rte_pmd_cnxk_sa_flush; }; INTERNAL { -- 2.34.1