1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2024 NVIDIA Corporation & Affiliates */
3
4 #ifndef MLX5HWS_TABLE_H_
5 #define MLX5HWS_TABLE_H_
6
7 struct mlx5hws_default_miss {
8 /* My miss table */
9 struct mlx5hws_table *miss_tbl;
10 struct list_head next;
11 /* Tables missing to my table */
12 struct list_head head;
13 };
14
15 struct mlx5hws_table {
16 struct mlx5hws_context *ctx;
17 u32 ft_id;
18 enum mlx5hws_table_type type;
19 u32 fw_ft_type;
20 u32 level;
21 struct list_head matchers_list;
22 struct list_head tbl_list_node;
23 struct mlx5hws_default_miss default_miss;
24 };
25
26 static inline
mlx5hws_table_get_fw_ft_type(enum mlx5hws_table_type type,u8 * ret_type)27 u32 mlx5hws_table_get_fw_ft_type(enum mlx5hws_table_type type,
28 u8 *ret_type)
29 {
30 if (type != MLX5HWS_TABLE_TYPE_FDB)
31 return -EOPNOTSUPP;
32
33 *ret_type = FS_FT_FDB;
34
35 return 0;
36 }
37
38 static inline
mlx5hws_table_get_res_fw_ft_type(enum mlx5hws_table_type tbl_type,bool is_mirror)39 u32 mlx5hws_table_get_res_fw_ft_type(enum mlx5hws_table_type tbl_type,
40 bool is_mirror)
41 {
42 if (tbl_type == MLX5HWS_TABLE_TYPE_FDB)
43 return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX;
44
45 return 0;
46 }
47
48 int mlx5hws_table_create_default_ft(struct mlx5_core_dev *mdev,
49 struct mlx5hws_table *tbl,
50 u32 *ft_id);
51
52 void mlx5hws_table_destroy_default_ft(struct mlx5hws_table *tbl,
53 u32 ft_id);
54
55 int mlx5hws_table_connect_to_miss_table(struct mlx5hws_table *src_tbl,
56 struct mlx5hws_table *dst_tbl);
57
58 int mlx5hws_table_update_connected_miss_tables(struct mlx5hws_table *dst_tbl);
59
60 int mlx5hws_table_ft_set_default_next_ft(struct mlx5hws_table *tbl, u32 ft_id);
61
62 int mlx5hws_table_ft_set_next_rtc(struct mlx5hws_context *ctx,
63 u32 ft_id,
64 u32 fw_ft_type,
65 u32 rtc_0_id,
66 u32 rtc_1_id);
67
68 #endif /* MLX5HWS_TABLE_H_ */
69