Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2022 NVIDIA Corporation & Affiliates 3 : : */ 4 : : 5 : : #ifndef MLX5DR_TABLE_H_ 6 : : #define MLX5DR_TABLE_H_ 7 : : 8 : : #define MLX5DR_ROOT_LEVEL 0 9 : : 10 : : struct mlx5dr_default_miss { 11 : : /* My miss table */ 12 : : struct mlx5dr_table *miss_tbl; 13 : : LIST_ENTRY(mlx5dr_table) next; 14 : : /* Tables missing to my table */ 15 : : LIST_HEAD(miss_table_head, mlx5dr_table) head; 16 : : }; 17 : : 18 : : struct mlx5dr_table { 19 : : struct mlx5dr_context *ctx; 20 : : struct mlx5dr_devx_obj *ft; 21 : : struct mlx5dr_devx_obj *local_ft; 22 : : enum mlx5dr_table_type type; 23 : : uint32_t fw_ft_type; 24 : : uint32_t level; 25 : : LIST_HEAD(matcher_head, mlx5dr_matcher) head; 26 : : LIST_ENTRY(mlx5dr_table) next; 27 : : struct mlx5dr_default_miss default_miss; 28 : : }; 29 : : 30 : : static inline 31 : 0 : uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type, 32 : : bool is_mirror) 33 : : { 34 [ # # ]: 0 : if (tbl_type == MLX5DR_TABLE_TYPE_NIC_RX) 35 : : return FS_FT_NIC_RX; 36 [ # # ]: 0 : else if (tbl_type == MLX5DR_TABLE_TYPE_NIC_TX) 37 : : return FS_FT_NIC_TX; 38 [ # # ]: 0 : else if (tbl_type == MLX5DR_TABLE_TYPE_FDB) 39 [ # # ]: 0 : return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX; 40 : : 41 : 0 : assert(0); 42 : : return 0; 43 : : } 44 : : 45 : : static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl) 46 : : { 47 [ # # # # : 0 : return (tbl->level == MLX5DR_ROOT_LEVEL); # # # # # # # # ] 48 : : } 49 : : 50 : : struct mlx5dr_devx_obj *mlx5dr_table_create_default_ft(struct ibv_context *ibv, 51 : : struct mlx5dr_table *tbl); 52 : : 53 : : void mlx5dr_table_destroy_default_ft(struct mlx5dr_table *tbl, 54 : : struct mlx5dr_devx_obj *ft_obj); 55 : : 56 : : int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, 57 : : struct mlx5dr_table *dst_tbl); 58 : : 59 : : int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl); 60 : : 61 : : int mlx5dr_table_ft_set_default_next_ft(struct mlx5dr_table *tbl, 62 : : struct mlx5dr_devx_obj *ft_obj); 63 : : 64 : : int mlx5dr_table_ft_set_next_rtc(struct mlx5dr_devx_obj *ft, 65 : : uint32_t fw_ft_type, 66 : : struct mlx5dr_devx_obj *rtc_0, 67 : : struct mlx5dr_devx_obj *rtc_1); 68 : : 69 : : #endif /* MLX5DR_TABLE_H_ */