net/ice/base: improve flow director masking
[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_NUM_PROFILES 256
20
21 #define ICE_MAX_FV_WORDS 48
22 struct ice_fv {
23         struct ice_fv_word ew[ICE_MAX_FV_WORDS];
24 };
25
26 /* Package and segment headers and tables */
27 struct ice_pkg_hdr {
28         struct ice_pkg_ver format_ver;
29         __le32 seg_count;
30         __le32 seg_offset[1];
31 };
32
33 /* generic segment */
34 struct ice_generic_seg_hdr {
35 #define SEGMENT_TYPE_METADATA   0x00000001
36 #define SEGMENT_TYPE_ICE        0x00000010
37         __le32 seg_type;
38         struct ice_pkg_ver seg_ver;
39         __le32 seg_size;
40         char seg_name[ICE_PKG_NAME_SIZE];
41 };
42
43 /* ice specific segment */
44
45 union ice_device_id {
46         struct {
47                 __le16 device_id;
48                 __le16 vendor_id;
49         } dev_vend_id;
50         __le32 id;
51 };
52
53 struct ice_device_id_entry {
54         union ice_device_id device;
55         union ice_device_id sub_device;
56 };
57
58 struct ice_seg {
59         struct ice_generic_seg_hdr hdr;
60         __le32 device_table_count;
61         struct ice_device_id_entry device_table[1];
62 };
63
64 struct ice_nvm_table {
65         __le32 table_count;
66         __le32 vers[1];
67 };
68
69 struct ice_buf {
70 #define ICE_PKG_BUF_SIZE        4096
71         u8 buf[ICE_PKG_BUF_SIZE];
72 };
73
74 struct ice_buf_table {
75         __le32 buf_count;
76         struct ice_buf buf_array[1];
77 };
78
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;
83         __le32 track_id;
84         char pkg_name[ICE_PKG_NAME_SIZE];
85 };
86
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
91
92 /* section information */
93 struct ice_section_entry {
94         __le32 type;
95         __le16 offset;
96         __le16 size;
97 };
98
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
103
104 #define ICE_METADATA_BUF        0x80000000
105
106 struct ice_buf_hdr {
107         __le16 section_count;
108         __le16 data_end;
109         struct ice_section_entry section_entry[1];
110 };
111
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))
114
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
125
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
135
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
145
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
155
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
166
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
177
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
188
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
198
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
244
245 enum ice_block {
246         ICE_BLK_SW = 0,
247         ICE_BLK_ACL,
248         ICE_BLK_FD,
249         ICE_BLK_RSS,
250         ICE_BLK_PE,
251         ICE_BLK_COUNT
252 };
253
254 enum ice_sect {
255         ICE_XLT0 = 0,
256         ICE_XLT_KB,
257         ICE_XLT1,
258         ICE_XLT2,
259         ICE_PROF_TCAM,
260         ICE_PROF_REDIR,
261         ICE_VEC_TBL,
262         ICE_CDID_KB,
263         ICE_CDID_REDIR,
264         ICE_SECT_COUNT
265 };
266
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
282 /* Packet Type Groups (PTG) - Inner Most fields (IM) */
283 #define ICE_PTG_IM_IPV4_TCP             16
284 #define ICE_PTG_IM_IPV4_UDP             17
285 #define ICE_PTG_IM_IPV4_SCTP            18
286 #define ICE_PTG_IM_IPV4_PAY             20
287 #define ICE_PTG_IM_IPV4_OTHER           21
288 #define ICE_PTG_IM_IPV6_TCP             32
289 #define ICE_PTG_IM_IPV6_UDP             33
290 #define ICE_PTG_IM_IPV6_SCTP            34
291 #define ICE_PTG_IM_IPV6_OTHER           37
292 #define ICE_PTG_IM_L2_OTHER             67
293
294 struct ice_flex_fields {
295         union {
296                 struct {
297                         u8 src_ip;
298                         u8 dst_ip;
299                         u8 flow_label;  /* valid for IPv6 only */
300                 } ip_fields;
301
302                 struct {
303                         u8 src_prt;
304                         u8 dst_prt;
305                 } tcp_udp_fields;
306
307                 struct {
308                         u8 src_ip;
309                         u8 dst_ip;
310                         u8 src_prt;
311                         u8 dst_prt;
312                 } ip_tcp_udp_fields;
313
314                 struct {
315                         u8 src_prt;
316                         u8 dst_prt;
317                         u8 flow_label;  /* valid for IPv6 only */
318                         u8 spi;
319                 } ip_esp_fields;
320
321                 struct {
322                         u32 offset;
323                         u32 length;
324                 } off_len;
325         } fields;
326 };
327
328 #define ICE_XLT1_DFLT_GRP       0
329 #define ICE_XLT1_TABLE_SIZE     1024
330
331 /* package labels */
332 struct ice_label {
333         __le16 value;
334 #define ICE_PKG_LABEL_SIZE      64
335         char name[ICE_PKG_LABEL_SIZE];
336 };
337
338 struct ice_label_section {
339         __le16 count;
340         struct ice_label label[1];
341 };
342
343 #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
344         sizeof(struct ice_label_section) - sizeof(struct ice_label), \
345         sizeof(struct ice_label))
346
347 struct ice_sw_fv_section {
348         __le16 count;
349         __le16 base_offset;
350         struct ice_fv fv[1];
351 };
352
353 struct ice_sw_fv_list_entry {
354         struct LIST_ENTRY_TYPE list_entry;
355         u32 profile_id;
356         struct ice_fv *fv_ptr;
357 };
358
359 #pragma pack(1)
360 /* The BOOST TCAM stores the match packet header in reverse order, meaning
361  * the fields are reversed; in addition, this means that the normally big endian
362  * fields of the packet are now little endian.
363  */
364 struct ice_boost_key_value {
365 #define ICE_BOOST_REMAINING_HV_KEY      15
366         u8 remaining_hv_key[ICE_BOOST_REMAINING_HV_KEY];
367         __le16 hv_dst_port_key;
368         __le16 hv_src_port_key;
369         u8 tcam_search_key;
370 };
371 #pragma pack()
372
373 struct ice_boost_key {
374         struct ice_boost_key_value key;
375         struct ice_boost_key_value key2;
376 };
377
378 /* package Boost TCAM entry */
379 struct ice_boost_tcam_entry {
380         __le16 addr;
381         __le16 reserved;
382         /* break up the 40 bytes of key into different fields */
383         struct ice_boost_key key;
384         u8 boost_hit_index_group;
385         /* The following contains bitfields which are not on byte boundaries.
386          * These fields are currently unused by driver software.
387          */
388 #define ICE_BOOST_BIT_FIELDS            43
389         u8 bit_fields[ICE_BOOST_BIT_FIELDS];
390 };
391
392 struct ice_boost_tcam_section {
393         __le16 count;
394         __le16 reserved;
395         struct ice_boost_tcam_entry tcam[1];
396 };
397
398 #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
399         sizeof(struct ice_boost_tcam_section) - \
400         sizeof(struct ice_boost_tcam_entry), \
401         sizeof(struct ice_boost_tcam_entry))
402
403 #pragma pack(1)
404 struct ice_xlt1_section {
405         __le16 count;
406         __le16 offset;
407         u8 value[1];
408 };
409 #pragma pack()
410
411 #define ICE_XLT1_SIZE(n)        (sizeof(struct ice_xlt1_section) + \
412                                  (sizeof(u8) * ((n) - 1)))
413
414 struct ice_xlt2_section {
415         __le16 count;
416         __le16 offset;
417         __le16 value[1];
418 };
419
420 #define ICE_XLT2_SIZE(n)        (sizeof(struct ice_xlt2_section) + \
421                                  (sizeof(u16) * ((n) - 1)))
422
423 struct ice_prof_redir_section {
424         __le16 count;
425         __le16 offset;
426         u8 redir_value[1];
427 };
428
429 #define ICE_PROF_REDIR_SIZE(n)  (sizeof(struct ice_prof_redir_section) + \
430                                  (sizeof(u8) * ((n) - 1)))
431
432 /* package buffer building */
433
434 struct ice_buf_build {
435         struct ice_buf buf;
436         u16 reserved_section_table_entries;
437 };
438
439 struct ice_pkg_enum {
440         struct ice_buf_table *buf_table;
441         u32 buf_idx;
442
443         u32 type;
444         struct ice_buf_hdr *buf;
445         u32 sect_idx;
446         void *sect;
447         u32 sect_type;
448
449         u32 entry_idx;
450         void *(*handler)(u32 sect_type, void *section, u32 index, u32 *offset);
451 };
452
453 /* Tunnel enabling */
454
455 enum ice_tunnel_type {
456         TNL_VXLAN = 0,
457         TNL_GENEVE,
458         TNL_LAST = 0xFF,
459         TNL_ALL = 0xFF,
460 };
461
462 struct ice_tunnel_type_scan {
463         enum ice_tunnel_type type;
464         const char *label_prefix;
465 };
466
467 struct ice_tunnel_entry {
468         enum ice_tunnel_type type;
469         u16 boost_addr;
470         u16 port;
471         struct ice_boost_tcam_entry *boost_entry;
472         u8 valid;
473         u8 in_use;
474         u8 marked;
475 };
476
477 #define ICE_TUNNEL_MAX_ENTRIES  16
478
479 struct ice_tunnel_table {
480         struct ice_tunnel_entry tbl[ICE_TUNNEL_MAX_ENTRIES];
481         u16 count;
482 };
483
484 struct ice_pkg_es {
485         __le16 count;
486         __le16 offset;
487         struct ice_fv_word es[1];
488 };
489
490 struct ice_es {
491         u32 sid;
492         u16 count;
493         u16 fvw;
494         u16 *ref_count;
495         u32 *mask_ena;
496         struct LIST_HEAD_TYPE prof_map;
497         struct ice_fv_word *t;
498         struct ice_lock prof_map_lock;  /* protect access to profiles list */
499         u8 *written;
500         u8 reverse; /* set to true to reverse FV order */
501 };
502
503 /* PTYPE Group management */
504
505 /* Note: XLT1 table takes 13-bit as input, and results in an 8-bit packet type
506  * group (PTG) ID as output.
507  *
508  * Note: PTG 0 is the default packet type group and it is assumed that all PTYPE
509  * are a part of this group until moved to a new PTG.
510  */
511 #define ICE_DEFAULT_PTG 0
512
513 struct ice_ptg_entry {
514         struct ice_ptg_ptype *first_ptype;
515         u8 in_use;
516 };
517
518 struct ice_ptg_ptype {
519         struct ice_ptg_ptype *next_ptype;
520         u8 ptg;
521 };
522
523 #define ICE_MAX_TCAM_PER_PROFILE        32
524 #define ICE_MAX_PTG_PER_PROFILE         32
525
526 struct ice_prof_map {
527         struct LIST_ENTRY_TYPE list;
528         u64 profile_cookie;
529         u64 context;
530         u8 prof_id;
531         u8 ptg_cnt;
532         u8 ptg[ICE_MAX_PTG_PER_PROFILE];
533 };
534
535 #define ICE_INVALID_TCAM        0xFFFF
536
537 struct ice_tcam_inf {
538         u16 tcam_idx;
539         u8 ptg;
540         u8 prof_id;
541         u8 in_use;
542 };
543
544 struct ice_vsig_prof {
545         struct LIST_ENTRY_TYPE list;
546         u64 profile_cookie;
547         u8 prof_id;
548         u8 tcam_count;
549         struct ice_tcam_inf tcam[ICE_MAX_TCAM_PER_PROFILE];
550 };
551
552 struct ice_vsig_entry {
553         struct LIST_HEAD_TYPE prop_lst;
554         struct ice_vsig_vsi *first_vsi;
555         u8 in_use;
556 };
557
558 struct ice_vsig_vsi {
559         struct ice_vsig_vsi *next_vsi;
560         u32 prop_mask;
561         u16 changed;
562         u16 vsig;
563 };
564
565 #define ICE_XLT1_CNT    1024
566 #define ICE_MAX_PTGS    256
567
568 /* XLT1 Table */
569 struct ice_xlt1 {
570         struct ice_ptg_entry *ptg_tbl;
571         struct ice_ptg_ptype *ptypes;
572         u8 *t;
573         u32 sid;
574         u16 count;
575 };
576
577 #define ICE_XLT2_CNT    768
578 #define ICE_MAX_VSIGS   768
579
580 /* Vsig bit layout:
581  * [0:12]: incremental vsig index 1 to ICE_MAX_VSIGS
582  * [13:15]: PF number of device
583  */
584 #define ICE_VSIG_IDX_M  (0x1FFF)
585 #define ICE_PF_NUM_S    13
586 #define ICE_PF_NUM_M    (0x07 << ICE_PF_NUM_S)
587 #define ICE_VSIG_VALUE(vsig, pf_id) \
588         (u16)((((u16)(vsig)) & ICE_VSIG_IDX_M) | \
589               (((u16)(pf_id) << ICE_PF_NUM_S) & ICE_PF_NUM_M))
590 #define ICE_DEFAULT_VSIG        0
591
592 /* XLT2 Table */
593 struct ice_xlt2 {
594         struct ice_vsig_entry *vsig_tbl;
595         struct ice_vsig_vsi *vsis;
596         u16 *t;
597         u32 sid;
598         u16 count;
599 };
600
601 /* Extraction sequence - list of match fields:
602  * protocol ID, offset, profile length
603  */
604 union ice_match_fld {
605         struct {
606                 u8 prot_id;
607                 u8 offset;
608                 u8 length;
609                 u8 reserved; /* must be zero */
610         } fld;
611         u32 val;
612 };
613
614 #define ICE_MATCH_LIST_SZ       20
615 #pragma pack(1)
616 struct ice_match {
617         u8 count;
618         union ice_match_fld list[ICE_MATCH_LIST_SZ];
619 };
620
621 /* Profile ID Management */
622 struct ice_prof_id_key {
623         __le16 flags;
624         u8 xlt1;
625         __le16 xlt2_cdid;
626 };
627
628 /* Keys are made up of two values, each one-half the size of the key.
629  * For TCAM, the entire key is 80 bits wide (or 2, 40-bit wide values)
630  */
631 #define ICE_TCAM_KEY_VAL_SZ     5
632 #define ICE_TCAM_KEY_SZ         (2 * ICE_TCAM_KEY_VAL_SZ)
633
634 struct ice_prof_tcam_entry {
635         __le16 addr;
636         u8 key[ICE_TCAM_KEY_SZ];
637         u8 prof_id;
638 };
639
640 struct ice_prof_id_section {
641         __le16 count;
642         struct ice_prof_tcam_entry entry[1];
643 };
644 #pragma pack()
645
646 struct ice_prof_tcam {
647         u32 sid;
648         u16 count;
649         u16 max_prof_id;
650         struct ice_prof_tcam_entry *t;
651         u8 cdid_bits; /* # cdid bits to use in key, 0, 2, 4, or 8 */
652 };
653
654 struct ice_prof_redir {
655         u8 *t;
656         u32 sid;
657         u16 count;
658 };
659
660 struct ice_mask {
661         u16 mask;       /* 16-bit mask */
662         u16 idx;        /* index */
663         u16 ref;        /* reference count */
664         u8 in_use;      /* non-zero if used */
665 };
666
667 struct ice_masks {
668         struct ice_lock lock;  /* lock to protect this structure */
669         u16 first;      /* first mask owned by the PF */
670         u16 count;      /* number of masks owned by the PF */
671 #define ICE_PROF_MASK_COUNT 32
672         struct ice_mask masks[ICE_PROF_MASK_COUNT];
673 };
674
675 /* Tables per block */
676 struct ice_blk_info {
677         struct ice_xlt1 xlt1;
678         struct ice_xlt2 xlt2;
679         struct ice_prof_tcam prof;
680         struct ice_prof_redir prof_redir;
681         struct ice_es es;
682         struct ice_masks masks;
683         u8 overwrite; /* set to true to allow overwrite of table entries */
684         u8 is_list_init;
685 };
686
687 enum ice_chg_type {
688         ICE_TCAM_NONE = 0,
689         ICE_PTG_ES_ADD,
690         ICE_TCAM_ADD,
691         ICE_VSIG_ADD,
692         ICE_VSIG_REM,
693         ICE_VSI_MOVE,
694 };
695
696 struct ice_chs_chg {
697         struct LIST_ENTRY_TYPE list_entry;
698         enum ice_chg_type type;
699
700         u8 add_ptg;
701         u8 add_vsig;
702         u8 add_tcam_idx;
703         u8 add_prof;
704         u16 ptype;
705         u8 ptg;
706         u8 prof_id;
707         u16 vsi;
708         u16 vsig;
709         u16 orig_vsig;
710         u16 tcam_idx;
711 };
712
713 #define ICE_FLOW_PTYPE_MAX              ICE_XLT1_CNT
714
715 enum ice_prof_type {
716         ICE_PROF_NON_TUN = 0x1,
717         ICE_PROF_TUN_UDP = 0x2,
718         ICE_PROF_TUN_GRE = 0x4,
719         ICE_PROF_TUN_PPPOE = 0x8,
720         ICE_PROF_TUN_ALL = 0xE,
721         ICE_PROF_ALL = 0xFF,
722 };
723 #endif /* _ICE_FLEX_TYPE_H_ */