xref: /linux/drivers/net/ethernet/mellanox/mlx5/core/en/rqt.h (revision c75e7e599c62c57d210eebb91140802dd81f2b70)
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021, Mellanox Technologies inc. All rights reserved. */
3 
4 #ifndef __MLX5_EN_RQT_H__
5 #define __MLX5_EN_RQT_H__
6 
7 #include <linux/kernel.h>
8 
9 #define MLX5E_INDIR_MIN_RQT_SIZE (BIT(8))
10 #define MLX5E_UNIFORM_SPREAD_RQT_FACTOR 4
11 
12 struct mlx5_core_dev;
13 
14 struct mlx5e_rss_params_indir {
15 	u32 *table;
16 	u32 actual_table_size;
17 	u32 max_table_size;
18 };
19 
20 void mlx5e_rss_params_indir_init_uniform(struct mlx5e_rss_params_indir *indir,
21 					 unsigned int num_channels);
22 
23 struct mlx5e_rqt {
24 	struct mlx5_core_dev *mdev; /* primary */
25 	u32 rqtn;
26 	u16 size;
27 };
28 
29 int mlx5e_rqt_init_direct(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev,
30 			  bool indir_enabled, u32 init_rqn, u32 indir_table_size);
31 int mlx5e_rqt_init_indir(struct mlx5e_rqt *rqt, struct mlx5_core_dev *mdev,
32 			 u32 *rqns, u32 *vhca_ids, unsigned int num_rqns,
33 			 u8 hfunc, struct mlx5e_rss_params_indir *indir);
34 void mlx5e_rqt_destroy(struct mlx5e_rqt *rqt);
35 
36 static inline u32 mlx5e_rqt_get_rqtn(struct mlx5e_rqt *rqt)
37 {
38 	return rqt->rqtn;
39 }
40 
41 u32 mlx5e_rqt_size(struct mlx5_core_dev *mdev, unsigned int num_channels);
42 int mlx5e_rqt_redirect_direct(struct mlx5e_rqt *rqt, u32 rqn, u32 *vhca_id);
43 int mlx5e_rqt_redirect_indir(struct mlx5e_rqt *rqt, u32 *rqns, u32 *vhca_ids,
44 			     unsigned int num_rqns,
45 			     u8 hfunc, struct mlx5e_rss_params_indir *indir);
46 
47 #endif /* __MLX5_EN_RQT_H__ */
48