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_HEAD(isolated_matchers_head, mlx5dr_matcher) isolated_matchers; 27 : : LIST_ENTRY(mlx5dr_table) next; 28 : : struct mlx5dr_default_miss default_miss; 29 : : }; 30 : : 31 : : static inline 32 : 0 : uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type, 33 : : bool is_mirror) 34 : : { 35 [ # # ]: 0 : if (tbl_type == MLX5DR_TABLE_TYPE_NIC_RX) 36 : : return FS_FT_NIC_RX; 37 [ # # ]: 0 : else if (tbl_type == MLX5DR_TABLE_TYPE_NIC_TX) 38 : : return FS_FT_NIC_TX; 39 [ # # ]: 0 : else if (tbl_type == MLX5DR_TABLE_TYPE_FDB) 40 [ # # ]: 0 : return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX; 41 : : 42 : 0 : assert(0); 43 : : return 0; 44 : : } 45 : : 46 : : static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl) 47 : : { 48 [ # # # # : 0 : return (tbl->level == MLX5DR_ROOT_LEVEL); # # # # # # # # # # ] 49 : : } 50 : : 51 : : struct mlx5dr_devx_obj *mlx5dr_table_create_default_ft(struct ibv_context *ibv, 52 : : struct mlx5dr_table *tbl); 53 : : 54 : : void mlx5dr_table_destroy_default_ft(struct mlx5dr_table *tbl, 55 : : struct mlx5dr_devx_obj *ft_obj); 56 : : 57 : : int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, 58 : : struct mlx5dr_table *dst_tbl, 59 : : bool only_update_last_ft); 60 : : 61 : : int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl); 62 : : 63 : : int mlx5dr_table_ft_set_default_next_ft(struct mlx5dr_table *tbl, 64 : : struct mlx5dr_devx_obj *ft_obj); 65 : : 66 : : int mlx5dr_table_ft_set_next_rtc(struct mlx5dr_devx_obj *ft, 67 : : uint32_t fw_ft_type, 68 : : struct mlx5dr_devx_obj *rtc_0, 69 : : struct mlx5dr_devx_obj *rtc_1); 70 : : 71 : : int mlx5dr_table_connect_src_ft_to_miss_table(struct mlx5dr_table *src_tbl, 72 : : struct mlx5dr_devx_obj *ft, 73 : : struct mlx5dr_table *dst_tbl); 74 : : 75 : : #endif /* MLX5DR_TABLE_H_ */