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 BYTES_IN_MBIT 125000
10
11struct mlx5e_priv;
12struct mlx5e_htb;
13struct mlx5e_channels;
14struct mlx5e_channel;
15struct tc_htb_qopt_offload;
16
17int mlx5e_qos_bytes_rate_check(struct mlx5_core_dev *mdev, u64 nbytes);
18int mlx5e_qos_max_leaf_nodes(struct mlx5_core_dev *mdev);
19
20/* SQ lifecycle */
21int mlx5e_open_qos_sq(struct mlx5e_priv *priv, struct mlx5e_channels *chs,
22 u16 node_qid, u32 hw_id);
23int mlx5e_activate_qos_sq(void *data, u16 node_qid, u32 hw_id);
24void mlx5e_deactivate_qos_sq(struct mlx5e_priv *priv, u16 qid);
25void mlx5e_close_qos_sq(struct mlx5e_priv *priv, u16 qid);
26void mlx5e_reactivate_qos_sq(struct mlx5e_priv *priv, u16 qid, struct netdev_queue *txq);
27void mlx5e_reset_qdisc(struct net_device *dev, u16 qid);
28
29int mlx5e_qos_open_queues(struct mlx5e_priv *priv, struct mlx5e_channels *chs);
30void mlx5e_qos_activate_queues(struct mlx5e_priv *priv);
31void mlx5e_qos_deactivate_queues(struct mlx5e_channel *c);
32void mlx5e_qos_deactivate_all_queues(struct mlx5e_channels *chs);
33void mlx5e_qos_close_queues(struct mlx5e_channel *c);
34void mlx5e_qos_close_all_queues(struct mlx5e_channels *chs);
35int mlx5e_qos_alloc_queues(struct mlx5e_priv *priv, struct mlx5e_channels *chs);
36
37/* TX datapath API */
38u16 mlx5e_qid_from_qos(struct mlx5e_channels *chs, u16 qid);
39
40/* HTB API */
41int mlx5e_htb_setup_tc(struct mlx5e_priv *priv, struct tc_htb_qopt_offload *htb);
42
43/* MQPRIO TX rate limit */
44struct mlx5e_mqprio_rl;
45struct mlx5e_mqprio_rl *mlx5e_mqprio_rl_alloc(void);
46void mlx5e_mqprio_rl_free(struct mlx5e_mqprio_rl *rl);
47int mlx5e_mqprio_rl_init(struct mlx5e_mqprio_rl *rl, struct mlx5_core_dev *mdev, u8 num_tc,
48 u64 max_rate[]);
49void mlx5e_mqprio_rl_cleanup(struct mlx5e_mqprio_rl *rl);
50int mlx5e_mqprio_rl_get_node_hw_id(struct mlx5e_mqprio_rl *rl, int tc, u32 *hw_id);
51#endif
52

source code of linux/drivers/net/ethernet/mellanox/mlx5/core/en/qos.h