From: Sepherosa Ziehau Date: Thu, 3 Jan 2013 09:21:34 +0000 (+0800) Subject: ifq: Add ifq_{is,set,clr}_started to access/modify altq_started X-Git-Tag: v3.4.0rc~567 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/acf18b65c8e880ecd9087a72c1d2a9283362487c ifq: Add ifq_{is,set,clr}_started to access/modify altq_started --- diff --git a/sys/net/if.c b/sys/net/if.c index 595172d072..e5ce25a503 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -320,7 +320,7 @@ if_start_need_schedule(struct ifaltq *ifq, int running) * TBR callout will call ifnet.if_start */ if (!running || !ifq_data_ready(ifq)) { - ifq->altq_started = 0; + ifq_clr_started(ifq); ALTQ_UNLOCK(ifq); return 0; } @@ -381,12 +381,12 @@ if_devstart(struct ifnet *ifp) ASSERT_IFNET_SERIALIZED_TX(ifp); ALTQ_LOCK(ifq); - if (ifq->altq_started || !ifq_data_ready(ifq)) { + if (ifq_is_started(ifq) || !ifq_data_ready(ifq)) { logifstart(avoid, ifp); ALTQ_UNLOCK(ifq); return; } - ifq->altq_started = 1; + ifq_set_started(ifq); ALTQ_UNLOCK(ifq); logifstart(run, ifp); @@ -2575,7 +2575,7 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa) } avoid_start = 0; } - if (!ifq->altq_started) { + if (!ifq_is_started(ifq)) { if (avoid_start) { ALTQ_UNLOCK(ifq); @@ -2592,7 +2592,7 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa) /* * Hold the interlock of ifnet.if_start */ - ifq->altq_started = 1; + ifq_set_started(ifq); start = 1; } ALTQ_UNLOCK(ifq); @@ -2850,11 +2850,11 @@ if_start_rollup(void) int start = 0; ALTQ_LOCK(ifq); - if (!ifq->altq_started) { + if (!ifq_is_started(ifq)) { /* * Hold the interlock of ifnet.if_start */ - ifq->altq_started = 1; + ifq_set_started(ifq); start = 1; } ALTQ_UNLOCK(ifq); diff --git a/sys/net/ifq_var.h b/sys/net/ifq_var.h index 7a31ae9d4f..710b5a7ca4 100644 --- a/sys/net/ifq_var.h +++ b/sys/net/ifq_var.h @@ -345,5 +345,32 @@ ifq_data_ready(struct ifaltq *_ifq) return !ifq_is_empty(_ifq); } +/* + * ALTQ lock must be held + */ +static __inline int +ifq_is_started(const struct ifaltq *_ifq) +{ + return _ifq->altq_started; +} + +/* + * ALTQ lock must be held + */ +static __inline void +ifq_set_started(struct ifaltq *_ifq) +{ + _ifq->altq_started = 1; +} + +/* + * ALTQ lock must be held + */ +static __inline void +ifq_clr_started(struct ifaltq *_ifq) +{ + _ifq->altq_started = 0; +} + #endif /* _KERNEL */ #endif /* _NET_IFQ_VAR_H_ */