net/octeontx2: add lookup mem changes to hold SA indices
authorArchana Muniganti <marchana@marvell.com>
Tue, 4 Feb 2020 11:17:20 +0000 (16:47 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 5 Feb 2020 14:20:51 +0000 (15:20 +0100)
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>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/common/octeontx2/otx2_common.h
drivers/net/octeontx2/otx2_ethdev_sec.c
drivers/net/octeontx2/otx2_lookup.c

index 81d5a71..bf5ea86 100644 (file)
@@ -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_ */
index e61d383..4b219b3 100644 (file)
@@ -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));
 }
index 5685571..89365ff 100644 (file)
@@ -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;