xref: /dpdk/drivers/net/bnxt/tf_ulp/ulp_template_struct.h (revision 2aa70990392930426d92192c59d237dd16de31e5)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2023 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _ULP_TEMPLATE_STRUCT_H_
7 #define _ULP_TEMPLATE_STRUCT_H_
8 
9 #include <stdint.h>
10 #include "rte_ether.h"
11 #include "rte_icmp.h"
12 #include "rte_ip.h"
13 #include "rte_tcp.h"
14 #include "rte_udp.h"
15 #include "rte_esp.h"
16 #include "rte_sctp.h"
17 #include "rte_flow.h"
18 #include "tf_core.h"
19 #include "cfa_resources.h"
20 #include "cfa_types.h"
21 
22 /* Number of fields for each protocol */
23 #define BNXT_ULP_PROTO_HDR_SVIF_NUM	2
24 #define BNXT_ULP_PROTO_HDR_ETH_NUM	3
25 #define BNXT_ULP_PROTO_HDR_S_VLAN_NUM	3
26 #define BNXT_ULP_PROTO_HDR_VLAN_NUM	6
27 #define BNXT_ULP_PROTO_HDR_IPV4_NUM	10
28 #define BNXT_ULP_PROTO_HDR_IPV6_NUM	8
29 #define BNXT_ULP_PROTO_HDR_UDP_NUM	4
30 #define BNXT_ULP_PROTO_HDR_TCP_NUM	9
31 #define BNXT_ULP_PROTO_HDR_VXLAN_NUM	4
32 #define BNXT_ULP_PROTO_HDR_VXLAN_GPE_NUM 5
33 #define BNXT_ULP_PROTO_HDR_GENEVE_NUM 4
34 #define BNXT_ULP_PROTO_HDR_GRE_NUM	2
35 #define BNXT_ULP_PROTO_HDR_ICMP_NUM	5
36 #define BNXT_ULP_PROTO_HDR_ECPRI_NUM	2
37 #define BNXT_ULP_PROTO_HDR_MAX		128
38 #define BNXT_ULP_PROTO_HDR_ENCAP_MAX	64
39 #define BNXT_ULP_PROTO_HDR_FIELD_SVIF_IDX	1
40 
41 /* Direction attributes */
42 #define BNXT_ULP_FLOW_ATTR_TRANSFER	0x1
43 #define BNXT_ULP_FLOW_ATTR_INGRESS	0x2
44 #define BNXT_ULP_FLOW_ATTR_EGRESS	0x4
45 
46 struct ulp_rte_hdr_bitmap {
47 	uint64_t	bits;
48 };
49 
50 struct ulp_rte_field_bitmap {
51 	uint64_t	bits;
52 };
53 
54 /* Structure to store the protocol fields */
55 #define RTE_PARSER_FLOW_HDR_FIELD_SIZE		16
56 struct ulp_rte_hdr_field {
57 	uint8_t		spec[RTE_PARSER_FLOW_HDR_FIELD_SIZE];
58 	uint8_t		mask[RTE_PARSER_FLOW_HDR_FIELD_SIZE];
59 	uint32_t	size;
60 };
61 
62 struct ulp_rte_act_bitmap {
63 	uint64_t	bits;
64 };
65 
66 /* Structure to hold the action property details. */
67 struct ulp_rte_act_prop {
68 	uint8_t	act_details[BNXT_ULP_ACT_PROP_IDX_LAST];
69 };
70 
71 /* Structure to be used for passing all the parser functions */
72 struct ulp_rte_parser_params {
73 	struct ulp_rte_hdr_bitmap	hdr_bitmap;
74 	struct ulp_rte_hdr_bitmap	enc_hdr_bitmap;
75 	struct ulp_rte_hdr_bitmap	hdr_fp_bit;
76 	struct ulp_rte_field_bitmap	fld_bitmap;
77 	struct ulp_rte_field_bitmap	fld_s_bitmap;
78 	struct ulp_rte_hdr_field	hdr_field[BNXT_ULP_PROTO_HDR_MAX];
79 	struct ulp_rte_hdr_field	enc_field[BNXT_ULP_PROTO_HDR_ENCAP_MAX];
80 	uint64_t			comp_fld[BNXT_ULP_CF_IDX_LAST];
81 	uint32_t			field_idx;
82 	struct ulp_rte_act_bitmap	act_bitmap;
83 	struct ulp_rte_act_prop		act_prop;
84 	uint32_t			dir_attr;
85 	uint32_t			priority;
86 	uint32_t			fid;
87 	uint32_t			parent_flow;
88 	uint32_t			child_flow;
89 	uint16_t			func_id;
90 	uint16_t			port_id;
91 	uint32_t			class_id;
92 	uint32_t			act_tmpl;
93 	struct bnxt_ulp_context		*ulp_ctx;
94 	uint32_t			hdr_sig_id;
95 	uint64_t			flow_sig_id;
96 	uint32_t			flow_pattern_id;
97 	uint32_t			act_pattern_id;
98 	uint8_t				app_id;
99 	uint8_t				tun_idx;
100 	uint16_t			class_info_idx;
101 	uint64_t			wc_field_bitmap;
102 	uint64_t			cf_bitmap;
103 	uint64_t			exclude_field_bitmap;
104 };
105 
106 /* Flow Parser Header Information Structure */
107 struct bnxt_ulp_rte_hdr_info {
108 	enum bnxt_ulp_hdr_type					hdr_type;
109 	/* Flow Parser Protocol Header Function Prototype */
110 	int (*proto_hdr_func)(const struct rte_flow_item	*item_list,
111 			      struct ulp_rte_parser_params	*params);
112 };
113 
114 /* Flow Parser Header Information Structure Array defined in template source*/
115 extern struct bnxt_ulp_rte_hdr_info	ulp_hdr_info[];
116 extern struct bnxt_ulp_rte_hdr_info	ulp_vendor_hdr_info[];
117 
118 /* Flow Parser Action Information Structure */
119 struct bnxt_ulp_rte_act_info {
120 	enum bnxt_ulp_act_type					act_type;
121 	/* Flow Parser Protocol Action Function Prototype */
122 	int32_t (*proto_act_func)
123 		(const struct rte_flow_action	*action_item,
124 		 struct ulp_rte_parser_params	*params);
125 };
126 
127 /* Flow Parser Action Information Structure Array defined in template source*/
128 extern struct bnxt_ulp_rte_act_info	ulp_act_info[];
129 extern struct bnxt_ulp_rte_act_info	ulp_vendor_act_info[];
130 
131 /* Flow Matcher structures */
132 struct bnxt_ulp_header_match_info {
133 	struct ulp_rte_hdr_bitmap		hdr_bitmap;
134 	uint32_t				start_idx;
135 	uint32_t				num_entries;
136 	uint32_t				class_tmpl_id;
137 	uint32_t				act_vnic;
138 };
139 
140 struct ulp_rte_bitmap {
141 	uint64_t	bits;
142 };
143 
144 struct bnxt_ulp_class_match_info {
145 	struct ulp_rte_bitmap	hdr_sig;
146 	struct ulp_rte_bitmap	field_sig;
147 	uint32_t		class_hid;
148 	uint32_t		class_tid;
149 	uint8_t			act_vnic;
150 	uint8_t			wc_pri;
151 	uint8_t			app_sig;
152 	uint32_t		hdr_sig_id;
153 	uint64_t		flow_sig_id;
154 	uint32_t		flow_pattern_id;
155 	uint8_t			app_id;
156 	struct ulp_rte_bitmap	hdr_bitmap;
157 	uint64_t		field_man_bitmap;
158 	uint64_t		field_opt_bitmap;
159 	uint64_t		field_exclude_bitmap;
160 	uint8_t			field_list[BNXT_ULP_GLB_FIELD_TBL_SIZE + 1];
161 };
162 
163 /* Flow Matcher templates Structure for class entries */
164 extern uint16_t ulp_class_sig_tbl[];
165 extern struct bnxt_ulp_class_match_info ulp_class_match_list[];
166 
167 /* Flow Matcher Action structures */
168 struct bnxt_ulp_action_match_info {
169 	struct ulp_rte_act_bitmap		act_bitmap;
170 	uint32_t				act_tmpl_id;
171 };
172 
173 struct bnxt_ulp_act_match_info {
174 	struct ulp_rte_bitmap	act_bitmap;
175 	uint32_t		act_tid;
176 };
177 
178 /* Flow Matcher templates Structure for action entries */
179 extern	uint16_t ulp_act_sig_tbl[];
180 extern struct bnxt_ulp_act_match_info ulp_act_match_list[];
181 
182 /* Device Specific Tables for mapper */
183 struct bnxt_ulp_mapper_cond_info {
184 	enum bnxt_ulp_cond_opc cond_opcode;
185 	uint64_t cond_operand;
186 };
187 
188 struct bnxt_ulp_mapper_cond_list_info {
189 	enum bnxt_ulp_cond_list_opc cond_list_opcode;
190 	uint32_t cond_start_idx;
191 	uint32_t cond_nums;
192 	int32_t cond_true_goto;
193 	int32_t cond_false_goto;
194 };
195 
196 struct bnxt_ulp_mapper_func_info {
197 	enum bnxt_ulp_func_opc		func_opc;
198 	enum bnxt_ulp_func_src		func_src1;
199 	enum bnxt_ulp_func_src		func_src2;
200 	uint64_t			func_opr1;
201 	uint64_t			func_opr2;
202 	uint16_t			func_dst_opr;
203 	uint32_t			func_oper_size;
204 };
205 
206 struct bnxt_ulp_template_device_tbls {
207 	struct bnxt_ulp_mapper_tmpl_info *tmpl_list;
208 	uint32_t tmpl_list_size;
209 	struct bnxt_ulp_mapper_tbl_info *tbl_list;
210 	uint32_t tbl_list_size;
211 	struct bnxt_ulp_mapper_key_info *key_info_list;
212 	uint32_t key_info_list_size;
213 	struct bnxt_ulp_mapper_field_info *key_ext_list;
214 	uint32_t key_ext_list_size;
215 	struct bnxt_ulp_mapper_field_info *result_field_list;
216 	uint32_t result_field_list_size;
217 	struct bnxt_ulp_mapper_ident_info *ident_list;
218 	uint32_t ident_list_size;
219 	struct bnxt_ulp_mapper_cond_info *cond_list;
220 	uint32_t cond_list_size;
221 	struct bnxt_ulp_mapper_cond_list_info *cond_oper_list;
222 	uint32_t cond_oper_list_size;
223 
224 };
225 
226 struct bnxt_ulp_dyn_size_map {
227 	uint32_t		slab_size;
228 	enum tf_tbl_type	tbl_type;
229 };
230 
231 /* Device specific parameters */
232 struct bnxt_ulp_device_params {
233 	uint8_t				description[16];
234 	enum bnxt_ulp_byte_order	key_byte_order;
235 	enum bnxt_ulp_byte_order	result_byte_order;
236 	enum bnxt_ulp_byte_order	encap_byte_order;
237 	enum bnxt_ulp_byte_order	wc_key_byte_order;
238 	enum bnxt_ulp_byte_order	em_byte_order;
239 	uint8_t				encap_byte_swap;
240 	uint8_t				num_phy_ports;
241 	uint32_t			mark_db_lfid_entries;
242 	uint64_t			mark_db_gfid_entries;
243 	uint64_t			int_flow_db_num_entries;
244 	uint64_t			ext_flow_db_num_entries;
245 	uint32_t			flow_count_db_entries;
246 	uint32_t			fdb_parent_flow_entries;
247 	uint32_t			num_resources_per_flow;
248 	uint32_t			ext_cntr_table_type;
249 	uint64_t			byte_count_mask;
250 	uint64_t			packet_count_mask;
251 	uint32_t			byte_count_shift;
252 	uint32_t			packet_count_shift;
253 	uint32_t			wc_dynamic_pad_en;
254 	uint32_t			em_dynamic_pad_en;
255 	uint32_t			dynamic_sram_en;
256 	uint32_t			dyn_encap_list_size;
257 	struct bnxt_ulp_dyn_size_map	dyn_encap_sizes[5];
258 	uint32_t			dyn_modify_list_size;
259 	struct bnxt_ulp_dyn_size_map	dyn_modify_sizes[4];
260 	uint16_t			em_blk_size_bits;
261 	uint16_t			em_blk_align_bits;
262 	uint16_t			em_key_align_bytes;
263 	uint16_t			em_result_size_bits;
264 	uint16_t			wc_slice_width;
265 	uint16_t			wc_max_slices;
266 	uint32_t			wc_mode_list[4];
267 	uint32_t			wc_mod_list_max_size;
268 	uint32_t			wc_ctl_size_bits;
269 	uint32_t			dev_features;
270 	const struct bnxt_ulp_generic_tbl_params *gen_tbl_params;
271 	const struct bnxt_ulp_allocator_tbl_params *allocator_tbl_params;
272 	const struct bnxt_ulp_template_device_tbls *dev_tbls;
273 };
274 
275 /* Flow Mapper */
276 struct bnxt_ulp_mapper_tmpl_info {
277 	uint32_t		device_name;
278 	uint32_t		start_tbl_idx;
279 	uint32_t		num_tbls;
280 	struct bnxt_ulp_mapper_cond_list_info reject_info;
281 };
282 
283 struct bnxt_ulp_mapper_tbl_info {
284 	enum bnxt_ulp_resource_func	resource_func;
285 	uint32_t			resource_type; /* TF_ enum type */
286 	enum bnxt_ulp_resource_sub_type	resource_sub_type;
287 	struct bnxt_ulp_mapper_cond_list_info execute_info;
288 	struct bnxt_ulp_mapper_func_info func_info;
289 	enum bnxt_ulp_cond_opc cond_opcode;
290 	uint32_t cond_operand;
291 	uint8_t				direction;
292 	enum bnxt_ulp_pri_opc		pri_opcode;
293 	uint32_t			pri_operand;
294 
295 	/* conflict resolution opcode */
296 	enum bnxt_ulp_accept_opc	accept_opcode;
297 
298 	enum bnxt_ulp_critical_resource		critical_resource;
299 
300 	/* Information for accessing the key in ulp_key_field_list */
301 	uint32_t	key_start_idx;
302 	uint16_t	key_bit_size;
303 	uint16_t	key_num_fields;
304 
305 	/* Information for accessing the partial key in ulp_key_field_list */
306 	uint32_t	partial_key_start_idx;
307 	uint16_t	partial_key_bit_size;
308 	uint16_t	partial_key_num_fields;
309 
310 	/* Size of the blob that holds the key */
311 	uint16_t	blob_key_bit_size;
312 	uint16_t	record_size;
313 
314 	/* Information for accessing the ulp_class_result_field_list */
315 	uint32_t	result_start_idx;
316 	uint16_t	result_bit_size;
317 	uint16_t	result_num_fields;
318 	uint16_t	encap_num_fields;
319 
320 	/* Information for accessing the ulp_ident_list */
321 	uint32_t	ident_start_idx;
322 	uint16_t	ident_nums;
323 
324 	enum bnxt_ulp_mark_db_opc	mark_db_opcode;
325 
326 	/* Table opcode for table operations */
327 	uint32_t			tbl_opcode;
328 	uint32_t			tbl_operand;
329 	enum bnxt_ulp_generic_tbl_lkup_type gen_tbl_lkup_type;
330 
331 	/* FDB table opcode */
332 	enum bnxt_ulp_fdb_opc		fdb_opcode;
333 	uint32_t			fdb_operand;
334 
335 	/* Manage ref_cnt via opcode for generic tables */
336 	enum bnxt_ulp_ref_cnt_opc	ref_cnt_opcode;
337 
338 	/* Shared session */
339 	enum bnxt_ulp_session_type	session_type;
340 	enum cfa_track_type		track_type;
341 
342 	/* Key recipes for generic templates */
343 	enum bnxt_ulp_key_recipe_opc key_recipe_opcode;
344 	uint32_t key_recipe_operand;
345 
346 	/* control table messages */
347 	const char			*false_message;
348 	const char			*true_message;
349 	const char			*description;
350 };
351 
352 struct bnxt_ulp_mapper_field_info {
353 	uint8_t				description[64];
354 	uint16_t			field_bit_size;
355 	enum bnxt_ulp_field_opc		field_opc;
356 	enum bnxt_ulp_field_src		field_src1;
357 	uint8_t				field_opr1[16];
358 	enum bnxt_ulp_field_src		field_src2;
359 	uint8_t				field_opr2[16];
360 	enum bnxt_ulp_field_src		field_src3;
361 	uint8_t				field_opr3[16];
362 };
363 
364 struct bnxt_ulp_mapper_key_info {
365 	struct bnxt_ulp_mapper_field_info	field_info_spec;
366 	struct bnxt_ulp_mapper_field_info	field_info_mask;
367 };
368 
369 struct bnxt_ulp_mapper_ident_info {
370 	uint8_t		description[64];
371 	uint32_t	resource_func;
372 
373 	uint16_t	ident_type;
374 	uint16_t	ident_bit_size;
375 	uint16_t	ident_bit_pos;
376 	enum bnxt_ulp_rf_idx	regfile_idx;
377 };
378 
379 struct bnxt_ulp_glb_resource_info {
380 	uint8_t				app_id;
381 	enum bnxt_ulp_device_id		device_id;
382 	enum tf_dir			direction;
383 	enum bnxt_ulp_session_type	session_type;
384 	enum bnxt_ulp_resource_func	resource_func;
385 	uint32_t			resource_type; /* TF_ enum type */
386 	enum bnxt_ulp_glb_rf_idx	glb_regfile_index;
387 };
388 
389 struct bnxt_ulp_resource_resv_info {
390 	uint8_t				app_id;
391 	enum bnxt_ulp_device_id		device_id;
392 	enum tf_dir			direction;
393 	enum bnxt_ulp_session_type	session_type;
394 	enum bnxt_ulp_resource_func	resource_func;
395 	uint32_t			resource_type; /* TF_ enum type */
396 	uint32_t			count;
397 };
398 
399 struct bnxt_ulp_app_capabilities_info {
400 	uint8_t				app_id;
401 	uint32_t			default_priority;
402 	uint32_t			max_def_priority;
403 	uint32_t			min_flow_priority;
404 	uint32_t			max_flow_priority;
405 	uint32_t			vxlan_port;
406 	uint32_t			vxlan_ip_port;
407 	uint32_t			ecpri_udp_port;
408 	enum bnxt_ulp_device_id		device_id;
409 	uint32_t			upgrade_fw_update;
410 	uint8_t				ha_pool_id;
411 	uint8_t				ha_reg_state;
412 	uint8_t				ha_reg_cnt;
413 	uint8_t				tunnel_next_proto;
414 	uint32_t			flags;
415 	uint32_t			max_pools;
416 	uint8_t				em_multiplier;
417 	uint32_t			num_rx_flows;
418 	uint32_t			num_tx_flows;
419 	uint16_t			act_rx_max_sz;
420 	uint16_t			act_tx_max_sz;
421 	uint16_t			em_rx_key_max_sz;
422 	uint16_t			em_tx_key_max_sz;
423 	uint32_t			pbl_page_sz_in_bytes;
424 	uint16_t			num_key_recipes_per_dir;
425 	uint64_t			feature_bits;
426 	uint64_t			default_class_bits;
427 	uint64_t			default_act_bits;
428 };
429 
430 struct bnxt_ulp_cache_tbl_params {
431 	uint16_t num_entries;
432 };
433 
434 struct bnxt_ulp_generic_tbl_params {
435 	const char			*name;
436 	enum bnxt_ulp_gen_tbl_type	gen_tbl_type;
437 	uint16_t			result_num_entries;
438 	uint16_t			result_num_bytes;
439 	enum bnxt_ulp_byte_order	result_byte_order;
440 	uint32_t			hash_tbl_entries;
441 	uint16_t			num_buckets;
442 	uint16_t			key_num_bytes;
443 	uint16_t			partial_key_num_bytes;
444 };
445 
446 struct bnxt_ulp_allocator_tbl_params  {
447 	const char			*name;
448 	uint16_t			num_entries;
449 };
450 
451 struct bnxt_ulp_shared_act_info {
452 	uint64_t act_bitmask;
453 };
454 
455 /*
456  * Flow Mapper Static Data Externs:
457  * Access to the below static data should be done through access functions and
458  * directly throughout the code.
459  */
460 
461 /*
462  * The ulp_device_params is indexed by the dev_id.
463  * This table maintains the device specific parameters.
464  */
465 extern struct bnxt_ulp_device_params ulp_device_params[];
466 
467 /*
468  * The ulp_act_prop_map_table provides the mapping to index and size of action
469  * properties.
470  */
471 extern uint32_t ulp_act_prop_map_table[];
472 
473 /*
474  * The ulp_glb_resource_tbl provides the list of global resources that need to
475  * be initialized and where to store them.
476  */
477 extern struct bnxt_ulp_glb_resource_info ulp_glb_resource_tbl[];
478 
479 /*
480  * The ulp_app_glb_resource_tbl provides the list of shared resources required
481  * in the event that shared session is enabled.
482  */
483 extern struct bnxt_ulp_glb_resource_info ulp_app_glb_resource_tbl[];
484 
485 /*
486  * The ulp_resource_resv_list provides the list of tf resources required when
487  * calling tf_open.
488  */
489 extern struct bnxt_ulp_resource_resv_info ulp_resource_resv_list[];
490 
491 /*
492  * The ulp_app_resource_resv_list provides the list of tf resources required
493  * when calling tf_open.
494  */
495 extern struct bnxt_ulp_resource_resv_info ulp_app_resource_resv_list[];
496 
497 /*
498  * The_app_cap_info_list provides the list of ULP capabilities per app/device.
499  */
500 extern struct bnxt_ulp_app_capabilities_info ulp_app_cap_info_list[];
501 
502 /*
503  * The ulp_cache_tbl_parms table provides the sizes of the cache tables the
504  * mapper must dynamically allocate during initialization.
505  */
506 extern struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[];
507 
508 /*
509  * The ulp_generic_tbl_parms table provides the sizes of the generic tables the
510  * mapper must dynamically allocate during initialization.
511  */
512 extern struct bnxt_ulp_generic_tbl_params ulp_generic_tbl_params[];
513 /*
514  * The ulp_global template table is used to initialize default entries
515  * that could be reused by other templates.
516  */
517 extern uint32_t ulp_glb_template_tbl[];
518 #endif /* _ULP_TEMPLATE_STRUCT_H_ */
519