FreeBSD/sys/net/altq/altq_fairq.c
/*
 * Figure out what the next packet would be if there were no limits.  If
 * this class hits its bandwidth limit *hit_limit is set to no-zero, otherwise
 * it is set to 0.  A non-NULL mbuf is returned either way.
 */
Figure out what the next packet would be if there were no limits.  If
this class hits its bandwidth limit *hit_limit is set to no-zero, otherwise
it is set to 0.  A non-NULL mbuf is returned either way.
Figure out what the next packet would be if there were no limits . If this class hits its bandwidth limit * hit_limit is set to no - zero otherwise it is set to 0 . A non - NULL mbuf is returned either way .
static struct mbuf *
fairq_pollq(struct fairq_class *cl, uint64_t cur_time, int *hit_limit)
{
	fairq_bucket_t *b;
	struct mbuf *m;
	uint64_t delta;
	uint64_t bw;
	*hit_limit = 0;
	b = fairq_selectq(cl, 1);
	if (b == NULL)
		return(NULL);
	m = qhead(&b->queue);
	delta = cur_time - cl->cl_last_time;
	if (delta > machclk_freq * 8)
		delta = machclk_freq * 8;
	cl->cl_bw_delta += delta;
	cl->cl_last_time = cur_time;
	if (cl->cl_bw_delta) {
		bw = cl->cl_bw_bytes * machclk_freq / cl->cl_bw_delta;
		if (bw > cl->cl_bandwidth)
			*hit_limit = 1;
#ifdef ALTQ_DEBUG
		printf("BW %6ju relative to %6u %d queue %p\n",
			(uintmax_t)bw, cl->cl_bandwidth, *hit_limit, b);
#endif
	}
	return(m);
}
static struct mbuf * fairq_pollq ( struct fairq_class * cl , uint64_t cur_time , int * hit_limit ) { fairq_bucket_t * b ; struct mbuf * m ; uint64_t delta ; uint64_t bw ; * hit_limit = 0 ; b = fairq_selectq ( cl , 1 ) ; if ( b == NULL ) return ( NULL ) ; m = qhead ( & b -> queue ) ; delta = cur_time - cl -> cl_last_time ; if ( delta > machclk_freq * 8 ) delta = machclk_freq * 8 ; cl -> cl_bw_delta += delta ; cl -> cl_last_time = cur_time ; if ( cl -> cl_bw_delta ) { bw = cl -> cl_bw_bytes * machclk_freq / cl -> cl_bw_delta ; if ( bw > cl -> cl_bandwidth ) * hit_limit = 1 ; #ifdef ALTQ_DEBUG printf ( " \n " , ( uintmax_t ) bw , cl -> cl_bandwidth , * hit_limit , b ) ; #endif } return ( m ) ; }
Figure out what the next packet would be if there were no limits.
Figure out what the next packet would be if there were no limits .
/*
	 * Did this packet exceed the class bandwidth?  Calculate the
	 * bandwidth component of the packet.
	 *
	 * - Calculate bytes per second
	 */