net/bnxt: add Truflow flush-timer to alloc table scope
[dpdk.git] / drivers / net / ice / ice_fdir_filter.c
index 6b10491..1a85d6c 100644 (file)
        ICE_FDIR_INSET_VXLAN_IPV4 | \
        ICE_INSET_TUN_SCTP_SRC_PORT | ICE_INSET_TUN_SCTP_DST_PORT)
 
-#define ICE_FDIR_INSET_GTPU_IPV4 (\
+#define ICE_FDIR_INSET_GTPU (\
+       ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | ICE_INSET_GTPU_TEID)
+
+#define ICE_FDIR_INSET_GTPU_EH (\
+       ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \
        ICE_INSET_GTPU_TEID | ICE_INSET_GTPU_QFI)
 
 static struct ice_pattern_match_item ice_fdir_pattern_os[] = {
@@ -122,12 +126,16 @@ static struct ice_pattern_match_item ice_fdir_pattern_comms[] = {
                                       ICE_FDIR_INSET_VXLAN_IPV4_TCP,        ICE_INSET_NONE},
        {pattern_eth_ipv4_udp_vxlan_eth_ipv4_sctp,
                                       ICE_FDIR_INSET_VXLAN_IPV4_SCTP,       ICE_INSET_NONE},
-       {pattern_eth_ipv4_gtpu_ipv4,   ICE_FDIR_INSET_GTPU_IPV4,             ICE_INSET_NONE},
+       {pattern_eth_ipv4_gtpu,        ICE_FDIR_INSET_GTPU,                  ICE_INSET_NONE},
+       {pattern_eth_ipv4_gtpu_eh,     ICE_FDIR_INSET_GTPU_EH,               ICE_INSET_NONE},
 };
 
 static struct ice_flow_parser ice_fdir_parser_os;
 static struct ice_flow_parser ice_fdir_parser_comms;
 
+static int
+ice_fdir_is_tunnel_profile(enum ice_fdir_tunnel_type tunnel_type);
+
 static const struct rte_memzone *
 ice_memzone_reserve(const char *name, uint32_t len, int socket_id)
 {
@@ -576,7 +584,7 @@ ice_fdir_prof_rm(struct ice_pf *pf, enum ice_fltr_ptype ptype, bool is_tunnel)
                                                     hw_prof->vsi_h[i]);
                        ice_rem_prof_id_flow(hw, ICE_BLK_FD,
                                             vsi_num, ptype);
-                       ice_flow_rem_entry(hw,
+                       ice_flow_rem_entry(hw, ICE_BLK_FD,
                                           hw_prof->entry_h[i][is_tunnel]);
                        hw_prof->entry_h[i][is_tunnel] = 0;
                }
@@ -868,7 +876,7 @@ ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi,
 err_add_entry:
        vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
        ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
-       ice_flow_rem_entry(hw, entry_1);
+       ice_flow_rem_entry(hw, ICE_BLK_FD, entry_1);
 err_add_prof:
        ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
 
@@ -910,7 +918,7 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
                {ICE_INSET_TUN_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
                {ICE_INSET_TUN_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
                {ICE_INSET_TUN_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
-               {ICE_INSET_GTPU_TEID, ICE_FLOW_FIELD_IDX_GTPU_EH_TEID},
+               {ICE_INSET_GTPU_TEID, ICE_FLOW_FIELD_IDX_GTPU_IP_TEID},
                {ICE_INSET_GTPU_QFI, ICE_FLOW_FIELD_IDX_GTPU_EH_QFI},
        };
 
@@ -923,11 +931,12 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
 
 static int
 ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
-                       uint64_t input_set, bool is_tunnel)
+                       uint64_t input_set, enum ice_fdir_tunnel_type ttype)
 {
        struct ice_flow_seg_info *seg;
        struct ice_flow_seg_info *seg_tun = NULL;
        enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
+       bool is_tunnel;
        int i, ret;
 
        if (!input_set)
@@ -979,8 +988,15 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
        case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP:
        case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP:
        case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER:
-               ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_EH |
-                                 ICE_FLOW_SEG_HDR_IPV4);
+               if (ttype == ICE_FDIR_TUNNEL_TYPE_GTPU)
+                       ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_IP |
+                                         ICE_FLOW_SEG_HDR_IPV4);
+               else if (ttype == ICE_FDIR_TUNNEL_TYPE_GTPU_EH)
+                       ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_GTPU_EH |
+                                         ICE_FLOW_SEG_HDR_GTPU_IP |
+                                         ICE_FLOW_SEG_HDR_IPV4);
+               else
+                       PMD_DRV_LOG(ERR, "not supported tunnel type.");
                break;
        default:
                PMD_DRV_LOG(ERR, "not supported filter type.");
