From 4cb655c020ce0bf72ffd024a23e2f468760c2c94 Mon Sep 17 00:00:00 2001 From: Max Laier Date: Tue, 15 Jun 2004 01:45:19 +0000 Subject: [PATCH] Transform tbr_dequeue into a function pointer in order to build drivers with ALTQ enabled versions of IFQ_* macros by default, as requested by serveral others. This is a follow-up to the quick fix I committed yesterday which turned off the ALTQ checks for non-ALTQ kernels. --- sys/contrib/altq/altq/altq_subr.c | 6 +++++- sys/contrib/altq/altq/if_altq.h | 4 ++-- sys/net/if.c | 4 ++-- sys/net/if_var.h | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/contrib/altq/altq/altq_subr.c b/sys/contrib/altq/altq/altq_subr.c index 435f7ab4462..b673d3c9406 100644 --- a/sys/contrib/altq/altq/altq_subr.c +++ b/sys/contrib/altq/altq/altq_subr.c @@ -91,6 +91,7 @@ */ static void tbr_timeout(void *); int (*altq_input)(struct mbuf *, int) = NULL; +static struct mbuf *tbr_dequeue(struct ifaltq *, int); static int tbr_timer = 0; /* token bucket regulator timer */ static struct callout tbr_callout = CALLOUT_INITIALIZER; @@ -312,7 +313,7 @@ altq_assert(file, line, failedexpr) #define TBR_SCALE(x) ((int64_t)(x) << TBR_SHIFT) #define TBR_UNSCALE(x) ((x) >> TBR_SHIFT) -struct mbuf * +static struct mbuf * tbr_dequeue(ifq, op) struct ifaltq *ifq; int op; @@ -370,6 +371,9 @@ tbr_set(ifq, profile) struct tb_profile *profile; { struct tb_regulator *tbr, *otbr; + + if (tbr_dequeue_ptr == NULL) + tbr_dequeue_ptr = tbr_dequeue; if (machclk_freq == 0) init_machclk(); diff --git a/sys/contrib/altq/altq/if_altq.h b/sys/contrib/altq/altq/if_altq.h index 8e605870f1b..0676e401f0b 100644 --- a/sys/contrib/altq/altq/if_altq.h +++ b/sys/contrib/altq/altq/if_altq.h @@ -181,9 +181,9 @@ extern int altq_attach(struct ifaltq *, int, void *, extern int altq_detach(struct ifaltq *); extern int altq_enable(struct ifaltq *); extern int altq_disable(struct ifaltq *); -extern struct mbuf *tbr_dequeue(struct ifaltq *, int); +extern struct mbuf *(*tbr_dequeue_ptr)(struct ifaltq *, int); extern int (*altq_input)(struct mbuf *, int); -#if 1 /* ALTQ3_CLFIER_COMPAT */ +#if 0 /* ALTQ3_CLFIER_COMPAT */ void altq_etherclassify(struct ifaltq *, struct mbuf *, struct altq_pktattr *); #endif #endif /* _KERNEL */ diff --git a/sys/net/if.c b/sys/net/if.c index c1d874a647d..79420656abc 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -75,6 +75,8 @@ #include #endif +struct mbuf *(*tbr_dequeue_ptr)(struct ifaltq *, int) = NULL; + static void if_attachdomain(void *); static void if_attachdomain1(struct ifnet *); static int ifconf(u_long, caddr_t); @@ -441,13 +443,11 @@ if_attach(struct ifnet *ifp) ifa->ifa_refcnt = 1; TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link); ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */ -#ifdef ALTQ 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; -#endif if (domains) if_attachdomain1(ifp); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 0354f534cbd..58372adb857 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -356,7 +356,7 @@ if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust) (*ifp->if_start)(ifp); return (1); } -#ifdef ALTQ +#if 1 /* ALTQ */ #define IFQ_ENQUEUE(ifq, m, err) \ do { \ IF_LOCK(ifq); \ @@ -379,7 +379,7 @@ do { \ #define IFQ_DEQUEUE_NOLOCK(ifq, m) \ do { \ if (TBR_IS_ENABLED(ifq)) \ - (m) = tbr_dequeue(ifq, ALTDQ_REMOVE); \ + (m) = tbr_dequeue_ptr(ifq, ALTDQ_REMOVE); \ else if (ALTQ_IS_ENABLED(ifq)) \ ALTQ_DEQUEUE(ifq, m); \ else \ @@ -396,7 +396,7 @@ do { \ #define IFQ_POLL_NOLOCK(ifq, m) \ do { \ if (TBR_IS_ENABLED(ifq)) \ - (m) = tbr_dequeue(ifq, ALTDQ_POLL); \ + (m) = tbr_dequeue_ptr(ifq, ALTDQ_POLL); \ else if (ALTQ_IS_ENABLED(ifq)) \ ALTQ_POLL(ifq, m); \ else \