X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fice%2Fbase%2Fice_sched.c;h=1374b9a0968c900d012a343b0fa5b8ee36fceb75;hb=d58cc74ebd5723f07ada4722e6b82d8cbc0d9ee2;hp=0c1c18ba145f5c223e1f62ee4c4c7a87ccce5d85;hpb=39e30e38c46045c85717145c00763dd8d97e6a9f;p=dpdk.git diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c index 0c1c18ba14..1374b9a096 100644 --- a/drivers/net/ice/base/ice_sched.c +++ b/drivers/net/ice/base/ice_sched.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2001-2019 + * Copyright(c) 2001-2020 Intel Corporation */ #include "ice_sched.h" - /** * ice_sched_add_root_node - Insert the Tx scheduler root node in SW DB * @pi: port information structure @@ -131,7 +130,7 @@ ice_aqc_send_sched_elem_cmd(struct ice_hw *hw, enum ice_adminq_opc cmd_opc, */ enum ice_status ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, - struct ice_aqc_get_elem *buf, u16 buf_size, + struct ice_aqc_txsched_elem_data *buf, u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) { return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_get_sched_elems, @@ -151,8 +150,8 @@ enum ice_status ice_sched_add_node(struct ice_port_info *pi, u8 layer, struct ice_aqc_txsched_elem_data *info) { + struct ice_aqc_txsched_elem_data elem; struct ice_sched_node *parent; - struct ice_aqc_get_elem elem; struct ice_sched_node *node; enum ice_status status; struct ice_hw *hw; @@ -166,13 +165,12 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, parent = ice_sched_find_node_by_teid(pi->root, LE32_TO_CPU(info->parent_teid)); if (!parent) { - ice_debug(hw, ICE_DBG_SCHED, - "Parent Node not found for parent_teid=0x%x\n", + ice_debug(hw, ICE_DBG_SCHED, "Parent Node not found for parent_teid=0x%x\n", LE32_TO_CPU(info->parent_teid)); return ICE_ERR_PARAM; } - /* query the current node information from FW before additing it + /* query the current node information from FW before adding it * to the SW DB */ status = ice_sched_query_elem(hw, LE32_TO_CPU(info->node_teid), &elem); @@ -195,7 +193,7 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, node->parent = parent; node->tx_sched_layer = layer; parent->children[parent->num_children++] = node; - node->info = elem.generic[0]; + node->info = elem; return ICE_SUCCESS; } @@ -238,7 +236,7 @@ ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, enum ice_status status; u16 buf_size; - buf_size = sizeof(*buf) + sizeof(u32) * (num_nodes - 1); + buf_size = ice_struct_size(buf, teid, num_nodes); buf = (struct ice_aqc_delete_elem *)ice_malloc(hw, buf_size); if (!buf) return ICE_ERR_NO_MEMORY; @@ -284,7 +282,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) @@ -423,7 +421,7 @@ ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req, */ static enum ice_status ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req, - struct ice_aqc_conf_elem *buf, u16 buf_size, + struct ice_aqc_txsched_elem_data *buf, u16 buf_size, u16 *elems_cfgd, struct ice_sq_cd *cd) { return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_cfg_sched_elems, @@ -464,8 +462,7 @@ ice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req, * Suspend scheduling elements (0x0409) */ static enum ice_status -ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, - struct ice_aqc_suspend_resume_elem *buf, +ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, __le32 *buf, u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) { return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_suspend_sched_elems, @@ -485,8 +482,7 @@ ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, * resume scheduling elements (0x040A) */ static enum ice_status -ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req, - struct ice_aqc_suspend_resume_elem *buf, +ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req, __le32 *buf, u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) { return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_resume_sched_elems, @@ -527,18 +523,17 @@ static enum ice_status ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, bool suspend) { - struct ice_aqc_suspend_resume_elem *buf; u16 i, buf_size, num_elem_ret = 0; enum ice_status status; + __le32 *buf; buf_size = sizeof(*buf) * num_nodes; - buf = (struct ice_aqc_suspend_resume_elem *) - ice_malloc(hw, buf_size); + buf = (__le32 *)ice_malloc(hw, buf_size); if (!buf) return ICE_ERR_NO_MEMORY; for (i = 0; i < num_nodes; i++) - buf->teid[i] = CPU_TO_LE32(node_teids[i]); + buf[i] = CPU_TO_LE32(node_teids[i]); if (suspend) status = ice_aq_suspend_sched_elems(hw, num_nodes, buf, @@ -600,18 +595,18 @@ ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs) /** * ice_aq_rl_profile - performs a rate limiting task * @hw: pointer to the HW struct - * @opcode:opcode for add, query, or remove profile(s) + * @opcode: opcode for add, query, or remove profile(s) * @num_profiles: the number of profiles * @buf: pointer to buffer * @buf_size: buffer size in bytes * @num_processed: number of processed add or remove profile(s) to return * @cd: pointer to command details structure * - * Rl profile function to add, query, or remove profile(s) + * RL profile function to add, query, or remove profile(s) */ static enum ice_status ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode, - u16 num_profiles, struct ice_aqc_rl_profile_generic_elem *buf, + u16 num_profiles, struct ice_aqc_rl_profile_elem *buf, u16 buf_size, u16 *num_processed, struct ice_sq_cd *cd) { struct ice_aqc_rl_profile *cmd; @@ -642,13 +637,11 @@ ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode, */ static enum ice_status ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles, - struct ice_aqc_rl_profile_generic_elem *buf, - u16 buf_size, u16 *num_profiles_added, - struct ice_sq_cd *cd) + struct ice_aqc_rl_profile_elem *buf, u16 buf_size, + u16 *num_profiles_added, struct ice_sq_cd *cd) { - return ice_aq_rl_profile(hw, ice_aqc_opc_add_rl_profiles, - num_profiles, buf, - buf_size, num_profiles_added, cd); + return ice_aq_rl_profile(hw, ice_aqc_opc_add_rl_profiles, num_profiles, + buf, buf_size, num_profiles_added, cd); } /** @@ -663,8 +656,8 @@ ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles, */ enum ice_status ice_aq_query_rl_profile(struct ice_hw *hw, u16 num_profiles, - struct ice_aqc_rl_profile_generic_elem *buf, - u16 buf_size, struct ice_sq_cd *cd) + struct ice_aqc_rl_profile_elem *buf, u16 buf_size, + struct ice_sq_cd *cd) { return ice_aq_rl_profile(hw, ice_aqc_opc_query_rl_profiles, num_profiles, buf, buf_size, NULL, cd); @@ -683,13 +676,12 @@ ice_aq_query_rl_profile(struct ice_hw *hw, u16 num_profiles, */ static enum ice_status ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles, - struct ice_aqc_rl_profile_generic_elem *buf, - u16 buf_size, u16 *num_profiles_removed, - struct ice_sq_cd *cd) + struct ice_aqc_rl_profile_elem *buf, u16 buf_size, + u16 *num_profiles_removed, struct ice_sq_cd *cd) { return ice_aq_rl_profile(hw, ice_aqc_opc_remove_rl_profiles, - num_profiles, buf, - buf_size, num_profiles_removed, cd); + num_profiles, buf, buf_size, + num_profiles_removed, cd); } /** @@ -705,7 +697,7 @@ static enum ice_status ice_sched_del_rl_profile(struct ice_hw *hw, struct ice_aqc_rl_profile_info *rl_info) { - struct ice_aqc_rl_profile_generic_elem *buf; + struct ice_aqc_rl_profile_elem *buf; u16 num_profiles_removed; enum ice_status status; u16 num_profiles = 1; @@ -714,8 +706,7 @@ ice_sched_del_rl_profile(struct ice_hw *hw, return ICE_ERR_IN_USE; /* Safe to remove profile ID */ - buf = (struct ice_aqc_rl_profile_generic_elem *) - &rl_info->profile; + buf = &rl_info->profile; status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf), &num_profiles_removed, NULL); if (status || num_profiles_removed != num_profiles) @@ -735,7 +726,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; @@ -750,8 +741,7 @@ static void ice_sched_clear_rl_prof(struct ice_port_info *pi) rl_prof_elem->prof_id_ref = 0; status = ice_sched_del_rl_profile(hw, rl_prof_elem); if (status) { - ice_debug(hw, ICE_DBG_SCHED, - "Remove rl profile failed\n"); + ice_debug(hw, ICE_DBG_SCHED, "Remove rl profile failed\n"); /* On error, free mem required */ LIST_DEL(&rl_prof_elem->list_entry); ice_free(hw, rl_prof_elem); @@ -790,7 +780,7 @@ void ice_sched_clear_agg(struct ice_hw *hw) } /** - * ice_sched_clear_tx_topo - clears the schduler tree nodes + * ice_sched_clear_tx_topo - clears the scheduler tree nodes * @pi: port information structure * * This function removes all the nodes from HW as well as from SW DB. @@ -841,8 +831,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; @@ -862,7 +851,7 @@ void ice_sched_cleanup_all(struct ice_hw *hw) */ enum ice_status ice_aq_cfg_l2_node_cgd(struct ice_hw *hw, u16 num_l2_nodes, - struct ice_aqc_cfg_l2_node_cgd_data *buf, + struct ice_aqc_cfg_l2_node_cgd_elem *buf, u16 buf_size, struct ice_sq_cd *cd) { struct ice_aqc_cfg_l2_node_cgd *cmd; @@ -876,7 +865,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 @@ -902,7 +890,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, u16 buf_size; u32 teid; - buf_size = sizeof(*buf) + sizeof(*buf->generic) * (num_nodes - 1); + buf_size = ice_struct_size(buf, generic, num_nodes); buf = (struct ice_aqc_add_elem *)ice_malloc(hw, buf_size); if (!buf) return ICE_ERR_NO_MEMORY; @@ -940,8 +928,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, for (i = 0; i < num_nodes; i++) { status = ice_sched_add_node(pi, layer, &buf->generic[i]); if (status != ICE_SUCCESS) { - ice_debug(hw, ICE_DBG_SCHED, - "add nodes in SW DB failed status =%d\n", + ice_debug(hw, ICE_DBG_SCHED, "add nodes in SW DB failed status =%d\n", status); break; } @@ -949,8 +936,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, teid = LE32_TO_CPU(buf->generic[i].node_teid); new_node = ice_sched_find_node_by_teid(parent, teid); if (!new_node) { - ice_debug(hw, ICE_DBG_SCHED, - "Node is missing for teid =%d\n", teid); + ice_debug(hw, ICE_DBG_SCHED, "Node is missing for teid =%d\n", teid); break; } @@ -1233,7 +1219,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 == @@ -1307,8 +1293,7 @@ struct ice_sched_node *ice_sched_get_node(struct ice_port_info *pi, u32 teid) ice_release_lock(&pi->sched_lock); if (!node) - ice_debug(pi->hw, ICE_DBG_SCHED, - "Node not found for teid=0x%x\n", teid); + ice_debug(pi->hw, ICE_DBG_SCHED, "Node not found for teid=0x%x\n", teid); return node; } @@ -1366,12 +1351,51 @@ 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; } +/** + * ice_sched_get_psm_clk_freq - determine the PSM clock frequency + * @hw: pointer to the HW struct + * + * Determine the PSM clock frequency and store in HW struct + */ +void ice_sched_get_psm_clk_freq(struct ice_hw *hw) +{ + u32 val, clk_src; + + val = rd32(hw, GLGEN_CLKSTAT_SRC); + clk_src = (val & GLGEN_CLKSTAT_SRC_PSM_CLK_SRC_M) >> + GLGEN_CLKSTAT_SRC_PSM_CLK_SRC_S; + +#define PSM_CLK_SRC_367_MHZ 0x0 +#define PSM_CLK_SRC_416_MHZ 0x1 +#define PSM_CLK_SRC_446_MHZ 0x2 +#define PSM_CLK_SRC_390_MHZ 0x3 + + switch (clk_src) { + case PSM_CLK_SRC_367_MHZ: + hw->psm_clk_freq = ICE_PSM_CLK_367MHZ_IN_HZ; + break; + case PSM_CLK_SRC_416_MHZ: + hw->psm_clk_freq = ICE_PSM_CLK_416MHZ_IN_HZ; + break; + case PSM_CLK_SRC_446_MHZ: + hw->psm_clk_freq = ICE_PSM_CLK_446MHZ_IN_HZ; + break; + case PSM_CLK_SRC_390_MHZ: + hw->psm_clk_freq = ICE_PSM_CLK_390MHZ_IN_HZ; + break; + default: + ice_debug(hw, ICE_DBG_SCHED, "PSM clk_src unexpected %u\n", + clk_src); + /* fall back to a safe default */ + hw->psm_clk_freq = ICE_PSM_CLK_446MHZ_IN_HZ; + } +} + /** * ice_sched_find_node_in_subtree - Find node in part of base node subtree * @hw: pointer to the HW struct @@ -1405,6 +1429,53 @@ ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base, return false; } +/** + * ice_sched_get_free_qgrp - Scan all queue group siblings and find a free node + * @pi: port information structure + * @vsi_node: software VSI handle + * @qgrp_node: first queue group node identified for scanning + * @owner: LAN or RDMA + * + * This function retrieves a free LAN or RDMA queue group node by scanning + * qgrp_node and its siblings for the queue group with the fewest number + * of queues currently assigned. + */ +static struct ice_sched_node * +ice_sched_get_free_qgrp(struct ice_port_info *pi, + struct ice_sched_node *vsi_node, + struct ice_sched_node *qgrp_node, u8 owner) +{ + struct ice_sched_node *min_qgrp; + u8 min_children; + + if (!qgrp_node) + return qgrp_node; + min_children = qgrp_node->num_children; + if (!min_children) + return qgrp_node; + min_qgrp = qgrp_node; + /* scan all queue groups until find a node which has less than the + * minimum number of children. This way all queue group nodes get + * equal number of shares and active. The bandwidth will be equally + * distributed across all queues. + */ + while (qgrp_node) { + /* make sure the qgroup node is part of the VSI subtree */ + if (ice_sched_find_node_in_subtree(pi->hw, vsi_node, qgrp_node)) + if (qgrp_node->num_children < min_children && + qgrp_node->owner == owner) { + /* replace the new min queue group node */ + min_qgrp = qgrp_node; + min_children = min_qgrp->num_children; + /* break if it has no children, */ + if (!min_children) + break; + } + qgrp_node = qgrp_node->sibling; + } + return min_qgrp; +} + /** * ice_sched_get_free_qparent - Get a free LAN or RDMA queue group node * @pi: port information structure @@ -1418,7 +1489,7 @@ struct ice_sched_node * ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 owner) { - struct ice_sched_node *vsi_node, *qgrp_node = NULL; + struct ice_sched_node *vsi_node, *qgrp_node; struct ice_vsi_ctx *vsi_ctx; u16 max_children; u8 qgrp_layer; @@ -1432,7 +1503,7 @@ ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, vsi_node = vsi_ctx->sched.vsi_node[tc]; /* validate invalid VSI ID */ if (!vsi_node) - goto lan_q_exit; + return NULL; /* get the first queue group node from VSI sub-tree */ qgrp_node = ice_sched_get_first_node(pi, vsi_node, qgrp_layer); @@ -1445,13 +1516,13 @@ ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, qgrp_node = qgrp_node->sibling; } -lan_q_exit: - return qgrp_node; + /* Select the best queue group */ + return ice_sched_get_free_qgrp(pi, vsi_node, qgrp_node, owner); } /** * 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 +1530,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 +1551,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 +1559,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) { @@ -1516,7 +1590,7 @@ ice_sched_get_agg_node(struct ice_hw *hw, struct ice_sched_node *tc_node, */ static bool ice_sched_check_node(struct ice_hw *hw, struct ice_sched_node *node) { - struct ice_aqc_get_elem buf; + struct ice_aqc_txsched_elem_data buf; enum ice_status status; u32 node_teid; @@ -1525,7 +1599,7 @@ static bool ice_sched_check_node(struct ice_hw *hw, struct ice_sched_node *node) if (status != ICE_SUCCESS) return false; - if (memcmp(buf.generic, &node->info, sizeof(*buf.generic))) { + if (memcmp(&buf, &node->info, sizeof(buf))) { ice_debug(hw, ICE_DBG_SCHED, "Node mismatch for teid=0x%x\n", node_teid); return false; @@ -1587,7 +1661,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 +1694,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 +1703,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 +1721,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 +1805,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 +1844,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 +1907,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 +1928,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; @@ -1894,8 +1967,7 @@ ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs, * This function removes single aggregator VSI info entry from * aggregator list. */ -static void -ice_sched_rm_agg_vsi_info(struct ice_port_info *pi, u16 vsi_handle) +static void ice_sched_rm_agg_vsi_info(struct ice_port_info *pi, u16 vsi_handle) { struct ice_sched_agg_info *agg_info; struct ice_sched_agg_info *atmp; @@ -1966,13 +2038,12 @@ 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; if (ice_sched_is_leaf_node_present(vsi_node)) { - ice_debug(pi->hw, ICE_DBG_SCHED, - "VSI has leaf nodes in TC %d\n", i); + ice_debug(pi->hw, ICE_DBG_SCHED, "VSI has leaf nodes in TC %d\n", i); status = ICE_ERR_IN_USE; goto exit_sched_rm_vsi_cfg; } @@ -2019,7 +2090,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 @@ -2057,7 +2127,7 @@ bool ice_sched_is_tree_balanced(struct ice_hw *hw, struct ice_sched_node *node) */ enum ice_status ice_aq_query_node_to_root(struct ice_hw *hw, u32 node_teid, - struct ice_aqc_get_elem *buf, u16 buf_size, + struct ice_aqc_txsched_elem_data *buf, u16 buf_size, struct ice_sq_cd *cd) { struct ice_aqc_query_node_to_root *cmd; @@ -2077,7 +2147,7 @@ ice_aq_query_node_to_root(struct ice_hw *hw, u32 node_teid, * This function validates aggregator ID. The function returns info if * aggregator ID is present in list otherwise it returns null. */ -static struct ice_sched_agg_info* +static struct ice_sched_agg_info * ice_get_agg_info(struct ice_hw *hw, u32 agg_id) { struct ice_sched_agg_info *agg_info; @@ -2179,12 +2249,12 @@ 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; + u16 buf_len; hw = pi->hw; @@ -2192,11 +2262,12 @@ ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent, return ICE_ERR_PARAM; /* Does parent have enough space */ - if (parent->num_children + num_items >= + if (parent->num_children + num_items > hw->max_children[parent->tx_sched_layer]) return ICE_ERR_AQ_FULL; - buf = (struct ice_aqc_move_elem *)ice_malloc(hw, sizeof(*buf)); + buf_len = ice_struct_size(buf, teid, 1); + buf = (struct ice_aqc_move_elem *)ice_malloc(hw, buf_len); if (!buf) return ICE_ERR_NO_MEMORY; @@ -2211,7 +2282,7 @@ ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent, buf->hdr.dest_parent_teid = parent->info.node_teid; buf->teid[0] = node->info.node_teid; buf->hdr.num_elems = CPU_TO_LE16(1); - status = ice_aq_move_sched_elems(hw, 1, buf, sizeof(*buf), + status = ice_aq_move_sched_elems(hw, 1, buf, buf_len, &grps_movd, NULL); if (status && grps_movd != 1) { status = ICE_ERR_CFG; @@ -2252,14 +2323,18 @@ 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; + /* Is this VSI already part of given aggregator? */ + if (ice_sched_find_node_in_subtree(pi->hw, agg_node, vsi_node)) + return ICE_SUCCESS; + aggl = ice_sched_get_agg_layer(pi->hw); vsil = ice_sched_get_vsi_layer(pi->hw); @@ -2389,7 +2464,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 +2573,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; @@ -2661,7 +2736,7 @@ ice_cfg_agg(struct ice_port_info *pi, u32 agg_id, enum ice_agg_type agg_type, * The function returns aggregator VSI info based on VSI handle. This function * needs to be called with scheduler lock held. */ -static struct ice_sched_agg_vsi_info* +static struct ice_sched_agg_vsi_info * ice_get_agg_vsi_info(struct ice_sched_agg_info *agg_info, u16 vsi_handle) { struct ice_sched_agg_vsi_info *agg_vsi_info; @@ -2683,7 +2758,7 @@ ice_get_agg_vsi_info(struct ice_sched_agg_info *agg_info, u16 vsi_handle) * VSI has in this case a different aggregator than the default one. This * function needs to be called with scheduler lock held. */ -static struct ice_sched_agg_info* +static struct ice_sched_agg_info * ice_get_vsi_agg_info(struct ice_hw *hw, u16 vsi_handle) { struct ice_sched_agg_info *agg_info; @@ -2800,7 +2875,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; @@ -2810,8 +2885,7 @@ static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi) &pi->rl_prof_list[ln], ice_aqc_rl_profile_info, list_entry) { if (!ice_sched_del_rl_profile(pi->hw, rl_prof_elem)) - ice_debug(pi->hw, ICE_DBG_SCHED, - "Removed rl profile\n"); + ice_debug(pi->hw, ICE_DBG_SCHED, "Removed rl profile\n"); } } } @@ -2822,7 +2896,7 @@ static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi) * @node: pointer to node * @info: node info to update * - * It updates the HW DB, and local SW DB of node. It updates the scheduling + * Update the HW DB, and local SW DB of node. Update the scheduling * parameters of node from argument info data buffer (Info->data buf) and * returns success or error on config sched element failure. The caller * needs to hold scheduler lock. @@ -2831,18 +2905,18 @@ static enum ice_status ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node, struct ice_aqc_txsched_elem_data *info) { - struct ice_aqc_conf_elem buf; + struct ice_aqc_txsched_elem_data buf; enum ice_status status; u16 elem_cfgd = 0; u16 num_elems = 1; - buf.generic[0] = *info; + buf = *info; /* Parent TEID is reserved field in this aq call */ - buf.generic[0].parent_teid = 0; + buf.parent_teid = 0; /* Element type is reserved field in this aq call */ - buf.generic[0].data.elem_type = 0; + buf.data.elem_type = 0; /* Flags is reserved field in this aq call */ - buf.generic[0].data.flags = 0; + buf.data.flags = 0; /* Update HW DB */ /* Configure element node */ @@ -2871,7 +2945,7 @@ ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node, */ static enum ice_status ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node, - enum ice_rl_type rl_type, u8 bw_alloc) + enum ice_rl_type rl_type, u16 bw_alloc) { struct ice_aqc_txsched_elem_data buf; struct ice_aqc_txsched_elem *data; @@ -3043,8 +3117,7 @@ ice_sched_save_vsi_bw_alloc(struct ice_port_info *pi, u16 vsi_handle, u8 tc, * * Save or clear CIR bandwidth (BW) in the passed param bw_t_info. */ -static void -ice_set_clear_cir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) +static void ice_set_clear_cir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) { if (bw == ICE_SCHED_DFLT_BW) { ice_clear_bit(ICE_BW_TYPE_CIR, bw_t_info->bw_t_bitmap); @@ -3063,8 +3136,7 @@ ice_set_clear_cir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) * * Save or clear EIR bandwidth (BW) in the passed param bw_t_info. */ -static void -ice_set_clear_eir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) +static void ice_set_clear_eir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) { if (bw == ICE_SCHED_DFLT_BW) { ice_clear_bit(ICE_BW_TYPE_EIR, bw_t_info->bw_t_bitmap); @@ -3089,8 +3161,7 @@ ice_set_clear_eir_bw(struct ice_bw_type_info *bw_t_info, u32 bw) * * Save or clear shared bandwidth (BW) in the passed param bw_t_info. */ -static void -ice_set_clear_shared_bw(struct ice_bw_type_info *bw_t_info, u32 bw) +static void ice_set_clear_shared_bw(struct ice_bw_type_info *bw_t_info, u32 bw) { if (bw == ICE_SCHED_DFLT_BW) { ice_clear_bit(ICE_BW_TYPE_SHARED, bw_t_info->bw_t_bitmap); @@ -3152,8 +3223,7 @@ ice_sched_save_vsi_bw(struct ice_port_info *pi, u16 vsi_handle, u8 tc, * * Save or clear priority (prio) in the passed param bw_t_info. */ -static void -ice_set_clear_prio(struct ice_bw_type_info *bw_t_info, u8 prio) +static void ice_set_clear_prio(struct ice_bw_type_info *bw_t_info, u8 prio) { bw_t_info->generic = prio; if (bw_t_info->generic) @@ -3435,7 +3505,6 @@ ice_cfg_agg_bw_no_shared_lmt(struct ice_port_info *pi, u32 agg_id) * @pi: port information structure * @num_qs: number of VSI queues * @q_ids: queue IDs array - * @q_ids: queue IDs array * @q_prio: queue priority array * * This function configures the queue node priority (Sibling Priority) of the @@ -3446,7 +3515,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 +3529,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 +3577,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 +3597,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 +3661,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 +3723,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; @@ -3674,11 +3744,12 @@ exit_cfg_agg_bw_alloc: /** * ice_sched_calc_wakeup - calculate RL profile wakeup parameter + * @hw: pointer to the HW struct * @bw: bandwidth in Kbps * * This function calculates the wakeup parameter of RL profile. */ -static u16 ice_sched_calc_wakeup(s32 bw) +static u16 ice_sched_calc_wakeup(struct ice_hw *hw, s32 bw) { s64 bytes_per_sec, wakeup_int, wakeup_a, wakeup_b, wakeup_f; s32 wakeup_f_int; @@ -3686,7 +3757,7 @@ static u16 ice_sched_calc_wakeup(s32 bw) /* Get the wakeup integer value */ bytes_per_sec = DIV_64BIT(((s64)bw * 1000), BITS_PER_BYTE); - wakeup_int = DIV_64BIT(ICE_RL_PROF_FREQUENCY, bytes_per_sec); + wakeup_int = DIV_64BIT(hw->psm_clk_freq, bytes_per_sec); if (wakeup_int > 63) { wakeup = (u16)((1 << 15) | wakeup_int); } else { @@ -3695,7 +3766,7 @@ static u16 ice_sched_calc_wakeup(s32 bw) */ wakeup_b = (s64)ICE_RL_PROF_MULTIPLIER * wakeup_int; wakeup_a = DIV_64BIT((s64)ICE_RL_PROF_MULTIPLIER * - ICE_RL_PROF_FREQUENCY, bytes_per_sec); + hw->psm_clk_freq, bytes_per_sec); /* Get Fraction value */ wakeup_f = wakeup_a - wakeup_b; @@ -3715,13 +3786,15 @@ static u16 ice_sched_calc_wakeup(s32 bw) /** * ice_sched_bw_to_rl_profile - convert BW to profile parameters + * @hw: pointer to the HW struct * @bw: bandwidth in Kbps * @profile: profile parameters to return * * This function converts the BW to profile structure format. */ static enum ice_status -ice_sched_bw_to_rl_profile(u32 bw, struct ice_aqc_rl_profile_elem *profile) +ice_sched_bw_to_rl_profile(struct ice_hw *hw, u32 bw, + struct ice_aqc_rl_profile_elem *profile) { enum ice_status status = ICE_ERR_PARAM; s64 bytes_per_sec, ts_rate, mv_tmp; @@ -3741,7 +3814,7 @@ ice_sched_bw_to_rl_profile(u32 bw, struct ice_aqc_rl_profile_elem *profile) for (i = 0; i < 64; i++) { u64 pow_result = BIT_ULL(i); - ts_rate = DIV_64BIT((s64)ICE_RL_PROF_FREQUENCY, + ts_rate = DIV_64BIT((s64)hw->psm_clk_freq, pow_result * ICE_RL_PROF_TS_MULTIPLIER); if (ts_rate <= 0) continue; @@ -3765,7 +3838,7 @@ ice_sched_bw_to_rl_profile(u32 bw, struct ice_aqc_rl_profile_elem *profile) if (found) { u16 wm; - wm = ice_sched_calc_wakeup(bw); + wm = ice_sched_calc_wakeup(hw, bw); profile->rl_multiply = CPU_TO_LE16(mv); profile->wake_up_calc = CPU_TO_LE16(wm); profile->rl_encode = CPU_TO_LE16(encode); @@ -3794,13 +3867,15 @@ static struct ice_aqc_rl_profile_info * ice_sched_add_rl_profile(struct ice_port_info *pi, enum ice_rl_type rl_type, u32 bw, u8 layer_num) { - 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; + struct ice_aqc_rl_profile_elem *buf; + 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; @@ -3820,8 +3895,8 @@ ice_sched_add_rl_profile(struct ice_port_info *pi, hw = pi->hw; LIST_FOR_EACH_ENTRY(rl_prof_elem, &pi->rl_prof_list[layer_num], ice_aqc_rl_profile_info, list_entry) - if (rl_prof_elem->profile.flags == profile_type && - rl_prof_elem->bw == bw) + if ((rl_prof_elem->profile.flags & ICE_AQC_RL_PROFILE_TYPE_M) == + profile_type && rl_prof_elem->bw == bw) /* Return existing profile ID info */ return rl_prof_elem; @@ -3832,7 +3907,7 @@ ice_sched_add_rl_profile(struct ice_port_info *pi, if (!rl_prof_elem) return NULL; - status = ice_sched_bw_to_rl_profile(bw, &rl_prof_elem->profile); + status = ice_sched_bw_to_rl_profile(hw, bw, &rl_prof_elem->profile); if (status != ICE_SUCCESS) goto exit_add_rl_prof; @@ -3843,8 +3918,7 @@ ice_sched_add_rl_profile(struct ice_port_info *pi, rl_prof_elem->profile.max_burst_size = CPU_TO_LE16(hw->max_burst_size); /* Create new entry in HW DB */ - buf = (struct ice_aqc_rl_profile_generic_elem *) - &rl_prof_elem->profile; + buf = &rl_prof_elem->profile; status = ice_aq_add_rl_profile(hw, num_profiles, buf, sizeof(*buf), &profiles_added, NULL); if (status || profiles_added != num_profiles) @@ -4047,10 +4121,13 @@ 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) - if (rl_prof_elem->profile.flags == profile_type && + if ((rl_prof_elem->profile.flags & ICE_AQC_RL_PROFILE_TYPE_M) == + profile_type && LE16_TO_CPU(rl_prof_elem->profile.profile_id) == profile_id) { if (rl_prof_elem->prof_id_ref) @@ -4059,8 +4136,7 @@ ice_sched_rm_rl_profile(struct ice_port_info *pi, u8 layer_num, u8 profile_type, /* Remove old profile ID from database */ status = ice_sched_del_rl_profile(pi->hw, rl_prof_elem); if (status && status != ICE_ERR_IN_USE) - ice_debug(pi->hw, ICE_DBG_SCHED, - "Remove rl profile failed\n"); + ice_debug(pi->hw, ICE_DBG_SCHED, "Remove rl profile failed\n"); break; } if (status == ICE_ERR_IN_USE) @@ -4212,8 +4288,8 @@ ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node, return ICE_SUCCESS; return ice_sched_rm_rl_profile(pi, layer_num, - rl_prof_info->profile.flags, - old_id); + rl_prof_info->profile.flags & + ICE_AQC_RL_PROFILE_TYPE_M, old_id); } /** @@ -4452,19 +4528,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 +4625,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 +4781,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 +4875,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 +4934,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 +4992,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 +5063,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 +5088,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 +5096,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; @@ -5060,16 +5135,15 @@ enum ice_status ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes) if (bytes < ICE_MIN_BURST_SIZE_ALLOWED || bytes > ICE_MAX_BURST_SIZE_ALLOWED) return ICE_ERR_PARAM; - if (bytes <= ICE_MAX_BURST_SIZE_BYTE_GRANULARITY) { - /* byte granularity case */ + if (ice_round_to_num(bytes, 64) <= + ICE_MAX_BURST_SIZE_64_BYTE_GRANULARITY) { + /* 64 byte granularity case */ /* Disable MSB granularity bit */ - burst_size_to_prog = ICE_BYTE_GRANULARITY; - /* round number to nearest 256 granularity */ - bytes = ice_round_to_num(bytes, 256); - /* check rounding doesn't go beyond allowed */ - if (bytes > ICE_MAX_BURST_SIZE_BYTE_GRANULARITY) - bytes = ICE_MAX_BURST_SIZE_BYTE_GRANULARITY; - burst_size_to_prog |= (u16)bytes; + burst_size_to_prog = ICE_64_BYTE_GRANULARITY; + /* round number to nearest 64 byte granularity */ + bytes = ice_round_to_num(bytes, 64); + /* The value is in 64 byte chunks */ + burst_size_to_prog |= (u16)(bytes / 64); } else { /* k bytes granularity case */ /* Enable MSB granularity bit */ @@ -5086,7 +5160,7 @@ enum ice_status ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes) return ICE_SUCCESS; } -/* +/** * ice_sched_replay_node_prio - re-configure node priority * @hw: pointer to the HW struct * @node: sched node to configure @@ -5198,7 +5272,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; @@ -5250,7 +5324,7 @@ void ice_sched_replay_agg(struct ice_hw *hw) ice_acquire_lock(&pi->sched_lock); LIST_FOR_EACH_ENTRY(agg_info, &hw->agg_list, ice_sched_agg_info, - list_entry) { + list_entry) /* replay aggregator (re-create aggregator node) */ if (!ice_cmp_bitmap(agg_info->tc_bitmap, agg_info->replay_tc_bitmap, @@ -5259,8 +5333,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); @@ -5280,7 +5353,6 @@ void ice_sched_replay_agg(struct ice_hw *hw) ice_info(hw, "Replay agg bw [id=%d] failed\n", agg_info->agg_id); } - } ice_release_lock(&pi->sched_lock); } @@ -5309,28 +5381,48 @@ void ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw) ice_release_lock(&pi->sched_lock); } +/** + * ice_sched_replay_root_node_bw - replay root node BW + * @pi: port information structure + * + * Replay root node BW settings. + */ +enum ice_status ice_sched_replay_root_node_bw(struct ice_port_info *pi) +{ + enum ice_status status = ICE_SUCCESS; + + if (!pi->hw) + return ICE_ERR_PARAM; + ice_acquire_lock(&pi->sched_lock); + + status = ice_sched_replay_node_bw(pi->hw, pi->root, + &pi->root_node_bw_t_info); + ice_release_lock(&pi->sched_lock); + return status; +} + /** * 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) +enum ice_status 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; } @@ -5367,7 +5459,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]; @@ -5396,7 +5488,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); @@ -5438,8 +5530,7 @@ ice_sched_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) * This function replays association of VSI to aggregator type nodes, and * node bandwidth information. */ -enum ice_status -ice_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) +enum ice_status ice_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) { struct ice_port_info *pi = hw->port_info; enum ice_status status;