• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Intel Corporation. */
3 
4 #ifndef _ICE_FLEX_TYPE_H_
5 #define _ICE_FLEX_TYPE_H_
6 
7 #define ICE_FV_OFFSET_INVAL	0x1FF
8 
9 /* Extraction Sequence (Field Vector) Table */
10 struct ice_fv_word {
11 	u8 prot_id;
12 	u16 off;		/* Offset within the protocol header */
13 	u8 resvrd;
14 } __packed;
15 
16 #define ICE_MAX_FV_WORDS 48
17 struct ice_fv {
18 	struct ice_fv_word ew[ICE_MAX_FV_WORDS];
19 };
20 
21 /* Package and segment headers and tables */
22 struct ice_pkg_hdr {
23 	struct ice_pkg_ver pkg_format_ver;
24 	__le32 seg_count;
25 	__le32 seg_offset[];
26 };
27 
28 /* generic segment */
29 struct ice_generic_seg_hdr {
30 #define SEGMENT_TYPE_METADATA	0x00000001
31 #define SEGMENT_TYPE_ICE	0x00000010
32 	__le32 seg_type;
33 	struct ice_pkg_ver seg_format_ver;
34 	__le32 seg_size;
35 	char seg_id[ICE_PKG_NAME_SIZE];
36 };
37 
38 /* ice specific segment */
39 
40 union ice_device_id {
41 	struct {
42 		__le16 device_id;
43 		__le16 vendor_id;
44 	} dev_vend_id;
45 	__le32 id;
46 };
47 
48 struct ice_device_id_entry {
49 	union ice_device_id device;
50 	union ice_device_id sub_device;
51 };
52 
53 struct ice_seg {
54 	struct ice_generic_seg_hdr hdr;
55 	__le32 device_table_count;
56 	struct ice_device_id_entry device_table[];
57 };
58 
59 struct ice_nvm_table {
60 	__le32 table_count;
61 	__le32 vers[];
62 };
63 
64 struct ice_buf {
65 #define ICE_PKG_BUF_SIZE	4096
66 	u8 buf[ICE_PKG_BUF_SIZE];
67 };
68 
69 struct ice_buf_table {
70 	__le32 buf_count;
71 	struct ice_buf buf_array[];
72 };
73 
74 /* global metadata specific segment */
75 struct ice_global_metadata_seg {
76 	struct ice_generic_seg_hdr hdr;
77 	struct ice_pkg_ver pkg_ver;
78 	__le32 rsvd;
79 	char pkg_name[ICE_PKG_NAME_SIZE];
80 };
81 
82 #define ICE_MIN_S_OFF		12
83 #define ICE_MAX_S_OFF		4095
84 #define ICE_MIN_S_SZ		1
85 #define ICE_MAX_S_SZ		4084
86 
87 /* section information */
88 struct ice_section_entry {
89 	__le32 type;
90 	__le16 offset;
91 	__le16 size;
92 };
93 
94 #define ICE_MIN_S_COUNT		1
95 #define ICE_MAX_S_COUNT		511
96 #define ICE_MIN_S_DATA_END	12
97 #define ICE_MAX_S_DATA_END	4096
98 
99 #define ICE_METADATA_BUF	0x80000000
100 
101 struct ice_buf_hdr {
102 	__le16 section_count;
103 	__le16 data_end;
104 	struct ice_section_entry section_entry[];
105 };
106 
107 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
108 	struct_size((struct ice_buf_hdr *)0, section_entry, 1) - (hd_sz)) /\
109 	(ent_sz))
110 
111 /* ice package section IDs */
112 #define ICE_SID_XLT0_SW			10
113 #define ICE_SID_XLT_KEY_BUILDER_SW	11
114 #define ICE_SID_XLT1_SW			12
115 #define ICE_SID_XLT2_SW			13
116 #define ICE_SID_PROFID_TCAM_SW		14
117 #define ICE_SID_PROFID_REDIR_SW		15
118 #define ICE_SID_FLD_VEC_SW		16
119 #define ICE_SID_CDID_KEY_BUILDER_SW	17
120 #define ICE_SID_CDID_REDIR_SW		18
121 
122 #define ICE_SID_XLT0_ACL		20
123 #define ICE_SID_XLT_KEY_BUILDER_ACL	21
124 #define ICE_SID_XLT1_ACL		22
125 #define ICE_SID_XLT2_ACL		23
126 #define ICE_SID_PROFID_TCAM_ACL		24
127 #define ICE_SID_PROFID_REDIR_ACL	25
128 #define ICE_SID_FLD_VEC_ACL		26
129 #define ICE_SID_CDID_KEY_BUILDER_ACL	27
130 #define ICE_SID_CDID_REDIR_ACL		28
131 
132 #define ICE_SID_XLT0_FD			30
133 #define ICE_SID_XLT_KEY_BUILDER_FD	31
134 #define ICE_SID_XLT1_FD			32
135 #define ICE_SID_XLT2_FD			33
136 #define ICE_SID_PROFID_TCAM_FD		34
137 #define ICE_SID_PROFID_REDIR_FD		35
138 #define ICE_SID_FLD_VEC_FD		36
139 #define ICE_SID_CDID_KEY_BUILDER_FD	37
140 #define ICE_SID_CDID_REDIR_FD		38
141 
142 #define ICE_SID_XLT0_RSS		40
143 #define ICE_SID_XLT_KEY_BUILDER_RSS	41
144 #define ICE_SID_XLT1_RSS		42
145 #define ICE_SID_XLT2_RSS		43
146 #define ICE_SID_PROFID_TCAM_RSS		44
147 #define ICE_SID_PROFID_REDIR_RSS	45
148 #define ICE_SID_FLD_VEC_RSS		46
149 #define ICE_SID_CDID_KEY_BUILDER_RSS	47
150 #define ICE_SID_CDID_REDIR_RSS		48
151 
152 #define ICE_SID_RXPARSER_BOOST_TCAM	56
153 #define ICE_SID_TXPARSER_BOOST_TCAM	66
154 
155 #define ICE_SID_XLT0_PE			80
156 #define ICE_SID_XLT_KEY_BUILDER_PE	81
157 #define ICE_SID_XLT1_PE			82
158 #define ICE_SID_XLT2_PE			83
159 #define ICE_SID_PROFID_TCAM_PE		84
160 #define ICE_SID_PROFID_REDIR_PE		85
161 #define ICE_SID_FLD_VEC_PE		86
162 #define ICE_SID_CDID_KEY_BUILDER_PE	87
163 #define ICE_SID_CDID_REDIR_PE		88
164 
165 /* Label Metadata section IDs */
166 #define ICE_SID_LBL_FIRST		0x80000010
167 #define ICE_SID_LBL_RXPARSER_TMEM	0x80000018
168 /* The following define MUST be updated to reflect the last label section ID */
169 #define ICE_SID_LBL_LAST		0x80000038
170 
171 enum ice_block {
172 	ICE_BLK_SW = 0,
173 	ICE_BLK_ACL,
174 	ICE_BLK_FD,
175 	ICE_BLK_RSS,
176 	ICE_BLK_PE,
177 	ICE_BLK_COUNT
178 };
179 
180 enum ice_sect {
181 	ICE_XLT0 = 0,
182 	ICE_XLT_KB,
183 	ICE_XLT1,
184 	ICE_XLT2,
185 	ICE_PROF_TCAM,
186 	ICE_PROF_REDIR,
187 	ICE_VEC_TBL,
188 	ICE_CDID_KB,
189 	ICE_CDID_REDIR,
190 	ICE_SECT_COUNT
191 };
192 
193 /* package labels */
194 struct ice_label {
195 	__le16 value;
196 #define ICE_PKG_LABEL_SIZE	64
197 	char name[ICE_PKG_LABEL_SIZE];
198 };
199 
200 struct ice_label_section {
201 	__le16 count;
202 	struct ice_label label[];
203 };
204 
205 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
206 	struct_size((struct ice_label_section *)0, label, 1) - \
207 	sizeof(struct ice_label), sizeof(struct ice_label))
208 
209 struct ice_sw_fv_section {
210 	__le16 count;
211 	__le16 base_offset;
212 	struct ice_fv fv[];
213 };
214 
215 /* The BOOST TCAM stores the match packet header in reverse order, meaning
216  * the fields are reversed; in addition, this means that the normally big endian
217  * fields of the packet are now little endian.
218  */
219 struct ice_boost_key_value {
220 #define ICE_BOOST_REMAINING_HV_KEY	15
221 	u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
222 	__le16 hv_dst_port_key;
223 	__le16 hv_src_port_key;
224 	u8 tcam_search_key;
225 } __packed;
226 
227 struct ice_boost_key {
228 	struct ice_boost_key_value key;
229 	struct ice_boost_key_value key2;
230 };
231 
232 /* package Boost TCAM entry */
233 struct ice_boost_tcam_entry {
234 	__le16 addr;
235 	__le16 reserved;
236 	/* break up the 40 bytes of key into different fields */
237 	struct ice_boost_key key;
238 	u8 boost_hit_index_group;
239 	/* The following contains bitfields which are not on byte boundaries.
240 	 * These fields are currently unused by driver software.
241 	 */
242 #define ICE_BOOST_BIT_FIELDS		43
243 	u8 bit_fields[ICE_BOOST_BIT_FIELDS];
244 };
245 
246 struct ice_boost_tcam_section {
247 	__le16 count;
248 	__le16 reserved;
249 	struct ice_boost_tcam_entry tcam[];
250 };
251 
252 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
253 	struct_size((struct ice_boost_tcam_section *)0, tcam, 1) - \
254 	sizeof(struct ice_boost_tcam_entry), \
255 	sizeof(struct ice_boost_tcam_entry))
256 
257 struct ice_xlt1_section {
258 	__le16 count;
259 	__le16 offset;
260 	u8 value[];
261 };
262 
263 struct ice_xlt2_section {
264 	__le16 count;
265 	__le16 offset;
266 	__le16 value[];
267 };
268 
269 struct ice_prof_redir_section {
270 	__le16 count;
271 	__le16 offset;
272 	u8 redir_value[];
273 };
274 
275 /* package buffer building */
276 
277 struct ice_buf_build {
278 	struct ice_buf buf;
279 	u16 reserved_section_table_entries;
280 };
281 
282 struct ice_pkg_enum {
283 	struct ice_buf_table *buf_table;
284 	u32 buf_idx;
285 
286 	u32 type;
287 	struct ice_buf_hdr *buf;
288 	u32 sect_idx;
289 	void *sect;
290 	u32 sect_type;
291 
292 	u32 entry_idx;
293 	void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
294 };
295 
296 /* Tunnel enabling */
297 
298 enum ice_tunnel_type {
299 	TNL_VXLAN = 0,
300 	TNL_GENEVE,
301 	__TNL_TYPE_CNT,
302 	TNL_LAST = 0xFF,
303 	TNL_ALL = 0xFF,
304 };
305 
306 struct ice_tunnel_type_scan {
307 	enum ice_tunnel_type type;
308 	const char *label_prefix;
309 };
310 
311 struct ice_tunnel_entry {
312 	enum ice_tunnel_type type;
313 	u16 boost_addr;
314 	u16 port;
315 	struct ice_boost_tcam_entry *boost_entry;
316 	u8 valid;
317 };
318 
319 #define ICE_TUNNEL_MAX_ENTRIES	16
320 
321 struct ice_tunnel_table {
322 	struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES];
323 	u16 count;
324 	u16 valid_count[__TNL_TYPE_CNT];
325 };
326 
327 struct ice_pkg_es {
328 	__le16 count;
329 	__le16 offset;
330 	struct ice_fv_word es[];
331 };
332 
333 struct ice_es {
334 	u32 sid;
335 	u16 count;
336 	u16 fvw;
337 	u16 *ref_count;
338 	struct list_head prof_map;
339 	struct ice_fv_word *t;
340 	struct mutex prof_map_lock;	/* protect access to profiles list */
341 	u8 *written;
342 	u8 reverse; /* set to true to reverse FV order */
343 };
344 
345 /* PTYPE Group management */
346 
347 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type
348  * group (PTG) ID as output.
349  *
350  * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE
351  * are a part of this group until moved to a new PTG.
352  */
353 #define ICE_DEFAULT_PTG	0
354 
355 struct ice_ptg_entry {
356 	struct ice_ptg_ptype *first_ptype;
357 	u8 in_use;
358 };
359 
360 struct ice_ptg_ptype {
361 	struct ice_ptg_ptype *next_ptype;
362 	u8 ptg;
363 };
364 
365 #define ICE_MAX_TCAM_PER_PROFILE	32
366 #define ICE_MAX_PTG_PER_PROFILE		32
367 
368 struct ice_prof_map {
369 	struct list_head list;
370 	u64 profile_cookie;
371 	u64 context;
372 	u8 prof_id;
373 	u8 ptg_cnt;
374 	u8 ptg[ICE_MAX_PTG_PER_PROFILE];
375 };
376 
377 #define ICE_INVALID_TCAM	0xFFFF
378 
379 struct ice_tcam_inf {
380 	u16 tcam_idx;
381 	u8 ptg;
382 	u8 prof_id;
383 	u8 in_use;
384 };
385 
386 struct ice_vsig_prof {
387 	struct list_head list;
388 	u64 profile_cookie;
389 	u8 prof_id;
390 	u8 tcam_count;
391 	struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE];
392 };
393 
394 struct ice_vsig_entry {
395 	struct list_head prop_lst;
396 	struct ice_vsig_vsi *first_vsi;
397 	u8 in_use;
398 };
399 
400 struct ice_vsig_vsi {
401 	struct ice_vsig_vsi *next_vsi;
402 	u32 prop_mask;
403 	u16 changed;
404 	u16 vsig;
405 };
406 
407 #define ICE_XLT1_CNT	1024
408 #define ICE_MAX_PTGS	256
409 
410 /* XLT1 Table */
411 struct ice_xlt1 {
412 	struct ice_ptg_entry *ptg_tbl;
413 	struct ice_ptg_ptype *ptypes;
414 	u8 *t;
415 	u32 sid;
416 	u16 count;
417 };
418 
419 #define ICE_XLT2_CNT	768
420 #define ICE_MAX_VSIGS	768
421 
422 /* VSIG bit layout:
423  * [0:12]: incremental VSIG index 1 to ICE_MAX_VSIGS
424  * [13:15]: PF number of device
425  */
426 #define ICE_VSIG_IDX_M	(0x1FFF)
427 #define ICE_PF_NUM_S	13
428 #define ICE_PF_NUM_M	(0x07 << ICE_PF_NUM_S)
429 #define ICE_VSIG_VALUE(vsig, pf_id) \
430 	(u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \
431 	      (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))
432 #define ICE_DEFAULT_VSIG	0
433 
434 /* XLT2 Table */
435 struct ice_xlt2 {
436 	struct ice_vsig_entry *vsig_tbl;
437 	struct ice_vsig_vsi *vsis;
438 	u16 *t;
439 	u32 sid;
440 	u16 count;
441 };
442 
443 /* Profile ID Management */
444 struct ice_prof_id_key {
445 	__le16 flags;
446 	u8 xlt1;
447 	__le16 xlt2_cdid;
448 } __packed;
449 
450 /* Keys are made up of two values, each one-half the size of the key.
451  * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)
452  */
453 #define ICE_TCAM_KEY_VAL_SZ	5
454 #define ICE_TCAM_KEY_SZ		(2 * ICE_TCAM_KEY_VAL_SZ)
455 
456 struct ice_prof_tcam_entry {
457 	__le16 addr;
458 	u8 key[ICE_TCAM_KEY_SZ];
459 	u8 prof_id;
460 } __packed;
461 
462 struct ice_prof_id_section {
463 	__le16 count;
464 	struct ice_prof_tcam_entry entry[];
465 };
466 
467 struct ice_prof_tcam {
468 	u32 sid;
469 	u16 count;
470 	u16 max_prof_id;
471 	struct ice_prof_tcam_entry *t;
472 	u8 cdid_bits; /* # CDID bits to use in key, 0, 2, 4, or 8 */
473 };
474 
475 struct ice_prof_redir {
476 	u8 *t;
477 	u32 sid;
478 	u16 count;
479 };
480 
481 /* Tables per block */
482 struct ice_blk_info {
483 	struct ice_xlt1 xlt1;
484 	struct ice_xlt2 xlt2;
485 	struct ice_prof_tcam prof;
486 	struct ice_prof_redir prof_redir;
487 	struct ice_es es;
488 	u8 overwrite; /* set to true to allow overwrite of table entries */
489 	u8 is_list_init;
490 };
491 
492 enum ice_chg_type {
493 	ICE_TCAM_NONE = 0,
494 	ICE_PTG_ES_ADD,
495 	ICE_TCAM_ADD,
496 	ICE_VSIG_ADD,
497 	ICE_VSIG_REM,
498 	ICE_VSI_MOVE,
499 };
500 
501 struct ice_chs_chg {
502 	struct list_head list_entry;
503 	enum ice_chg_type type;
504 
505 	u8 add_ptg;
506 	u8 add_vsig;
507 	u8 add_tcam_idx;
508 	u8 add_prof;
509 	u16 ptype;
510 	u8 ptg;
511 	u8 prof_id;
512 	u16 vsi;
513 	u16 vsig;
514 	u16 orig_vsig;
515 	u16 tcam_idx;
516 };
517 
518 #define ICE_FLOW_PTYPE_MAX		ICE_XLT1_CNT
519 #endif /* _ICE_FLEX_TYPE_H_ */
520