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 #define ICE_FV_OFFSET_INVAL 0x1FF
11 /* Extraction Sequence (Field Vector) Table */
14 u16 off; /* Offset within the protocol header */
19 #define ICE_MAX_NUM_PROFILES 256
21 #define ICE_MAX_FV_WORDS 48
23 struct ice_fv_word ew[ICE_MAX_FV_WORDS];
26 /* Package and segment headers and tables */
28 struct ice_pkg_ver format_ver;
34 struct ice_generic_seg_hdr {
35 #define SEGMENT_TYPE_METADATA 0x00000001
36 #define SEGMENT_TYPE_ICE 0x00000010
38 struct ice_pkg_ver seg_ver;
40 char seg_name[ICE_PKG_NAME_SIZE];
43 /* ice specific segment */
53 struct ice_device_id_entry {
54 union ice_device_id device;
55 union ice_device_id sub_device;
59 struct ice_generic_seg_hdr hdr;
60 __le32 device_table_count;
61 struct ice_device_id_entry device_table[1];
64 struct ice_nvm_table {
70 #define ICE_PKG_BUF_SIZE 4096
71 u8 buf[ICE_PKG_BUF_SIZE];
74 struct ice_buf_table {
76 struct ice_buf buf_array[1];
79 /* global metadata specific segment */
80 struct ice_global_metadata_seg {
81 struct ice_generic_seg_hdr hdr;
82 struct ice_pkg_ver pkg_ver;
84 char pkg_name[ICE_PKG_NAME_SIZE];
87 #define ICE_MIN_S_OFF 12
88 #define ICE_MAX_S_OFF 4095
89 #define ICE_MIN_S_SZ 1
90 #define ICE_MAX_S_SZ 4084
92 /* section information */
93 struct ice_section_entry {
99 #define ICE_MIN_S_COUNT 1
100 #define ICE_MAX_S_COUNT 511
101 #define ICE_MIN_S_DATA_END 12
102 #define ICE_MAX_S_DATA_END 4096
104 #define ICE_METADATA_BUF 0x80000000
107 __le16 section_count;
109 struct ice_section_entry section_entry[1];
112 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
113 sizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz))
115 /* ice package section IDs */
116 #define ICE_SID_XLT0_SW 10
117 #define ICE_SID_XLT_KEY_BUILDER_SW 11
118 #define ICE_SID_XLT1_SW 12
119 #define ICE_SID_XLT2_SW 13
120 #define ICE_SID_PROFID_TCAM_SW 14
121 #define ICE_SID_PROFID_REDIR_SW 15
122 #define ICE_SID_FLD_VEC_SW 16
123 #define ICE_SID_CDID_KEY_BUILDER_SW 17
124 #define ICE_SID_CDID_REDIR_SW 18
126 #define ICE_SID_XLT0_ACL 20
127 #define ICE_SID_XLT_KEY_BUILDER_ACL 21
128 #define ICE_SID_XLT1_ACL 22
129 #define ICE_SID_XLT2_ACL 23
130 #define ICE_SID_PROFID_TCAM_ACL 24
131 #define ICE_SID_PROFID_REDIR_ACL 25
132 #define ICE_SID_FLD_VEC_ACL 26
133 #define ICE_SID_CDID_KEY_BUILDER_ACL 27
134 #define ICE_SID_CDID_REDIR_ACL 28
136 #define ICE_SID_XLT0_FD 30
137 #define ICE_SID_XLT_KEY_BUILDER_FD 31
138 #define ICE_SID_XLT1_FD 32
139 #define ICE_SID_XLT2_FD 33
140 #define ICE_SID_PROFID_TCAM_FD 34
141 #define ICE_SID_PROFID_REDIR_FD 35
142 #define ICE_SID_FLD_VEC_FD 36
143 #define ICE_SID_CDID_KEY_BUILDER_FD 37
144 #define ICE_SID_CDID_REDIR_FD 38
146 #define ICE_SID_XLT0_RSS 40
147 #define ICE_SID_XLT_KEY_BUILDER_RSS 41
148 #define ICE_SID_XLT1_RSS 42
149 #define ICE_SID_XLT2_RSS 43
150 #define ICE_SID_PROFID_TCAM_RSS 44
151 #define ICE_SID_PROFID_REDIR_RSS 45
152 #define ICE_SID_FLD_VEC_RSS 46
153 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
154 #define ICE_SID_CDID_REDIR_RSS 48
156 #define ICE_SID_RXPARSER_CAM 50
157 #define ICE_SID_RXPARSER_NOMATCH_CAM 51
158 #define ICE_SID_RXPARSER_IMEM 52
159 #define ICE_SID_RXPARSER_XLT0_BUILDER 53
160 #define ICE_SID_RXPARSER_NODE_PTYPE 54
161 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
162 #define ICE_SID_RXPARSER_BOOST_TCAM 56
163 #define ICE_SID_RXPARSER_PROTO_GRP 57
164 #define ICE_SID_RXPARSER_METADATA_INIT 58
165 #define ICE_SID_RXPARSER_XLT0 59
167 #define ICE_SID_TXPARSER_CAM 60
168 #define ICE_SID_TXPARSER_NOMATCH_CAM 61
169 #define ICE_SID_TXPARSER_IMEM 62
170 #define ICE_SID_TXPARSER_XLT0_BUILDER 63
171 #define ICE_SID_TXPARSER_NODE_PTYPE 64
172 #define ICE_SID_TXPARSER_MARKER_PTYPE 65
173 #define ICE_SID_TXPARSER_BOOST_TCAM 66
174 #define ICE_SID_TXPARSER_PROTO_GRP 67
175 #define ICE_SID_TXPARSER_METADATA_INIT 68
176 #define ICE_SID_TXPARSER_XLT0 69
178 #define ICE_SID_RXPARSER_INIT_REDIR 70
179 #define ICE_SID_TXPARSER_INIT_REDIR 71
180 #define ICE_SID_RXPARSER_MARKER_GRP 72
181 #define ICE_SID_TXPARSER_MARKER_GRP 73
182 #define ICE_SID_RXPARSER_LAST_PROTO 74
183 #define ICE_SID_TXPARSER_LAST_PROTO 75
184 #define ICE_SID_RXPARSER_PG_SPILL 76
185 #define ICE_SID_TXPARSER_PG_SPILL 77
186 #define ICE_SID_RXPARSER_NOMATCH_SPILL 78
187 #define ICE_SID_TXPARSER_NOMATCH_SPILL 79
189 #define ICE_SID_XLT0_PE 80
190 #define ICE_SID_XLT_KEY_BUILDER_PE 81
191 #define ICE_SID_XLT1_PE 82
192 #define ICE_SID_XLT2_PE 83
193 #define ICE_SID_PROFID_TCAM_PE 84
194 #define ICE_SID_PROFID_REDIR_PE 85
195 #define ICE_SID_FLD_VEC_PE 86
196 #define ICE_SID_CDID_KEY_BUILDER_PE 87
197 #define ICE_SID_CDID_REDIR_PE 88
199 /* Label Metadata section IDs */
200 #define ICE_SID_LBL_FIRST 0x80000010
201 #define ICE_SID_LBL_RXPARSER_IMEM 0x80000010
202 #define ICE_SID_LBL_TXPARSER_IMEM 0x80000011
203 #define ICE_SID_LBL_RESERVED_12 0x80000012
204 #define ICE_SID_LBL_RESERVED_13 0x80000013
205 #define ICE_SID_LBL_RXPARSER_MARKER 0x80000014
206 #define ICE_SID_LBL_TXPARSER_MARKER 0x80000015
207 #define ICE_SID_LBL_PTYPE 0x80000016
208 #define ICE_SID_LBL_PROTOCOL_ID 0x80000017
209 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
210 #define ICE_SID_LBL_TXPARSER_TMEM 0x80000019
211 #define ICE_SID_LBL_RXPARSER_PG 0x8000001A
212 #define ICE_SID_LBL_TXPARSER_PG 0x8000001B
213 #define ICE_SID_LBL_RXPARSER_M_TCAM 0x8000001C
214 #define ICE_SID_LBL_TXPARSER_M_TCAM 0x8000001D
215 #define ICE_SID_LBL_SW_PROFID_TCAM 0x8000001E
216 #define ICE_SID_LBL_ACL_PROFID_TCAM 0x8000001F
217 #define ICE_SID_LBL_PE_PROFID_TCAM 0x80000020
218 #define ICE_SID_LBL_RSS_PROFID_TCAM 0x80000021
219 #define ICE_SID_LBL_FD_PROFID_TCAM 0x80000022
220 #define ICE_SID_LBL_FLAG 0x80000023
221 #define ICE_SID_LBL_REG 0x80000024
222 #define ICE_SID_LBL_SW_PTG 0x80000025
223 #define ICE_SID_LBL_ACL_PTG 0x80000026
224 #define ICE_SID_LBL_PE_PTG 0x80000027
225 #define ICE_SID_LBL_RSS_PTG 0x80000028
226 #define ICE_SID_LBL_FD_PTG 0x80000029
227 #define ICE_SID_LBL_SW_VSIG 0x8000002A
228 #define ICE_SID_LBL_ACL_VSIG 0x8000002B
229 #define ICE_SID_LBL_PE_VSIG 0x8000002C
230 #define ICE_SID_LBL_RSS_VSIG 0x8000002D
231 #define ICE_SID_LBL_FD_VSIG 0x8000002E
232 #define ICE_SID_LBL_PTYPE_META 0x8000002F
233 #define ICE_SID_LBL_SW_PROFID 0x80000030
234 #define ICE_SID_LBL_ACL_PROFID 0x80000031
235 #define ICE_SID_LBL_PE_PROFID 0x80000032
236 #define ICE_SID_LBL_RSS_PROFID 0x80000033
237 #define ICE_SID_LBL_FD_PROFID 0x80000034
238 #define ICE_SID_LBL_RXPARSER_MARKER_GRP 0x80000035
239 #define ICE_SID_LBL_TXPARSER_MARKER_GRP 0x80000036
240 #define ICE_SID_LBL_RXPARSER_PROTO 0x80000037
241 #define ICE_SID_LBL_TXPARSER_PROTO 0x80000038
242 /* The following define MUST be updated to reflect the last label section ID */
243 #define ICE_SID_LBL_LAST 0x80000038
267 /* Packet Type (PTYPE) values */
268 #define ICE_PTYPE_MAC_PAY 1
269 #define ICE_PTYPE_IPV4FRAG_PAY 22
270 #define ICE_PTYPE_IPV4_PAY 23
271 #define ICE_PTYPE_IPV4_UDP_PAY 24
272 #define ICE_PTYPE_IPV4_TCP_PAY 26
273 #define ICE_PTYPE_IPV4_SCTP_PAY 27
274 #define ICE_PTYPE_IPV4_ICMP_PAY 28
275 #define ICE_PTYPE_IPV6FRAG_PAY 88
276 #define ICE_PTYPE_IPV6_PAY 89
277 #define ICE_PTYPE_IPV6_UDP_PAY 90
278 #define ICE_PTYPE_IPV6_TCP_PAY 92
279 #define ICE_PTYPE_IPV6_SCTP_PAY 93
280 #define ICE_PTYPE_IPV6_ICMP_PAY 94
281 #define ICE_MAC_IPV4_GTPC_TEID 325
282 #define ICE_MAC_IPV6_GTPC_TEID 326
283 #define ICE_MAC_IPV4_GTPC 327
284 #define ICE_MAC_IPV6_GTPC 328
285 #define ICE_MAC_IPV4_GTPU 329
286 #define ICE_MAC_IPV6_GTPU 330
287 #define ICE_MAC_IPV4_GTPU_IPV4_FRAG 331
288 #define ICE_MAC_IPV4_GTPU_IPV4_PAY 332
289 #define ICE_MAC_IPV4_GTPU_IPV4_UDP_PAY 333
290 #define ICE_MAC_IPV4_GTPU_IPV4_TCP 334
291 #define ICE_MAC_IPV4_GTPU_IPV4_ICMP 335
292 #define ICE_MAC_IPV6_GTPU_IPV4_FRAG 336
293 #define ICE_MAC_IPV6_GTPU_IPV4_PAY 337
294 #define ICE_MAC_IPV6_GTPU_IPV4_UDP_PAY 338
295 #define ICE_MAC_IPV6_GTPU_IPV4_TCP 339
296 #define ICE_MAC_IPV6_GTPU_IPV4_ICMP 340
297 #define ICE_MAC_IPV4_GTPU_IPV6_FRAG 341
298 #define ICE_MAC_IPV4_GTPU_IPV6_PAY 342
299 #define ICE_MAC_IPV4_GTPU_IPV6_UDP_PAY 343
300 #define ICE_MAC_IPV4_GTPU_IPV6_TCP 344
301 #define ICE_MAC_IPV4_GTPU_IPV6_ICMPV6 345
302 #define ICE_MAC_IPV6_GTPU_IPV6_FRAG 346
303 #define ICE_MAC_IPV6_GTPU_IPV6_PAY 347
304 #define ICE_MAC_IPV6_GTPU_IPV6_UDP_PAY 348
305 #define ICE_MAC_IPV6_GTPU_IPV6_TCP 349
306 #define ICE_MAC_IPV6_GTPU_IPV6_ICMPV6 350
308 /* Attributes that can modify PTYPE definitions.
310 * These values will represent special attributes for PTYPES, which will
311 * resolve into metadata packet flags definitions that can be used in the TCAM
312 * for identifying a PTYPE with specific characteristics.
314 enum ice_ptype_attrib_type {
316 ICE_PTYPE_ATTR_GTP_PDU_EH,
317 ICE_PTYPE_ATTR_GTP_SESSION,
318 ICE_PTYPE_ATTR_GTP_DOWNLINK,
319 ICE_PTYPE_ATTR_GTP_UPLINK,
322 struct ice_ptype_attrib_info {
327 /* TCAM flag definitions */
328 #define ICE_GTP_PDU BIT(14)
329 #define ICE_GTP_PDU_LINK BIT(13)
332 #define ICE_GTP_PDU_FLAG_MASK (ICE_GTP_PDU)
333 #define ICE_GTP_PDU_EH ICE_GTP_PDU
335 #define ICE_GTP_FLAGS_MASK (ICE_GTP_PDU | ICE_GTP_PDU_LINK)
336 #define ICE_GTP_SESSION 0
337 #define ICE_GTP_DOWNLINK ICE_GTP_PDU
338 #define ICE_GTP_UPLINK (ICE_GTP_PDU | ICE_GTP_PDU_LINK)
340 struct ice_ptype_attributes {
342 enum ice_ptype_attrib_type attrib;
345 /* Packet Type Groups (PTG) - Inner Most fields (IM) */
346 #define ICE_PTG_IM_IPV4_TCP 16
347 #define ICE_PTG_IM_IPV4_UDP 17
348 #define ICE_PTG_IM_IPV4_SCTP 18
349 #define ICE_PTG_IM_IPV4_PAY 20
350 #define ICE_PTG_IM_IPV4_OTHER 21
351 #define ICE_PTG_IM_IPV6_TCP 32
352 #define ICE_PTG_IM_IPV6_UDP 33
353 #define ICE_PTG_IM_IPV6_SCTP 34
354 #define ICE_PTG_IM_IPV6_OTHER 37
355 #define ICE_PTG_IM_L2_OTHER 67
357 struct ice_flex_fields {
362 u8 flow_label; /* valid for IPv6 only */
380 u8 flow_label; /* valid for IPv6 only */
391 #define ICE_XLT1_DFLT_GRP 0
392 #define ICE_XLT1_TABLE_SIZE 1024
397 #define ICE_PKG_LABEL_SIZE 64
398 char name[ICE_PKG_LABEL_SIZE];
401 struct ice_label_section {
403 struct ice_label label[1];
406 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
407 sizeof(struct ice_label_section) - sizeof(struct ice_label), \
408 sizeof(struct ice_label))
410 struct ice_sw_fv_section {
416 struct ice_sw_fv_list_entry {
417 struct LIST_ENTRY_TYPE list_entry;
419 struct ice_fv *fv_ptr;
423 /* The BOOST TCAM stores the match packet header in reverse order, meaning
424 * the fields are reversed; in addition, this means that the normally big endian
425 * fields of the packet are now little endian.
427 struct ice_boost_key_value {
428 #define ICE_BOOST_REMAINING_HV_KEY 15
429 u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
430 __le16 hv_dst_port_key;
431 __le16 hv_src_port_key;
436 struct ice_boost_key {
437 struct ice_boost_key_value key;
438 struct ice_boost_key_value key2;
441 /* package Boost TCAM entry */
442 struct ice_boost_tcam_entry {
445 /* break up the 40 bytes of key into different fields */
446 struct ice_boost_key key;
447 u8 boost_hit_index_group;
448 /* The following contains bitfields which are not on byte boundaries.
449 * These fields are currently unused by driver software.
451 #define ICE_BOOST_BIT_FIELDS 43
452 u8 bit_fields[ICE_BOOST_BIT_FIELDS];
455 struct ice_boost_tcam_section {
458 struct ice_boost_tcam_entry tcam[1];
461 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
462 sizeof(struct ice_boost_tcam_section) - \
463 sizeof(struct ice_boost_tcam_entry), \
464 sizeof(struct ice_boost_tcam_entry))
467 struct ice_xlt1_section {
474 #define ICE_XLT1_SIZE(n) (sizeof(struct ice_xlt1_section) + \
475 (sizeof(u8) * ((n) - 1)))
477 struct ice_xlt2_section {
483 #define ICE_XLT2_SIZE(n) (sizeof(struct ice_xlt2_section) + \
484 (sizeof(u16) * ((n) - 1)))
486 struct ice_prof_redir_section {
492 #define ICE_PROF_REDIR_SIZE(n) (sizeof(struct ice_prof_redir_section) + \
493 (sizeof(u8) * ((n) - 1)))
495 /* package buffer building */
497 struct ice_buf_build {
499 u16 reserved_section_table_entries;
502 struct ice_pkg_enum {
503 struct ice_buf_table *buf_table;
507 struct ice_buf_hdr *buf;
513 void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
516 /* Tunnel enabling */
518 enum ice_tunnel_type {
525 struct ice_tunnel_type_scan {
526 enum ice_tunnel_type type;
527 const char *label_prefix;
530 struct ice_tunnel_entry {
531 enum ice_tunnel_type type;
534 struct ice_boost_tcam_entry *boost_entry;
540 #define ICE_TUNNEL_MAX_ENTRIES 16
542 struct ice_tunnel_table {
543 struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES];
550 struct ice_fv_word es[1];
559 struct LIST_HEAD_TYPE prof_map;
560 struct ice_fv_word *t;
561 struct ice_lock prof_map_lock; /* protect access to profiles list */
563 u8 reverse; /* set to true to reverse FV order */
566 /* PTYPE Group management */
568 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type
569 * group (PTG) ID as output.
571 * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE
572 * are a part of this group until moved to a new PTG.
574 #define ICE_DEFAULT_PTG 0
576 struct ice_ptg_entry {
577 struct ice_ptg_ptype *first_ptype;
581 struct ice_ptg_ptype {
582 struct ice_ptg_ptype *next_ptype;
586 #define ICE_MAX_TCAM_PER_PROFILE 32
587 #define ICE_MAX_PTG_PER_PROFILE 32
589 struct ice_prof_map {
590 struct LIST_ENTRY_TYPE list;
595 u8 ptg[ICE_MAX_PTG_PER_PROFILE];
596 struct ice_ptype_attrib_info attr[ICE_MAX_PTG_PER_PROFILE];
599 #define ICE_INVALID_TCAM 0xFFFF
601 struct ice_tcam_inf {
603 struct ice_ptype_attrib_info attr;
609 struct ice_vsig_prof {
610 struct LIST_ENTRY_TYPE list;
614 struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE];
617 struct ice_vsig_entry {
618 struct LIST_HEAD_TYPE prop_lst;
619 struct ice_vsig_vsi *first_vsi;
623 struct ice_vsig_vsi {
624 struct ice_vsig_vsi *next_vsi;
630 #define ICE_XLT1_CNT 1024
631 #define ICE_MAX_PTGS 256
635 struct ice_ptg_entry *ptg_tbl;
636 struct ice_ptg_ptype *ptypes;
642 #define ICE_XLT2_CNT 768
643 #define ICE_MAX_VSIGS 768
646 * [0:12]: incremental vsig index 1 to ICE_MAX_VSIGS
647 * [13:15]: PF number of device
649 #define ICE_VSIG_IDX_M (0x1FFF)
650 #define ICE_PF_NUM_S 13
651 #define ICE_PF_NUM_M (0x07 << ICE_PF_NUM_S)
652 #define ICE_VSIG_VALUE(vsig, pf_id) \
653 (u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \
654 (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))
655 #define ICE_DEFAULT_VSIG 0
659 struct ice_vsig_entry *vsig_tbl;
660 struct ice_vsig_vsi *vsis;
666 /* Extraction sequence - list of match fields:
667 * protocol ID, offset, profile length
669 union ice_match_fld {
674 u8 reserved; /* must be zero */
679 #define ICE_MATCH_LIST_SZ 20
683 union ice_match_fld list[ICE_MATCH_LIST_SZ];
686 /* Profile ID Management */
687 struct ice_prof_id_key {
693 /* Keys are made up of two values, each one-half the size of the key.
694 * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)
696 #define ICE_TCAM_KEY_VAL_SZ 5
697 #define ICE_TCAM_KEY_SZ (2 * ICE_TCAM_KEY_VAL_SZ)
699 struct ice_prof_tcam_entry {
701 u8 key[ICE_TCAM_KEY_SZ];
705 struct ice_prof_id_section {
707 struct ice_prof_tcam_entry entry[1];
711 struct ice_prof_tcam {
715 struct ice_prof_tcam_entry *t;
716 u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
719 struct ice_prof_redir {
726 u16 mask; /* 16-bit mask */
728 u16 ref; /* reference count */
729 u8 in_use; /* non-zero if used */
733 struct ice_lock lock; /* lock to protect this structure */
734 u16 first; /* first mask owned by the PF */
735 u16 count; /* number of masks owned by the PF */
736 #define ICE_PROF_MASK_COUNT 32
737 struct ice_mask masks[ICE_PROF_MASK_COUNT];
740 /* Tables per block */
741 struct ice_blk_info {
742 struct ice_xlt1 xlt1;
743 struct ice_xlt2 xlt2;
744 struct ice_prof_tcam prof;
745 struct ice_prof_redir prof_redir;
747 struct ice_masks masks;
748 u8 overwrite; /* set to true to allow overwrite of table entries */
762 struct LIST_ENTRY_TYPE list_entry;
763 enum ice_chg_type type;
776 struct ice_ptype_attrib_info attr;
779 #define ICE_FLOW_PTYPE_MAX ICE_XLT1_CNT
782 ICE_PROF_NON_TUN = 0x1,
783 ICE_PROF_TUN_UDP = 0x2,
784 ICE_PROF_TUN_GRE = 0x4,
785 ICE_PROF_TUN_PPPOE = 0x8,
786 ICE_PROF_TUN_ALL = 0xE,
789 #endif /* _ICE_FLEX_TYPE_H_ */