#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"
}
};
+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)
{
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;
return sizeof(struct otx2_sec_session);
}
+static int
+otx2_eth_sec_set_pkt_mdata(void *device __rte_unused,
+ struct rte_security_session *session,
+ struct rte_mbuf *m, void *params __rte_unused)
+{
+ /* Set security session as the pkt metadata */
+ m->udata64 = (uint64_t)session;
+
+ return 0;
+}
+
+static int
+otx2_eth_sec_get_userdata(void *device __rte_unused, uint64_t md,
+ void **userdata)
+{
+ /* Retrieve userdata */
+ *userdata = (void *)md;
+
+ return 0;
+}
+
static const struct rte_security_capability *
otx2_eth_sec_capabilities_get(void *device __rte_unused)
{
.session_create = otx2_eth_sec_session_create,
.session_destroy = otx2_eth_sec_session_destroy,
.session_get_size = otx2_eth_sec_session_get_size,
+ .set_pkt_metadata = otx2_eth_sec_set_pkt_mdata,
+ .get_userdata = otx2_eth_sec_get_userdata,
.capabilities_get = otx2_eth_sec_capabilities_get
};
!(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));
}