crypto/dpaa2_sec: add sample descriptors
[dpdk.git] / drivers / net / dpaa2 / mc / fsl_net.h
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license. When using or
3  * redistributing this file, you may do so under either license.
4  *
5  *   BSD LICENSE
6  *
7  * Copyright 2013-2015 Freescale Semiconductor Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * * Neither the name of the above-listed copyright holders nor the
17  * names of any contributors may be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  *   GPL LICENSE SUMMARY
21  *
22  * ALTERNATIVELY, this software may be distributed under the terms of the
23  * GNU General Public License ("GPL") as published by the Free Software
24  * Foundation, either version 2 of that License or (at your option) any
25  * later version.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 #ifndef __FSL_NET_H
40 #define __FSL_NET_H
41
42 #define LAST_HDR_INDEX 0xFFFFFFFF
43
44 /*****************************************************************************/
45 /*                Protocol fields                                            */
46 /*****************************************************************************/
47
48 /*************************  Ethernet fields  *********************************/
49 #define NH_FLD_ETH_DA                         (1)
50 #define NH_FLD_ETH_SA                         (NH_FLD_ETH_DA << 1)
51 #define NH_FLD_ETH_LENGTH                     (NH_FLD_ETH_DA << 2)
52 #define NH_FLD_ETH_TYPE                       (NH_FLD_ETH_DA << 3)
53 #define NH_FLD_ETH_FINAL_CKSUM                (NH_FLD_ETH_DA << 4)
54 #define NH_FLD_ETH_PADDING                    (NH_FLD_ETH_DA << 5)
55 #define NH_FLD_ETH_ALL_FIELDS                 ((NH_FLD_ETH_DA << 6) - 1)
56
57 #define NH_FLD_ETH_ADDR_SIZE                 6
58
59 /***************************  VLAN fields  ***********************************/
60 #define NH_FLD_VLAN_VPRI                      (1)
61 #define NH_FLD_VLAN_CFI                       (NH_FLD_VLAN_VPRI << 1)
62 #define NH_FLD_VLAN_VID                       (NH_FLD_VLAN_VPRI << 2)
63 #define NH_FLD_VLAN_LENGTH                    (NH_FLD_VLAN_VPRI << 3)
64 #define NH_FLD_VLAN_TYPE                      (NH_FLD_VLAN_VPRI << 4)
65 #define NH_FLD_VLAN_ALL_FIELDS                ((NH_FLD_VLAN_VPRI << 5) - 1)
66
67 #define NH_FLD_VLAN_TCI                       (NH_FLD_VLAN_VPRI | \
68                                                NH_FLD_VLAN_CFI | \
69                                                NH_FLD_VLAN_VID)
70
71 /************************  IP (generic) fields  ******************************/
72 #define NH_FLD_IP_VER                         (1)
73 #define NH_FLD_IP_DSCP                        (NH_FLD_IP_VER << 2)
74 #define NH_FLD_IP_ECN                         (NH_FLD_IP_VER << 3)
75 #define NH_FLD_IP_PROTO                       (NH_FLD_IP_VER << 4)
76 #define NH_FLD_IP_SRC                         (NH_FLD_IP_VER << 5)
77 #define NH_FLD_IP_DST                         (NH_FLD_IP_VER << 6)
78 #define NH_FLD_IP_TOS_TC                      (NH_FLD_IP_VER << 7)
79 #define NH_FLD_IP_ID                          (NH_FLD_IP_VER << 8)
80 #define NH_FLD_IP_ALL_FIELDS                  ((NH_FLD_IP_VER << 9) - 1)
81
82 #define NH_FLD_IP_PROTO_SIZE                  1
83
84 /*****************************  IPV4 fields  *********************************/
85 #define NH_FLD_IPV4_VER                       (1)
86 #define NH_FLD_IPV4_HDR_LEN                   (NH_FLD_IPV4_VER << 1)
87 #define NH_FLD_IPV4_TOS                       (NH_FLD_IPV4_VER << 2)
88 #define NH_FLD_IPV4_TOTAL_LEN                 (NH_FLD_IPV4_VER << 3)
89 #define NH_FLD_IPV4_ID                        (NH_FLD_IPV4_VER << 4)
90 #define NH_FLD_IPV4_FLAG_D                    (NH_FLD_IPV4_VER << 5)
91 #define NH_FLD_IPV4_FLAG_M                    (NH_FLD_IPV4_VER << 6)
92 #define NH_FLD_IPV4_OFFSET                    (NH_FLD_IPV4_VER << 7)
93 #define NH_FLD_IPV4_TTL                       (NH_FLD_IPV4_VER << 8)
94 #define NH_FLD_IPV4_PROTO                     (NH_FLD_IPV4_VER << 9)
95 #define NH_FLD_IPV4_CKSUM                     (NH_FLD_IPV4_VER << 10)
96 #define NH_FLD_IPV4_SRC_IP                    (NH_FLD_IPV4_VER << 11)
97 #define NH_FLD_IPV4_DST_IP                    (NH_FLD_IPV4_VER << 12)
98 #define NH_FLD_IPV4_OPTS                      (NH_FLD_IPV4_VER << 13)
99 #define NH_FLD_IPV4_OPTS_COUNT                (NH_FLD_IPV4_VER << 14)
100 #define NH_FLD_IPV4_ALL_FIELDS                ((NH_FLD_IPV4_VER << 15) - 1)
101
102 #define NH_FLD_IPV4_ADDR_SIZE                 4
103 #define NH_FLD_IPV4_PROTO_SIZE                1
104
105 /*****************************  IPV6 fields  *********************************/
106 #define NH_FLD_IPV6_VER                       (1)
107 #define NH_FLD_IPV6_TC                        (NH_FLD_IPV6_VER << 1)
108 #define NH_FLD_IPV6_SRC_IP                    (NH_FLD_IPV6_VER << 2)
109 #define NH_FLD_IPV6_DST_IP                    (NH_FLD_IPV6_VER << 3)
110 #define NH_FLD_IPV6_NEXT_HDR                  (NH_FLD_IPV6_VER << 4)
111 #define NH_FLD_IPV6_FL                        (NH_FLD_IPV6_VER << 5)
112 #define NH_FLD_IPV6_HOP_LIMIT                 (NH_FLD_IPV6_VER << 6)
113 #define NH_FLD_IPV6_ID                        (NH_FLD_IPV6_VER << 7)
114 #define NH_FLD_IPV6_ALL_FIELDS                ((NH_FLD_IPV6_VER << 8) - 1)
115
116 #define NH_FLD_IPV6_ADDR_SIZE                 16
117 #define NH_FLD_IPV6_NEXT_HDR_SIZE             1
118
119 /*****************************  ICMP fields  *********************************/
120 #define NH_FLD_ICMP_TYPE                      (1)
121 #define NH_FLD_ICMP_CODE                      (NH_FLD_ICMP_TYPE << 1)
122 #define NH_FLD_ICMP_CKSUM                     (NH_FLD_ICMP_TYPE << 2)
123 #define NH_FLD_ICMP_ID                        (NH_FLD_ICMP_TYPE << 3)
124 #define NH_FLD_ICMP_SQ_NUM                    (NH_FLD_ICMP_TYPE << 4)
125 #define NH_FLD_ICMP_ALL_FIELDS                ((NH_FLD_ICMP_TYPE << 5) - 1)
126
127 #define NH_FLD_ICMP_CODE_SIZE                 1
128 #define NH_FLD_ICMP_TYPE_SIZE                 1
129
130 /*****************************  IGMP fields  *********************************/
131 #define NH_FLD_IGMP_VERSION                   (1)
132 #define NH_FLD_IGMP_TYPE                      (NH_FLD_IGMP_VERSION << 1)
133 #define NH_FLD_IGMP_CKSUM                     (NH_FLD_IGMP_VERSION << 2)
134 #define NH_FLD_IGMP_DATA                      (NH_FLD_IGMP_VERSION << 3)
135 #define NH_FLD_IGMP_ALL_FIELDS                ((NH_FLD_IGMP_VERSION << 4) - 1)
136
137 /*****************************  TCP fields  **********************************/
138 #define NH_FLD_TCP_PORT_SRC                   (1)
139 #define NH_FLD_TCP_PORT_DST                   (NH_FLD_TCP_PORT_SRC << 1)
140 #define NH_FLD_TCP_SEQ                        (NH_FLD_TCP_PORT_SRC << 2)
141 #define NH_FLD_TCP_ACK                        (NH_FLD_TCP_PORT_SRC << 3)
142 #define NH_FLD_TCP_OFFSET                     (NH_FLD_TCP_PORT_SRC << 4)
143 #define NH_FLD_TCP_FLAGS                      (NH_FLD_TCP_PORT_SRC << 5)
144 #define NH_FLD_TCP_WINDOW                     (NH_FLD_TCP_PORT_SRC << 6)
145 #define NH_FLD_TCP_CKSUM                      (NH_FLD_TCP_PORT_SRC << 7)
146 #define NH_FLD_TCP_URGPTR                     (NH_FLD_TCP_PORT_SRC << 8)
147 #define NH_FLD_TCP_OPTS                       (NH_FLD_TCP_PORT_SRC << 9)
148 #define NH_FLD_TCP_OPTS_COUNT                 (NH_FLD_TCP_PORT_SRC << 10)
149 #define NH_FLD_TCP_ALL_FIELDS                 ((NH_FLD_TCP_PORT_SRC << 11) - 1)
150
151 #define NH_FLD_TCP_PORT_SIZE                  2
152
153 /*****************************  UDP fields  **********************************/
154 #define NH_FLD_UDP_PORT_SRC                   (1)
155 #define NH_FLD_UDP_PORT_DST                   (NH_FLD_UDP_PORT_SRC << 1)
156 #define NH_FLD_UDP_LEN                        (NH_FLD_UDP_PORT_SRC << 2)
157 #define NH_FLD_UDP_CKSUM                      (NH_FLD_UDP_PORT_SRC << 3)
158 #define NH_FLD_UDP_ALL_FIELDS                 ((NH_FLD_UDP_PORT_SRC << 4) - 1)
159
160 #define NH_FLD_UDP_PORT_SIZE                  2
161
162 /***************************  UDP-lite fields  *******************************/
163 #define NH_FLD_UDP_LITE_PORT_SRC              (1)
164 #define NH_FLD_UDP_LITE_PORT_DST              (NH_FLD_UDP_LITE_PORT_SRC << 1)
165 #define NH_FLD_UDP_LITE_ALL_FIELDS \
166         ((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1)
167
168 #define NH_FLD_UDP_LITE_PORT_SIZE             2
169
170 /***************************  UDP-encap-ESP fields  **************************/
171 #define NH_FLD_UDP_ENC_ESP_PORT_SRC         (1)
172 #define NH_FLD_UDP_ENC_ESP_PORT_DST         (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1)
173 #define NH_FLD_UDP_ENC_ESP_LEN              (NH_FLD_UDP_ENC_ESP_PORT_SRC << 2)
174 #define NH_FLD_UDP_ENC_ESP_CKSUM            (NH_FLD_UDP_ENC_ESP_PORT_SRC << 3)
175 #define NH_FLD_UDP_ENC_ESP_SPI              (NH_FLD_UDP_ENC_ESP_PORT_SRC << 4)
176 #define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM     (NH_FLD_UDP_ENC_ESP_PORT_SRC << 5)
177 #define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \
178         ((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1)
179
180 #define NH_FLD_UDP_ENC_ESP_PORT_SIZE        2
181 #define NH_FLD_UDP_ENC_ESP_SPI_SIZE         4
182
183 /*****************************  SCTP fields  *********************************/
184 #define NH_FLD_SCTP_PORT_SRC                  (1)
185 #define NH_FLD_SCTP_PORT_DST                  (NH_FLD_SCTP_PORT_SRC << 1)
186 #define NH_FLD_SCTP_VER_TAG                   (NH_FLD_SCTP_PORT_SRC << 2)
187 #define NH_FLD_SCTP_CKSUM                     (NH_FLD_SCTP_PORT_SRC << 3)
188 #define NH_FLD_SCTP_ALL_FIELDS                ((NH_FLD_SCTP_PORT_SRC << 4) - 1)
189
190 #define NH_FLD_SCTP_PORT_SIZE                 2
191
192 /*****************************  DCCP fields  *********************************/
193 #define NH_FLD_DCCP_PORT_SRC                  (1)
194 #define NH_FLD_DCCP_PORT_DST                  (NH_FLD_DCCP_PORT_SRC << 1)
195 #define NH_FLD_DCCP_ALL_FIELDS                ((NH_FLD_DCCP_PORT_SRC << 2) - 1)
196
197 #define NH_FLD_DCCP_PORT_SIZE                 2
198
199 /*****************************  IPHC fields  *********************************/
200 #define NH_FLD_IPHC_CID                       (1)
201 #define NH_FLD_IPHC_CID_TYPE                  (NH_FLD_IPHC_CID << 1)
202 #define NH_FLD_IPHC_HCINDEX                   (NH_FLD_IPHC_CID << 2)
203 #define NH_FLD_IPHC_GEN                       (NH_FLD_IPHC_CID << 3)
204 #define NH_FLD_IPHC_D_BIT                     (NH_FLD_IPHC_CID << 4)
205 #define NH_FLD_IPHC_ALL_FIELDS                ((NH_FLD_IPHC_CID << 5) - 1)
206
207 /*****************************  SCTP fields  *********************************/
208 #define NH_FLD_SCTP_CHUNK_DATA_TYPE           (1)
209 #define NH_FLD_SCTP_CHUNK_DATA_FLAGS          (NH_FLD_SCTP_CHUNK_DATA_TYPE << 1)
210 #define NH_FLD_SCTP_CHUNK_DATA_LENGTH         (NH_FLD_SCTP_CHUNK_DATA_TYPE << 2)
211 #define NH_FLD_SCTP_CHUNK_DATA_TSN            (NH_FLD_SCTP_CHUNK_DATA_TYPE << 3)
212 #define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID      (NH_FLD_SCTP_CHUNK_DATA_TYPE << 4)
213 #define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN     (NH_FLD_SCTP_CHUNK_DATA_TYPE << 5)
214 #define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID    (NH_FLD_SCTP_CHUNK_DATA_TYPE << 6)
215 #define NH_FLD_SCTP_CHUNK_DATA_UNORDERED      (NH_FLD_SCTP_CHUNK_DATA_TYPE << 7)
216 #define NH_FLD_SCTP_CHUNK_DATA_BEGINNING      (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8)
217 #define NH_FLD_SCTP_CHUNK_DATA_END            (NH_FLD_SCTP_CHUNK_DATA_TYPE << 9)
218 #define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \
219         ((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1)
220
221 /***************************  L2TPV2 fields  *********************************/
222 #define NH_FLD_L2TPV2_TYPE_BIT                (1)
223 #define NH_FLD_L2TPV2_LENGTH_BIT              (NH_FLD_L2TPV2_TYPE_BIT << 1)
224 #define NH_FLD_L2TPV2_SEQUENCE_BIT            (NH_FLD_L2TPV2_TYPE_BIT << 2)
225 #define NH_FLD_L2TPV2_OFFSET_BIT              (NH_FLD_L2TPV2_TYPE_BIT << 3)
226 #define NH_FLD_L2TPV2_PRIORITY_BIT            (NH_FLD_L2TPV2_TYPE_BIT << 4)
227 #define NH_FLD_L2TPV2_VERSION                 (NH_FLD_L2TPV2_TYPE_BIT << 5)
228 #define NH_FLD_L2TPV2_LEN                     (NH_FLD_L2TPV2_TYPE_BIT << 6)
229 #define NH_FLD_L2TPV2_TUNNEL_ID               (NH_FLD_L2TPV2_TYPE_BIT << 7)
230 #define NH_FLD_L2TPV2_SESSION_ID              (NH_FLD_L2TPV2_TYPE_BIT << 8)
231 #define NH_FLD_L2TPV2_NS                      (NH_FLD_L2TPV2_TYPE_BIT << 9)
232 #define NH_FLD_L2TPV2_NR                      (NH_FLD_L2TPV2_TYPE_BIT << 10)
233 #define NH_FLD_L2TPV2_OFFSET_SIZE             (NH_FLD_L2TPV2_TYPE_BIT << 11)
234 #define NH_FLD_L2TPV2_FIRST_BYTE              (NH_FLD_L2TPV2_TYPE_BIT << 12)
235 #define NH_FLD_L2TPV2_ALL_FIELDS \
236         ((NH_FLD_L2TPV2_TYPE_BIT << 13) - 1)
237
238 /***************************  L2TPV3 fields  *********************************/
239 #define NH_FLD_L2TPV3_CTRL_TYPE_BIT           (1)
240 #define NH_FLD_L2TPV3_CTRL_LENGTH_BIT         (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 1)
241 #define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT       (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 2)
242 #define NH_FLD_L2TPV3_CTRL_VERSION            (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 3)
243 #define NH_FLD_L2TPV3_CTRL_LENGTH             (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 4)
244 #define NH_FLD_L2TPV3_CTRL_CONTROL            (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 5)
245 #define NH_FLD_L2TPV3_CTRL_SENT               (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 6)
246 #define NH_FLD_L2TPV3_CTRL_RECV               (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 7)
247 #define NH_FLD_L2TPV3_CTRL_FIRST_BYTE         (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 8)
248 #define NH_FLD_L2TPV3_CTRL_ALL_FIELDS \
249         ((NH_FLD_L2TPV3_CTRL_TYPE_BIT << 9) - 1)
250
251 #define NH_FLD_L2TPV3_SESS_TYPE_BIT           (1)
252 #define NH_FLD_L2TPV3_SESS_VERSION            (NH_FLD_L2TPV3_SESS_TYPE_BIT << 1)
253 #define NH_FLD_L2TPV3_SESS_ID                 (NH_FLD_L2TPV3_SESS_TYPE_BIT << 2)
254 #define NH_FLD_L2TPV3_SESS_COOKIE             (NH_FLD_L2TPV3_SESS_TYPE_BIT << 3)
255 #define NH_FLD_L2TPV3_SESS_ALL_FIELDS \
256         ((NH_FLD_L2TPV3_SESS_TYPE_BIT << 4) - 1)
257
258 /****************************  PPP fields  ***********************************/
259 #define NH_FLD_PPP_PID                        (1)
260 #define NH_FLD_PPP_COMPRESSED                 (NH_FLD_PPP_PID << 1)
261 #define NH_FLD_PPP_ALL_FIELDS                 ((NH_FLD_PPP_PID << 2) - 1)
262
263 /**************************  PPPoE fields  ***********************************/
264 #define NH_FLD_PPPOE_VER                      (1)
265 #define NH_FLD_PPPOE_TYPE                     (NH_FLD_PPPOE_VER << 1)
266 #define NH_FLD_PPPOE_CODE                     (NH_FLD_PPPOE_VER << 2)
267 #define NH_FLD_PPPOE_SID                      (NH_FLD_PPPOE_VER << 3)
268 #define NH_FLD_PPPOE_LEN                      (NH_FLD_PPPOE_VER << 4)
269 #define NH_FLD_PPPOE_SESSION                  (NH_FLD_PPPOE_VER << 5)
270 #define NH_FLD_PPPOE_PID                      (NH_FLD_PPPOE_VER << 6)
271 #define NH_FLD_PPPOE_ALL_FIELDS               ((NH_FLD_PPPOE_VER << 7) - 1)
272
273 /*************************  PPP-Mux fields  **********************************/
274 #define NH_FLD_PPPMUX_PID                     (1)
275 #define NH_FLD_PPPMUX_CKSUM                   (NH_FLD_PPPMUX_PID << 1)
276 #define NH_FLD_PPPMUX_COMPRESSED              (NH_FLD_PPPMUX_PID << 2)
277 #define NH_FLD_PPPMUX_ALL_FIELDS              ((NH_FLD_PPPMUX_PID << 3) - 1)
278
279 /***********************  PPP-Mux sub-frame fields  **************************/
280 #define NH_FLD_PPPMUX_SUBFRM_PFF            (1)
281 #define NH_FLD_PPPMUX_SUBFRM_LXT            (NH_FLD_PPPMUX_SUBFRM_PFF << 1)
282 #define NH_FLD_PPPMUX_SUBFRM_LEN            (NH_FLD_PPPMUX_SUBFRM_PFF << 2)
283 #define NH_FLD_PPPMUX_SUBFRM_PID            (NH_FLD_PPPMUX_SUBFRM_PFF << 3)
284 #define NH_FLD_PPPMUX_SUBFRM_USE_PID        (NH_FLD_PPPMUX_SUBFRM_PFF << 4)
285 #define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS \
286         ((NH_FLD_PPPMUX_SUBFRM_PFF << 5) - 1)
287
288 /***************************  LLC fields  ************************************/
289 #define NH_FLD_LLC_DSAP                       (1)
290 #define NH_FLD_LLC_SSAP                       (NH_FLD_LLC_DSAP << 1)
291 #define NH_FLD_LLC_CTRL                       (NH_FLD_LLC_DSAP << 2)
292 #define NH_FLD_LLC_ALL_FIELDS                 ((NH_FLD_LLC_DSAP << 3) - 1)
293
294 /***************************  NLPID fields  **********************************/
295 #define NH_FLD_NLPID_NLPID                    (1)
296 #define NH_FLD_NLPID_ALL_FIELDS               ((NH_FLD_NLPID_NLPID << 1) - 1)
297
298 /***************************  SNAP fields  ***********************************/
299 #define NH_FLD_SNAP_OUI                       (1)
300 #define NH_FLD_SNAP_PID                       (NH_FLD_SNAP_OUI << 1)
301 #define NH_FLD_SNAP_ALL_FIELDS                ((NH_FLD_SNAP_OUI << 2) - 1)
302
303 /***************************  LLC SNAP fields  *******************************/
304 #define NH_FLD_LLC_SNAP_TYPE                  (1)
305 #define NH_FLD_LLC_SNAP_ALL_FIELDS            ((NH_FLD_LLC_SNAP_TYPE << 1) - 1)
306
307 #define NH_FLD_ARP_HTYPE                      (1)
308 #define NH_FLD_ARP_PTYPE                      (NH_FLD_ARP_HTYPE << 1)
309 #define NH_FLD_ARP_HLEN                       (NH_FLD_ARP_HTYPE << 2)
310 #define NH_FLD_ARP_PLEN                       (NH_FLD_ARP_HTYPE << 3)
311 #define NH_FLD_ARP_OPER                       (NH_FLD_ARP_HTYPE << 4)
312 #define NH_FLD_ARP_SHA                        (NH_FLD_ARP_HTYPE << 5)
313 #define NH_FLD_ARP_SPA                        (NH_FLD_ARP_HTYPE << 6)
314 #define NH_FLD_ARP_THA                        (NH_FLD_ARP_HTYPE << 7)
315 #define NH_FLD_ARP_TPA                        (NH_FLD_ARP_HTYPE << 8)
316 #define NH_FLD_ARP_ALL_FIELDS                 ((NH_FLD_ARP_HTYPE << 9) - 1)
317
318 /***************************  RFC2684 fields  ********************************/
319 #define NH_FLD_RFC2684_LLC                    (1)
320 #define NH_FLD_RFC2684_NLPID                  (NH_FLD_RFC2684_LLC << 1)
321 #define NH_FLD_RFC2684_OUI                    (NH_FLD_RFC2684_LLC << 2)
322 #define NH_FLD_RFC2684_PID                    (NH_FLD_RFC2684_LLC << 3)
323 #define NH_FLD_RFC2684_VPN_OUI                (NH_FLD_RFC2684_LLC << 4)
324 #define NH_FLD_RFC2684_VPN_IDX                (NH_FLD_RFC2684_LLC << 5)
325 #define NH_FLD_RFC2684_ALL_FIELDS             ((NH_FLD_RFC2684_LLC << 6) - 1)
326
327 /***************************  User defined fields  ***************************/
328 #define NH_FLD_USER_DEFINED_SRCPORT           (1)
329 #define NH_FLD_USER_DEFINED_PCDID             (NH_FLD_USER_DEFINED_SRCPORT << 1)
330 #define NH_FLD_USER_DEFINED_ALL_FIELDS \
331         ((NH_FLD_USER_DEFINED_SRCPORT << 2) - 1)
332
333 /***************************  Payload fields  ********************************/
334 #define NH_FLD_PAYLOAD_BUFFER                 (1)
335 #define NH_FLD_PAYLOAD_SIZE                   (NH_FLD_PAYLOAD_BUFFER << 1)
336 #define NH_FLD_MAX_FRM_SIZE                   (NH_FLD_PAYLOAD_BUFFER << 2)
337 #define NH_FLD_MIN_FRM_SIZE                   (NH_FLD_PAYLOAD_BUFFER << 3)
338 #define NH_FLD_PAYLOAD_TYPE                   (NH_FLD_PAYLOAD_BUFFER << 4)
339 #define NH_FLD_FRAME_SIZE                     (NH_FLD_PAYLOAD_BUFFER << 5)
340 #define NH_FLD_PAYLOAD_ALL_FIELDS             ((NH_FLD_PAYLOAD_BUFFER << 6) - 1)
341
342 /***************************  GRE fields  ************************************/
343 #define NH_FLD_GRE_TYPE                       (1)
344 #define NH_FLD_GRE_ALL_FIELDS                 ((NH_FLD_GRE_TYPE << 1) - 1)
345
346 /***************************  MINENCAP fields  *******************************/
347 #define NH_FLD_MINENCAP_SRC_IP                (1)
348 #define NH_FLD_MINENCAP_DST_IP                (NH_FLD_MINENCAP_SRC_IP << 1)
349 #define NH_FLD_MINENCAP_TYPE                  (NH_FLD_MINENCAP_SRC_IP << 2)
350 #define NH_FLD_MINENCAP_ALL_FIELDS \
351         ((NH_FLD_MINENCAP_SRC_IP << 3) - 1)
352
353 /***************************  IPSEC AH fields  *******************************/
354 #define NH_FLD_IPSEC_AH_SPI                   (1)
355 #define NH_FLD_IPSEC_AH_NH                    (NH_FLD_IPSEC_AH_SPI << 1)
356 #define NH_FLD_IPSEC_AH_ALL_FIELDS            ((NH_FLD_IPSEC_AH_SPI << 2) - 1)
357
358 /***************************  IPSEC ESP fields  ******************************/
359 #define NH_FLD_IPSEC_ESP_SPI                  (1)
360 #define NH_FLD_IPSEC_ESP_SEQUENCE_NUM         (NH_FLD_IPSEC_ESP_SPI << 1)
361 #define NH_FLD_IPSEC_ESP_ALL_FIELDS           ((NH_FLD_IPSEC_ESP_SPI << 2) - 1)
362
363 #define NH_FLD_IPSEC_ESP_SPI_SIZE             4
364
365 /***************************  MPLS fields  ***********************************/
366 #define NH_FLD_MPLS_LABEL_STACK               (1)
367 #define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS \
368         ((NH_FLD_MPLS_LABEL_STACK << 1) - 1)
369
370 /***************************  MACSEC fields  *********************************/
371 #define NH_FLD_MACSEC_SECTAG                  (1)
372 #define NH_FLD_MACSEC_ALL_FIELDS              ((NH_FLD_MACSEC_SECTAG << 1) - 1)
373
374 /***************************  GTP fields  ************************************/
375 #define NH_FLD_GTP_TEID                       (1)
376
377 /* Protocol options */
378
379 /* Ethernet options */
380 #define NH_OPT_ETH_BROADCAST                    1
381 #define NH_OPT_ETH_MULTICAST                    2
382 #define NH_OPT_ETH_UNICAST                      3
383 #define NH_OPT_ETH_BPDU                         4
384
385 #define NH_ETH_IS_MULTICAST_ADDR(addr) (addr[0] & 0x01)
386 /* also applicable for broadcast */
387
388 /* VLAN options */
389 #define NH_OPT_VLAN_CFI                         1
390
391 /* IPV4 options */
392 #define NH_OPT_IPV4_UNICAST                     1
393 #define NH_OPT_IPV4_MULTICAST                   2
394 #define NH_OPT_IPV4_BROADCAST                   3
395 #define NH_OPT_IPV4_OPTION                      4
396 #define NH_OPT_IPV4_FRAG                        5
397 #define NH_OPT_IPV4_INITIAL_FRAG                6
398
399 /* IPV6 options */
400 #define NH_OPT_IPV6_UNICAST                     1
401 #define NH_OPT_IPV6_MULTICAST                   2
402 #define NH_OPT_IPV6_OPTION                      3
403 #define NH_OPT_IPV6_FRAG                        4
404 #define NH_OPT_IPV6_INITIAL_FRAG                5
405
406 /* General IP options (may be used for any version) */
407 #define NH_OPT_IP_FRAG                          1
408 #define NH_OPT_IP_INITIAL_FRAG                  2
409 #define NH_OPT_IP_OPTION                        3
410
411 /* Minenc. options */
412 #define NH_OPT_MINENCAP_SRC_ADDR_PRESENT        1
413
414 /* GRE. options */
415 #define NH_OPT_GRE_ROUTING_PRESENT              1
416
417 /* TCP options */
418 #define NH_OPT_TCP_OPTIONS                      1
419 #define NH_OPT_TCP_CONTROL_HIGH_BITS            2
420 #define NH_OPT_TCP_CONTROL_LOW_BITS             3
421
422 /* CAPWAP options */
423 #define NH_OPT_CAPWAP_DTLS                      1
424
425 enum net_prot {
426         NET_PROT_NONE = 0,
427         NET_PROT_PAYLOAD,
428         NET_PROT_ETH,
429         NET_PROT_VLAN,
430         NET_PROT_IPV4,
431         NET_PROT_IPV6,
432         NET_PROT_IP,
433         NET_PROT_TCP,
434         NET_PROT_UDP,
435         NET_PROT_UDP_LITE,
436         NET_PROT_IPHC,
437         NET_PROT_SCTP,
438         NET_PROT_SCTP_CHUNK_DATA,
439         NET_PROT_PPPOE,
440         NET_PROT_PPP,
441         NET_PROT_PPPMUX,
442         NET_PROT_PPPMUX_SUBFRM,
443         NET_PROT_L2TPV2,
444         NET_PROT_L2TPV3_CTRL,
445         NET_PROT_L2TPV3_SESS,
446         NET_PROT_LLC,
447         NET_PROT_LLC_SNAP,
448         NET_PROT_NLPID,
449         NET_PROT_SNAP,
450         NET_PROT_MPLS,
451         NET_PROT_IPSEC_AH,
452         NET_PROT_IPSEC_ESP,
453         NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
454         NET_PROT_MACSEC,
455         NET_PROT_GRE,
456         NET_PROT_MINENCAP,
457         NET_PROT_DCCP,
458         NET_PROT_ICMP,
459         NET_PROT_IGMP,
460         NET_PROT_ARP,
461         NET_PROT_CAPWAP_DATA,
462         NET_PROT_CAPWAP_CTRL,
463         NET_PROT_RFC2684,
464         NET_PROT_ICMPV6,
465         NET_PROT_FCOE,
466         NET_PROT_FIP,
467         NET_PROT_ISCSI,
468         NET_PROT_GTP,
469         NET_PROT_USER_DEFINED_L2,
470         NET_PROT_USER_DEFINED_L3,
471         NET_PROT_USER_DEFINED_L4,
472         NET_PROT_USER_DEFINED_L5,
473         NET_PROT_USER_DEFINED_SHIM1,
474         NET_PROT_USER_DEFINED_SHIM2,
475
476         NET_PROT_DUMMY_LAST
477 };
478
479 /*! IEEE8021.Q */
480 #define NH_IEEE8021Q_ETYPE  0x8100
481 #define NH_IEEE8021Q_HDR(etype, pcp, dei, vlan_id)      \
482             ((((uint32_t)(etype & 0xFFFF)) << 16) |       \
483             (((uint32_t)(pcp & 0x07)) << 13) |          \
484             (((uint32_t)(dei & 0x01)) << 12) |          \
485             (((uint32_t)(vlan_id & 0xFFF))))
486
487 #endif /* __FSL_NET_H */