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