// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2018, Intel Corporation. */ #include <net/devlink.h> #include "ice_sched.h" /** * ice_sched_add_root_node - Insert the Tx scheduler root node in SW DB * @pi: port information structure * @info: Scheduler element information from firmware * * This function inserts the root node of the scheduling tree topology * to the SW DB. */ static int ice_sched_add_root_node(struct ice_port_info *pi, struct ice_aqc_txsched_elem_data *info) { … } /** * ice_sched_find_node_by_teid - Find the Tx scheduler node in SW DB * @start_node: pointer to the starting ice_sched_node struct in a sub-tree * @teid: node TEID to search * * This function searches for a node matching the TEID in the scheduling tree * from the SW DB. The search is recursive and is restricted by the number of * layers it has searched through; stopping at the max supported layer. * * This function needs to be called when holding the port_info->sched_lock */ struct ice_sched_node * ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid) { … } /** * ice_aqc_send_sched_elem_cmd - send scheduling elements cmd * @hw: pointer to the HW struct * @cmd_opc: cmd opcode * @elems_req: number of elements to request * @buf: pointer to buffer * @buf_size: buffer size in bytes * @elems_resp: returns total number of elements response * @cd: pointer to command details structure or NULL * * This function sends a scheduling elements cmd (cmd_opc) */ static int ice_aqc_send_sched_elem_cmd(struct ice_hw *hw, enum ice_adminq_opc cmd_opc, u16 elems_req, void *buf, u16 buf_size, u16 *elems_resp, struct ice_sq_cd *cd) { … } /** * ice_aq_query_sched_elems - query scheduler elements * @hw: pointer to the HW struct * @elems_req: number of elements to query * @buf: pointer to buffer * @buf_size: buffer size in bytes * @elems_ret: returns total number of elements returned * @cd: pointer to command details structure or NULL * * Query scheduling elements (0x0404) */ int ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, struct ice_aqc_txsched_elem_data *buf, u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) { … } /** * ice_sched_add_node - Insert the Tx scheduler node in SW DB * @pi: port information structure * @layer: Scheduler layer of the node * @info: Scheduler element information from firmware * @prealloc_node: preallocated ice_sched_node struct for SW DB * * This function inserts a scheduler node to the SW DB. */ int ice_sched_add_node(struct ice_port_info *pi, u8 layer, struct ice_aqc_txsched_elem_data *info, struct ice_sched_node *prealloc_node) { … } /** * ice_aq_delete_sched_elems - delete scheduler elements * @hw: pointer to the HW struct * @grps_req: number of groups to delete * @buf: pointer to buffer * @buf_size: buffer size in bytes * @grps_del: returns total number of elements deleted * @cd: pointer to command details structure or NULL * * Delete scheduling elements (0x040F) */ static int ice_aq_delete_sched_elems(struct ice_hw *hw, u16 grps_req, struct ice_aqc_delete_elem *buf, u16 buf_size, u16 *grps_del, struct ice_sq_cd *cd) { … } /** * ice_sched_remove_elems - remove nodes from HW * @hw: pointer to the HW struct * @parent: pointer to the parent node * @node_teid: node teid to be deleted * * This function remove nodes from HW */ static int ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, u32 node_teid) { … } /** * ice_sched_get_first_node - get the first node of the given layer * @pi: port information structure * @parent: pointer the base node of the subtree * @layer: layer number * * This function retrieves the first node of the given layer from the subtree */ static struct ice_sched_node * ice_sched_get_first_node(struct ice_port_info *pi, struct ice_sched_node *parent, u8 layer) { … } /** * ice_sched_get_tc_node - get pointer to TC node * @pi: port information structure * @tc: TC number * * This function returns the TC node pointer */ struct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc) { … } /** * ice_free_sched_node - Free a Tx scheduler node from SW DB * @pi: port information structure * @node: pointer to the ice_sched_node struct * * This function frees up a node from SW DB as well as from HW * * This function needs to be called with the port_info->sched_lock held */ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node) { … } /** * ice_aq_get_dflt_topo - gets default scheduler topology * @hw: pointer to the HW struct * @lport: logical port number * @buf: pointer to buffer * @buf_size: buffer size in bytes * @num_branches: returns total number of queue to port branches * @cd: pointer to command details structure or NULL * * Get default scheduler topology (0x400) */ static int ice_aq_get_dflt_topo(struct ice_hw *hw, u8 lport, struct ice_aqc_get_topo_elem *buf, u16 buf_size, u8 *num_branches, struct ice_sq_cd *cd) { … } /** * ice_aq_add_sched_elems - adds scheduling element * @hw: pointer to the HW struct * @grps_req: the number of groups that are requested to be added * @buf: pointer to buffer * @buf_size: buffer size in bytes * @grps_added: returns total number of groups added * @cd: pointer to command details structure or NULL * * Add scheduling elements (0x0401) */ static int ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req, struct ice_aqc_add_elem *buf, u16 buf_size, u16 *grps_added, struct ice_sq_cd *cd) { … } /** * ice_aq_cfg_sched_elems - configures scheduler elements * @hw: pointer to the HW struct * @elems_req: number of elements to configure * @buf: pointer to buffer * @buf_size: buffer size in bytes * @elems_cfgd: returns total number of elements configured * @cd: pointer to command details structure or NULL * * Configure scheduling elements (0x0403) */ static int ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req, struct ice_aqc_txsched_elem_data *buf, u16 buf_size, u16 *elems_cfgd, struct ice_sq_cd *cd) { … } /** * ice_aq_move_sched_elems - move scheduler element (just 1 group) * @hw: pointer to the HW struct * @buf: pointer to buffer * @buf_size: buffer size in bytes * @grps_movd: returns total number of groups moved * * Move scheduling elements (0x0408) */ int ice_aq_move_sched_elems(struct ice_hw *hw, struct ice_aqc_move_elem *buf, u16 buf_size, u16 *grps_movd) { … } /** * ice_aq_suspend_sched_elems - suspend scheduler elements * @hw: pointer to the HW struct * @elems_req: number of elements to suspend * @buf: pointer to buffer * @buf_size: buffer size in bytes * @elems_ret: returns total number of elements suspended * @cd: pointer to command details structure or NULL * * Suspend scheduling elements (0x0409) */ static int 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) { … } /** * ice_aq_resume_sched_elems - resume scheduler elements * @hw: pointer to the HW struct * @elems_req: number of elements to resume * @buf: pointer to buffer * @buf_size: buffer size in bytes * @elems_ret: returns total number of elements resumed * @cd: pointer to command details structure or NULL * * resume scheduling elements (0x040A) */ static int 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) { … } /** * ice_aq_query_sched_res - query scheduler resource * @hw: pointer to the HW struct * @buf_size: buffer size in bytes * @buf: pointer to buffer * @cd: pointer to command details structure or NULL * * Query scheduler resource allocation (0x0412) */ static int ice_aq_query_sched_res(struct ice_hw *hw, u16 buf_size, struct ice_aqc_query_txsched_res_resp *buf, struct ice_sq_cd *cd) { … } /** * ice_sched_suspend_resume_elems - suspend or resume HW nodes * @hw: pointer to the HW struct * @num_nodes: number of nodes * @node_teids: array of node teids to be suspended or resumed * @suspend: true means suspend / false means resume * * This function suspends or resumes HW nodes */ int ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, bool suspend) { … } /** * ice_alloc_lan_q_ctx - allocate LAN queue contexts for the given VSI and TC * @hw: pointer to the HW struct * @vsi_handle: VSI handle * @tc: TC number * @new_numqs: number of queues */ static int ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs) { … } /** * ice_alloc_rdma_q_ctx - allocate RDMA queue contexts for the given VSI and TC * @hw: pointer to the HW struct * @vsi_handle: VSI handle * @tc: TC number * @new_numqs: number of queues */ static int ice_alloc_rdma_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) * @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) */ static int ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode, u16 num_profiles, struct ice_aqc_rl_profile_elem *buf, u16 buf_size, u16 *num_processed, struct ice_sq_cd *cd) { … } /** * ice_aq_add_rl_profile - adds rate limiting profile(s) * @hw: pointer to the HW struct * @num_profiles: the number of profile(s) to be add * @buf: pointer to buffer * @buf_size: buffer size in bytes * @num_profiles_added: total number of profiles added to return * @cd: pointer to command details structure * * Add RL profile (0x0410) */ static int ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles, struct ice_aqc_rl_profile_elem *buf, u16 buf_size, u16 *num_profiles_added, struct ice_sq_cd *cd) { … } /** * ice_aq_remove_rl_profile - removes RL profile(s) * @hw: pointer to the HW struct * @num_profiles: the number of profile(s) to remove * @buf: pointer to buffer * @buf_size: buffer size in bytes * @num_profiles_removed: total number of profiles removed to return * @cd: pointer to command details structure or NULL * * Remove RL profile (0x0415) */ static int ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles, struct ice_aqc_rl_profile_elem *buf, u16 buf_size, u16 *num_profiles_removed, struct ice_sq_cd *cd) { … } /** * ice_sched_del_rl_profile - remove RL profile * @hw: pointer to the HW struct * @rl_info: rate limit profile information * * If the profile ID is not referenced anymore, it removes profile ID with * its associated parameters from HW DB,and locally. The caller needs to * hold scheduler lock. */ static int ice_sched_del_rl_profile(struct ice_hw *hw, struct ice_aqc_rl_profile_info *rl_info) { … } /** * ice_sched_clear_rl_prof - clears RL prof entries * @pi: port information structure * * This function removes all RL profile from HW as well as from SW DB. */ static void ice_sched_clear_rl_prof(struct ice_port_info *pi) { … } /** * ice_sched_clear_agg - clears the aggregator related information * @hw: pointer to the hardware structure * * This function removes aggregator list and free up aggregator related memory * previously allocated. */ void ice_sched_clear_agg(struct ice_hw *hw) { … } /** * 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. */ static void ice_sched_clear_tx_topo(struct ice_port_info *pi) { … } /** * ice_sched_clear_port - clear the scheduler elements from SW DB for a port * @pi: port information structure * * Cleanup scheduling elements from SW DB */ void ice_sched_clear_port(struct ice_port_info *pi) { … } /** * ice_sched_cleanup_all - cleanup scheduler elements from SW DB for all ports * @hw: pointer to the HW struct * * Cleanup scheduling elements from SW DB for all the ports */ void ice_sched_cleanup_all(struct ice_hw *hw) { … } /** * ice_sched_add_elems - add nodes to HW and SW DB * @pi: port information structure * @tc_node: pointer to the branch node * @parent: pointer to the parent node * @layer: layer number to add nodes * @num_nodes: number of nodes * @num_nodes_added: pointer to num nodes added * @first_node_teid: if new nodes are added then return the TEID of first node * @prealloc_nodes: preallocated nodes struct for software DB * * This function add nodes to HW as well as to SW DB for a given layer */ int ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, struct ice_sched_node *parent, u8 layer, u16 num_nodes, u16 *num_nodes_added, u32 *first_node_teid, struct ice_sched_node **prealloc_nodes) { … } /** * ice_sched_add_nodes_to_hw_layer - Add nodes to HW layer * @pi: port information structure * @tc_node: pointer to TC node * @parent: pointer to parent node * @layer: layer number to add nodes * @num_nodes: number of nodes to be added * @first_node_teid: pointer to the first node TEID * @num_nodes_added: pointer to number of nodes added * * Add nodes into specific HW layer. */ static int ice_sched_add_nodes_to_hw_layer(struct ice_port_info *pi, struct ice_sched_node *tc_node, struct ice_sched_node *parent, u8 layer, u16 num_nodes, u32 *first_node_teid, u16 *num_nodes_added) { … } /** * ice_sched_add_nodes_to_layer - Add nodes to a given layer * @pi: port information structure * @tc_node: pointer to TC node * @parent: pointer to parent node * @layer: layer number to add nodes * @num_nodes: number of nodes to be added * @first_node_teid: pointer to the first node TEID * @num_nodes_added: pointer to number of nodes added * * This function add nodes to a given layer. */ int ice_sched_add_nodes_to_layer(struct ice_port_info *pi, struct ice_sched_node *tc_node, struct ice_sched_node *parent, u8 layer, u16 num_nodes, u32 *first_node_teid, u16 *num_nodes_added) { … } /** * ice_sched_get_qgrp_layer - get the current queue group layer number * @hw: pointer to the HW struct * * This function returns the current queue group layer number */ static u8 ice_sched_get_qgrp_layer(struct ice_hw *hw) { … } /** * ice_sched_get_vsi_layer - get the current VSI layer number * @hw: pointer to the HW struct * * This function returns the current VSI layer number */ u8 ice_sched_get_vsi_layer(struct ice_hw *hw) { … } /** * ice_sched_get_agg_layer - get the current aggregator layer number * @hw: pointer to the HW struct * * This function returns the current aggregator layer number */ u8 ice_sched_get_agg_layer(struct ice_hw *hw) { … } /** * ice_rm_dflt_leaf_node - remove the default leaf node in the tree * @pi: port information structure * * This function removes the leaf node that was created by the FW * during initialization */ static void ice_rm_dflt_leaf_node(struct ice_port_info *pi) { … } /** * ice_sched_rm_dflt_nodes - free the default nodes in the tree * @pi: port information structure * * This function frees all the nodes except root and TC that were created by * the FW during initialization */ static void ice_sched_rm_dflt_nodes(struct ice_port_info *pi) { … } /** * ice_sched_init_port - Initialize scheduler by querying information from FW * @pi: port info structure for the tree to cleanup * * This function is the initial call to find the total number of Tx scheduler * resources, default topology created by firmware and storing the information * in SW DB. */ int ice_sched_init_port(struct ice_port_info *pi) { … } /** * ice_sched_query_res_alloc - query the FW for num of logical sched layers * @hw: pointer to the HW struct * * query FW for allocated scheduler resources and store in HW struct */ int ice_sched_query_res_alloc(struct ice_hw *hw) { … } /** * 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) { … } /** * ice_sched_find_node_in_subtree - Find node in part of base node subtree * @hw: pointer to the HW struct * @base: pointer to the base node * @node: pointer to the node to search * * This function checks whether a given node is part of the base node * subtree or not */ static bool ice_sched_find_node_in_subtree(struct ice_hw *hw, struct ice_sched_node *base, struct ice_sched_node *node) { … } /** * 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) { … } /** * ice_sched_get_free_qparent - Get a free LAN or RDMA queue group node * @pi: port information structure * @vsi_handle: software VSI handle * @tc: branch number * @owner: LAN or RDMA * * This function retrieves a free LAN or RDMA queue group node */ struct ice_sched_node * ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 owner) { … } /** * ice_sched_get_vsi_node - Get a VSI node based on VSI ID * @pi: pointer to the port information structure * @tc_node: pointer to the TC node * @vsi_handle: software VSI handle * * This function retrieves a VSI node for a given VSI ID from a given * TC branch */ static struct ice_sched_node * ice_sched_get_vsi_node(struct ice_port_info *pi, struct ice_sched_node *tc_node, u16 vsi_handle) { … } /** * ice_sched_get_agg_node - Get an aggregator node based on aggregator ID * @pi: pointer to the port information structure * @tc_node: pointer to the TC node * @agg_id: aggregator ID * * This function retrieves an aggregator node for a given aggregator ID from * a given TC branch */ struct ice_sched_node * ice_sched_get_agg_node(struct ice_port_info *pi, struct ice_sched_node *tc_node, u32 agg_id) { … } /** * ice_sched_calc_vsi_child_nodes - calculate number of VSI child nodes * @hw: pointer to the HW struct * @num_qs: number of queues * @num_nodes: num nodes array * * This function calculates the number of VSI child nodes based on the * number of queues. */ static void ice_sched_calc_vsi_child_nodes(struct ice_hw *hw, u16 num_qs, u16 *num_nodes) { … } /** * ice_sched_add_vsi_child_nodes - add VSI child nodes to tree * @pi: port information structure * @vsi_handle: software VSI handle * @tc_node: pointer to the TC node * @num_nodes: pointer to the num nodes that needs to be added per layer * @owner: node owner (LAN or RDMA) * * This function adds the VSI child nodes to tree. It gets called for * LAN and RDMA separately. */ static int ice_sched_add_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle, struct ice_sched_node *tc_node, u16 *num_nodes, u8 owner) { … } /** * ice_sched_calc_vsi_support_nodes - calculate number of VSI support nodes * @pi: pointer to the port info structure * @tc_node: pointer to TC node * @num_nodes: pointer to num nodes array * * This function calculates the number of supported nodes needed to add this * VSI into Tx tree including the VSI, parent and intermediate nodes in below * layers */ static void ice_sched_calc_vsi_support_nodes(struct ice_port_info *pi, struct ice_sched_node *tc_node, u16 *num_nodes) { … } /** * ice_sched_add_vsi_support_nodes - add VSI supported nodes into Tx tree * @pi: port information structure * @vsi_handle: software VSI handle * @tc_node: pointer to TC node * @num_nodes: pointer to num nodes array * * This function adds the VSI supported nodes into Tx tree including the * VSI, its parent and intermediate nodes in below layers */ static int ice_sched_add_vsi_support_nodes(struct ice_port_info *pi, u16 vsi_handle, struct ice_sched_node *tc_node, u16 *num_nodes) { … } /** * ice_sched_add_vsi_to_topo - add a new VSI into tree * @pi: port information structure * @vsi_handle: software VSI handle * @tc: TC number * * This function adds a new VSI into scheduler tree */ static int ice_sched_add_vsi_to_topo(struct ice_port_info *pi, u16 vsi_handle, u8 tc) { … } /** * ice_sched_update_vsi_child_nodes - update VSI child nodes * @pi: port information structure * @vsi_handle: software VSI handle * @tc: TC number * @new_numqs: new number of max queues * @owner: owner of this subtree * * This function updates the VSI child nodes based on the number of queues */ static int ice_sched_update_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 new_numqs, u8 owner) { … } /** * ice_sched_cfg_vsi - configure the new/existing VSI * @pi: port information structure * @vsi_handle: software VSI handle * @tc: TC number * @maxqs: max number of queues * @owner: LAN or RDMA * @enable: TC enabled or disabled * * This function adds/updates VSI nodes based on the number of queues. If TC is * enabled and VSI is in suspended state then resume the VSI back. If TC is * disabled then suspend the VSI if it is not already. */ int ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs, u8 owner, bool enable) { … } /** * ice_sched_rm_agg_vsi_info - remove aggregator related VSI info entry * @pi: port information structure * @vsi_handle: software VSI handle * * 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) { … } /** * ice_sched_is_leaf_node_present - check for a leaf node in the sub-tree * @node: pointer to the sub-tree node * * This function checks for a leaf node presence in a given sub-tree node. */ static bool ice_sched_is_leaf_node_present(struct ice_sched_node *node) { … } /** * ice_sched_rm_vsi_cfg - remove the VSI and its children nodes * @pi: port information structure * @vsi_handle: software VSI handle * @owner: LAN or RDMA * * This function removes the VSI and its LAN or RDMA children nodes from the * scheduler tree. */ static int ice_sched_rm_vsi_cfg(struct ice_port_info *pi, u16 vsi_handle, u8 owner) { … } /** * ice_rm_vsi_lan_cfg - remove VSI and its LAN children nodes * @pi: port information structure * @vsi_handle: software VSI handle * * This function clears the VSI and its LAN children nodes from scheduler tree * for all TCs. */ int ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle) { … } /** * ice_rm_vsi_rdma_cfg - remove VSI and its RDMA children nodes * @pi: port information structure * @vsi_handle: software VSI handle * * This function clears the VSI and its RDMA children nodes from scheduler tree * for all TCs. */ int ice_rm_vsi_rdma_cfg(struct ice_port_info *pi, u16 vsi_handle) { … } /** * ice_get_agg_info - get the aggregator ID * @hw: pointer to the hardware structure * @agg_id: aggregator ID * * 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 * ice_get_agg_info(struct ice_hw *hw, u32 agg_id) { … } /** * ice_sched_get_free_vsi_parent - Find a free parent node in aggregator subtree * @hw: pointer to the HW struct * @node: pointer to a child node * @num_nodes: num nodes count array * * This function walks through the aggregator subtree to find a free parent * node */ struct ice_sched_node * ice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node, u16 *num_nodes) { … } /** * ice_sched_update_parent - update the new parent in SW DB * @new_parent: pointer to a new parent node * @node: pointer to a child node * * This function removes the child from the old parent and adds it to a new * parent */ void ice_sched_update_parent(struct ice_sched_node *new_parent, struct ice_sched_node *node) { … } /** * ice_sched_move_nodes - move child nodes to a given parent * @pi: port information structure * @parent: pointer to parent node * @num_items: number of child nodes to be moved * @list: pointer to child node teids * * This function move the child nodes to a given parent. */ int ice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent, u16 num_items, u32 *list) { … } /** * ice_sched_move_vsi_to_agg - move VSI to aggregator node * @pi: port information structure * @vsi_handle: software VSI handle * @agg_id: aggregator ID * @tc: TC number * * This function moves a VSI to an aggregator node or its subtree. * Intermediate nodes may be created if required. */ static int ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id, u8 tc) { … } /** * ice_move_all_vsi_to_dflt_agg - move all VSI(s) to default aggregator * @pi: port information structure * @agg_info: aggregator info * @tc: traffic class number * @rm_vsi_info: true or false * * This function move all the VSI(s) to the default aggregator and delete * aggregator VSI info based on passed in boolean parameter rm_vsi_info. The * caller holds the scheduler lock. */ static int ice_move_all_vsi_to_dflt_agg(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info, u8 tc, bool rm_vsi_info) { … } /** * ice_sched_is_agg_inuse - check whether the aggregator is in use or not * @pi: port information structure * @node: node pointer * * This function checks whether the aggregator is attached with any VSI or not. */ static bool ice_sched_is_agg_inuse(struct ice_port_info *pi, struct ice_sched_node *node) { … } /** * ice_sched_rm_agg_cfg - remove the aggregator node * @pi: port information structure * @agg_id: aggregator ID * @tc: TC number * * This function removes the aggregator node and intermediate nodes if any * from the given TC */ static int ice_sched_rm_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc) { … } /** * ice_rm_agg_cfg_tc - remove aggregator configuration for TC * @pi: port information structure * @agg_info: aggregator ID * @tc: TC number * @rm_vsi_info: bool value true or false * * This function removes aggregator reference to VSI of given TC. It removes * the aggregator configuration completely for requested TC. The caller needs * to hold the scheduler lock. */ static int ice_rm_agg_cfg_tc(struct ice_port_info *pi, struct ice_sched_agg_info *agg_info, u8 tc, bool rm_vsi_info) { … } /** * ice_save_agg_tc_bitmap - save aggregator TC bitmap * @pi: port information structure * @agg_id: aggregator ID * @tc_bitmap: 8 bits TC bitmap * * Save aggregator TC bitmap. This function needs to be called with scheduler * lock held. */ static int ice_save_agg_tc_bitmap(struct ice_port_info *pi, u32 agg_id, unsigned long *tc_bitmap) { … } /** * ice_sched_add_agg_cfg - create an aggregator node * @pi: port information structure * @agg_id: aggregator ID * @tc: TC number * * This function creates an aggregator node and intermediate nodes if required * for the given TC */ static int ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc) { … } /** * ice_sched_cfg_agg - configure aggregator node * @pi: port information structure * @agg_id: aggregator ID * @agg_type: aggregator type queue, VSI, or aggregator group * @tc_bitmap: bits TC bitmap * * It registers a unique aggregator node into scheduler services. It * allows a user to register with a unique ID to track it's resources. * The aggregator type determines if this is a queue group, VSI group * or aggregator group. It then creates the aggregator node(s) for requested * TC(s) or removes an existing aggregator node including its configuration * if indicated via tc_bitmap. Call ice_rm_agg_cfg to release aggregator * resources and remove aggregator ID. * This function needs to be called with scheduler lock held. */ static int ice_sched_cfg_agg(struct ice_port_info *pi, u32 agg_id, enum ice_agg_type agg_type, unsigned long *tc_bitmap) { … } /** * ice_cfg_agg - config aggregator node * @pi: port information structure * @agg_id: aggregator ID * @agg_type: aggregator type queue, VSI, or aggregator group * @tc_bitmap: bits TC bitmap * * This function configures aggregator node(s). */ int ice_cfg_agg(struct ice_port_info *pi, u32 agg_id, enum ice_agg_type agg_type, u8 tc_bitmap) { … } /** * ice_get_agg_vsi_info - get the aggregator ID * @agg_info: aggregator info * @vsi_handle: software VSI handle * * 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 * ice_get_agg_vsi_info(struct ice_sched_agg_info *agg_info, u16 vsi_handle) { … } /** * ice_get_vsi_agg_info - get the aggregator info of VSI * @hw: pointer to the hardware structure * @vsi_handle: Sw VSI handle * * The function returns aggregator info of VSI represented via vsi_handle. The * 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 * ice_get_vsi_agg_info(struct ice_hw *hw, u16 vsi_handle) { … } /** * ice_save_agg_vsi_tc_bitmap - save aggregator VSI TC bitmap * @pi: port information structure * @agg_id: aggregator ID * @vsi_handle: software VSI handle * @tc_bitmap: TC bitmap of enabled TC(s) * * Save VSI to aggregator TC bitmap. This function needs to call with scheduler * lock held. */ static int ice_save_agg_vsi_tc_bitmap(struct ice_port_info *pi, u32 agg_id, u16 vsi_handle, unsigned long *tc_bitmap) { … } /** * ice_sched_assoc_vsi_to_agg - associate/move VSI to new/default aggregator * @pi: port information structure * @agg_id: aggregator ID * @vsi_handle: software VSI handle * @tc_bitmap: TC bitmap of enabled TC(s) * * This function moves VSI to a new or default aggregator node. If VSI is * already associated to the aggregator node then no operation is performed on * the tree. This function needs to be called with scheduler lock held. */ static int ice_sched_assoc_vsi_to_agg(struct ice_port_info *pi, u32 agg_id, u16 vsi_handle, unsigned long *tc_bitmap) { … } /** * ice_sched_rm_unused_rl_prof - remove unused RL profile * @pi: port information structure * * This function removes unused rate limit profiles from the HW and * SW DB. The caller needs to hold scheduler lock. */ static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi) { … } /** * ice_sched_update_elem - update element * @hw: pointer to the HW struct * @node: pointer to node * @info: node info to update * * 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. */ static int ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node, struct ice_aqc_txsched_elem_data *info) { … } /** * ice_sched_cfg_node_bw_alloc - configure node BW weight/alloc params * @hw: pointer to the HW struct * @node: sched node to configure * @rl_type: rate limit type CIR, EIR, or shared * @bw_alloc: BW weight/allocation * * This function configures node element's BW allocation. */ static int ice_sched_cfg_node_bw_alloc(struct ice_hw *hw, struct ice_sched_node *node, enum ice_rl_type rl_type, u16 bw_alloc) { … } /** * ice_move_vsi_to_agg - moves VSI to new or default aggregator * @pi: port information structure * @agg_id: aggregator ID * @vsi_handle: software VSI handle * @tc_bitmap: TC bitmap of enabled TC(s) * * Move or associate VSI to a new or default aggregator node. */ int ice_move_vsi_to_agg(struct ice_port_info *pi, u32 agg_id, u16 vsi_handle, u8 tc_bitmap) { … } /** * ice_set_clear_cir_bw - set or clear CIR BW * @bw_t_info: bandwidth type information structure * @bw: bandwidth in Kbps - Kilo bits per sec * * 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) { … } /** * ice_set_clear_eir_bw - set or clear EIR BW * @bw_t_info: bandwidth type information structure * @bw: bandwidth in Kbps - Kilo bits per sec * * 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) { … } /** * ice_set_clear_shared_bw - set or clear shared BW * @bw_t_info: bandwidth type information structure * @bw: bandwidth in Kbps - Kilo bits per sec * * 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) { … } /** * ice_sched_save_vsi_bw - save VSI node's BW information * @pi: port information structure * @vsi_handle: sw VSI handle * @tc: traffic class * @rl_type: rate limit type min, max, or shared * @bw: bandwidth in Kbps - Kilo bits per sec * * Save BW information of VSI type node for post replay use. */ static int ice_sched_save_vsi_bw(struct ice_port_info *pi, u16 vsi_handle, u8 tc, enum ice_rl_type rl_type, u32 bw) { … } /** * 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(struct ice_hw *hw, 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 int ice_sched_bw_to_rl_profile(struct ice_hw *hw, u32 bw, struct ice_aqc_rl_profile_elem *profile) { … } /** * ice_sched_add_rl_profile - add RL profile * @pi: port information structure * @rl_type: type of rate limit BW - min, max, or shared * @bw: bandwidth in Kbps - Kilo bits per sec * @layer_num: specifies in which layer to create profile * * This function first checks the existing list for corresponding BW * parameter. If it exists, it returns the associated profile otherwise * it creates a new rate limit profile for requested BW, and adds it to * the HW DB and local list. It returns the new profile or null on error. * The caller needs to hold the scheduler lock. */ 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) { … } /** * ice_sched_cfg_node_bw_lmt - configure node sched params * @hw: pointer to the HW struct * @node: sched node to configure * @rl_type: rate limit type CIR, EIR, or shared * @rl_prof_id: rate limit profile ID * * This function configures node element's BW limit. */ static int ice_sched_cfg_node_bw_lmt(struct ice_hw *hw, struct ice_sched_node *node, enum ice_rl_type rl_type, u16 rl_prof_id) { … } /** * ice_sched_get_node_rl_prof_id - get node's rate limit profile ID * @node: sched node * @rl_type: rate limit type * * If existing profile matches, it returns the corresponding rate * limit profile ID, otherwise it returns an invalid ID as error. */ static u16 ice_sched_get_node_rl_prof_id(struct ice_sched_node *node, enum ice_rl_type rl_type) { … } /** * ice_sched_get_rl_prof_layer - selects rate limit profile creation layer * @pi: port information structure * @rl_type: type of rate limit BW - min, max, or shared * @layer_index: layer index * * This function returns requested profile creation layer. */ static u8 ice_sched_get_rl_prof_layer(struct ice_port_info *pi, enum ice_rl_type rl_type, u8 layer_index) { … } /** * ice_sched_get_srl_node - get shared rate limit node * @node: tree node * @srl_layer: shared rate limit layer * * This function returns SRL node to be used for shared rate limit purpose. * The caller needs to hold scheduler lock. */ static struct ice_sched_node * ice_sched_get_srl_node(struct ice_sched_node *node, u8 srl_layer) { … } /** * ice_sched_rm_rl_profile - remove RL profile ID * @pi: port information structure * @layer_num: layer number where profiles are saved * @profile_type: profile type like EIR, CIR, or SRL * @profile_id: profile ID to remove * * This function removes rate limit profile from layer 'layer_num' of type * 'profile_type' and profile ID as 'profile_id'. The caller needs to hold * scheduler lock. */ static int ice_sched_rm_rl_profile(struct ice_port_info *pi, u8 layer_num, u8 profile_type, u16 profile_id) { … } /** * ice_sched_set_node_bw_dflt - set node's bandwidth limit to default * @pi: port information structure * @node: pointer to node structure * @rl_type: rate limit type min, max, or shared * @layer_num: layer number where RL profiles are saved * * This function configures node element's BW rate limit profile ID of * type CIR, EIR, or SRL to default. This function needs to be called * with the scheduler lock held. */ static int ice_sched_set_node_bw_dflt(struct ice_port_info *pi, struct ice_sched_node *node, enum ice_rl_type rl_type, u8 layer_num) { … } /** * ice_sched_set_eir_srl_excl - set EIR/SRL exclusiveness * @pi: port information structure * @node: pointer to node structure * @layer_num: layer number where rate limit profiles are saved * @rl_type: rate limit type min, max, or shared * @bw: bandwidth value * * This function prepares node element's bandwidth to SRL or EIR exclusively. * EIR BW and Shared BW profiles are mutually exclusive and hence only one of * them may be set for any given element. This function needs to be called * with the scheduler lock held. */ static int ice_sched_set_eir_srl_excl(struct ice_port_info *pi, struct ice_sched_node *node, u8 layer_num, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_sched_set_node_bw - set node's bandwidth * @pi: port information structure * @node: tree node * @rl_type: rate limit type min, max, or shared * @bw: bandwidth in Kbps - Kilo bits per sec * @layer_num: layer number * * This function adds new profile corresponding to requested BW, configures * node's RL profile ID of type CIR, EIR, or SRL, and removes old profile * ID from local database. The caller needs to hold scheduler lock. */ int ice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node, enum ice_rl_type rl_type, u32 bw, u8 layer_num) { … } /** * ice_sched_set_node_priority - set node's priority * @pi: port information structure * @node: tree node * @priority: number 0-7 representing priority among siblings * * This function sets priority of a node among it's siblings. */ int ice_sched_set_node_priority(struct ice_port_info *pi, struct ice_sched_node *node, u16 priority) { … } /** * ice_sched_set_node_weight - set node's weight * @pi: port information structure * @node: tree node * @weight: number 1-200 representing weight for WFQ * * This function sets weight of the node for WFQ algorithm. */ int ice_sched_set_node_weight(struct ice_port_info *pi, struct ice_sched_node *node, u16 weight) { … } /** * ice_sched_set_node_bw_lmt - set node's BW limit * @pi: port information structure * @node: tree node * @rl_type: rate limit type min, max, or shared * @bw: bandwidth in Kbps - Kilo bits per sec * * It updates node's BW limit parameters like BW RL profile ID of type CIR, * EIR, or SRL. The caller needs to hold scheduler lock. */ int ice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_sched_set_node_bw_dflt_lmt - set node's BW limit to default * @pi: port information structure * @node: pointer to node structure * @rl_type: rate limit type min, max, or shared * * This function configures node element's BW rate limit profile ID of * type CIR, EIR, or SRL to default. This function needs to be called * with the scheduler lock held. */ static int ice_sched_set_node_bw_dflt_lmt(struct ice_port_info *pi, struct ice_sched_node *node, enum ice_rl_type rl_type) { … } /** * ice_sched_validate_srl_node - Check node for SRL applicability * @node: sched node to configure * @sel_layer: selected SRL layer * * This function checks if the SRL can be applied to a selected layer node on * behalf of the requested node (first argument). This function needs to be * called with scheduler lock held. */ static int ice_sched_validate_srl_node(struct ice_sched_node *node, u8 sel_layer) { … } /** * ice_sched_save_q_bw - save queue node's BW information * @q_ctx: queue context structure * @rl_type: rate limit type min, max, or shared * @bw: bandwidth in Kbps - Kilo bits per sec * * Save BW information of queue type node for post replay use. */ static int ice_sched_save_q_bw(struct ice_q_ctx *q_ctx, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_sched_set_q_bw_lmt - sets queue BW limit * @pi: port information structure * @vsi_handle: sw VSI handle * @tc: traffic class * @q_handle: software queue handle * @rl_type: min, max, or shared * @bw: bandwidth in Kbps * * This function sets BW limit of queue scheduling node. */ static int ice_sched_set_q_bw_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_cfg_q_bw_lmt - configure queue BW limit * @pi: port information structure * @vsi_handle: sw VSI handle * @tc: traffic class * @q_handle: software queue handle * @rl_type: min, max, or shared * @bw: bandwidth in Kbps * * This function configures BW limit of queue scheduling node. */ int ice_cfg_q_bw_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_cfg_q_bw_dflt_lmt - configure queue BW default limit * @pi: port information structure * @vsi_handle: sw VSI handle * @tc: traffic class * @q_handle: software queue handle * @rl_type: min, max, or shared * * This function configures BW default limit of queue scheduling node. */ int ice_cfg_q_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 q_handle, enum ice_rl_type rl_type) { … } /** * ice_sched_get_node_by_id_type - get node from ID type * @pi: port information structure * @id: identifier * @agg_type: type of aggregator * @tc: traffic class * * This function returns node identified by ID of type aggregator, and * based on traffic class (TC). This function needs to be called with * the scheduler lock held. */ static struct ice_sched_node * ice_sched_get_node_by_id_type(struct ice_port_info *pi, u32 id, enum ice_agg_type agg_type, u8 tc) { … } /** * ice_sched_set_node_bw_lmt_per_tc - set node BW limit per TC * @pi: port information structure * @id: ID (software VSI handle or AGG ID) * @agg_type: aggregator type (VSI or AGG type node) * @tc: traffic class * @rl_type: min or max * @bw: bandwidth in Kbps * * This function sets BW limit of VSI or Aggregator scheduling node * based on TC information from passed in argument BW. */ static int ice_sched_set_node_bw_lmt_per_tc(struct ice_port_info *pi, u32 id, enum ice_agg_type agg_type, u8 tc, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_cfg_vsi_bw_lmt_per_tc - configure VSI BW limit per TC * @pi: port information structure * @vsi_handle: software VSI handle * @tc: traffic class * @rl_type: min or max * @bw: bandwidth in Kbps * * This function configures BW limit of VSI scheduling node based on TC * information. */ int ice_cfg_vsi_bw_lmt_per_tc(struct ice_port_info *pi, u16 vsi_handle, u8 tc, enum ice_rl_type rl_type, u32 bw) { … } /** * ice_cfg_vsi_bw_dflt_lmt_per_tc - configure default VSI BW limit per TC * @pi: port information structure * @vsi_handle: software VSI handle * @tc: traffic class * @rl_type: min or max * * This function configures default BW limit of VSI scheduling node based on TC * information. */ int ice_cfg_vsi_bw_dflt_lmt_per_tc(struct ice_port_info *pi, u16 vsi_handle, u8 tc, enum ice_rl_type rl_type) { … } /** * ice_cfg_rl_burst_size - Set burst size value * @hw: pointer to the HW struct * @bytes: burst size in bytes * * This function configures/set the burst size to requested new value. The new * burst size value is used for future rate limit calls. It doesn't change the * existing or previously created RL profiles. */ int ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes) { … } /** * ice_sched_replay_node_prio - re-configure node priority * @hw: pointer to the HW struct * @node: sched node to configure * @priority: priority value * * This function configures node element's priority value. It * needs to be called with scheduler lock held. */ static int ice_sched_replay_node_prio(struct ice_hw *hw, struct ice_sched_node *node, u8 priority) { … } /** * ice_sched_replay_node_bw - replay node(s) BW * @hw: pointer to the HW struct * @node: sched node to configure * @bw_t_info: BW type information * * This function restores node's BW from bw_t_info. The caller needs * to hold the scheduler lock. */ static int ice_sched_replay_node_bw(struct ice_hw *hw, struct ice_sched_node *node, struct ice_bw_type_info *bw_t_info) { … } /** * ice_sched_get_ena_tc_bitmap - get enabled TC bitmap * @pi: port info struct * @tc_bitmap: 8 bits TC bitmap to check * @ena_tc_bitmap: 8 bits enabled TC bitmap to return * * This function returns enabled TC bitmap in variable ena_tc_bitmap. Some TCs * may be missing, it returns enabled TCs. This function needs to be called with * scheduler lock held. */ static void ice_sched_get_ena_tc_bitmap(struct ice_port_info *pi, unsigned long *tc_bitmap, unsigned long *ena_tc_bitmap) { … } /** * ice_sched_replay_agg - recreate aggregator node(s) * @hw: pointer to the HW struct * * This function recreate aggregator type nodes which are not replayed earlier. * It also replay aggregator BW information. These aggregator nodes are not * associated with VSI type node yet. */ void ice_sched_replay_agg(struct ice_hw *hw) { … } /** * ice_sched_replay_agg_vsi_preinit - Agg/VSI replay pre initialization * @hw: pointer to the HW struct * * This function initialize aggregator(s) TC bitmap to zero. A required * preinit step for replaying aggregators. */ void ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw) { … } /** * ice_sched_replay_vsi_agg - replay aggregator & VSI to aggregator node(s) * @hw: pointer to the HW struct * @vsi_handle: software VSI handle * * This function replays aggregator node, VSI to aggregator type nodes, and * their node bandwidth information. This function needs to be called with * scheduler lock held. */ static int ice_sched_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) { … } /** * ice_replay_vsi_agg - replay VSI to aggregator node * @hw: pointer to the HW struct * @vsi_handle: software VSI handle * * This function replays association of VSI to aggregator type nodes, and * node bandwidth information. */ int ice_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) { … } /** * ice_sched_replay_q_bw - replay queue type node BW * @pi: port information structure * @q_ctx: queue context structure * * This function replays queue type node bandwidth. This function needs to be * called with scheduler lock held. */ int ice_sched_replay_q_bw(struct ice_port_info *pi, struct ice_q_ctx *q_ctx) { … }