FreeBSD/sys/netpfil/ipfw/dn_sched_fq_pie.c
/*
 * Configure FQ-PIE scheduler.
 * the configurations for the scheduler is passed fromipfw  userland.
 */
Configure FQ-PIE scheduler.
the configurations for the scheduler is passed fromipfw  userland.
Configure FQ - PIE scheduler . the configurations for the scheduler is passed fromipfw userland .
static int
fq_pie_config(struct dn_schk *_schk)
{
	struct fq_pie_schk *schk;
	struct dn_extra_parms *ep;
	struct dn_sch_fq_pie_parms *fqp_cfg;
	schk = (struct fq_pie_schk *)(_schk+1);
	ep = (struct dn_extra_parms *) _schk->cfg;
	if (ep && ep->oid.len ==sizeof(*ep) &&
		ep->oid.subtype == DN_SCH_PARAMS) {
		fqp_cfg = &schk->cfg;
		if (ep->par[0] < 0)
			fqp_cfg->pcfg.qdelay_ref = fq_pie_sysctl.pcfg.qdelay_ref;
		else
			fqp_cfg->pcfg.qdelay_ref = ep->par[0];
		if (ep->par[1] < 0)
			fqp_cfg->pcfg.tupdate = fq_pie_sysctl.pcfg.tupdate;
		else
			fqp_cfg->pcfg.tupdate = ep->par[1];
		if (ep->par[2] < 0)
			fqp_cfg->pcfg.max_burst = fq_pie_sysctl.pcfg.max_burst;
		else
			fqp_cfg->pcfg.max_burst = ep->par[2];
		if (ep->par[3] < 0)
			fqp_cfg->pcfg.max_ecnth = fq_pie_sysctl.pcfg.max_ecnth;
		else
			fqp_cfg->pcfg.max_ecnth = ep->par[3];
		if (ep->par[4] < 0)
			fqp_cfg->pcfg.alpha = fq_pie_sysctl.pcfg.alpha;
		else
			fqp_cfg->pcfg.alpha = ep->par[4];
		if (ep->par[5] < 0)
			fqp_cfg->pcfg.beta = fq_pie_sysctl.pcfg.beta;
		else
			fqp_cfg->pcfg.beta = ep->par[5];
		if (ep->par[6] < 0)
			fqp_cfg->pcfg.flags = 0;
		else
			fqp_cfg->pcfg.flags = ep->par[6];
		if (ep->par[7] < 0)
			fqp_cfg->quantum = fq_pie_sysctl.quantum;
		else
			fqp_cfg->quantum = ep->par[7];
		if (ep->par[8] < 0)
			fqp_cfg->limit = fq_pie_sysctl.limit;
		else
			fqp_cfg->limit = ep->par[8];
		if (ep->par[9] < 0)
			fqp_cfg->flows_cnt = fq_pie_sysctl.flows_cnt;
		else
			fqp_cfg->flows_cnt = ep->par[9];
		fqp_cfg->pcfg.qdelay_ref = BOUND_VAR(fqp_cfg->pcfg.qdelay_ref,
			1, 5 * AQM_TIME_1S);
		fqp_cfg->pcfg.tupdate = BOUND_VAR(fqp_cfg->pcfg.tupdate,
			1, 5 * AQM_TIME_1S);
		fqp_cfg->pcfg.max_burst = BOUND_VAR(fqp_cfg->pcfg.max_burst,
			0, 5 * AQM_TIME_1S);
		fqp_cfg->pcfg.max_ecnth = BOUND_VAR(fqp_cfg->pcfg.max_ecnth,
			0, PIE_SCALE);
		fqp_cfg->pcfg.alpha = BOUND_VAR(fqp_cfg->pcfg.alpha, 0, 7 * PIE_SCALE);
		fqp_cfg->pcfg.beta = BOUND_VAR(fqp_cfg->pcfg.beta, 0, 7 * PIE_SCALE);
		fqp_cfg->quantum = BOUND_VAR(fqp_cfg->quantum,1,9000);
		fqp_cfg->limit= BOUND_VAR(fqp_cfg->limit,1,20480);
		fqp_cfg->flows_cnt= BOUND_VAR(fqp_cfg->flows_cnt,1,65536);
	}
	else {
		D("Wrong parameters for fq_pie scheduler");
		return 1;
	}
	return 0;
}
static int fq_pie_config ( struct dn_schk * _schk ) { struct fq_pie_schk * schk ; struct dn_extra_parms * ep ; struct dn_sch_fq_pie_parms * fqp_cfg ; schk = ( struct fq_pie_schk * ) ( _schk + 1 ) ; ep = ( struct dn_extra_parms * ) _schk -> cfg ; if ( ep && ep -> oid . len == sizeof ( * ep ) && ep -> oid . subtype == DN_SCH_PARAMS ) { fqp_cfg = & schk -> cfg ; if ( ep -> par [ 0 ] < 0 ) fqp_cfg -> pcfg . qdelay_ref = fq_pie_sysctl . pcfg . qdelay_ref ; else fqp_cfg -> pcfg . qdelay_ref = ep -> par [ 0 ] ; if ( ep -> par [ 1 ] < 0 ) fqp_cfg -> pcfg . tupdate = fq_pie_sysctl . pcfg . tupdate ; else fqp_cfg -> pcfg . tupdate = ep -> par [ 1 ] ; if ( ep -> par [ 2 ] < 0 ) fqp_cfg -> pcfg . max_burst = fq_pie_sysctl . pcfg . max_burst ; else fqp_cfg -> pcfg . max_burst = ep -> par [ 2 ] ; if ( ep -> par [ 3 ] < 0 ) fqp_cfg -> pcfg . max_ecnth = fq_pie_sysctl . pcfg . max_ecnth ; else fqp_cfg -> pcfg . max_ecnth = ep -> par [ 3 ] ; if ( ep -> par [ 4 ] < 0 ) fqp_cfg -> pcfg . alpha = fq_pie_sysctl . pcfg . alpha ; else fqp_cfg -> pcfg . alpha = ep -> par [ 4 ] ; if ( ep -> par [ 5 ] < 0 ) fqp_cfg -> pcfg . beta = fq_pie_sysctl . pcfg . beta ; else fqp_cfg -> pcfg . beta = ep -> par [ 5 ] ; if ( ep -> par [ 6 ] < 0 ) fqp_cfg -> pcfg . flags = 0 ; else fqp_cfg -> pcfg . flags = ep -> par [ 6 ] ; if ( ep -> par [ 7 ] < 0 ) fqp_cfg -> quantum = fq_pie_sysctl . quantum ; else fqp_cfg -> quantum = ep -> par [ 7 ] ; if ( ep -> par [ 8 ] < 0 ) fqp_cfg -> limit = fq_pie_sysctl . limit ; else fqp_cfg -> limit = ep -> par [ 8 ] ; if ( ep -> par [ 9 ] < 0 ) fqp_cfg -> flows_cnt = fq_pie_sysctl . flows_cnt ; else fqp_cfg -> flows_cnt = ep -> par [ 9 ] ; fqp_cfg -> pcfg . qdelay_ref = BOUND_VAR ( fqp_cfg -> pcfg . qdelay_ref , 1 , 5 * AQM_TIME_1S ) ; fqp_cfg -> pcfg . tupdate = BOUND_VAR ( fqp_cfg -> pcfg . tupdate , 1 , 5 * AQM_TIME_1S ) ; fqp_cfg -> pcfg . max_burst = BOUND_VAR ( fqp_cfg -> pcfg . max_burst , 0 , 5 * AQM_TIME_1S ) ; fqp_cfg -> pcfg . max_ecnth = BOUND_VAR ( fqp_cfg -> pcfg . max_ecnth , 0 , PIE_SCALE ) ; fqp_cfg -> pcfg . alpha = BOUND_VAR ( fqp_cfg -> pcfg . alpha , 0 , 7 * PIE_SCALE ) ; fqp_cfg -> pcfg . beta = BOUND_VAR ( fqp_cfg -> pcfg . beta , 0 , 7 * PIE_SCALE ) ; fqp_cfg -> quantum = BOUND_VAR ( fqp_cfg -> quantum , 1 , 9000 ) ; fqp_cfg -> limit = BOUND_VAR ( fqp_cfg -> limit , 1 , 20480 ) ; fqp_cfg -> flows_cnt = BOUND_VAR ( fqp_cfg -> flows_cnt , 1 , 65536 ) ; } else { D ( " " ) ; return 1 ; } return 0 ; }
Configure FQ-PIE scheduler.
Configure FQ - PIE scheduler .
/* par array contains fq_pie configuration as follow
	 * PIE: 0- qdelay_ref,1- tupdate, 2- max_burst
	 * 3- max_ecnth, 4- alpha, 5- beta, 6- flags
	 * FQ_PIE: 7- quantum, 8- limit, 9- flows
	 */ /* FQ configurations */ /* Bound the configurations */