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