/*1* CoDel - The Controlled-Delay Active Queue Management algorithm2*3* Copyright (C) 2013 Ermal Luçi <[email protected]>4* Copyright (C) 2011-2012 Kathleen Nichols <[email protected]>5* Copyright (C) 2011-2012 Van Jacobson <[email protected]>6* Copyright (C) 2012 Michael D. Taht <[email protected]>7* Copyright (C) 2012 Eric Dumazet <[email protected]>8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions, and the following disclaimer,14* without modification.15* 2. Redistributions in binary form must reproduce the above copyright16* notice, this list of conditions and the following disclaimer in the17* documentation and/or other materials provided with the distribution.18* 3. The names of the authors may not be used to endorse or promote products19* derived from this software without specific prior written permission.20*21* Alternatively, provided that this notice is retained in full, this22* software may be distributed under the terms of the GNU General23* Public License ("GPL") version 2, in which case the provisions of the24* GPL apply INSTEAD OF those given above.25*26* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS27* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT28* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR29* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT30* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,31* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT32* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,33* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY34* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT35* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE36* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH37* DAMAGE.38*/3940#ifndef _ALTQ_ALTQ_CODEL_H_41#define _ALTQ_ALTQ_CODEL_H_4243struct codel_stats {44u_int32_t maxpacket;45struct pktcntr drop_cnt;46u_int marked_packets;47};4849struct codel_ifstats {50u_int qlength;51u_int qlimit;52struct codel_stats stats;53struct pktcntr cl_xmitcnt; /* transmitted packet counter */54struct pktcntr cl_dropcnt; /* dropped packet counter */55};5657/*58* CBQ_STATS_VERSION is defined in altq.h to work around issues stemming59* from mixing of public-API and internal bits in each scheduler-specific60* header.61*/6263#ifdef _KERNEL64#include <net/altq/altq_classq.h>6566/**67* struct codel_params - contains codel parameters68* <at> target: target queue size (in time units)69* <at> interval: width of moving time window70* <at> ecn: is Explicit Congestion Notification enabled71*/72struct codel_params {73u_int64_t target;74u_int64_t interval;75int ecn;76};7778/**79* struct codel_vars - contains codel variables80* <at> count: how many drops we've done since the last time we81* entered dropping state82* <at> lastcount: count at entry to dropping state83* <at> dropping: set to true if in dropping state84* <at> rec_inv_sqrt: reciprocal value of sqrt(count) >> 185* <at> first_above_time: when we went (or will go) continuously above86* target for interval87* <at> drop_next: time to drop next packet, or when we dropped last88* <at> ldelay: sojourn time of last dequeued packet89*/90struct codel_vars {91u_int32_t count;92u_int32_t lastcount;93int dropping;94u_int16_t rec_inv_sqrt;95u_int64_t first_above_time;96u_int64_t drop_next;97u_int64_t ldelay;98};99100struct codel {101int last_pps;102struct codel_params params;103struct codel_vars vars;104struct codel_stats stats;105struct timeval last_log;106u_int32_t drop_overlimit;107};108109/*110* codel interface state111*/112struct codel_if {113struct codel_if *cif_next; /* interface state list */114struct ifaltq *cif_ifq; /* backpointer to ifaltq */115u_int cif_bandwidth; /* link bandwidth in bps */116117class_queue_t *cl_q; /* class queue structure */118struct codel codel;119120/* statistics */121struct codel_ifstats cl_stats;122};123124struct codel *codel_alloc(int, int, int);125void codel_destroy(struct codel *);126int codel_addq(struct codel *, class_queue_t *, struct mbuf *);127struct mbuf *codel_getq(struct codel *, class_queue_t *);128void codel_getstats(struct codel *, struct codel_stats *);129130#endif /* _KERNEL */131132#endif /* _ALTQ_ALTQ_CODEL_H_ */133134135