net/ice/base: fix advanced switch rule stale information
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 15 Jun 2020 02:04:53 +0000 (10:04 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jun 2020 17:21:08 +0000 (19:21 +0200)
To avoid having stale information about "adv_rule" per recipe, when all
rules associated to a given recipe are deleted, reset the "adv_rule"
flag otherwise it causes problem later on when decisions about filter
rules being present or not are made based on "adv_rule" flag.

Removed setting "adv_rule = 1" when recipe is created. It is set
correctly when advanced switch rule is added referring to the recipe
which was created as a result of adding advanced switch rule.

Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/base/ice_switch.c

index 94268d5..f379a5f 100644 (file)
@@ -4122,6 +4122,9 @@ void ice_rem_all_sw_rules_info(struct ice_hw *hw)
                        ice_rem_sw_rule_info(hw, rule_head);
                else
                        ice_rem_adv_rule_info(hw, rule_head);
+               if (sw->recp_list[i].adv_rule &&
+                   LIST_EMPTY(&sw->recp_list[i].filt_rules))
+                       sw->recp_list[i].adv_rule = false;
        }
 }
 
@@ -6130,7 +6133,6 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
                recp->n_grp_count = rm->n_grp_count;
                recp->tun_type = rm->tun_type;
                recp->recp_created = true;
-               recp->adv_rule = 1;
        }
        rm->root_buf = buf;
        ice_free(hw, tmp);
@@ -7611,11 +7613,15 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
                                         rule_buf_sz, 1,
                                         ice_aqc_opc_remove_sw_rules, NULL);
                if (status == ICE_SUCCESS || status == ICE_ERR_DOES_NOT_EXIST) {
+                       struct ice_switch_info *sw = hw->switch_info;
+
                        ice_acquire_lock(rule_lock);
                        LIST_DEL(&list_elem->list_entry);
                        ice_free(hw, list_elem->lkups);
                        ice_free(hw, list_elem);
                        ice_release_lock(rule_lock);
+                       if (LIST_EMPTY(&sw->recp_list[rid].filt_rules))
+                               sw->recp_list[rid].adv_rule = false;
                }
                ice_free(hw, s_rule);
        }