1 /* $KAME: altq_red.h,v 1.8 2003/07/10 12:07:49 kjc Exp $ */
2 /* $DragonFly: src/sys/net/altq/altq_red.h,v 1.1 2005/02/11 22:25:57 joerg Exp $ */
5 * Copyright (C) 1997-2003
6 * Sony Computer Science Laboratories Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #ifndef _ALTQ_ALTQ_RED_H_
31 #define _ALTQ_ALTQ_RED_H_
33 #include <net/altq/altq_classq.h>
36 #define REDF_ECN4 0x01 /* use packet marking for IPv4 packets */
37 #define REDF_ECN6 0x02 /* use packet marking for IPv6 packets */
38 #define REDF_ECN (REDF_ECN4 | REDF_ECN6)
41 * simpler versions of red parameters and statistics used by other
42 * disciplines (e.g., CBQ)
45 int th_min
; /* red min threshold */
46 int th_max
; /* red max threshold */
47 int inv_pmax
; /* inverse of max drop probability */
52 struct pktcntr xmit_cnt
;
53 struct pktcntr drop_cnt
;
61 /* weight table structure for idle time calibration */
63 SLIST_ENTRY(wtab
) w_link
;
71 int red_pkttime
; /* average packet time in micro sec
72 used for idle calibration */
73 int red_flags
; /* red flags */
76 int red_weight
; /* weight for EWMA */
77 int red_inv_pmax
; /* inverse of max drop probability */
78 int red_thmin
; /* red min threshold */
79 int red_thmax
; /* red max threshold */
81 /* variables for internal use */
82 int red_wshift
; /* log(red_weight) */
83 int red_thmin_s
; /* th_min scaled by avgshift */
84 int red_thmax_s
; /* th_max scaled by avgshift */
85 int red_probd
; /* drop probability denominator */
87 int red_avg
; /* queue len avg scaled by avgshift */
88 int red_count
; /* packet count since last dropped/
90 int red_idle
; /* queue was empty */
91 int red_old
; /* avg is above th_min */
92 struct wtab
*red_wtab
; /* weight table */
93 struct timeval red_last
; /* time when the queue becomes idle */
96 struct pktcntr xmit_cnt
;
97 struct pktcntr drop_cnt
;
100 u_int marked_packets
;
105 #define DTYPE_NODROP 0 /* no drop */
106 #define DTYPE_FORCED 1 /* a "forced" drop */
107 #define DTYPE_EARLY 2 /* an "unforced" (early) drop */
109 red_t
*red_alloc(int, int, int, int, int, int);
110 void red_destroy(red_t
*);
111 void red_getstats(red_t
*, struct redstats
*);
112 int red_addq(red_t
*, class_queue_t
*, struct mbuf
*,
113 struct altq_pktattr
*);
114 struct mbuf
*red_getq(red_t
*, class_queue_t
*);
115 int drop_early(int, int, int);
116 int mark_ecn(struct mbuf
*, struct altq_pktattr
*, int);
117 struct wtab
*wtab_alloc(int);
118 int wtab_destroy(struct wtab
*);
119 int32_t pow_w(struct wtab
*, int);
123 #endif /* _ALTQ_ALTQ_RED_H_ */