1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2020 Mellanox Technologies. */ 3 4 #ifndef __ML5_ESW_CHAINS_H__ 5 #define __ML5_ESW_CHAINS_H__ 6 7 #include <linux/mlx5/fs.h> 8 9 struct mlx5_fs_chains; 10 11 enum mlx5_chains_flags { 12 MLX5_CHAINS_AND_PRIOS_SUPPORTED = BIT(0), 13 MLX5_CHAINS_IGNORE_FLOW_LEVEL_SUPPORTED = BIT(1), 14 MLX5_CHAINS_FT_TUNNEL_SUPPORTED = BIT(2), 15 }; 16 17 struct mlx5_chains_attr { 18 enum mlx5_flow_namespace_type ns; 19 u32 flags; 20 u32 max_ft_sz; 21 u32 max_grp_num; 22 struct mlx5_flow_table *default_ft; 23 u32 max_restore_tag; 24 }; 25 26 #if IS_ENABLED(CONFIG_MLX5_CLS_ACT) 27 28 bool 29 mlx5_chains_prios_supported(struct mlx5_fs_chains *chains); 30 bool 31 mlx5_chains_backwards_supported(struct mlx5_fs_chains *chains); 32 u32 33 mlx5_chains_get_prio_range(struct mlx5_fs_chains *chains); 34 u32 35 mlx5_chains_get_chain_range(struct mlx5_fs_chains *chains); 36 u32 37 mlx5_chains_get_nf_ft_chain(struct mlx5_fs_chains *chains); 38 39 struct mlx5_flow_table * 40 mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio, 41 u32 level); 42 void 43 mlx5_chains_put_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio, 44 u32 level); 45 46 struct mlx5_flow_table * 47 mlx5_chains_get_tc_end_ft(struct mlx5_fs_chains *chains); 48 49 struct mlx5_flow_table * 50 mlx5_chains_create_global_table(struct mlx5_fs_chains *chains); 51 void 52 mlx5_chains_destroy_global_table(struct mlx5_fs_chains *chains, 53 struct mlx5_flow_table *ft); 54 55 int 56 mlx5_chains_get_chain_mapping(struct mlx5_fs_chains *chains, u32 chain, 57 u32 *chain_mapping); 58 int 59 mlx5_chains_put_chain_mapping(struct mlx5_fs_chains *chains, 60 u32 chain_mapping); 61 62 struct mlx5_fs_chains * 63 mlx5_chains_create(struct mlx5_core_dev *dev, struct mlx5_chains_attr *attr); 64 void mlx5_chains_destroy(struct mlx5_fs_chains *chains); 65 66 int 67 mlx5_get_chain_for_tag(struct mlx5_fs_chains *chains, u32 tag, u32 *chain); 68 69 void 70 mlx5_chains_set_end_ft(struct mlx5_fs_chains *chains, 71 struct mlx5_flow_table *ft); 72 73 #else /* CONFIG_MLX5_CLS_ACT */ 74 75 static inline struct mlx5_flow_table * 76 mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio, 77 u32 level) { return ERR_PTR(-EOPNOTSUPP); } 78 static inline void 79 mlx5_chains_put_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio, 80 u32 level) {}; 81 82 static inline struct mlx5_flow_table * 83 mlx5_chains_get_tc_end_ft(struct mlx5_fs_chains *chains) { return ERR_PTR(-EOPNOTSUPP); } 84 85 static inline struct mlx5_fs_chains * 86 mlx5_chains_create(struct mlx5_core_dev *dev, struct mlx5_chains_attr *attr) 87 { return NULL; } 88 static inline void 89 mlx5_chains_destroy(struct mlx5_fs_chains *chains) {}; 90 91 #endif /* CONFIG_MLX5_CLS_ACT */ 92 93 #endif /* __ML5_ESW_CHAINS_H__ */ 94