View | Details | Raw Unified | Return to bug 241563
Collapse All | Expand All

(-)freebsd-ared/sys/conf/options (+1 lines)
Lines 408-413 Link Here
408
ACCEPT_FILTER_DNS
408
ACCEPT_FILTER_DNS
409
ACCEPT_FILTER_HTTP
409
ACCEPT_FILTER_HTTP
410
ALTQ			opt_global.h
410
ALTQ			opt_global.h
411
ALTQ_ADAPTIVE_RED       opt_altq.h
411
ALTQ_CBQ		opt_altq.h
412
ALTQ_CBQ		opt_altq.h
412
ALTQ_CDNR		opt_altq.h
413
ALTQ_CDNR		opt_altq.h
413
ALTQ_CODEL		opt_altq.h
414
ALTQ_CODEL		opt_altq.h
(-)freebsd-ared/sys/net/altq/altq_red.c (-4 / +73 lines)
Lines 57-63 Link Here
57
 * SUCH DAMAGE.
57
 * SUCH DAMAGE.
58
 *
58
 *
59
 * $KAME: altq_red.c,v 1.18 2003/09/05 22:40:36 itojun Exp $
59
 * $KAME: altq_red.c,v 1.18 2003/09/05 22:40:36 itojun Exp $
60
 * $FreeBSD$	
60
 * $FreeBSD$
61
 */
61
 */
62
62
63
#include "opt_altq.h"
63
#include "opt_altq.h"
Lines 71-76 Link Here
71
#include <sys/socket.h>
71
#include <sys/socket.h>
72
#include <sys/systm.h>
72
#include <sys/systm.h>
73
#include <sys/errno.h>
73
#include <sys/errno.h>
74
#include <sys/types.h>
75
74
#if 1 /* ALTQ3_COMPAT */
76
#if 1 /* ALTQ3_COMPAT */
75
#include <sys/sockio.h>
77
#include <sys/sockio.h>
76
#include <sys/proc.h>
78
#include <sys/proc.h>
Lines 161-166 Link Here
161
#define	RED_LIMIT	60	/* default max queue length */
163
#define	RED_LIMIT	60	/* default max queue length */
162
#define	RED_STATS		/* collect statistics */
164
#define	RED_STATS		/* collect statistics */
163
165
166
/* parameters needed for adaptive-red */
167
#define INV_MIN_P		100					/* denominator of minimum drop probability */
168
#define INV_MAX_P 		2					/* denominator of maximum drop probability */
169
#define RED_ALPHA_INV(val) 	max(100<<FP_SHIFT,val<<2)		/* inverse of Additive adjustment factor for adaptive red */
170
#define RED_BETA 		0.9					/* multiplicative adjustment factor for adaptive red */
171
164
/*
172
/*
165
 * our default policy for forced-drop is drop-tail.
173
 * our default policy for forced-drop is drop-tail.
166
 * (in altq-1.1.2 or earlier, the default was random-drop.
174
 * (in altq-1.1.2 or earlier, the default was random-drop.
Lines 250-258 Link Here
250
	rp->red_idle = 1;
258
	rp->red_idle = 1;
251
259
252
	if (inv_pmax == 0)
260
	if (inv_pmax == 0)
253
		rp->red_inv_pmax = default_inv_pmax;
261
		rp->red_inv_pmax = default_inv_pmax<<FP_SHIFT;
254
	else
262
	else
255
		rp->red_inv_pmax = inv_pmax;
263
		rp->red_inv_pmax = inv_pmax<<FP_SHIFT;
256
	if (th_min == 0)
264
	if (th_min == 0)
257
		rp->red_thmin = default_th_min;
265
		rp->red_thmin = default_th_min;
258
	else
266
	else
Lines 306-314 Link Here
306
	 *  probd = (2 * (TH_MAX-TH_MIN) / pmax) in fixed-point
314
	 *  probd = (2 * (TH_MAX-TH_MIN) / pmax) in fixed-point
307
	 */
315
	 */
308
	rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
316
	rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
309
			 * rp->red_inv_pmax) << FP_SHIFT;
317
			 * rp->red_inv_pmax);
310
318
311
	microtime(&rp->red_last);
319
	microtime(&rp->red_last);
320
#ifdef ALTQ_ADAPTIVE_RED
321
	int delta = (rp->red_thmax_s-rp->red_thmin_s)/5;
322
	rp->target_min = rp->red_thmin_s + 2*delta;
323
	rp->target_max = rp->red_thmin_s + 3*delta;
324
	mtx_init(&rp->lock_mtx, "mtx_red", NULL, MTX_DEF);
325
	callout_init_mtx(&rp->adaptive_callout, &rp->lock_mtx,
326
			CALLOUT_RETURNUNLOCKED);
327
	mtx_lock(&rp->lock_mtx);
328
	callout_reset_sbt(&rp->adaptive_callout, 500*SBT_1MS,  0, red_adaptive_timer, (void *)rp, 0);
329
	mtx_unlock(&rp->lock_mtx);
330
#endif
312
	return (rp);
331
	return (rp);
313
}
332
}
314
333
Lines 322-327 Link Here
322
#endif
341
#endif
323
#endif /* ALTQ3_COMPAT */
342
#endif /* ALTQ3_COMPAT */
324
	wtab_destroy(rp->red_wtab);
343
	wtab_destroy(rp->red_wtab);
344
	/* stop any pending callouts */
