FreeBSD/sys/netpfil/ipfw/dn_sched_fq_pie.c
/*
 * Enqueue a packet in q, subject to space and FQ-PIE queue management policy
 * (whose parameters are in q->fs).
 * Update stats for the queue and the scheduler.
 * Return 0 on success, 1 on drop. The packet is consumed anyways.
 */
Enqueue a packet in q, subject to space and FQ-PIE queue management policy
(whose parameters are in q->fs).
Update stats for the queue and the scheduler.
Return 0 on success, 1 on drop. The packet is consumed anyways.
Enqueue a packet in q subject to space and FQ - PIE queue management policy ( whose parameters are in q - > fs ) . Update stats for the queue and the scheduler . Return 0 on success 1 on drop . The packet is consumed anyways .
static int
pie_enqueue(struct fq_pie_flow *q, struct mbuf* m, struct fq_pie_si *si)
{
	uint64_t len;
	struct pie_status *pst;
	struct dn_aqm_pie_parms *pprms;
	int t;
	len = m->m_pkthdr.len;
	pst  = &q->pst;
	pprms = pst->parms;
	t = ENQUE;
	if (pst->sflags & PIE_ACTIVE && pst->burst_allowance == 0
		&& drop_early(pst, q->stats.len_bytes) == DROP) {
			if (pprms->flags & PIE_ECN_ENABLED && pst->drop_prob < 
				(pprms->max_ecnth << (PIE_PROB_BITS - PIE_FIX_POINT_BITS))
				&& ecn_mark(m))
				t = ENQUE;
			else
				t = DROP;
		}
	if (!(pst->sflags & PIE_ACTIVE) && q->stats.len_bytes >= 
		pst->one_third_q_size) {
		fq_activate_pie(q);
	}
	if (pst->drop_prob == 0 && pst->current_qdelay < (pprms->qdelay_ref >> 1)
		&& pst->qdelay_old < (pprms->qdelay_ref >> 1)) {
			pst->burst_allowance = pprms->max_burst;
		if (pprms->flags & PIE_ON_OFF_MODE_ENABLED && q->stats.len_bytes<=0)
			fq_deactivate_pie(pst);
	}
	if (t != DROP && !(pprms->flags & PIE_DEPRATEEST_ENABLED)) {
		struct m_tag *mtag;
		mtag = m_tag_locate(m, MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, NULL);
		if (mtag == NULL)
			mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS,
				sizeof(aqm_time_t), M_NOWAIT);
		if (mtag == NULL) {
			m_freem(m); 
			t = DROP;
		}
		*(aqm_time_t *)(mtag + 1) = AQM_UNOW;
		m_tag_prepend(m, mtag);
	}
	if (t != DROP) {
		mq_append(&q->mq, m);
		fq_update_stats(q, si, len, 0);
		return 0;
	} else {
		fq_update_stats(q, si, len, 1);
		pst->accu_prob = 0;
		FREE_PKT(m);
		return 1;
	}
	return 0;
}
static int pie_enqueue ( struct fq_pie_flow * q , struct mbuf * m , struct fq_pie_si * si ) { uint64_t len ; struct pie_status * pst ; struct dn_aqm_pie_parms * pprms ; int t ; len = m -> m_pkthdr . len ; pst = & q -> pst ; pprms = pst -> parms ; t = ENQUE ; if ( pst -> sflags & PIE_ACTIVE && pst -> burst_allowance == 0 && drop_early ( pst , q -> stats . len_bytes ) == DROP ) { if ( pprms -> flags & PIE_ECN_ENABLED && pst -> drop_prob < ( pprms -> max_ecnth << ( PIE_PROB_BITS - PIE_FIX_POINT_BITS ) ) && ecn_mark ( m ) ) t = ENQUE ; else t = DROP ; } if ( ! ( pst -> sflags & PIE_ACTIVE ) && q -> stats . len_bytes >= pst -> one_third_q_size ) { fq_activate_pie ( q ) ; } if ( pst -> drop_prob == 0 && pst -> current_qdelay < ( pprms -> qdelay_ref >> 1 ) && pst -> qdelay_old < ( pprms -> qdelay_ref >> 1 ) ) { pst -> burst_allowance = pprms -> max_burst ; if ( pprms -> flags & PIE_ON_OFF_MODE_ENABLED && q -> stats . len_bytes <= 0 ) fq_deactivate_pie ( pst ) ; } if ( t != DROP && ! ( pprms -> flags & PIE_DEPRATEEST_ENABLED ) ) { struct m_tag * mtag ; mtag = m_tag_locate ( m , MTAG_ABI_COMPAT , DN_AQM_MTAG_TS , NULL ) ; if ( mtag == NULL ) mtag = m_tag_alloc ( MTAG_ABI_COMPAT , DN_AQM_MTAG_TS , sizeof ( aqm_time_t ) , M_NOWAIT ) ; if ( mtag == NULL ) { m_freem ( m ) ; t = DROP ; } * ( aqm_time_t * ) ( mtag + 1 ) = AQM_UNOW ; m_tag_prepend ( m , mtag ) ; } if ( t != DROP ) { mq_append ( & q -> mq , m ) ; fq_update_stats ( q , si , len , 0 ) ; return 0 ; } else { fq_update_stats ( q , si , len , 1 ) ; pst -> accu_prob = 0 ; FREE_PKT ( m ) ; return 1 ; } return 0 ; }
Enqueue a packet in q, subject to space and FQ-PIE queue management policy
 (whose parameters are in q->fs).
Enqueue a packet in q subject to space and FQ - PIE queue management policy ( whose parameters are in q - > fs ) .
/* drop/mark the packet when PIE is active and burst time elapsed */ /* 
			 * if drop_prob over ECN threshold, drop the packet 
			 * otherwise mark and enqueue it.
			 */ /* Turn PIE on when 1/3 of the queue is full */ /*  reset burst tolerance and optinally turn PIE off*/ /* Use timestamp if Departure Rate Estimation mode is disabled */ /* Add TS to mbuf as a TAG */