codel_qdisc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef __NET_SCHED_CODEL_QDISC_H
  2. #define __NET_SCHED_CODEL_QDISC_H
  3. /*
  4. * Codel - The Controlled-Delay Active Queue Management algorithm
  5. *
  6. * Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
  7. * Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
  8. * Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
  9. * Copyright (C) 2012,2015 Eric Dumazet <edumazet@google.com>
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. The names of the authors may not be used to endorse or promote products
  21. * derived from this software without specific prior written permission.
  22. *
  23. * Alternatively, provided that this notice is retained in full, this
  24. * software may be distributed under the terms of the GNU General
  25. * Public License ("GPL") version 2, in which case the provisions of the
  26. * GPL apply INSTEAD OF those given above.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  39. * DAMAGE.
  40. *
  41. */
  42. /* Controlling Queue Delay (CoDel) algorithm
  43. * =========================================
  44. * Source : Kathleen Nichols and Van Jacobson
  45. * http://queue.acm.org/detail.cfm?id=2209336
  46. *
  47. * Implemented on linux by Dave Taht and Eric Dumazet
  48. */
  49. /* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */
  50. struct codel_skb_cb {
  51. codel_time_t enqueue_time;
  52. unsigned int mem_usage;
  53. };
  54. static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
  55. {
  56. qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb));
  57. return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data;
  58. }
  59. static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb)
  60. {
  61. return get_codel_cb(skb)->enqueue_time;
  62. }
  63. static void codel_set_enqueue_time(struct sk_buff *skb)
  64. {
  65. get_codel_cb(skb)->enqueue_time = codel_get_time();
  66. }
  67. #endif