@@ -994,6 +1010,7 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
                                 ICE_FLOW_FLD_OFF_INVAL, false);
        }
 
+       is_tunnel = ice_fdir_is_tunnel_profile(ttype);
        if (!is_tunnel) {
                ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
                                           seg, flow, false);
@@ -1044,6 +1061,9 @@ ice_fdir_init(struct ice_adapter *ad)
        struct ice_flow_parser *parser;
        int ret;
 
+       if (ad->hw.dcf_enabled)
+               return 0;
+
        ret = ice_fdir_setup(pf);
        if (ret)
                return ret;
@@ -1064,6 +1084,9 @@ ice_fdir_uninit(struct ice_adapter *ad)
        struct ice_pf *pf = &ad->pf;
        struct ice_flow_parser *parser;
 
+       if (ad->hw.dcf_enabled)
+               return;
+
        if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
                parser = &ice_fdir_parser_comms;
        else
@@ -1218,7 +1241,7 @@ ice_fdir_create_filter(struct ice_adapter *ad,
        is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type);
 
        ret = ice_fdir_input_set_conf(pf, filter->input.flow_type,
-                       filter->input_set, is_tun);
+                       filter->input_set, filter->tunnel_type);
        if (ret) {
                rte_flow_error_set(error, -ret,
                                   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
@@ -1482,8 +1505,7 @@ ice_fdir_parse_action(struct ice_adapter *ad,
                        dest_num++;
 
                        filter->input.dest_ctl =
-                               ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
-                       filter->input.q_index = 0;
+                               ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_OTHER;
                        break;
                case RTE_FLOW_ACTION_TYPE_RSS:
                        dest_num++;
@@ -1498,6 +1520,7 @@ ice_fdir_parse_action(struct ice_adapter *ad,
 
                        mark_spec = actions->conf;
                        filter->input.fltr_id = mark_spec->id;
+                       filter->input.fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_ONE;
                        break;
                case RTE_FLOW_ACTION_TYPE_COUNT:
                        counter_num++;
@@ -1876,6 +1899,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 
                                filter->input.gtpu_data.teid = gtp_spec->teid;
                        }
+
+                       tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU;
                        break;
                case RTE_FLOW_ITEM_TYPE_GTP_PSC:
                        gtp_psc_spec = item->spec;
@@ -1888,8 +1913,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                                filter->input.gtpu_data.qfi =
                                        gtp_psc_spec->qfi;
                        }
-
-                       tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU;
+                       tunnel_type = ICE_FDIR_TUNNEL_TYPE_GTPU_EH;
                        break;
                default:
                        rte_flow_error_set(error, EINVAL,
@@ -1900,7 +1924,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
                }
        }
 
-       if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU)
+       if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU ||
+           tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU_EH)
                flow_type = ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER;
 
        filter->tunnel_type = tunnel_type;
@@ -1932,23 +1957,26 @@ ice_fdir_parse(struct ice_adapter *ad,
 
        ret = ice_fdir_parse_pattern(ad, pattern, error, filter);
        if (ret)
-               return ret;
+               goto error;
        input_set = filter->input_set;
        if (!input_set || input_set & ~item->input_set_mask) {
                rte_flow_error_set(error, EINVAL,
                                   RTE_FLOW_ERROR_TYPE_ITEM_SPEC,
                                   pattern,
                                   "Invalid input set");
-               return -rte_errno;
+               ret = -rte_errno;
+               goto error;
        }
 
        ret = ice_fdir_parse_action(ad, actions, error, filter);
        if (ret)
-               return ret;
-
-       *meta = filter;
+               goto error;
 
-       return 0;
+       if (meta)
+               *meta = filter;
+error:
+       rte_free(item);
+       return ret;
 }
 
 static struct ice_flow_parser ice_fdir_parser_os = {