18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _ICE_SCHED_H_
58c2ecf20Sopenharmony_ci#define _ICE_SCHED_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include "ice_common.h"
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define ICE_QGRP_LAYER_OFFSET	2
108c2ecf20Sopenharmony_ci#define ICE_VSI_LAYER_OFFSET	4
118c2ecf20Sopenharmony_ci#define ICE_SCHED_INVAL_LAYER_NUM	0xFF
128c2ecf20Sopenharmony_ci/* Burst size is a 12 bits register that is configured while creating the RL
138c2ecf20Sopenharmony_ci * profile(s). MSB is a granularity bit and tells the granularity type
148c2ecf20Sopenharmony_ci * 0 - LSB bits are in 64 bytes granularity
158c2ecf20Sopenharmony_ci * 1 - LSB bits are in 1K bytes granularity
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci#define ICE_64_BYTE_GRANULARITY			0
188c2ecf20Sopenharmony_ci#define ICE_KBYTE_GRANULARITY			BIT(11)
198c2ecf20Sopenharmony_ci#define ICE_MIN_BURST_SIZE_ALLOWED		64 /* In Bytes */
208c2ecf20Sopenharmony_ci#define ICE_MAX_BURST_SIZE_ALLOWED \
218c2ecf20Sopenharmony_ci	((BIT(11) - 1) * 1024) /* In Bytes */
228c2ecf20Sopenharmony_ci#define ICE_MAX_BURST_SIZE_64_BYTE_GRANULARITY \
238c2ecf20Sopenharmony_ci	((BIT(11) - 1) * 64) /* In Bytes */
248c2ecf20Sopenharmony_ci#define ICE_MAX_BURST_SIZE_KBYTE_GRANULARITY	ICE_MAX_BURST_SIZE_ALLOWED
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define ICE_RL_PROF_FREQUENCY 446000000
278c2ecf20Sopenharmony_ci#define ICE_RL_PROF_ACCURACY_BYTES 128
288c2ecf20Sopenharmony_ci#define ICE_RL_PROF_MULTIPLIER 10000
298c2ecf20Sopenharmony_ci#define ICE_RL_PROF_TS_MULTIPLIER 32
308c2ecf20Sopenharmony_ci#define ICE_RL_PROF_FRACTION 512
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* BW rate limit profile parameters list entry along
338c2ecf20Sopenharmony_ci * with bandwidth maintained per layer in port info
348c2ecf20Sopenharmony_ci */
358c2ecf20Sopenharmony_cistruct ice_aqc_rl_profile_info {
368c2ecf20Sopenharmony_ci	struct ice_aqc_rl_profile_elem profile;
378c2ecf20Sopenharmony_ci	struct list_head list_entry;
388c2ecf20Sopenharmony_ci	u32 bw;			/* requested */
398c2ecf20Sopenharmony_ci	u16 prof_id_ref;	/* profile ID to node association ref count */
408c2ecf20Sopenharmony_ci};
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistruct ice_sched_agg_vsi_info {
438c2ecf20Sopenharmony_ci	struct list_head list_entry;
448c2ecf20Sopenharmony_ci	DECLARE_BITMAP(tc_bitmap, ICE_MAX_TRAFFIC_CLASS);
458c2ecf20Sopenharmony_ci	u16 vsi_handle;
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_cistruct ice_sched_agg_info {
498c2ecf20Sopenharmony_ci	struct list_head agg_vsi_list;
508c2ecf20Sopenharmony_ci	struct list_head list_entry;
518c2ecf20Sopenharmony_ci	DECLARE_BITMAP(tc_bitmap, ICE_MAX_TRAFFIC_CLASS);
528c2ecf20Sopenharmony_ci	u32 agg_id;
538c2ecf20Sopenharmony_ci	enum ice_agg_type agg_type;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* FW AQ command calls */
578c2ecf20Sopenharmony_cienum ice_status
588c2ecf20Sopenharmony_ciice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
598c2ecf20Sopenharmony_ci			 struct ice_aqc_txsched_elem_data *buf, u16 buf_size,
608c2ecf20Sopenharmony_ci			 u16 *elems_ret, struct ice_sq_cd *cd);
618c2ecf20Sopenharmony_cienum ice_status ice_sched_init_port(struct ice_port_info *pi);
628c2ecf20Sopenharmony_cienum ice_status ice_sched_query_res_alloc(struct ice_hw *hw);
638c2ecf20Sopenharmony_civoid ice_sched_clear_port(struct ice_port_info *pi);
648c2ecf20Sopenharmony_civoid ice_sched_cleanup_all(struct ice_hw *hw);
658c2ecf20Sopenharmony_civoid ice_sched_clear_agg(struct ice_hw *hw);
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cistruct ice_sched_node *
688c2ecf20Sopenharmony_ciice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid);
698c2ecf20Sopenharmony_cienum ice_status
708c2ecf20Sopenharmony_ciice_sched_add_node(struct ice_port_info *pi, u8 layer,
718c2ecf20Sopenharmony_ci		   struct ice_aqc_txsched_elem_data *info);
728c2ecf20Sopenharmony_civoid ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node);
738c2ecf20Sopenharmony_cistruct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc);
748c2ecf20Sopenharmony_cistruct ice_sched_node *
758c2ecf20Sopenharmony_ciice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
768c2ecf20Sopenharmony_ci			   u8 owner);
778c2ecf20Sopenharmony_cienum ice_status
788c2ecf20Sopenharmony_ciice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
798c2ecf20Sopenharmony_ci		  u8 owner, bool enable);
808c2ecf20Sopenharmony_cienum ice_status ice_rm_vsi_lan_cfg(struct ice_port_info *pi, u16 vsi_handle);
818c2ecf20Sopenharmony_cienum ice_status
828c2ecf20Sopenharmony_ciice_cfg_q_bw_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
838c2ecf20Sopenharmony_ci		 u16 q_handle, enum ice_rl_type rl_type, u32 bw);
848c2ecf20Sopenharmony_cienum ice_status
858c2ecf20Sopenharmony_ciice_cfg_q_bw_dflt_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc,
868c2ecf20Sopenharmony_ci		      u16 q_handle, enum ice_rl_type rl_type);
878c2ecf20Sopenharmony_cienum ice_status ice_cfg_rl_burst_size(struct ice_hw *hw, u32 bytes);
888c2ecf20Sopenharmony_cienum ice_status
898c2ecf20Sopenharmony_ciice_sched_replay_q_bw(struct ice_port_info *pi, struct ice_q_ctx *q_ctx);
908c2ecf20Sopenharmony_ci#endif /* _ICE_SCHED_H_ */
91