svn commit: r185150 - user/kmacy/HEAD_fast_multi_xmit/sys/net
Kip Macy
kmacy at FreeBSD.org
Fri Nov 21 00:00:41 PST 2008
Author: kmacy
Date: Fri Nov 21 08:00:41 2008
New Revision: 185150
URL: http://svn.freebsd.org/changeset/base/185150
Log:
abstract out ifq initialization and teardown to allow drivers to maintain their own
Modified:
user/kmacy/HEAD_fast_multi_xmit/sys/net/if.c
user/kmacy/HEAD_fast_multi_xmit/sys/net/if_var.h
Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/if.c
==============================================================================
--- user/kmacy/HEAD_fast_multi_xmit/sys/net/if.c Fri Nov 21 06:01:05 2008 (r185149)
+++ user/kmacy/HEAD_fast_multi_xmit/sys/net/if.c Fri Nov 21 08:00:41 2008 (r185150)
@@ -480,6 +480,28 @@ if_free_type(struct ifnet *ifp, u_char t
free(ifp, M_IFNET);
};
+void
+ifq_attach(struct ifaltq *ifq, char *buf)
+{
+
+ mtx_init(ifq->ifq_mtx, buf, "if send queue", MTX_DEF);
+
+ if (ifq->ifq_maxlen == 0)
+ ifq->ifq_maxlen = ifqmaxlen;
+
+ ifq->altq_type = 0;
+ ifq->altq_disc = NULL;
+ ifq->altq_flags &= ALTQF_CANTCHANGE;
+ ifq->altq_tbr = NULL;
+ ifq->altq_ifp = ifp;
+}
+
+void
+ifq_detach(struct ifaltq *ifq)
+{
+ mtx_destroy(ifq->ifq_mtx);
+}
+
/*
* Perform generic interface initalization tasks and attach the interface
* to the list of "active" interfaces.
@@ -522,6 +544,7 @@ if_attach(struct ifnet *ifp)
ifp->if_data.ifi_epoch = time_uptime;
ifp->if_data.ifi_datalen = sizeof(struct if_data);
ifp->if_transmit = if_transmit;
+ ifp->if_qflush = if_qflush;
#ifdef MAC
mac_ifnet_init(ifp);
mac_ifnet_create(ifp);
@@ -533,7 +556,7 @@ if_attach(struct ifnet *ifp)
make_dev_alias(ifdev_byindex(ifp->if_index), "%s%d",
net_cdevsw.d_name, ifp->if_index);
- mtx_init(&ifp->if_snd.ifq_mtx, ifp->if_xname, "if send queue", MTX_DEF);
+ ifq_attach(&ifp->if_snd, ifp->if_xname);
/*
* create a Link Level name for this device
@@ -571,19 +594,6 @@ if_attach(struct ifnet *ifp)
TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
ifp->if_broadcastaddr = NULL; /* reliably crash if used uninitialized */
- /*
- * XXX: why do we warn about this? We're correcting it and most
- * drivers just set the value the way we do.
- */
- if (ifp->if_snd.ifq_maxlen == 0) {
- if_printf(ifp, "XXX: driver didn't set ifq_maxlen\n");
- ifp->if_snd.ifq_maxlen = ifqmaxlen;
- }
- 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;
IFNET_WLOCK();
TAILQ_INSERT_TAIL(&V_ifnet, ifp, if_link);
@@ -825,7 +835,7 @@ if_detach(struct ifnet *ifp)
KNOTE_UNLOCKED(&ifp->if_klist, NOTE_EXIT);
knlist_clear(&ifp->if_klist, 0);
knlist_destroy(&ifp->if_klist);
- mtx_destroy(&ifp->if_snd.ifq_mtx);
+ ifq_detach(&ifp->if_snd);
IF_AFDATA_DESTROY(ifp);
splx(s);
}
@@ -1376,7 +1386,8 @@ if_unroute(struct ifnet *ifp, int flag,
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
- if_qflush(&ifp->if_snd);
+ ifp->if_qflush(ifp);
+
#ifdef DEV_CARP
if (ifp->if_carp)
carp_carpdev_state(ifp->if_carp);
@@ -1506,10 +1517,12 @@ if_up(struct ifnet *ifp)
* Flush an interface queue.
*/
static void
-if_qflush(struct ifaltq *ifq)
+if_qflush(struct ifnet *ifp)
{
struct mbuf *m, *n;
-
+ struct ifaltq *ifq;
+
+ ifq = &ifp->if_snd;
IFQ_LOCK(ifq);
#ifdef ALTQ
if (ALTQ_IS_ENABLED(ifq))
Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/if_var.h
==============================================================================
--- user/kmacy/HEAD_fast_multi_xmit/sys/net/if_var.h Fri Nov 21 06:01:05 2008 (r185149)
+++ user/kmacy/HEAD_fast_multi_xmit/sys/net/if_var.h Fri Nov 21 08:00:41 2008 (r185150)
@@ -186,7 +186,9 @@ struct ifnet {
/* protected by if_addr_mtx */
void *if_pf_kif;
void *if_lagg; /* lagg glue */
- void *if_pspare[9]; /* multiq/TOE 3; vimage 3; general use 4 */
+ void *if_pspare[8]; /* multiq/TOE 3; vimage 3; general use 4 */
+ int (*if_qflush) /* flush any queues */
+ (struct ifnet *);
int (*if_transmit) /* initiate output routine */
(struct ifnet *, struct mbuf *);
int if_ispare[2]; /* general use 2 */
@@ -688,6 +690,9 @@ int ifioctl(struct socket *, u_long, cad
int ifpromisc(struct ifnet *, int);
struct ifnet *ifunit(const char *);
+void ifq_attach(struct ifaltq *);
+void ifq_detach(struct ifaltq *);
+
struct ifaddr *ifa_ifwithaddr(struct sockaddr *);
struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *);
struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *);
More information about the svn-src-user
mailing list