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 bool mlx5dr_table_is_fw_fdb_any(uint32_t fw_tbl_type) 32 : : { 33 [ # # # # ]: 0 : if (fw_tbl_type == FS_FT_FDB_TX || fw_tbl_type == FS_FT_FDB_RX || 34 : : fw_tbl_type == FS_FT_FDB_UNIFIED) 35 : : return true; 36 : : 37 : : return false; 38 : : } 39 : : 40 : : static inline bool mlx5dr_table_is_fdb_any(enum mlx5dr_table_type tbl_type) 41 : : { 42 [ # # ]: 0 : if (tbl_type == MLX5DR_TABLE_TYPE_FDB || 43 [ # # # # : 0 : tbl_type == MLX5DR_TABLE_TYPE_FDB_TX || # # # # # # # # # # # # ] 44 : 0 : tbl_type == MLX5DR_TABLE_TYPE_FDB_RX || 45 [ # # # # : 0 : tbl_type == MLX5DR_TABLE_TYPE_FDB_UNIFIED) # # # # # # # # # # # # ] 46 : : return true; 47 : : 48 : : return false; 49 : : } 50 : : 51 : : static inline bool mlx5dr_table_fdb_no_unified(enum mlx5dr_table_type tbl_type) 52 : : { 53 [ # # # # ]: 0 : if (mlx5dr_table_is_fdb_any(tbl_type) && 54 : : tbl_type != MLX5DR_TABLE_TYPE_FDB_UNIFIED) 55 : : return true; 56 : : 57 : : return false; 58 : : } 59 : : 60 : : static inline 61 : 0 : uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type, 62 : : bool is_mirror) 63 : : { 64 [ # # # # : 0 : switch (tbl_type) { # ] 65 : : case MLX5DR_TABLE_TYPE_NIC_RX: 66 : : return FS_FT_NIC_RX; 67 : 0 : case MLX5DR_TABLE_TYPE_NIC_TX: 68 : 0 : return FS_FT_NIC_TX; 69 : 0 : case MLX5DR_TABLE_TYPE_FDB: 70 : : case MLX5DR_TABLE_TYPE_FDB_RX: 71 : : case MLX5DR_TABLE_TYPE_FDB_TX: 72 [ # # ]: 0 : return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX; 73 : 0 : case MLX5DR_TABLE_TYPE_FDB_UNIFIED: 74 : 0 : return FS_FT_FDB_UNIFIED; 75 : 0 : default: 76 : 0 : assert(0); 77 : : return 0; 78 : : } 79 : : } 80 : : 81 : : static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl) 82 : : { 83 [ # # # # : 0 : return (tbl->level == MLX5DR_ROOT_LEVEL); # # # # # # # # # # ] 84 : : } 85 : : 86 : : static inline 87 : 0 : void mlx5dr_table_get_fw_ft_type(enum mlx5dr_table_type type, 88 : : uint8_t *ret_type) 89 : : { 90 [ # # # # ]: 0 : switch (type) { 91 : 0 : case MLX5DR_TABLE_TYPE_NIC_RX: 92 : 0 : *ret_type = FS_FT_NIC_RX; 93 : 0 : break; 94 : 0 : case MLX5DR_TABLE_TYPE_NIC_TX: 95 : 0 : *ret_type = FS_FT_NIC_TX; 96 : 0 : break; 97 : 0 : case MLX5DR_TABLE_TYPE_FDB: 98 : : case MLX5DR_TABLE_TYPE_FDB_RX: 99 : : case MLX5DR_TABLE_TYPE_FDB_TX: 100 : : case MLX5DR_TABLE_TYPE_FDB_UNIFIED: 101 : 0 : *ret_type = FS_FT_FDB; 102 : 0 : break; 103 : 0 : default: 104 : 0 : assert(0); 105 : : } 106 : 0 : } 107 : : 108 : : struct mlx5dr_devx_obj *mlx5dr_table_create_default_ft(struct ibv_context *ibv, 109 : : struct mlx5dr_table *tbl); 110 : : 111 : : void mlx5dr_table_destroy_default_ft(struct mlx5dr_table *tbl, 112 : : struct mlx5dr_devx_obj *ft_obj); 113 : : 114 : : int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, 115 : : struct mlx5dr_table *dst_tbl, 116 : : bool only_update_last_ft); 117 : : 118 : : int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl); 119 : : 120 : : int mlx5dr_table_ft_set_default_next_ft(struct mlx5dr_table *tbl, 121 : : struct mlx5dr_devx_obj *ft_obj); 122 : : 123 : : int mlx5dr_table_ft_set_next_rtc(struct mlx5dr_devx_obj *ft, 124 : : uint32_t fw_ft_type, 125 : : struct mlx5dr_devx_obj *rtc_0, 126 : : struct mlx5dr_devx_obj *rtc_1); 127 : : 128 : : int mlx5dr_table_connect_src_ft_to_miss_table(struct mlx5dr_table *src_tbl, 129 : : struct mlx5dr_devx_obj *ft, 130 : : struct mlx5dr_table *dst_tbl); 131 : : 132 : : #endif /* MLX5DR_TABLE_H_ */