1607ca46eSDavid Howells #ifndef __LINUX_PKT_SCHED_H 2607ca46eSDavid Howells #define __LINUX_PKT_SCHED_H 3607ca46eSDavid Howells 4607ca46eSDavid Howells #include <linux/types.h> 5607ca46eSDavid Howells 6607ca46eSDavid Howells /* Logical priority bands not depending on specific packet scheduler. 7607ca46eSDavid Howells Every scheduler will map them to real traffic classes, if it has 8607ca46eSDavid Howells no more precise mechanism to classify packets. 9607ca46eSDavid Howells 10607ca46eSDavid Howells These numbers have no special meaning, though their coincidence 11607ca46eSDavid Howells with obsolete IPv6 values is not occasional :-). New IPv6 drafts 12607ca46eSDavid Howells preferred full anarchy inspired by diffserv group. 13607ca46eSDavid Howells 14607ca46eSDavid Howells Note: TC_PRIO_BESTEFFORT does not mean that it is the most unhappy 15607ca46eSDavid Howells class, actually, as rule it will be handled with more care than 16607ca46eSDavid Howells filler or even bulk. 17607ca46eSDavid Howells */ 18607ca46eSDavid Howells 19607ca46eSDavid Howells #define TC_PRIO_BESTEFFORT 0 20607ca46eSDavid Howells #define TC_PRIO_FILLER 1 21607ca46eSDavid Howells #define TC_PRIO_BULK 2 22607ca46eSDavid Howells #define TC_PRIO_INTERACTIVE_BULK 4 23607ca46eSDavid Howells #define TC_PRIO_INTERACTIVE 6 24607ca46eSDavid Howells #define TC_PRIO_CONTROL 7 25607ca46eSDavid Howells 26607ca46eSDavid Howells #define TC_PRIO_MAX 15 27607ca46eSDavid Howells 28607ca46eSDavid Howells /* Generic queue statistics, available for all the elements. 29607ca46eSDavid Howells Particular schedulers may have also their private records. 30607ca46eSDavid Howells */ 31607ca46eSDavid Howells 32607ca46eSDavid Howells struct tc_stats { 33607ca46eSDavid Howells __u64 bytes; /* Number of enqueued bytes */ 34607ca46eSDavid Howells __u32 packets; /* Number of enqueued packets */ 35607ca46eSDavid Howells __u32 drops; /* Packets dropped because of lack of resources */ 36607ca46eSDavid Howells __u32 overlimits; /* Number of throttle events when this 37607ca46eSDavid Howells * flow goes out of allocated bandwidth */ 38607ca46eSDavid Howells __u32 bps; /* Current flow byte rate */ 39607ca46eSDavid Howells __u32 pps; /* Current flow packet rate */ 40607ca46eSDavid Howells __u32 qlen; 41607ca46eSDavid Howells __u32 backlog; 42607ca46eSDavid Howells }; 43607ca46eSDavid Howells 44607ca46eSDavid Howells struct tc_estimator { 45607ca46eSDavid Howells signed char interval; 46607ca46eSDavid Howells unsigned char ewma_log; 47607ca46eSDavid Howells }; 48607ca46eSDavid Howells 49607ca46eSDavid Howells /* "Handles" 50607ca46eSDavid Howells --------- 51607ca46eSDavid Howells 52607ca46eSDavid Howells All the traffic control objects have 32bit identifiers, or "handles". 53607ca46eSDavid Howells 54607ca46eSDavid Howells They can be considered as opaque numbers from user API viewpoint, 55607ca46eSDavid Howells but actually they always consist of two fields: major and 56607ca46eSDavid Howells minor numbers, which are interpreted by kernel specially, 57607ca46eSDavid Howells that may be used by applications, though not recommended. 58607ca46eSDavid Howells 59607ca46eSDavid Howells F.e. qdisc handles always have minor number equal to zero, 60607ca46eSDavid Howells classes (or flows) have major equal to parent qdisc major, and 61607ca46eSDavid Howells minor uniquely identifying class inside qdisc. 62607ca46eSDavid Howells 63607ca46eSDavid Howells Macros to manipulate handles: 64607ca46eSDavid Howells */ 65607ca46eSDavid Howells 66607ca46eSDavid Howells #define TC_H_MAJ_MASK (0xFFFF0000U) 67607ca46eSDavid Howells #define TC_H_MIN_MASK (0x0000FFFFU) 68607ca46eSDavid Howells #define TC_H_MAJ(h) ((h)&TC_H_MAJ_MASK) 69607ca46eSDavid Howells #define TC_H_MIN(h) ((h)&TC_H_MIN_MASK) 70607ca46eSDavid Howells #define TC_H_MAKE(maj,min) (((maj)&TC_H_MAJ_MASK)|((min)&TC_H_MIN_MASK)) 71607ca46eSDavid Howells 72607ca46eSDavid Howells #define TC_H_UNSPEC (0U) 73607ca46eSDavid Howells #define TC_H_ROOT (0xFFFFFFFFU) 74607ca46eSDavid Howells #define TC_H_INGRESS (0xFFFFFFF1U) 75607ca46eSDavid Howells 768a8e3d84SJesper Dangaard Brouer /* Need to corrospond to iproute2 tc/tc_core.h "enum link_layer" */ 778a8e3d84SJesper Dangaard Brouer enum tc_link_layer { 788a8e3d84SJesper Dangaard Brouer TC_LINKLAYER_UNAWARE, /* Indicate unaware old iproute2 util */ 798a8e3d84SJesper Dangaard Brouer TC_LINKLAYER_ETHERNET, 808a8e3d84SJesper Dangaard Brouer TC_LINKLAYER_ATM, 818a8e3d84SJesper Dangaard Brouer }; 828a8e3d84SJesper Dangaard Brouer #define TC_LINKLAYER_MASK 0x0F /* limit use to lower 4 bits */ 838a8e3d84SJesper Dangaard Brouer 84607ca46eSDavid Howells struct tc_ratespec { 85607ca46eSDavid Howells unsigned char cell_log; 868a8e3d84SJesper Dangaard Brouer __u8 linklayer; /* lower 4 bits */ 87607ca46eSDavid Howells unsigned short overhead; 88607ca46eSDavid Howells short cell_align; 89607ca46eSDavid Howells unsigned short mpu; 90607ca46eSDavid Howells __u32 rate; 91607ca46eSDavid Howells }; 92607ca46eSDavid Howells 93607ca46eSDavid Howells #define TC_RTAB_SIZE 1024 94607ca46eSDavid Howells 95607ca46eSDavid Howells struct tc_sizespec { 96607ca46eSDavid Howells unsigned char cell_log; 97607ca46eSDavid Howells unsigned char size_log; 98607ca46eSDavid Howells short cell_align; 99607ca46eSDavid Howells int overhead; 100607ca46eSDavid Howells unsigned int linklayer; 101607ca46eSDavid Howells unsigned int mpu; 102607ca46eSDavid Howells unsigned int mtu; 103607ca46eSDavid Howells unsigned int tsize; 104607ca46eSDavid Howells }; 105607ca46eSDavid Howells 106607ca46eSDavid Howells enum { 107607ca46eSDavid Howells TCA_STAB_UNSPEC, 108607ca46eSDavid Howells TCA_STAB_BASE, 109607ca46eSDavid Howells TCA_STAB_DATA, 110607ca46eSDavid Howells __TCA_STAB_MAX 111607ca46eSDavid Howells }; 112607ca46eSDavid Howells 113607ca46eSDavid Howells #define TCA_STAB_MAX (__TCA_STAB_MAX - 1) 114607ca46eSDavid Howells 115607ca46eSDavid Howells /* FIFO section */ 116607ca46eSDavid Howells 117607ca46eSDavid Howells struct tc_fifo_qopt { 118607ca46eSDavid Howells __u32 limit; /* Queue length: bytes for bfifo, packets for pfifo */ 119607ca46eSDavid Howells }; 120607ca46eSDavid Howells 121607ca46eSDavid Howells /* PRIO section */ 122607ca46eSDavid Howells 123607ca46eSDavid Howells #define TCQ_PRIO_BANDS 16 124607ca46eSDavid Howells #define TCQ_MIN_PRIO_BANDS 2 125607ca46eSDavid Howells 126607ca46eSDavid Howells struct tc_prio_qopt { 127607ca46eSDavid Howells int bands; /* Number of bands */ 128607ca46eSDavid Howells __u8 priomap[TC_PRIO_MAX+1]; /* Map: logical priority -> PRIO band */ 129607ca46eSDavid Howells }; 130607ca46eSDavid Howells 131607ca46eSDavid Howells /* MULTIQ section */ 132607ca46eSDavid Howells 133607ca46eSDavid Howells struct tc_multiq_qopt { 134607ca46eSDavid Howells __u16 bands; /* Number of bands */ 135607ca46eSDavid Howells __u16 max_bands; /* Maximum number of queues */ 136607ca46eSDavid Howells }; 137607ca46eSDavid Howells 138607ca46eSDavid Howells /* PLUG section */ 139607ca46eSDavid Howells 140607ca46eSDavid Howells #define TCQ_PLUG_BUFFER 0 141607ca46eSDavid Howells #define TCQ_PLUG_RELEASE_ONE 1 142607ca46eSDavid Howells #define TCQ_PLUG_RELEASE_INDEFINITE 2 143607ca46eSDavid Howells #define TCQ_PLUG_LIMIT 3 144607ca46eSDavid Howells 145607ca46eSDavid Howells struct tc_plug_qopt { 146607ca46eSDavid Howells /* TCQ_PLUG_BUFFER: Inset a plug into the queue and 147607ca46eSDavid Howells * buffer any incoming packets 148607ca46eSDavid Howells * TCQ_PLUG_RELEASE_ONE: Dequeue packets from queue head 149607ca46eSDavid Howells * to beginning of the next plug. 150607ca46eSDavid Howells * TCQ_PLUG_RELEASE_INDEFINITE: Dequeue all packets from queue. 151607ca46eSDavid Howells * Stop buffering packets until the next TCQ_PLUG_BUFFER 152607ca46eSDavid Howells * command is received (just act as a pass-thru queue). 153607ca46eSDavid Howells * TCQ_PLUG_LIMIT: Increase/decrease queue size 154607ca46eSDavid Howells */ 155607ca46eSDavid Howells int action; 156607ca46eSDavid Howells __u32 limit; 157607ca46eSDavid Howells }; 158607ca46eSDavid Howells 159607ca46eSDavid Howells /* TBF section */ 160607ca46eSDavid Howells 161607ca46eSDavid Howells struct tc_tbf_qopt { 162607ca46eSDavid Howells struct tc_ratespec rate; 163607ca46eSDavid Howells struct tc_ratespec peakrate; 164607ca46eSDavid Howells __u32 limit; 165607ca46eSDavid Howells __u32 buffer; 166607ca46eSDavid Howells __u32 mtu; 167607ca46eSDavid Howells }; 168607ca46eSDavid Howells 169607ca46eSDavid Howells enum { 170607ca46eSDavid Howells TCA_TBF_UNSPEC, 171607ca46eSDavid Howells TCA_TBF_PARMS, 172607ca46eSDavid Howells TCA_TBF_RTAB, 173607ca46eSDavid Howells TCA_TBF_PTAB, 174*a33c4a26SYang Yingliang TCA_TBF_RATE64, 175*a33c4a26SYang Yingliang TCA_TBF_PRATE64, 176607ca46eSDavid Howells __TCA_TBF_MAX, 177607ca46eSDavid Howells }; 178607ca46eSDavid Howells 179607ca46eSDavid Howells #define TCA_TBF_MAX (__TCA_TBF_MAX - 1) 180607ca46eSDavid Howells 181607ca46eSDavid Howells 182607ca46eSDavid Howells /* TEQL section */ 183607ca46eSDavid Howells 184607ca46eSDavid Howells /* TEQL does not require any parameters */ 185607ca46eSDavid Howells 186607ca46eSDavid Howells /* SFQ section */ 187607ca46eSDavid Howells 188607ca46eSDavid Howells struct tc_sfq_qopt { 189607ca46eSDavid Howells unsigned quantum; /* Bytes per round allocated to flow */ 190607ca46eSDavid Howells int perturb_period; /* Period of hash perturbation */ 191607ca46eSDavid Howells __u32 limit; /* Maximal packets in queue */ 192607ca46eSDavid Howells unsigned divisor; /* Hash divisor */ 193607ca46eSDavid Howells unsigned flows; /* Maximal number of flows */ 194607ca46eSDavid Howells }; 195607ca46eSDavid Howells 196607ca46eSDavid Howells struct tc_sfqred_stats { 197607ca46eSDavid Howells __u32 prob_drop; /* Early drops, below max threshold */ 198607ca46eSDavid Howells __u32 forced_drop; /* Early drops, after max threshold */ 199607ca46eSDavid Howells __u32 prob_mark; /* Marked packets, below max threshold */ 200607ca46eSDavid Howells __u32 forced_mark; /* Marked packets, after max threshold */ 201607ca46eSDavid Howells __u32 prob_mark_head; /* Marked packets, below max threshold */ 202607ca46eSDavid Howells __u32 forced_mark_head;/* Marked packets, after max threshold */ 203607ca46eSDavid Howells }; 204607ca46eSDavid Howells 205607ca46eSDavid Howells struct tc_sfq_qopt_v1 { 206607ca46eSDavid Howells struct tc_sfq_qopt v0; 207607ca46eSDavid Howells unsigned int depth; /* max number of packets per flow */ 208607ca46eSDavid Howells unsigned int headdrop; 209607ca46eSDavid Howells /* SFQRED parameters */ 210607ca46eSDavid Howells __u32 limit; /* HARD maximal flow queue length (bytes) */ 211607ca46eSDavid Howells __u32 qth_min; /* Min average length threshold (bytes) */ 212607ca46eSDavid Howells __u32 qth_max; /* Max average length threshold (bytes) */ 213607ca46eSDavid Howells unsigned char Wlog; /* log(W) */ 214607ca46eSDavid Howells unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ 215607ca46eSDavid Howells unsigned char Scell_log; /* cell size for idle damping */ 216607ca46eSDavid Howells unsigned char flags; 217607ca46eSDavid Howells __u32 max_P; /* probability, high resolution */ 218607ca46eSDavid Howells /* SFQRED stats */ 219607ca46eSDavid Howells struct tc_sfqred_stats stats; 220607ca46eSDavid Howells }; 221607ca46eSDavid Howells 222607ca46eSDavid Howells 223607ca46eSDavid Howells struct tc_sfq_xstats { 224607ca46eSDavid Howells __s32 allot; 225607ca46eSDavid Howells }; 226607ca46eSDavid Howells 227607ca46eSDavid Howells /* RED section */ 228607ca46eSDavid Howells 229607ca46eSDavid Howells enum { 230607ca46eSDavid Howells TCA_RED_UNSPEC, 231607ca46eSDavid Howells TCA_RED_PARMS, 232607ca46eSDavid Howells TCA_RED_STAB, 233607ca46eSDavid Howells TCA_RED_MAX_P, 234607ca46eSDavid Howells __TCA_RED_MAX, 235607ca46eSDavid Howells }; 236607ca46eSDavid Howells 237607ca46eSDavid Howells #define TCA_RED_MAX (__TCA_RED_MAX - 1) 238607ca46eSDavid Howells 239607ca46eSDavid Howells struct tc_red_qopt { 240607ca46eSDavid Howells __u32 limit; /* HARD maximal queue length (bytes) */ 241607ca46eSDavid Howells __u32 qth_min; /* Min average length threshold (bytes) */ 242607ca46eSDavid Howells __u32 qth_max; /* Max average length threshold (bytes) */ 243607ca46eSDavid Howells unsigned char Wlog; /* log(W) */ 244607ca46eSDavid Howells unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ 245607ca46eSDavid Howells unsigned char Scell_log; /* cell size for idle damping */ 246607ca46eSDavid Howells unsigned char flags; 247607ca46eSDavid Howells #define TC_RED_ECN 1 248607ca46eSDavid Howells #define TC_RED_HARDDROP 2 249607ca46eSDavid Howells #define TC_RED_ADAPTATIVE 4 250607ca46eSDavid Howells }; 251607ca46eSDavid Howells 252607ca46eSDavid Howells struct tc_red_xstats { 253607ca46eSDavid Howells __u32 early; /* Early drops */ 254607ca46eSDavid Howells __u32 pdrop; /* Drops due to queue limits */ 255607ca46eSDavid Howells __u32 other; /* Drops due to drop() calls */ 256607ca46eSDavid Howells __u32 marked; /* Marked packets */ 257607ca46eSDavid Howells }; 258607ca46eSDavid Howells 259607ca46eSDavid Howells /* GRED section */ 260607ca46eSDavid Howells 261607ca46eSDavid Howells #define MAX_DPs 16 262607ca46eSDavid Howells 263607ca46eSDavid Howells enum { 264607ca46eSDavid Howells TCA_GRED_UNSPEC, 265607ca46eSDavid Howells TCA_GRED_PARMS, 266607ca46eSDavid Howells TCA_GRED_STAB, 267607ca46eSDavid Howells TCA_GRED_DPS, 268607ca46eSDavid Howells TCA_GRED_MAX_P, 269607ca46eSDavid Howells __TCA_GRED_MAX, 270607ca46eSDavid Howells }; 271607ca46eSDavid Howells 272607ca46eSDavid Howells #define TCA_GRED_MAX (__TCA_GRED_MAX - 1) 273607ca46eSDavid Howells 274607ca46eSDavid Howells struct tc_gred_qopt { 275607ca46eSDavid Howells __u32 limit; /* HARD maximal queue length (bytes) */ 276607ca46eSDavid Howells __u32 qth_min; /* Min average length threshold (bytes) */ 277607ca46eSDavid Howells __u32 qth_max; /* Max average length threshold (bytes) */ 278607ca46eSDavid Howells __u32 DP; /* up to 2^32 DPs */ 279607ca46eSDavid Howells __u32 backlog; 280607ca46eSDavid Howells __u32 qave; 281607ca46eSDavid Howells __u32 forced; 282607ca46eSDavid Howells __u32 early; 283607ca46eSDavid Howells __u32 other; 284607ca46eSDavid Howells __u32 pdrop; 285607ca46eSDavid Howells __u8 Wlog; /* log(W) */ 286607ca46eSDavid Howells __u8 Plog; /* log(P_max/(qth_max-qth_min)) */ 287607ca46eSDavid Howells __u8 Scell_log; /* cell size for idle damping */ 288607ca46eSDavid Howells __u8 prio; /* prio of this VQ */ 289607ca46eSDavid Howells __u32 packets; 290607ca46eSDavid Howells __u32 bytesin; 291607ca46eSDavid Howells }; 292607ca46eSDavid Howells 293607ca46eSDavid Howells /* gred setup */ 294607ca46eSDavid Howells struct tc_gred_sopt { 295607ca46eSDavid Howells __u32 DPs; 296607ca46eSDavid Howells __u32 def_DP; 297607ca46eSDavid Howells __u8 grio; 298607ca46eSDavid Howells __u8 flags; 299607ca46eSDavid Howells __u16 pad1; 300607ca46eSDavid Howells }; 301607ca46eSDavid Howells 302607ca46eSDavid Howells /* CHOKe section */ 303607ca46eSDavid Howells 304607ca46eSDavid Howells enum { 305607ca46eSDavid Howells TCA_CHOKE_UNSPEC, 306607ca46eSDavid Howells TCA_CHOKE_PARMS, 307607ca46eSDavid Howells TCA_CHOKE_STAB, 308607ca46eSDavid Howells TCA_CHOKE_MAX_P, 309607ca46eSDavid Howells __TCA_CHOKE_MAX, 310607ca46eSDavid Howells }; 311607ca46eSDavid Howells 312607ca46eSDavid Howells #define TCA_CHOKE_MAX (__TCA_CHOKE_MAX - 1) 313607ca46eSDavid Howells 314607ca46eSDavid Howells struct tc_choke_qopt { 315607ca46eSDavid Howells __u32 limit; /* Hard queue length (packets) */ 316607ca46eSDavid Howells __u32 qth_min; /* Min average threshold (packets) */ 317607ca46eSDavid Howells __u32 qth_max; /* Max average threshold (packets) */ 318607ca46eSDavid Howells unsigned char Wlog; /* log(W) */ 319607ca46eSDavid Howells unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ 320607ca46eSDavid Howells unsigned char Scell_log; /* cell size for idle damping */ 321607ca46eSDavid Howells unsigned char flags; /* see RED flags */ 322607ca46eSDavid Howells }; 323607ca46eSDavid Howells 324607ca46eSDavid Howells struct tc_choke_xstats { 325607ca46eSDavid Howells __u32 early; /* Early drops */ 326607ca46eSDavid Howells __u32 pdrop; /* Drops due to queue limits */ 327607ca46eSDavid Howells __u32 other; /* Drops due to drop() calls */ 328607ca46eSDavid Howells __u32 marked; /* Marked packets */ 329607ca46eSDavid Howells __u32 matched; /* Drops due to flow match */ 330607ca46eSDavid Howells }; 331607ca46eSDavid Howells 332607ca46eSDavid Howells /* HTB section */ 333607ca46eSDavid Howells #define TC_HTB_NUMPRIO 8 334607ca46eSDavid Howells #define TC_HTB_MAXDEPTH 8 335607ca46eSDavid Howells #define TC_HTB_PROTOVER 3 /* the same as HTB and TC's major */ 336607ca46eSDavid Howells 337607ca46eSDavid Howells struct tc_htb_opt { 338607ca46eSDavid Howells struct tc_ratespec rate; 339607ca46eSDavid Howells struct tc_ratespec ceil; 340607ca46eSDavid Howells __u32 buffer; 341607ca46eSDavid Howells __u32 cbuffer; 342607ca46eSDavid Howells __u32 quantum; 343607ca46eSDavid Howells __u32 level; /* out only */ 344607ca46eSDavid Howells __u32 prio; 345607ca46eSDavid Howells }; 346607ca46eSDavid Howells struct tc_htb_glob { 347607ca46eSDavid Howells __u32 version; /* to match HTB/TC */ 348607ca46eSDavid Howells __u32 rate2quantum; /* bps->quantum divisor */ 349607ca46eSDavid Howells __u32 defcls; /* default class number */ 350607ca46eSDavid Howells __u32 debug; /* debug flags */ 351607ca46eSDavid Howells 352607ca46eSDavid Howells /* stats */ 353607ca46eSDavid Howells __u32 direct_pkts; /* count of non shaped packets */ 354607ca46eSDavid Howells }; 355607ca46eSDavid Howells enum { 356607ca46eSDavid Howells TCA_HTB_UNSPEC, 357607ca46eSDavid Howells TCA_HTB_PARMS, 358607ca46eSDavid Howells TCA_HTB_INIT, 359607ca46eSDavid Howells TCA_HTB_CTAB, 360607ca46eSDavid Howells TCA_HTB_RTAB, 3616906f4edSEric Dumazet TCA_HTB_DIRECT_QLEN, 362df62cdf3SEric Dumazet TCA_HTB_RATE64, 363df62cdf3SEric Dumazet TCA_HTB_CEIL64, 364607ca46eSDavid Howells __TCA_HTB_MAX, 365607ca46eSDavid Howells }; 366607ca46eSDavid Howells 367607ca46eSDavid Howells #define TCA_HTB_MAX (__TCA_HTB_MAX - 1) 368607ca46eSDavid Howells 369607ca46eSDavid Howells struct tc_htb_xstats { 370607ca46eSDavid Howells __u32 lends; 371607ca46eSDavid Howells __u32 borrows; 372607ca46eSDavid Howells __u32 giants; /* too big packets (rate will not be accurate) */ 373607ca46eSDavid Howells __u32 tokens; 374607ca46eSDavid Howells __u32 ctokens; 375607ca46eSDavid Howells }; 376607ca46eSDavid Howells 377607ca46eSDavid Howells /* HFSC section */ 378607ca46eSDavid Howells 379607ca46eSDavid Howells struct tc_hfsc_qopt { 380607ca46eSDavid Howells __u16 defcls; /* default class */ 381607ca46eSDavid Howells }; 382607ca46eSDavid Howells 383607ca46eSDavid Howells struct tc_service_curve { 384607ca46eSDavid Howells __u32 m1; /* slope of the first segment in bps */ 385607ca46eSDavid Howells __u32 d; /* x-projection of the first segment in us */ 386607ca46eSDavid Howells __u32 m2; /* slope of the second segment in bps */ 387607ca46eSDavid Howells }; 388607ca46eSDavid Howells 389607ca46eSDavid Howells struct tc_hfsc_stats { 390607ca46eSDavid Howells __u64 work; /* total work done */ 391607ca46eSDavid Howells __u64 rtwork; /* work done by real-time criteria */ 392607ca46eSDavid Howells __u32 period; /* current period */ 393607ca46eSDavid Howells __u32 level; /* class level in hierarchy */ 394607ca46eSDavid Howells }; 395607ca46eSDavid Howells 396607ca46eSDavid Howells enum { 397607ca46eSDavid Howells TCA_HFSC_UNSPEC, 398607ca46eSDavid Howells TCA_HFSC_RSC, 399607ca46eSDavid Howells TCA_HFSC_FSC, 400607ca46eSDavid Howells TCA_HFSC_USC, 401607ca46eSDavid Howells __TCA_HFSC_MAX, 402607ca46eSDavid Howells }; 403607ca46eSDavid Howells 404607ca46eSDavid Howells #define TCA_HFSC_MAX (__TCA_HFSC_MAX - 1) 405607ca46eSDavid Howells 406607ca46eSDavid Howells 407607ca46eSDavid Howells /* CBQ section */ 408607ca46eSDavid Howells 409607ca46eSDavid Howells #define TC_CBQ_MAXPRIO 8 410607ca46eSDavid Howells #define TC_CBQ_MAXLEVEL 8 411607ca46eSDavid Howells #define TC_CBQ_DEF_EWMA 5 412607ca46eSDavid Howells 413607ca46eSDavid Howells struct tc_cbq_lssopt { 414607ca46eSDavid Howells unsigned char change; 415607ca46eSDavid Howells unsigned char flags; 416607ca46eSDavid Howells #define TCF_CBQ_LSS_BOUNDED 1 417607ca46eSDavid Howells #define TCF_CBQ_LSS_ISOLATED 2 418607ca46eSDavid Howells unsigned char ewma_log; 419607ca46eSDavid Howells unsigned char level; 420607ca46eSDavid Howells #define TCF_CBQ_LSS_FLAGS 1 421607ca46eSDavid Howells #define TCF_CBQ_LSS_EWMA 2 422607ca46eSDavid Howells #define TCF_CBQ_LSS_MAXIDLE 4 423607ca46eSDavid Howells #define TCF_CBQ_LSS_MINIDLE 8 424607ca46eSDavid Howells #define TCF_CBQ_LSS_OFFTIME 0x10 425607ca46eSDavid Howells #define TCF_CBQ_LSS_AVPKT 0x20 426607ca46eSDavid Howells __u32 maxidle; 427607ca46eSDavid Howells __u32 minidle; 428607ca46eSDavid Howells __u32 offtime; 429607ca46eSDavid Howells __u32 avpkt; 430607ca46eSDavid Howells }; 431607ca46eSDavid Howells 432607ca46eSDavid Howells struct tc_cbq_wrropt { 433607ca46eSDavid Howells unsigned char flags; 434607ca46eSDavid Howells unsigned char priority; 435607ca46eSDavid Howells unsigned char cpriority; 436607ca46eSDavid Howells unsigned char __reserved; 437607ca46eSDavid Howells __u32 allot; 438607ca46eSDavid Howells __u32 weight; 439607ca46eSDavid Howells }; 440607ca46eSDavid Howells 441607ca46eSDavid Howells struct tc_cbq_ovl { 442607ca46eSDavid Howells unsigned char strategy; 443607ca46eSDavid Howells #define TC_CBQ_OVL_CLASSIC 0 444607ca46eSDavid Howells #define TC_CBQ_OVL_DELAY 1 445607ca46eSDavid Howells #define TC_CBQ_OVL_LOWPRIO 2 446607ca46eSDavid Howells #define TC_CBQ_OVL_DROP 3 447607ca46eSDavid Howells #define TC_CBQ_OVL_RCLASSIC 4 448607ca46eSDavid Howells unsigned char priority2; 449607ca46eSDavid Howells __u16 pad; 450607ca46eSDavid Howells __u32 penalty; 451607ca46eSDavid Howells }; 452607ca46eSDavid Howells 453607ca46eSDavid Howells struct tc_cbq_police { 454607ca46eSDavid Howells unsigned char police; 455607ca46eSDavid Howells unsigned char __res1; 456607ca46eSDavid Howells unsigned short __res2; 457607ca46eSDavid Howells }; 458607ca46eSDavid Howells 459607ca46eSDavid Howells struct tc_cbq_fopt { 460607ca46eSDavid Howells __u32 split; 461607ca46eSDavid Howells __u32 defmap; 462607ca46eSDavid Howells __u32 defchange; 463607ca46eSDavid Howells }; 464607ca46eSDavid Howells 465607ca46eSDavid Howells struct tc_cbq_xstats { 466607ca46eSDavid Howells __u32 borrows; 467607ca46eSDavid Howells __u32 overactions; 468607ca46eSDavid Howells __s32 avgidle; 469607ca46eSDavid Howells __s32 undertime; 470607ca46eSDavid Howells }; 471607ca46eSDavid Howells 472607ca46eSDavid Howells enum { 473607ca46eSDavid Howells TCA_CBQ_UNSPEC, 474607ca46eSDavid Howells TCA_CBQ_LSSOPT, 475607ca46eSDavid Howells TCA_CBQ_WRROPT, 476607ca46eSDavid Howells TCA_CBQ_FOPT, 477607ca46eSDavid Howells TCA_CBQ_OVL_STRATEGY, 478607ca46eSDavid Howells TCA_CBQ_RATE, 479607ca46eSDavid Howells TCA_CBQ_RTAB, 480607ca46eSDavid Howells TCA_CBQ_POLICE, 481607ca46eSDavid Howells __TCA_CBQ_MAX, 482607ca46eSDavid Howells }; 483607ca46eSDavid Howells 484607ca46eSDavid Howells #define TCA_CBQ_MAX (__TCA_CBQ_MAX - 1) 485607ca46eSDavid Howells 486607ca46eSDavid Howells /* dsmark section */ 487607ca46eSDavid Howells 488607ca46eSDavid Howells enum { 489607ca46eSDavid Howells TCA_DSMARK_UNSPEC, 490607ca46eSDavid Howells TCA_DSMARK_INDICES, 491607ca46eSDavid Howells TCA_DSMARK_DEFAULT_INDEX, 492607ca46eSDavid Howells TCA_DSMARK_SET_TC_INDEX, 493607ca46eSDavid Howells TCA_DSMARK_MASK, 494607ca46eSDavid Howells TCA_DSMARK_VALUE, 495607ca46eSDavid Howells __TCA_DSMARK_MAX, 496607ca46eSDavid Howells }; 497607ca46eSDavid Howells 498607ca46eSDavid Howells #define TCA_DSMARK_MAX (__TCA_DSMARK_MAX - 1) 499607ca46eSDavid Howells 500607ca46eSDavid Howells /* ATM section */ 501607ca46eSDavid Howells 502607ca46eSDavid Howells enum { 503607ca46eSDavid Howells TCA_ATM_UNSPEC, 504607ca46eSDavid Howells TCA_ATM_FD, /* file/socket descriptor */ 505607ca46eSDavid Howells TCA_ATM_PTR, /* pointer to descriptor - later */ 506607ca46eSDavid Howells TCA_ATM_HDR, /* LL header */ 507607ca46eSDavid Howells TCA_ATM_EXCESS, /* excess traffic class (0 for CLP) */ 508607ca46eSDavid Howells TCA_ATM_ADDR, /* PVC address (for output only) */ 509607ca46eSDavid Howells TCA_ATM_STATE, /* VC state (ATM_VS_*; for output only) */ 510607ca46eSDavid Howells __TCA_ATM_MAX, 511607ca46eSDavid Howells }; 512607ca46eSDavid Howells 513607ca46eSDavid Howells #define TCA_ATM_MAX (__TCA_ATM_MAX - 1) 514607ca46eSDavid Howells 515607ca46eSDavid Howells /* Network emulator */ 516607ca46eSDavid Howells 517607ca46eSDavid Howells enum { 518607ca46eSDavid Howells TCA_NETEM_UNSPEC, 519607ca46eSDavid Howells TCA_NETEM_CORR, 520607ca46eSDavid Howells TCA_NETEM_DELAY_DIST, 521607ca46eSDavid Howells TCA_NETEM_REORDER, 522607ca46eSDavid Howells TCA_NETEM_CORRUPT, 523607ca46eSDavid Howells TCA_NETEM_LOSS, 524607ca46eSDavid Howells TCA_NETEM_RATE, 525607ca46eSDavid Howells TCA_NETEM_ECN, 526607ca46eSDavid Howells __TCA_NETEM_MAX, 527607ca46eSDavid Howells }; 528607ca46eSDavid Howells 529607ca46eSDavid Howells #define TCA_NETEM_MAX (__TCA_NETEM_MAX - 1) 530607ca46eSDavid Howells 531607ca46eSDavid Howells struct tc_netem_qopt { 532607ca46eSDavid Howells __u32 latency; /* added delay (us) */ 533607ca46eSDavid Howells __u32 limit; /* fifo limit (packets) */ 534607ca46eSDavid Howells __u32 loss; /* random packet loss (0=none ~0=100%) */ 535607ca46eSDavid Howells __u32 gap; /* re-ordering gap (0 for none) */ 536607ca46eSDavid Howells __u32 duplicate; /* random packet dup (0=none ~0=100%) */ 537607ca46eSDavid Howells __u32 jitter; /* random jitter in latency (us) */ 538607ca46eSDavid Howells }; 539607ca46eSDavid Howells 540607ca46eSDavid Howells struct tc_netem_corr { 541607ca46eSDavid Howells __u32 delay_corr; /* delay correlation */ 542607ca46eSDavid Howells __u32 loss_corr; /* packet loss correlation */ 543607ca46eSDavid Howells __u32 dup_corr; /* duplicate correlation */ 544607ca46eSDavid Howells }; 545607ca46eSDavid Howells 546607ca46eSDavid Howells struct tc_netem_reorder { 547607ca46eSDavid Howells __u32 probability; 548607ca46eSDavid Howells __u32 correlation; 549607ca46eSDavid Howells }; 550607ca46eSDavid Howells 551607ca46eSDavid Howells struct tc_netem_corrupt { 552607ca46eSDavid Howells __u32 probability; 553607ca46eSDavid Howells __u32 correlation; 554607ca46eSDavid Howells }; 555607ca46eSDavid Howells 556607ca46eSDavid Howells struct tc_netem_rate { 557607ca46eSDavid Howells __u32 rate; /* byte/s */ 558607ca46eSDavid Howells __s32 packet_overhead; 559607ca46eSDavid Howells __u32 cell_size; 560607ca46eSDavid Howells __s32 cell_overhead; 561607ca46eSDavid Howells }; 562607ca46eSDavid Howells 563607ca46eSDavid Howells enum { 564607ca46eSDavid Howells NETEM_LOSS_UNSPEC, 565607ca46eSDavid Howells NETEM_LOSS_GI, /* General Intuitive - 4 state model */ 566607ca46eSDavid Howells NETEM_LOSS_GE, /* Gilbert Elliot models */ 567607ca46eSDavid Howells __NETEM_LOSS_MAX 568607ca46eSDavid Howells }; 569607ca46eSDavid Howells #define NETEM_LOSS_MAX (__NETEM_LOSS_MAX - 1) 570607ca46eSDavid Howells 571607ca46eSDavid Howells /* State transition probabilities for 4 state model */ 572607ca46eSDavid Howells struct tc_netem_gimodel { 573607ca46eSDavid Howells __u32 p13; 574607ca46eSDavid Howells __u32 p31; 575607ca46eSDavid Howells __u32 p32; 576607ca46eSDavid Howells __u32 p14; 577607ca46eSDavid Howells __u32 p23; 578607ca46eSDavid Howells }; 579607ca46eSDavid Howells 580607ca46eSDavid Howells /* Gilbert-Elliot models */ 581607ca46eSDavid Howells struct tc_netem_gemodel { 582607ca46eSDavid Howells __u32 p; 583607ca46eSDavid Howells __u32 r; 584607ca46eSDavid Howells __u32 h; 585607ca46eSDavid Howells __u32 k1; 586607ca46eSDavid Howells }; 587607ca46eSDavid Howells 588607ca46eSDavid Howells #define NETEM_DIST_SCALE 8192 589607ca46eSDavid Howells #define NETEM_DIST_MAX 16384 590607ca46eSDavid Howells 591607ca46eSDavid Howells /* DRR */ 592607ca46eSDavid Howells 593607ca46eSDavid Howells enum { 594607ca46eSDavid Howells TCA_DRR_UNSPEC, 595607ca46eSDavid Howells TCA_DRR_QUANTUM, 596607ca46eSDavid Howells __TCA_DRR_MAX 597607ca46eSDavid Howells }; 598607ca46eSDavid Howells 599607ca46eSDavid Howells #define TCA_DRR_MAX (__TCA_DRR_MAX - 1) 600607ca46eSDavid Howells 601607ca46eSDavid Howells struct tc_drr_stats { 602607ca46eSDavid Howells __u32 deficit; 603607ca46eSDavid Howells }; 604607ca46eSDavid Howells 605607ca46eSDavid Howells /* MQPRIO */ 606607ca46eSDavid Howells #define TC_QOPT_BITMASK 15 607607ca46eSDavid Howells #define TC_QOPT_MAX_QUEUE 16 608607ca46eSDavid Howells 609607ca46eSDavid Howells struct tc_mqprio_qopt { 610607ca46eSDavid Howells __u8 num_tc; 611607ca46eSDavid Howells __u8 prio_tc_map[TC_QOPT_BITMASK + 1]; 612607ca46eSDavid Howells __u8 hw; 613607ca46eSDavid Howells __u16 count[TC_QOPT_MAX_QUEUE]; 614607ca46eSDavid Howells __u16 offset[TC_QOPT_MAX_QUEUE]; 615607ca46eSDavid Howells }; 616607ca46eSDavid Howells 617607ca46eSDavid Howells /* SFB */ 618607ca46eSDavid Howells 619607ca46eSDavid Howells enum { 620607ca46eSDavid Howells TCA_SFB_UNSPEC, 621607ca46eSDavid Howells TCA_SFB_PARMS, 622607ca46eSDavid Howells __TCA_SFB_MAX, 623607ca46eSDavid Howells }; 624607ca46eSDavid Howells 625607ca46eSDavid Howells #define TCA_SFB_MAX (__TCA_SFB_MAX - 1) 626607ca46eSDavid Howells 627607ca46eSDavid Howells /* 628607ca46eSDavid Howells * Note: increment, decrement are Q0.16 fixed-point values. 629607ca46eSDavid Howells */ 630607ca46eSDavid Howells struct tc_sfb_qopt { 631607ca46eSDavid Howells __u32 rehash_interval; /* delay between hash move, in ms */ 632607ca46eSDavid Howells __u32 warmup_time; /* double buffering warmup time in ms (warmup_time < rehash_interval) */ 633607ca46eSDavid Howells __u32 max; /* max len of qlen_min */ 634607ca46eSDavid Howells __u32 bin_size; /* maximum queue length per bin */ 635607ca46eSDavid Howells __u32 increment; /* probability increment, (d1 in Blue) */ 636607ca46eSDavid Howells __u32 decrement; /* probability decrement, (d2 in Blue) */ 637607ca46eSDavid Howells __u32 limit; /* max SFB queue length */ 638607ca46eSDavid Howells __u32 penalty_rate; /* inelastic flows are rate limited to 'rate' pps */ 639607ca46eSDavid Howells __u32 penalty_burst; 640607ca46eSDavid Howells }; 641607ca46eSDavid Howells 642607ca46eSDavid Howells struct tc_sfb_xstats { 643607ca46eSDavid Howells __u32 earlydrop; 644607ca46eSDavid Howells __u32 penaltydrop; 645607ca46eSDavid Howells __u32 bucketdrop; 646607ca46eSDavid Howells __u32 queuedrop; 647607ca46eSDavid Howells __u32 childdrop; /* drops in child qdisc */ 648607ca46eSDavid Howells __u32 marked; 649607ca46eSDavid Howells __u32 maxqlen; 650607ca46eSDavid Howells __u32 maxprob; 651607ca46eSDavid Howells __u32 avgprob; 652607ca46eSDavid Howells }; 653607ca46eSDavid Howells 654607ca46eSDavid Howells #define SFB_MAX_PROB 0xFFFF 655607ca46eSDavid Howells 656607ca46eSDavid Howells /* QFQ */ 657607ca46eSDavid Howells enum { 658607ca46eSDavid Howells TCA_QFQ_UNSPEC, 659607ca46eSDavid Howells TCA_QFQ_WEIGHT, 660607ca46eSDavid Howells TCA_QFQ_LMAX, 661607ca46eSDavid Howells __TCA_QFQ_MAX 662607ca46eSDavid Howells }; 663607ca46eSDavid Howells 664607ca46eSDavid Howells #define TCA_QFQ_MAX (__TCA_QFQ_MAX - 1) 665607ca46eSDavid Howells 666607ca46eSDavid Howells struct tc_qfq_stats { 667607ca46eSDavid Howells __u32 weight; 668607ca46eSDavid Howells __u32 lmax; 669607ca46eSDavid Howells }; 670607ca46eSDavid Howells 671607ca46eSDavid Howells /* CODEL */ 672607ca46eSDavid Howells 673607ca46eSDavid Howells enum { 674607ca46eSDavid Howells TCA_CODEL_UNSPEC, 675607ca46eSDavid Howells TCA_CODEL_TARGET, 676607ca46eSDavid Howells TCA_CODEL_LIMIT, 677607ca46eSDavid Howells TCA_CODEL_INTERVAL, 678607ca46eSDavid Howells TCA_CODEL_ECN, 679607ca46eSDavid Howells __TCA_CODEL_MAX 680607ca46eSDavid Howells }; 681607ca46eSDavid Howells 682607ca46eSDavid Howells #define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1) 683607ca46eSDavid Howells 684607ca46eSDavid Howells struct tc_codel_xstats { 685607ca46eSDavid Howells __u32 maxpacket; /* largest packet we've seen so far */ 686607ca46eSDavid Howells __u32 count; /* how many drops we've done since the last time we 687607ca46eSDavid Howells * entered dropping state 688607ca46eSDavid Howells */ 689607ca46eSDavid Howells __u32 lastcount; /* count at entry to dropping state */ 690607ca46eSDavid Howells __u32 ldelay; /* in-queue delay seen by most recently dequeued packet */ 691607ca46eSDavid Howells __s32 drop_next; /* time to drop next packet */ 692607ca46eSDavid Howells __u32 drop_overlimit; /* number of time max qdisc packet limit was hit */ 693607ca46eSDavid Howells __u32 ecn_mark; /* number of packets we ECN marked instead of dropped */ 694607ca46eSDavid Howells __u32 dropping; /* are we in dropping state ? */ 695607ca46eSDavid Howells }; 696607ca46eSDavid Howells 697607ca46eSDavid Howells /* FQ_CODEL */ 698607ca46eSDavid Howells 699607ca46eSDavid Howells enum { 700607ca46eSDavid Howells TCA_FQ_CODEL_UNSPEC, 701607ca46eSDavid Howells TCA_FQ_CODEL_TARGET, 702607ca46eSDavid Howells TCA_FQ_CODEL_LIMIT, 703607ca46eSDavid Howells TCA_FQ_CODEL_INTERVAL, 704607ca46eSDavid Howells TCA_FQ_CODEL_ECN, 705607ca46eSDavid Howells TCA_FQ_CODEL_FLOWS, 706607ca46eSDavid Howells TCA_FQ_CODEL_QUANTUM, 707607ca46eSDavid Howells __TCA_FQ_CODEL_MAX 708607ca46eSDavid Howells }; 709607ca46eSDavid Howells 710607ca46eSDavid Howells #define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1) 711607ca46eSDavid Howells 712607ca46eSDavid Howells enum { 713607ca46eSDavid Howells TCA_FQ_CODEL_XSTATS_QDISC, 714607ca46eSDavid Howells TCA_FQ_CODEL_XSTATS_CLASS, 715607ca46eSDavid Howells }; 716607ca46eSDavid Howells 717607ca46eSDavid Howells struct tc_fq_codel_qd_stats { 718607ca46eSDavid Howells __u32 maxpacket; /* largest packet we've seen so far */ 719607ca46eSDavid Howells __u32 drop_overlimit; /* number of time max qdisc 720607ca46eSDavid Howells * packet limit was hit 721607ca46eSDavid Howells */ 722607ca46eSDavid Howells __u32 ecn_mark; /* number of packets we ECN marked 723607ca46eSDavid Howells * instead of being dropped 724607ca46eSDavid Howells */ 725607ca46eSDavid Howells __u32 new_flow_count; /* number of time packets 726607ca46eSDavid Howells * created a 'new flow' 727607ca46eSDavid Howells */ 728607ca46eSDavid Howells __u32 new_flows_len; /* count of flows in new list */ 729607ca46eSDavid Howells __u32 old_flows_len; /* count of flows in old list */ 730607ca46eSDavid Howells }; 731607ca46eSDavid Howells 732607ca46eSDavid Howells struct tc_fq_codel_cl_stats { 733607ca46eSDavid Howells __s32 deficit; 734607ca46eSDavid Howells __u32 ldelay; /* in-queue delay seen by most recently 735607ca46eSDavid Howells * dequeued packet 736607ca46eSDavid Howells */ 737607ca46eSDavid Howells __u32 count; 738607ca46eSDavid Howells __u32 lastcount; 739607ca46eSDavid Howells __u32 dropping; 740607ca46eSDavid Howells __s32 drop_next; 741607ca46eSDavid Howells }; 742607ca46eSDavid Howells 743607ca46eSDavid Howells struct tc_fq_codel_xstats { 744607ca46eSDavid Howells __u32 type; 745607ca46eSDavid Howells union { 746607ca46eSDavid Howells struct tc_fq_codel_qd_stats qdisc_stats; 747607ca46eSDavid Howells struct tc_fq_codel_cl_stats class_stats; 748607ca46eSDavid Howells }; 749607ca46eSDavid Howells }; 750607ca46eSDavid Howells 751afe4fd06SEric Dumazet /* FQ */ 752afe4fd06SEric Dumazet 753afe4fd06SEric Dumazet enum { 754afe4fd06SEric Dumazet TCA_FQ_UNSPEC, 755afe4fd06SEric Dumazet 756afe4fd06SEric Dumazet TCA_FQ_PLIMIT, /* limit of total number of packets in queue */ 757afe4fd06SEric Dumazet 758afe4fd06SEric Dumazet TCA_FQ_FLOW_PLIMIT, /* limit of packets per flow */ 759afe4fd06SEric Dumazet 760afe4fd06SEric Dumazet TCA_FQ_QUANTUM, /* RR quantum */ 761afe4fd06SEric Dumazet 762afe4fd06SEric Dumazet TCA_FQ_INITIAL_QUANTUM, /* RR quantum for new flow */ 763afe4fd06SEric Dumazet 764afe4fd06SEric Dumazet TCA_FQ_RATE_ENABLE, /* enable/disable rate limiting */ 765afe4fd06SEric Dumazet 766afe4fd06SEric Dumazet TCA_FQ_FLOW_DEFAULT_RATE,/* for sockets with unspecified sk_rate, 767afe4fd06SEric Dumazet * use the following rate 768afe4fd06SEric Dumazet */ 769afe4fd06SEric Dumazet 770afe4fd06SEric Dumazet TCA_FQ_FLOW_MAX_RATE, /* per flow max rate */ 771afe4fd06SEric Dumazet 772afe4fd06SEric Dumazet TCA_FQ_BUCKETS_LOG, /* log2(number of buckets) */ 773afe4fd06SEric Dumazet __TCA_FQ_MAX 774afe4fd06SEric Dumazet }; 775afe4fd06SEric Dumazet 776afe4fd06SEric Dumazet #define TCA_FQ_MAX (__TCA_FQ_MAX - 1) 777afe4fd06SEric Dumazet 778afe4fd06SEric Dumazet struct tc_fq_qd_stats { 779afe4fd06SEric Dumazet __u64 gc_flows; 780afe4fd06SEric Dumazet __u64 highprio_packets; 781afe4fd06SEric Dumazet __u64 tcp_retrans; 782afe4fd06SEric Dumazet __u64 throttled; 783afe4fd06SEric Dumazet __u64 flows_plimit; 784afe4fd06SEric Dumazet __u64 pkts_too_long; 785afe4fd06SEric Dumazet __u64 allocation_errors; 786afe4fd06SEric Dumazet __s64 time_next_delayed_flow; 787afe4fd06SEric Dumazet __u32 flows; 788afe4fd06SEric Dumazet __u32 inactive_flows; 789afe4fd06SEric Dumazet __u32 throttled_flows; 790afe4fd06SEric Dumazet __u32 pad; 791afe4fd06SEric Dumazet }; 792607ca46eSDavid Howells #endif 793