net/ngbe: support MAC filters
[dpdk.git] / drivers / net / octeontx2 / otx2_ethdev_sec.c
index 72298cf..4d40184 100644 (file)
@@ -455,6 +455,9 @@ eth_sec_ipsec_out_sess_create(struct rte_eth_dev *eth_dev,
                        goto cpt_put;
        }
 
+       rte_io_wmb();
+       ctl->valid = 1;
+
        return 0;
 cpt_put:
        otx2_sec_idev_tx_cpt_qp_put(sess->qp);
@@ -595,6 +598,9 @@ eth_sec_ipsec_in_sess_create(struct rte_eth_dev *eth_dev,
                sa->esn_hi = 0;
        }
 
+       rte_io_wmb();
+       ctl->valid = 1;
+
        rte_spinlock_unlock(&dev->ipsec_tbl_lock);
        return 0;
 
@@ -682,10 +688,12 @@ otx2_eth_sec_free_anti_replay(struct otx2_ipsec_fp_in_sa *sa)
 }
 
 static int
-otx2_eth_sec_session_destroy(void *device __rte_unused,
+otx2_eth_sec_session_destroy(void *device,
                             struct rte_security_session *sess)
 {
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(device);
        struct otx2_sec_session_ipsec_ip *sess_ip;
+       struct otx2_ipsec_fp_in_sa *sa;
        struct otx2_sec_session *priv;
        struct rte_mempool *sess_mp;
        int ret;
@@ -696,9 +704,21 @@ otx2_eth_sec_session_destroy(void *device __rte_unused,
 
        sess_ip = &priv->ipsec.ip;
 
-       /* Release the anti replay window */
-       if (priv->ipsec.dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS)
-               otx2_eth_sec_free_anti_replay(sess_ip->in_sa);
+       if (priv->ipsec.dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
+               rte_spinlock_lock(&dev->ipsec_tbl_lock);
+               sa = sess_ip->in_sa;
+
+               /* Release the anti replay window */
+               otx2_eth_sec_free_anti_replay(sa);
+
+               /* Clear SA table entry */
+               if (sa != NULL) {
+                       sa->ctl.valid = 0;
+                       rte_io_wmb();
+               }
+
+               rte_spinlock_unlock(&dev->ipsec_tbl_lock);
+       }
 
        /* Release CPT LF used for this session */
        if (sess_ip->qp != NULL) {
@@ -721,27 +741,6 @@ otx2_eth_sec_session_get_size(void *device __rte_unused)
        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 */
-       *rte_security_dynfield(m) = (rte_security_dynfield_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)
 {
@@ -752,8 +751,6 @@ static struct rte_security_ops otx2_eth_sec_ops = {
        .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
 };
 
@@ -779,6 +776,8 @@ otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev)
        ctx->device = eth_dev;
        ctx->ops = &otx2_eth_sec_ops;
        ctx->sess_cnt = 0;
+       ctx->flags =
+               (RTE_SEC_CTX_F_FAST_SET_MDATA | RTE_SEC_CTX_F_FAST_GET_UDATA);
 
        eth_dev->security_ctx = ctx;
 
@@ -870,8 +869,8 @@ otx2_eth_sec_init(struct rte_eth_dev *eth_dev)
        RTE_BUILD_BUG_ON(sa_width < 32 || sa_width > 512 ||
                         !RTE_IS_POWER_OF_2(sa_width));
 
-       if (!(dev->tx_offloads & DEV_TX_OFFLOAD_SECURITY) &&
-           !(dev->rx_offloads & DEV_RX_OFFLOAD_SECURITY))
+       if (!(dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) &&
+           !(dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY))
                return 0;
 
        if (rte_security_dynfield_register() < 0)
@@ -913,8 +912,8 @@ otx2_eth_sec_fini(struct rte_eth_dev *eth_dev)
        uint16_t port = eth_dev->data->port_id;
        char name[RTE_MEMZONE_NAMESIZE];
 
-       if (!(dev->tx_offloads & DEV_TX_OFFLOAD_SECURITY) &&
-           !(dev->rx_offloads & DEV_RX_OFFLOAD_SECURITY))
+       if (!(dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) &&
+           !(dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY))
                return;
 
        lookup_mem_sa_tbl_clear(eth_dev);