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