FreeBSD/sys/netpfil/ipfw/dn_sched_fq_codel.c
/*
 * Initialize fq_codel scheduler instance.
 * also, allocate memory for flows array.
 */
Initialize fq_codel scheduler instance.
also, allocate memory for flows array.
Initialize fq_codel scheduler instance . also allocate memory for flows array .
static int
fq_codel_new_sched(struct dn_sch_inst *_si)
{
	struct fq_codel_si *si;
	struct dn_queue *q;
	struct fq_codel_schk *schk;
	int i;
	si = (struct fq_codel_si *)_si;
	schk = (struct fq_codel_schk *)(_si->sched+1);
	if(si->flows) {
		D("si already configured!");
		return 0;
	}
	q = &si->main_q;
	set_oid(&q->ni.oid, DN_QUEUE, sizeof(*q));
	q->_si = _si;
	q->fs = _si->sched->fs;
	si->flows = malloc(schk->cfg.flows_cnt * sizeof(struct fq_codel_flow),
		 M_DUMMYNET, M_NOWAIT | M_ZERO);
	if (si->flows == NULL) {
		D("cannot allocate memory for fq_codel configuration parameters");
		return ENOMEM ; 
	}
	si->perturbation = random();
	STAILQ_INIT(&si->newflows);
	STAILQ_INIT(&si->oldflows);
	for (i = 0; i < schk->cfg.flows_cnt; i++) {
		si->flows[i].cst.maxpkt_size = 500;
	}
	fq_codel_desc.ref_count++;
	return 0;
}
static int fq_codel_new_sched ( struct dn_sch_inst * _si ) { struct fq_codel_si * si ; struct dn_queue * q ; struct fq_codel_schk * schk ; int i ; si = ( struct fq_codel_si * ) _si ; schk = ( struct fq_codel_schk * ) ( _si -> sched + 1 ) ; if ( si -> flows ) { D ( " " ) ; return 0 ; } q = & si -> main_q ; set_oid ( & q -> ni . oid , DN_QUEUE , sizeof ( * q ) ) ; q -> _si = _si ; q -> fs = _si -> sched -> fs ; si -> flows = malloc ( schk -> cfg . flows_cnt * sizeof ( struct fq_codel_flow ) , M_DUMMYNET , M_NOWAIT | M_ZERO ) ; if ( si -> flows == NULL ) { D ( " " ) ; return ENOMEM ; } si -> perturbation = random ( ) ; STAILQ_INIT ( & si -> newflows ) ; STAILQ_INIT ( & si -> oldflows ) ; for ( i = 0 ; i < schk -> cfg . flows_cnt ; i ++ ) { si -> flows [ i ] . cst . maxpkt_size = 500 ; } fq_codel_desc . ref_count ++ ; return 0 ; }
Initialize fq_codel scheduler instance.
Initialize fq_codel scheduler instance .
/* init the main queue */ /* allocate memory for flows array */ /* init perturbation for this si */ /* init the old and new flows lists */ /* init the flows (sub-queues) */ /* init codel */