1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
3 
4 #ifndef __MLX5E_EN_QOS_H
5 #define __MLX5E_EN_QOS_H
6 
7 #include <linux/mlx5/driver.h>
8 
9 #define MLX5E_QOS_MAX_LEAF_NODES 256
10 
11 struct mlx5e_priv;
12 struct mlx5e_channels;
13 struct mlx5e_channel;
14 
15 int mlx5e_qos_bytes_rate_check(struct mlx5_core_dev *mdev, u64 nbytes);
16 int mlx5e_qos_max_leaf_nodes(struct mlx5_core_dev *mdev);
17 int mlx5e_qos_cur_leaf_nodes(struct mlx5e_priv *priv);
18 
19 /* TX datapath API */
20 int mlx5e_get_txq_by_classid(struct mlx5e_priv *priv, u16 classid);
21 
22 /* SQ lifecycle */
23 int mlx5e_qos_open_queues(struct mlx5e_priv *priv, struct mlx5e_channels *chs);
24 void mlx5e_qos_activate_queues(struct mlx5e_priv *priv);
25 void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c);
26 void mlx5e_qos_close_queues(struct mlx5e_channel *c);
27 
28 /* HTB API */
29 int mlx5e_htb_root_add(struct mlx5e_priv *priv, u16 htb_maj_id, u16 htb_defcls,
30 		       struct netlink_ext_ack *extack);
31 int mlx5e_htb_root_del(struct mlx5e_priv *priv);
32 int mlx5e_htb_leaf_alloc_queue(struct mlx5e_priv *priv, u16 classid,
33 			       u32 parent_classid, u64 rate, u64 ceil,
34 			       struct netlink_ext_ack *extack);
35 int mlx5e_htb_leaf_to_inner(struct mlx5e_priv *priv, u16 classid, u16 child_classid,
36 			    u64 rate, u64 ceil, struct netlink_ext_ack *extack);
37 int mlx5e_htb_leaf_del(struct mlx5e_priv *priv, u16 *classid,
38 		       struct netlink_ext_ack *extack);
39 int mlx5e_htb_leaf_del_last(struct mlx5e_priv *priv, u16 classid, bool force,
40 			    struct netlink_ext_ack *extack);
41 int mlx5e_htb_node_modify(struct mlx5e_priv *priv, u16 classid, u64 rate, u64 ceil,
42 			  struct netlink_ext_ack *extack);
43 
44 /* MQPRIO TX rate limit */
45 struct mlx5e_mqprio_rl;
46 struct mlx5e_mqprio_rl *mlx5e_mqprio_rl_alloc(void);
47 void mlx5e_mqprio_rl_free(struct mlx5e_mqprio_rl *rl);
48 int mlx5e_mqprio_rl_init(struct mlx5e_mqprio_rl *rl, struct mlx5_core_dev *mdev, u8 num_tc,
49 			 u64 max_rate[]);
50 void mlx5e_mqprio_rl_cleanup(struct mlx5e_mqprio_rl *rl);
51 int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_id);
52 #endif
53