ifq: Add ifq_purge_all(); currently it's same as ifq_purge()
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 28 Dec 2012 03:08:35 +0000 (11:08 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 28 Dec 2012 03:12:15 +0000 (11:12 +0800)
This paves the way for the multiple transmission queues support.

ifq_purge_all() is used when ALTQ packet scheduler is changed,
interface routing is changed and pseudo devices are closed.

sys/net/altq/altq_cbq.c
sys/net/altq/altq_fairq.c
sys/net/altq/altq_hfsc.c
sys/net/altq/altq_priq.c
sys/net/altq/altq_subr.c
sys/net/if.c
sys/net/ifq_var.h
sys/net/sppp/if_spppsubr.c
sys/net/tap/if_tap.c
sys/net/tun/if_tun.c

index 41c958e..f6c23e0 100644 (file)
@@ -223,7 +223,7 @@ cbq_add_altq(struct pf_altq *a)
        callout_init(&cbqp->cbq_callout);
        cbqp->cbq_qlen = 0;
        cbqp->ifnp.ifq_ = &ifp->if_snd;     /* keep the ifq */
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        /* keep the state in pf_altq */
        a->altq_disc = cbqp;
index bd197d5..71ac80b 100644 (file)
@@ -162,7 +162,7 @@ fairq_add_altq(struct pf_altq *a)
        pif->pif_bandwidth = a->ifbandwidth;
        pif->pif_maxpri = -1;
        pif->pif_ifq = &ifp->if_snd;
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        /* keep the state in pf_altq */
        a->altq_disc = pif;
index 2c3d69a..b0f32d5 100644 (file)
@@ -159,7 +159,7 @@ hfsc_add_altq(struct pf_altq *a)
 
        hif->hif_eligible = ellist_alloc();
        hif->hif_ifq = &ifp->if_snd;
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        /* keep the state in pf_altq */
        a->altq_disc = hif;
index 84eae1b..fd6d29a 100644 (file)
@@ -99,7 +99,7 @@ priq_add_altq(struct pf_altq *a)
        pif->pif_bandwidth = a->ifbandwidth;
        pif->pif_maxpri = -1;
        pif->pif_ifq = &ifp->if_snd;
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        /* keep the state in pf_altq */
        a->altq_disc = pif;
index dab4493..b6f36fb 100644 (file)
@@ -164,7 +164,7 @@ altq_enable_locked(struct ifaltq *ifq)
        if (ifq_is_enabled(ifq))
                return 0;
 
-       ifq_purge_locked(ifq);
+       ifq_purge_all_locked(ifq);
        KKASSERT(ifq->ifq_len == 0);
 
        ifq->altq_flags |= ALTQF_ENABLED;
@@ -190,7 +190,7 @@ altq_disable_locked(struct ifaltq *ifq)
        if (!ifq_is_enabled(ifq))
                return 0;
 
-       ifq_purge_locked(ifq);
+       ifq_purge_all_locked(ifq);
        KKASSERT(ifq->ifq_len == 0);
        ifq->altq_flags &= ~(ALTQF_ENABLED|ALTQF_CLASSIFY);
        return 0;
index 0e57a88..12163f3 100644 (file)
@@ -1315,7 +1315,7 @@ if_unroute(struct ifnet *ifp, int flag, int fam)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        kpfctlinput(PRC_IFDOWN, ifa->ifa_addr);
        }
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
        rt_ifmsg(ifp);
 }
 
@@ -1329,7 +1329,7 @@ if_route(struct ifnet *ifp, int flag, int fam)
 {
        struct ifaddr_container *ifac;
 
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
        ifp->if_flags |= flag;
        getmicrotime(&ifp->if_lastchange);
        TAILQ_FOREACH(ifac, &ifp->if_addrheads[mycpuid], ifa_link) {
index 4b931c8..38a9b77 100644 (file)
@@ -242,6 +242,24 @@ ifq_purge(struct ifaltq *_ifq)
  * WARNING: Should only be called in an MPSAFE manner.
  */
 static __inline void
+ifq_purge_all_locked(struct ifaltq *_ifq)
+{
+       /* XXX temporary */
+       ifq_purge_locked(_ifq);
+}
+
+static __inline void
+ifq_purge_all(struct ifaltq *_ifq)
+{
+       ALTQ_LOCK(_ifq);
+       ifq_purge_all_locked(_ifq);
+       ALTQ_UNLOCK(_ifq);
+}
+
+/*
+ * WARNING: Should only be called in an MPSAFE manner.
+ */
+static __inline void
 ifq_classify(struct ifaltq *_ifq, struct mbuf *_m, uint8_t _af,
             struct altq_pktattr *_pa)
 {
index d8d847b..c599162 100644 (file)
@@ -1063,7 +1063,7 @@ sppp_flush(struct ifnet *ifp)
 {
        struct sppp *sp = (struct sppp*) ifp;
 
-       ifq_purge(&sp->pp_if.if_snd);
+       ifq_purge_all(&sp->pp_if.if_snd);
        IF_DRAIN(&sp->pp_fastq);
        IF_DRAIN(&sp->pp_cpq);
 }
index a7cb035..14ad923 100644 (file)
@@ -400,7 +400,7 @@ tapclose(struct dev_close_args *ap)
        get_mplock();
 
        /* Junk all pending output */
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        /*
         * Do not bring the interface down, and do not anything with
index 3387a88..1819ed2 100644 (file)
@@ -208,7 +208,7 @@ tunclose(struct dev_close_args *ap)
        tp->tun_pid = 0;
 
        /* Junk all pending output. */
-       ifq_purge(&ifp->if_snd);
+       ifq_purge_all(&ifp->if_snd);
 
        if (ifp->if_flags & IFF_UP)
                if_down(ifp);