From 8a4d60fb93b14b5a3d3a50dccd975dc9b633a2e3 Mon Sep 17 00:00:00 2001 From: mlaier Date: Sat, 12 Jun 2004 18:47:24 +0000 Subject: Add an additional queue which will be "owned by the driver". This allows to rig a PREPEND macro for ALTQ as the POLL/DEQUEUE semantic is very bad in terms of locking. We make this a full functional queue to allow "bulk dequeue" which will further reduce the locking overhead (for non-altq enabled devices). Drivers will access this via the following macros, which will show up in once we expose ALTQ to the build: IFQ_DRV_DEQUEUE(ifq, m) - takes a mbuf off the queue (driver queue first) IFQ_DRV_PREPEND(ifq, m) - pushes a mbuf back to the driver queue IFQ_DRV_PURGE(ifq) - drops all packets in both queues IFQ_DRV_IS_EMPTY(ifq) - checks for pending mbufs in either queue One has to make sure that the first three are protected by a driver mutex. At the moment most network drivers still require Giant, so this is not an issue. Even those that have thier own mutex usually hold it in if_start and the like, so this requirement is almost always satisfied. This evolved from a discussion with Andrew Gallatin. --- sys/contrib/altq/altq/if_altq.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sys/contrib/altq') diff --git a/sys/contrib/altq/altq/if_altq.h b/sys/contrib/altq/altq/if_altq.h index 8abb6a6..8e60587 100644 --- a/sys/contrib/altq/altq/if_altq.h +++ b/sys/contrib/altq/altq/if_altq.h @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* $KAME: if_altq.h,v 1.11 2003/07/10 12:07:50 kjc Exp $ */ /* @@ -54,6 +55,12 @@ struct ifaltq { struct mtx ifq_mtx; #endif + /* driver owned queue (used for bulk dequeue and prepend) UNLOCKED */ + struct mbuf *ifq_drv_head; + struct mbuf *ifq_drv_tail; + int ifq_drv_len; + int ifq_drv_maxlen; + /* alternate queueing related fields */ int altq_type; /* discipline type */ int altq_flags; /* flags (e.g. ready, in-use) */ -- cgit v1.1