- return ICE_SUCCESS;
-}
-
-/**
- * ice_sched_set_vsi_bw_shared_lmt - set VSI bw shared limit
- * @pi: port information structure
- * @vsi_handle: software VSI handle
- * @bw: bandwidth in kbps
- *
- * This function Configures shared rate limiter(SRL) of all VSI type nodes
- * across all traffic classes for VSI matching handle. When bw value of
- * ICE_SCHED_DFLT_BW is passed, it removes the SRL from the node.
- */
-enum ice_status
-ice_sched_set_vsi_bw_shared_lmt(struct ice_port_info *pi, u16 vsi_handle,
- u32 bw)
-{
- enum ice_status status = ICE_SUCCESS;
- u8 tc;
-
- if (!pi)
- return ICE_ERR_PARAM;
-
- if (!ice_is_vsi_valid(pi->hw, vsi_handle))
- return ICE_ERR_PARAM;
-
- ice_acquire_lock(&pi->sched_lock);
- status = ice_sched_validate_vsi_srl_node(pi, vsi_handle);
- if (status)
- goto exit_set_vsi_bw_shared_lmt;
- /* Return success if no nodes are present across tc */
- for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
- struct ice_sched_node *tc_node, *vsi_node;
- enum ice_rl_type rl_type = ICE_SHARED_BW;
-
- tc_node = ice_sched_get_tc_node(pi, tc);
- if (!tc_node)
- continue;
-
- vsi_node = ice_sched_get_vsi_node(pi->hw, tc_node, vsi_handle);
- if (!vsi_node)
- continue;
-
- if (bw == ICE_SCHED_DFLT_BW)
- /* It removes existing SRL from the node */
- status = ice_sched_set_node_bw_dflt_lmt(pi, vsi_node,
- rl_type);
- else
- status = ice_sched_set_node_bw_lmt(pi, vsi_node,
- rl_type, bw);
- if (status)
- break;
- status = ice_sched_save_vsi_bw(pi, vsi_handle, tc, rl_type, bw);
- if (status)
- break;
- }
-
-exit_set_vsi_bw_shared_lmt:
- ice_release_lock(&pi->sched_lock);
- return status;
-}
-
-/**
- * ice_sched_validate_agg_srl_node - validate AGG SRL node
- * @pi: port information structure
- * @agg_id: aggregator id
- *
- * This function validates SRL node of the AGG node if available SRL layer is
- * different than the AGG node layer on all tc(s).This function needs to be
- * called with scheduler lock held.
- */
-static enum ice_status
-ice_sched_validate_agg_srl_node(struct ice_port_info *pi, u32 agg_id)
-{
- u8 sel_layer = ICE_SCHED_INVAL_LAYER_NUM;
- struct ice_sched_agg_info *agg_info;
- bool agg_id_present = false;
- enum ice_status status = ICE_SUCCESS;
- u8 tc;
-
- LIST_FOR_EACH_ENTRY(agg_info, &pi->hw->agg_list, ice_sched_agg_info,
- list_entry)
- if (agg_info->agg_id == agg_id) {
- agg_id_present = true;
- break;
- }
- if (!agg_id_present)
- return ICE_ERR_PARAM;
- /* Return success if no nodes are present across tc */
- for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
- struct ice_sched_node *tc_node, *agg_node;
- enum ice_rl_type rl_type = ICE_SHARED_BW;
-
- tc_node = ice_sched_get_tc_node(pi, tc);
- if (!tc_node)
- continue;
-
- agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
- if (!agg_node)
- continue;
- /* SRL bandwidth layer selection */
- if (sel_layer == ICE_SCHED_INVAL_LAYER_NUM) {
- u8 node_layer = agg_node->tx_sched_layer;
- u8 layer_num;
-
- layer_num = ice_sched_get_rl_prof_layer(pi, rl_type,
- node_layer);
- if (layer_num >= pi->hw->num_tx_sched_layers)
- return ICE_ERR_PARAM;
- sel_layer = layer_num;
- }
-
- status = ice_sched_validate_srl_node(agg_node, sel_layer);
- if (status)
- break;
- }
- return status;
-}
-
-/**
- * ice_sched_set_agg_bw_shared_lmt - set aggregator bw shared limit
- * @pi: port information structure
- * @agg_id: aggregator id
- * @bw: bandwidth in kbps
- *
- * This function configures the shared rate limiter(SRL) of all agg type
- * nodes across all traffic classes for aggregator matching agg_id. When
- * bw value of ICE_SCHED_DFLT_BW is passed, it removes SRL from the
- * node(s).
- */
-enum ice_status
-ice_sched_set_agg_bw_shared_lmt(struct ice_port_info *pi, u32 agg_id, u32 bw)
-{
- struct ice_sched_agg_info *agg_info;
- struct ice_sched_agg_info *tmp;
- bool agg_id_present = false;
- enum ice_status status = ICE_SUCCESS;
- u8 tc;
-
- if (!pi)
- return ICE_ERR_PARAM;
-
- ice_acquire_lock(&pi->sched_lock);
- status = ice_sched_validate_agg_srl_node(pi, agg_id);
- if (status)
- goto exit_agg_bw_shared_lmt;
-
- LIST_FOR_EACH_ENTRY_SAFE(agg_info, tmp, &pi->hw->agg_list,
- ice_sched_agg_info, list_entry)
- if (agg_info->agg_id == agg_id) {
- agg_id_present = true;
- break;
- }
-
- if (!agg_id_present) {
- status = ICE_ERR_PARAM;
- goto exit_agg_bw_shared_lmt;
- }
-
- /* Return success if no nodes are present across tc */
- for (tc = 0; tc < ICE_MAX_TRAFFIC_CLASS; tc++) {
- enum ice_rl_type rl_type = ICE_SHARED_BW;
- struct ice_sched_node *tc_node, *agg_node;
-
- tc_node = ice_sched_get_tc_node(pi, tc);
- if (!tc_node)
- continue;
-
- agg_node = ice_sched_get_agg_node(pi->hw, tc_node, agg_id);
- if (!agg_node)
- continue;
-
- if (bw == ICE_SCHED_DFLT_BW)
- /* It removes existing SRL from the node */
- status = ice_sched_set_node_bw_dflt_lmt(pi, agg_node,
- rl_type);
- else
- status = ice_sched_set_node_bw_lmt(pi, agg_node,
- rl_type, bw);
- if (status)
- break;
- status = ice_sched_save_agg_bw(pi, agg_id, tc, rl_type, bw);
- if (status)
- break;
- }
-
-exit_agg_bw_shared_lmt:
- ice_release_lock(&pi->sched_lock);
- return status;
-}
-
-/**
- * ice_sched_cfg_sibl_node_prio - configure node sibling priority
- * @hw: pointer to the hw struct
- * @node: sched node to configure
- * @priority: sibling priority
- *
- * This function configures node element's sibling priority only. This
- * 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)
-{
- struct ice_aqc_txsched_elem_data buf;
- struct ice_aqc_txsched_elem *data;
- enum ice_status status;
-
- buf = node->info;
- data = &buf.data;
- data->valid_sections |= ICE_AQC_ELEM_VALID_GENERIC;
- priority = (priority << ICE_AQC_ELEM_GENERIC_PRIO_S) &
- ICE_AQC_ELEM_GENERIC_PRIO_M;
- data->generic &= ~ICE_AQC_ELEM_GENERIC_PRIO_M;
- data->generic |= priority;
-
- /* Configure element */
- status = ice_sched_update_elem(hw, node, &buf);
- return status;