[10/15] crypto/octeontx2: add lookup mem changes to hold sa indices
diff mbox series

Message ID 1575806094-28391-11-git-send-email-anoobj@marvell.com
State Superseded, archived
Delegated to: akhil goyal
Headers show
Series
  • add OCTEONTX2 inline IPsec support
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Anoob Joseph Dec. 8, 2019, 11:54 a.m. UTC
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   | 20 +++++++++++
 drivers/crypto/octeontx2/otx2_security.c | 59 +++++++++++++++++++++++++++++++-
 drivers/net/octeontx2/otx2_lookup.c      |  9 +----
 drivers/net/octeontx2/otx2_rx.h          | 10 ++----
 4 files changed, 81 insertions(+), 17 deletions(-)

Comments

Jerin Jacob Dec. 9, 2019, 8:02 a.m. UTC | #1
On Sun, Dec 8, 2019 at 5:27 PM Anoob Joseph <anoobj@marvell.com> wrote:
>
> 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   | 20 +++++++++++
>  drivers/crypto/octeontx2/otx2_security.c | 59 +++++++++++++++++++++++++++++++-
>  drivers/net/octeontx2/otx2_lookup.c      |  9 +----
>  drivers/net/octeontx2/otx2_rx.h          | 10 ++----
>  4 files changed, 81 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
> index 9705a8d..6456c4b 100644
> --- a/drivers/common/octeontx2/otx2_common.h
> +++ b/drivers/common/octeontx2/otx2_common.h
> @@ -170,4 +170,24 @@ extern int otx2_logtype_dpi;
>  #include "otx2_io_generic.h"
>  #endif
>
> +/* Fastpath lookup */
> +#define OTX2_NIX_FASTPATH_LOOKUP_MEM "otx2_nix_fastpath_lookup_mem"
> +#define PTYPE_NON_TUNNEL_WIDTH         16
> +#define PTYPE_TUNNEL_WIDTH             12
> +#define PTYPE_NON_TUNNEL_ARRAY_SZ      BIT(PTYPE_NON_TUNNEL_WIDTH)
> +#define PTYPE_TUNNEL_ARRAY_SZ          BIT(PTYPE_TUNNEL_WIDTH)
> +#define PTYPE_ARRAY_SZ                 ((PTYPE_NON_TUNNEL_ARRAY_SZ +\
> +                                        PTYPE_TUNNEL_ARRAY_SZ) *\
> +                                        sizeof(uint16_t))
> +
> +/* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
> +#define ERRCODE_ERRLEN_WIDTH           12
> +#define ERR_ARRAY_SZ                   ((BIT(ERRCODE_ERRLEN_WIDTH)) *\
> +                                       sizeof(uint32_t))
> +
> +#define PORT_ARRAY_SZ                  (RTE_MAX_ETHPORTS * sizeof(uint64_t))
> +
> +#define LOOKUP_ARRAY_SZ                        (PTYPE_ARRAY_SZ + ERR_ARRAY_SZ +\
> +                                       PORT_ARRAY_SZ)
> +

All these defines are not relevant to common code, But I understand
the security code needs
PORT_ARRAY_START

Please rector the logic to the following or similar way to keep the
lookup constants internal.

#define OTX2_PORT_ARRAY_START value

in otx2_nix_fastpath_lookup_mem_get()

RTE_BUILD_BUG_ON(OTX2_PORT_ARRAY_START != PTYPE_ARRAY_SZ + ERR_ARRAY_SZ)
Anoob Joseph Dec. 13, 2019, 7:12 a.m. UTC | #2
Hi Jerin,

Please see inline.

Thanks,
Anoob

> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Monday, December 9, 2019 1:32 PM
> To: Anoob Joseph <anoobj@marvell.com>
> Cc: Akhil Goyal <akhil.goyal@nxp.com>; Declan Doherty
> <declan.doherty@intel.com>; Thomas Monjalon <thomas@monjalon.net>;
> Archana Muniganti <marchana@marvell.com>; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Narayana Prasad Raju Athreya
> <pathreya@marvell.com>; Kiran Kumar Kokkilagadda
> <kirankumark@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Pavan Nikhilesh Bhagavatula
> <pbhagavatula@marvell.com>; Ankur Dwivedi <adwivedi@marvell.com>;
> Tejasree Kondoj <ktejasree@marvell.com>; Vamsi Krishna Attunuru
> <vattunuru@marvell.com>; Lukas Bartosik <lbartosik@marvell.com>; dpdk-
> dev <dev@dpdk.org>
> Subject: [EXT] Re: [dpdk-dev] [PATCH 10/15] crypto/octeontx2: add lookup
> mem changes to hold sa indices
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Sun, Dec 8, 2019 at 5:27 PM Anoob Joseph <anoobj@marvell.com> wrote:
> >
> > 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   | 20 +++++++++++
> >  drivers/crypto/octeontx2/otx2_security.c | 59
> +++++++++++++++++++++++++++++++-
> >  drivers/net/octeontx2/otx2_lookup.c      |  9 +----
> >  drivers/net/octeontx2/otx2_rx.h          | 10 ++----
> >  4 files changed, 81 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/common/octeontx2/otx2_common.h
> > b/drivers/common/octeontx2/otx2_common.h
> > index 9705a8d..6456c4b 100644
> > --- a/drivers/common/octeontx2/otx2_common.h
> > +++ b/drivers/common/octeontx2/otx2_common.h
> > @@ -170,4 +170,24 @@ extern int otx2_logtype_dpi;  #include
> > "otx2_io_generic.h"
> >  #endif
> >
> > +/* Fastpath lookup */
> > +#define OTX2_NIX_FASTPATH_LOOKUP_MEM
> "otx2_nix_fastpath_lookup_mem"
> > +#define PTYPE_NON_TUNNEL_WIDTH         16
> > +#define PTYPE_TUNNEL_WIDTH             12
> > +#define PTYPE_NON_TUNNEL_ARRAY_SZ
> BIT(PTYPE_NON_TUNNEL_WIDTH)
> > +#define PTYPE_TUNNEL_ARRAY_SZ          BIT(PTYPE_TUNNEL_WIDTH)
> > +#define PTYPE_ARRAY_SZ                 ((PTYPE_NON_TUNNEL_ARRAY_SZ +\
> > +                                        PTYPE_TUNNEL_ARRAY_SZ) *\
> > +                                        sizeof(uint16_t))
> > +
> > +/* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
> > +#define ERRCODE_ERRLEN_WIDTH           12
> > +#define ERR_ARRAY_SZ                   ((BIT(ERRCODE_ERRLEN_WIDTH)) *\
> > +                                       sizeof(uint32_t))
> > +
> > +#define PORT_ARRAY_SZ                  (RTE_MAX_ETHPORTS *
> sizeof(uint64_t))
> > +
> > +#define LOOKUP_ARRAY_SZ                        (PTYPE_ARRAY_SZ +
> ERR_ARRAY_SZ +\
> > +                                       PORT_ARRAY_SZ)
> > +
> 
> All these defines are not relevant to common code, But I understand the
> security code needs PORT_ARRAY_START
> 
> Please rector the logic to the following or similar way to keep the lookup
> constants internal.
> 
> #define OTX2_PORT_ARRAY_START value
> 
> in otx2_nix_fastpath_lookup_mem_get()
> 
> RTE_BUILD_BUG_ON(OTX2_PORT_ARRAY_START != PTYPE_ARRAY_SZ +
> ERR_ARRAY_SZ)

[Anoob] Will make this change in v2.

Patch
diff mbox series

diff --git a/drivers/common/octeontx2/otx2_common.h b/drivers/common/octeontx2/otx2_common.h
index 9705a8d..6456c4b 100644
--- a/drivers/common/octeontx2/otx2_common.h
+++ b/drivers/common/octeontx2/otx2_common.h
@@ -170,4 +170,24 @@  extern int otx2_logtype_dpi;
 #include "otx2_io_generic.h"
 #endif
 
+/* Fastpath lookup */
+#define OTX2_NIX_FASTPATH_LOOKUP_MEM "otx2_nix_fastpath_lookup_mem"
+#define PTYPE_NON_TUNNEL_WIDTH		16
+#define PTYPE_TUNNEL_WIDTH		12
+#define PTYPE_NON_TUNNEL_ARRAY_SZ	BIT(PTYPE_NON_TUNNEL_WIDTH)
+#define PTYPE_TUNNEL_ARRAY_SZ		BIT(PTYPE_TUNNEL_WIDTH)
+#define PTYPE_ARRAY_SZ			((PTYPE_NON_TUNNEL_ARRAY_SZ +\
+					 PTYPE_TUNNEL_ARRAY_SZ) *\
+					 sizeof(uint16_t))
+
+/* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
+#define ERRCODE_ERRLEN_WIDTH		12
+#define ERR_ARRAY_SZ			((BIT(ERRCODE_ERRLEN_WIDTH)) *\
+					sizeof(uint32_t))
+
+#define PORT_ARRAY_SZ			(RTE_MAX_ETHPORTS * sizeof(uint64_t))
+
+#define LOOKUP_ARRAY_SZ			(PTYPE_ARRAY_SZ + ERR_ARRAY_SZ +\
+					PORT_ARRAY_SZ)
+
 #endif /* _OTX2_COMMON_H_ */
