log: introduce logtype register macro
[dpdk.git] / drivers / net / octeontx2 / otx2_flow.c
index 3ddecfb..13a76e4 100644 (file)
@@ -3,6 +3,7 @@
  */
 
 #include "otx2_ethdev.h"
+#include "otx2_ethdev_sec.h"
 #include "otx2_flow.h"
 
 int
@@ -299,6 +300,21 @@ flow_free_rss_action(struct rte_eth_dev *eth_dev,
        return 0;
 }
 
+static int
+flow_update_sec_tt(struct rte_eth_dev *eth_dev,
+                  const struct rte_flow_action actions[])
+{
+       int rc = 0;
+
+       for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+               if (actions->type == RTE_FLOW_ACTION_TYPE_SECURITY) {
+                       rc = otx2_eth_sec_update_tag_type(eth_dev);
+                       break;
+               }
+       }
+
+       return rc;
+}
 
 static int
 flow_parse_meta_items(__rte_unused struct otx2_parse_state *pst)
@@ -325,6 +341,7 @@ flow_parse_pattern(struct rte_eth_dev *dev,
 {
        flow_parse_stage_func_t parse_stage_funcs[] = {
                flow_parse_meta_items,
+               otx2_flow_parse_higig2_hdr,
                otx2_flow_parse_la,
                otx2_flow_parse_lb,
                otx2_flow_parse_lc,
@@ -490,6 +507,16 @@ otx2_flow_create(struct rte_eth_dev *dev,
                goto err_exit;
        }
 
+       if (hw->rx_offloads & DEV_RX_OFFLOAD_SECURITY) {
+               rc = flow_update_sec_tt(dev, actions);
+               if (rc != 0) {
+                       rte_flow_error_set(error, EIO,
+                                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                          NULL,
+                                          "Failed to update tt with sec act");
+                       goto err_exit;
+               }
+       }
 
        list = &hw->npc_flow.flow_list[flow->priority];
        /* List in ascending order of mcam entries */
@@ -528,8 +555,10 @@ otx2_flow_destroy(struct rte_eth_dev *dev,
                        return -EINVAL;
 
                /* Clear mark offload flag if there are no more mark actions */
-               if (rte_atomic32_sub_return(&npc->mark_actions, 1) == 0)
+               if (rte_atomic32_sub_return(&npc->mark_actions, 1) == 0) {
                        hw->rx_offload_flags &= ~NIX_RX_OFFLOAD_MARK_UPDATE_F;
+                       otx2_eth_set_rx_function(dev);
+               }
        }
 
        rc = flow_free_rss_action(dev, flow);
@@ -682,6 +711,7 @@ flow_update_kex_info(struct npc_xtract_info *xtract_info,
        xtract_info->hdr_off = (val >> HDR_OFF_SHIFT) & 0xff;
        xtract_info->key_off = val & 0x3f;
        xtract_info->enable = ((val >> 7) & 0x1);
+       xtract_info->flags_enable = ((val >> 6) & 0x1);
 }
 
 static void
@@ -841,7 +871,7 @@ otx2_flow_init(struct otx2_eth_dev *hw)
        }
 
        npc->free_entries = rte_zmalloc(NULL, npc->flow_max_priority
-                                       * sizeof(struct rte_bitmap),
+                                       * sizeof(struct rte_bitmap *),
                                        0);
        if (npc->free_entries == NULL) {
                otx2_err("free_entries alloc failed");
@@ -850,7 +880,7 @@ otx2_flow_init(struct otx2_eth_dev *hw)
        }
 
        npc->free_entries_rev = rte_zmalloc(NULL, npc->flow_max_priority
-                                       * sizeof(struct rte_bitmap),
+                                       * sizeof(struct rte_bitmap *),
                                        0);
        if (npc->free_entries_rev == NULL) {
                otx2_err("free_entries_rev alloc failed");
@@ -859,7 +889,7 @@ otx2_flow_init(struct otx2_eth_dev *hw)
        }
 
        npc->live_entries = rte_zmalloc(NULL, npc->flow_max_priority
-                                       * sizeof(struct rte_bitmap),
+                                       * sizeof(struct rte_bitmap *),
                                        0);
        if (npc->live_entries == NULL) {
                otx2_err("live_entries alloc failed");
@@ -868,7 +898,7 @@ otx2_flow_init(struct otx2_eth_dev *hw)
        }
 
        npc->live_entries_rev = rte_zmalloc(NULL, npc->flow_max_priority
-                                       * sizeof(struct rte_bitmap),
+                                       * sizeof(struct rte_bitmap *),
                                        0);
        if (npc->live_entries_rev == NULL) {
                otx2_err("live_entries_rev alloc failed");
@@ -945,8 +975,6 @@ err:
                rte_free(npc->flow_entry_info);
        if (npc_mem)
                rte_free(npc_mem);
-       if (nix_mem)
-               rte_free(nix_mem);
        return rc;
 }