FreeBSD/Linux Kernel Cross Reference
sys/altq/altq_red.h
1 /* $NetBSD: altq_red.h,v 1.2 2000/12/14 08:49:51 thorpej Exp $ */
2 /* $KAME: altq_red.h,v 1.5 2000/12/14 08:12:46 thorpej Exp $ */
3
4 /*
5 * Copyright (C) 1997-2000
6 * Sony Computer Science Laboratories Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
16 *
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
27 * SUCH DAMAGE.
28 */
29
30 #ifndef _ALTQ_ALTQ_RED_H_
31 #define _ALTQ_ALTQ_RED_H_
32
33 #include <altq/altq_classq.h>
34
35 struct red_interface {
36 char red_ifname[IFNAMSIZ];
37 };
38
39 struct red_stats {
40 struct red_interface iface;
41 int q_len;
42 int q_avg;
43
44 struct pktcntr xmit_cnt;
45 struct pktcntr drop_cnt;
46 u_int drop_forced;
47 u_int drop_unforced;
48 u_int marked_packets;
49
50 /* static red parameters */
51 int q_limit;
52 int weight;
53 int inv_pmax;
54 int th_min;
55 int th_max;
56
57 /* flowvalve related stuff */
58 u_int fv_flows;
59 u_int fv_pass;
60 u_int fv_predrop;
61 u_int fv_alloc;
62 u_int fv_escape;
63 };
64
65 struct red_conf {
66 struct red_interface iface;
67 int red_weight; /* weight for EWMA */
68 int red_inv_pmax; /* inverse of max drop probability */
69 int red_thmin; /* red min threshold */
70 int red_thmax; /* red max threshold */
71 int red_limit; /* max queue length */
72 int red_pkttime; /* average packet time in usec */
73 int red_flags; /* see below */
74 };
75
76 /* red flags */
77 #define REDF_ECN4 0x01 /* use packet marking for IPv4 packets */
78 #define REDF_ECN6 0x02 /* use packet marking for IPv6 packets */
79 #define REDF_ECN (REDF_ECN4 | REDF_ECN6)
80 #define REDF_FLOWVALVE 0x04 /* use flowvalve (aka penalty-box) */
81
82 /*
83 * simpler versions of red parameters and statistics used by other
84 * disciplines (e.g., CBQ)
85 */
86 struct redparams {
87 int th_min; /* red min threshold */
88 int th_max; /* red max threshold */
89 int inv_pmax; /* inverse of max drop probability */
90 };
91
92 struct redstats {
93 int q_avg;
94 struct pktcntr xmit_cnt;
95 struct pktcntr drop_cnt;
96 u_int drop_forced;
97 u_int drop_unforced;
98 u_int marked_packets;
99 };
100
101
102 /*
103 * IOCTLs for RED
104 */
105 #define RED_IF_ATTACH _IOW('Q', 1, struct red_interface)
106 #define RED_IF_DETACH _IOW('Q', 2, struct red_interface)
107 #define RED_ENABLE _IOW('Q', 3, struct red_interface)
108 #define RED_DISABLE _IOW('Q', 4, struct red_interface)
109 #define RED_CONFIG _IOWR('Q', 6, struct red_conf)
110 #define RED_GETSTATS _IOWR('Q', 12, struct red_stats)
111 #define RED_SETDEFAULTS _IOW('Q', 30, struct redparams)
112
113 #ifdef _KERNEL
114
115 struct flowvalve;
116
117 /* weight table structure for idle time calibration */
118 struct wtab {
119 struct wtab *w_next;
120 int w_weight;
121 int w_param_max;
122 int w_refcount;
123 int32_t w_tab[32];
124 };
125
126 typedef struct red {
127 int red_pkttime; /* average packet time in micro sec
128 used for idle calibration */
129 int red_flags; /* red flags */
130
131 /* red parameters */
132 int red_weight; /* weight for EWMA */
133 int red_inv_pmax; /* inverse of max drop probability */
134 int red_thmin; /* red min threshold */
135 int red_thmax; /* red max threshold */
136
137 /* variables for internal use */
138 int red_wshift; /* log(red_weight) */
139 int red_thmin_s; /* th_min scaled by avgshift */
140 int red_thmax_s; /* th_max scaled by avgshift */
141 int red_probd; /* drop probability denominator */
142
143 int red_avg; /* queue length average scaled by avgshift */
144 int red_count; /* packet count since the last dropped/marked
145 packet */
146 int red_idle; /* queue was empty */
147 int red_old; /* avg is above th_min */
148 struct wtab *red_wtab; /* weight table */
149 struct timeval red_last; /* timestamp when the queue becomes idle */
150
151 struct flowvalve *red_flowvalve; /* flowvalve state */
152
153 struct {
154 struct pktcntr xmit_cnt;
155 struct pktcntr drop_cnt;
156 u_int drop_forced;
157 u_int drop_unforced;
158 u_int marked_packets;
159 } red_stats;
160 } red_t;
161
162 typedef struct red_queue {
163 struct red_queue *rq_next; /* next red_state in the list */
164 struct ifaltq *rq_ifq; /* backpointer to ifaltq */
165
166 class_queue_t *rq_q;
167
168 red_t *rq_red;
169 } red_queue_t;
170
171 /* red drop types */
172 #define DTYPE_NODROP 0 /* no drop */
173 #define DTYPE_FORCED 1 /* a "forced" drop */
174 #define DTYPE_EARLY 2 /* an "unforced" (early) drop */
175
176 extern red_t *red_alloc __P((int, int, int, int, int, int));
177 extern void red_destroy __P((red_t *));
178 extern void red_getstats __P((red_t *, struct redstats *));
179 extern int red_addq __P((red_t *, class_queue_t *, struct mbuf *,
180 struct altq_pktattr *));
181 extern struct mbuf *red_getq __P((red_t *, class_queue_t *));
182 extern int drop_early __P((int, int, int));
183 extern int mark_ecn __P((struct mbuf *, struct altq_pktattr *, int));
184 extern struct wtab *wtab_alloc __P((int));
185 extern int wtab_destroy __P((struct wtab *));
186 extern int32_t pow_w __P((struct wtab *, int));
187
188 #endif /* _KERNEL */
189
190 #endif /* _ALTQ_ALTQ_RED_H_ */
Cache object: 6b9c81524185b5f7e8892a76d2e1bba5
|