svn commit: r189202 - user/kmacy/releng_7_fast_net/sys/net
Kip Macy
kmacy at FreeBSD.org
Sat Feb 28 20:45:38 PST 2009
Author: kmacy
Date: Sun Mar 1 04:45:37 2009
New Revision: 189202
URL: http://svn.freebsd.org/changeset/base/189202
Log:
multiq step 3:
- if_transmit: add if_transmit and if_qflush to struct ifnet to give
high performance drivers the option of managing their own queues
Modified:
user/kmacy/releng_7_fast_net/sys/net/if.c
user/kmacy/releng_7_fast_net/sys/net/if_var.h
Modified: user/kmacy/releng_7_fast_net/sys/net/if.c
==============================================================================
--- user/kmacy/releng_7_fast_net/sys/net/if.c Sun Mar 1 04:43:30 2009 (r189201)
+++ user/kmacy/releng_7_fast_net/sys/net/if.c Sun Mar 1 04:45:37 2009 (r189202)
@@ -115,10 +115,11 @@ static void if_freemulti(struct ifmultia
static void if_grow(void);
static void if_init(void *);
static void if_check(void *);
-static void if_qflush(struct ifaltq *);
+static void if_qflush(struct ifnet *);
static void if_route(struct ifnet *, int flag, int fam);
static int if_setflag(struct ifnet *, int, int, int *, int);
static void if_slowtimo(void *);
+static int if_transmit(struct ifnet *ifp, struct mbuf *m);
static void if_unroute(struct ifnet *, int flag, int fam);
static void link_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
static int if_rtdel(struct radix_node *, void *);
@@ -128,6 +129,7 @@ static void if_start_deferred(void *cont
static void do_link_state_change(void *, int);
static int if_getgroup(struct ifgroupreq *, struct ifnet *);
static int if_getgroupmembers(struct ifgroupreq *);
+
#ifdef INET6
/*
* XXX: declare here to avoid to include many inet6 related files..
@@ -502,6 +504,28 @@ if_free_type(struct ifnet *ifp, u_char t
free(ifp, M_IFNET);
};
+void
+ifq_attach(struct ifaltq *ifq, struct ifnet *ifp)
+{
+
+ mtx_init(&ifq->ifq_mtx, ifp->if_xname, "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.
@@ -542,7 +566,8 @@ if_attach(struct ifnet *ifp)
getmicrotime(&ifp->if_lastchange);
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_init_ifnet(ifp);
mac_create_ifnet(ifp);
@@ -554,7 +579,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);
/*
* create a Link Level name for this device
@@ -591,11 +616,6 @@ if_attach(struct ifnet *ifp)
ifa->ifa_refcnt = 1;
TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
ifp->if_broadcastaddr = NULL; /* reliably crash if used uninitialized */
- 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(&ifnet, ifp, if_link);
@@ -843,7 +863,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);
}
@@ -1387,7 +1407,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);
@@ -1515,10 +1536,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))
@@ -2794,6 +2817,19 @@ if_start_deferred(void *context, int pen
(ifp->if_start)(ifp);
}
+/*
+ * Backwards compatibility interface for drivers
+ * that have not implemented it
+ */
+static int
+if_transmit(struct ifnet *ifp, struct mbuf *m)
+{
+ int error;
+
+ IFQ_HANDOFF(ifp, m, error);
+ return (error);
+}
+
int
if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
{
Modified: user/kmacy/releng_7_fast_net/sys/net/if_var.h
==============================================================================
--- user/kmacy/releng_7_fast_net/sys/net/if_var.h Sun Mar 1 04:43:30 2009 (r189201)
+++ user/kmacy/releng_7_fast_net/sys/net/if_var.h Sun Mar 1 04:45:37 2009 (r189202)
@@ -186,7 +186,11 @@ struct ifnet {
/* protected by if_addr_mtx */
void *if_pf_kif;
void *if_lagg; /* lagg glue */
- void *if_pspare[10]; /* multiq/TOE 3; vimage 3; general use 4 */
+ void *if_pspare[8]; /* multiq/TOE 3; vimage 3; general use 4 */
+ void (*if_qflush) /* flush any queues */
+ (struct ifnet *);
+ int (*if_transmit) /* initiate output routine */
+ (struct ifnet *, struct mbuf *);
int if_ispare[2]; /* general use 2 */
};
@@ -684,6 +688,9 @@ int ifioctl(struct socket *, u_long, cad
int ifpromisc(struct ifnet *, int);
struct ifnet *ifunit(const char *);
+void ifq_attach(struct ifaltq *, struct ifnet *ifp);
+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