1
2
3
4 #ifndef __FSL_DPKG_H_
5 #define __FSL_DPKG_H_
6
7 #include <linux/types.h>
8
9
10
11
12
13
14
15
16
17
18 #define DPKG_NUM_OF_MASKS 4
19
20
21
22 #define DPKG_MAX_NUM_OF_EXTRACTS 10
23
24
25
26
27
28
29
30 enum dpkg_extract_from_hdr_type {
31 DPKG_FROM_HDR = 0,
32 DPKG_FROM_FIELD = 1,
33 DPKG_FULL_FIELD = 2
34 };
35
36
37
38
39
40
41
42
43
44 enum dpkg_extract_type {
45 DPKG_EXTRACT_FROM_HDR = 0,
46 DPKG_EXTRACT_FROM_DATA = 1,
47 DPKG_EXTRACT_FROM_PARSE = 3
48 };
49
50
51
52
53
54
55 struct dpkg_mask {
56 u8 mask;
57 u8 offset;
58 };
59
60
61
62
63 #define NH_FLD_ETH_DA BIT(0)
64 #define NH_FLD_ETH_SA BIT(1)
65 #define NH_FLD_ETH_LENGTH BIT(2)
66 #define NH_FLD_ETH_TYPE BIT(3)
67 #define NH_FLD_ETH_FINAL_CKSUM BIT(4)
68 #define NH_FLD_ETH_PADDING BIT(5)
69 #define NH_FLD_ETH_ALL_FIELDS (BIT(6) - 1)
70
71
72 #define NH_FLD_VLAN_VPRI BIT(0)
73 #define NH_FLD_VLAN_CFI BIT(1)
74 #define NH_FLD_VLAN_VID BIT(2)
75 #define NH_FLD_VLAN_LENGTH BIT(3)
76 #define NH_FLD_VLAN_TYPE BIT(4)
77 #define NH_FLD_VLAN_ALL_FIELDS (BIT(5) - 1)
78
79 #define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \
80 NH_FLD_VLAN_CFI | \
81 NH_FLD_VLAN_VID)
82
83
84 #define NH_FLD_IP_VER BIT(0)
85 #define NH_FLD_IP_DSCP BIT(2)
86 #define NH_FLD_IP_ECN BIT(3)
87 #define NH_FLD_IP_PROTO BIT(4)
88 #define NH_FLD_IP_SRC BIT(5)
89 #define NH_FLD_IP_DST BIT(6)
90 #define NH_FLD_IP_TOS_TC BIT(7)
91 #define NH_FLD_IP_ID BIT(8)
92 #define NH_FLD_IP_ALL_FIELDS (BIT(9) - 1)
93
94
95 #define NH_FLD_IPV4_VER BIT(0)
96 #define NH_FLD_IPV4_HDR_LEN BIT(1)
97 #define NH_FLD_IPV4_TOS BIT(2)
98 #define NH_FLD_IPV4_TOTAL_LEN BIT(3)
99 #define NH_FLD_IPV4_ID BIT(4)
100 #define NH_FLD_IPV4_FLAG_D BIT(5)
101 #define NH_FLD_IPV4_FLAG_M BIT(6)
102 #define NH_FLD_IPV4_OFFSET BIT(7)
103 #define NH_FLD_IPV4_TTL BIT(8)
104 #define NH_FLD_IPV4_PROTO BIT(9)
105 #define NH_FLD_IPV4_CKSUM BIT(10)
106 #define NH_FLD_IPV4_SRC_IP BIT(11)
107 #define NH_FLD_IPV4_DST_IP BIT(12)
108 #define NH_FLD_IPV4_OPTS BIT(13)
109 #define NH_FLD_IPV4_OPTS_COUNT BIT(14)
110 #define NH_FLD_IPV4_ALL_FIELDS (BIT(15) - 1)
111
112
113 #define NH_FLD_IPV6_VER BIT(0)
114 #define NH_FLD_IPV6_TC BIT(1)
115 #define NH_FLD_IPV6_SRC_IP BIT(2)
116 #define NH_FLD_IPV6_DST_IP BIT(3)
117 #define NH_FLD_IPV6_NEXT_HDR BIT(4)
118 #define NH_FLD_IPV6_FL BIT(5)
119 #define NH_FLD_IPV6_HOP_LIMIT BIT(6)
120 #define NH_FLD_IPV6_ID BIT(7)
121 #define NH_FLD_IPV6_ALL_FIELDS (BIT(8) - 1)
122
123
124 #define NH_FLD_ICMP_TYPE BIT(0)
125 #define NH_FLD_ICMP_CODE BIT(1)
126 #define NH_FLD_ICMP_CKSUM BIT(2)
127 #define NH_FLD_ICMP_ID BIT(3)
128 #define NH_FLD_ICMP_SQ_NUM BIT(4)
129 #define NH_FLD_ICMP_ALL_FIELDS (BIT(5) - 1)
130
131
132 #define NH_FLD_IGMP_VERSION BIT(0)
133 #define NH_FLD_IGMP_TYPE BIT(1)
134 #define NH_FLD_IGMP_CKSUM BIT(2)
135 #define NH_FLD_IGMP_DATA BIT(3)
136 #define NH_FLD_IGMP_ALL_FIELDS (BIT(4) - 1)
137
138
139 #define NH_FLD_TCP_PORT_SRC BIT(0)
140 #define NH_FLD_TCP_PORT_DST BIT(1)
141 #define NH_FLD_TCP_SEQ BIT(2)
142 #define NH_FLD_TCP_ACK BIT(3)
143 #define NH_FLD_TCP_OFFSET BIT(4)
144 #define NH_FLD_TCP_FLAGS BIT(5)
145 #define NH_FLD_TCP_WINDOW BIT(6)
146 #define NH_FLD_TCP_CKSUM BIT(7)
147 #define NH_FLD_TCP_URGPTR BIT(8)
148 #define NH_FLD_TCP_OPTS BIT(9)
149 #define NH_FLD_TCP_OPTS_COUNT BIT(10)
150 #define NH_FLD_TCP_ALL_FIELDS (BIT(11) - 1)
151
152
153 #define NH_FLD_UDP_PORT_SRC BIT(0)
154 #define NH_FLD_UDP_PORT_DST BIT(1)
155 #define NH_FLD_UDP_LEN BIT(2)
156 #define NH_FLD_UDP_CKSUM BIT(3)
157 #define NH_FLD_UDP_ALL_FIELDS (BIT(4) - 1)
158
159
160 #define NH_FLD_UDP_LITE_PORT_SRC BIT(0)
161 #define NH_FLD_UDP_LITE_PORT_DST BIT(1)
162 #define NH_FLD_UDP_LITE_ALL_FIELDS (BIT(2) - 1)
163
164
165 #define NH_FLD_UDP_ENC_ESP_PORT_SRC BIT(0)
166 #define NH_FLD_UDP_ENC_ESP_PORT_DST BIT(1)
167 #define NH_FLD_UDP_ENC_ESP_LEN BIT(2)
168 #define NH_FLD_UDP_ENC_ESP_CKSUM BIT(3)
169 #define NH_FLD_UDP_ENC_ESP_SPI BIT(4)
170 #define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM BIT(5)
171 #define NH_FLD_UDP_ENC_ESP_ALL_FIELDS (BIT(6) - 1)
172
173
174 #define NH_FLD_SCTP_PORT_SRC BIT(0)
175 #define NH_FLD_SCTP_PORT_DST BIT(1)
176 #define NH_FLD_SCTP_VER_TAG BIT(2)
177 #define NH_FLD_SCTP_CKSUM BIT(3)
178 #define NH_FLD_SCTP_ALL_FIELDS (BIT(4) - 1)
179
180
181 #define NH_FLD_DCCP_PORT_SRC BIT(0)
182 #define NH_FLD_DCCP_PORT_DST BIT(1)
183 #define NH_FLD_DCCP_ALL_FIELDS (BIT(2) - 1)
184
185
186 #define NH_FLD_IPHC_CID BIT(0)
187 #define NH_FLD_IPHC_CID_TYPE BIT(1)
188 #define NH_FLD_IPHC_HCINDEX BIT(2)
189 #define NH_FLD_IPHC_GEN BIT(3)
190 #define NH_FLD_IPHC_D_BIT BIT(4)
191 #define NH_FLD_IPHC_ALL_FIELDS (BIT(5) - 1)
192
193
194 #define NH_FLD_SCTP_CHUNK_DATA_TYPE BIT(0)
195 #define NH_FLD_SCTP_CHUNK_DATA_FLAGS BIT(1)
196 #define NH_FLD_SCTP_CHUNK_DATA_LENGTH BIT(2)
197 #define NH_FLD_SCTP_CHUNK_DATA_TSN BIT(3)
198 #define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID BIT(4)
199 #define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN BIT(5)
200 #define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID BIT(6)
201 #define NH_FLD_SCTP_CHUNK_DATA_UNORDERED BIT(7)
202 #define NH_FLD_SCTP_CHUNK_DATA_BEGGINING BIT(8)
203 #define NH_FLD_SCTP_CHUNK_DATA_END BIT(9)
204 #define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS (BIT(10) - 1)
205
206
207 #define NH_FLD_L2TPV2_TYPE_BIT BIT(0)
208 #define NH_FLD_L2TPV2_LENGTH_BIT BIT(1)
209 #define NH_FLD_L2TPV2_SEQUENCE_BIT BIT(2)
210 #define NH_FLD_L2TPV2_OFFSET_BIT BIT(3)
211 #define NH_FLD_L2TPV2_PRIORITY_BIT BIT(4)
212 #define NH_FLD_L2TPV2_VERSION BIT(5)
213 #define NH_FLD_L2TPV2_LEN BIT(6)
214 #define NH_FLD_L2TPV2_TUNNEL_ID BIT(7)
215 #define NH_FLD_L2TPV2_SESSION_ID BIT(8)
216 #define NH_FLD_L2TPV2_NS BIT(9)
217 #define NH_FLD_L2TPV2_NR BIT(10)
218 #define NH_FLD_L2TPV2_OFFSET_SIZE BIT(11)
219 #define NH_FLD_L2TPV2_FIRST_BYTE BIT(12)
220 #define NH_FLD_L2TPV2_ALL_FIELDS (BIT(13) - 1)
221
222
223 #define NH_FLD_L2TPV3_CTRL_TYPE_BIT BIT(0)
224 #define NH_FLD_L2TPV3_CTRL_LENGTH_BIT BIT(1)
225 #define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT BIT(2)
226 #define NH_FLD_L2TPV3_CTRL_VERSION BIT(3)
227 #define NH_FLD_L2TPV3_CTRL_LENGTH BIT(4)
228 #define NH_FLD_L2TPV3_CTRL_CONTROL BIT(5)
229 #define NH_FLD_L2TPV3_CTRL_SENT BIT(6)
230 #define NH_FLD_L2TPV3_CTRL_RECV BIT(7)
231 #define NH_FLD_L2TPV3_CTRL_FIRST_BYTE BIT(8)
232 #define NH_FLD_L2TPV3_CTRL_ALL_FIELDS (BIT(9) - 1)
233
234 #define NH_FLD_L2TPV3_SESS_TYPE_BIT BIT(0)
235 #define NH_FLD_L2TPV3_SESS_VERSION BIT(1)
236 #define NH_FLD_L2TPV3_SESS_ID BIT(2)
237 #define NH_FLD_L2TPV3_SESS_COOKIE BIT(3)
238 #define NH_FLD_L2TPV3_SESS_ALL_FIELDS (BIT(4) - 1)
239
240
241 #define NH_FLD_PPP_PID BIT(0)
242 #define NH_FLD_PPP_COMPRESSED BIT(1)
243 #define NH_FLD_PPP_ALL_FIELDS (BIT(2) - 1)
244
245
246 #define NH_FLD_PPPOE_VER BIT(0)
247 #define NH_FLD_PPPOE_TYPE BIT(1)
248 #define NH_FLD_PPPOE_CODE BIT(2)
249 #define NH_FLD_PPPOE_SID BIT(3)
250 #define NH_FLD_PPPOE_LEN BIT(4)
251 #define NH_FLD_PPPOE_SESSION BIT(5)
252 #define NH_FLD_PPPOE_PID BIT(6)
253 #define NH_FLD_PPPOE_ALL_FIELDS (BIT(7) - 1)
254
255
256 #define NH_FLD_PPPMUX_PID BIT(0)
257 #define NH_FLD_PPPMUX_CKSUM BIT(1)
258 #define NH_FLD_PPPMUX_COMPRESSED BIT(2)
259 #define NH_FLD_PPPMUX_ALL_FIELDS (BIT(3) - 1)
260
261
262 #define NH_FLD_PPPMUX_SUBFRM_PFF BIT(0)
263 #define NH_FLD_PPPMUX_SUBFRM_LXT BIT(1)
264 #define NH_FLD_PPPMUX_SUBFRM_LEN BIT(2)
265 #define NH_FLD_PPPMUX_SUBFRM_PID BIT(3)
266 #define NH_FLD_PPPMUX_SUBFRM_USE_PID BIT(4)
267 #define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS (BIT(5) - 1)
268
269
270 #define NH_FLD_LLC_DSAP BIT(0)
271 #define NH_FLD_LLC_SSAP BIT(1)
272 #define NH_FLD_LLC_CTRL BIT(2)
273 #define NH_FLD_LLC_ALL_FIELDS (BIT(3) - 1)
274
275
276 #define NH_FLD_NLPID_NLPID BIT(0)
277 #define NH_FLD_NLPID_ALL_FIELDS (BIT(1) - 1)
278
279
280 #define NH_FLD_SNAP_OUI BIT(0)
281 #define NH_FLD_SNAP_PID BIT(1)
282 #define NH_FLD_SNAP_ALL_FIELDS (BIT(2) - 1)
283
284
285 #define NH_FLD_LLC_SNAP_TYPE BIT(0)
286 #define NH_FLD_LLC_SNAP_ALL_FIELDS (BIT(1) - 1)
287
288
289 #define NH_FLD_ARP_HTYPE BIT(0)
290 #define NH_FLD_ARP_PTYPE BIT(1)
291 #define NH_FLD_ARP_HLEN BIT(2)
292 #define NH_FLD_ARP_PLEN BIT(3)
293 #define NH_FLD_ARP_OPER BIT(4)
294 #define NH_FLD_ARP_SHA BIT(5)
295 #define NH_FLD_ARP_SPA BIT(6)
296 #define NH_FLD_ARP_THA BIT(7)
297 #define NH_FLD_ARP_TPA BIT(8)
298 #define NH_FLD_ARP_ALL_FIELDS (BIT(9) - 1)
299
300
301 #define NH_FLD_RFC2684_LLC BIT(0)
302 #define NH_FLD_RFC2684_NLPID BIT(1)
303 #define NH_FLD_RFC2684_OUI BIT(2)
304 #define NH_FLD_RFC2684_PID BIT(3)
305 #define NH_FLD_RFC2684_VPN_OUI BIT(4)
306 #define NH_FLD_RFC2684_VPN_IDX BIT(5)
307 #define NH_FLD_RFC2684_ALL_FIELDS (BIT(6) - 1)
308
309
310 #define NH_FLD_USER_DEFINED_SRCPORT BIT(0)
311 #define NH_FLD_USER_DEFINED_PCDID BIT(1)
312 #define NH_FLD_USER_DEFINED_ALL_FIELDS (BIT(2) - 1)
313
314
315 #define NH_FLD_PAYLOAD_BUFFER BIT(0)
316 #define NH_FLD_PAYLOAD_SIZE BIT(1)
317 #define NH_FLD_MAX_FRM_SIZE BIT(2)
318 #define NH_FLD_MIN_FRM_SIZE BIT(3)
319 #define NH_FLD_PAYLOAD_TYPE BIT(4)
320 #define NH_FLD_FRAME_SIZE BIT(5)
321 #define NH_FLD_PAYLOAD_ALL_FIELDS (BIT(6) - 1)
322
323
324 #define NH_FLD_GRE_TYPE BIT(0)
325 #define NH_FLD_GRE_ALL_FIELDS (BIT(1) - 1)
326
327
328 #define NH_FLD_MINENCAP_SRC_IP BIT(0)
329 #define NH_FLD_MINENCAP_DST_IP BIT(1)
330 #define NH_FLD_MINENCAP_TYPE BIT(2)
331 #define NH_FLD_MINENCAP_ALL_FIELDS (BIT(3) - 1)
332
333
334 #define NH_FLD_IPSEC_AH_SPI BIT(0)
335 #define NH_FLD_IPSEC_AH_NH BIT(1)
336 #define NH_FLD_IPSEC_AH_ALL_FIELDS (BIT(2) - 1)
337
338
339 #define NH_FLD_IPSEC_ESP_SPI BIT(0)
340 #define NH_FLD_IPSEC_ESP_SEQUENCE_NUM BIT(1)
341 #define NH_FLD_IPSEC_ESP_ALL_FIELDS (BIT(2) - 1)
342
343
344 #define NH_FLD_MPLS_LABEL_STACK BIT(0)
345 #define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS (BIT(1) - 1)
346
347
348 #define NH_FLD_MACSEC_SECTAG BIT(0)
349 #define NH_FLD_MACSEC_ALL_FIELDS (BIT(1) - 1)
350
351
352 #define NH_FLD_GTP_TEID BIT(0)
353
354
355 enum net_prot {
356 NET_PROT_NONE = 0,
357 NET_PROT_PAYLOAD,
358 NET_PROT_ETH,
359 NET_PROT_VLAN,
360 NET_PROT_IPV4,
361 NET_PROT_IPV6,
362 NET_PROT_IP,
363 NET_PROT_TCP,
364 NET_PROT_UDP,
365 NET_PROT_UDP_LITE,
366 NET_PROT_IPHC,
367 NET_PROT_SCTP,
368 NET_PROT_SCTP_CHUNK_DATA,
369 NET_PROT_PPPOE,
370 NET_PROT_PPP,
371 NET_PROT_PPPMUX,
372 NET_PROT_PPPMUX_SUBFRM,
373 NET_PROT_L2TPV2,
374 NET_PROT_L2TPV3_CTRL,
375 NET_PROT_L2TPV3_SESS,
376 NET_PROT_LLC,
377 NET_PROT_LLC_SNAP,
378 NET_PROT_NLPID,
379 NET_PROT_SNAP,
380 NET_PROT_MPLS,
381 NET_PROT_IPSEC_AH,
382 NET_PROT_IPSEC_ESP,
383 NET_PROT_UDP_ENC_ESP,
384 NET_PROT_MACSEC,
385 NET_PROT_GRE,
386 NET_PROT_MINENCAP,
387 NET_PROT_DCCP,
388 NET_PROT_ICMP,
389 NET_PROT_IGMP,
390 NET_PROT_ARP,
391 NET_PROT_CAPWAP_DATA,
392 NET_PROT_CAPWAP_CTRL,
393 NET_PROT_RFC2684,
394 NET_PROT_ICMPV6,
395 NET_PROT_FCOE,
396 NET_PROT_FIP,
397 NET_PROT_ISCSI,
398 NET_PROT_GTP,
399 NET_PROT_USER_DEFINED_L2,
400 NET_PROT_USER_DEFINED_L3,
401 NET_PROT_USER_DEFINED_L4,
402 NET_PROT_USER_DEFINED_L5,
403 NET_PROT_USER_DEFINED_SHIM1,
404 NET_PROT_USER_DEFINED_SHIM2,
405
406 NET_PROT_DUMMY_LAST
407 };
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444 struct dpkg_extract {
445 enum dpkg_extract_type type;
446 union {
447 struct {
448 enum net_prot prot;
449 enum dpkg_extract_from_hdr_type type;
450 u32 field;
451 u8 size;
452 u8 offset;
453 u8 hdr_index;
454 } from_hdr;
455 struct {
456 u8 size;
457 u8 offset;
458 } from_data;
459 struct {
460 u8 size;
461 u8 offset;
462 } from_parse;
463 } extract;
464
465 u8 num_of_byte_masks;
466 struct dpkg_mask masks[DPKG_NUM_OF_MASKS];
467 };
468
469
470
471
472
473
474
475 struct dpkg_profile_cfg {
476 u8 num_extracts;
477 struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
478 };
479
480 #endif