On 04/11/15(Wed) 10:44, David Gwynne wrote:
> ive sent this to a couple of people before, but that was before i
> added mq_purge and ml_purge.
> 
> it uses mbuf_queues in the net80211 stack instead of ifqueues. this
> means we shrink memory usage slightly, and get some locking.
> 
> could someone give this a run on some wifi chips and see how it goes?

Works for me with iwn(4) and urtwn(4), reads fine, ok mpi@

> cheers,
> dlg
> 
> Index: dev/ic/acx.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/acx.c,v
> retrieving revision 1.113
> diff -u -p -r1.113 acx.c
> --- dev/ic/acx.c      25 Oct 2015 12:48:46 -0000      1.113
> +++ dev/ic/acx.c      4 Nov 2015 00:40:27 -0000
> @@ -930,7 +930,7 @@ acx_start(struct ifnet *ifp)
>               struct mbuf *m;
>               int rate;
>  
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               /* first dequeue management frames */
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
> @@ -958,7 +958,7 @@ acx_start(struct ifnet *ifp)
>                       struct ether_header *eh;
>  
>                       /* then dequeue packets on the powersave queue */
> -                     IF_DEQUEUE(&ic->ic_pwrsaveq, m);
> +                     m = mq_dequeue(&ic->ic_pwrsaveq);
>                       if (m != NULL) {
>                               ni = m->m_pkthdr.ph_cookie;
>                               goto encapped;
> Index: dev/ic/ar5008.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ar5008.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 ar5008.c
> --- dev/ic/ar5008.c   14 Mar 2015 03:38:47 -0000      1.29
> +++ dev/ic/ar5008.c   4 Nov 2015 00:40:27 -0000
> @@ -1058,7 +1058,7 @@ ar5008_swba_intr(struct athn_softc *sc)
>       int error, totlen;
>  
>       if (ic->ic_tim_mcast_pending &&
> -         IF_IS_EMPTY(&ni->ni_savedq) &&
> +         mq_empty(&ni->ni_savedq) &&
>           SIMPLEQ_EMPTY(&sc->txq[ATHN_QID_CAB].head))
>               ic->ic_tim_mcast_pending = 0;
>  
> @@ -1139,10 +1139,10 @@ ar5008_swba_intr(struct athn_softc *sc)
>               if (SIMPLEQ_EMPTY(&sc->txbufs))
>                       break;
>  
> -             IF_DEQUEUE(&ni->ni_savedq, m);
> +             m = mq_dequeue(&ni->ni_savedq);
>               if (m == NULL)
>                       break;
> -             if (!IF_IS_EMPTY(&ni->ni_savedq)) {
> +             if (!mq_empty(&ni->ni_savedq)) {
>                       /* more queued frames, set the more data bit */
>                       wh = mtod(m, struct ieee80211_frame *);
>                       wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
> Index: dev/ic/ar9003.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ar9003.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 ar9003.c
> --- dev/ic/ar9003.c   14 Mar 2015 03:38:47 -0000      1.33
> +++ dev/ic/ar9003.c   4 Nov 2015 00:40:27 -0000
> @@ -1191,7 +1191,7 @@ ar9003_swba_intr(struct athn_softc *sc)
>       int error, totlen;
>  
>       if (ic->ic_tim_mcast_pending &&
> -         IF_IS_EMPTY(&ni->ni_savedq) &&
> +         mq_empty(&ni->ni_savedq) &&
>           SIMPLEQ_EMPTY(&sc->txq[ATHN_QID_CAB].head))
>               ic->ic_tim_mcast_pending = 0;
>  
> @@ -1284,10 +1284,10 @@ ar9003_swba_intr(struct athn_softc *sc)
>               if (SIMPLEQ_EMPTY(&sc->txbufs))
>                       break;
>  
> -             IF_DEQUEUE(&ni->ni_savedq, m);
> +             m = mq_dequeue(&ni->ni_savedq);
>               if (m == NULL)
>                       break;
> -             if (!IF_IS_EMPTY(&ni->ni_savedq)) {
> +             if (!mq_empty(&ni->ni_savedq)) {
>                       /* more queued frames, set the more data bit */
>                       wh = mtod(m, struct ieee80211_frame *);
>                       wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
> Index: dev/ic/ath.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/ath.c,v
> retrieving revision 1.106
> diff -u -p -r1.106 ath.c
> --- dev/ic/ath.c      25 Oct 2015 12:48:46 -0000      1.106
> +++ dev/ic/ath.c      4 Nov 2015 00:40:27 -0000
> @@ -857,7 +857,7 @@ ath_start(struct ifnet *ifp)
>                * Poll the management queue for frames; they
>                * have priority over normal data frames.
>                */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m == NULL) {
>                       /*
>                        * No data frames go out unless we're associated.
> Index: dev/ic/athn.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/athn.c,v
> retrieving revision 1.87
> diff -u -p -r1.87 athn.c
> --- dev/ic/athn.c     25 Oct 2015 12:48:46 -0000      1.87
> +++ dev/ic/athn.c     4 Nov 2015 00:40:27 -0000
> @@ -2549,7 +2549,7 @@ athn_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> @@ -2557,7 +2557,7 @@ athn_start(struct ifnet *ifp)
>               if (ic->ic_state != IEEE80211_S_RUN)
>                       break;
>  
> -             IF_DEQUEUE(&ic->ic_pwrsaveq, m);
> +             m = mq_dequeue(&ic->ic_pwrsaveq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/ic/atw.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/atw.c,v
> retrieving revision 1.89
> diff -u -p -r1.89 atw.c
> --- dev/ic/atw.c      25 Oct 2015 12:48:46 -0000      1.89
> +++ dev/ic/atw.c      4 Nov 2015 00:40:27 -0000
> @@ -3596,7 +3596,7 @@ atw_start(struct ifnet *ifp)
>                * Grab a packet off the management queue, if it
>                * is not empty. Otherwise, from the data queue.
>                */
> -             IF_DEQUEUE(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       ni = m0->m_pkthdr.ph_cookie;
>               } else {
> Index: dev/ic/bwi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/bwi.c,v
> retrieving revision 1.118
> diff -u -p -r1.118 bwi.c
> --- dev/ic/bwi.c      25 Oct 2015 12:48:46 -0000      1.118
> +++ dev/ic/bwi.c      4 Nov 2015 00:40:27 -0000
> @@ -7194,10 +7194,8 @@ bwi_start(struct ifnet *ifp)
>               struct mbuf *m;
>               int mgt_pkt = 0;
>  
> -             IF_POLL(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
> -                     IF_DEQUEUE(&ic->ic_mgtq, m);
> -
>                       ni = m->m_pkthdr.ph_cookie;
>  
>                       mgt_pkt = 1;
> Index: dev/ic/malo.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/malo.c,v
> retrieving revision 1.108
> diff -u -p -r1.108 malo.c
> --- dev/ic/malo.c     25 Oct 2015 12:48:46 -0000      1.108
> +++ dev/ic/malo.c     4 Nov 2015 00:40:27 -0000
> @@ -1010,13 +1010,13 @@ malo_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->sc_txring.queued >= MALO_TX_RING_COUNT) {
>                               ifp->if_flags |= IFF_OACTIVE;
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/ic/rt2560.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rt2560.c,v
> retrieving revision 1.73
> diff -u -p -r1.73 rt2560.c
> --- dev/ic/rt2560.c   25 Oct 2015 12:48:46 -0000      1.73
> +++ dev/ic/rt2560.c   4 Nov 2015 00:40:27 -0000
> @@ -1928,14 +1928,14 @@ rt2560_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->prioq.queued >= RT2560_PRIO_RING_COUNT) {
>                               ifp->if_flags |= IFF_OACTIVE;
>                               sc->sc_flags |= RT2560_PRIO_OACTIVE;
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/ic/rt2661.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rt2661.c,v
> retrieving revision 1.83
> diff -u -p -r1.83 rt2661.c
> --- dev/ic/rt2661.c   25 Oct 2015 12:48:46 -0000      1.83
> +++ dev/ic/rt2661.c   4 Nov 2015 00:40:27 -0000
> @@ -1933,13 +1933,13 @@ rt2661_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->mgtq.queued >= RT2661_MGT_RING_COUNT) {
>                               ifp->if_flags |= IFF_OACTIVE;
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/ic/rt2860.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rt2860.c,v
> retrieving revision 1.82
> diff -u -p -r1.82 rt2860.c
> --- dev/ic/rt2860.c   25 Oct 2015 12:48:46 -0000      1.82
> +++ dev/ic/rt2860.c   4 Nov 2015 00:40:27 -0000
> @@ -1748,7 +1748,7 @@ rt2860_start(struct ifnet *ifp)
>                       break;
>               }
>               /* send pending management frames first */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> @@ -1757,7 +1757,7 @@ rt2860_start(struct ifnet *ifp)
>                       break;
>  
>               /* send buffered frames for power-save mode */
> -             IF_DEQUEUE(&ic->ic_pwrsaveq, m);
> +             m = mq_dequeue(&ic->ic_pwrsaveq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/ic/rtw.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rtw.c,v
> retrieving revision 1.91
> diff -u -p -r1.91 rtw.c
> --- dev/ic/rtw.c      25 Oct 2015 12:48:46 -0000      1.91
> +++ dev/ic/rtw.c      4 Nov 2015 00:40:27 -0000
> @@ -185,7 +185,7 @@ void       rtw_rxdesc_init_all(struct rtw_rxd
>  int   rtw_txring_choose(struct rtw_softc *, struct rtw_txsoft_blk **,
>           struct rtw_txdesc_blk **, int);
>  u_int         rtw_txring_next(struct rtw_regs *, struct rtw_txdesc_blk *);
> -struct mbuf *rtw_80211_dequeue(struct rtw_softc *, struct ifqueue *, int,
> +struct mbuf *rtw_80211_dequeue(struct rtw_softc *, struct mbuf_queue *, int,
>           struct rtw_txsoft_blk **, struct rtw_txdesc_blk **,
>           struct ieee80211_node **, short *);
>  uint64_t rtw_tsf_extend(struct rtw_regs *, u_int32_t);
> @@ -1500,7 +1500,7 @@ rtw_intr_beacon(struct rtw_softc *sc, u_
>                       return;
>               }
>               m->m_pkthdr.ph_cookie = ieee80211_ref_node(ic->ic_bss);
> -             IF_ENQUEUE(&sc->sc_beaconq, m);
> +             mq_enqueue(&sc->sc_beaconq, m);
>               rtw_start(&sc->sc_if);
>       }
>  }
> @@ -2678,13 +2678,13 @@ rtw_txring_choose(struct rtw_softc *sc, 
>  }
>  
>  struct mbuf *
> -rtw_80211_dequeue(struct rtw_softc *sc, struct ifqueue *ifq, int pri,
> +rtw_80211_dequeue(struct rtw_softc *sc, struct mbuf_queue *ifq, int pri,
>      struct rtw_txsoft_blk **tsbp, struct rtw_txdesc_blk **tdbp,
>      struct ieee80211_node **nip, short *if_flagsp)
>  {
>       struct mbuf *m;
>  
> -     if (IF_IS_EMPTY(ifq))
> +     if (mq_empty(ifq))
>               return NULL;
>       if (rtw_txring_choose(sc, tsbp, tdbp, pri) == -1) {
>               DPRINTF(sc, RTW_DEBUG_XMIT_RSRC, ("%s: no ring %d descriptor\n",
> @@ -2693,7 +2693,7 @@ rtw_80211_dequeue(struct rtw_softc *sc, 
>               sc->sc_if.if_timer = 1;
>               return NULL;
>       }
> -     IF_DEQUEUE(ifq, m);
> +     m = mq_dequeue(ifq);
>       *nip = m->m_pkthdr.ph_cookie;
>       return m;
>  }
> Index: dev/ic/rtwvar.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/rtwvar.h,v
> retrieving revision 1.30
> diff -u -p -r1.30 rtwvar.h
> --- dev/ic/rtwvar.h   7 Sep 2010 16:21:43 -0000       1.30
> +++ dev/ic/rtwvar.h   4 Nov 2015 00:40:27 -0000
> @@ -423,7 +423,7 @@ struct rtw_softc {
>       } sc_txtapu;
>       union rtw_keys          sc_keys;
>       int                     sc_txkey;
> -     struct ifqueue          sc_beaconq;
> +     struct mbuf_queue       sc_beaconq;
>       struct rtw_led_state    sc_led_state;
>       u_int                   sc_hwverid;
>  };
> Index: dev/pci/if_iwm.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 if_iwm.c
> --- dev/pci/if_iwm.c  25 Oct 2015 13:04:28 -0000      1.62
> +++ dev/pci/if_iwm.c  4 Nov 2015 00:40:28 -0000
> @@ -5591,7 +5591,7 @@ iwm_start(struct ifnet *ifp)
>               }
>  
>               /* need to send management frames even if we're not RUNning */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/pci/if_iwn.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_iwn.c,v
> retrieving revision 1.145
> diff -u -p -r1.145 if_iwn.c
> --- dev/pci/if_iwn.c  25 Oct 2015 13:04:28 -0000      1.145
> +++ dev/pci/if_iwn.c  4 Nov 2015 00:40:28 -0000
> @@ -3046,7 +3046,7 @@ iwn_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/pci/if_rtwn.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_rtwn.c,v
> retrieving revision 1.7
> diff -u -p -r1.7 if_rtwn.c
> --- dev/pci/if_rtwn.c 25 Oct 2015 13:04:28 -0000      1.7
> +++ dev/pci/if_rtwn.c 4 Nov 2015 00:40:28 -0000
> @@ -1871,7 +1871,7 @@ rtwn_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/pci/if_wpi.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_wpi.c,v
> retrieving revision 1.129
> diff -u -p -r1.129 if_wpi.c
> --- dev/pci/if_wpi.c  25 Oct 2015 13:04:28 -0000      1.129
> +++ dev/pci/if_wpi.c  4 Nov 2015 00:40:28 -0000
> @@ -1905,7 +1905,7 @@ wpi_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/usb/if_athn_usb.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_athn_usb.c,v
> retrieving revision 1.37
> diff -u -p -r1.37 if_athn_usb.c
> --- dev/usb/if_athn_usb.c     25 Oct 2015 12:11:56 -0000      1.37
> +++ dev/usb/if_athn_usb.c     4 Nov 2015 00:40:28 -0000
> @@ -2065,7 +2065,7 @@ athn_usb_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/usb/if_atu.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_atu.c,v
> retrieving revision 1.113
> diff -u -p -r1.113 if_atu.c
> --- dev/usb/if_atu.c  25 Oct 2015 12:11:56 -0000      1.113
> +++ dev/usb/if_atu.c  4 Nov 2015 00:40:29 -0000
> @@ -1944,7 +1944,7 @@ atu_start(struct ifnet *ifp)
>                * Poll the management queue for frames, it has priority over
>                * normal data frames.
>                */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m == NULL) {
>                       DPRINTFN(10, ("%s: atu_start: data packet\n",
>                           sc->atu_dev.dv_xname));
> Index: dev/usb/if_otus.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_otus.c,v
> retrieving revision 1.47
> diff -u -p -r1.47 if_otus.c
> --- dev/usb/if_otus.c 25 Oct 2015 12:11:56 -0000      1.47
> +++ dev/usb/if_otus.c 4 Nov 2015 00:40:29 -0000
> @@ -1416,7 +1416,7 @@ otus_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/usb/if_ral.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_ral.c,v
> retrieving revision 1.133
> diff -u -p -r1.133 if_ral.c
> --- dev/usb/if_ral.c  25 Oct 2015 12:11:56 -0000      1.133
> +++ dev/usb/if_ral.c  4 Nov 2015 00:40:30 -0000
> @@ -1238,13 +1238,13 @@ ural_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->tx_queued >= RAL_TX_LIST_COUNT - 1) {
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               ifp->if_flags |= IFF_OACTIVE;
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/usb/if_rum.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_rum.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 if_rum.c
> --- dev/usb/if_rum.c  25 Oct 2015 12:11:56 -0000      1.112
> +++ dev/usb/if_rum.c  4 Nov 2015 00:40:30 -0000
> @@ -1242,13 +1242,13 @@ rum_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->tx_queued >= RUM_TX_LIST_COUNT - 1) {
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               ifp->if_flags |= IFF_OACTIVE;
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/usb/if_run.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_run.c,v
> retrieving revision 1.111
> diff -u -p -r1.111 if_run.c
> --- dev/usb/if_run.c  25 Oct 2015 12:11:56 -0000      1.111
> +++ dev/usb/if_run.c  4 Nov 2015 00:40:30 -0000
> @@ -2530,7 +2530,7 @@ run_start(struct ifnet *ifp)
>                       break;
>               }
>               /* send pending management frames first */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/usb/if_uath.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_uath.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 if_uath.c
> --- dev/usb/if_uath.c 25 Oct 2015 12:11:56 -0000      1.70
> +++ dev/usb/if_uath.c 4 Nov 2015 00:40:30 -0000
> @@ -1477,13 +1477,13 @@ uath_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->tx_queued >= UATH_TX_DATA_LIST_COUNT) {
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               ifp->if_flags |= IFF_OACTIVE;
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>  
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
> Index: dev/usb/if_upgt.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_upgt.c,v
> retrieving revision 1.70
> diff -u -p -r1.70 if_upgt.c
> --- dev/usb/if_upgt.c 25 Oct 2015 12:11:56 -0000      1.70
> +++ dev/usb/if_upgt.c 4 Nov 2015 00:40:30 -0000
> @@ -1377,11 +1377,9 @@ upgt_start(struct ifnet *ifp)
>       for (i = 0; i < UPGT_TX_COUNT; i++) {
>               struct upgt_data *data_tx = &sc->tx_data[i];
>  
> -             IF_POLL(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       /* management frame */
> -                     IF_DEQUEUE(&ic->ic_mgtq, m);
> -
>                       ni = m->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
>                       if (ic->ic_rawbpf != NULL)
> Index: dev/usb/if_urtw.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_urtw.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 if_urtw.c
> --- dev/usb/if_urtw.c 25 Oct 2015 12:11:56 -0000      1.55
> +++ dev/usb/if_urtw.c 4 Nov 2015 00:40:30 -0000
> @@ -2429,15 +2429,15 @@ urtw_start(struct ifnet *ifp)
>               return;
>  
>       for (;;) {
> -             IF_POLL(&ic->ic_mgtq, m0);
> +             m0 = mq_dequeue(&ic->ic_mgtq);
>               if (m0 != NULL) {
>                       if (sc->sc_tx_low_queued >= URTW_TX_DATA_LIST_COUNT ||
>                           sc->sc_tx_normal_queued >=
>                           URTW_TX_DATA_LIST_COUNT) {
> +                             mq_requeue(&ic->ic_mgtq, m0);
>                               ifp->if_flags |= IFF_OACTIVE;
>                               break;
>                       }
> -                     IF_DEQUEUE(&ic->ic_mgtq, m0);
>                       ni = m0->m_pkthdr.ph_cookie;
>  #if NBPFILTER > 0
>                       if (ic->ic_rawbpf != NULL)
> Index: dev/usb/if_urtwn.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v
> retrieving revision 1.53
> diff -u -p -r1.53 if_urtwn.c
> --- dev/usb/if_urtwn.c        25 Oct 2015 12:11:56 -0000      1.53
> +++ dev/usb/if_urtwn.c        4 Nov 2015 00:40:30 -0000
> @@ -2142,7 +2142,7 @@ urtwn_start(struct ifnet *ifp)
>                       break;
>               }
>               /* Send pending management frames first. */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: dev/usb/if_zyd.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/if_zyd.c,v
> retrieving revision 1.109
> diff -u -p -r1.109 if_zyd.c
> --- dev/usb/if_zyd.c  25 Oct 2015 12:11:56 -0000      1.109
> +++ dev/usb/if_zyd.c  4 Nov 2015 00:40:30 -0000
> @@ -2242,7 +2242,7 @@ zyd_start(struct ifnet *ifp)
>                       break;
>               }
>               /* send pending management frames first */
> -             IF_DEQUEUE(&ic->ic_mgtq, m);
> +             m = mq_dequeue(&ic->ic_mgtq);
>               if (m != NULL) {
>                       ni = m->m_pkthdr.ph_cookie;
>                       goto sendit;
> Index: net80211/ieee80211_input.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_input.c,v
> retrieving revision 1.137
> diff -u -p -r1.137 ieee80211_input.c
> --- net80211/ieee80211_input.c        15 Jul 2015 22:16:42 -0000      1.137
> +++ net80211/ieee80211_input.c        4 Nov 2015 00:40:30 -0000
> @@ -316,6 +316,8 @@ ieee80211_input(struct ifnet *ifp, struc
>                                   ether_sprintf(wh->i_addr2), ic->ic_pssta));
>                       }
>               } else if (ni->ni_pwrsave == IEEE80211_PS_DOZE) {
> +                     struct mbuf *m;
> +
>                       /* turn off PS mode */
>                       ni->ni_pwrsave = IEEE80211_PS_AWAKE;
>                       ic->ic_pssta--;
> @@ -325,10 +327,8 @@ ieee80211_input(struct ifnet *ifp, struc
>                       (*ic->ic_set_tim)(ic, ni->ni_associd, 0);
>  
>                       /* dequeue buffered unicast frames */
> -                     while (!IF_IS_EMPTY(&ni->ni_savedq)) {
> -                             struct mbuf *m;
> -                             IF_DEQUEUE(&ni->ni_savedq, m);
> -                             IF_ENQUEUE(&ic->ic_pwrsaveq, m);
> +                     while ((m = mq_dequeue(&ni->ni_savedq)) != NULL) {
> +                             mq_enqueue(&ic->ic_pwrsaveq, m);
>                               (*ifp->if_start)(ifp);
>                       }
>               }
> @@ -2799,10 +2799,10 @@ ieee80211_recv_pspoll(struct ieee80211co
>       }
>  
>       /* take the first queued frame and put it out.. */
> -     IF_DEQUEUE(&ni->ni_savedq, m);
> +     m = mq_dequeue(&ni->ni_savedq);
>       if (m == NULL)
>               return;
> -     if (IF_IS_EMPTY(&ni->ni_savedq)) {
> +     if (mq_empty(&ni->ni_savedq)) {
>               /* last queued frame, turn off the TIM bit */
>               (*ic->ic_set_tim)(ic, ni->ni_associd, 0);
>       } else {
> @@ -2810,7 +2810,7 @@ ieee80211_recv_pspoll(struct ieee80211co
>               wh = mtod(m, struct ieee80211_frame *);
>               wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
>       }
> -     IF_ENQUEUE(&ic->ic_pwrsaveq, m);
> +     mq_enqueue(&ic->ic_pwrsaveq, m);
>       (*ifp->if_start)(ifp);
>  }
>  #endif       /* IEEE80211_STA_ONLY */
> Index: net80211/ieee80211_node.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
> retrieving revision 1.88
> diff -u -p -r1.88 ieee80211_node.c
> --- net80211/ieee80211_node.c 15 Jul 2015 22:16:42 -0000      1.88
> +++ net80211/ieee80211_node.c 4 Nov 2015 00:40:30 -0000
> @@ -191,7 +191,7 @@ ieee80211_node_lateattach(struct ifnet *
>       ic->ic_bss = ieee80211_ref_node(ni);
>       ic->ic_txpower = IEEE80211_TXPOWER_MAX;
>  #ifndef IEEE80211_STA_ONLY
> -     IFQ_SET_MAXLEN(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE);
> +     mq_init(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE, IPL_NET);
>  #endif
>  }
>  
> @@ -797,7 +797,7 @@ ieee80211_setup_node(struct ieee80211com
>  
>       ni->ni_ic = ic; /* back-pointer */
>  #ifndef IEEE80211_STA_ONLY
> -     IFQ_SET_MAXLEN(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE);
> +     mq_init(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE, IPL_NET);
>       timeout_set(&ni->ni_eapol_to, ieee80211_eapol_timeout, ni);
>       timeout_set(&ni->ni_sa_query_to, ieee80211_sa_query_timeout, ni);
>  #endif
> @@ -1083,8 +1083,7 @@ ieee80211_free_node(struct ieee80211com 
>       RB_REMOVE(ieee80211_tree, &ic->ic_tree, ni);
>       ic->ic_nnodes--;
>  #ifndef IEEE80211_STA_ONLY
> -     if (!IF_IS_EMPTY(&ni->ni_savedq)) {
> -             IF_PURGE(&ni->ni_savedq);
> +     if (mq_purge(&ni->ni_savedq) > 0) {
>               if (ic->ic_set_tim != NULL)
>                       (*ic->ic_set_tim)(ic, ni->ni_associd, 0);
>       }
> @@ -1611,8 +1610,7 @@ ieee80211_node_leave(struct ieee80211com
>               ni->ni_pwrsave = IEEE80211_PS_AWAKE;
>       }
>  
> -     if (!IF_IS_EMPTY(&ni->ni_savedq)) {
> -             IF_PURGE(&ni->ni_savedq);
> +     if (mq_purge(&ni->ni_savedq) > 0) {
>               if (ic->ic_set_tim != NULL)
>                       (*ic->ic_set_tim)(ic, ni->ni_associd, 0);
>       }
> @@ -1772,16 +1770,13 @@ ieee80211_notify_dtim(struct ieee80211co
>  
>       KASSERT(ic->ic_opmode == IEEE80211_M_HOSTAP);
>  
> -     for (;;) {
> -             IF_DEQUEUE(&ni->ni_savedq, m);
> -             if (m == NULL)
> -                     break;
> -             if (!IF_IS_EMPTY(&ni->ni_savedq)) {
> +     while ((m = mq_dequeue(&ni->ni_savedq)) != NULL) {
> +             if (!mq_empty(&ni->ni_savedq)) {
>                       /* more queued frames, set the more data bit */
>                       wh = mtod(m, struct ieee80211_frame *);
>                       wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
>               }
> -             IF_ENQUEUE(&ic->ic_pwrsaveq, m);
> +             mq_enqueue(&ic->ic_pwrsaveq, m);
>               (*ifp->if_start)(ifp);
>       }
>       /* XXX assumes everything has been sent */
> Index: net80211/ieee80211_node.h
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_node.h,v
> retrieving revision 1.46
> diff -u -p -r1.46 ieee80211_node.h
> --- net80211/ieee80211_node.h 12 Sep 2014 16:02:40 -0000      1.46
> +++ net80211/ieee80211_node.h 4 Nov 2015 00:40:30 -0000
> @@ -188,7 +188,7 @@ struct ieee80211_node {
>  
>       /* power saving mode */
>       u_int8_t                ni_pwrsave;
> -     struct ifqueue          ni_savedq;      /* packets queued for pspoll */
> +     struct mbuf_queue       ni_savedq;      /* packets queued for pspoll */
>  
>       /* RSN */
>       struct timeout          ni_eapol_to;
> Index: net80211/ieee80211_output.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_output.c,v
> retrieving revision 1.97
> diff -u -p -r1.97 ieee80211_output.c
> --- net80211/ieee80211_output.c       15 Jul 2015 22:16:42 -0000      1.97
> +++ net80211/ieee80211_output.c       4 Nov 2015 00:40:30 -0000
> @@ -239,7 +239,7 @@ ieee80211_mgmt_output(struct ifnet *ifp,
>           ieee80211_pwrsave(ic, m, ni) != 0)
>               return 0;
>  #endif
> -     IF_ENQUEUE(&ic->ic_mgtq, m);
> +     mq_enqueue(&ic->ic_mgtq, m);
>       ifp->if_timer = 1;
>       (*ifp->if_start)(ifp);
>       return 0;
> @@ -1867,22 +1867,16 @@ ieee80211_pwrsave(struct ieee80211com *i
>                   (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
>                   IEEE80211_FC0_TYPE_CTL)
>                       return 0;
> -             if (IF_IS_EMPTY(&ni->ni_savedq))
> +             if (mq_empty(&ni->ni_savedq))
>                       (*ic->ic_set_tim)(ic, ni->ni_associd, 1);
>       }
>       /* NB: ni == ic->ic_bss for broadcast/multicast */
> -     if (IF_QFULL(&ni->ni_savedq)) {
> -             /* XXX should we drop the oldest instead? */
> -             IF_DROP(&ni->ni_savedq);
> -             m_freem(m);
> -     } else {
> -             IF_ENQUEUE(&ni->ni_savedq, m);
> -             /*
> -              * Similar to ieee80211_mgmt_output, store the node in a
> -              * special pkthdr field.
> -              */
> -             m->m_pkthdr.ph_cookie = ni;
> -     }
> +     /*
> +      * Similar to ieee80211_mgmt_output, store the node in a
> +      * special pkthdr field.
> +      */
> +     m->m_pkthdr.ph_cookie = ni;
> +     mq_enqueue(&ni->ni_savedq, m);
>       return 1;
>  }
>  #endif       /* IEEE80211_STA_ONLY */
> Index: net80211/ieee80211_proto.c
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_proto.c,v
> retrieving revision 1.52
> diff -u -p -r1.52 ieee80211_proto.c
> --- net80211/ieee80211_proto.c        15 Jul 2015 22:16:42 -0000      1.52
> +++ net80211/ieee80211_proto.c        4 Nov 2015 00:40:30 -0000
> @@ -84,6 +84,9 @@ ieee80211_proto_attach(struct ifnet *ifp
>  {
>       struct ieee80211com *ic = (void *)ifp;
>  
> +     mq_init(&ic->ic_mgtq, IFQ_MAXLEN, IPL_NET);
> +     mq_init(&ic->ic_pwrsaveq, IFQ_MAXLEN, IPL_NET);
> +
>       ifp->if_hdrlen = sizeof(struct ieee80211_frame);
>  
>  #ifdef notdef
> @@ -108,8 +111,8 @@ ieee80211_proto_detach(struct ifnet *ifp
>  {
>       struct ieee80211com *ic = (void *)ifp;
>  
> -     IF_PURGE(&ic->ic_mgtq);
> -     IF_PURGE(&ic->ic_pwrsaveq);
> +     mq_purge(&ic->ic_mgtq);
> +     mq_purge(&ic->ic_pwrsaveq);
>  }
>  
>  void
> @@ -835,8 +838,8 @@ justcleanup:
>                               timeout_del(&ic->ic_rsn_timeout);
>  #endif
>                       ic->ic_mgt_timer = 0;
> -                     IF_PURGE(&ic->ic_mgtq);
> -                     IF_PURGE(&ic->ic_pwrsaveq);
> +                     mq_purge(&ic->ic_mgtq);
> +                     mq_purge(&ic->ic_pwrsaveq);
>                       ieee80211_free_allnodes(ic);
>                       break;
>               }
> Index: net80211/ieee80211_var.h
> ===================================================================
> RCS file: /cvs/src/sys/net80211/ieee80211_var.h,v
> retrieving revision 1.64
> diff -u -p -r1.64 ieee80211_var.h
> --- net80211/ieee80211_var.h  27 Sep 2015 16:51:31 -0000      1.64
> +++ net80211/ieee80211_var.h  4 Nov 2015 00:40:30 -0000
> @@ -227,8 +227,8 @@ struct ieee80211com {
>       u_char                  ic_chan_avail[howmany(IEEE80211_CHAN_MAX,NBBY)];
>       u_char                  ic_chan_active[howmany(IEEE80211_CHAN_MAX, 
> NBBY)];
>       u_char                  ic_chan_scan[howmany(IEEE80211_CHAN_MAX,NBBY)];
> -     struct ifqueue          ic_mgtq;
> -     struct ifqueue          ic_pwrsaveq;
> +     struct mbuf_queue       ic_mgtq;
> +     struct mbuf_queue       ic_pwrsaveq;
>       u_int                   ic_scan_lock;   /* user-initiated scan */
>       u_int8_t                ic_scan_count;  /* count scans */
>       u_int32_t               ic_flags;       /* state flags */
> 

Reply via email to