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 Alloc and queue xfers on attach / free on ...
details: https://anonhg.NetBSD.org/src-all/rev/17d110ab15a2
branches: trunk
changeset: 990105:17d110ab15a2
user: Nathanial Sloss <nat%netbsd.org@localhost>
date: Sun May 03 07:12:57 2020 +1000
description:
Alloc and queue xfers on attach / free on detach.
diffstat:
sys/dev/usb/if_urtwn.c | 68 +++++++++++++++++++++++++------------------------
1 files changed, 35 insertions(+), 33 deletions(-)
diffs (120 lines):
diff -r ee0585ee21f1 -r 17d110ab15a2 sys/dev/usb/if_urtwn.c
--- a/sys/dev/usb/if_urtwn.c Sun May 03 07:04:28 2020 +1000
+++ b/sys/dev/usb/if_urtwn.c Sun May 03 07:12:57 2020 +1000
@@ -389,6 +389,7 @@
struct usb_attach_arg *uaa = aux;
char *devinfop;
const struct urtwn_dev *dev;
+ struct urtwn_rx_data *data;
usb_device_request_t req;
// NNN loop below size_t i;
int error;
@@ -602,6 +603,35 @@
goto fail;
}
+ /* Allocate Tx/Rx buffers. */
+ error = urtwn_alloc_rx_list(sc);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev,
+ "could not allocate Rx buffers\n");
+ goto fail;
+ }
+
+ error = urtwn_alloc_tx_list(sc);
+ if (error != 0) {
+ aprint_error_dev(sc->sc_dev,
+ "could not allocate Tx buffers\n");
+ 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;
+ }
+ mutex_exit(&sc->sc_rx_mtx);
+ }
return;
fail:
@@ -643,6 +673,10 @@
urtwn_close_pipes(sc);
}
+ /* Free Tx/Rx buffers. */
+ urtwn_free_tx_list(sc);
+ urtwn_free_rx_list(sc);
+
/* sendq destroy */
IFQ_PURGE(&sc->sc_sendq);
IFQ_LOCK_DESTROY(&sc->sc_sendq);
@@ -5510,7 +5544,6 @@
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;
@@ -5530,19 +5563,7 @@
sc->fwcur = 0;
mutex_exit(&sc->sc_fwcmd_mtx);
- /* Allocate Tx/Rx buffers. */
- error = urtwn_alloc_rx_list(sc);
- if (error != 0) {
- aprint_error_dev(sc->sc_dev,
- "could not allocate Rx buffers\n");
- goto fail;
- }
- error = urtwn_alloc_tx_list(sc);
- if (error != 0) {
- aprint_error_dev(sc->sc_dev,
- "could not allocate Tx buffers\n");
- goto fail;
- }
+
/* Power on adapter. */
error = urtwn_power_on(sc);
@@ -5738,21 +5759,6 @@
/* Set default channel. */
urtwn_set_chan(sc, ic->ic_curchan, IEEE80211_HTINFO_2NDCHAN_NONE);
- /* 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;
- }
- mutex_exit(&sc->sc_rx_mtx);
- }
-
/* We're ready to go. */
ifp->if_flags &= ~IFF_OACTIVE;
ifp->if_flags |= IFF_RUNNING;
@@ -5821,10 +5827,6 @@
usbd_abort_pipe(sc->rx_pipe[i]);
}
- /* Free Tx/Rx buffers. */
- urtwn_free_tx_list(sc);
- urtwn_free_rx_list(sc);
-
sc->sc_running = false;
if (disable)
urtwn_chip_stop(sc);
Home |
Main Index |
Thread Index |
Old Index