pkt_sched.h 9.6 KB

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