c30d407c2e5229b9585042922645a53b023a4021
[dpdk.git] / drivers / net / ice / base / ice_flex_type.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2019
3  */
4
5 #ifndef _ICE_FLEX_TYPE_H_
6 #define _ICE_FLEX_TYPE_H_
7
8 #define ICE_FV_OFFSET_INVAL     0x1FF
9
10 #pragma pack(1)
11 /* Extraction Sequence (Field Vector) Table */
12 struct ice_fv_word {
13         u8 prot_id;
14         u16 off;                /* Offset within the protocol header */
15         u8 resvrd;
16 };
17 #pragma pack()
18
19 #define ICE_MAX_FV_WORDS 48
20 struct ice_fv {
21         struct ice_fv_word ew[ICE_MAX_FV_WORDS];
22 };
23
24 /* Package and segment headers and tables */
25 struct ice_pkg_hdr {
26         struct ice_pkg_ver format_ver;
27         __le32 seg_count;
28         __le32 seg_offset[1];
29 };
30
31 /* generic segment */
32 struct ice_generic_seg_hdr {
33 #define SEGMENT_TYPE_METADATA   0x00000001
34 #define SEGMENT_TYPE_ICE        0x00000010
35         __le32 seg_type;
36         struct ice_pkg_ver seg_ver;
37         __le32 seg_size;
38         char seg_name[ICE_PKG_NAME_SIZE];
39 };
40
41 /* ice specific segment */
42
43 union ice_device_id {
44         struct {
45                 __le16 device_id;
46                 __le16 vendor_id;
47         } dev_vend_id;
48         __le32 id;
49 };
50
51 struct ice_device_id_entry {
52         union ice_device_id device;
53         union ice_device_id sub_device;
54 };
55
56 struct ice_seg {
57         struct ice_generic_seg_hdr hdr;
58         __le32 device_table_count;
59         struct ice_device_id_entry device_table[1];
60 };
61
62 struct ice_nvm_table {
63         __le32 table_count;
64         __le32 vers[1];
65 };
66
67 struct ice_buf {
68 #define ICE_PKG_BUF_SIZE        4096
69         u8 buf[ICE_PKG_BUF_SIZE];
70 };
71
72 struct ice_buf_table {
73         __le32 buf_count;
74         struct ice_buf buf_array[1];
75 };
76
77 /* global metadata specific segment */
78 struct ice_global_metadata_seg {
79         struct ice_generic_seg_hdr hdr;
80         struct ice_pkg_ver pkg_ver;
81         __le32 track_id;
82         char pkg_name[ICE_PKG_NAME_SIZE];
83 };
84
85 #define ICE_MIN_S_OFF           12
86 #define ICE_MAX_S_OFF           4095
87 #define ICE_MIN_S_SZ            1
88 #define ICE_MAX_S_SZ            4084
89
90 /* section information */
91 struct ice_section_entry {
92         __le32 type;
93         __le16 offset;
94         __le16 size;
95 };
96
97 #define ICE_MIN_S_COUNT         1
98 #define ICE_MAX_S_COUNT         511
99 #define ICE_MIN_S_DATA_END      12
100 #define ICE_MAX_S_DATA_END      4096
101
102 #define ICE_METADATA_BUF        0x80000000
103
104 struct ice_buf_hdr {
105         __le16 section_count;
106         __le16 data_end;
107         struct ice_section_entry section_entry[1];
108 };
109
110 #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
111         sizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz))
112
113 /* ice package section IDs */
114 #define ICE_SID_XLT0_SW                 10
115 #define ICE_SID_XLT_KEY_BUILDER_SW      11
116 #define ICE_SID_XLT1_SW                 12
117 #define ICE_SID_XLT2_SW                 13
118 #define ICE_SID_PROFID_TCAM_SW          14
119 #define ICE_SID_PROFID_REDIR_SW         15
120 #define ICE_SID_FLD_VEC_SW              16
121 #define ICE_SID_CDID_KEY_BUILDER_SW     17
122 #define ICE_SID_CDID_REDIR_SW           18
123
124 #define ICE_SID_XLT0_ACL                20
125 #define ICE_SID_XLT_KEY_BUILDER_ACL     21
126 #define ICE_SID_XLT1_ACL                22
127 #define ICE_SID_XLT2_ACL                23
128 #define ICE_SID_PROFID_TCAM_ACL         24
129 #define ICE_SID_PROFID_REDIR_ACL        25
130 #define ICE_SID_FLD_VEC_ACL             26
131 #define ICE_SID_CDID_KEY_BUILDER_ACL    27
132 #define ICE_SID_CDID_REDIR_ACL          28
133
134 #define ICE_SID_XLT0_FD                 30
135 #define ICE_SID_XLT_KEY_BUILDER_FD      31
136 #define ICE_SID_XLT1_FD                 32
137 #define ICE_SID_XLT2_FD                 33
138 #define ICE_SID_PROFID_TCAM_FD          34
139 #define ICE_SID_PROFID_REDIR_FD         35
140 #define ICE_SID_FLD_VEC_FD              36
141 #define ICE_SID_CDID_KEY_BUILDER_FD     37
142 #define ICE_SID_CDID_REDIR_FD           38
143
144 #define ICE_SID_XLT0_RSS                40
145 #define ICE_SID_XLT_KEY_BUILDER_RSS     41
146 #define ICE_SID_XLT1_RSS                42
147 #define ICE_SID_XLT2_RSS                43
148 #define ICE_SID_PROFID_TCAM_RSS         44
149 #define ICE_SID_PROFID_REDIR_RSS        45
150 #define ICE_SID_FLD_VEC_RSS             46
151 #define ICE_SID_CDID_KEY_BUILDER_RSS    47
152 #define ICE_SID_CDID_REDIR_RSS          48
153
154 #define ICE_SID_RXPARSER_CAM            50
155 #define ICE_SID_RXPARSER_NOMATCH_CAM    51
156 #define ICE_SID_RXPARSER_IMEM           52
157 #define ICE_SID_RXPARSER_XLT0_BUILDER   53
158 #define ICE_SID_RXPARSER_NODE_PTYPE     54
159 #define ICE_SID_RXPARSER_MARKER_PTYPE   55
160 #define ICE_SID_RXPARSER_BOOST_TCAM     56
161 #define ICE_SID_RXPARSER_PROTO_GRP      57
162 #define ICE_SID_RXPARSER_METADATA_INIT  58
163 #define ICE_SID_RXPARSER_XLT0           59
164
165 #define ICE_SID_TXPARSER_CAM            60
166 #define ICE_SID_TXPARSER_NOMATCH_CAM    61
167 #define ICE_SID_TXPARSER_IMEM           62
168 #define ICE_SID_TXPARSER_XLT0_BUILDER   63
169 #define ICE_SID_TXPARSER_NODE_PTYPE     64
170 #define ICE_SID_TXPARSER_MARKER_PTYPE   65
171 #define ICE_SID_TXPARSER_BOOST_TCAM     66
172 #define ICE_SID_TXPARSER_PROTO_GRP      67
173 #define ICE_SID_TXPARSER_METADATA_INIT  68
174 #define ICE_SID_TXPARSER_XLT0           69
175
176 #define ICE_SID_RXPARSER_INIT_REDIR     70
177 #define ICE_SID_TXPARSER_INIT_REDIR     71
178 #define ICE_SID_RXPARSER_MARKER_GRP     72
179 #define ICE_SID_TXPARSER_MARKER_GRP     73
180 #define ICE_SID_RXPARSER_LAST_PROTO     74
181 #define ICE_SID_TXPARSER_LAST_PROTO     75
182 #define ICE_SID_RXPARSER_PG_SPILL       76
183 #define ICE_SID_TXPARSER_PG_SPILL       77
184 #define ICE_SID_RXPARSER_NOMATCH_SPILL  78
185 #define ICE_SID_TXPARSER_NOMATCH_SPILL  79
186
187 #define ICE_SID_XLT0_PE                 80
188 #define ICE_SID_XLT_KEY_BUILDER_PE      81
189 #define ICE_SID_XLT1_PE                 82
190 #define ICE_SID_XLT2_PE                 83
191 #define ICE_SID_PROFID_TCAM_PE          84
192 #define ICE_SID_PROFID_REDIR_PE         85
193 #define ICE_SID_FLD_VEC_PE              86
194 #define ICE_SID_CDID_KEY_BUILDER_PE     87
195 #define ICE_SID_CDID_REDIR_PE           88
196
197 /* Label Metadata section IDs */
198 #define ICE_SID_LBL_FIRST               0x80000010
199 #define ICE_SID_LBL_RXPARSER_IMEM       0x80000010
200 #define ICE_SID_LBL_TXPARSER_IMEM       0x80000011
201 #define ICE_SID_LBL_RESERVED_12         0x80000012
202 #define ICE_SID_LBL_RESERVED_13         0x80000013
203 #define ICE_SID_LBL_RXPARSER_MARKER     0x80000014
204 #define ICE_SID_LBL_TXPARSER_MARKER     0x80000015
205 #define ICE_SID_LBL_PTYPE               0x80000016
206 #define ICE_SID_LBL_PROTOCOL_ID         0x80000017
207 #define ICE_SID_LBL_RXPARSER_TMEM       0x80000018
208 #define ICE_SID_LBL_TXPARSER_TMEM       0x80000019
209 #define ICE_SID_LBL_RXPARSER_PG         0x8000001A
210 #define ICE_SID_LBL_TXPARSER_PG         0x8000001B
211 #define ICE_SID_LBL_RXPARSER_M_TCAM     0x8000001C
212 #define ICE_SID_LBL_TXPARSER_M_TCAM     0x8000001D
213 #define ICE_SID_LBL_SW_PROFID_TCAM      0x8000001E
214 #define ICE_SID_LBL_ACL_PROFID_TCAM     0x8000001F
215 #define ICE_SID_LBL_PE_PROFID_TCAM      0x80000020
216 #define ICE_SID_LBL_RSS_PROFID_TCAM     0x80000021
217 #define ICE_SID_LBL_FD_PROFID_TCAM      0x80000022
218 #define ICE_SID_LBL_FLAG                0x80000023
219 #define ICE_SID_LBL_REG                 0x80000024
220 #define ICE_SID_LBL_SW_PTG              0x80000025
221 #define ICE_SID_LBL_ACL_PTG             0x80000026
222 #define ICE_SID_LBL_PE_PTG              0x80000027
223 #define ICE_SID_LBL_RSS_PTG             0x80000028
224 #define ICE_SID_LBL_FD_PTG              0x80000029
225 #define ICE_SID_LBL_SW_VSIG             0x8000002A
226 #define ICE_SID_LBL_ACL_VSIG            0x8000002B
227 #define ICE_SID_LBL_PE_VSIG             0x8000002C
228 #define ICE_SID_LBL_RSS_VSIG            0x8000002D
229 #define ICE_SID_LBL_FD_VSIG             0x8000002E
230 #define ICE_SID_LBL_PTYPE_META          0x8000002F
231 #define ICE_SID_LBL_SW_PROFID           0x80000030
232 #define ICE_SID_LBL_ACL_PROFID          0x80000031
233 #define ICE_SID_LBL_PE_PROFID           0x80000032
234 #define ICE_SID_LBL_RSS_PROFID          0x80000033
235 #define ICE_SID_LBL_FD_PROFID           0x80000034
236 #define ICE_SID_LBL_RXPARSER_MARKER_GRP 0x80000035
237 #define ICE_SID_LBL_TXPARSER_MARKER_GRP 0x80000036
238 #define ICE_SID_LBL_RXPARSER_PROTO      0x80000037
239 #define ICE_SID_LBL_TXPARSER_PROTO      0x80000038
240 /* The following define MUST be updated to reflect the last label section ID */
241 #define ICE_SID_LBL_LAST                0x80000038
242
243 enum ice_block {
244         ICE_BLK_SW = 0,
245         ICE_BLK_ACL,
246         ICE_BLK_FD,
247         ICE_BLK_RSS,
248         ICE_BLK_PE,
249         ICE_BLK_COUNT
250 };
251
252 enum ice_sect {
253         ICE_XLT0 = 0,
254         ICE_XLT_KB,
255         ICE_XLT1,
256         ICE_XLT2,
257         ICE_PROF_TCAM,
258         ICE_PROF_REDIR,
259         ICE_VEC_TBL,
260         ICE_CDID_KB,
261         ICE_CDID_REDIR,
262         ICE_SECT_COUNT
263 };
264
265 /* Packet Type (PTYPE) values */
266 #define ICE_PTYPE_MAC_PAY               1
267 #define ICE_PTYPE_IPV4FRAG_PAY          22
268 #define ICE_PTYPE_IPV4_PAY              23
269 #define ICE_PTYPE_IPV4_UDP_PAY          24
270 #define ICE_PTYPE_IPV4_TCP_PAY          26
271 #define ICE_PTYPE_IPV4_SCTP_PAY         27
272 #define ICE_PTYPE_IPV4_ICMP_PAY         28
273 #define ICE_PTYPE_IPV6FRAG_PAY          88
274 #define ICE_PTYPE_IPV6_PAY              89
275 #define ICE_PTYPE_IPV6_UDP_PAY          90
276 #define ICE_PTYPE_IPV6_TCP_PAY          92
277 #define ICE_PTYPE_IPV6_SCTP_PAY         93
278 #define ICE_PTYPE_IPV6_ICMP_PAY         94
279
280 /* Packet Type Groups (PTG) - Inner Most fields (IM) */
281 #define ICE_PTG_IM_IPV4_TCP             16
282 #define ICE_PTG_IM_IPV4_UDP             17
283 #define ICE_PTG_IM_IPV4_SCTP            18
284 #define ICE_PTG_IM_IPV4_PAY             20
285 #define ICE_PTG_IM_IPV4_OTHER           21
286 #define ICE_PTG_IM_IPV6_TCP             32
287 #define ICE_PTG_IM_IPV6_UDP             33
288 #define ICE_PTG_IM_IPV6_SCTP            34
289 #define ICE_PTG_IM_IPV6_OTHER           37
290 #define ICE_PTG_IM_L2_OTHER             67
291
292 struct ice_flex_fields {
293         union {
294                 struct {
295                         u8 src_ip;
296                         u8 dst_ip;
297                         u8 flow_label;  /* valid for IPv6 only */
298                 } ip_fields;
299
300                 struct {
301                         u8 src_prt;
302                         u8 dst_prt;
303                 } tcp_udp_fields;
304
305                 struct {
306                         u8 src_ip;
307                         u8 dst_ip;
308                         u8 src_prt;
309                         u8 dst_prt;
310                 } ip_tcp_udp_fields;
311
312                 struct {
313                         u8 src_prt;
314                         u8 dst_prt;
315                         u8 flow_label;  /* valid for IPv6 only */
316                         u8 spi;
317                 } ip_esp_fields;
318
319                 struct {
320                         u32 offset;
321                         u32 length;
322                 } off_len;
323         } fields;
324 };
325
326 #define ICE_XLT1_DFLT_GRP       0
327 #define ICE_XLT1_TABLE_SIZE     1024
328
329 /* package labels */
330 struct ice_label {
331         __le16 value;
332 #define ICE_PKG_LABEL_SIZE      64
333         char name[ICE_PKG_LABEL_SIZE];
334 };
335
336 struct ice_label_section {
337         __le16 count;
338         struct ice_label label[1];
339 };
340
341 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
342         sizeof(struct ice_label_section) - sizeof(struct ice_label), \
343         sizeof(struct ice_label))
344
345 struct ice_sw_fv_section {
346         __le16 count;
347         __le16 base_offset;
348         struct ice_fv fv[1];
349 };
350
351 struct ice_sw_fv_list_entry {
352         struct LIST_ENTRY_TYPE list_entry;
353         u32 profile_id;
354         struct ice_fv *fv_ptr;
355 };
356
357 #pragma pack(1)
358 /* The BOOST TCAM stores the match packet header in reverse order, meaning
359  * the fields are reversed; in addition, this means that the normally big endian
360  * fields of the packet are now little endian.
361  */
362 struct ice_boost_key_value {
363 #define ICE_BOOST_REMAINING_HV_KEY      15
364         u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
365         __le16 hv_dst_port_key;
366         __le16 hv_src_port_key;
367         u8 tcam_search_key;
368 };
369 #pragma pack()
370
371 struct ice_boost_key {
372         struct ice_boost_key_value key;
373         struct ice_boost_key_value key2;
374 };
375
376 /* package Boost TCAM entry */
377 struct ice_boost_tcam_entry {
378         __le16 addr;
379         __le16 reserved;
380         /* break up the 40 bytes of key into different fields */
381         struct ice_boost_key key;
382         u8 boost_hit_index_group;
383         /* The following contains bitfields which are not on byte boundaries.
384          * These fields are currently unused by driver software.
385          */
386 #define ICE_BOOST_BIT_FIELDS            43
387         u8 bit_fields[ICE_BOOST_BIT_FIELDS];
388 };
389
390 struct ice_boost_tcam_section {
391         __le16 count;
392         __le16 reserved;
393         struct ice_boost_tcam_entry tcam[1];
394 };
395
396 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
397         sizeof(struct ice_boost_tcam_section) - \
398         sizeof(struct ice_boost_tcam_entry), \
399         sizeof(struct ice_boost_tcam_entry))
400
401 #pragma pack(1)
402 struct ice_xlt1_section {
403         __le16 count;
404         __le16 offset;
405         u8 value[1];
406 };
407 #pragma pack()
408
409 #define ICE_XLT1_SIZE(n)        (sizeof(struct ice_xlt1_section) + \
410                                  (sizeof(u8) * ((n) - 1)))
411
412 struct ice_xlt2_section {
413         __le16 count;
414         __le16 offset;
415         __le16 value[1];
416 };
417
418 #define ICE_XLT2_SIZE(n)        (sizeof(struct ice_xlt2_section) + \
419                                  (sizeof(u16) * ((n) - 1)))
420
421 struct ice_prof_redir_section {
422         __le16 count;
423         __le16 offset;
424         u8 redir_value[1];
425 };
426
427 #define ICE_PROF_REDIR_SIZE(n)  (sizeof(struct ice_prof_redir_section) + \
428                                  (sizeof(u8) * ((n) - 1)))
429
430 /* package buffer building */
431
432 struct ice_buf_build {
433         struct ice_buf buf;
434         u16 reserved_section_table_entries;
435 };
436
437 struct ice_pkg_enum {
438         struct ice_buf_table *buf_table;
439         u32 buf_idx;
440
441         u32 type;
442         struct ice_buf_hdr *buf;
443         u32 sect_idx;
444         void *sect;
445         u32 sect_type;
446
447         u32 entry_idx;
448         void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
449 };
450
451 /* Tunnel enabling */
452
453 enum ice_tunnel_type {
454         TNL_VXLAN = 0,
455         TNL_GENEVE,
456         TNL_LAST = 0xFF,
457         TNL_ALL = 0xFF,
458 };
459
460 struct ice_tunnel_type_scan {
461         enum ice_tunnel_type type;
462         const char *label_prefix;
463 };
464
465 struct ice_tunnel_entry {
466         enum ice_tunnel_type type;
467         u16 boost_addr;
468         u16 port;
469         struct ice_boost_tcam_entry *boost_entry;
470         u8 valid;
471         u8 in_use;
472         u8 marked;
473 };
474
475 #define ICE_TUNNEL_MAX_ENTRIES  16
476
477 struct ice_tunnel_table {
478         struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES];
479         u16 count;
480 };
481
482 struct ice_pkg_es {
483         __le16 count;
484         __le16 offset;
485         struct ice_fv_word es[1];
486 };
487
488 struct ice_es {
489         u32 sid;
490         u16 count;
491         u16 fvw;
492         u16 *ref_count;
493         u32 *mask_ena;
494         struct LIST_HEAD_TYPE prof_map;
495         struct ice_fv_word *t;
496         struct ice_lock prof_map_lock;  /* protect access to profiles list */
497         u8 *written;
498         u8 reverse; /* set to true to reverse FV order */
499 };
500
501 /* PTYPE Group management */
502
503 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type
504  * group (PTG) ID as output.
505  *
506  * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE
507  * are a part of this group until moved to a new PTG.
508  */
509 #define ICE_DEFAULT_PTG 0
510
511 struct ice_ptg_entry {
512         struct ice_ptg_ptype *first_ptype;
513         u8 in_use;
514 };
515
516 struct ice_ptg_ptype {
517         struct ice_ptg_ptype *next_ptype;
518         u8 ptg;
519 };
520
521 #define ICE_MAX_TCAM_PER_PROFILE        32
522 #define ICE_MAX_PTG_PER_PROFILE         32
523
524 struct ice_prof_map {
525         struct LIST_ENTRY_TYPE list;
526         u64 profile_cookie;
527         u64 context;
528         u8 prof_id;
529         u8 ptg_cnt;
530         u8 ptg[ICE_MAX_PTG_PER_PROFILE];
531 };
532
533 #define ICE_INVALID_TCAM        0xFFFF
534
535 struct ice_tcam_inf {
536         u16 tcam_idx;
537         u8 ptg;
538         u8 prof_id;
539         u8 in_use;
540 };
541
542 struct ice_vsig_prof {
543         struct LIST_ENTRY_TYPE list;
544         u64 profile_cookie;
545         u8 prof_id;
546         u8 tcam_count;
547         struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE];
548 };
549
550 struct ice_vsig_entry {
551         struct LIST_HEAD_TYPE prop_lst;
552         struct ice_vsig_vsi *first_vsi;
553         u8 in_use;
554 };
555
556 struct ice_vsig_vsi {
557         struct ice_vsig_vsi *next_vsi;
558         u32 prop_mask;
559         u16 changed;
560         u16 vsig;
561 };
562
563 #define ICE_XLT1_CNT    1024
564 #define ICE_MAX_PTGS    256
565
566 /* XLT1 Table */
567 struct ice_xlt1 {
568         struct ice_ptg_entry *ptg_tbl;
569         struct ice_ptg_ptype *ptypes;
570         u8 *t;
571         u32 sid;
572         u16 count;
573 };
574
575 #define ICE_XLT2_CNT    768
576 #define ICE_MAX_VSIGS   768
577
578 /* Vsig bit layout:
579  * [0:12]: incremental vsig index 1 to ICE_MAX_VSIGS
580  * [13:15]: PF number of device
581  */
582 #define ICE_VSIG_IDX_M  (0x1FFF)
583 #define ICE_PF_NUM_S    13
584 #define ICE_PF_NUM_M    (0x07 << ICE_PF_NUM_S)
585 #define ICE_VSIG_VALUE(vsig, pf_id) \
586         (u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \
587               (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))
588 #define ICE_DEFAULT_VSIG        0
589
590 /* XLT2 Table */
591 struct ice_xlt2 {
592         struct ice_vsig_entry *vsig_tbl;
593         struct ice_vsig_vsi *vsis;
594         u16 *t;
595         u32 sid;
596         u16 count;
597 };
598
599 /* Extraction sequence - list of match fields:
600  * protocol ID, offset, profile length
601  */
602 union ice_match_fld {
603         struct {
604                 u8 prot_id;
605                 u8 offset;
606                 u8 length;
607                 u8 reserved; /* must be zero */
608         } fld;
609         u32 val;
610 };
611
612 #define ICE_MATCH_LIST_SZ       20
613 #pragma pack(1)
614 struct ice_match {
615         u8 count;
616         union ice_match_fld list[ICE_MATCH_LIST_SZ];
617 };
618
619 /* Profile ID Management */
620 struct ice_prof_id_key {
621         __le16 flags;
622         u8 xlt1;
623         __le16 xlt2_cdid;
624 };
625
626 /* Keys are made up of two values, each one-half the size of the key.
627  * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)
628  */
629 #define ICE_TCAM_KEY_VAL_SZ     5
630 #define ICE_TCAM_KEY_SZ         (2 * ICE_TCAM_KEY_VAL_SZ)
631
632 struct ice_prof_tcam_entry {
633         __le16 addr;
634         u8 key[ICE_TCAM_KEY_SZ];
635         u8 prof_id;
636 };
637
638 struct ice_prof_id_section {
639         __le16 count;
640         struct ice_prof_tcam_entry entry[1];
641 };
642 #pragma pack()
643
644 struct ice_prof_tcam {
645         u32 sid;
646         u16 count;
647         u16 max_prof_id;
648         struct ice_prof_tcam_entry *t;
649         u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
650 };
651
652 struct ice_prof_redir {
653         u8 *t;
654         u32 sid;
655         u16 count;
656 };
657
658 struct ice_mask {
659         u16 mask;       /* 16-bit mask */
660         u16 idx;        /* index */
661         u16 ref;        /* reference count */
662         u8 in_use;      /* non-zero if used */
663 };
664
665 struct ice_masks {
666         struct ice_lock lock;  /* lock to protect this structure */
667         u16 first;      /* first mask owned by the PF */
668         u16 count;      /* number of masks owned by the PF */
669 #define ICE_PROFILE_MASK_COUNT 32
670         struct ice_mask masks[ICE_PROFILE_MASK_COUNT];
671 };
672
673 /* Tables per block */
674 struct ice_blk_info {
675         struct ice_xlt1 xlt1;
676         struct ice_xlt2 xlt2;
677         struct ice_prof_tcam prof;
678         struct ice_prof_redir prof_redir;
679         struct ice_es es;
680         struct ice_masks masks;
681         u8 overwrite; /* set to true to allow overwrite of table entries */
682         u8 is_list_init;
683 };
684
685 enum ice_chg_type {
686         ICE_TCAM_NONE = 0,
687         ICE_PTG_ES_ADD,
688         ICE_TCAM_ADD,
689         ICE_VSIG_ADD,
690         ICE_VSIG_REM,
691         ICE_VSI_MOVE,
692 };
693
694 struct ice_chs_chg {
695         struct LIST_ENTRY_TYPE list_entry;
696         enum ice_chg_type type;
697
698         u8 add_ptg;
699         u8 add_vsig;
700         u8 add_tcam_idx;
701         u8 add_prof;
702         u16 ptype;
703         u8 ptg;
704         u8 prof_id;
705         u16 vsi;
706         u16 vsig;
707         u16 orig_vsig;
708         u16 tcam_idx;
709 };
710
711 #define ICE_FLOW_PTYPE_MAX              ICE_XLT1_CNT
712
713 enum ice_prof_type {
714         ICE_PROF_NON_TUN = 0x1,
715         ICE_PROF_TUN_UDP = 0x2,
716         ICE_PROF_TUN_GRE = 0x4,
717         ICE_PROF_TUN_PPPOE = 0x8,
718         ICE_PROF_TUN_ALL = 0xE,
719         ICE_PROF_ALL = 0xFF,
720 };
721 #endif /* _ICE_FLEX_TYPE_H_ */