net/ice: fix flow FDIR/switch memory leak
[dpdk.git] / drivers / net / ice / base / ice_sched.c
index a72e729..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
@@ -1233,7 +1230,7 @@ enum ice_status ice_sched_init_port(struct ice_port_info *pi)
                goto err_init_port;
        }
 
-       /* If the last node is a leaf node then the index of the Q group
+       /* If the last node is a leaf node then the index of the queue group
         * layer is two less than the number of elements.
         */
        if (num_elems > 2 && buf[0].generic[num_elems - 1].data.elem_type ==
@@ -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;
@@ -1451,7 +1447,7 @@ lan_q_exit:
 
 /**
  * ice_sched_get_vsi_node - Get a VSI node based on VSI ID
- * @hw: pointer to the HW struct
+ * @pi: pointer to the port information structure
  * @tc_node: pointer to the TC node
  * @vsi_handle: software VSI handle
  *
@@ -1459,14 +1455,14 @@ lan_q_exit:
  * TC branch
  */
 struct ice_sched_node *
-ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
+ice_sched_get_vsi_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,
                       u16 vsi_handle)
 {
        struct ice_sched_node *node;
        u8 vsi_layer;
 
-       vsi_layer = ice_sched_get_vsi_layer(hw);
-       node = ice_sched_get_first_node(hw->port_info, tc_node, vsi_layer);
+       vsi_layer = ice_sched_get_vsi_layer(pi->hw);
+       node = ice_sched_get_first_node(pi, tc_node, vsi_layer);
 
        /* Check whether it already exists */
        while (node) {
@@ -1480,7 +1476,7 @@ ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
 
 /**
  * ice_sched_get_agg_node - Get an aggregator node based on aggregator ID
- * @hw: pointer to the HW struct
+ * @pi: pointer to the port information structure
  * @tc_node: pointer to the TC node
  * @agg_id: aggregator ID
  *
@@ -1488,14 +1484,17 @@ ice_sched_get_vsi_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
  * a given TC branch
  */
 static struct ice_sched_node *
-ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node,
+ice_sched_get_agg_node(struct ice_port_info *pi, struct ice_sched_node *tc_node,
                       u32 agg_id)
 {
        struct ice_sched_node *node;
+       struct ice_hw *hw = pi->hw;
        u8 agg_layer;
 
+       if (!hw)
+               return NULL;
        agg_layer = ice_sched_get_agg_layer(hw);
-       node = ice_sched_get_first_node(hw->port_info, tc_node, agg_layer);
+       node = ice_sched_get_first_node(pi, tc_node, agg_layer);
 
        /* Check whether it already exists */
        while (node) {
@@ -1587,7 +1586,7 @@ ice_sched_add_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
 
        qgl = ice_sched_get_qgrp_layer(hw);
        vsil = ice_sched_get_vsi_layer(hw);
-       parent = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+       parent = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
        for (i = vsil + 1; i <= qgl; i++) {
                if (!parent)
                        return ICE_ERR_CFG;
@@ -1620,7 +1619,7 @@ ice_sched_add_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
 
 /**
  * ice_sched_calc_vsi_support_nodes - calculate number of VSI support nodes
- * @hw: pointer to the HW struct
+ * @pi: pointer to the port info structure
  * @tc_node: pointer to TC node
  * @num_nodes: pointer to num nodes array
  *
@@ -1629,15 +1628,15 @@ ice_sched_add_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
  * layers
  */
 static void
-ice_sched_calc_vsi_support_nodes(struct ice_hw *hw,
+ice_sched_calc_vsi_support_nodes(struct ice_port_info *pi,
                                 struct ice_sched_node *tc_node, u16 *num_nodes)
 {
        struct ice_sched_node *node;
        u8 vsil;
        int i;
 
-       vsil = ice_sched_get_vsi_layer(hw);
-       for (i = vsil; i >= hw->sw_entry_point_layer; i--)
+       vsil = ice_sched_get_vsi_layer(pi->hw);
+       for (i = vsil; i >= pi->hw->sw_entry_point_layer; i--)
                /* Add intermediate nodes if TC has no children and
                 * need at least one node for VSI
                 */
@@ -1647,11 +1646,11 @@ ice_sched_calc_vsi_support_nodes(struct ice_hw *hw,
                        /* If intermediate nodes are reached max children
                         * then add a new one.
                         */
-                       node = ice_sched_get_first_node(hw->port_info, tc_node,
-                                                       (u8)i);
+                       node = ice_sched_get_first_node(pi, tc_node, (u8)i);
                        /* scan all the siblings */
                        while (node) {
-                               if (node->num_children < hw->max_children[i])
+                               if (node->num_children <
+                                   pi->hw->max_children[i])
                                        break;
                                node = node->sibling;
                        }
@@ -1731,14 +1730,13 @@ ice_sched_add_vsi_to_topo(struct ice_port_info *pi, u16 vsi_handle, u8 tc)
 {
        u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
        struct ice_sched_node *tc_node;
-       struct ice_hw *hw = pi->hw;
 
        tc_node = ice_sched_get_tc_node(pi, tc);
        if (!tc_node)
                return ICE_ERR_PARAM;
 
        /* calculate number of supported nodes needed for this VSI */
-       ice_sched_calc_vsi_support_nodes(hw, tc_node, num_nodes);
+       ice_sched_calc_vsi_support_nodes(pi, tc_node, num_nodes);
 
        /* add VSI supported nodes to TC subtree */
        return ice_sched_add_vsi_support_nodes(pi, vsi_handle, tc_node,
@@ -1771,7 +1769,7 @@ ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle,
        if (!tc_node)
                return ICE_ERR_CFG;
 
-       vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+       vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
        if (!vsi_node)
                return ICE_ERR_CFG;
 
@@ -1834,7 +1832,7 @@ ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
        vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
        if (!vsi_ctx)
                return ICE_ERR_PARAM;
-       vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+       vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
 
        /* suspend the VSI if TC is not enabled */
        if (!enable) {
@@ -1855,7 +1853,7 @@ ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
                if (status)
                        return status;
 
-               vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        return ICE_ERR_CFG;
 
@@ -1966,7 +1964,7 @@ ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner)
                if (!tc_node)
                        continue;
 
-               vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        continue;
 
@@ -2019,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
@@ -2179,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;
 
@@ -2252,11 +2248,11 @@ ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
        if (!tc_node)
                return ICE_ERR_CFG;
 
-       agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+       agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
        if (!agg_node)
                return ICE_ERR_DOES_NOT_EXIST;
 
-       vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+       vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
        if (!vsi_node)
                return ICE_ERR_DOES_NOT_EXIST;
 
@@ -2389,7 +2385,7 @@ ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
        if (!tc_node)
                return ICE_ERR_CFG;
 
-       agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+       agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
        if (!agg_node)
                return ICE_ERR_DOES_NOT_EXIST;
 
@@ -2498,7 +2494,7 @@ ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
        if (!tc_node)
                return ICE_ERR_CFG;
 
-       agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+       agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
        /* Does Agg node already exist ? */
        if (agg_node)
                return status;
@@ -2800,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;
@@ -3446,7 +3442,6 @@ ice_cfg_vsi_q_priority(struct ice_port_info *pi, u16 num_qs, u32 *q_ids,
                       u8 *q_prio)
 {
        enum ice_status status = ICE_ERR_PARAM;
-       struct ice_hw *hw = pi->hw;
        u16 i;
 
        ice_acquire_lock(&pi->sched_lock);
@@ -3461,7 +3456,7 @@ ice_cfg_vsi_q_priority(struct ice_port_info *pi, u16 num_qs, u32 *q_ids,
                        break;
                }
                /* Configure Priority */
-               status = ice_sched_cfg_sibl_node_prio(hw, node, q_prio[i]);
+               status = ice_sched_cfg_sibl_node_prio(pi, node, q_prio[i]);
                if (status)
                        break;
        }
@@ -3509,7 +3504,7 @@ ice_cfg_agg_vsi_priority_per_tc(struct ice_port_info *pi, u32 agg_id,
        if (!tc_node)
                goto exit_agg_priority_per_tc;
 
-       agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+       agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
        if (!agg_node)
                goto exit_agg_priority_per_tc;
 
@@ -3529,19 +3524,21 @@ ice_cfg_agg_vsi_priority_per_tc(struct ice_port_info *pi, u32 agg_id,
                LIST_FOR_EACH_ENTRY(agg_vsi_info, &agg_info->agg_vsi_list,
                                    ice_sched_agg_vsi_info, list_entry)
                        if (agg_vsi_info->vsi_handle == vsi_handle) {
+                               /* cppcheck-suppress unreadVariable */
                                vsi_handle_valid = true;
                                break;
                        }
+
                if (!vsi_handle_valid)
                        goto exit_agg_priority_per_tc;
 
-               vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        goto exit_agg_priority_per_tc;
 
                if (ice_sched_find_node_in_subtree(hw, agg_node, vsi_node)) {
                        /* Configure Priority */
-                       status = ice_sched_cfg_sibl_node_prio(hw, vsi_node,
+                       status = ice_sched_cfg_sibl_node_prio(pi, vsi_node,
                                                              node_prio[i]);
                        if (status)
                                break;
@@ -3591,7 +3588,7 @@ ice_cfg_vsi_bw_alloc(struct ice_port_info *pi, u16 vsi_handle, u8 ena_tcmap,
                if (!tc_node)
                        continue;
 
-               vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        continue;
 
@@ -3653,7 +3650,7 @@ ice_cfg_agg_bw_alloc(struct ice_port_info *pi, u32 agg_id, u8 ena_tcmap,
                if (!tc_node)
                        continue;
 
-               agg_node = ice_sched_get_agg_node(hw, tc_node, agg_id);
+               agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
                if (!agg_node)
                        continue;
 
@@ -3797,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;
@@ -4047,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)
@@ -4452,19 +4453,17 @@ static enum ice_status
 ice_sched_save_tc_node_bw(struct ice_port_info *pi, u8 tc,
                          enum ice_rl_type rl_type, u32 bw)
 {
-       struct ice_hw *hw = pi->hw;
-
        if (tc >= ICE_MAX_TRAFFIC_CLASS)
                return ICE_ERR_PARAM;
        switch (rl_type) {
        case ICE_MIN_BW:
-               ice_set_clear_cir_bw(&hw->tc_node_bw_t_info[tc], bw);
+               ice_set_clear_cir_bw(&pi->tc_node_bw_t_info[tc], bw);
                break;
        case ICE_MAX_BW:
-               ice_set_clear_eir_bw(&hw->tc_node_bw_t_info[tc], bw);
+               ice_set_clear_eir_bw(&pi->tc_node_bw_t_info[tc], bw);
                break;
        case ICE_SHARED_BW:
-               ice_set_clear_shared_bw(&hw->tc_node_bw_t_info[tc], bw);
+               ice_set_clear_shared_bw(&pi->tc_node_bw_t_info[tc], bw);
                break;
        default:
                return ICE_ERR_PARAM;
@@ -4551,17 +4550,15 @@ static enum ice_status
 ice_sched_save_tc_node_bw_alloc(struct ice_port_info *pi, u8 tc,
                                enum ice_rl_type rl_type, u16 bw_alloc)
 {
-       struct ice_hw *hw = pi->hw;
-
        if (tc >= ICE_MAX_TRAFFIC_CLASS)
                return ICE_ERR_PARAM;
        switch (rl_type) {
        case ICE_MIN_BW:
-               ice_set_clear_cir_bw_alloc(&hw->tc_node_bw_t_info[tc],
+               ice_set_clear_cir_bw_alloc(&pi->tc_node_bw_t_info[tc],
                                           bw_alloc);
                break;
        case ICE_MAX_BW:
-               ice_set_clear_eir_bw_alloc(&hw->tc_node_bw_t_info[tc],
+               ice_set_clear_eir_bw_alloc(&pi->tc_node_bw_t_info[tc],
                                           bw_alloc);
                break;
        default:
@@ -4709,7 +4706,7 @@ ice_sched_get_node_by_id_type(struct ice_port_info *pi, u32 id,
 
                tc_node = ice_sched_get_tc_node(pi, tc);
                if (tc_node)
-                       node = ice_sched_get_agg_node(pi->hw, tc_node, id);
+                       node = ice_sched_get_agg_node(pi, tc_node, id);
                break;
        }
 
@@ -4803,7 +4800,7 @@ ice_sched_validate_vsi_srl_node(struct ice_port_info *pi, u16 vsi_handle)
                if (!tc_node)
                        continue;
 
-               vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        continue;
 
@@ -4862,7 +4859,7 @@ ice_sched_set_vsi_bw_shared_lmt(struct ice_port_info *pi, u16 vsi_handle,
                if (!tc_node)
                        continue;
 
-               vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        continue;
 
@@ -4920,7 +4917,7 @@ ice_sched_validate_agg_srl_node(struct ice_port_info *pi, u32 agg_id)
                if (!tc_node)
                        continue;
 
-               agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+               agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
                if (!agg_node)
                        continue;
                /* SRL bandwidth layer selection */
@@ -4991,7 +4988,7 @@ ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
                if (!tc_node)
                        continue;
 
-               agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
+               agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
                if (!agg_node)
                        continue;
 
@@ -5016,7 +5013,7 @@ exit_agg_bw_shared_lmt:
 
 /**
  * ice_sched_cfg_sibl_node_prio - configure node sibling priority
- * @hw: pointer to the HW struct
+ * @pi: port information structure
  * @node: sched node to configure
  * @priority: sibling priority
  *
@@ -5024,13 +5021,16 @@ exit_agg_bw_shared_lmt:
  * function needs to be called with scheduler lock held.
  */
 enum ice_status
-ice_sched_cfg_sibl_node_prio(struct ice_hw *hw, struct ice_sched_node *node,
-                            u8 priority)
+ice_sched_cfg_sibl_node_prio(struct ice_port_info *pi,
+                            struct ice_sched_node *node, u8 priority)
 {
        struct ice_aqc_txsched_elem_data buf;
        struct ice_aqc_txsched_elem *data;
+       struct ice_hw *hw = pi->hw;
        enum ice_status status;
 
+       if (!hw)
+               return ICE_ERR_PARAM;
        buf = node->info;
        data = &buf.data;
        data->valid_sections |= ICE_AQC_ELEM_VALID_GENERIC;
@@ -5197,7 +5197,7 @@ ice_sched_replay_agg_bw(struct ice_hw *hw, struct ice_sched_agg_info *agg_info)
                        status = ICE_ERR_PARAM;
                        break;
                }
-               agg_node = ice_sched_get_agg_node(hw, tc_node,
+               agg_node = ice_sched_get_agg_node(hw->port_info, tc_node,
                                                  agg_info->agg_id);
                if (!agg_node) {
                        status = ICE_ERR_PARAM;
@@ -5258,8 +5258,7 @@ void ice_sched_replay_agg(struct ice_hw *hw)
                                           ICE_MAX_TRAFFIC_CLASS);
                        enum ice_status status;
 
-                       ice_zero_bitmap(replay_bitmap,
-                                       sizeof(replay_bitmap) * BITS_PER_BYTE);
+                       ice_zero_bitmap(replay_bitmap, ICE_MAX_TRAFFIC_CLASS);
                        ice_sched_get_ena_tc_bitmap(pi,
                                                    agg_info->replay_tc_bitmap,
                                                    replay_bitmap);
@@ -5310,26 +5309,27 @@ void ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw)
 
 /**
  * ice_sched_replay_tc_node_bw - replay TC node(s) BW
- * @hw: pointer to the HW struct
+ * @pi: port information structure
  *
- * This function replay TC nodes. The caller needs to hold the scheduler lock.
+ * This function replay TC nodes.
  */
 enum ice_status
-ice_sched_replay_tc_node_bw(struct ice_hw *hw)
+ice_sched_replay_tc_node_bw(struct ice_port_info *pi)
 {
-       struct ice_port_info *pi = hw->port_info;
        enum ice_status status = ICE_SUCCESS;
        u8 tc;
 
+       if (!pi->hw)
+               return ICE_ERR_PARAM;
        ice_acquire_lock(&pi->sched_lock);
        ice_for_each_traffic_class(tc) {
                struct ice_sched_node *tc_node;
 
-               tc_node = ice_sched_get_tc_node(hw->port_info, tc);
+               tc_node = ice_sched_get_tc_node(pi, tc);
                if (!tc_node)
                        continue; /* TC not present */
-               status = ice_sched_replay_node_bw(hw, tc_node,
-                                                 &hw->tc_node_bw_t_info[tc]);
+               status = ice_sched_replay_node_bw(pi->hw, tc_node,
+                                                 &pi->tc_node_bw_t_info[tc]);
                if (status)
                        break;
        }
@@ -5366,7 +5366,7 @@ ice_sched_replay_vsi_bw(struct ice_hw *hw, u16 vsi_handle,
                tc_node = ice_sched_get_tc_node(pi, tc);
                if (!tc_node)
                        continue;
-               vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle);
+               vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
                if (!vsi_node)
                        continue;
                bw_t_info = &vsi_ctx->sched.bw_t_info[tc];
@@ -5395,7 +5395,7 @@ ice_sched_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle)
        struct ice_sched_agg_info *agg_info;
        enum ice_status status;
 
-       ice_zero_bitmap(replay_bitmap, sizeof(replay_bitmap) * BITS_PER_BYTE);
+       ice_zero_bitmap(replay_bitmap, ICE_MAX_TRAFFIC_CLASS);
        if (!ice_is_vsi_valid(hw, vsi_handle))
                return ICE_ERR_PARAM;
        agg_info = ice_get_vsi_agg_info(hw, vsi_handle);