forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
....@@ -36,10 +36,51 @@
3636 #include <linux/refcount.h>
3737 #include <linux/mlx5/fs.h>
3838 #include <linux/rhashtable.h>
39
+#include <linux/llist.h>
40
+#include <steering/fs_dr.h>
41
+
42
+#define FDB_TC_MAX_CHAIN 3
43
+#define FDB_FT_CHAIN (FDB_TC_MAX_CHAIN + 1)
44
+#define FDB_TC_SLOW_PATH_CHAIN (FDB_FT_CHAIN + 1)
45
+
46
+/* The index of the last real chain (FT) + 1 as chain zero is valid as well */
47
+#define FDB_NUM_CHAINS (FDB_FT_CHAIN + 1)
48
+
49
+#define FDB_TC_MAX_PRIO 16
50
+#define FDB_TC_LEVELS_PER_PRIO 2
51
+
52
+struct mlx5_modify_hdr {
53
+ enum mlx5_flow_namespace_type ns_type;
54
+ union {
55
+ struct mlx5_fs_dr_action action;
56
+ u32 id;
57
+ };
58
+};
59
+
60
+struct mlx5_pkt_reformat {
61
+ enum mlx5_flow_namespace_type ns_type;
62
+ int reformat_type; /* from mlx5_ifc */
63
+ union {
64
+ struct mlx5_fs_dr_action action;
65
+ u32 id;
66
+ };
67
+};
68
+
69
+/* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only,
70
+ * and those are in parallel to one another when going over them to connect
71
+ * a new flow table. Meaning the last flow table in a TYPE_PRIO prio in one
72
+ * parallel namespace will not automatically connect to the first flow table
73
+ * found in any prio in any next namespace, but skip the entire containing
74
+ * TYPE_PRIO_CHAINS prio.
75
+ *
76
+ * This is used to implement tc chains, each chain of prios is a different
77
+ * namespace inside a containing TYPE_PRIO_CHAINS prio.
78
+ */
3979
4080 enum fs_node_type {
4181 FS_TYPE_NAMESPACE,
4282 FS_TYPE_PRIO,
83
+ FS_TYPE_PRIO_CHAINS,
4384 FS_TYPE_FLOW_TABLE,
4485 FS_TYPE_FLOW_GROUP,
4586 FS_TYPE_FLOW_ENTRY,
....@@ -54,7 +95,9 @@
5495 FS_FT_FDB = 0X4,
5596 FS_FT_SNIFFER_RX = 0X5,
5697 FS_FT_SNIFFER_TX = 0X6,
57
- FS_FT_MAX_TYPE = FS_FT_SNIFFER_TX,
98
+ FS_FT_RDMA_RX = 0X7,
99
+ FS_FT_RDMA_TX = 0X8,
100
+ FS_FT_MAX_TYPE = FS_FT_RDMA_TX,
58101 };
59102
60103 enum fs_flow_table_op_mod {
....@@ -66,16 +109,25 @@
66109 FS_FTE_STATUS_EXISTING = 1UL << 0,
67110 };
68111
112
+enum mlx5_flow_steering_mode {
113
+ MLX5_FLOW_STEERING_MODE_DMFS,
114
+ MLX5_FLOW_STEERING_MODE_SMFS
115
+};
116
+
69117 struct mlx5_flow_steering {
70118 struct mlx5_core_dev *dev;
71
- struct kmem_cache *fgs_cache;
119
+ enum mlx5_flow_steering_mode mode;
120
+ struct kmem_cache *fgs_cache;
72121 struct kmem_cache *ftes_cache;
73122 struct mlx5_flow_root_namespace *root_ns;
74123 struct mlx5_flow_root_namespace *fdb_root_ns;
124
+ struct mlx5_flow_namespace **fdb_sub_ns;
75125 struct mlx5_flow_root_namespace **esw_egress_root_ns;
76126 struct mlx5_flow_root_namespace **esw_ingress_root_ns;
77127 struct mlx5_flow_root_namespace *sniffer_tx_root_ns;
78128 struct mlx5_flow_root_namespace *sniffer_rx_root_ns;
129
+ struct mlx5_flow_root_namespace *rdma_rx_root_ns;
130
+ struct mlx5_flow_root_namespace *rdma_tx_root_ns;
79131 struct mlx5_flow_root_namespace *egress_root_ns;
80132 };
81133
....@@ -96,6 +148,7 @@
96148
97149 struct mlx5_flow_rule {
98150 struct fs_node node;
151
+ struct mlx5_flow_table *ft;
99152 struct mlx5_flow_destination dest_attr;
100153 /* next_ft should be accessed under chain_lock and only of
101154 * destination type is FWD_NEXT_fT.
....@@ -112,6 +165,7 @@
112165 /* Type of children is mlx5_flow_group */
113166 struct mlx5_flow_table {
114167 struct fs_node node;
168
+ struct mlx5_fs_dr_table fs_dr_table;
115169 u32 id;
116170 u16 vport;
117171 unsigned int max_fte;
....@@ -123,6 +177,7 @@
123177 unsigned int required_groups;
124178 unsigned int group_size;
125179 unsigned int num_groups;
180
+ unsigned int max_fte;
126181 } autogroup;
127182 /* Protect fwd_rules */
128183 struct mutex lock;
....@@ -130,29 +185,8 @@
130185 struct list_head fwd_rules;
131186 u32 flags;
132187 struct rhltable fgs_hash;
133
-};
134
-
135
-struct mlx5_fc_cache {
136
- u64 packets;
137
- u64 bytes;
138
- u64 lastuse;
139
-};
140
-
141
-struct mlx5_fc {
142
- struct rb_node node;
143
- struct list_head list;
144
-
145
- /* last{packets,bytes} members are used when calculating the delta since
146
- * last reading
147
- */
148
- u64 lastpackets;
149
- u64 lastbytes;
150
-
151
- u32 id;
152
- bool deleted;
153
- bool aging;
154
-
155
- struct mlx5_fc_cache cache ____cacheline_aligned_in_smp;
188
+ enum mlx5_flow_table_miss_action def_miss_action;
189
+ struct mlx5_flow_namespace *ns;
156190 };
157191
158192 struct mlx5_ft_underlay_qp {
....@@ -160,7 +194,7 @@
160194 u32 qpn;
161195 };
162196
163
-#define MLX5_FTE_MATCH_PARAM_RESERVED reserved_at_800
197
+#define MLX5_FTE_MATCH_PARAM_RESERVED reserved_at_a00
164198 /* Calculate the fte_match_param length and without the reserved length.
165199 * Make sure the reserved field is the last.
166200 */
....@@ -175,13 +209,16 @@
175209 /* Type of children is mlx5_flow_rule */
176210 struct fs_fte {
177211 struct fs_node node;
212
+ struct mlx5_fs_dr_rule fs_dr_rule;
178213 u32 val[MLX5_ST_SZ_DW_MATCH_PARAM];
179214 u32 dests_size;
180215 u32 index;
216
+ struct mlx5_flow_context flow_context;
181217 struct mlx5_flow_act action;
182218 enum fs_fte_status status;
183219 struct mlx5_fc *counter;
184220 struct rhash_head hash;
221
+ int modify_mask;
185222 };
186223
187224 /* Type of children is mlx5_flow_table/namespace */
....@@ -197,6 +234,7 @@
197234 struct mlx5_flow_namespace {
198235 /* parent == NULL => root ns */
199236 struct fs_node node;
237
+ enum mlx5_flow_table_miss_action def_miss_action;
200238 };
201239
202240 struct mlx5_flow_group_mask {
....@@ -207,6 +245,7 @@
207245 /* Type of children is fs_fte */
208246 struct mlx5_flow_group {
209247 struct fs_node node;
248
+ struct mlx5_fs_dr_matcher fs_dr_matcher;
210249 struct mlx5_flow_group_mask mask;
211250 u32 start_index;
212251 u32 max_ftes;
....@@ -218,6 +257,8 @@
218257
219258 struct mlx5_flow_root_namespace {
220259 struct mlx5_flow_namespace ns;
260
+ enum mlx5_flow_steering_mode mode;
261
+ struct mlx5_fs_dr_domain fs_dr_domain;
221262 enum fs_flow_table_type table_type;
222263 struct mlx5_core_dev *dev;
223264 struct mlx5_flow_table *root_ft;
....@@ -234,6 +275,14 @@
234275 unsigned long delay);
235276 void mlx5_fc_update_sampling_interval(struct mlx5_core_dev *dev,
236277 unsigned long interval);
278
+
279
+const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void);
280
+
281
+int mlx5_flow_namespace_set_peer(struct mlx5_flow_root_namespace *ns,
282
+ struct mlx5_flow_root_namespace *peer_ns);
283
+
284
+int mlx5_flow_namespace_set_mode(struct mlx5_flow_namespace *ns,
285
+ enum mlx5_flow_steering_mode mode);
237286
238287 int mlx5_init_fs(struct mlx5_core_dev *dev);
239288 void mlx5_cleanup_fs(struct mlx5_core_dev *dev);
....@@ -280,7 +329,9 @@
280329 (type == FS_FT_FDB) ? MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, cap) : \
281330 (type == FS_FT_SNIFFER_RX) ? MLX5_CAP_FLOWTABLE_SNIFFER_RX(mdev, cap) : \
282331 (type == FS_FT_SNIFFER_TX) ? MLX5_CAP_FLOWTABLE_SNIFFER_TX(mdev, cap) : \
283
- (BUILD_BUG_ON_ZERO(FS_FT_SNIFFER_TX != FS_FT_MAX_TYPE))\
332
+ (type == FS_FT_RDMA_RX) ? MLX5_CAP_FLOWTABLE_RDMA_RX(mdev, cap) : \
333
+ (type == FS_FT_RDMA_TX) ? MLX5_CAP_FLOWTABLE_RDMA_TX(mdev, cap) : \
334
+ (BUILD_BUG_ON_ZERO(FS_FT_RDMA_TX != FS_FT_MAX_TYPE))\
284335 )
285336
286337 #endif