Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/usb Move queueing of rx/tx xfers back into urt...



details:   https://anonhg.NetBSD.org/src-all/rev/b8c5e597f6b9
branches:  trunk
changeset: 371421:b8c5e597f6b9
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sun Aug 16 06:21:15 2020 +1000

description:
Move queueing of rx/tx xfers back into urtwn_init and closing of
the usb pipes back into urtwn_stop.

Fixes bring the interface up and down rapidly as the pending transfers
between these state transitions are aborted.

diffstat:

 sys/dev/usb/if_urtwn.c |  66 +++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 32 deletions(-)

diffs (125 lines):

diff -r 5b81ca934899 -r b8c5e597f6b9 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c    Sun Aug 16 05:02:36 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c    Sun Aug 16 06:21:15 2020 +1000
@@ -382,7 +382,6 @@
        struct urtwn_softc *sc = device_private(self);
        struct ieee80211com *ic = &sc->sc_ic;
        struct usb_attach_arg *uaa = aux;
-       struct urtwn_rx_data *data;
        char *devinfop;
        const struct urtwn_dev *dev;
        usb_device_request_t req;
@@ -615,20 +614,6 @@
                goto fail;
        }
 
-       /* Queue Rx xfers. */
-       for (size_t j = 0; j < sc->rx_npipe; j++) {
-               mutex_enter(&sc->sc_rx_mtx); 
-               TAILQ_FOREACH(data, &sc->rx_free_list[j], next) {
-                       usbd_setup_xfer(data->xfer, data, data->buf,
-                           URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
-                           urtwn_rxeof);
-                       error = usbd_transfer(data->xfer);
-                       if (__predict_false(error != USBD_NORMAL_COMPLETION &&
-                           error != USBD_IN_PROGRESS))
-                               goto fail_1;
-               }
-               mutex_exit(&sc->sc_rx_mtx);
-       }
        mutex_exit(&sc->sc_write_mtx);
 
        return;
@@ -646,7 +631,6 @@
 {
        struct urtwn_softc *sc = device_private(self);
        struct ieee80211com *ic = &sc->sc_ic;
-       size_t i;
        int s;
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -672,22 +656,6 @@
                urtwn_close_pipes(sc);
        }
 
-       mutex_enter(&sc->sc_tx_mtx);
-       /* Abort Tx. */
-       for (i = 0; i < sc->tx_npipe; i++) {
-               if (sc->tx_pipe[i] != NULL)
-                       usbd_abort_pipe(sc->tx_pipe[i]);
-       }
-       mutex_exit(&sc->sc_tx_mtx);
-
-       mutex_enter(&sc->sc_rx_mtx);
-       /* Stop Rx pipe. */
-       for (i = 0; i < sc->rx_npipe; i++) {
-               if (sc->rx_pipe[i] != NULL)
-                       usbd_abort_pipe(sc->rx_pipe[i]);
-       }
-       mutex_exit(&sc->sc_rx_mtx);
-
        /* Free Tx/Rx buffers. */
        urtwn_free_tx_list(sc);
        urtwn_free_rx_list(sc);
@@ -5570,6 +5538,7 @@
        struct ieee80211com *ic = vap->iv_ic;
        struct ifmediareq imr;
        struct urtwn_softc *sc = ic->ic_softc;
+       struct urtwn_rx_data *data;
        uint32_t reg;
        int error;
 
@@ -5790,6 +5759,22 @@
        ifp->if_flags |= IFF_RUNNING;
        sc->sc_running = true;
 
+       /* Queue Rx xfers. */
+       for (size_t j = 0; j < sc->rx_npipe; j++) {
+               mutex_enter(&sc->sc_rx_mtx); 
+               TAILQ_FOREACH(data, &sc->rx_free_list[j], next) {
+                       usbd_setup_xfer(data->xfer, data, data->buf,
+                           URTWN_RXBUFSZ, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
+                           urtwn_rxeof);
+                       error = usbd_transfer(data->xfer);
+                       if (__predict_false(error != USBD_NORMAL_COMPLETION &&
+                           error != USBD_IN_PROGRESS)) {
+                               mutex_exit(&sc->sc_rx_mtx);
+                               goto fail;
+                       }
+               }
+               mutex_exit(&sc->sc_rx_mtx);
+       }
        mutex_exit(&sc->sc_write_mtx);
 
        if (ic->ic_opmode == IEEE80211_M_MONITOR)
@@ -5823,6 +5808,7 @@
        struct ieee80211vap *vap = ifp->if_softc;
        struct ieee80211com *ic = vap->iv_ic;
        struct urtwn_softc *sc = ic->ic_softc;
+       size_t i;
        int s;
 
        DPRINTFN(DBG_FN, ("%s: %s\n", device_xname(sc->sc_dev), __func__));
@@ -5839,6 +5825,22 @@
        callout_stop(&sc->sc_scan_to);
        callout_stop(&sc->sc_calib_to);
 
+       mutex_enter(&sc->sc_tx_mtx);
+       /* Abort Tx. */
+       for (i = 0; i < sc->tx_npipe; i++) {
+               if (sc->tx_pipe[i] != NULL)
+                       usbd_abort_pipe(sc->tx_pipe[i]);
+       }
+       mutex_exit(&sc->sc_tx_mtx);
+
+       mutex_enter(&sc->sc_rx_mtx);
+       /* Stop Rx pipe. */
+       for (i = 0; i < sc->rx_npipe; i++) {
+               if (sc->rx_pipe[i] != NULL)
+                       usbd_abort_pipe(sc->rx_pipe[i]);
+       }
+       mutex_exit(&sc->sc_rx_mtx);
+
        sc->sc_running = false;
        if (disable)
                urtwn_chip_stop(sc);



Home | Main Index | Thread Index | Old Index