345
	mtx_lock(&rp->lock_mtx);
346
	callout_stop(&rp->adaptive_callout);
347
	mtx_unlock(&rp->lock_mtx);
325
	free(rp, M_DEVBUF);
348
	free(rp, M_DEVBUF);
326
}
349
}
327
350
Lines 707-712 Link Here
707
	return (val);
730
	return (val);
708
}
731
}
709
732
733
#ifdef ALTQ_ADAPTIVE_RED
734
/*
735
 * calling function for Adaptive-RED
736
 */
737
void
738
red_adaptive_timer(void *params)
739
{
740
	red_t *rp = (red_t *)params;
741
	red_adaptive_algo(rp);
742
	callout_reset_sbt(&rp->adaptive_callout, 500*SBT_1MS,  0, red_adaptive_timer, (void *)rp, 0);
743
	mtx_unlock(&rp->lock_mtx);
744
}
745
746
/*
747
 * Adaptive-RED algorithm
748
 */
749
void
750
red_adaptive_algo(red_t *rp)
751
{
752
	if(rp->red_inv_pmax > INV_MAX_P<<FP_SHIFT && rp->red_avg >= rp->target_max)
753
	{
754
		/*
755
		 * Additively increase RED drop
756
		 * probability using RED_ALPHA_INV
757
		 * red_inv_pmax = 1/((1/red_inv_pmax)+(1/RED_ALPHA_INV(red_inv_pmax)));
758
		 */
759
		rp->red_inv_pmax = (rp->red_inv_pmax*(RED_ALPHA_INV(rp->red_inv_pmax)))/(rp->red_inv_pmax+(RED_ALPHA_INV(rp->red_inv_pmax)));
760
	}
761
	else if(rp->red_inv_pmax < INV_MIN_P<<FP_SHIFT && rp->red_avg <= rp->target_min)
762
	{
763
		/*
764
		 * Multiplicately decrease RED drop
765
		 * probability using RED_BETA
766
		 * red_inv_pmax = red_inv_pmax/RED_BETA;
767
		 */
768
		rp->red_inv_pmax = (rp->red_inv_pmax*10)/9;
769
	}
770
	/*
771
	 * precompute probability denominator
772
	 * probd = (2 * (TH_MAX-TH_MIN) / pmax) in fixed-point
773
	 */
774
	rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)*rp->red_inv_pmax);
775
}
776
777
#endif /* ALTQ_ADAPTIVE_RED */
778
710
#ifdef ALTQ3_COMPAT
779
#ifdef ALTQ3_COMPAT
711
/*
780
/*
712
 * red device interface
781
 * red device interface
(-)freebsd-ared/sys/net/altq/altq_red.h (-1 / +14 lines)
Lines 31-36 Link Here
31
#define	_ALTQ_ALTQ_RED_H_
31
#define	_ALTQ_ALTQ_RED_H_
32
32
33
#include <net/altq/altq_classq.h>
33
#include <net/altq/altq_classq.h>
34
#include <sys/types.h>
35
#include <sys/mutex.h>
36
#include <sys/lock.h>
34
37
35
#ifdef ALTQ3_COMPAT
38
#ifdef ALTQ3_COMPAT
36
struct red_interface {
39
struct red_interface {
Lines 135-141 Link Here
135
138
136
	/* red parameters */
139
	/* red parameters */
137
	int		red_weight;	/* weight for EWMA */
140
	int		red_weight;	/* weight for EWMA */
138
	int		red_inv_pmax;	/* inverse of max drop probability */
141
	uint64_t	red_inv_pmax;	/* inverse of max drop probability */
139
	int		red_thmin;	/* red min threshold */
142
	int		red_thmin;	/* red min threshold */
140
	int		red_thmax;	/* red max threshold */
143
	int		red_thmax;	/* red max threshold */
141
144
Lines 153-158 Link Here
153
	struct wtab	*red_wtab;	/* weight table */
156
	struct wtab	*red_wtab;	/* weight table */
154
	struct timeval	 red_last;	/* time when the queue becomes idle */
157
	struct timeval	 red_last;	/* time when the queue becomes idle */
155
158
159
#ifdef ALTQ_ADAPTIVE_RED
160
	/* variables for Adaptive RED */
161
	struct callout 	adaptive_callout;	/* callout structure for use with Adaptive-RED */
162
	int 		target_min;             /* target minimum for the queue */
163
	int 		target_max;             /* target maximum for the queue */
164
	struct mtx 	lock_mtx;
165
#endif
166
156
#ifdef ALTQ3_COMPAT
167
#ifdef ALTQ3_COMPAT
157
	struct flowvalve *red_flowvalve;	/* flowvalve state */
168
	struct flowvalve *red_flowvalve;	/* flowvalve state */
158
#endif
169
#endif
Lines 193-198 Link Here
193
extern struct wtab	*wtab_alloc(int);
204
extern struct wtab	*wtab_alloc(int);
194
extern int		 wtab_destroy(struct wtab *);
205
extern int		 wtab_destroy(struct wtab *);
195
extern int32_t		 pow_w(struct wtab *, int);
206
extern int32_t		 pow_w(struct wtab *, int);
207
extern void		 red_adaptive_timer(void *);
208
extern void		 red_adaptive_algo(red_t *);
196
209
197
#endif /* _KERNEL */
210
#endif /* _KERNEL */
198
211

Return to bug 241563