1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2019
5 #ifndef _ICE_FLEX_TYPE_H_
6 #define _ICE_FLEX_TYPE_H_
8 /* Extraction Sequence (Field Vector) Table */
11 u8 off; /* Offset within the protocol header */
14 #define ICE_MAX_FV_WORDS 48
16 struct ice_fv_word ew[ICE_MAX_FV_WORDS];
19 /* Package and segment headers and tables */
21 struct ice_pkg_ver format_ver;
27 struct ice_generic_seg_hdr {
28 #define SEGMENT_TYPE_METADATA 0x00000001
29 #define SEGMENT_TYPE_ICE 0x00000010
31 struct ice_pkg_ver seg_ver;
33 char seg_name[ICE_PKG_NAME_SIZE];
36 /* ice specific segment */
46 struct ice_device_id_entry {
47 union ice_device_id device;
48 union ice_device_id sub_device;
52 struct ice_generic_seg_hdr hdr;
53 __le32 device_table_count;
54 struct ice_device_id_entry device_table[1];
57 struct ice_nvm_table {
63 #define ICE_PKG_BUF_SIZE 4096
64 u8 buf[ICE_PKG_BUF_SIZE];
67 struct ice_buf_table {
69 struct ice_buf buf_array[1];
72 /* global metadata specific segment */
73 struct ice_global_metadata_seg {
74 struct ice_generic_seg_hdr hdr;
75 struct ice_pkg_ver pkg_ver;
77 char pkg_name[ICE_PKG_NAME_SIZE];
80 #define ICE_MIN_S_OFF 12
81 #define ICE_MAX_S_OFF 4095
82 #define ICE_MIN_S_SZ 1
83 #define ICE_MAX_S_SZ 4084
85 /* section information */
86 struct ice_section_entry {
92 #define ICE_MIN_S_COUNT 1
93 #define ICE_MAX_S_COUNT 511
94 #define ICE_MIN_S_DATA_END 12
95 #define ICE_MAX_S_DATA_END 4096
97 #define ICE_METADATA_BUF 0x80000000
100 __le16 section_count;
102 struct ice_section_entry section_entry[1];
105 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
106 sizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz))
108 /* ice package section IDs */
109 #define ICE_SID_XLT0_SW 10
110 #define ICE_SID_XLT_KEY_BUILDER_SW 11
111 #define ICE_SID_XLT1_SW 12
112 #define ICE_SID_XLT2_SW 13
113 #define ICE_SID_PROFID_TCAM_SW 14
114 #define ICE_SID_PROFID_REDIR_SW 15
115 #define ICE_SID_FLD_VEC_SW 16
116 #define ICE_SID_CDID_KEY_BUILDER_SW 17
117 #define ICE_SID_CDID_REDIR_SW 18
119 #define ICE_SID_XLT0_ACL 20
120 #define ICE_SID_XLT_KEY_BUILDER_ACL 21
121 #define ICE_SID_XLT1_ACL 22
122 #define ICE_SID_XLT2_ACL 23
123 #define ICE_SID_PROFID_TCAM_ACL 24
124 #define ICE_SID_PROFID_REDIR_ACL 25
125 #define ICE_SID_FLD_VEC_ACL 26
126 #define ICE_SID_CDID_KEY_BUILDER_ACL 27
127 #define ICE_SID_CDID_REDIR_ACL 28
129 #define ICE_SID_XLT0_FD 30
130 #define ICE_SID_XLT_KEY_BUILDER_FD 31
131 #define ICE_SID_XLT1_FD 32
132 #define ICE_SID_XLT2_FD 33
133 #define ICE_SID_PROFID_TCAM_FD 34
134 #define ICE_SID_PROFID_REDIR_FD 35
135 #define ICE_SID_FLD_VEC_FD 36
136 #define ICE_SID_CDID_KEY_BUILDER_FD 37
137 #define ICE_SID_CDID_REDIR_FD 38
139 #define ICE_SID_XLT0_RSS 40
140 #define ICE_SID_XLT_KEY_BUILDER_RSS 41
141 #define ICE_SID_XLT1_RSS 42
142 #define ICE_SID_XLT2_RSS 43
143 #define ICE_SID_PROFID_TCAM_RSS 44
144 #define ICE_SID_PROFID_REDIR_RSS 45
145 #define ICE_SID_FLD_VEC_RSS 46
146 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
147 #define ICE_SID_CDID_REDIR_RSS 48
149 #define ICE_SID_RXPARSER_CAM 50
150 #define ICE_SID_RXPARSER_NOMATCH_CAM 51
151 #define ICE_SID_RXPARSER_IMEM 52
152 #define ICE_SID_RXPARSER_XLT0_BUILDER 53
153 #define ICE_SID_RXPARSER_NODE_PTYPE 54
154 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
155 #define ICE_SID_RXPARSER_BOOST_TCAM 56
156 #define ICE_SID_RXPARSER_PROTO_GRP 57
157 #define ICE_SID_RXPARSER_METADATA_INIT 58
158 #define ICE_SID_RXPARSER_XLT0 59
160 #define ICE_SID_TXPARSER_CAM 60
161 #define ICE_SID_TXPARSER_NOMATCH_CAM 61
162 #define ICE_SID_TXPARSER_IMEM 62
163 #define ICE_SID_TXPARSER_XLT0_BUILDER 63
164 #define ICE_SID_TXPARSER_NODE_PTYPE 64
165 #define ICE_SID_TXPARSER_MARKER_PTYPE 65
166 #define ICE_SID_TXPARSER_BOOST_TCAM 66
167 #define ICE_SID_TXPARSER_PROTO_GRP 67
168 #define ICE_SID_TXPARSER_METADATA_INIT 68
169 #define ICE_SID_TXPARSER_XLT0 69
171 #define ICE_SID_RXPARSER_INIT_REDIR 70
172 #define ICE_SID_TXPARSER_INIT_REDIR 71
173 #define ICE_SID_RXPARSER_MARKER_GRP 72
174 #define ICE_SID_TXPARSER_MARKER_GRP 73
175 #define ICE_SID_RXPARSER_LAST_PROTO 74
176 #define ICE_SID_TXPARSER_LAST_PROTO 75
177 #define ICE_SID_RXPARSER_PG_SPILL 76
178 #define ICE_SID_TXPARSER_PG_SPILL 77
179 #define ICE_SID_RXPARSER_NOMATCH_SPILL 78
180 #define ICE_SID_TXPARSER_NOMATCH_SPILL 79
182 #define ICE_SID_XLT0_PE 80
183 #define ICE_SID_XLT_KEY_BUILDER_PE 81
184 #define ICE_SID_XLT1_PE 82
185 #define ICE_SID_XLT2_PE 83
186 #define ICE_SID_PROFID_TCAM_PE 84
187 #define ICE_SID_PROFID_REDIR_PE 85
188 #define ICE_SID_FLD_VEC_PE 86
189 #define ICE_SID_CDID_KEY_BUILDER_PE 87
190 #define ICE_SID_CDID_REDIR_PE 88
192 /* Label Metadata section IDs */
193 #define ICE_SID_LBL_FIRST 0x80000010
194 #define ICE_SID_LBL_RXPARSER_IMEM 0x80000010
195 #define ICE_SID_LBL_TXPARSER_IMEM 0x80000011
196 #define ICE_SID_LBL_RESERVED_12 0x80000012
197 #define ICE_SID_LBL_RESERVED_13 0x80000013
198 #define ICE_SID_LBL_RXPARSER_MARKER 0x80000014
199 #define ICE_SID_LBL_TXPARSER_MARKER 0x80000015
200 #define ICE_SID_LBL_PTYPE 0x80000016
201 #define ICE_SID_LBL_PROTOCOL_ID 0x80000017
202 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
203 #define ICE_SID_LBL_TXPARSER_TMEM 0x80000019
204 #define ICE_SID_LBL_RXPARSER_PG 0x8000001A
205 #define ICE_SID_LBL_TXPARSER_PG 0x8000001B
206 #define ICE_SID_LBL_RXPARSER_M_TCAM 0x8000001C
207 #define ICE_SID_LBL_TXPARSER_M_TCAM 0x8000001D
208 #define ICE_SID_LBL_SW_PROFID_TCAM 0x8000001E
209 #define ICE_SID_LBL_ACL_PROFID_TCAM 0x8000001F
210 #define ICE_SID_LBL_PE_PROFID_TCAM 0x80000020
211 #define ICE_SID_LBL_RSS_PROFID_TCAM 0x80000021
212 #define ICE_SID_LBL_FD_PROFID_TCAM 0x80000022
213 #define ICE_SID_LBL_FLAG 0x80000023
214 #define ICE_SID_LBL_REG 0x80000024
215 #define ICE_SID_LBL_SW_PTG 0x80000025
216 #define ICE_SID_LBL_ACL_PTG 0x80000026
217 #define ICE_SID_LBL_PE_PTG 0x80000027
218 #define ICE_SID_LBL_RSS_PTG 0x80000028
219 #define ICE_SID_LBL_FD_PTG 0x80000029
220 #define ICE_SID_LBL_SW_VSIG 0x8000002A
221 #define ICE_SID_LBL_ACL_VSIG 0x8000002B
222 #define ICE_SID_LBL_PE_VSIG 0x8000002C
223 #define ICE_SID_LBL_RSS_VSIG 0x8000002D
224 #define ICE_SID_LBL_FD_VSIG 0x8000002E
225 #define ICE_SID_LBL_PTYPE_META 0x8000002F
226 #define ICE_SID_LBL_SW_PROFID 0x80000030
227 #define ICE_SID_LBL_ACL_PROFID 0x80000031
228 #define ICE_SID_LBL_PE_PROFID 0x80000032
229 #define ICE_SID_LBL_RSS_PROFID 0x80000033
230 #define ICE_SID_LBL_FD_PROFID 0x80000034
231 #define ICE_SID_LBL_RXPARSER_MARKER_GRP 0x80000035
232 #define ICE_SID_LBL_TXPARSER_MARKER_GRP 0x80000036
233 #define ICE_SID_LBL_RXPARSER_PROTO 0x80000037
234 #define ICE_SID_LBL_TXPARSER_PROTO 0x80000038
235 /* The following define MUST be updated to reflect the last label section ID */
236 #define ICE_SID_LBL_LAST 0x80000038
260 /* Packet Type (PTYPE) values */
261 #define ICE_PTYPE_MAC_PAY 1
262 #define ICE_PTYPE_IPV4FRAG_PAY 22
263 #define ICE_PTYPE_IPV4_PAY 23
264 #define ICE_PTYPE_IPV4_UDP_PAY 24
265 #define ICE_PTYPE_IPV4_TCP_PAY 26
266 #define ICE_PTYPE_IPV4_SCTP_PAY 27
267 #define ICE_PTYPE_IPV4_ICMP_PAY 28
268 #define ICE_PTYPE_IPV6FRAG_PAY 88
269 #define ICE_PTYPE_IPV6_PAY 89
270 #define ICE_PTYPE_IPV6_UDP_PAY 90
271 #define ICE_PTYPE_IPV6_TCP_PAY 92
272 #define ICE_PTYPE_IPV6_SCTP_PAY 93
273 #define ICE_PTYPE_IPV6_ICMP_PAY 94
275 /* Packet Type Groups (PTG) - Inner Most fields (IM) */
276 #define ICE_PTG_IM_IPV4_TCP 16
277 #define ICE_PTG_IM_IPV4_UDP 17
278 #define ICE_PTG_IM_IPV4_SCTP 18
279 #define ICE_PTG_IM_IPV4_PAY 20
280 #define ICE_PTG_IM_IPV4_OTHER 21
281 #define ICE_PTG_IM_IPV6_TCP 32
282 #define ICE_PTG_IM_IPV6_UDP 33
283 #define ICE_PTG_IM_IPV6_SCTP 34
284 #define ICE_PTG_IM_IPV6_OTHER 37
285 #define ICE_PTG_IM_L2_OTHER 67
287 struct ice_flex_fields {
292 u8 flow_label; /* valid for IPv6 only */
310 u8 flow_label; /* valid for IPv6 only */
321 #define ICE_XLT1_DFLT_GRP 0
322 #define ICE_XLT1_TABLE_SIZE 1024
327 #define ICE_PKG_LABEL_SIZE 64
328 char name[ICE_PKG_LABEL_SIZE];
331 struct ice_label_section {
333 struct ice_label label[1];
336 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
337 sizeof(struct ice_label_section) - sizeof(struct ice_label), \
338 sizeof(struct ice_label))
340 struct ice_sw_fv_section {
346 struct ice_sw_fv_list_entry {
347 struct LIST_ENTRY_TYPE list_entry;
349 struct ice_fv *fv_ptr;
353 /* The BOOST TCAM stores the match packet header in reverse order, meaning
354 * the fields are reversed; in addition, this means that the normally big endian
355 * fields of the packet are now little endian.
357 struct ice_boost_key_value {
358 #define ICE_BOOST_REMAINING_HV_KEY 15
359 u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
360 __le16 hv_dst_port_key;
361 __le16 hv_src_port_key;
367 struct ice_boost_key {
368 struct ice_boost_key_value key;
369 struct ice_boost_key_value key2;
372 /* package Boost TCAM entry */
373 struct ice_boost_tcam_entry {
376 /* break up the 40 bytes of key into different fields */
377 struct ice_boost_key key;
378 u8 boost_hit_index_group;
379 /* The following contains bitfields which are not on byte boundaries.
380 * These fields are currently unused by driver software.
382 #define ICE_BOOST_BIT_FIELDS 43
383 u8 bit_fields[ICE_BOOST_BIT_FIELDS];
386 struct ice_boost_tcam_section {
389 struct ice_boost_tcam_entry tcam[1];
392 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
393 sizeof(struct ice_boost_tcam_section) - \
394 sizeof(struct ice_boost_tcam_entry), \
395 sizeof(struct ice_boost_tcam_entry))
398 struct ice_xlt1_section {
406 #define ICE_XLT1_SIZE(n) (sizeof(struct ice_xlt1_section) + \
407 (sizeof(u8) * ((n) - 1)))
409 struct ice_xlt2_section {
415 #define ICE_XLT2_SIZE(n) (sizeof(struct ice_xlt2_section) + \
416 (sizeof(u16) * ((n) - 1)))
418 struct ice_prof_redir_section {
424 #define ICE_PROF_REDIR_SIZE(n) (sizeof(struct ice_prof_redir_section) + \
425 (sizeof(u8) * ((n) - 1)))
427 /* package buffer building */
429 struct ice_buf_build {
431 u16 reserved_section_table_entries;
434 struct ice_pkg_enum {
435 struct ice_buf_table *buf_table;
439 struct ice_buf_hdr *buf;
445 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
448 /* Tunnel enabling */
450 enum ice_tunnel_type {
467 struct ice_tunnel_type_scan {
468 enum ice_tunnel_type type;
469 const char *label_prefix;
472 struct ice_tunnel_entry {
473 enum ice_tunnel_type type;
479 struct ice_boost_tcam_entry *boost_entry;
482 #define ICE_TUNNEL_MAX_ENTRIES 16
484 struct ice_tunnel_table {
486 struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES];
492 struct ice_fv_word es[1];
500 u8 reverse; /* set to true to reverse FV order */
501 struct LIST_HEAD_TYPE prof_map;
502 struct ice_fv_word *t;
503 u8 *resource_used_hack; /* hack for testing */
506 /* PTYPE Group management */
508 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type
509 * group (PTG) ID as output.
511 * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE
512 * are a part of this group until moved to a new PTG.
514 #define ICE_DEFAULT_PTG 0
516 struct ice_ptg_entry {
518 struct ice_ptg_ptype *first_ptype;
521 struct ice_ptg_ptype {
523 struct ice_ptg_ptype *next_ptype;
526 #define ICE_MAX_TCAM_PER_PROFILE 8
527 #define ICE_MAX_PTYPE_PER_PROFILE 8
529 struct ice_prof_map {
530 struct LIST_ENTRY_TYPE list;
535 u8 ptype[ICE_MAX_PTYPE_PER_PROFILE];
538 #define ICE_INVALID_TCAM 0xFFFF
540 struct ice_tcam_inf {
547 struct ice_vsig_prof {
548 struct LIST_ENTRY_TYPE list;
552 struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE];
555 struct ice_vsig_entry {
557 struct LIST_HEAD_TYPE prop_lst;
558 struct ice_vsig_vsi *first_vsi;
561 struct ice_vsig_vsi {
565 struct ice_vsig_vsi *next_vsi;
568 #define ICE_XLT1_CNT 1024
569 #define ICE_MAX_PTGS 256
575 struct ice_ptg_entry *ptg_tbl;
576 struct ice_ptg_ptype *ptypes;
580 #define ICE_XLT2_CNT 768
581 #define ICE_MAX_VSIGS 768
584 * [0:12]: incremental vsig index 1 to ICE_MAX_VSIGS
585 * [13:15]: pf number of device
587 #define ICE_VSIG_IDX_M (0x1FFF)
588 #define ICE_PF_NUM_S 13
589 #define ICE_PF_NUM_M (0x07 << ICE_PF_NUM_S)
590 #define ICE_VSIG_VALUE(vsig, pf_id) \
591 (u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \
592 (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))
593 #define ICE_DEFAULT_VSIG 0
599 struct ice_vsig_entry *vsig_tbl;
600 struct ice_vsig_vsi *vsis;
604 /* Extraction sequence - list of match fields:
605 * protocol ID, offset, profile length
607 union ice_match_fld {
612 u8 reserved; /* must be zero */
617 #define ICE_MATCH_LIST_SZ 20
621 union ice_match_fld list[ICE_MATCH_LIST_SZ];
624 /* Profile ID Management */
625 struct ice_prof_id_key {
631 /* Keys are made up of two values, each one-half the size of the key.
632 * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)
634 #define ICE_TCAM_KEY_VAL_SZ 5
635 #define ICE_TCAM_KEY_SZ (2 * ICE_TCAM_KEY_VAL_SZ)
637 struct ice_prof_tcam_entry {
639 u8 key[ICE_TCAM_KEY_SZ];
643 struct ice_prof_id_section {
645 struct ice_prof_tcam_entry entry[1];
650 struct ice_prof_tcam {
654 u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
655 struct ice_prof_tcam_entry *t;
656 u8 *resource_used_hack;
659 struct ice_prof_redir {
665 /* Tables per block */
666 struct ice_blk_info {
667 struct ice_xlt1 xlt1;
668 struct ice_xlt2 xlt2;
669 struct ice_prof_tcam prof;
670 struct ice_prof_redir prof_redir;
672 u8 overwrite; /* set to true to allow overwrite of table entries */
685 struct LIST_ENTRY_TYPE list_entry;
686 enum ice_chg_type type;
701 #define ICE_FLOW_PTYPE_MAX ICE_XLT1_CNT
703 #endif /* _ICE_FLEX_TYPE_H_ */