xref: /linux/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/mlx5hws_cmd.h (revision 9410645520e9b820069761f3450ef6661418e279)
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2024 NVIDIA Corporation & Affiliates */
3 
4 #ifndef MLX5HWS_CMD_H_
5 #define MLX5HWS_CMD_H_
6 
7 #define WIRE_PORT 0xFFFF
8 
9 #define ACCESS_KEY_LEN	32
10 
11 enum mlx5hws_cmd_ext_dest_flags {
12 	MLX5HWS_CMD_EXT_DEST_REFORMAT = 1 << 0,
13 	MLX5HWS_CMD_EXT_DEST_ESW_OWNER_VHCA_ID = 1 << 1,
14 };
15 
16 struct mlx5hws_cmd_set_fte_dest {
17 	u8 destination_type;
18 	u32 destination_id;
19 	enum mlx5hws_cmd_ext_dest_flags ext_flags;
20 	u32 ext_reformat_id;
21 	u16 esw_owner_vhca_id;
22 };
23 
24 struct mlx5hws_cmd_set_fte_attr {
25 	u32 action_flags;
26 	bool ignore_flow_level;
27 	u8 flow_source;
28 	u8 extended_dest;
29 	u8 encrypt_decrypt_type;
30 	u32 encrypt_decrypt_obj_id;
31 	u32 packet_reformat_id;
32 	u32 dests_num;
33 	struct mlx5hws_cmd_set_fte_dest *dests;
34 };
35 
36 struct mlx5hws_cmd_ft_create_attr {
37 	u8 type;
38 	u8 level;
39 	bool rtc_valid;
40 	bool decap_en;
41 	bool reformat_en;
42 };
43 
44 struct mlx5hws_cmd_ft_modify_attr {
45 	u8 type;
46 	u32 rtc_id_0;
47 	u32 rtc_id_1;
48 	u32 table_miss_id;
49 	u8 table_miss_action;
50 	u64 modify_fs;
51 };
52 
53 struct mlx5hws_cmd_ft_query_attr {
54 	u8 type;
55 };
56 
57 struct mlx5hws_cmd_fg_attr {
58 	u32 table_id;
59 	u32 table_type;
60 };
61 
62 struct mlx5hws_cmd_forward_tbl {
63 	u8 type;
64 	u32 ft_id;
65 	u32 fg_id;
66 	u32 refcount;
67 };
68 
69 struct mlx5hws_cmd_rtc_create_attr {
70 	u32 pd;
71 	u32 stc_base;
72 	u32 ste_base;
73 	u32 ste_offset;
74 	u32 miss_ft_id;
75 	bool fw_gen_wqe;
76 	u8 update_index_mode;
77 	u8 access_index_mode;
78 	u8 num_hash_definer;
79 	u8 log_depth;
80 	u8 log_size;
81 	u8 table_type;
82 	u8 match_definer_0;
83 	u8 match_definer_1;
84 	u8 reparse_mode;
85 	bool is_frst_jumbo;
86 	bool is_scnd_range;
87 };
88 
89 struct mlx5hws_cmd_alias_obj_create_attr {
90 	u32 obj_id;
91 	u16 vhca_id;
92 	u16 obj_type;
93 	u8 access_key[ACCESS_KEY_LEN];
94 };
95 
96 struct mlx5hws_cmd_stc_create_attr {
97 	u8 log_obj_range;
98 	u8 table_type;
99 };
100 
101 struct mlx5hws_cmd_stc_modify_attr {
102 	u32 stc_offset;
103 	u8 action_offset;
104 	u8 reparse_mode;
105 	enum mlx5_ifc_stc_action_type action_type;
106 	union {
107 		u32 id; /* TIRN, TAG, FT ID, STE ID, CRYPTO */
108 		struct {
109 			u8 decap;
110 			u16 start_anchor;
111 			u16 end_anchor;
112 		} remove_header;
113 		struct {
114 			u32 arg_id;
115 			u32 pattern_id;
116 		} modify_header;
117 		struct {
118 			__be64 data;
119 		} modify_action;
120 		struct {
121 			u32 arg_id;
122 			u32 header_size;
123 			u8 is_inline;
124 			u8 encap;
125 			u16 insert_anchor;
126 			u16 insert_offset;
127 		} insert_header;
128 		struct {
129 			u8 aso_type;
130 			u32 devx_obj_id;
131 			u8 return_reg_id;
132 		} aso;
133 		struct {
134 			u16 vport_num;
135 			u16 esw_owner_vhca_id;
136 			u8 eswitch_owner_vhca_id_valid;
137 		} vport;
138 		struct {
139 			struct mlx5hws_pool_chunk ste;
140 			struct mlx5hws_pool *ste_pool;
141 			u32 ste_obj_id; /* Internal */
142 			u32 match_definer_id;
143 			u8 log_hash_size;
144 			bool ignore_tx;
145 		} ste_table;
146 		struct {
147 			u16 start_anchor;
148 			u16 num_of_words;
149 		} remove_words;
150 		struct {
151 			u8 type;
152 			u8 op;
153 			u8 size;
154 		} reformat_trailer;
155 
156 		u32 dest_table_id;
157 		u32 dest_tir_num;
158 	};
159 };
160 
161 struct mlx5hws_cmd_ste_create_attr {
162 	u8 log_obj_range;
163 	u8 table_type;
164 };
165 
166 struct mlx5hws_cmd_definer_create_attr {
167 	u8 *dw_selector;
168 	u8 *byte_selector;
169 	u8 *match_mask;
170 };
171 
172 struct mlx5hws_cmd_allow_other_vhca_access_attr {
173 	u16 obj_type;
174 	u32 obj_id;
175 	u8 access_key[ACCESS_KEY_LEN];
176 };
177 
178 struct mlx5hws_cmd_packet_reformat_create_attr {
179 	u8 type;
180 	size_t data_sz;
181 	void *data;
182 	u8 reformat_param_0;
183 };
184 
185 struct mlx5hws_cmd_query_ft_caps {
186 	u8 max_level;
187 	u8 reparse;
188 	u8 ignore_flow_level_rtc_valid;
189 };
190 
191 struct mlx5hws_cmd_generate_wqe_attr {
192 	u8 *wqe_ctrl;
193 	u8 *gta_ctrl;
194 	u8 *gta_data_0;
195 	u8 *gta_data_1;
196 	u32 pdn;
197 };
198 
199 struct mlx5hws_cmd_query_caps {
200 	u32 flex_protocols;
201 	u8 wqe_based_update;
202 	u8 rtc_reparse_mode;
203 	u16 ste_format;
204 	u8 rtc_index_mode;
205 	u8 ste_alloc_log_max;
206 	u8 ste_alloc_log_gran;
207 	u8 stc_alloc_log_max;
208 	u8 stc_alloc_log_gran;
209 	u8 rtc_log_depth_max;
210 	u8 format_select_gtpu_dw_0;
211 	u8 format_select_gtpu_dw_1;
212 	u8 flow_table_hash_type;
213 	u8 format_select_gtpu_dw_2;
214 	u8 format_select_gtpu_ext_dw_0;
215 	u8 access_index_mode;
216 	u32 linear_match_definer;
217 	bool full_dw_jumbo_support;
218 	bool rtc_hash_split_table;
219 	bool rtc_linear_lookup_table;
220 	u32 supp_type_gen_wqe;
221 	u8 rtc_max_hash_def_gen_wqe;
222 	u16 supp_ste_format_gen_wqe;
223 	struct mlx5hws_cmd_query_ft_caps nic_ft;
224 	struct mlx5hws_cmd_query_ft_caps fdb_ft;
225 	bool eswitch_manager;
226 	bool merged_eswitch;
227 	u32 eswitch_manager_vport_number;
228 	u8 log_header_modify_argument_granularity;
229 	u8 log_header_modify_argument_max_alloc;
230 	u8 sq_ts_format;
231 	u8 fdb_tir_stc;
232 	u64 definer_format_sup;
233 	u32 trivial_match_definer;
234 	u32 vhca_id;
235 	u32 shared_vhca_id;
236 	char fw_ver[64];
237 	bool ipsec_offload;
238 	bool is_ecpf;
239 	u8 flex_parser_ok_bits_supp;
240 	u8 flex_parser_id_geneve_tlv_option_0;
241 	u8 flex_parser_id_mpls_over_gre;
242 	u8 flex_parser_id_mpls_over_udp;
243 };
244 
245 int mlx5hws_cmd_flow_table_create(struct mlx5_core_dev *mdev,
246 				  struct mlx5hws_cmd_ft_create_attr *ft_attr,
247 				  u32 *table_id);
248 
249 int mlx5hws_cmd_flow_table_modify(struct mlx5_core_dev *mdev,
250 				  struct mlx5hws_cmd_ft_modify_attr *ft_attr,
251 				  u32 table_id);
252 
253 int mlx5hws_cmd_flow_table_query(struct mlx5_core_dev *mdev,
254 				 u32 obj_id,
255 				 struct mlx5hws_cmd_ft_query_attr *ft_attr,
256 				 u64 *icm_addr_0, u64 *icm_addr_1);
257 
258 int mlx5hws_cmd_flow_table_destroy(struct mlx5_core_dev *mdev,
259 				   u8 fw_ft_type, u32 table_id);
260 
261 void mlx5hws_cmd_alias_flow_table_destroy(struct mlx5_core_dev *mdev,
262 					  u32 table_id);
263 
264 int mlx5hws_cmd_rtc_create(struct mlx5_core_dev *mdev,
265 			   struct mlx5hws_cmd_rtc_create_attr *rtc_attr,
266 			   u32 *rtc_id);
267 
268 void mlx5hws_cmd_rtc_destroy(struct mlx5_core_dev *mdev, u32 rtc_id);
269 
270 int mlx5hws_cmd_stc_create(struct mlx5_core_dev *mdev,
271 			   struct mlx5hws_cmd_stc_create_attr *stc_attr,
272 			   u32 *stc_id);
273 
274 int mlx5hws_cmd_stc_modify(struct mlx5_core_dev *mdev,
275 			   u32 stc_id,
276 			   struct mlx5hws_cmd_stc_modify_attr *stc_attr);
277 
278 void mlx5hws_cmd_stc_destroy(struct mlx5_core_dev *mdev, u32 stc_id);
279 
280 int mlx5hws_cmd_generate_wqe(struct mlx5_core_dev *mdev,
281 			     struct mlx5hws_cmd_generate_wqe_attr *attr,
282 			     struct mlx5_cqe64 *ret_cqe);
283 
284 int mlx5hws_cmd_ste_create(struct mlx5_core_dev *mdev,
285 			   struct mlx5hws_cmd_ste_create_attr *ste_attr,
286 			   u32 *ste_id);
287 
288 void mlx5hws_cmd_ste_destroy(struct mlx5_core_dev *mdev, u32 ste_id);
289 
290 int mlx5hws_cmd_definer_create(struct mlx5_core_dev *mdev,
291 			       struct mlx5hws_cmd_definer_create_attr *def_attr,
292 			       u32 *definer_id);
293 
294 void mlx5hws_cmd_definer_destroy(struct mlx5_core_dev *mdev,
295 				 u32 definer_id);
296 
297 int mlx5hws_cmd_arg_create(struct mlx5_core_dev *mdev,
298 			   u16 log_obj_range,
299 			   u32 pd,
300 			   u32 *arg_id);
301 
302 void mlx5hws_cmd_arg_destroy(struct mlx5_core_dev *mdev,
303 			     u32 arg_id);
304 
305 int mlx5hws_cmd_header_modify_pattern_create(struct mlx5_core_dev *mdev,
306 					     u32 pattern_length,
307 					     u8 *actions,
308 					     u32 *ptrn_id);
309 
310 void mlx5hws_cmd_header_modify_pattern_destroy(struct mlx5_core_dev *mdev,
311 					       u32 ptrn_id);
312 
313 int mlx5hws_cmd_packet_reformat_create(struct mlx5_core_dev *mdev,
314 				       struct mlx5hws_cmd_packet_reformat_create_attr *attr,
315 				       u32 *reformat_id);
316 
317 int mlx5hws_cmd_packet_reformat_destroy(struct mlx5_core_dev *mdev,
318 					u32 reformat_id);
319 
320 int mlx5hws_cmd_set_fte(struct mlx5_core_dev *mdev,
321 			u32 table_type,
322 			u32 table_id,
323 			u32 group_id,
324 			struct mlx5hws_cmd_set_fte_attr *fte_attr);
325 
326 int mlx5hws_cmd_delete_fte(struct mlx5_core_dev *mdev,
327 			   u32 table_type, u32 table_id);
328 
329 struct mlx5hws_cmd_forward_tbl *
330 mlx5hws_cmd_forward_tbl_create(struct mlx5_core_dev *mdev,
331 			       struct mlx5hws_cmd_ft_create_attr *ft_attr,
332 			       struct mlx5hws_cmd_set_fte_attr *fte_attr);
333 
334 void mlx5hws_cmd_forward_tbl_destroy(struct mlx5_core_dev *mdev,
335 				     struct mlx5hws_cmd_forward_tbl *tbl);
336 
337 int mlx5hws_cmd_alias_obj_create(struct mlx5_core_dev *mdev,
338 				 struct mlx5hws_cmd_alias_obj_create_attr *alias_attr,
339 				 u32 *obj_id);
340 
341 int mlx5hws_cmd_alias_obj_destroy(struct mlx5_core_dev *mdev,
342 				  u16 obj_type,
343 				  u32 obj_id);
344 
345 int mlx5hws_cmd_sq_modify_rdy(struct mlx5_core_dev *mdev, u32 sqn);
346 
347 int mlx5hws_cmd_query_caps(struct mlx5_core_dev *mdev,
348 			   struct mlx5hws_cmd_query_caps *caps);
349 
350 void mlx5hws_cmd_set_attr_connect_miss_tbl(struct mlx5hws_context *ctx,
351 					   u32 fw_ft_type,
352 					   enum mlx5hws_table_type type,
353 					   struct mlx5hws_cmd_ft_modify_attr *ft_attr);
354 
355 int mlx5hws_cmd_allow_other_vhca_access(struct mlx5_core_dev *mdev,
356 					struct mlx5hws_cmd_allow_other_vhca_access_attr *attr);
357 
358 int mlx5hws_cmd_query_gvmi(struct mlx5_core_dev *mdev, bool other_function,
359 			   u16 vport_number, u16 *gvmi);
360 
361 #endif /* MLX5HWS_CMD_H_ */
362