net/hns3: support flow director
[dpdk.git] / drivers / net / ice / base / ice_sched.c
index d16f256..553fc28 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "ice_sched.h"
 
-
 /**
  * ice_sched_add_root_node - Insert the Tx scheduler root node in SW DB
  * @pi: port information structure
@@ -284,7 +283,7 @@ struct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc)
 {
        u8 i;
 
-       if (!pi)
+       if (!pi || !pi->root)
                return NULL;
        for (i = 0; i < pi->root->num_children; i++)
                if (pi->root->children[i]->tc_num == tc)
@@ -735,7 +734,7 @@ ice_sched_del_rl_profile(struct ice_hw *hw,
  */
 static void ice_sched_clear_rl_prof(struct ice_port_info *pi)
 {
-       u8 ln;
+       u16 ln;
 
        for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
                struct ice_aqc_rl_profile_info *rl_prof_elem;
@@ -841,8 +840,7 @@ void ice_sched_cleanup_all(struct ice_hw *hw)
                hw->layer_info = NULL;
        }
 
-       if (hw->port_info)
-               ice_sched_clear_port(hw->port_info);
+       ice_sched_clear_port(hw->port_info);
 
        hw->num_tx_sched_layers = 0;
        hw->num_tx_sched_phys_layers = 0;
@@ -876,7 +874,6 @@ ice_aq_cfg_l2_node_cgd(struct ice_hw *hw, u16 num_l2_nodes,
        return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
 }
 
-
 /**
  * ice_sched_add_elems - add nodes to HW and SW DB
  * @pi: port information structure
@@ -1366,7 +1363,6 @@ enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw)
                goto sched_query_out;
        }
 
-
 sched_query_out:
        ice_free(hw, buf);
        return status;
@@ -2021,7 +2017,6 @@ enum ice_status ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle)
        return ice_sched_rm_vsi_cfg(pi, vsi_handle, ICE_SCHED_NODE_OWNER_LAN);
 }
 
-
 /**
  * ice_sched_is_tree_balanced - Check tree nodes are identical or not
  * @hw: pointer to the HW struct
@@ -2181,12 +2176,11 @@ static enum ice_status
 ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent,
                     u16 num_items, u32 *list)
 {
+       enum ice_status status = ICE_SUCCESS;
        struct ice_aqc_move_elem *buf;
        struct ice_sched_node *node;
-       enum ice_status status = ICE_SUCCESS;
+       u16 i, grps_movd = 0;
        struct ice_hw *hw;
-       u16 grps_movd = 0;
-       u8 i;
 
        hw = pi->hw;
 
@@ -2802,7 +2796,7 @@ ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id,
  */
 static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
 {
-       u8 ln;
+       u16 ln;
 
        for (ln = 0; ln < pi->hw->num_tx_sched_layers; ln++) {
                struct ice_aqc_rl_profile_info *rl_prof_elem;
@@ -3800,10 +3794,12 @@ ice_sched_add_rl_profile(struct ice_port_info *pi,
        struct ice_aqc_rl_profile_generic_elem *buf;
        struct ice_aqc_rl_profile_info *rl_prof_elem;
        u16 profiles_added = 0, num_profiles = 1;
-       enum ice_status status = ICE_ERR_PARAM;
+       enum ice_status status;
        struct ice_hw *hw;
        u8 profile_type;
 
+       if (layer_num >= ICE_AQC_TOPO_MAX_LEVEL_NUM)
+               return NULL;
        switch (rl_type) {
        case ICE_MIN_BW:
                profile_type = ICE_AQC_RL_PROFILE_TYPE_CIR;
@@ -4050,6 +4046,8 @@ ice_sched_rm_rl_profile(struct ice_port_info *pi, u8 layer_num, u8 profile_type,
        struct ice_aqc_rl_profile_info *rl_prof_elem;
        enum ice_status status = ICE_SUCCESS;
 
+       if (layer_num >= ICE_AQC_TOPO_MAX_LEVEL_NUM)
+               return ICE_ERR_PARAM;
        /* Check the existing list for RL profile */
        LIST_FOR_EACH_ENTRY(rl_prof_elem, &pi->rl_prof_list[layer_num],
                            ice_aqc_rl_profile_info, list_entry)