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