diff --git a/drivers/crypto/octeontx2/otx2_security.c b/drivers/crypto/octeontx2/otx2_security.c
index 545c806..4d762d9 100644
--- a/drivers/crypto/octeontx2/otx2_security.c
+++ b/drivers/crypto/octeontx2/otx2_security.c
@@ -136,6 +136,59 @@  static const struct rte_security_capability otx2_sec_eth_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 **)(mem + PTYPE_ARRAY_SZ + ERR_ARRAY_SZ);
+	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 **)(mem + PTYPE_ARRAY_SZ + ERR_ARRAY_SZ);
+
+	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 int
 otx2_sec_eth_tx_cpt_qp_get(uint16_t port_id, struct otx2_cpt_qp **qp)
 {
@@ -383,8 +436,10 @@  sec_eth_ipsec_in_sess_create(struct rte_eth_dev *eth_dev,
 
 	sa->userdata = priv->userdata;
 
-	return ipsec_fp_sa_ctl_set(ipsec, crypto_xform, ctl);
+	if (lookup_mem_sa_index_update(eth_dev, ipsec->spi, sa))
+		return -EINVAL;
 
+	return ipsec_fp_sa_ctl_set(ipsec, crypto_xform, ctl);
 }
 
 static int
@@ -667,6 +722,8 @@  otx2_sec_eth_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 bcf2ff4..46fdbc8 100644
--- a/drivers/net/octeontx2/otx2_lookup.c
+++ b/drivers/net/octeontx2/otx2_lookup.c
@@ -7,13 +7,6 @@ 
 
 #include "otx2_ethdev.h"
 
-/* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */
-#define ERRCODE_ERRLEN_WIDTH		12
-#define ERR_ARRAY_SZ			((BIT(ERRCODE_ERRLEN_WIDTH)) *\
-					sizeof(uint32_t))
-
-#define LOOKUP_ARRAY_SZ			(PTYPE_ARRAY_SZ + ERR_ARRAY_SZ)
-
 const uint32_t *
 otx2_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev)
 {
@@ -314,7 +307,7 @@  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;
 
diff --git a/drivers/net/octeontx2/otx2_rx.h b/drivers/net/octeontx2/otx2_rx.h
index 351ad0f..5e1d5a2 100644
--- a/drivers/net/octeontx2/otx2_rx.h
+++ b/drivers/net/octeontx2/otx2_rx.h
@@ -5,17 +5,11 @@ 
 #ifndef __OTX2_RX_H__
 #define __OTX2_RX_H__
 
+#include "otx2_common.h"
+
 /* Default mark value used when none is provided. */
 #define OTX2_FLOW_ACTION_FLAG_DEFAULT	0xffff
 
-#define PTYPE_NON_TUNNEL_WIDTH		16
-#define PTYPE_TUNNEL_WIDTH		12
-#define PTYPE_NON_TUNNEL_ARRAY_SZ	BIT(PTYPE_NON_TUNNEL_WIDTH)
-#define PTYPE_TUNNEL_ARRAY_SZ		BIT(PTYPE_TUNNEL_WIDTH)
-#define PTYPE_ARRAY_SZ			((PTYPE_NON_TUNNEL_ARRAY_SZ +\
-					 PTYPE_TUNNEL_ARRAY_SZ) *\
-					 sizeof(uint16_t))
-
 #define NIX_RX_OFFLOAD_NONE            (0)
 #define NIX_RX_OFFLOAD_RSS_F           BIT(0)
 #define NIX_RX_OFFLOAD_PTYPE_F         BIT(1)