initial commit with v2.6.9
[linux-2.6.9-moxart.git] / include / linux / pkt_cls.h
blob9abc5b5a925caba7a918b1cbeed441a8d4427c56
1 #ifndef __LINUX_PKT_CLS_H
2 #define __LINUX_PKT_CLS_H
4 /* I think i could have done better macros ; for now this is stolen from
5 * some arch/mips code - jhs
6 */
7 #define _TC_MAKE32(x) ((x))
9 #define _TC_MAKEMASK1(n) (_TC_MAKE32(1) << _TC_MAKE32(n))
10 #define _TC_MAKEMASK(v,n) (_TC_MAKE32((_TC_MAKE32(1)<<(v))-1) << _TC_MAKE32(n))
11 #define _TC_MAKEVALUE(v,n) (_TC_MAKE32(v) << _TC_MAKE32(n))
12 #define _TC_GETVALUE(v,n,m) ((_TC_MAKE32(v) & _TC_MAKE32(m)) >> _TC_MAKE32(n))
14 /* verdict bit breakdown
16 bit 0: when set -> this packet has been munged already
18 bit 1: when set -> It is ok to munge this packet
20 bit 2,3,4,5: Reclassify counter - sort of reverse TTL - if exceeded
21 assume loop
23 bit 6,7: Where this packet was last seen
24 0: Above the transmit example at the socket level
25 1: on the Ingress
26 2: on the Egress
28 bit 8: when set --> Request not to classify on ingress.
30 bits 9,10,11: redirect counter - redirect TTL. Loop avoidance
33 * */
35 #define TC_MUNGED _TC_MAKEMASK1(0)
36 #define SET_TC_MUNGED(v) ( TC_MUNGED | (v & ~TC_MUNGED))
37 #define CLR_TC_MUNGED(v) ( v & ~TC_MUNGED)
39 #define TC_OK2MUNGE _TC_MAKEMASK1(1)
40 #define SET_TC_OK2MUNGE(v) ( TC_OK2MUNGE | (v & ~TC_OK2MUNGE))
41 #define CLR_TC_OK2MUNGE(v) ( v & ~TC_OK2MUNGE)
43 #define S_TC_VERD _TC_MAKE32(2)
44 #define M_TC_VERD _TC_MAKEMASK(4,S_TC_VERD)
45 #define G_TC_VERD(x) _TC_GETVALUE(x,S_TC_VERD,M_TC_VERD)
46 #define V_TC_VERD(x) _TC_MAKEVALUE(x,S_TC_VERD)
47 #define SET_TC_VERD(v,n) ((V_TC_VERD(n)) | (v & ~M_TC_VERD))
49 #define S_TC_FROM _TC_MAKE32(6)
50 #define M_TC_FROM _TC_MAKEMASK(2,S_TC_FROM)
51 #define G_TC_FROM(x) _TC_GETVALUE(x,S_TC_FROM,M_TC_FROM)
52 #define V_TC_FROM(x) _TC_MAKEVALUE(x,S_TC_FROM)
53 #define SET_TC_FROM(v,n) ((V_TC_FROM(n)) | (v & ~M_TC_FROM))
54 #define AT_STACK 0x0
55 #define AT_INGRESS 0x1
56 #define AT_EGRESS 0x2
58 #define TC_NCLS _TC_MAKEMASK1(8)
59 #define SET_TC_NCLS(v) ( TC_NCLS | (v & ~TC_NCLS))
60 #define CLR_TC_NCLS(v) ( v & ~TC_NCLS)
62 #define S_TC_RTTL _TC_MAKE32(9)
63 #define M_TC_RTTL _TC_MAKEMASK(3,S_TC_RTTL)
64 #define G_TC_RTTL(x) _TC_GETVALUE(x,S_TC_RTTL,M_TC_RTTL)
65 #define V_TC_RTTL(x) _TC_MAKEVALUE(x,S_TC_RTTL)
66 #define SET_TC_RTTL(v,n) ((V_TC_RTTL(n)) | (v & ~M_TC_RTTL))
68 #define S_TC_AT _TC_MAKE32(12)
69 #define M_TC_AT _TC_MAKEMASK(2,S_TC_AT)
70 #define G_TC_AT(x) _TC_GETVALUE(x,S_TC_AT,M_TC_AT)
71 #define V_TC_AT(x) _TC_MAKEVALUE(x,S_TC_AT)
72 #define SET_TC_AT(v,n) ((V_TC_AT(n)) | (v & ~M_TC_AT))
74 /* Action attributes */
75 enum
77 TCA_ACT_UNSPEC,
78 TCA_ACT_KIND,
79 TCA_ACT_OPTIONS,
80 TCA_ACT_INDEX,
81 __TCA_ACT_MAX
84 #define TCA_ACT_MAX __TCA_ACT_MAX
85 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
86 #define TCA_ACT_MAX_PRIO 32
87 #define TCA_ACT_BIND 1
88 #define TCA_ACT_NOBIND 0
89 #define TCA_ACT_UNBIND 1
90 #define TCA_ACT_NOUNBIND 0
91 #define TCA_ACT_REPLACE 1
92 #define TCA_ACT_NOREPLACE 0
93 #define MAX_REC_LOOP 4
94 #define MAX_RED_LOOP 4
96 #define TC_ACT_UNSPEC (-1)
97 #define TC_ACT_OK 0
98 #define TC_ACT_RECLASSIFY 1
99 #define TC_ACT_SHOT 2
100 #define TC_ACT_PIPE 3
101 #define TC_ACT_STOLEN 4
102 #define TC_ACT_QUEUED 5
103 #define TC_ACT_REPEAT 6
104 #define TC_ACT_JUMP 0x10000000
106 /* Action type identifiers*/
107 enum
109 TCA_ID_UNSPEC=0,
110 TCA_ID_POLICE=1,
111 /* other actions go here */
112 __TCA_ID_MAX=255
115 #define TCA_ID_MAX __TCA_ID_MAX
117 struct tc_police
119 __u32 index;
120 int action;
121 #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
122 #define TC_POLICE_OK TC_ACT_OK
123 #define TC_POLICE_RECLASSIFY TC_ACT_RECLASSIFY
124 #define TC_POLICE_SHOT TC_ACT_SHOT
125 #define TC_POLICE_PIPE TC_ACT_PIPE
127 __u32 limit;
128 __u32 burst;
129 __u32 mtu;
130 struct tc_ratespec rate;
131 struct tc_ratespec peakrate;
132 int refcnt;
133 int bindcnt;
134 __u32 capab;
137 struct tcf_t
139 __u32 install;
140 __u32 lastuse;
141 __u32 expires;
144 struct tc_cnt
146 int refcnt;
147 int bindcnt;
150 #define tc_gen \
151 __u32 index; \
152 __u32 capab; \
153 int action; \
154 int refcnt; \
155 int bindcnt
157 enum
159 TCA_POLICE_UNSPEC,
160 TCA_POLICE_TBF,
161 TCA_POLICE_RATE,
162 TCA_POLICE_PEAKRATE,
163 TCA_POLICE_AVRATE,
164 TCA_POLICE_RESULT,
165 __TCA_POLICE_MAX
166 #define TCA_POLICE_RESULT TCA_POLICE_RESULT
169 #define TCA_POLICE_MAX (__TCA_POLICE_MAX - 1)
171 /* U32 filters */
173 #define TC_U32_HTID(h) ((h)&0xFFF00000)
174 #define TC_U32_USERHTID(h) (TC_U32_HTID(h)>>20)
175 #define TC_U32_HASH(h) (((h)>>12)&0xFF)
176 #define TC_U32_NODE(h) ((h)&0xFFF)
177 #define TC_U32_KEY(h) ((h)&0xFFFFF)
178 #define TC_U32_UNSPEC 0
179 #define TC_U32_ROOT (0xFFF00000)
181 enum
183 TCA_U32_UNSPEC,
184 TCA_U32_CLASSID,
185 TCA_U32_HASH,
186 TCA_U32_LINK,
187 TCA_U32_DIVISOR,
188 TCA_U32_SEL,
189 TCA_U32_POLICE,
190 TCA_U32_ACT,
191 TCA_U32_INDEV,
192 TCA_U32_PCNT,
193 __TCA_U32_MAX
196 #define TCA_U32_MAX (__TCA_U32_MAX - 1)
198 struct tc_u32_key
200 __u32 mask;
201 __u32 val;
202 int off;
203 int offmask;
206 struct tc_u32_sel
208 unsigned char flags;
209 unsigned char offshift;
210 unsigned char nkeys;
212 __u16 offmask;
213 __u16 off;
214 short offoff;
216 short hoff;
217 __u32 hmask;
218 struct tc_u32_key keys[0];
221 #ifdef CONFIG_CLS_U32_PERF
222 struct tc_u32_pcnt
224 __u64 rcnt;
225 __u64 rhit;
226 __u64 kcnts[0];
228 #endif
229 /* Flags */
231 #define TC_U32_TERMINAL 1
232 #define TC_U32_OFFSET 2
233 #define TC_U32_VAROFFSET 4
234 #define TC_U32_EAT 8
236 #define TC_U32_MAXDEPTH 8
239 /* RSVP filter */
241 enum
243 TCA_RSVP_UNSPEC,
244 TCA_RSVP_CLASSID,
245 TCA_RSVP_DST,
246 TCA_RSVP_SRC,
247 TCA_RSVP_PINFO,
248 TCA_RSVP_POLICE,
249 __TCA_RSVP_MAX
252 #define TCA_RSVP_MAX (__TCA_RSVP_MAX - 1 )
254 struct tc_rsvp_gpi
256 __u32 key;
257 __u32 mask;
258 int offset;
261 struct tc_rsvp_pinfo
263 struct tc_rsvp_gpi dpi;
264 struct tc_rsvp_gpi spi;
265 __u8 protocol;
266 __u8 tunnelid;
267 __u8 tunnelhdr;
270 /* ROUTE filter */
272 enum
274 TCA_ROUTE4_UNSPEC,
275 TCA_ROUTE4_CLASSID,
276 TCA_ROUTE4_TO,
277 TCA_ROUTE4_FROM,
278 TCA_ROUTE4_IIF,
279 TCA_ROUTE4_POLICE,
280 __TCA_ROUTE4_MAX
283 #define TCA_ROUTE4_MAX (__TCA_ROUTE4_MAX - 1)
286 /* FW filter */
288 enum
290 TCA_FW_UNSPEC,
291 TCA_FW_CLASSID,
292 TCA_FW_POLICE,
293 TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
294 TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
295 __TCA_FW_MAX
298 #define TCA_FW_MAX (__TCA_FW_MAX - 1)
300 /* TC index filter */
302 enum
304 TCA_TCINDEX_UNSPEC,
305 TCA_TCINDEX_HASH,
306 TCA_TCINDEX_MASK,
307 TCA_TCINDEX_SHIFT,
308 TCA_TCINDEX_FALL_THROUGH,
309 TCA_TCINDEX_CLASSID,
310 TCA_TCINDEX_POLICE,
311 __TCA_TCINDEX_MAX
314 #define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
316 #endif