1*462b0059SMoshe Tal /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2*462b0059SMoshe Tal /* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3*462b0059SMoshe Tal 
4*462b0059SMoshe Tal #ifndef __MLX5E_EN_HTB_H_
5*462b0059SMoshe Tal #define __MLX5E_EN_HTB_H_
6*462b0059SMoshe Tal 
7*462b0059SMoshe Tal #include "qos.h"
8*462b0059SMoshe Tal 
9*462b0059SMoshe Tal #define MLX5E_QOS_MAX_LEAF_NODES 256
10*462b0059SMoshe Tal 
11*462b0059SMoshe Tal struct mlx5e_selq;
12*462b0059SMoshe Tal struct mlx5e_htb;
13*462b0059SMoshe Tal 
14*462b0059SMoshe Tal typedef int (*mlx5e_fp_htb_enumerate)(void *data, u16 qid, u32 hw_id);
15*462b0059SMoshe Tal int mlx5e_htb_enumerate_leaves(struct mlx5e_htb *htb, mlx5e_fp_htb_enumerate callback, void *data);
16*462b0059SMoshe Tal 
17*462b0059SMoshe Tal int mlx5e_htb_cur_leaf_nodes(struct mlx5e_htb *htb);
18*462b0059SMoshe Tal 
19*462b0059SMoshe Tal /* TX datapath API */
20*462b0059SMoshe Tal int mlx5e_htb_get_txq_by_classid(struct mlx5e_htb *htb, u16 classid);
21*462b0059SMoshe Tal 
22*462b0059SMoshe Tal /* HTB TC handlers */
23*462b0059SMoshe Tal 
24*462b0059SMoshe Tal int
25*462b0059SMoshe Tal mlx5e_htb_leaf_alloc_queue(struct mlx5e_htb *htb, u16 classid,
26*462b0059SMoshe Tal 			   u32 parent_classid, u64 rate, u64 ceil,
27*462b0059SMoshe Tal 			   struct netlink_ext_ack *extack);
28*462b0059SMoshe Tal int
29*462b0059SMoshe Tal mlx5e_htb_leaf_to_inner(struct mlx5e_htb *htb, u16 classid, u16 child_classid,
30*462b0059SMoshe Tal 			u64 rate, u64 ceil, struct netlink_ext_ack *extack);
31*462b0059SMoshe Tal int mlx5e_htb_leaf_del(struct mlx5e_htb *htb, u16 *classid,
32*462b0059SMoshe Tal 		       struct netlink_ext_ack *extack);
33*462b0059SMoshe Tal int
34*462b0059SMoshe Tal mlx5e_htb_leaf_del_last(struct mlx5e_htb *htb, u16 classid, bool force,
35*462b0059SMoshe Tal 			struct netlink_ext_ack *extack);
36*462b0059SMoshe Tal int
37*462b0059SMoshe Tal mlx5e_htb_node_modify(struct mlx5e_htb *htb, u16 classid, u64 rate, u64 ceil,
38*462b0059SMoshe Tal 		      struct netlink_ext_ack *extack);
39*462b0059SMoshe Tal struct mlx5e_htb *mlx5e_htb_alloc(void);
40*462b0059SMoshe Tal void mlx5e_htb_free(struct mlx5e_htb *htb);
41*462b0059SMoshe Tal int mlx5e_htb_init(struct mlx5e_htb *htb, struct tc_htb_qopt_offload *htb_qopt,
42*462b0059SMoshe Tal 		   struct net_device *netdev, struct mlx5_core_dev *mdev,
43*462b0059SMoshe Tal 		   struct mlx5e_selq *selq, struct mlx5e_priv *priv);
44*462b0059SMoshe Tal void mlx5e_htb_cleanup(struct mlx5e_htb *htb);
45*462b0059SMoshe Tal #endif
46*462b0059SMoshe Tal 
47