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