net/ice/base: preserve NVM capabilities in safe mode
[dpdk.git] / drivers / net / ice / base / ice_switch.c
index a82af6f..1c07c60 100644 (file)
@@ -1591,7 +1591,7 @@ static void ice_get_recp_to_prof_map(struct ice_hw *hw)
        ice_declare_bitmap(r_bitmap, ICE_MAX_NUM_RECIPES);
        u16 i;
 
-       for (i = 0; i < ICE_MAX_NUM_PROFILES; i++) {
+       for (i = 0; i < hw->switch_info->max_used_prof_index + 1; i++) {
                u16 j;
 
                ice_zero_bitmap(profile_to_recipe[i], ICE_MAX_NUM_RECIPES);
@@ -2367,7 +2367,7 @@ ice_aq_alloc_free_vsi_list_exit:
  * @hw: pointer to the HW struct
  * @bcast_thresh: represents the upper threshold for broadcast storm control
  * @mcast_thresh: represents the upper threshold for multicast storm control
- * @ctl_bitmask: storm control control knobs
+ * @ctl_bitmask: storm control knobs
  *
  * Sets the storm control configuration (0x0280)
  */
@@ -2394,7 +2394,7 @@ ice_aq_set_storm_ctrl(struct ice_hw *hw, u32 bcast_thresh, u32 mcast_thresh,
  * @hw: pointer to the HW struct
  * @bcast_thresh: represents the upper threshold for broadcast storm control
  * @mcast_thresh: represents the upper threshold for multicast storm control
- * @ctl_bitmask: storm control control knobs
+ * @ctl_bitmask: storm control knobs
  *
  * Gets the storm control configuration (0x0281)
  */
@@ -8114,13 +8114,12 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw,
  */
 enum ice_status ice_rem_adv_rule_for_vsi(struct ice_hw *hw, u16 vsi_handle)
 {
-       struct ice_adv_fltr_mgmt_list_entry *list_itr;
+       struct ice_adv_fltr_mgmt_list_entry *list_itr, *tmp_entry;
        struct ice_vsi_list_map_info *map_info;
        struct LIST_HEAD_TYPE *list_head;
        struct ice_adv_rule_info rinfo;
        struct ice_switch_info *sw;
        enum ice_status status;
-       u16 vsi_list_id = 0;
        u8 rid;
 
        sw = hw->switch_info;
@@ -8129,22 +8128,31 @@ enum ice_status ice_rem_adv_rule_for_vsi(struct ice_hw *hw, u16 vsi_handle)
                        continue;
                if (!sw->recp_list[rid].adv_rule)
                        continue;
+
                list_head = &sw->recp_list[rid].filt_rules;
-               map_info = NULL;
-               LIST_FOR_EACH_ENTRY(list_itr, list_head,
-                                   ice_adv_fltr_mgmt_list_entry, list_entry) {
-                       map_info = ice_find_vsi_list_entry(&sw->recp_list[rid],
-                                                          vsi_handle,
-                                                          &vsi_list_id);
-                       if (!map_info)
-                               continue;
+               LIST_FOR_EACH_ENTRY_SAFE(list_itr, tmp_entry, list_head,
+                                        ice_adv_fltr_mgmt_list_entry,
+                                        list_entry) {
                        rinfo = list_itr->rule_info;
+
+                       if (rinfo.sw_act.fltr_act == ICE_FWD_TO_VSI_LIST) {
+                               map_info = list_itr->vsi_list_info;
+                               if (!map_info)
+                                       continue;
+
+                               if (!ice_is_bit_set(map_info->vsi_map,
+                                                   vsi_handle))
+                                       continue;
+                       } else if (rinfo.sw_act.vsi_handle != vsi_handle) {
+                               continue;
+                       }
+
                        rinfo.sw_act.vsi_handle = vsi_handle;
                        status = ice_rem_adv_rule(hw, list_itr->lkups,
                                                  list_itr->lkups_cnt, &rinfo);
+
                        if (status)
                                return status;
-                       map_info = NULL;
                }
        }
        return ICE_SUCCESS;