net/ice/base: fix reference count on VSI list update
[dpdk.git] / drivers / net / ice / base / ice_switch.c
index 01dcace..9c7e55f 100644 (file)
@@ -3250,26 +3250,11 @@ static enum ice_status
 ice_remove_vsi_list_rule(struct ice_hw *hw, u16 vsi_list_id,
                         enum ice_sw_lkup_type lkup_type)
 {
-       struct ice_aqc_sw_rules_elem *s_rule;
-       enum ice_status status;
-       u16 s_rule_size;
-
-       s_rule_size = (u16)ICE_SW_RULE_VSI_LIST_SIZE(0);
-       s_rule = (struct ice_aqc_sw_rules_elem *)ice_malloc(hw, s_rule_size);
-       if (!s_rule)
-               return ICE_ERR_NO_MEMORY;
-
-       s_rule->type = CPU_TO_LE16(ICE_AQC_SW_RULES_T_VSI_LIST_CLEAR);
-       s_rule->pdata.vsi_list.index = CPU_TO_LE16(vsi_list_id);
-
        /* Free the vsi_list resource that we allocated. It is assumed that the
         * list is empty at this point.
         */
-       status = ice_aq_alloc_free_vsi_list(hw, &vsi_list_id, lkup_type,
+       return ice_aq_alloc_free_vsi_list(hw, &vsi_list_id, lkup_type,
                                            ice_aqc_opc_free_res);
-
-       ice_free(hw, s_rule);
-       return status;
 }
 
 /**
@@ -7503,6 +7488,7 @@ ice_adv_rem_update_vsi_list(struct ice_hw *hw, u16 vsi_handle,
                                  tmp_fltr.fwd_id.hw_vsi_id, status);
                        return status;
                }
+               fm_list->vsi_list_info->ref_cnt--;
 
                /* Remove the VSI list since it is no longer used */
                status = ice_remove_vsi_list_rule(hw, vsi_list_id, lkup_type);
@@ -7581,7 +7567,6 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
        if (list_elem->rule_info.sw_act.fltr_act != ICE_FWD_TO_VSI_LIST) {
                remove_rule = true;
        } else if (list_elem->vsi_count > 1) {
-               list_elem->vsi_list_info->ref_cnt--;
                remove_rule = false;
                vsi_handle = rinfo->sw_act.vsi_handle;
                status = ice_adv_rem_update_vsi_list(hw, vsi_handle, list_elem);
@@ -7661,7 +7646,8 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw,
                                                list_itr->lkups_cnt, &rinfo);
                }
        }
-       return ICE_ERR_PARAM;
+       /* either list is empty or unable to find rule */
+       return ICE_ERR_DOES_NOT_EXIST;
 }
 
 /**