From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 55B60A0524;
	Fri, 31 Jan 2020 11:06:28 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 121891C135;
	Fri, 31 Jan 2020 11:05:23 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id B4B8E1BF83
 for <dev@dpdk.org>; Fri, 31 Jan 2020 11:05:17 +0100 (CET)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id
 00VA0XG4014373; Fri, 31 Jan 2020 02:05:17 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0818;
 bh=6kxfI5q8l3niTH+SELtYAJePizZG7KD/OGNO09KRq/s=;
 b=MNBLzuvzXE8/VFHYY4zHNCRxFxTi7Tw8GrJWNMZj/hcicoqs9LIvlI6HNBus/+gK1dLf
 YfZOEM0nwdoSX8RhFU6Gdv+9Jrf/sZpmPkRT+O+9gasZhQNTwlpFDPvXu5N4PMLNCx3f
 CAVTgaYu8KrsJqbnN2R/eso2f7GkjhVarYoR3hijZD8Bv3xp2fovZhShwHTDudoBYp77
 b8Vrg7dQsO8Ri/b5psSIRSevCNzRBN/0Z9D0fbdezVM8Ckv+xUWUyljzhaA2U0f27hN5
 mNQEhSi2QQWYx6kOwaLnhBdbqL4dvS7LhbtMlVRHxvD8cjNVKmJbjEbusl2Gdbr8SVrl hg== 
