cvs commit: src/sys/dev/netif/vr if_vr.c

Joerg Sonnenberger joerg at britannica.bec.de
Tue Mar 8 06:04:18 PST 2005


On Mon, Mar 07, 2005 at 01:15:51PM -0500, Andrew Atrens wrote:
> Hey Joerg,
> 
> Is it worth adding -DALTQ to the module's Makefile, too, or
> are you planning to move the ALTQ conditionals out of ifq_var.h ?
> 
> Andrew.

Depends. We could remove the conditionals in combination with the
attached patch, which almost allows us to make ALTQ module-loadable
itself. What do you all think? Jeff, you saw that patch already.

Joerg
Index: if.c
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/net/if.c,v
retrieving revision 1.28
diff -u -r1.28 if.c
--- if.c	11 Feb 2005 22:25:57 -0000	1.28
+++ if.c	28 Feb 2005 00:17:38 -0000
@@ -82,6 +82,15 @@
 #endif /* COMPAT_43 */
 
 /*
+ * Support for non-ALTQ interfaces.
+ */
+static int	ifq_classic_enqueue(struct ifaltq *, struct mbuf *,
+				    struct altq_pktattr *);
+static struct mbuf *
+		ifq_classic_dequeue(struct ifaltq *, int);
+static int	ifq_classic_request(struct ifaltq *, int, void *);
+
+/*
  * System initialization
  */
 
@@ -160,6 +169,7 @@
 	int namelen, masklen;
 	struct sockaddr_dl *sdl;
 	struct ifaddr *ifa;
+	struct ifaltq *ifq;
 
 	static int if_indexlim = 8;
 	static boolean_t inited;
@@ -240,11 +250,15 @@
 
 	EVENTHANDLER_INVOKE(ifnet_attach_event, ifp);
 
-	ifp->if_snd.altq_type = 0;
-	ifp->if_snd.altq_disc = NULL;
-	ifp->if_snd.altq_flags &= ALTQF_CANTCHANGE;
-	ifp->if_snd.altq_tbr = NULL;
-	ifp->if_snd.altq_ifp = ifp;
+	ifq = &ifp->if_snd;
+	ifq->altq_type = 0;
+	ifq->altq_disc = NULL;
+	ifq->altq_flags &= ALTQF_CANTCHANGE;
+	ifq->altq_tbr = NULL;
+	ifq->altq_ifp = ifp;
+	ifq->altq_enqueue = ifq_classic_enqueue;
+	ifq->altq_dequeue = ifq_classic_dequeue;
+	ifq->altq_request = ifq_classic_request;
 
 	if (domains)
 		if_attachdomain1(ifp);
@@ -1783,3 +1797,49 @@
 
 SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");
 SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management");
+
+static int
+ifq_classic_enqueue(struct ifaltq *ifq, struct mbuf *m,
+		    struct altq_pktattr *pa __unused)
+{
+	if (IF_QFULL(ifq)) {
+		m_freem(m);
+		return(ENOBUFS);
+	} else {
+		IF_ENQUEUE(ifq, m);
+		return(0);
+	}	
+}
+
+static struct mbuf *
+ifq_classic_dequeue(struct ifaltq *ifq, int op)
+{
+	struct mbuf *m;
+
+	switch (op) {
+	case ALTDQ_POLL:
+		IF_POLL(ifq, m);
+		break;
+	case ALTDQ_REMOVE:
+		IF_DEQUEUE(ifq, m);
+		break;
+	default:
+		panic("unsupported ALTQ dequeue op: %d", op);
+	}
+
+	return(m);
+}
+
+static int
+ifq_classic_request(struct ifaltq *ifq, int req, void *arg)
+{
+	switch (req) {
+	case ALTRQ_PURGE:
+		IF_DRAIN(ifq);
+		break;
+	default:
+		panic("unspported ALTQ request: %d", req);
+	}
+
+	return(0);
+}
Index: ifq_var.h
===================================================================
RCS file: /home/joerg/wd/repository/dragonflybsd/src/sys/net/ifq_var.h,v
retrieving revision 1.1
diff -u -r1.1 ifq_var.h
--- ifq_var.h	11 Feb 2005 22:25:57 -0000	1.1
+++ ifq_var.h	28 Feb 2005 00:17:28 -0000
@@ -74,17 +74,7 @@
 static __inline int
 ifq_enqueue(struct ifaltq *_ifq, struct mbuf *_m, struct altq_pktattr *_pa)
 {
-	if (ifq_is_enabled(_ifq)) {
-		return((*_ifq->altq_enqueue)(_ifq, _m, _pa));
-	} else {
-		if (IF_QFULL(_ifq)) {
-			m_freem(_m);
-			return(ENOBUFS);
-		} else {
-			IF_ENQUEUE(_ifq, _m);
-			return(0);
-		}
-	}
+	return((*_ifq->altq_enqueue)(_ifq, _m, _pa));
 }
 
 static __inline struct mbuf *
@@ -94,14 +84,7 @@
 	if (_ifq->altq_tbr != NULL)
 		return(tbr_dequeue(_ifq, ALTDQ_REMOVE));
 #endif
-	if (ifq_is_enabled(_ifq)) {
-		return((*_ifq->altq_dequeue)(_ifq, ALTDQ_REMOVE));
-	} else {
-		struct mbuf *_m;
-
-		IF_DEQUEUE(_ifq, _m);
-		return(_m);
-	}
+	return((*_ifq->altq_dequeue)(_ifq, ALTDQ_REMOVE));
 }
 
 static __inline struct mbuf *
@@ -111,23 +94,13 @@
 	if (_ifq->altq_tbr != NULL)
 		return(tbr_dequeue(_ifq, ALTDQ_POLL));
 #endif
-	if (ifq_is_enabled(_ifq)) {
-		return((*_ifq->altq_dequeue)(_ifq, ALTDQ_POLL));
-	} else {
-		struct mbuf *_m;
-
-		IF_POLL(_ifq, _m);
-		return(_m);
-	}
+	return((*_ifq->altq_dequeue)(_ifq, ALTDQ_POLL));
 }
 
 static __inline void
 ifq_purge(struct ifaltq *_ifq)
 {
-	if (ifq_is_enabled(_ifq))
-		(*_ifq->altq_request)(_ifq, ALTRQ_PURGE, NULL);
-	else
-		IF_DRAIN(_ifq);
+	(*_ifq->altq_request)(_ifq, ALTRQ_PURGE, NULL);
 }
 
 static __inline void




More information about the Commits mailing list