Merge tag 'staging-5.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / lib / fs_chains.h
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 struct mlx5_mapped_obj;
11
12 enum 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
18 struct 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
29 bool
30 mlx5_chains_prios_supported(struct mlx5_fs_chains *chains);
31 bool mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains);
32 bool
33 mlx5_chains_backwards_supported(struct mlx5_fs_chains *chains);
34 u32
35 mlx5_chains_get_prio_range(struct mlx5_fs_chains *chains);
36 u32
37 mlx5_chains_get_chain_range(struct mlx5_fs_chains *chains);
38 u32
39 mlx5_chains_get_nf_ft_chain(struct mlx5_fs_chains *chains);
40
41 struct mlx5_flow_table *
42 mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio,
43                       u32 level);
44 void
45 mlx5_chains_put_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio,
46                       u32 level);
47
48 struct mlx5_flow_table *
49 mlx5_chains_get_tc_end_ft(struct mlx5_fs_chains *chains);
50
51 struct mlx5_flow_table *
52 mlx5_chains_create_global_table(struct mlx5_fs_chains *chains);
53 void
54 mlx5_chains_destroy_global_table(struct mlx5_fs_chains *chains,
55                                  struct mlx5_flow_table *ft);
56
57 int
58 mlx5_chains_get_chain_mapping(struct mlx5_fs_chains *chains, u32 chain,
59                               u32 *chain_mapping);
60 int
61 mlx5_chains_put_chain_mapping(struct mlx5_fs_chains *chains,
62                               u32 chain_mapping);
63
64 struct mlx5_fs_chains *
65 mlx5_chains_create(struct mlx5_core_dev *dev, struct mlx5_chains_attr *attr);
66 void mlx5_chains_destroy(struct mlx5_fs_chains *chains);
67
68 void
69 mlx5_chains_set_end_ft(struct mlx5_fs_chains *chains,
70                        struct mlx5_flow_table *ft);
71
72 #else /* CONFIG_MLX5_CLS_ACT */
73
74 static inline bool
75 mlx5_chains_ignore_flow_level_supported(struct mlx5_fs_chains *chains)
76 { return false; }
77
78 static inline struct mlx5_flow_table *
79 mlx5_chains_get_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio,
80                       u32 level) { return ERR_PTR(-EOPNOTSUPP); }
81 static inline void
82 mlx5_chains_put_table(struct mlx5_fs_chains *chains, u32 chain, u32 prio,
83                       u32 level) {};
84
85 static inline struct mlx5_flow_table *
86 mlx5_chains_get_tc_end_ft(struct mlx5_fs_chains *chains) { return ERR_PTR(-EOPNOTSUPP); }
87
88 static inline struct mlx5_fs_chains *
89 mlx5_chains_create(struct mlx5_core_dev *dev, struct mlx5_chains_attr *attr)
90 { return NULL; }
91 static inline void
92 mlx5_chains_destroy(struct mlx5_fs_chains *chains) {};
93
94 #endif /* CONFIG_MLX5_CLS_ACT */
95
96 #endif /* __ML5_ESW_CHAINS_H__ */