ifq: Add ifq_get_stage to loacte proper altq_stage data
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 3 Jan 2013 10:04:57 +0000 (18:04 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 3 Jan 2013 10:04:57 +0000 (18:04 +0800)
sys/net/if.c
sys/net/ifq_var.h

index e5ce25a..809af6b 100644 (file)
@@ -273,7 +273,8 @@ if_start_schedule(struct ifnet *ifp, int force)
 
        if (!force && curthread->td_type == TD_TYPE_NETISR &&
            ifq_stage_cntmax > 0) {
-               struct ifaltq_stage *stage = &ifp->if_snd.altq_stage[mycpuid];
+               struct ifaltq_stage *stage =
+                   ifq_get_stage(&ifp->if_snd, mycpuid);
 
                stage->ifqs_cnt = 0;
                stage->ifqs_len = 0;
@@ -705,7 +706,7 @@ static void
 ifq_stage_detach_handler(netmsg_t nmsg)
 {
        struct ifaltq *ifq = nmsg->lmsg.u.ms_resultp;
-       struct ifaltq_stage *stage = &ifq->altq_stage[mycpuid];
+       struct ifaltq_stage *stage = ifq_get_stage(ifq, mycpuid);
 
        if (stage->ifqs_flags & IFQ_STAGE_FLAG_QUED)
                ifq_stage_remove(&ifq_stage_heads[mycpuid], stage);
@@ -2557,7 +2558,7 @@ ifq_dispatch(struct ifnet *ifp, struct mbuf *m, struct altq_pktattr *pa)
 
        if (curthread->td_type == TD_TYPE_NETISR) {
                head = &ifq_stage_heads[mycpuid];
-               stage = &ifq->altq_stage[mycpuid];
+               stage = ifq_get_stage(ifq, mycpuid);
 
                stage->ifqs_cnt++;
                stage->ifqs_len += len;
index 710b5a7..5c51b4f 100644 (file)
@@ -372,5 +372,11 @@ ifq_clr_started(struct ifaltq *_ifq)
        _ifq->altq_started = 0;
 }
 
+static __inline struct ifaltq_stage *
+ifq_get_stage(struct ifaltq *_ifq, int cpuid)
+{
+       return &_ifq->altq_stage[cpuid];
+}
+
 #endif /* _KERNEL */
 #endif /* _NET_IFQ_VAR_H_ */