162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _ICE_SCHED_H_ 562306a36Sopenharmony_ci#define _ICE_SCHED_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include "ice_common.h" 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define SCHED_NODE_NAME_MAX_LEN 32 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define ICE_QGRP_LAYER_OFFSET 2 1262306a36Sopenharmony_ci#define ICE_VSI_LAYER_OFFSET 4 1362306a36Sopenharmony_ci#define ICE_AGG_LAYER_OFFSET 6 1462306a36Sopenharmony_ci#define ICE_SCHED_INVAL_LAYER_NUM 0xFF 1562306a36Sopenharmony_ci/* Burst size is a 12 bits register that is configured while creating the RL 1662306a36Sopenharmony_ci * profile(s). MSB is a granularity bit and tells the granularity type 1762306a36Sopenharmony_ci * 0 - LSB bits are in 64 bytes granularity 1862306a36Sopenharmony_ci * 1 - LSB bits are in 1K bytes granularity 1962306a36Sopenharmony_ci */ 2062306a36Sopenharmony_ci#define ICE_64_BYTE_GRANULARITY 0 2162306a36Sopenharmony_ci#define ICE_KBYTE_GRANULARITY BIT(11) 2262306a36Sopenharmony_ci#define ICE_MIN_BURST_SIZE_ALLOWED 64 /* In Bytes */ 2362306a36Sopenharmony_ci#define ICE_MAX_BURST_SIZE_ALLOWED \ 2462306a36Sopenharmony_ci ((BIT(11) - 1) * 1024) /* In Bytes */ 2562306a36Sopenharmony_ci#define ICE_MAX_BURST_SIZE_64_BYTE_GRANULARITY \ 2662306a36Sopenharmony_ci ((BIT(11) - 1) * 64) /* In Bytes */ 2762306a36Sopenharmony_ci#define ICE_MAX_BURST_SIZE_KBYTE_GRANULARITY ICE_MAX_BURST_SIZE_ALLOWED 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define ICE_RL_PROF_ACCURACY_BYTES 128 3062306a36Sopenharmony_ci#define ICE_RL_PROF_MULTIPLIER 10000 3162306a36Sopenharmony_ci#define ICE_RL_PROF_TS_MULTIPLIER 32 3262306a36Sopenharmony_ci#define ICE_RL_PROF_FRACTION 512 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define ICE_PSM_CLK_367MHZ_IN_HZ 367647059 3562306a36Sopenharmony_ci#define ICE_PSM_CLK_416MHZ_IN_HZ 416666667 3662306a36Sopenharmony_ci#define ICE_PSM_CLK_446MHZ_IN_HZ 446428571 3762306a36Sopenharmony_ci#define ICE_PSM_CLK_390MHZ_IN_HZ 390625000 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* BW rate limit profile parameters list entry along 4062306a36Sopenharmony_ci * with bandwidth maintained per layer in port info 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_cistruct ice_aqc_rl_profile_info { 4362306a36Sopenharmony_ci struct ice_aqc_rl_profile_elem profile; 4462306a36Sopenharmony_ci struct list_head list_entry; 4562306a36Sopenharmony_ci u32 bw; /* requested */ 4662306a36Sopenharmony_ci u16 prof_id_ref; /* profile ID to node association ref count */ 4762306a36Sopenharmony_ci}; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_cistruct ice_sched_agg_vsi_info { 5062306a36Sopenharmony_ci struct list_head list_entry; 5162306a36Sopenharmony_ci DECLARE_BITMAP(tc_bitmap, ICE_MAX_TRAFFIC_CLASS); 5262306a36Sopenharmony_ci u16 vsi_handle; 5362306a36Sopenharmony_ci /* save aggregator VSI TC bitmap */ 5462306a36Sopenharmony_ci DECLARE_BITMAP(replay_tc_bitmap, ICE_MAX_TRAFFIC_CLASS); 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistruct ice_sched_agg_info { 5862306a36Sopenharmony_ci struct list_head agg_vsi_list; 5962306a36Sopenharmony_ci struct list_head list_entry; 6062306a36Sopenharmony_ci DECLARE_BITMAP(tc_bitmap, ICE_MAX_TRAFFIC_CLASS); 6162306a36Sopenharmony_ci u32 agg_id; 6262306a36Sopenharmony_ci enum ice_agg_type agg_type; 6362306a36Sopenharmony_ci /* bw_t_info saves aggregator BW information */ 6462306a36Sopenharmony_ci struct ice_bw_type_info bw_t_info[ICE_MAX_TRAFFIC_CLASS]; 6562306a36Sopenharmony_ci /* save aggregator TC bitmap */ 6662306a36Sopenharmony_ci DECLARE_BITMAP(replay_tc_bitmap, ICE_MAX_TRAFFIC_CLASS); 6762306a36Sopenharmony_ci}; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* FW AQ command calls */ 7062306a36Sopenharmony_ciint 7162306a36Sopenharmony_ciice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, 7262306a36Sopenharmony_ci struct ice_aqc_txsched_elem_data *buf, u16 buf_size, 7362306a36Sopenharmony_ci u16 *elems_ret, struct ice_sq_cd *cd); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciint 7662306a36Sopenharmony_ciice_sched_set_node_bw_lmt(struct ice_port_info *pi, struct ice_sched_node *node, 7762306a36Sopenharmony_ci enum ice_rl_type rl_type, u32 bw); 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciint 8062306a36Sopenharmony_ciice_sched_set_node_bw(struct ice_port_info *pi, struct ice_sched_node *node, 8162306a36Sopenharmony_ci enum ice_rl_type rl_type, u32 bw, u8 layer_num); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ciint 8462306a36Sopenharmony_ciice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, 8562306a36Sopenharmony_ci struct ice_sched_node *parent, u8 layer, u16 num_nodes, 8662306a36Sopenharmony_ci u16 *num_nodes_added, u32 *first_node_teid, 8762306a36Sopenharmony_ci struct ice_sched_node **prealloc_node); 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ciint 9062306a36Sopenharmony_ciice_sched_move_nodes(struct ice_port_info *pi, struct ice_sched_node *parent, 9162306a36Sopenharmony_ci u16 num_items, u32 *list); 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ciint ice_sched_set_node_priority(struct ice_port_info *pi, struct ice_sched_node *node, 9462306a36Sopenharmony_ci u16 priority); 9562306a36Sopenharmony_ciint ice_sched_set_node_weight(struct ice_port_info *pi, struct ice_sched_node *node, u16 weight); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciint ice_sched_init_port(struct ice_port_info *pi); 9862306a36Sopenharmony_ciint ice_sched_query_res_alloc(struct ice_hw *hw); 9962306a36Sopenharmony_civoid ice_sched_get_psm_clk_freq(struct ice_hw *hw); 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_civoid ice_sched_clear_port(struct ice_port_info *pi); 10262306a36Sopenharmony_civoid ice_sched_cleanup_all(struct ice_hw *hw); 10362306a36Sopenharmony_civoid ice_sched_clear_agg(struct ice_hw *hw); 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cistruct ice_sched_node * 10662306a36Sopenharmony_ciice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid); 10762306a36Sopenharmony_ciint 10862306a36Sopenharmony_ciice_sched_add_node(struct ice_port_info *pi, u8 layer, 10962306a36Sopenharmony_ci struct ice_aqc_txsched_elem_data *info, 11062306a36Sopenharmony_ci struct ice_sched_node *prealloc_node); 11162306a36Sopenharmony_civoid 11262306a36Sopenharmony_ciice_sched_update_parent(struct ice_sched_node *new_parent, 11362306a36Sopenharmony_ci struct ice_sched_node *node); 11462306a36Sopenharmony_civoid ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node); 11562306a36Sopenharmony_cistruct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc); 11662306a36Sopenharmony_cistruct ice_sched_node * 11762306a36Sopenharmony_ciice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, 11862306a36Sopenharmony_ci u8 owner); 11962306a36Sopenharmony_ciint 12062306a36Sopenharmony_ciice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs, 12162306a36Sopenharmony_ci u8 owner, bool enable); 12262306a36Sopenharmony_ciint ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle); 12362306a36Sopenharmony_ciint ice_rm_vsi_rdma_cfg(struct ice_port_info *pi, u16 vsi_handle); 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* Tx scheduler rate limiter functions */ 12662306a36Sopenharmony_ciint 12762306a36Sopenharmony_ciice_cfg_agg(struct ice_port_info *pi, u32 agg_id, 12862306a36Sopenharmony_ci enum ice_agg_type agg_type, u8 tc_bitmap); 12962306a36Sopenharmony_ciint 13062306a36Sopenharmony_ciice_move_vsi_to_agg(struct ice_port_info *pi, u32 agg_id, u16 vsi_handle, 13162306a36Sopenharmony_ci u8 tc_bitmap); 13262306a36Sopenharmony_ciint 13362306a36Sopenharmony_ciice_cfg_q_bw_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc, 13462306a36Sopenharmony_ci u16 q_handle, enum ice_rl_type rl_type, u32 bw); 13562306a36Sopenharmony_ciint 13662306a36Sopenharmony_ciice_cfg_q_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc, 13762306a36Sopenharmony_ci u16 q_handle, enum ice_rl_type rl_type); 13862306a36Sopenharmony_ciint 13962306a36Sopenharmony_ciice_cfg_vsi_bw_lmt_per_tc(struct ice_port_info *pi, u16 vsi_handle, u8 tc, 14062306a36Sopenharmony_ci enum ice_rl_type rl_type, u32 bw); 14162306a36Sopenharmony_ciint 14262306a36Sopenharmony_ciice_cfg_vsi_bw_dflt_lmt_per_tc(struct ice_port_info *pi, u16 vsi_handle, u8 tc, 14362306a36Sopenharmony_ci enum ice_rl_type rl_type); 14462306a36Sopenharmony_ciint ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes); 14562306a36Sopenharmony_ciint 14662306a36Sopenharmony_ciice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, 14762306a36Sopenharmony_ci bool suspend); 14862306a36Sopenharmony_cistruct ice_sched_node * 14962306a36Sopenharmony_ciice_sched_get_agg_node(struct ice_port_info *pi, struct ice_sched_node *tc_node, 15062306a36Sopenharmony_ci u32 agg_id); 15162306a36Sopenharmony_ciu8 ice_sched_get_agg_layer(struct ice_hw *hw); 15262306a36Sopenharmony_ciu8 ice_sched_get_vsi_layer(struct ice_hw *hw); 15362306a36Sopenharmony_cistruct ice_sched_node * 15462306a36Sopenharmony_ciice_sched_get_free_vsi_parent(struct ice_hw *hw, struct ice_sched_node *node, 15562306a36Sopenharmony_ci u16 *num_nodes); 15662306a36Sopenharmony_ciint 15762306a36Sopenharmony_ciice_sched_add_nodes_to_layer(struct ice_port_info *pi, 15862306a36Sopenharmony_ci struct ice_sched_node *tc_node, 15962306a36Sopenharmony_ci struct ice_sched_node *parent, u8 layer, 16062306a36Sopenharmony_ci u16 num_nodes, u32 *first_node_teid, 16162306a36Sopenharmony_ci u16 *num_nodes_added); 16262306a36Sopenharmony_civoid ice_sched_replay_agg_vsi_preinit(struct ice_hw *hw); 16362306a36Sopenharmony_civoid ice_sched_replay_agg(struct ice_hw *hw); 16462306a36Sopenharmony_ciint 16562306a36Sopenharmony_ciice_aq_move_sched_elems(struct ice_hw *hw, u16 grps_req, 16662306a36Sopenharmony_ci struct ice_aqc_move_elem *buf, u16 buf_size, 16762306a36Sopenharmony_ci u16 *grps_movd, struct ice_sq_cd *cd); 16862306a36Sopenharmony_ciint ice_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle); 16962306a36Sopenharmony_ciint ice_sched_replay_q_bw(struct ice_port_info *pi, struct ice_q_ctx *q_ctx); 17062306a36Sopenharmony_ci#endif /* _ICE_SCHED_H_ */ 171