Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / pkt_cls.h
blob3c842edff388c90ef76bab969322cddfa7e076d1
1 #ifndef __LINUX_PKT_CLS_H
2 #define __LINUX_PKT_CLS_H
4 #include <linux/types.h>
5 #include <linux/pkt_sched.h>
7 /* I think i could have done better macros ; for now this is stolen from
8 * some arch/mips code - jhs
9 */
10 #define _TC_MAKE32(x) ((x))
12 #define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
13 #define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
14 #define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
15 #define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
17 /* verdict bit breakdown
19 bit 0: when set -> this packet has been munged already
21 bit 1: when set -> It is ok to munge this packet
23 bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
24 assume loop
26 bit 6,7: Where this packet was last seen
27 0: Above the transmit example at the socket level
28 1: on the Ingress
29 2: on the Egress
31 bit 8: when set --> Request not to classify on ingress.
33 bits 9,10,11: redirect counter - redirect TTL. Loop avoidance
36 * */
38 #define TC_MUNGED _TC_MAKEMASK1(0)
39 #define SET_TC_MUNGED(v) ( TC_MUNGED | (v & ~TC_MUNGED))
40 #define CLR_TC_MUNGED(v) ( v & ~TC_MUNGED)
42 #define TC_OK2MUNGE _TC_MAKEMASK1(1)
43 #define SET_TC_OK2MUNGE(v) ( TC_OK2MUNGE | (v & ~TC_OK2MUNGE))
44 #define CLR_TC_OK2MUNGE(v) ( v & ~TC_OK2MUNGE)
46 #define S_TC_VERD _TC_MAKE32(2)
47 #define M_TC_VERD _TC_MAKEMASK(4,S_TC_VERD)
48 #define G_TC_VERD(x) _TC_GETVALUE(x,S_TC_VERD,M_TC_VERD)
49 #define V_TC_VERD(x) _TC_MAKEVALUE(x,S_TC_VERD)
50 #define SET_TC_VERD(v,n) ((V_TC_VERD(n)) | (v & ~M_TC_VERD))
52 #define S_TC_FROM _TC_MAKE32(6)
53 #define M_TC_FROM _TC_MAKEMASK(2,S_TC_FROM)
54 #define G_TC_FROM(x) _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
55 #define V_TC_FROM(x) _TC_MAKEVALUE(x,S_TC_FROM)
56 #define SET_TC_FROM(v,n) ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
57 #define AT_STACK 0x0
58 #define AT_INGRESS 0x1
59 #define AT_EGRESS 0x2
61 #define TC_NCLS _TC_MAKEMASK1(8)
62 #define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
63 #define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
65 #define S_TC_RTTL _TC_MAKE32(9)
66 #define M_TC_RTTL _TC_MAKEMASK(3,S_TC_RTTL)
67 #define G_TC_RTTL(x) _TC_GETVALUE(x,S_TC_RTTL,M_TC_RTTL)
68 #define V_TC_RTTL(x) _TC_MAKEVALUE(x,S_TC_RTTL)
69 #define SET_TC_RTTL(v,n) ((V_TC_RTTL(n)) | (v & ~M_TC_RTTL))
71 #define S_TC_AT _TC_MAKE32(12)
72 #define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
73 #define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
74 #define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT)
75 #define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
77 /* Action attributes */
78 enum
80 TCA_ACT_UNSPEC,
81 TCA_ACT_KIND,
82 TCA_ACT_OPTIONS,
83 TCA_ACT_INDEX,
84 TCA_ACT_STATS,
85 __TCA_ACT_MAX
88 #define TCA_ACT_MAX __TCA_ACT_MAX
89 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
90 #define TCA_ACT_MAX_PRIO 32
91 #define TCA_ACT_BIND 1
92 #define TCA_ACT_NOBIND 0
93 #define TCA_ACT_UNBIND 1
94 #define TCA_ACT_NOUNBIND 0
95 #define TCA_ACT_REPLACE 1
96 #define TCA_ACT_NOREPLACE 0
97 #define MAX_REC_LOOP 4
98 #define MAX_RED_LOOP 4
100 #define TC_ACT_UNSPEC (-1)
101 #define TC_ACT_OK 0
102 #define TC_ACT_RECLASSIFY 1
103 #define TC_ACT_SHOT 2
104 #define TC_ACT_PIPE 3
105 #define TC_ACT_STOLEN 4
106 #define TC_ACT_QUEUED 5
107 #define TC_ACT_REPEAT 6
108 #define TC_ACT_JUMP 0x10000000
110 /* Action type identifiers*/
111 enum
113 TCA_ID_UNSPEC=0,
114 TCA_ID_POLICE=1,
115 /* other actions go here */
116 __TCA_ID_MAX=255
119 #define TCA_ID_MAX __TCA_ID_MAX
121 struct tc_police
123 __u32 index;
124 int action;
125 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
126 #define TC_POLICE_OK TC_ACT_OK
127 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
128 #define TC_POLICE_SHOT TC_ACT_SHOT
129 #define TC_POLICE_PIPE TC_ACT_PIPE
131 __u32 limit;
132 __u32 burst;
133 __u32 mtu;
134 struct tc_ratespec rate;
135 struct tc_ratespec peakrate;
136 int refcnt;
137 int bindcnt;
138 __u32 capab;
141 struct tcf_t
143 __u64 install;
144 __u64 lastuse;
145 __u64 expires;
148 struct tc_cnt
150 int refcnt;
151 int bindcnt;
154 #define tc_gen \
155 __u32 index; \
156 __u32 capab; \
157 int action; \
158 int refcnt; \
159 int bindcnt
161 enum
163 TCA_POLICE_UNSPEC,
164 TCA_POLICE_TBF,
165 TCA_POLICE_RATE,
166 TCA_POLICE_PEAKRATE,
167 TCA_POLICE_AVRATE,
168 TCA_POLICE_RESULT,
169 __TCA_POLICE_MAX
170 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
173 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
175 /* U32 filters */
177 #define TC_U32_HTID(h) ((h)&0xFFF00000)
178 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
179 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
180 #define TC_U32_NODE(h) ((h)&0xFFF)
181 #define TC_U32_KEY(h) ((h)&0xFFFFF)
182 #define TC_U32_UNSPEC 0
183 #define TC_U32_ROOT (0xFFF00000)
185 enum
187 TCA_U32_UNSPEC,
188 TCA_U32_CLASSID,
189 TCA_U32_HASH,
190 TCA_U32_LINK,
191 TCA_U32_DIVISOR,
192 TCA_U32_SEL,
193 TCA_U32_POLICE,
194 TCA_U32_ACT,
195 TCA_U32_INDEV,
196 TCA_U32_PCNT,
197 TCA_U32_MARK,
198 __TCA_U32_MAX
201 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
203 struct tc_u32_key
205 __be32 mask;
206 __be32 val;
207 int off;
208 int offmask;
211 struct tc_u32_sel
213 unsigned char flags;
214 unsigned char offshift;
215 unsigned char nkeys;
217 __be16 offmask;
218 __u16 off;
219 short offoff;
221 short hoff;
222 __be32 hmask;
223 struct tc_u32_key keys[0];
226 struct tc_u32_mark
228 __u32 val;
229 __u32 mask;
230 __u32 success;
233 struct tc_u32_pcnt
235 __u64 rcnt;
236 __u64 rhit;
237 __u64 kcnts[0];
240 /* Flags */
242 #define TC_U32_TERMINAL 1
243 #define TC_U32_OFFSET 2
244 #define TC_U32_VAROFFSET 4
245 #define TC_U32_EAT 8
247 #define TC_U32_MAXDEPTH 8
250 /* RSVP filter */
252 enum
254 TCA_RSVP_UNSPEC,
255 TCA_RSVP_CLASSID,
256 TCA_RSVP_DST,
257 TCA_RSVP_SRC,
258 TCA_RSVP_PINFO,
259 TCA_RSVP_POLICE,
260 TCA_RSVP_ACT,
261 __TCA_RSVP_MAX
264 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
266 struct tc_rsvp_gpi
268 __u32 key;
269 __u32 mask;
270 int offset;
273 struct tc_rsvp_pinfo
275 struct tc_rsvp_gpi dpi;
276 struct tc_rsvp_gpi spi;
277 __u8 protocol;
278 __u8 tunnelid;
279 __u8 tunnelhdr;
280 __u8 pad;
283 /* ROUTE filter */
285 enum
287 TCA_ROUTE4_UNSPEC,
288 TCA_ROUTE4_CLASSID,
289 TCA_ROUTE4_TO,
290 TCA_ROUTE4_FROM,
291 TCA_ROUTE4_IIF,
292 TCA_ROUTE4_POLICE,
293 TCA_ROUTE4_ACT,
294 __TCA_ROUTE4_MAX
297 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
300 /* FW filter */
302 enum
304 TCA_FW_UNSPEC,
305 TCA_FW_CLASSID,
306 TCA_FW_POLICE,
307 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
308 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
309 TCA_FW_MASK,
310 __TCA_FW_MAX
313 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
315 /* TC index filter */
317 enum
319 TCA_TCINDEX_UNSPEC,
320 TCA_TCINDEX_HASH,
321 TCA_TCINDEX_MASK,
322 TCA_TCINDEX_SHIFT,
323 TCA_TCINDEX_FALL_THROUGH,
324 TCA_TCINDEX_CLASSID,
325 TCA_TCINDEX_POLICE,
326 TCA_TCINDEX_ACT,
327 __TCA_TCINDEX_MAX
330 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
332 /* Flow filter */
334 enum
336 FLOW_KEY_SRC,
337 FLOW_KEY_DST,
338 FLOW_KEY_PROTO,
339 FLOW_KEY_PROTO_SRC,
340 FLOW_KEY_PROTO_DST,
341 FLOW_KEY_IIF,
342 FLOW_KEY_PRIORITY,
343 FLOW_KEY_MARK,
344 FLOW_KEY_NFCT,
345 FLOW_KEY_NFCT_SRC,
346 FLOW_KEY_NFCT_DST,
347 FLOW_KEY_NFCT_PROTO_SRC,
348 FLOW_KEY_NFCT_PROTO_DST,
349 FLOW_KEY_RTCLASSID,
350 FLOW_KEY_SKUID,
351 FLOW_KEY_SKGID,
352 FLOW_KEY_VLAN_TAG,
353 __FLOW_KEY_MAX,
356 #define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
358 enum
360 FLOW_MODE_MAP,
361 FLOW_MODE_HASH,
364 enum
366 TCA_FLOW_UNSPEC,
367 TCA_FLOW_KEYS,
368 TCA_FLOW_MODE,
369 TCA_FLOW_BASECLASS,
370 TCA_FLOW_RSHIFT,
371 TCA_FLOW_ADDEND,
372 TCA_FLOW_MASK,
373 TCA_FLOW_XOR,
374 TCA_FLOW_DIVISOR,
375 TCA_FLOW_ACT,
376 TCA_FLOW_POLICE,
377 TCA_FLOW_EMATCHES,
378 TCA_FLOW_PERTURB,
379 __TCA_FLOW_MAX
382 #define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
384 /* Basic filter */
386 enum
388 TCA_BASIC_UNSPEC,
389 TCA_BASIC_CLASSID,
390 TCA_BASIC_EMATCHES,
391 TCA_BASIC_ACT,
392 TCA_BASIC_POLICE,
393 __TCA_BASIC_MAX
396 #define TCA_BASIC_MAX (__TCA_BASIC_MAX - 1)
399 /* Cgroup classifier */
401 enum
403 TCA_CGROUP_UNSPEC,
404 TCA_CGROUP_ACT,
405 TCA_CGROUP_POLICE,
406 TCA_CGROUP_EMATCHES,
407 __TCA_CGROUP_MAX,
410 #define TCA_CGROUP_MAX (__TCA_CGROUP_MAX - 1)
412 /* Extended Matches */
414 struct tcf_ematch_tree_hdr
416 __u16 nmatches;
417 __u16 progid;
420 enum
422 TCA_EMATCH_TREE_UNSPEC,
423 TCA_EMATCH_TREE_HDR,
424 TCA_EMATCH_TREE_LIST,
425 __TCA_EMATCH_TREE_MAX
427 #define TCA_EMATCH_TREE_MAX (__TCA_EMATCH_TREE_MAX - 1)
429 struct tcf_ematch_hdr
431 __u16 matchid;
432 __u16 kind;
433 __u16 flags;
434 __u16 pad; /* currently unused */
437 /* 0 1
438 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
439 * +-----------------------+-+-+---+
440 * | Unused |S|I| R |
441 * +-----------------------+-+-+---+
443 * R(2) ::= relation to next ematch
444 * where: 0 0 END (last ematch)
445 * 0 1 AND
446 * 1 0 OR
447 * 1 1 Unused (invalid)
448 * I(1) ::= invert result
449 * S(1) ::= simple payload
451 #define TCF_EM_REL_END 0
452 #define TCF_EM_REL_AND (1<<0)
453 #define TCF_EM_REL_OR (1<<1)
454 #define TCF_EM_INVERT (1<<2)
455 #define TCF_EM_SIMPLE (1<<3)
457 #define TCF_EM_REL_MASK 3
458 #define TCF_EM_REL_VALID(v) (((v) & TCF_EM_REL_MASK) != TCF_EM_REL_MASK)
460 enum
462 TCF_LAYER_LINK,
463 TCF_LAYER_NETWORK,
464 TCF_LAYER_TRANSPORT,
465 __TCF_LAYER_MAX
467 #define TCF_LAYER_MAX (__TCF_LAYER_MAX - 1)
469 /* Ematch type assignments
470 * 1..32767 Reserved for ematches inside kernel tree
471 * 32768..65535 Free to use, not reliable
473 #define TCF_EM_CONTAINER 0
474 #define TCF_EM_CMP 1
475 #define TCF_EM_NBYTE 2
476 #define TCF_EM_U32 3
477 #define TCF_EM_META 4
478 #define TCF_EM_TEXT 5
479 #define TCF_EM_VLAN 6
480 #define TCF_EM_MAX 6
482 enum
484 TCF_EM_PROG_TC
487 enum
489 TCF_EM_OPND_EQ,
490 TCF_EM_OPND_GT,
491 TCF_EM_OPND_LT
494 #endif