Deleted Added
sdiff udiff text old ( 288051 ) new ( 288052 )
full compact
1/* $OpenBSD: if_rsu.c,v 1.17 2013/04/15 09:23:01 mglocker Exp $ */
2
3/*-
4 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18#include <sys/cdefs.h>
19__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_rsu.c 288051 2015-09-21 02:12:01Z adrian $");
20
21/*
22 * Driver for Realtek RTL8188SU/RTL8191SU/RTL8192SU.
23 *
24 * TODO:
25 * o 11n support
26 * o h/w crypto
27 * o hostap / ibss / mesh

--- 157 unchanged lines hidden (view full) ---

185static uint8_t rsu_read_1(struct rsu_softc *, uint16_t);
186static uint16_t rsu_read_2(struct rsu_softc *, uint16_t);
187static uint32_t rsu_read_4(struct rsu_softc *, uint16_t);
188static int rsu_fw_iocmd(struct rsu_softc *, uint32_t);
189static uint8_t rsu_efuse_read_1(struct rsu_softc *, uint16_t);
190static int rsu_read_rom(struct rsu_softc *);
191static int rsu_fw_cmd(struct rsu_softc *, uint8_t, void *, int);
192static void rsu_calib_task(void *, int);
193static int rsu_newstate(struct ieee80211vap *, enum ieee80211_state, int);
194#ifdef notyet
195static void rsu_set_key(struct rsu_softc *, const struct ieee80211_key *);
196static void rsu_delete_key(struct rsu_softc *, const struct ieee80211_key *);
197#endif
198static int rsu_site_survey(struct rsu_softc *, struct ieee80211vap *);
199static int rsu_join_bss(struct rsu_softc *, struct ieee80211_node *);
200static int rsu_disconnect(struct rsu_softc *);

--- 11 unchanged lines hidden (view full) ---

212static void rsu_txeof(struct usb_xfer *, struct rsu_data *);
213static int rsu_raw_xmit(struct ieee80211_node *, struct mbuf *,
214 const struct ieee80211_bpf_params *);
215static void rsu_init(struct rsu_softc *);
216static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *,
217 struct mbuf *, struct rsu_data *);
218static int rsu_transmit(struct ieee80211com *, struct mbuf *);
219static void rsu_start(struct rsu_softc *);
220static void rsu_parent(struct ieee80211com *);
221static void rsu_stop(struct rsu_softc *);
222static void rsu_ms_delay(struct rsu_softc *, int);
223
224static device_method_t rsu_methods[] = {
225 DEVMETHOD(device_probe, rsu_match),
226 DEVMETHOD(device_attach, rsu_attach),
227 DEVMETHOD(device_detach, rsu_detach),

--- 146 unchanged lines hidden (view full) ---

374 "the driver currently only supports 4-endpoint devices\n");
375 return (ENXIO);
376 }
377
378 mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
379 MTX_DEF);
380 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_task, 0,
381 rsu_calib_task, sc);
382 mbufq_init(&sc->sc_snd, ifqmaxlen);
383
384 /* Allocate Tx/Rx buffers. */
385 error = rsu_alloc_rx_list(sc);
386 if (error != 0) {
387 device_printf(sc->sc_dev, "could not allocate Rx buffers\n");
388 goto fail_usb;
389 }

--- 118 unchanged lines hidden (view full) ---

508 rsu_stop(sc);
509 RSU_UNLOCK(sc);
510 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
511
512 /* Frames are freed; detach from net80211 */
513 ieee80211_ifdetach(ic);
514
515 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
516
517 /* Free Tx/Rx buffers. */
518 rsu_free_tx_list(sc);
519 rsu_free_rx_list(sc);
520
521 mtx_destroy(&sc->sc_mtx);
522
523 return (0);

--- 497 unchanged lines hidden (view full) ---

