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