ethdev: change stop operation callback to return int
[dpdk.git] / drivers / net / ice / base / ice_flow.c
index 58a9144..de5dfb2 100644 (file)
@@ -224,7 +224,7 @@ static const u32 ice_ptypes_macvlan_il[] = {
 static const u32 ice_ptypes_ipv4_ofos[] = {
        0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
        0x00000000, 0x00000155, 0x00000000, 0x00000000,
-       0x00000000, 0x000FC000, 0x000000A0, 0x00000000,
+       0x00000000, 0x000FC000, 0x000002A0, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -238,7 +238,7 @@ static const u32 ice_ptypes_ipv4_ofos[] = {
 static const u32 ice_ptypes_ipv4_ofos_all[] = {
        0x1DC00000, 0x04000800, 0x00000000, 0x00000000,
        0x00000000, 0x00000155, 0x00000000, 0x00000000,
-       0x00000000, 0x000FC000, 0x83E0F8A0, 0x00000101,
+       0x00000000, 0x000FC000, 0x83E0FAA0, 0x00000101,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -264,7 +264,7 @@ static const u32 ice_ptypes_ipv4_il[] = {
 static const u32 ice_ptypes_ipv6_ofos[] = {
        0x00000000, 0x00000000, 0x77000000, 0x10002000,
        0x00000000, 0x000002AA, 0x00000000, 0x00000000,
-       0x00000000, 0x03F00000, 0x00000140, 0x00000000,
+       0x00000000, 0x03F00000, 0x00000540, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -278,7 +278,7 @@ static const u32 ice_ptypes_ipv6_ofos[] = {
 static const u32 ice_ptypes_ipv6_ofos_all[] = {
        0x00000000, 0x00000000, 0x77000000, 0x10002000,
        0x00000000, 0x000002AA, 0x00000000, 0x00000000,
-       0x00000000, 0x03F00000, 0x7C1F0140, 0x00000206,
+       0x00000000, 0x03F00000, 0x7C1F0540, 0x00000206,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -302,7 +302,7 @@ static const u32 ice_ptypes_ipv6_il[] = {
 static const u32 ice_ipv4_ofos_no_l4[] = {
        0x10C00000, 0x04000800, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x000cc000, 0x000000A0, 0x00000000,
+       0x00000000, 0x000cc000, 0x000002A0, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -326,7 +326,7 @@ static const u32 ice_ipv4_il_no_l4[] = {
 static const u32 ice_ipv6_ofos_no_l4[] = {
        0x00000000, 0x00000000, 0x43000000, 0x10002000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
-       0x00000000, 0x02300000, 0x00000140, 0x00000000,
+       0x00000000, 0x02300000, 0x00000540, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
@@ -667,6 +667,17 @@ static const u32 ice_ptypes_mac_non_ip_ofos[] = {
        0x00000000, 0x00000000, 0x00000000, 0x00000000,
 };
 
+static const u32 ice_ptypes_gtpu_no_ip[] = {
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000600, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+};
+
 /* Manage parameters and info. used during the creation of a flow profile */
 struct ice_flow_prof_params {
        enum ice_block blk;
@@ -691,7 +702,7 @@ struct ice_flow_prof_params {
        ICE_FLOW_SEG_HDR_GTPC_TEID | ICE_FLOW_SEG_HDR_GTPU | \
        ICE_FLOW_SEG_HDR_PFCP_SESSION | ICE_FLOW_SEG_HDR_L2TPV3 | \
        ICE_FLOW_SEG_HDR_ESP | ICE_FLOW_SEG_HDR_AH | \
-       ICE_FLOW_SEG_HDR_NAT_T_ESP)
+       ICE_FLOW_SEG_HDR_NAT_T_ESP | ICE_FLOW_SEG_HDR_GTPU_NON_IP)
 
 #define ICE_FLOW_SEG_HDRS_L2_MASK      \
        (ICE_FLOW_SEG_HDR_ETH | ICE_FLOW_SEG_HDR_VLAN)
@@ -911,6 +922,10 @@ ice_flow_proc_seg_hdrs(struct ice_flow_prof_params *params)
                        src = (const ice_bitmap_t *)ice_ptypes_gtpc_tid;
                        ice_and_bitmap(params->ptypes, params->ptypes,
                                       src, ICE_FLOW_PTYPE_MAX);
+               } else if (hdrs & ICE_FLOW_SEG_HDR_GTPU_NON_IP) {
+                       src = (const ice_bitmap_t *)ice_ptypes_gtpu_no_ip;
+                       ice_and_bitmap(params->ptypes, params->ptypes,
+                                      src, ICE_FLOW_PTYPE_MAX);
                } else if (hdrs & ICE_FLOW_SEG_HDR_GTPU_DWN) {
                        src = (const ice_bitmap_t *)ice_ptypes_gtpu;
                        ice_and_bitmap(params->ptypes, params->ptypes,
@@ -1074,7 +1089,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
                 */
                if (fld == ICE_FLOW_FIELD_IDX_IPV4_TTL)
                        sib = ICE_FLOW_FIELD_IDX_IPV4_PROT;
-               else if (fld == ICE_FLOW_FIELD_IDX_IPV4_PROT)
+               else
                        sib = ICE_FLOW_FIELD_IDX_IPV4_TTL;
 
                /* If the sibling field is also included, that field's
@@ -1093,7 +1108,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
                 */
                if (fld == ICE_FLOW_FIELD_IDX_IPV6_TTL)
                        sib = ICE_FLOW_FIELD_IDX_IPV6_PROT;
-               else if (fld == ICE_FLOW_FIELD_IDX_IPV6_PROT)
+               else
                        sib = ICE_FLOW_FIELD_IDX_IPV6_TTL;
 
                /* If the sibling field is also included, that field's
@@ -1239,7 +1254,7 @@ ice_flow_xtract_fld(struct ice_hw *hw, struct ice_flow_prof_params *params,
  * ice_flow_xtract_raws - Create extract sequence entries for raw bytes
  * @hw: pointer to the HW struct
  * @params: information about the flow to be processed
- * @seg: index of packet segment whose raw fields are to be be extracted
+ * @seg: index of packet segment whose raw fields are to be extracted
  */
 static enum ice_status
 ice_flow_xtract_raws(struct ice_hw *hw, struct ice_flow_prof_params *params,
@@ -1627,6 +1642,30 @@ ice_dealloc_flow_entry(struct ice_hw *hw, struct ice_flow_entry *entry)
        ice_free(hw, entry);
 }
 
+/**
+ * ice_flow_get_hw_prof - return the HW profile for a specific profile ID handle
+ * @hw: pointer to the HW struct
+ * @blk: classification stage
+ * @prof_id: the profile ID handle
+ * @hw_prof_id: pointer to variable to receive the HW profile ID
+ */
+enum ice_status
+ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
+                    u8 *hw_prof_id)
+{
+       enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
+       struct ice_prof_map *map;
+
+       ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
+       map = ice_search_prof_id(hw, blk, prof_id);
+       if (map) {
+               *hw_prof_id = map->prof_id;
+               status = ICE_SUCCESS;
+       }
+       ice_release_lock(&hw->blk[blk].es.prof_map_lock);
+       return status;
+}
+
 #define ICE_ACL_INVALID_SCEN   0x3f
 
 /**
@@ -1673,8 +1712,8 @@ ice_flow_acl_is_prof_in_use(struct ice_hw *hw, struct ice_flow_prof *prof,
            buf->pf_scenario_num[6] == ICE_ACL_INVALID_SCEN &&
            buf->pf_scenario_num[7] == ICE_ACL_INVALID_SCEN)
                return ICE_SUCCESS;
-       else
-               return ICE_ERR_IN_USE;
+
+       return ICE_ERR_IN_USE;
 }
 
 /**
@@ -1741,7 +1780,7 @@ ice_flow_acl_disassoc_scen(struct ice_hw *hw, struct ice_flow_prof *prof)
 
        /* Clear scenario for this PF */
        buf.pf_scenario_num[hw->pf_id] = ICE_ACL_INVALID_SCEN;
-       status = ice_prgm_acl_prof_extrt(hw, prof_id, &buf, NULL);
+       status = ice_prgm_acl_prof_xtrct(hw, prof_id, &buf, NULL);
 
        return status;
 }
@@ -2043,7 +2082,7 @@ ice_flow_acl_set_xtrct_seq(struct ice_hw *hw, struct ice_flow_prof *prof)
 
        /* Update the current PF */
        buf.pf_scenario_num[hw->pf_id] = (u8)prof->cfg.scen->id;
-       status = ice_prgm_acl_prof_extrt(hw, prof_id, &buf, NULL);
+       status = ice_prgm_acl_prof_xtrct(hw, prof_id, &buf, NULL);
 
        return status;
 }
@@ -2217,30 +2256,6 @@ out:
        return status;
 }
 
-/**
- * ice_flow_get_hw_prof - return the HW profile for a specific profile ID handle
- * @hw: pointer to the HW struct
- * @blk: classification stage
- * @prof_id: the profile ID handle
- * @hw_prof_id: pointer to variable to receive the HW profile ID
- */
-enum ice_status
-ice_flow_get_hw_prof(struct ice_hw *hw, enum ice_block blk, u64 prof_id,
-                    u8 *hw_prof_id)
-{
-       enum ice_status status = ICE_ERR_DOES_NOT_EXIST;
-       struct ice_prof_map *map;
-
-       ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
-       map = ice_search_prof_id(hw, blk, prof_id);
-       if (map) {
-               *hw_prof_id = map->prof_id;
-               status = ICE_SUCCESS;
-       }
-       ice_release_lock(&hw->blk[blk].es.prof_map_lock);
-       return status;
-}
-
 /**
  * ice_flow_find_entry - look for a flow entry using its unique ID
  * @hw: pointer to the HW struct
@@ -2495,7 +2510,6 @@ ice_flow_acl_frmt_entry(struct ice_hw *hw, struct ice_flow_prof *prof,
        e->acts = (struct ice_flow_action *)
                ice_memdup(hw, acts, acts_cnt * sizeof(*acts),
                           ICE_NONDMA_TO_NONDMA);
-
        if (!e->acts)
                goto out;
 
@@ -2701,30 +2715,30 @@ ice_flow_acl_find_scen_entry_cond(struct ice_flow_prof *prof,
 }
 
 /**
- * ice_flow_acl_convert_to_acl_prior - Convert to ACL priority
+ * ice_flow_acl_convert_to_acl_prio - Convert to ACL priority
  * @p: flow priority
  */
-static enum ice_acl_entry_prior
-ice_flow_acl_convert_to_acl_prior(enum ice_flow_priority p)
+static enum ice_acl_entry_prio
+ice_flow_acl_convert_to_acl_prio(enum ice_flow_priority p)
 {
-       enum ice_acl_entry_prior acl_prior;
+       enum ice_acl_entry_prio acl_prio;
 
        switch (p) {
        case ICE_FLOW_PRIO_LOW:
-               acl_prior = ICE_LOW;
+               acl_prio = ICE_ACL_PRIO_LOW;
                break;
        case ICE_FLOW_PRIO_NORMAL:
-               acl_prior = ICE_NORMAL;
+               acl_prio = ICE_ACL_PRIO_NORMAL;
                break;
        case ICE_FLOW_PRIO_HIGH:
-               acl_prior = ICE_HIGH;
+               acl_prio = ICE_ACL_PRIO_HIGH;
                break;
        default:
-               acl_prior = ICE_NORMAL;
+               acl_prio = ICE_ACL_PRIO_NORMAL;
                break;
        }
 
-       return acl_prior;
+       return acl_prio;
 }
 
 /**
@@ -2803,7 +2817,7 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof,
        if (!entry || !(*entry) || !prof)
                return ICE_ERR_BAD_PTR;
 
-       e = *(entry);
+       e = *entry;
 
        do_chg_rng_chk = false;
        if (e->range_buf) {
@@ -2846,7 +2860,6 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof,
         */
        exist = ice_flow_acl_find_scen_entry_cond(prof, e, &do_chg_action,
                                                  &do_add_entry, &do_rem_entry);
-
        if (do_rem_entry) {
                status = ice_flow_rem_entry_sync(hw, ICE_BLK_ACL, exist);
                if (status)
@@ -2854,23 +2867,26 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof,
        }
 
        /* Prepare the result action buffer */
-       acts = (struct ice_acl_act_entry *)ice_calloc
-               (hw, e->entry_sz, sizeof(struct ice_acl_act_entry));
+       acts = (struct ice_acl_act_entry *)
+               ice_calloc(hw, e->entry_sz, sizeof(struct ice_acl_act_entry));
+       if (!acts)
+               return ICE_ERR_NO_MEMORY;
+
        for (i = 0; i < e->acts_cnt; i++)
                ice_memcpy(&acts[i], &e->acts[i].data.acl_act,
                           sizeof(struct ice_acl_act_entry),
                           ICE_NONDMA_TO_NONDMA);
 
        if (do_add_entry) {
-               enum ice_acl_entry_prior prior;
+               enum ice_acl_entry_prio prio;
                u8 *keys, *inverts;
                u16 entry_idx;
 
                keys = (u8 *)e->entry;
                inverts = keys + (e->entry_sz / 2);
-               prior = ice_flow_acl_convert_to_acl_prior(e->priority);
+               prio = ice_flow_acl_convert_to_acl_prio(e->priority);
 
-               status = ice_acl_add_entry(hw, prof->cfg.scen, prior, keys,
+               status = ice_acl_add_entry(hw, prof->cfg.scen, prio, keys,
                                           inverts, acts, e->acts_cnt,
                                           &entry_idx);
                if (status)
@@ -2888,7 +2904,6 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof,
                        exist->acts = (struct ice_flow_action *)
                                ice_calloc(hw, exist->acts_cnt,
                                           sizeof(struct ice_flow_action));
-
                        if (!exist->acts) {
                                status = ICE_ERR_NO_MEMORY;
                                goto out;
@@ -2922,8 +2937,7 @@ ice_flow_acl_add_scen_entry_sync(struct ice_hw *hw, struct ice_flow_prof *prof,
                *(entry) = exist;
        }
 out:
-       if (acts)
-               ice_free(hw, acts);
+       ice_free(hw, acts);
 
        return status;
 }
@@ -3090,7 +3104,7 @@ enum ice_status ice_flow_rem_entry(struct ice_hw *hw, enum ice_block blk,
  *
  * This helper function stores information of a field being matched, including
  * the type of the field and the locations of the value to match, the mask, and
- * and the upper-bound value in the start of the input buffer for a flow entry.
+ * the upper-bound value in the start of the input buffer for a flow entry.
  * This function should only be used for fixed-size data structures.
  *
  * This function also opportunistically determines the protocol headers to be
@@ -3220,8 +3234,7 @@ ice_flow_add_fld_raw(struct ice_flow_seg_info *seg, u16 off, u8 len,
        (ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV6)
 
 #define ICE_FLOW_RSS_SEG_HDR_L4_MASKS \
-       (ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | \
-        ICE_FLOW_SEG_HDR_SCTP)
+       (ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_SCTP)
 
 #define ICE_FLOW_RSS_SEG_HDR_VAL_MASKS \
        (ICE_FLOW_RSS_SEG_HDR_L2_MASKS | \
@@ -3557,7 +3570,7 @@ ice_add_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
        if (status)
                goto exit;
 
-       /* don't do RSS for GTPU outer */
+       /* Don't do RSS for GTPU Outer */
        if (segs_cnt == ICE_RSS_OUTER_HEADERS &&
            segs[segs_cnt - 1].hdrs & ICE_FLOW_SEG_HDR_GTPU) {
                status = ICE_SUCCESS;
@@ -3680,7 +3693,6 @@ ice_add_rss_cfg(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
        ice_acquire_lock(&hw->rss_locks);
        status = ice_add_rss_cfg_sync(hw, vsi_handle, hashed_flds, addl_hdrs,
                                      ICE_RSS_OUTER_HEADERS, symm);
-
        if (!status)
                status = ice_add_rss_cfg_sync(hw, vsi_handle, hashed_flds,
                                              addl_hdrs, ICE_RSS_INNER_HEADERS,
@@ -3720,6 +3732,7 @@ ice_rem_rss_cfg_sync(struct ice_hw *hw, u16 vsi_handle, u64 hashed_flds,
        if (status)
                goto out;
 
+       /* Don't do RSS for GTPU Outer */
        if (segs_cnt == ICE_RSS_OUTER_HEADERS &&
            segs[segs_cnt - 1].hdrs & ICE_FLOW_SEG_HDR_GTPU) {
                status = ICE_SUCCESS;