The
ALTQ system is a framework to manage queueing disciplines on network interfaces.
ALTQ introduces new macros to manipulate output queues. The output queue macros are used to abstract queue operations and not to touch the internal fields of the output queue structure. The macros are independent from the
ALTQ implementation, and compatible with the traditional
ifqueue macros for ease of transition.
IFQ_ENQUEUE() enqueues a packet
m to the queue
ifq. The underlying queueing discipline may discard the packet.
err is set to 0 on success, or
ENOBUFS if the packet is discarded.
m will be freed by the device driver on success or by the queueing discipline on failure, so that the caller should not touch
m after calling
IFQ_ENQUEUE().
IFQ_DEQUEUE() dequeues a packet from the queue. The dequeued packet is returned in
m, or
m is set to
NULL if no packet is dequeued. The caller must always check
m since a non-empty queue could return
NULL under rate-limiting.
IFQ_POLL() returns the next packet without removing it from the queue. It is guaranteed by the underlying queueing discipline that
IFQ_DEQUEUE() immediately after
IFQ_POLL() returns the same packet.
IFQ_PURGE() discards all the packets in the queue. The purge operation is needed since a non-work conserving queue cannot be emptied by a dequeue loop.
IFQ_CLASSIFY() classifies a packet to a scheduling class, and returns the result in
pattr.
IFQ_IS_EMPTY() can be used to check if the queue is empty. Note that
IFQ_DEQUEUE() could still return
NULL if the queueing discipline is non-work conserving.
IFQ_SET_MAXLEN() sets the queue length limit to the default FIFO queue.
IFQ_INC_LEN() and
IFQ_DEC_LEN() increment or decrement the current queue length in packets.
IFQ_INC_DROPS() increments the drop counter and is equal to
IF_DROP(). It is defined for naming consistency.
IFQ_SET_READY() sets a flag to indicate this driver is converted to use the new macros.
ALTQ can be enabled only on interfaces with this flag.