FreeBSD/sys/netpfil/ipfw/dn_sched_fq_pie.c
/* 
 * Dequeue and return a pcaket from sub-queue 'q' or NULL if 'q' is empty.
 * Also, caculate depature time or queue delay using timestamp
 */
Dequeue and return a pcaket from sub-queue 'q' or NULL if 'q' is empty.
Also, caculate depature time or queue delay using timestamp
Dequeue and return a pcaket from sub - queue ' q ' or NULL if ' q ' is empty . Also caculate depature time or queue delay using timestamp
static struct mbuf *
pie_dequeue(struct fq_pie_flow *q, struct fq_pie_si *si)
{
	struct mbuf *m;
	struct dn_aqm_pie_parms *pprms;
	struct pie_status *pst;
	aqm_time_t now;
	aqm_time_t pkt_ts, dq_time;
	int32_t w;
	pst  = &q->pst;
	pprms = q->pst.parms;
	m = fq_pie_extract_head(q, &pkt_ts, si, 
		!(pprms->flags & PIE_DEPRATEEST_ENABLED));
	if (!m || !(pst->sflags & PIE_ACTIVE))
		return m;
	now = AQM_UNOW;
	if (pprms->flags & PIE_DEPRATEEST_ENABLED) {
		if(pst->sflags & PIE_INMEASUREMENT) {
			pst->dq_count += m->m_pkthdr.len;
			if (pst->dq_count >= PIE_DQ_THRESHOLD) {
				dq_time = now - pst->measurement_start;
				if(pst->avg_dq_time == 0)
					pst->avg_dq_time = dq_time;
				else {
					w = PIE_DQ_THRESHOLD >> 8;
					pst->avg_dq_time = (dq_time* w
						+ (pst->avg_dq_time * ((1L << 8) - w))) >> 8;
					pst->sflags &= ~PIE_INMEASUREMENT;
				}
			}
		}
		if(!(pst->sflags & PIE_INMEASUREMENT) && 
			q->stats.len_bytes >= PIE_DQ_THRESHOLD) {
			pst->sflags |= PIE_INMEASUREMENT;
			pst->measurement_start = now;
			pst->dq_count = 0;
		}
	}
	else
		pst->current_qdelay = now - pkt_ts;
	return m;	
}
static struct mbuf * pie_dequeue ( struct fq_pie_flow * q , struct fq_pie_si * si ) { struct mbuf * m ; struct dn_aqm_pie_parms * pprms ; struct pie_status * pst ; aqm_time_t now ; aqm_time_t pkt_ts , dq_time ; int32_t w ; pst = & q -> pst ; pprms = q -> pst . parms ; m = fq_pie_extract_head ( q , & pkt_ts , si , ! ( pprms -> flags & PIE_DEPRATEEST_ENABLED ) ) ; if ( ! m || ! ( pst -> sflags & PIE_ACTIVE ) ) return m ; now = AQM_UNOW ; if ( pprms -> flags & PIE_DEPRATEEST_ENABLED ) { if ( pst -> sflags & PIE_INMEASUREMENT ) { pst -> dq_count += m -> m_pkthdr . len ; if ( pst -> dq_count >= PIE_DQ_THRESHOLD ) { dq_time = now - pst -> measurement_start ; if ( pst -> avg_dq_time == 0 ) pst -> avg_dq_time = dq_time ; else { w = PIE_DQ_THRESHOLD >> 8 ; pst -> avg_dq_time = ( dq_time * w + ( pst -> avg_dq_time * ( ( 1L << 8 ) - w ) ) ) >> 8 ; pst -> sflags &= ~ PIE_INMEASUREMENT ; } } } if ( ! ( pst -> sflags & PIE_INMEASUREMENT ) && q -> stats . len_bytes >= PIE_DQ_THRESHOLD ) { pst -> sflags |= PIE_INMEASUREMENT ; pst -> measurement_start = now ; pst -> dq_count = 0 ; } } else pst -> current_qdelay = now - pkt_ts ; return m ; }
Dequeue and return a pcaket from sub-queue 'q' or NULL if 'q' is empty.
Dequeue and return a pcaket from sub - queue ' q ' or NULL if ' q ' is empty .
/*we extarct packet ts only when Departure Rate Estimation dis not used*/ /* calculate average depature time */ /* 
				 * if we don't have old avg dq_time i.e PIE is (re)initialized, 
				 * don't use weight to calculate new avg_dq_time
				 */ /* 
					 * weight = PIE_DQ_THRESHOLD/2^6, but we scaled 
					 * weight by 2^8. Thus, scaled 
					 * weight = PIE_DQ_THRESHOLD /2^8 
					 * */ /* 
		 * Start new measurment cycle when the queue has
		 *  PIE_DQ_THRESHOLD worth of bytes.
		 */ /* Optionally, use packet timestamp to estimate queue delay */