1394cc7baSAlex Vesker /* SPDX-License-Identifier: BSD-3-Clause 2394cc7baSAlex Vesker * Copyright (c) 2022 NVIDIA Corporation & Affiliates 3394cc7baSAlex Vesker */ 4394cc7baSAlex Vesker 5394cc7baSAlex Vesker #ifndef MLX5DR_TABLE_H_ 6394cc7baSAlex Vesker #define MLX5DR_TABLE_H_ 7394cc7baSAlex Vesker 8394cc7baSAlex Vesker #define MLX5DR_ROOT_LEVEL 0 9394cc7baSAlex Vesker 10b81f95caSItamar Gozlan struct mlx5dr_default_miss { 11b81f95caSItamar Gozlan /* My miss table */ 12b81f95caSItamar Gozlan struct mlx5dr_table *miss_tbl; 13b81f95caSItamar Gozlan LIST_ENTRY(mlx5dr_table) next; 14b81f95caSItamar Gozlan /* Tables missing to my table */ 15b81f95caSItamar Gozlan LIST_HEAD(miss_table_head, mlx5dr_table) head; 16b81f95caSItamar Gozlan }; 17b81f95caSItamar Gozlan 18394cc7baSAlex Vesker struct mlx5dr_table { 19394cc7baSAlex Vesker struct mlx5dr_context *ctx; 20394cc7baSAlex Vesker struct mlx5dr_devx_obj *ft; 21ce946c7dSErez Shitrit struct mlx5dr_devx_obj *local_ft; 22394cc7baSAlex Vesker enum mlx5dr_table_type type; 23394cc7baSAlex Vesker uint32_t fw_ft_type; 24394cc7baSAlex Vesker uint32_t level; 25394cc7baSAlex Vesker LIST_HEAD(matcher_head, mlx5dr_matcher) head; 26*486f9aacSHamdan Igbaria LIST_HEAD(isolated_matchers_head, mlx5dr_matcher) isolated_matchers; 27394cc7baSAlex Vesker LIST_ENTRY(mlx5dr_table) next; 28b81f95caSItamar Gozlan struct mlx5dr_default_miss default_miss; 29394cc7baSAlex Vesker }; 30394cc7baSAlex Vesker 31394cc7baSAlex Vesker static inline 32394cc7baSAlex Vesker uint32_t mlx5dr_table_get_res_fw_ft_type(enum mlx5dr_table_type tbl_type, 33394cc7baSAlex Vesker bool is_mirror) 34394cc7baSAlex Vesker { 35394cc7baSAlex Vesker if (tbl_type == MLX5DR_TABLE_TYPE_NIC_RX) 36394cc7baSAlex Vesker return FS_FT_NIC_RX; 37394cc7baSAlex Vesker else if (tbl_type == MLX5DR_TABLE_TYPE_NIC_TX) 38394cc7baSAlex Vesker return FS_FT_NIC_TX; 39394cc7baSAlex Vesker else if (tbl_type == MLX5DR_TABLE_TYPE_FDB) 40394cc7baSAlex Vesker return is_mirror ? FS_FT_FDB_TX : FS_FT_FDB_RX; 41394cc7baSAlex Vesker 42394cc7baSAlex Vesker assert(0); 43394cc7baSAlex Vesker return 0; 44394cc7baSAlex Vesker } 45394cc7baSAlex Vesker 46394cc7baSAlex Vesker static inline bool mlx5dr_table_is_root(struct mlx5dr_table *tbl) 47394cc7baSAlex Vesker { 48394cc7baSAlex Vesker return (tbl->level == MLX5DR_ROOT_LEVEL); 49394cc7baSAlex Vesker } 50394cc7baSAlex Vesker 51ce946c7dSErez Shitrit struct mlx5dr_devx_obj *mlx5dr_table_create_default_ft(struct ibv_context *ibv, 52ce946c7dSErez Shitrit struct mlx5dr_table *tbl); 53394cc7baSAlex Vesker 54394cc7baSAlex Vesker void mlx5dr_table_destroy_default_ft(struct mlx5dr_table *tbl, 55394cc7baSAlex Vesker struct mlx5dr_devx_obj *ft_obj); 56b81f95caSItamar Gozlan 57b81f95caSItamar Gozlan int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, 58*486f9aacSHamdan Igbaria struct mlx5dr_table *dst_tbl, 59*486f9aacSHamdan Igbaria bool only_update_last_ft); 60b81f95caSItamar Gozlan 61b81f95caSItamar Gozlan int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl); 62b81f95caSItamar Gozlan 63b81f95caSItamar Gozlan int mlx5dr_table_ft_set_default_next_ft(struct mlx5dr_table *tbl, 64b81f95caSItamar Gozlan struct mlx5dr_devx_obj *ft_obj); 65b81f95caSItamar Gozlan 66b81f95caSItamar Gozlan int mlx5dr_table_ft_set_next_rtc(struct mlx5dr_devx_obj *ft, 67b81f95caSItamar Gozlan uint32_t fw_ft_type, 68b81f95caSItamar Gozlan struct mlx5dr_devx_obj *rtc_0, 69b81f95caSItamar Gozlan struct mlx5dr_devx_obj *rtc_1); 70b81f95caSItamar Gozlan 71*486f9aacSHamdan Igbaria int mlx5dr_table_connect_src_ft_to_miss_table(struct mlx5dr_table *src_tbl, 72*486f9aacSHamdan Igbaria struct mlx5dr_devx_obj *ft, 73*486f9aacSHamdan Igbaria struct mlx5dr_table *dst_tbl); 74*486f9aacSHamdan Igbaria 75394cc7baSAlex Vesker #endif /* MLX5DR_TABLE_H_ */ 76