Received: from sc-exch01.marvell.com ([199.233.58.181])
 by mx0a-0016f401.pphosted.com with ESMTP id 2xupkhxx4u-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Fri, 31 Jan 2020 02:05:16 -0800
Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com
 (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 31 Jan
 2020 02:05:15 -0800
Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com
 (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
 Transport; Fri, 31 Jan 2020 02:05:15 -0800
Received: from ajoseph83.caveonetworks.com (unknown [10.29.45.60])
 by maili.marvell.com (Postfix) with ESMTP id 22E1E3F703F;
 Fri, 31 Jan 2020 02:05:10 -0800 (PST)
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <akhil.goyal@nxp.com>, Declan Doherty
 <declan.doherty@intel.com>, Thomas Monjalon <thomas@monjalon.net>
CC: Archana Muniganti <marchana@marvell.com>, Jerin Jacob <jerinj@marvell.com>,
 Narayana Prasad <pathreya@marvell.com>, Kiran Kumar K
 <kirankumark@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>,
 "Pavan Nikhilesh" <pbhagavatula@marvell.com>, Ankur Dwivedi
 <adwivedi@marvell.com>, Anoob Joseph <anoobj@marvell.com>, Tejasree Kondoj
 <ktejasree@marvell.com>, Vamsi Attunuru <vattunuru@marvell.com>, Lukasz
 Bartosik <lbartosik@marvell.com>, <dev@dpdk.org>
Date: Fri, 31 Jan 2020 15:33:50 +0530
Message-ID: <1580465035-30455-11-git-send-email-anoobj@marvell.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1580465035-30455-1-git-send-email-anoobj@marvell.com>
References: <1579344553-11428-1-git-send-email-anoobj@marvell.com>
 <1580465035-30455-1-git-send-email-anoobj@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572
 definitions=2020-01-31_02:2020-01-30,
 2020-01-31 signatures=0
Subject: [dpdk-dev] [PATCH v3 10/15] net/octeontx2: add lookup mem changes
	to hold sa indices
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Archana Muniganti <marchana@marvell.com>

lookup_mem provides fast accessing of data path fields.
Storing sa indices in lookup_mem which are required in
inline rx data path.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Signed-off-by: Anoob Joseph <anoobj@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/common/octeontx2/otx2_common.h  |  4 +++
 drivers/net/octeontx2/otx2_ethdev_sec.c | 59 +++++++++++++++++++++++++++++++++
 drivers/net/octeontx2/otx2_lookup.c     | 11 ++++--
 3 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
index 81d5a71..bf5ea86 100644
--- a/drivers/common/octeontx2/otx2_common.h
+++ b/drivers/common/octeontx2/otx2_common.h
@@ -155,4 +155,8 @@ extern int otx2_logtype_ep;
 #include "otx2_io_generic.h"
 #endif
 
+/* Fastpath lookup */
+#define OTX2_NIX_FASTPATH_LOOKUP_MEM	"otx2_nix_fastpath_lookup_mem"
+#define OTX2_NIX_SA_TBL_START		(4096*4 + 69632*2)
+
 #endif /* _OTX2_COMMON_H_ */
diff --git a/drivers/net/octeontx2/otx2_ethdev_sec.c b/drivers/net/octeontx2/otx2_ethdev_sec.c
index e61d383..4b219b3 100644
--- a/drivers/net/octeontx2/otx2_ethdev_sec.c
+++ b/drivers/net/octeontx2/otx2_ethdev_sec.c
@@ -10,6 +10,7 @@
 #include <rte_security.h>
 #include <rte_security_driver.h>
 
+#include "otx2_common.h"
 #include "otx2_cryptodev_qp.h"
 #include "otx2_ethdev.h"
 #include "otx2_ethdev_sec.h"
@@ -135,6 +136,59 @@ static const struct rte_security_capability otx2_eth_sec_capabilities[] = {
 	}
 };
 
+static void
+lookup_mem_sa_tbl_clear(struct rte_eth_dev *eth_dev)
+{
+	static const char name[] = OTX2_NIX_FASTPATH_LOOKUP_MEM;
+	uint16_t port = eth_dev->data->port_id;
+	const struct rte_memzone *mz;
+	uint64_t **sa_tbl;
+	uint8_t *mem;
+
+	mz = rte_memzone_lookup(name);
+	if (mz == NULL)
+		return;
+
+	mem = mz->addr;
+
+	sa_tbl  = (uint64_t **)RTE_PTR_ADD(mem, OTX2_NIX_SA_TBL_START);
+	if (sa_tbl[port] == NULL)
+		return;
+
+	rte_free(sa_tbl[port]);
+	sa_tbl[port] = NULL;
+}
+
+static int
+lookup_mem_sa_index_update(struct rte_eth_dev *eth_dev, int spi, void *sa)
+{
+	static const char name[] = OTX2_NIX_FASTPATH_LOOKUP_MEM;
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	uint16_t port = eth_dev->data->port_id;
+	const struct rte_memzone *mz;
+	uint64_t **sa_tbl;
+	uint8_t *mem;
+
+	mz = rte_memzone_lookup(name);
+	if (mz == NULL) {
+		otx2_err("Could not find fastpath lookup table");
+		return -EINVAL;
+	}
+
+	mem = mz->addr;
+
+	sa_tbl = (uint64_t **)RTE_PTR_ADD(mem, OTX2_NIX_SA_TBL_START);
+
+	if (sa_tbl[port] == NULL) {
+		sa_tbl[port] = rte_malloc(NULL, dev->ipsec_in_max_spi *
+					  sizeof(uint64_t), 0);
+	}
+
+	sa_tbl[port][spi] = (uint64_t)sa;
+
+	return 0;
+}
+
 static inline void
 in_sa_mz_name_get(char *name, int size, uint16_t port)
 {
@@ -393,6 +447,9 @@ eth_sec_ipsec_in_sess_create(struct rte_eth_dev *eth_dev,
 
 	sa->userdata = priv->userdata;
 
+	if (lookup_mem_sa_index_update(eth_dev, ipsec->spi, sa))
+		return -EINVAL;
+
 	ret = ipsec_fp_sa_ctl_set(ipsec, crypto_xform, ctl);
 	if (ret)
 		return ret;
@@ -670,6 +727,8 @@ otx2_eth_sec_fini(struct rte_eth_dev *eth_dev)
 	    !(dev->rx_offloads & DEV_RX_OFFLOAD_SECURITY))
 		return;
 
+	lookup_mem_sa_tbl_clear(eth_dev);
+
 	in_sa_mz_name_get(name, RTE_MEMZONE_NAMESIZE, port);
 	rte_memzone_free(rte_memzone_lookup(name));
 }
diff --git a/drivers/net/octeontx2/otx2_lookup.c b/drivers/net/octeontx2/otx2_lookup.c
index 5685571..89365ff 100644
--- a/drivers/net/octeontx2/otx2_lookup.c
+++ b/drivers/net/octeontx2/otx2_lookup.c
@@ -5,6 +5,7 @@
 #include <rte_common.h>
 #include <rte_memzone.h>
 
+#include "otx2_common.h"
 #include "otx2_ethdev.h"
 
 /* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
@@ -12,7 +13,9 @@
 #define ERR_ARRAY_SZ			((BIT(ERRCODE_ERRLEN_WIDTH)) *\
 					sizeof(uint32_t))
 
-#define LOOKUP_ARRAY_SZ			(PTYPE_ARRAY_SZ + ERR_ARRAY_SZ)
+#define SA_TBL_SZ			(RTE_MAX_ETHPORTS * sizeof(uint64_t))
+#define LOOKUP_ARRAY_SZ			(PTYPE_ARRAY_SZ + ERR_ARRAY_SZ +\
+					SA_TBL_SZ)
 
 const uint32_t *
 otx2_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev)
@@ -311,10 +314,14 @@ nix_create_rx_ol_flags_array(void *mem)
 void *
 otx2_nix_fastpath_lookup_mem_get(void)
 {
-	const char name[] = "otx2_nix_fastpath_lookup_mem";
+	const char name[] = OTX2_NIX_FASTPATH_LOOKUP_MEM;
 	const struct rte_memzone *mz;
 	void *mem;
 
+	/* SA_TBL starts after PTYPE_ARRAY & ERR_ARRAY */
+	RTE_BUILD_BUG_ON(OTX2_NIX_SA_TBL_START != (PTYPE_ARRAY_SZ +
+						   ERR_ARRAY_SZ));
+
 	mz = rte_memzone_lookup(name);
 	if (mz != NULL)
 		return mz->addr;
-- 
2.7.4