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