Back to home page

OSCL-LXR

 
 

    


0001 #ifndef __NET_SCHED_CODEL_QDISC_H
0002 #define __NET_SCHED_CODEL_QDISC_H
0003 
0004 /*
0005  * Codel - The Controlled-Delay Active Queue Management algorithm
0006  *
0007  *  Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
0008  *  Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
0009  *  Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
0010  *  Copyright (C) 2012,2015 Eric Dumazet <edumazet@google.com>
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions, and the following disclaimer,
0017  *    without modification.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  * 3. The names of the authors may not be used to endorse or promote products
0022  *    derived from this software without specific prior written permission.
0023  *
0024  * Alternatively, provided that this notice is retained in full, this
0025  * software may be distributed under the terms of the GNU General
0026  * Public License ("GPL") version 2, in which case the provisions of the
0027  * GPL apply INSTEAD OF those given above.
0028  *
0029  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0030  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0031  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0032  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0033  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0034  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0035  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0036  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0037  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0038  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0039  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
0040  * DAMAGE.
0041  *
0042  */
0043 
0044 /* Controlling Queue Delay (CoDel) algorithm
0045  * =========================================
0046  * Source : Kathleen Nichols and Van Jacobson
0047  * http://queue.acm.org/detail.cfm?id=2209336
0048  *
0049  * Implemented on linux by Dave Taht and Eric Dumazet
0050  */
0051 
0052 #include <net/codel.h>
0053 #include <net/pkt_sched.h>
0054 
0055 /* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */
0056 struct codel_skb_cb {
0057     codel_time_t enqueue_time;
0058     unsigned int mem_usage;
0059 };
0060 
0061 static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
0062 {
0063     qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb));
0064     return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data;
0065 }
0066 
0067 static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb)
0068 {
0069     return get_codel_cb(skb)->enqueue_time;
0070 }
0071 
0072 static void codel_set_enqueue_time(struct sk_buff *skb)
0073 {
0074     get_codel_cb(skb)->enqueue_time = codel_get_time();
0075 }
0076 
0077 #endif