2 * CoDel - The Controlled-Delay Active Queue Management algorithm
4 * Copyright (C) 2013 Ermal Luçi <eri@FreeBSD.org>
5 * Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com>
6 * Copyright (C) 2011-2012 Van Jacobson <van@pollere.net>
7 * Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net>
8 * Copyright (C) 2012 Eric Dumazet <edumazet@google.com>
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions, and the following disclaimer,
15 * without modification.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The names of the authors may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * Alternatively, provided that this notice is retained in full, this
23 * software may be distributed under the terms of the GNU General
24 * Public License ("GPL") version 2, in which case the provisions of the
25 * GPL apply INSTEAD OF those given above.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
43 #ifndef _ALTQ_ALTQ_CODEL_H_
44 #define _ALTQ_ALTQ_CODEL_H_
48 struct pktcntr drop_cnt;
52 struct codel_ifstats {
55 struct codel_stats stats;
56 struct pktcntr cl_xmitcnt; /* transmitted packet counter */
57 struct pktcntr cl_dropcnt; /* dropped packet counter */
61 * CBQ_STATS_VERSION is defined in altq.h to work around issues stemming
62 * from mixing of public-API and internal bits in each scheduler-specific
67 #include <net/altq/altq_classq.h>
70 * struct codel_params - contains codel parameters
71 * <at> target: target queue size (in time units)
72 * <at> interval: width of moving time window
73 * <at> ecn: is Explicit Congestion Notification enabled
82 * struct codel_vars - contains codel variables
83 * <at> count: how many drops we've done since the last time we
84 * entered dropping state
85 * <at> lastcount: count at entry to dropping state
86 * <at> dropping: set to true if in dropping state
87 * <at> rec_inv_sqrt: reciprocal value of sqrt(count) >> 1
88 * <at> first_above_time: when we went (or will go) continuously above
90 * <at> drop_next: time to drop next packet, or when we dropped last
91 * <at> ldelay: sojourn time of last dequeued packet
97 u_int16_t rec_inv_sqrt;
98 u_int64_t first_above_time;
105 struct codel_params params;
106 struct codel_vars vars;
107 struct codel_stats stats;
108 struct timeval last_log;
109 u_int32_t drop_overlimit;
113 * codel interface state
116 struct codel_if *cif_next; /* interface state list */
117 struct ifaltq *cif_ifq; /* backpointer to ifaltq */
118 u_int cif_bandwidth; /* link bandwidth in bps */
120 class_queue_t *cl_q; /* class queue structure */
124 struct codel_ifstats cl_stats;
127 struct codel *codel_alloc(int, int, int);
128 void codel_destroy(struct codel *);
129 int codel_addq(struct codel *, class_queue_t *, struct mbuf *);
130 struct mbuf *codel_getq(struct codel *, class_queue_t *);
131 void codel_getstats(struct codel *, struct codel_stats *);
135 #endif /* _ALTQ_ALTQ_CODEL_H_ */