1021 RSU_DPRINTF(sc, RSU_DEBUG_CALIB, "%s: RSSI=%d%%\n",
1022 __func__, reg >> 4);
1023 }
1024 if (sc->sc_calibrating)
1025 taskqueue_enqueue_timeout(taskqueue_thread, &sc->calib_task, hz);
1026 RSU_UNLOCK(sc);
1027}
1028
1029static int
1030rsu_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
1031{
1032 struct rsu_vap *uvp = RSU_VAP(vap);
1033 struct ieee80211com *ic = vap->iv_ic;
1034 struct rsu_softc *sc = ic->ic_softc;
1035 struct ieee80211_node *ni;
1036 struct ieee80211_rateset *rs;

--- 8 unchanged lines hidden (view full) ---

1045
1046 IEEE80211_UNLOCK(ic);
1047 if (ostate == IEEE80211_S_RUN) {
1048 RSU_LOCK(sc);
1049 /* Stop calibration. */
1050 sc->sc_calibrating = 0;
1051 RSU_UNLOCK(sc);
1052 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
1053 /* Disassociate from our current BSS. */
1054 RSU_LOCK(sc);
1055 rsu_disconnect(sc);
1056 } else
1057 RSU_LOCK(sc);
1058 switch (nstate) {
1059 case IEEE80211_S_INIT:
1060 break;

--- 772 unchanged lines hidden (view full) ---

1833 }
1834 break;
1835 }
1836}
1837
1838static void
1839rsu_bulk_tx_callback_be_bk(struct usb_xfer *xfer, usb_error_t error)
1840{
1841 rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_BE_BK);
1842}
1843
1844static void
1845rsu_bulk_tx_callback_vi_vo(struct usb_xfer *xfer, usb_error_t error)
1846{
1847 rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_VI_VO);
1848}
1849
1850static void
1851rsu_bulk_tx_callback_h2c(struct usb_xfer *xfer, usb_error_t error)
1852{
1853 rsu_bulk_tx_callback_sub(xfer, error, RSU_BULK_TX_H2C);
1854}
1855
1856static int
1857rsu_tx_start(struct rsu_softc *sc, struct ieee80211_node *ni,
1858 struct mbuf *m0, struct rsu_data *data)
1859{
1860 struct ieee80211com *ic = &sc->sc_ic;
1861 struct ieee80211vap *vap = ni->ni_vap;

--- 141 unchanged lines hidden (view full) ---

2003 if (error) {
2004 RSU_DPRINTF(sc, RSU_DEBUG_TX,
2005 "%s: mbufq_enable: failed (%d)\n",
2006 __func__,
2007 error);
2008 RSU_UNLOCK(sc);
2009 return (error);
2010 }
2011 rsu_start(sc);
2012 RSU_UNLOCK(sc);
2013
2014 return (0);
2015}
2016
2017static void
2018rsu_drain_mbufq(struct rsu_softc *sc)
2019{
2020 struct mbuf *m;
2021 struct ieee80211_node *ni;
2022
2023 RSU_ASSERT_LOCKED(sc);
2024 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
2025 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
2026 m->m_pkthdr.rcvif = NULL;
2027 ieee80211_free_node(ni);
2028 m_freem(m);
2029 }
2030}
2031
2032static void
2033rsu_start(struct rsu_softc *sc)
2034{
2035 struct ieee80211_node *ni;
2036 struct rsu_data *bf;
2037 struct mbuf *m;
2038
2039 RSU_ASSERT_LOCKED(sc);
2040
2041 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {

--- 16 unchanged lines hidden (view full) ---

2058 rsu_freebuf(sc, bf);
2059 ieee80211_free_node(ni);
2060 break;
2061 }
2062 }
2063}
2064
2065static void
2066rsu_parent(struct ieee80211com *ic)
2067{
2068 struct rsu_softc *sc = ic->ic_softc;
2069 int startall = 0;
2070
2071 RSU_LOCK(sc);
2072 if (ic->ic_nrunning > 0) {
2073 if (!sc->sc_running) {

--- 605 unchanged lines hidden (view full) ---

2679static void
2680rsu_stop(struct rsu_softc *sc)
2681{
2682 int i;
2683
2684 sc->sc_running = 0;
2685 sc->sc_calibrating = 0;
2686 taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL);
2687
2688 /* Power off adapter. */
2689 rsu_power_off(sc);
2690
2691 for (i = 0; i < RSU_N_TRANSFER; i++)
2692 usbd_transfer_stop(sc->sc_xfer[i]);
2693
2694 /* Ensure the mbuf queue is drained */

--- 14 unchanged lines hidden ---