net/ice/base: force switch to use different recipe
[dpdk.git] / drivers / net / ice / base / ice_switch.c
index 373f4b3..fd2cf10 100644 (file)
@@ -4983,7 +4983,8 @@ static const struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
  *
  * Returns index of matching recipe, or ICE_MAX_NUM_RECIPES if not found.
  */
-static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts)
+static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts,
+                        enum ice_sw_tunnel_type tun_type)
 {
        bool refresh_required = true;
        struct ice_sw_recipe *recp;
@@ -5042,7 +5043,10 @@ static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts)
                        /* If for "i"th recipe the found was never set to false
                         * then it means we found our match
                         */
-                       if (found)
+                       if (ice_is_prof_rule(tun_type) &&
+                           tun_type == recp[i].tun_type && found)
+                               return i; /* Return the recipe ID */
+                       else if (!ice_is_prof_rule(tun_type) && found)
                                return i; /* Return the recipe ID */
                }
        }
@@ -5798,7 +5802,7 @@ ice_get_compat_fv_bitmap(struct ice_hw *hw, struct ice_adv_rule_info *rinfo,
  * if the rule type is a profile rule, that means that there no field value
  * match required, in this case just a profile hit is required.
  */
-static bool ice_is_prof_rule(enum ice_sw_tunnel_type type)
+bool ice_is_prof_rule(enum ice_sw_tunnel_type type)
 {
        switch (type) {
        case ICE_SW_TUN_PROFID_IPV6_ESP:
@@ -5952,11 +5956,12 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
                goto err_free_lkup_exts;
 
        /* Look for a recipe which matches our requested fv / mask list */
-       *rid = ice_find_recp(hw, lkup_exts);
+       *rid = ice_find_recp(hw, lkup_exts, rinfo->tun_type);
        if (*rid < ICE_MAX_NUM_RECIPES)
                /* Success if found a recipe that match the existing criteria */
                goto err_unroll;
 
+       rm->tun_type = rinfo->tun_type;
        /* Recipe we need does not exist, add a recipe */
        status = ice_add_sw_recipe(hw, rm, match_tun, profiles);
        if (status)
@@ -6857,7 +6862,7 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
        if (status)
                return status;
 
-       rid = ice_find_recp(hw, &lkup_exts);
+       rid = ice_find_recp(hw, &lkup_exts, rinfo->tun_type);
        /* If did not find a recipe that match the existing criteria */
        if (rid == ICE_MAX_NUM_RECIPES)
                return ICE_ERR_PARAM;