FreeBSD/sys/net/altq/altq_fairq.c
/*
 * Locate the next queue we want to pull a packet out of.  This code
 * is also responsible for removing empty buckets from the circular list.
 */
Locate the next queue we want to pull a packet out of.  This code
is also responsible for removing empty buckets from the circular list.
Locate the next queue we want to pull a packet out of . This code is also responsible for removing empty buckets from the circular list .
static
fairq_bucket_t *
fairq_selectq(struct fairq_class *cl, int ispoll)
{
	fairq_bucket_t *b;
	uint64_t bw;
	if (ispoll == 0 && cl->cl_polled) {
		b = cl->cl_polled;
		cl->cl_polled = NULL;
		return(b);
	}
	while ((b = cl->cl_head) != NULL) {
		if (qempty(&b->queue)) {
			b->in_use = 0;
			cl->cl_head = b->next;
			if (cl->cl_head == b) {
				cl->cl_head = NULL;
			} else {
				b->next->prev = b->prev;
				b->prev->next = b->next;
			}
			continue;
		}
		if (cl->cl_hogs_m1 == 0) {
			cl->cl_head = b->next;
		} else if (b->bw_delta) {
			bw = b->bw_bytes * machclk_freq / b->bw_delta;
			if (bw >= cl->cl_hogs_m1) {
				cl->cl_head = b->next;
			}
		}
		break;
	}
	if (ispoll)
		cl->cl_polled = b;
	return(b);
}
static fairq_bucket_t * fairq_selectq ( struct fairq_class * cl , int ispoll ) { fairq_bucket_t * b ; uint64_t bw ; if ( ispoll == 0 && cl -> cl_polled ) { b = cl -> cl_polled ; cl -> cl_polled = NULL ; return ( b ) ; } while ( ( b = cl -> cl_head ) != NULL ) { if ( qempty ( & b -> queue ) ) { b -> in_use = 0 ; cl -> cl_head = b -> next ; if ( cl -> cl_head == b ) { cl -> cl_head = NULL ; } else { b -> next -> prev = b -> prev ; b -> prev -> next = b -> next ; } continue ; } if ( cl -> cl_hogs_m1 == 0 ) { cl -> cl_head = b -> next ; } else if ( b -> bw_delta ) { bw = b -> bw_bytes * machclk_freq / b -> bw_delta ; if ( bw >= cl -> cl_hogs_m1 ) { cl -> cl_head = b -> next ; } } break ; } if ( ispoll ) cl -> cl_polled = b ; return ( b ) ; }
Locate the next queue we want to pull a packet out of.
Locate the next queue we want to pull a packet out of .
/*
		 * Remove empty queues from consideration
		 */ /*
		 * Advance the round robin.  Queues with bandwidths less
		 * then the hog bandwidth are allowed to burst.
		 */ /*
			 * XXX TODO - 
			 */ /*
		 * Return bucket b.
		 */