18c2ecf20Sopenharmony_ci#ifndef __NET_SCHED_CODEL_QDISC_H
28c2ecf20Sopenharmony_ci#define __NET_SCHED_CODEL_QDISC_H
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * Codel - The Controlled-Delay Active Queue Management algorithm
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
88c2ecf20Sopenharmony_ci *  Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
98c2ecf20Sopenharmony_ci *  Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
108c2ecf20Sopenharmony_ci *  Copyright (C) 2012,2015 Eric Dumazet <edumazet@google.com>
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
138c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
148c2ecf20Sopenharmony_ci * are met:
158c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
168c2ecf20Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
178c2ecf20Sopenharmony_ci *    without modification.
188c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
198c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
208c2ecf20Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
218c2ecf20Sopenharmony_ci * 3. The names of the authors may not be used to endorse or promote products
228c2ecf20Sopenharmony_ci *    derived from this software without specific prior written permission.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * Alternatively, provided that this notice is retained in full, this
258c2ecf20Sopenharmony_ci * software may be distributed under the terms of the GNU General
268c2ecf20Sopenharmony_ci * Public License ("GPL") version 2, in which case the provisions of the
278c2ecf20Sopenharmony_ci * GPL apply INSTEAD OF those given above.
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
308c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
318c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
328c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
338c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
348c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
358c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
368c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
378c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
388c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
398c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
408c2ecf20Sopenharmony_ci * DAMAGE.
418c2ecf20Sopenharmony_ci *
428c2ecf20Sopenharmony_ci */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/* Controlling Queue Delay (CoDel) algorithm
458c2ecf20Sopenharmony_ci * =========================================
468c2ecf20Sopenharmony_ci * Source : Kathleen Nichols and Van Jacobson
478c2ecf20Sopenharmony_ci * http://queue.acm.org/detail.cfm?id=2209336
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci * Implemented on linux by Dave Taht and Eric Dumazet
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */
538c2ecf20Sopenharmony_cistruct codel_skb_cb {
548c2ecf20Sopenharmony_ci	codel_time_t enqueue_time;
558c2ecf20Sopenharmony_ci	unsigned int mem_usage;
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cistatic struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb));
618c2ecf20Sopenharmony_ci	return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic codel_time_t codel_get_enqueue_time(const struct sk_buff *skb)
658c2ecf20Sopenharmony_ci{
668c2ecf20Sopenharmony_ci	return get_codel_cb(skb)->enqueue_time;
678c2ecf20Sopenharmony_ci}
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic void codel_set_enqueue_time(struct sk_buff *skb)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	get_codel_cb(skb)->enqueue_time = codel_get_time();
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#endif
75