Index: sys/dev/usb/wlan/if_urtwn.c =================================================================== --- sys/dev/usb/wlan/if_urtwn.c +++ sys/dev/usb/wlan/if_urtwn.c @@ -188,10 +188,10 @@ struct urtwn_data[], int, int); static int urtwn_alloc_rx_list(struct urtwn_softc *); static int urtwn_alloc_tx_list(struct urtwn_softc *); -static void urtwn_free_tx_list(struct urtwn_softc *); -static void urtwn_free_rx_list(struct urtwn_softc *); static void urtwn_free_list(struct urtwn_softc *, struct urtwn_data data[], int); +static void urtwn_free_rx_list(struct urtwn_softc *); +static void urtwn_free_tx_list(struct urtwn_softc *); static struct urtwn_data * _urtwn_getbuf(struct urtwn_softc *); static struct urtwn_data * urtwn_getbuf(struct urtwn_softc *); static int urtwn_write_region_1(struct urtwn_softc *, uint16_t, @@ -268,10 +268,10 @@ static void urtwn_scan_start(struct ieee80211com *); static void urtwn_scan_end(struct ieee80211com *); static void urtwn_set_channel(struct ieee80211com *); +static void urtwn_update_mcast(struct ieee80211com *); static void urtwn_set_chan(struct urtwn_softc *, struct ieee80211_channel *, struct ieee80211_channel *); -static void urtwn_update_mcast(struct ieee80211com *); static void urtwn_iq_calib(struct urtwn_softc *); static void urtwn_lc_calib(struct urtwn_softc *); static void urtwn_init(struct urtwn_softc *); @@ -473,20 +473,6 @@ return (ENXIO); /* failure */ } -static void -urtwn_drain_mbufq(struct urtwn_softc *sc) -{ - struct mbuf *m; - struct ieee80211_node *ni; - URTWN_ASSERT_LOCKED(sc); - while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; - ieee80211_free_node(ni); - m_freem(m); - } -} - static int urtwn_detach(device_t self) { @@ -532,33 +518,16 @@ } static void -urtwn_free_tx_list(struct urtwn_softc *sc) -{ - urtwn_free_list(sc, sc->sc_tx, URTWN_TX_LIST_COUNT); -} - -static void -urtwn_free_rx_list(struct urtwn_softc *sc) -{ - urtwn_free_list(sc, sc->sc_rx, URTWN_RX_LIST_COUNT); -} - -static void -urtwn_free_list(struct urtwn_softc *sc, struct urtwn_data data[], int ndata) +urtwn_drain_mbufq(struct urtwn_softc *sc) { - int i; - - for (i = 0; i < ndata; i++) { - struct urtwn_data *dp = &data[i]; - - if (dp->buf != NULL) { - free(dp->buf, M_USBDEV); - dp->buf = NULL; - } - if (dp->ni != NULL) { - ieee80211_free_node(dp->ni); - dp->ni = NULL; - } + struct mbuf *m; + struct ieee80211_node *ni; + URTWN_ASSERT_LOCKED(sc); + while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { + ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; + m->m_pkthdr.rcvif = NULL; + ieee80211_free_node(ni); + m_freem(m); } } @@ -886,6 +855,102 @@ sc->sc_txtimer = 0; } +static int +urtwn_alloc_list(struct urtwn_softc *sc, struct urtwn_data data[], + int ndata, int maxsz) +{ + int i, error; + + for (i = 0; i < ndata; i++) { + struct urtwn_data *dp = &data[i]; + dp->sc = sc; + dp->m = NULL; + dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT); + if (dp->buf == NULL) { + device_printf(sc->sc_dev, + "could not allocate buffer\n"); + error = ENOMEM; + goto fail; + } + dp->ni = NULL; + } + + return (0); +fail: + urtwn_free_list(sc, data, ndata); + return (error); +} + +static int +urtwn_alloc_rx_list(struct urtwn_softc *sc) +{ + int error, i; + + error = urtwn_alloc_list(sc, sc->sc_rx, URTWN_RX_LIST_COUNT, + URTWN_RXBUFSZ); + if (error != 0) + return (error); + + STAILQ_INIT(&sc->sc_rx_active); + STAILQ_INIT(&sc->sc_rx_inactive); + + for (i = 0; i < URTWN_RX_LIST_COUNT; i++) + STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next); + + return (0); +} + +static int +urtwn_alloc_tx_list(struct urtwn_softc *sc) +{ + int error, i; + + error = urtwn_alloc_list(sc, sc->sc_tx, URTWN_TX_LIST_COUNT, + URTWN_TXBUFSZ); + if (error != 0) + return (error); + + STAILQ_INIT(&sc->sc_tx_active); + STAILQ_INIT(&sc->sc_tx_inactive); + STAILQ_INIT(&sc->sc_tx_pending); + + for (i = 0; i < URTWN_TX_LIST_COUNT; i++) + STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next); + + return (0); +} + +static void +urtwn_free_list(struct urtwn_softc *sc, struct urtwn_data data[], int ndata) +{ + int i; + + for (i = 0; i < ndata; i++) { + struct urtwn_data *dp = &data[i]; + + if (dp->buf != NULL) { + free(dp->buf, M_USBDEV); + dp->buf = NULL; + } + if (dp->ni != NULL) { + ieee80211_free_node(dp->ni); + dp->ni = NULL; + } + } +} + +static void +urtwn_free_rx_list(struct urtwn_softc *sc) +{ + urtwn_free_list(sc, sc->sc_rx, URTWN_RX_LIST_COUNT); +} + +static void +urtwn_free_tx_list(struct urtwn_softc *sc) +{ + urtwn_free_list(sc, sc->sc_tx, URTWN_TX_LIST_COUNT); +} + static void urtwn_bulk_tx_callback(struct usb_xfer *xfer, usb_error_t error) { @@ -1793,7 +1858,6 @@ return (rssi); } - static int urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, struct urtwn_data *data) @@ -2009,71 +2073,6 @@ ieee80211_start_all(ic); } -static int -urtwn_alloc_list(struct urtwn_softc *sc, struct urtwn_data data[], - int ndata, int maxsz) -{ - int i, error; - - for (i = 0; i < ndata; i++) { - struct urtwn_data *dp = &data[i]; - dp->sc = sc; - dp->m = NULL; - dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT); - if (dp->buf == NULL) { - device_printf(sc->sc_dev, - "could not allocate buffer\n"); - error = ENOMEM; - goto fail; - } - dp->ni = NULL; - } - - return (0); -fail: - urtwn_free_list(sc, data, ndata); - return (error); -} - -static int -urtwn_alloc_rx_list(struct urtwn_softc *sc) -{ - int error, i; - - error = urtwn_alloc_list(sc, sc->sc_rx, URTWN_RX_LIST_COUNT, - URTWN_RXBUFSZ); - if (error != 0) - return (error); - - STAILQ_INIT(&sc->sc_rx_active); - STAILQ_INIT(&sc->sc_rx_inactive); - - for (i = 0; i < URTWN_RX_LIST_COUNT; i++) - STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next); - - return (0); -} - -static int -urtwn_alloc_tx_list(struct urtwn_softc *sc) -{ - int error, i; - - error = urtwn_alloc_list(sc, sc->sc_tx, URTWN_TX_LIST_COUNT, - URTWN_TXBUFSZ); - if (error != 0) - return (error); - - STAILQ_INIT(&sc->sc_tx_active); - STAILQ_INIT(&sc->sc_tx_inactive); - STAILQ_INIT(&sc->sc_tx_pending); - - for (i = 0; i < URTWN_TX_LIST_COUNT; i++) - STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next); - - return (0); -} - static __inline int urtwn_power_on(struct urtwn_softc *sc) { @@ -2714,7 +2713,7 @@ } } -void +static void urtwn_rf_init(struct urtwn_softc *sc) { const struct urtwn_rf_prog *prog; @@ -2855,7 +2854,7 @@ urtwn_write_4(sc, R92C_EDCA_VO_PARAM, 0x002fa226); } -void +static void urtwn_write_txpower(struct urtwn_softc *sc, int chain, uint16_t power[URTWN_RIDX_COUNT]) { @@ -2915,7 +2914,7 @@ SM(R92C_TXAGC_MCS15, power[27])); } -void +static void urtwn_get_txpower(struct urtwn_softc *sc, int chain, struct ieee80211_channel *c, struct ieee80211_channel *extc, uint16_t power[URTWN_RIDX_COUNT]) @@ -3014,7 +3013,7 @@ #endif } -void +static void urtwn_r88e_get_txpower(struct urtwn_softc *sc, int chain, struct ieee80211_channel *c, struct ieee80211_channel *extc, uint16_t power[URTWN_RIDX_COUNT]) @@ -3083,7 +3082,7 @@ } } -void +static void urtwn_set_txpower(struct urtwn_softc *sc, struct ieee80211_channel *c, struct ieee80211_channel *extc) {