1 | #ifndef __LINUX_PKT_SCHED_H
|
---|
2 | #define __LINUX_PKT_SCHED_H
|
---|
3 |
|
---|
4 | /* Logical priority bands not depending on specific packet scheduler.
|
---|
5 | Every scheduler will map them to real traffic classes, if it has
|
---|
6 | no more precise mechanism to classify packets.
|
---|
7 |
|
---|
8 | These numbers have no special meaning, though their coincidence
|
---|
9 | with obsolete IPv6 values is not occasional :-). New IPv6 drafts
|
---|
10 | preferred full anarchy inspired by diffserv group.
|
---|
11 |
|
---|
12 | Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy
|
---|
13 | class, actually, as rule it will be handled with more care than
|
---|
14 | filler or even bulk.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #include <asm/types.h>
|
---|
18 |
|
---|
19 | #define TC_PRIO_BESTEFFORT 0
|
---|
20 | #define TC_PRIO_FILLER 1
|
---|
21 | #define TC_PRIO_BULK 2
|
---|
22 | #define TC_PRIO_INTERACTIVE_BULK 4
|
---|
23 | #define TC_PRIO_INTERACTIVE 6
|
---|
24 | #define TC_PRIO_CONTROL 7
|
---|
25 |
|
---|
26 | #define TC_PRIO_MAX 15
|
---|
27 |
|
---|
28 | /* Generic queue statistics, available for all the elements.
|
---|
29 | Particular schedulers may have also their private records.
|
---|
30 | */
|
---|
31 |
|
---|
32 | struct tc_stats
|
---|
33 | {
|
---|
34 | __u64 bytes; /* NUmber of enqueues bytes */
|
---|
35 | __u32 packets; /* Number of enqueued packets */
|
---|
36 | __u32 drops; /* Packets dropped because of lack of resources */
|
---|
37 | __u32 overlimits; /* Number of throttle events when this
|
---|
38 | * flow goes out of allocated bandwidth */
|
---|
39 | __u32 bps; /* Current flow byte rate */
|
---|
40 | __u32 pps; /* Current flow packet rate */
|
---|
41 | __u32 qlen;
|
---|
42 | __u32 backlog;
|
---|
43 | #ifdef __KERNEL__
|
---|
44 | spinlock_t *lock;
|
---|
45 | #endif
|
---|
46 | };
|
---|
47 |
|
---|
48 | struct tc_estimator
|
---|
49 | {
|
---|
50 | char interval;
|
---|
51 | unsigned char ewma_log;
|
---|
52 | };
|
---|
53 |
|
---|
54 | /* "Handles"
|
---|
55 | ---------
|
---|
56 |
|
---|
57 | All the traffic control objects have 32bit identifiers, or "handles".
|
---|
58 |
|
---|
59 | They can be considered as opaque numbers from user API viewpoint,
|
---|
60 | but actually they always consist of two fields: major and
|
---|
61 | minor numbers, which are interpreted by kernel specially,
|
---|
62 | that may be used by applications, though not recommended.
|
---|
63 |
|
---|
64 | F.e. qdisc handles always have minor number equal to zero,
|
---|
65 | classes (or flows) have major equal to parent qdisc major, and
|
---|
66 | minor uniquely identifying class inside qdisc.
|
---|
67 |
|
---|
68 | Macros to manipulate handles:
|
---|
69 | */
|
---|
70 |
|
---|
71 | #define TC_H_MAJ_MASK (0xFFFF0000U)
|
---|
72 | #define TC_H_MIN_MASK (0x0000FFFFU)
|
---|
73 | #define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK)
|
---|
74 | #define TC_H_MIN(h) ((h)&TC_H_MIN_MASK)
|
---|
75 | #define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK))
|
---|
76 |
|
---|
77 | #define TC_H_UNSPEC (0U)
|
---|
78 | #define TC_H_ROOT (0xFFFFFFFFU)
|
---|
79 | #define TC_H_INGRESS (0xFFFFFFF1U)
|
---|
80 |
|
---|
81 | struct tc_ratespec
|
---|
82 | {
|
---|
83 | unsigned char cell_log;
|
---|
84 | unsigned char __reserved;
|
---|
85 | unsigned short feature;
|
---|
86 | short addend;
|
---|
87 | unsigned short mpu;
|
---|
88 | __u32 rate;
|
---|
89 | };
|
---|
90 |
|
---|
91 | /* FIFO section */
|
---|
92 |
|
---|
93 | struct tc_fifo_qopt
|
---|
94 | {
|
---|
95 | __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */
|
---|
96 | };
|
---|
97 |
|
---|
98 | /* PRIO section */
|
---|
99 |
|
---|
100 | #define TCQ_PRIO_BANDS 16
|
---|
101 |
|
---|
102 | struct tc_prio_qopt
|
---|
103 | {
|
---|
104 | int bands; /* Number of bands */
|
---|
105 | __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */
|
---|
106 | };
|
---|
107 |
|
---|
108 | /* CSZ section */
|
---|
109 |
|
---|
110 | struct tc_csz_qopt
|
---|
111 | {
|
---|
112 | int flows; /* Maximal number of guaranteed flows */
|
---|
113 | unsigned char R_log; /* Fixed point position for round number */
|
---|
114 | unsigned char delta_log; /* Log of maximal managed time interval */
|
---|
115 | __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> CSZ band */
|
---|
116 | };
|
---|
117 |
|
---|
118 | struct tc_csz_copt
|
---|
119 | {
|
---|
120 | struct tc_ratespec slice;
|
---|
121 | struct tc_ratespec rate;
|
---|
122 | struct tc_ratespec peakrate;
|
---|
123 | __u32 limit;
|
---|
124 | __u32 buffer;
|
---|
125 | __u32 mtu;
|
---|
126 | };
|
---|
127 |
|
---|
128 | enum
|
---|
129 | {
|
---|
130 | TCA_CSZ_UNSPEC,
|
---|
131 | TCA_CSZ_PARMS,
|
---|
132 | TCA_CSZ_RTAB,
|
---|
133 | TCA_CSZ_PTAB,
|
---|
134 | };
|
---|
135 |
|
---|
136 | /* TBF section */
|
---|
137 |
|
---|
138 | struct tc_tbf_qopt
|
---|
139 | {
|
---|
140 | struct tc_ratespec rate;
|
---|
141 | struct tc_ratespec peakrate;
|
---|
142 | __u32 limit;
|
---|
143 | __u32 buffer;
|
---|
144 | __u32 mtu;
|
---|
145 | };
|
---|
146 |
|
---|
147 | enum
|
---|
148 | {
|
---|
149 | TCA_TBF_UNSPEC,
|
---|
150 | TCA_TBF_PARMS,
|
---|
151 | TCA_TBF_RTAB,
|
---|
152 | TCA_TBF_PTAB,
|
---|
153 | };
|
---|
154 |
|
---|
155 |
|
---|
156 | /* TEQL section */
|
---|
157 |
|
---|
158 | /* TEQL does not require any parameters */
|
---|
159 |
|
---|
160 | /* SFQ section */
|
---|
161 |
|
---|
162 | struct tc_sfq_qopt
|
---|
163 | {
|
---|
164 | unsigned quantum; /* Bytes per round allocated to flow */
|
---|
165 | int perturb_period; /* Period of hash perturbation */
|
---|
166 | __u32 limit; /* Maximal packets in queue */
|
---|
167 | unsigned divisor; /* Hash divisor */
|
---|
168 | unsigned flows; /* Maximal number of flows */
|
---|
169 | };
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * NOTE: limit, divisor and flows are hardwired to code at the moment.
|
---|
173 | *
|
---|
174 | * limit=flows=128, divisor=1024;
|
---|
175 | *
|
---|
176 | * The only reason for this is efficiency, it is possible
|
---|
177 | * to change these parameters in compile time.
|
---|
178 | */
|
---|
179 |
|
---|
180 | /* RED section */
|
---|
181 |
|
---|
182 | enum
|
---|
183 | {
|
---|
184 | TCA_RED_UNSPEC,
|
---|
185 | TCA_RED_PARMS,
|
---|
186 | TCA_RED_STAB,
|
---|
187 | };
|
---|
188 |
|
---|
189 | struct tc_red_qopt
|
---|
190 | {
|
---|
191 | __u32 limit; /* HARD maximal queue length (bytes) */
|
---|
192 | __u32 qth_min; /* Min average length threshold (bytes) */
|
---|
193 | __u32 qth_max; /* Max average length threshold (bytes) */
|
---|
194 | unsigned char Wlog; /* log(W) */
|
---|
195 | unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
|
---|
196 | unsigned char Scell_log; /* cell size for idle damping */
|
---|
197 | unsigned char flags;
|
---|
198 | #define TC_RED_ECN 1
|
---|
199 | };
|
---|
200 |
|
---|
201 | struct tc_red_xstats
|
---|
202 | {
|
---|
203 | __u32 early; /* Early drops */
|
---|
204 | __u32 pdrop; /* Drops due to queue limits */
|
---|
205 | __u32 other; /* Drops due to drop() calls */
|
---|
206 | __u32 marked; /* Marked packets */
|
---|
207 | };
|
---|
208 |
|
---|
209 | /* GRED section */
|
---|
210 |
|
---|
211 | #define MAX_DPs 16
|
---|
212 |
|
---|
213 | enum
|
---|
214 | {
|
---|
215 | TCA_GRED_UNSPEC,
|
---|
216 | TCA_GRED_PARMS,
|
---|
217 | TCA_GRED_STAB,
|
---|
218 | TCA_GRED_DPS,
|
---|
219 | };
|
---|
220 |
|
---|
221 | #define TCA_SET_OFF TCA_GRED_PARMS
|
---|
222 | struct tc_gred_qopt
|
---|
223 | {
|
---|
224 | __u32 limit; /* HARD maximal queue length (bytes)
|
---|
225 | */
|
---|
226 | __u32 qth_min; /* Min average length threshold (bytes)
|
---|
227 | */
|
---|
228 | __u32 qth_max; /* Max average length threshold (bytes)
|
---|
229 | */
|
---|
230 | __u32 DP; /* upto 2^32 DPs */
|
---|
231 | __u32 backlog;
|
---|
232 | __u32 qave;
|
---|
233 | __u32 forced;
|
---|
234 | __u32 early;
|
---|
235 | __u32 other;
|
---|
236 | __u32 pdrop;
|
---|
237 |
|
---|
238 | unsigned char Wlog; /* log(W) */
|
---|
239 | unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
|
---|
240 | unsigned char Scell_log; /* cell size for idle damping */
|
---|
241 | __u8 prio; /* prio of this VQ */
|
---|
242 | __u32 packets;
|
---|
243 | __u32 bytesin;
|
---|
244 | };
|
---|
245 | /* gred setup */
|
---|
246 | struct tc_gred_sopt
|
---|
247 | {
|
---|
248 | __u32 DPs;
|
---|
249 | __u32 def_DP;
|
---|
250 | __u8 grio;
|
---|
251 | };
|
---|
252 |
|
---|
253 | /* HTB section */
|
---|
254 | #define TC_HTB_NUMPRIO 4
|
---|
255 | #define TC_HTB_MAXDEPTH 4
|
---|
256 |
|
---|
257 | struct tc_htb_opt
|
---|
258 | {
|
---|
259 | struct tc_ratespec rate;
|
---|
260 | struct tc_ratespec ceil;
|
---|
261 | __u32 buffer;
|
---|
262 | __u32 cbuffer;
|
---|
263 | __u32 quantum; /* out only */
|
---|
264 | __u32 level; /* out only */
|
---|
265 | __u8 prio;
|
---|
266 | __u8 injectd; /* inject class distance */
|
---|
267 | __u8 pad[2];
|
---|
268 | };
|
---|
269 | struct tc_htb_glob
|
---|
270 | {
|
---|
271 | __u32 rate2quantum; /* bps->quantum divisor */
|
---|
272 | __u32 defcls; /* default class number */
|
---|
273 | __u32 use_dcache; /* use dequeue cache ? */
|
---|
274 | __u32 debug; /* debug flags */
|
---|
275 |
|
---|
276 |
|
---|
277 | /* stats */
|
---|
278 | __u32 deq_rate; /* dequeue rate */
|
---|
279 | __u32 utilz; /* dequeue utilization */
|
---|
280 | __u32 trials; /* deq_prio trials per dequeue */
|
---|
281 | __u32 dcache_hits;
|
---|
282 | __u32 direct_pkts; /* count of non shapped packets */
|
---|
283 | };
|
---|
284 | enum
|
---|
285 | {
|
---|
286 | TCA_HTB_UNSPEC,
|
---|
287 | TCA_HTB_PARMS,
|
---|
288 | TCA_HTB_INIT,
|
---|
289 | TCA_HTB_CTAB,
|
---|
290 | TCA_HTB_RTAB,
|
---|
291 | };
|
---|
292 | struct tc_htb_xstats
|
---|
293 | {
|
---|
294 | __u32 lends;
|
---|
295 | __u32 borrows;
|
---|
296 | __u32 giants; /* too big packets (rate will not be accurate) */
|
---|
297 | __u32 injects; /* how many times leaf used injected bw */
|
---|
298 | __u32 tokens;
|
---|
299 | __u32 ctokens;
|
---|
300 | };
|
---|
301 |
|
---|
302 | /* CBQ section */
|
---|
303 |
|
---|
304 | #define TC_CBQ_MAXPRIO 8
|
---|
305 | #define TC_CBQ_MAXLEVEL 8
|
---|
306 | #define TC_CBQ_DEF_EWMA 5
|
---|
307 |
|
---|
308 | struct tc_cbq_lssopt
|
---|
309 | {
|
---|
310 | unsigned char change;
|
---|
311 | unsigned char flags;
|
---|
312 | #define TCF_CBQ_LSS_BOUNDED 1
|
---|
313 | #define TCF_CBQ_LSS_ISOLATED 2
|
---|
314 | unsigned char ewma_log;
|
---|
315 | unsigned char level;
|
---|
316 | #define TCF_CBQ_LSS_FLAGS 1
|
---|
317 | #define TCF_CBQ_LSS_EWMA 2
|
---|
318 | #define TCF_CBQ_LSS_MAXIDLE 4
|
---|
319 | #define TCF_CBQ_LSS_MINIDLE 8
|
---|
320 | #define TCF_CBQ_LSS_OFFTIME 0x10
|
---|
321 | #define TCF_CBQ_LSS_AVPKT 0x20
|
---|
322 | __u32 maxidle;
|
---|
323 | __u32 minidle;
|
---|
324 | __u32 offtime;
|
---|
325 | __u32 avpkt;
|
---|
326 | };
|
---|
327 |
|
---|
328 | struct tc_cbq_wrropt
|
---|
329 | {
|
---|
330 | unsigned char flags;
|
---|
331 | unsigned char priority;
|
---|
332 | unsigned char cpriority;
|
---|
333 | unsigned char __reserved;
|
---|
334 | __u32 allot;
|
---|
335 | __u32 weight;
|
---|
336 | };
|
---|
337 |
|
---|
338 | struct tc_cbq_ovl
|
---|
339 | {
|
---|
340 | unsigned char strategy;
|
---|
341 | #define TC_CBQ_OVL_CLASSIC 0
|
---|
342 | #define TC_CBQ_OVL_DELAY 1
|
---|
343 | #define TC_CBQ_OVL_LOWPRIO 2
|
---|
344 | #define TC_CBQ_OVL_DROP 3
|
---|
345 | #define TC_CBQ_OVL_RCLASSIC 4
|
---|
346 | unsigned char priority2;
|
---|
347 | __u32 penalty;
|
---|
348 | };
|
---|
349 |
|
---|
350 | struct tc_cbq_police
|
---|
351 | {
|
---|
352 | unsigned char police;
|
---|
353 | unsigned char __res1;
|
---|
354 | unsigned short __res2;
|
---|
355 | };
|
---|
356 |
|
---|
357 | struct tc_cbq_fopt
|
---|
358 | {
|
---|
359 | __u32 split;
|
---|
360 | __u32 defmap;
|
---|
361 | __u32 defchange;
|
---|
362 | };
|
---|
363 |
|
---|
364 | struct tc_cbq_xstats
|
---|
365 | {
|
---|
366 | __u32 borrows;
|
---|
367 | __u32 overactions;
|
---|
368 | __s32 avgidle;
|
---|
369 | __s32 undertime;
|
---|
370 | };
|
---|
371 |
|
---|
372 | enum
|
---|
373 | {
|
---|
374 | TCA_CBQ_UNSPEC,
|
---|
375 | TCA_CBQ_LSSOPT,
|
---|
376 | TCA_CBQ_WRROPT,
|
---|
377 | TCA_CBQ_FOPT,
|
---|
378 | TCA_CBQ_OVL_STRATEGY,
|
---|
379 | TCA_CBQ_RATE,
|
---|
380 | TCA_CBQ_RTAB,
|
---|
381 | TCA_CBQ_POLICE,
|
---|
382 | };
|
---|
383 |
|
---|
384 | #define TCA_CBQ_MAX TCA_CBQ_POLICE
|
---|
385 |
|
---|
386 | /* dsmark section */
|
---|
387 |
|
---|
388 | enum {
|
---|
389 | TCA_DSMARK_UNSPEC,
|
---|
390 | TCA_DSMARK_INDICES,
|
---|
391 | TCA_DSMARK_DEFAULT_INDEX,
|
---|
392 | TCA_DSMARK_SET_TC_INDEX,
|
---|
393 | TCA_DSMARK_MASK,
|
---|
394 | TCA_DSMARK_VALUE
|
---|
395 | };
|
---|
396 |
|
---|
397 | #define TCA_DSMARK_MAX TCA_DSMARK_VALUE
|
---|
398 |
|
---|
399 | /* ATM section */
|
---|
400 |
|
---|
401 | enum {
|
---|
402 | TCA_ATM_UNSPEC,
|
---|
403 | TCA_ATM_FD, /* file/socket descriptor */
|
---|
404 | TCA_ATM_PTR, /* pointer to descriptor - later */
|
---|
405 | TCA_ATM_HDR, /* LL header */
|
---|
406 | TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */
|
---|
407 | TCA_ATM_ADDR, /* PVC address (for output only) */
|
---|
408 | TCA_ATM_STATE /* VC state (ATM_VS_*; for output only) */
|
---|
409 | };
|
---|
410 |
|
---|
411 | #define TCA_ATM_MAX TCA_ATM_STATE
|
---|
412 |
|
---|
413 | #endif
|
---|