33#include <sys/endian.h>
34#include <sys/sockio.h>
35#include <sys/malloc.h>
37#include <sys/kernel.h>
38#include <sys/socket.h>
42#include <sys/firmware.h>
43#include <sys/module.h>
47#include <net/if_var.h>
48#include <net/if_arp.h>
50#include <net/if_media.h>
51#include <net/if_types.h>
53#include <netinet/in.h>
54#include <netinet/in_systm.h>
55#include <netinet/in_var.h>
56#include <netinet/if_ether.h>
57#include <netinet/ip.h>
59#include <net80211/ieee80211_var.h>
60#include <net80211/ieee80211_regdomain.h>
61#include <net80211/ieee80211_radiotap.h>
67#include <dev/rtwn/if_rtwn_ridx.h>
70#define RSU_RATE_IS_CCK RTWN_RATE_IS_CCK
73static int rsu_debug = 0;
74SYSCTL_NODE(_hw_usb, OID_AUTO, rsu, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
78#define RSU_DPRINTF(_sc, _flg, ...) \
80 if (((_flg) == (RSU_DEBUG_ANY)) || (rsu_debug & (_flg))) \
81 device_printf((_sc)->sc_dev, __VA_ARGS__); \
84#define RSU_DPRINTF(_sc, _flg, ...)
90#define RSU_DEBUG_ANY 0xffffffff
91#define RSU_DEBUG_TX 0x00000001
92#define RSU_DEBUG_RX 0x00000002
93#define RSU_DEBUG_RESET 0x00000004
94#define RSU_DEBUG_CALIB 0x00000008
95#define RSU_DEBUG_STATE 0x00000010
96#define RSU_DEBUG_SCAN 0x00000020
97#define RSU_DEBUG_FWCMD 0x00000040
98#define RSU_DEBUG_TXDONE 0x00000080
99#define RSU_DEBUG_FW 0x00000100
100#define RSU_DEBUG_FWDBG 0x00000200
101#define RSU_DEBUG_AMPDU 0x00000400
102#define RSU_DEBUG_KEY 0x00000800
103#define RSU_DEBUG_USB 0x00001000
106#define RSU_HT_NOT_SUPPORTED 0
107#define RSU_HT_SUPPORTED 1
108#define RSU_DEV_HT(v,p) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
110#define RSU_DEV(v,p) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, \
111 RSU_HT_NOT_SUPPORTED) }
113 RSU_DEV(AZUREWAVE, RTL8192SU_4),
165static struct ieee80211vap *
167 int,
enum ieee80211_opmode,
int,
const uint8_t bssid[],
168 const uint8_t mac[]);
173 struct ieee80211_channel[]);
207 enum ieee80211_state,
int);
208static int rsu_newstate(
struct ieee80211vap *,
enum ieee80211_state,
int);
209static int rsu_key_alloc(
struct ieee80211vap *,
struct ieee80211_key *,
210 ieee80211_keyix *, ieee80211_keyix *);
212 const struct ieee80211_key *,
int);
214 const struct ieee80211_key *);
216 const struct ieee80211_key *);
222 const struct ieee80211_key *);
224 const struct ieee80211_key *);
229 struct ieee80211_scan_ssid *);
247static int rsu_raw_xmit(
struct ieee80211_node *,
struct mbuf *,
248 const struct ieee80211_bpf_params *);
255static int rsu_transmit(
struct ieee80211com *,
struct mbuf *);
258static int rsu_ioctl_net(
struct ieee80211com *, u_long,
void *);
294#define RSU_H2C_ENDPOINT 3
316 .force_short_xfer = 1
329 .force_short_xfer = 1
386 struct rsu_softc *sc = ni->ni_ic->ic_softc;
390 if (IEEE80211_AMPDU_REQUESTED(tap))
392 if (IEEE80211_AMPDU_RUNNING(tap))
396 req.tid = htole32(tap->txa_tid);
399 if (ieee80211_ampdu_tx_request_ext(ni, tap->txa_tid) != 1)
411 (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 0);
417 (void) ieee80211_ampdu_tx_request_active_ext(ni, tap->txa_tid, 1);
435 struct rsu_softc *sc = device_get_softc(self);
436 struct ieee80211com *ic = &sc->
sc_ic;
456 "the driver currently only supports 4-endpoint devices\n");
460 mtx_init(&sc->
sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
463 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->
calib_task, 0,
467 mbufq_init(&sc->
sc_snd, ifqmaxlen);
472 device_printf(sc->
sc_dev,
"could not allocate Rx buffers\n");
478 device_printf(sc->
sc_dev,
"could not allocate Tx buffers\n");
488 "could not allocate USB transfers, err=%s\n",
496 sc->
cut = (sc->
cut >> 1) + 1;
500 device_printf(self,
"could not read ROM\n");
505 switch (sc->
rom[84]) {
528 rft =
"1T2R ('green')";
532 "%s: unknown board type (rfconfig=0x%02x)\n",
538 IEEE80211_ADDR_COPY(ic->ic_macaddr, &sc->
rom[0x12]);
539 device_printf(self,
"MAC/BB RTL8712 cut %d %s\n", sc->
cut, rft);
542 ic->ic_name = device_get_nameunit(self);
543 ic->ic_phytype = IEEE80211_T_OFDM;
544 ic->ic_opmode = IEEE80211_M_STA;
549 IEEE80211_C_MONITOR |
553 IEEE80211_C_SHPREAMBLE |
559 IEEE80211_CRYPTO_WEP |
560 IEEE80211_CRYPTO_TKIP |
561 IEEE80211_CRYPTO_AES_CCM;
565 device_printf(sc->
sc_dev,
"%s: enabling 11n\n", __func__);
568 ic->ic_htcaps = IEEE80211_HTC_HT |
570 IEEE80211_HTC_AMPDU |
572 IEEE80211_HTC_AMSDU |
573 IEEE80211_HTCAP_MAXAMSDU_3839 |
574 IEEE80211_HTCAP_SMPS_OFF;
575 ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40;
581 ic->ic_flags_ext |= IEEE80211_FEXT_SCAN_OFFLOAD;
586 ieee80211_ifattach(ic);
606 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
608 &sc->sc_rxtap.wr_ihdr,
sizeof(sc->sc_rxtap),
612 ieee80211_announce(ic);
626 struct rsu_softc *sc = device_get_softc(self);
627 struct ieee80211com *ic = &sc->
sc_ic;
644 ieee80211_ifdetach(ic);
646 taskqueue_drain_timeout(taskqueue_thread, &sc->
calib_task);
648 taskqueue_drain(taskqueue_thread, &sc->
tx_task);
671 "Control request failed, %s (retries left: %d)\n",
679static struct ieee80211vap *
681 enum ieee80211_opmode opmode,
int flags,
682 const uint8_t bssid[IEEE80211_ADDR_LEN],
683 const uint8_t mac[IEEE80211_ADDR_LEN])
687 struct ieee80211vap *vap;
690 if (!TAILQ_EMPTY(&ic->ic_vaps))
693 uvp = malloc(
sizeof(
struct rsu_vap), M_80211_VAP, M_WAITOK | M_ZERO);
696 if (ieee80211_vap_setup(ic, vap,
name, unit, opmode,
697 flags, bssid) != 0) {
699 free(uvp, M_80211_VAP);
704 ifp->if_capabilities = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
707 ifp->if_capenable |= IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
712 if (opmode == IEEE80211_M_MONITOR)
721 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_16;
722 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K;
725 ieee80211_vap_attach(vap, ieee80211_media_change,
726 ieee80211_media_status, mac);
727 ic->ic_opmode = opmode;
737 ieee80211_vap_detach(
vap);
738 free(uvp, M_80211_VAP);
745 struct ieee80211_scan_state *ss = ic->ic_scan;
746 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
757 "could not send site survey command\n");
758 ieee80211_cancel_scan(vap);
770 int maxchans,
int *nchans,
struct ieee80211_channel chans[])
773 uint8_t bands[IEEE80211_MODE_BYTES];
776 memset(bands, 0,
sizeof(bands));
777 setbit(bands, IEEE80211_MODE_11B);
778 setbit(bands, IEEE80211_MODE_11G);
780 setbit(bands, IEEE80211_MODE_11NG);
781 ieee80211_add_channels_default_2ghz(chans, maxchans, nchans,
782 bands, (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40) ?
783 NET80211_CBW_FLAG_HT40 : 0);
795 if (ic->ic_opmode == IEEE80211_M_MONITOR) {
799 cmd.
channel = IEEE80211_CHAN2IEEE(ic->ic_curchan);
806 "%s: error %d setting channel\n", __func__,
848 uint64_t mask = 0x00004d101df481b4;
852 for (i = 0; i < IEEE80211_ADDR_LEN; i++)
853 for (j = (i == 0) ? 1 : 0; j < 8; j++)
854 if ((maddr[i] >> j) & 1)
855 pos ^= (mask >> (i * 8 + j - 1));
865 uint32_t *mfilt = arg;
869 mfilt[pos / 32] |= (1 << (pos % 32));
877 struct ieee80211com *ic = &sc->
sc_ic;
883 if (ic->ic_allmulti == 0) {
884 struct ieee80211vap *vap;
889 mfilt[0] = mfilt[1] = 0;
890 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
893 mfilt[0] = mfilt[1] = ~0;
899 __func__, mfilt[0], mfilt[1]);
915 int ndata,
int maxsz)
919 for (i = 0; i < ndata; i++) {
923 dp->
buf = malloc(maxsz, M_USBDEV, M_NOWAIT);
924 if (dp->
buf == NULL) {
926 "could not allocate buffer\n");
949 STAILQ_INIT(&
sc->sc_rx_active);
950 STAILQ_INIT(&
sc->sc_rx_inactive);
953 STAILQ_INSERT_HEAD(&
sc->sc_rx_inactive, &
sc->
sc_rx[i],
next);
968 STAILQ_INIT(&
sc->sc_tx_inactive);
971 STAILQ_INIT(&
sc->sc_tx_active[i]);
972 STAILQ_INIT(&
sc->sc_tx_pending[i]);
976 STAILQ_INSERT_HEAD(&
sc->sc_tx_inactive, &
sc->
sc_tx[i],
next);
988 STAILQ_INIT(&
sc->sc_tx_inactive);
991 STAILQ_INIT(&
sc->sc_tx_active[i]);
992 STAILQ_INIT(&
sc->sc_tx_pending[i]);
1002 STAILQ_INIT(&
sc->sc_rx_inactive);
1003 STAILQ_INIT(&
sc->sc_rx_active);
1013 for (i = 0; i < ndata; i++) {
1016 if (dp->
buf != NULL) {
1017 free(dp->
buf, M_USBDEV);
1020 if (dp->
ni != NULL) {
1021 ieee80211_free_node(dp->
ni);
1032 bf = STAILQ_FIRST(&
sc->sc_tx_inactive);
1034 STAILQ_REMOVE_HEAD(&
sc->sc_tx_inactive,
next);
1059 STAILQ_INSERT_TAIL(&
sc->sc_tx_inactive, bf,
next);
1129 return (le16toh(
val));
1138 return (0xffffffff);
1139 return (le32toh(
val));
1149 for (ntries = 0; ntries < 50; ntries++) {
1165 reg &= ~R92S_EFUSE_CTRL_VALID;
1168 for (ntries = 0; ntries < 100; ntries++) {
1171 return (
MS(
reg, R92S_EFUSE_CTRL_DATA));
1175 "could not read efuse byte at address 0x%x\n",
addr);
1182 uint8_t *rom =
sc->
rom;
1201 while (
addr < 512) {
1208 for (i = 0; i < 4; i++) {
1211 rom[off * 8 + i * 2 + 0] =
1214 rom[off * 8 + i * 2 + 1] =
1223 for (i = 0; i <
sizeof(
sc->
rom); i++)
1224 printf(
"%02x:", rom[i]);
1252 cmdsz = (
len + 7) & ~7;
1254 xferlen =
sizeof(*txd) +
sizeof(*cmd) + cmdsz;
1255 KASSERT(xferlen <=
RSU_TXBUFSZ, (
"%s: invalid length", __func__));
1256 memset(
data->buf, 0, xferlen);
1260 txd->
txdw0 = htole32(
1261 SM(R92S_TXDW0_OFFSET,
sizeof(*txd)) |
1262 SM(R92S_TXDW0_PKTLEN,
sizeof(*cmd) + cmdsz) |
1268 cmd->
len = htole16(cmdsz);
1274 memcpy(&cmd[1], buf,
len);
1277 "%s: Tx cmd code=0x%x len=0x%x\n",
1278 __func__,
code, cmdsz);
1279 data->buflen = xferlen;
1280 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which],
data,
next);
1317 taskqueue_enqueue_timeout(taskqueue_thread, &sc->
calib_task, hz);
1331#define RSU_PWR_UNKNOWN 0x0
1332#define RSU_PWR_ACTIVE 0x1
1333#define RSU_PWR_OFF 0x2
1334#define RSU_PWR_SLEEP 0x3
1366 memset(&cmd, 0,
sizeof(cmd));
1384 device_printf(sc->
sc_dev,
"%s: unknown ps mode (%d)\n",
1391 "%s: setting ps mode to %d (mode %d)\n",
1411 struct ieee80211com *ic = vap->iv_ic;
1415 if (
vap->iv_state != nstate) {
1416 IEEE80211_UNLOCK(ic);
1420 case IEEE80211_S_INIT:
1424 case IEEE80211_S_RUN:
1445 struct ieee80211com *ic = vap->iv_ic;
1447 struct ieee80211_node *ni;
1448 struct ieee80211_rateset *rs;
1449 enum ieee80211_state ostate;
1450 int error, startcal = 0;
1452 ostate = vap->iv_state;
1455 ieee80211_state_name[ostate],
1456 ieee80211_state_name[nstate]);
1458 IEEE80211_UNLOCK(ic);
1459 if (ostate == IEEE80211_S_RUN) {
1469 taskqueue_drain_timeout(taskqueue_thread, &sc->
calib_task);
1470 taskqueue_drain(taskqueue_thread, &sc->
tx_task);
1486 case IEEE80211_S_INIT:
1489 case IEEE80211_S_AUTH:
1490 ni = ieee80211_ref_node(vap->iv_bss);
1493 ieee80211_free_node(ni);
1495 device_printf(sc->
sc_dev,
1496 "could not send join command\n");
1499 case IEEE80211_S_RUN:
1503 ni = ieee80211_ref_node(vap->iv_bss);
1506 ni->ni_txrate = rs->rs_rates[rs->rs_nrates - 1];
1508 ieee80211_free_node(ni);
1514 if (startcal != 0) {
1517 taskqueue_enqueue_timeout(taskqueue_thread, &sc->
calib_task,
1522 return (uvp->
newstate(vap, nstate, arg));
1527 ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
1529 struct rsu_softc *sc = vap->iv_ic->ic_softc;
1532 if (&vap->iv_nw_keys[0] <=
k &&
1533 k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
1534 *keyix = ieee80211_crypto_get_key_wepidx(vap,
k);
1536 if (vap->iv_opmode != IEEE80211_M_STA) {
1540 k->wk_flags |= IEEE80211_KEY_SWCRYPT;
1548 device_printf(sc->
sc_dev,
1549 "%s: key slot %d is already used!\n",
1567 struct rsu_softc *sc = vap->iv_ic->ic_softc;
1570 if (
k->wk_flags & IEEE80211_KEY_SWCRYPT) {
1576 if (&vap->iv_nw_keys[0] <=
k &&
1577 k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) {
1579 (
"keyix %u > %zu\n",
k->wk_keyix, nitems(sc->
group_keys)));
1611 taskqueue_enqueue(taskqueue_thread, &sc->
del_key_task);
1637 for (ntries = 0; ntries < 10; ntries++) {
1644 device_printf(sc->
sc_dev,
1645 "%s: cannot read CAM entry at address %02X\n",
1662 SM(R92S_CAMCMD_ADDR,
addr));
1671 for (ntries = 0; ntries < 20; ntries++) {
1676 device_printf(sc->
sc_dev,
1677 "%s: cannot check key status!\n", __func__);
1684 device_printf(sc->
sc_dev,
1685 "%s: key %d is %s marked as valid, rejecting request\n",
1686 __func__, keyix, is_valid ?
"not" :
"still");
1700 case IEEE80211_CIPHER_WEP:
1702 case IEEE80211_CIPHER_TKIP:
1704 case IEEE80211_CIPHER_AES_CCM:
1707 device_printf(sc->
sc_dev,
"unknown cipher %d\n", cipher);
1726 memset(&
key, 0,
sizeof(
key));
1728 key.cam_id =
k->wk_keyix;
1729 key.grpkey = (
k->wk_flags & IEEE80211_KEY_GROUP) != 0;
1730 memcpy(
key.key,
k->wk_key, MIN(
k->wk_keylen,
sizeof(
key.key)));
1733 "%s: keyix %u, group %u, algo %u/%u, flags %04X, len %u, "
1734 "macaddr %s\n", __func__,
key.cam_id,
key.grpkey,
1735 k->wk_cipher->ic_cipher,
key.algo,
k->wk_flags,
k->wk_keylen,
1736 ether_sprintf(
k->wk_macaddr));
1740 device_printf(sc->
sc_dev,
1741 "%s: cannot send firmware command, error %d\n",
1766 memset(&
key, 0,
sizeof(
key));
1768 memcpy(
key.macaddr,
k->wk_macaddr,
sizeof(
key.macaddr));
1769 memcpy(
key.key,
k->wk_key, MIN(
k->wk_keylen,
sizeof(
key.key)));
1772 "%s: keyix %u, algo %u/%u, flags %04X, len %u, macaddr %s\n",
1773 __func__,
k->wk_keyix,
k->wk_cipher->ic_cipher,
key.algo,
1774 k->wk_flags,
k->wk_keylen, ether_sprintf(
key.macaddr));
1778 device_printf(sc->
sc_dev,
1779 "%s: cannot send firmware command, error %d\n",
1792 for (i = 0; i < nitems(sc->
group_keys); i++) {
1796 device_printf(sc->
sc_dev,
1797 "%s: failed to set static key %d, "
1798 "error %d\n", __func__, i,
error);
1823 "%s: key %u does not exist\n", __func__, keyix);
1828 memset(&
key, 0,
sizeof(
key));
1832 "%s: removing key %u\n", __func__,
key.cam_id);
1836 device_printf(sc->
sc_dev,
1837 "%s: cannot send firmware command, error %d\n",
1869 "%s: calling rsu_delete_key() with keyix = %d\n",
1878 i = IEEE80211_WEP_NKID - 1;
1892 memset(&cmd, 0,
sizeof(cmd));
1896 cmd.
limit = htole32(48);
1905 device_printf(sc->
sc_dev,
1906 "sending site survey command, active %d",
1910 ieee80211_print_essid(cmd.
ssid, le32toh(cmd.
ssidlen));
1921 struct ieee80211com *ic = &sc->
sc_ic;
1922 struct ieee80211vap *vap = ni->ni_vap;
1926 uint8_t buf[
sizeof(*bss) + 128]
__aligned(4);
1936 "%s: setting operating mode to %d\n",
1942 memset(&auth, 0,
sizeof(auth));
1943 if (vap->iv_flags & IEEE80211_F_WPA) {
1945 auth.
dot1x = (ni->ni_authmode == IEEE80211_AUTH_8021X);
1949 "%s: setting auth mode to %d\n",
1950 __func__, auth.
mode);
1955 memset(buf, 0,
sizeof(buf));
1957 IEEE80211_ADDR_COPY(bss->
macaddr, ni->ni_bssid);
1959 memcpy(bss->
ssid.
ssid, ni->ni_essid, ni->ni_esslen);
1960 if (vap->iv_flags & (IEEE80211_F_PRIVACY | IEEE80211_F_WPA))
1962 bss->
rssi = htole32(ni->ni_avgrssi);
1963 if (ic->ic_curmode == IEEE80211_MODE_11B)
1969 bss->
config.
dsconfig = htole32(ieee80211_chan2ieee(ic, ni->ni_chan));
1972 memcpy(bss->
supprates, ni->ni_rates.rs_rates,
1973 ni->ni_rates.rs_nrates);
1976 memcpy(&fixed->
tstamp, ni->ni_tstamp.data, 8);
1977 fixed->
bintval = htole16(ni->ni_intval);
1980 frm = (uint8_t *)&fixed[1];
1981 frm = ieee80211_add_rsn(frm, vap);
1982 frm = ieee80211_add_wpa(frm, vap);
1983 frm = ieee80211_add_qos(frm, ni);
1984 if ((ic->ic_flags & IEEE80211_F_WME) &&
1985 (ni->ni_ies.wme_ie != NULL))
1986 frm = ieee80211_add_wme_info(frm, &ic->ic_wme, ni);
1987 if (ni->ni_flags & IEEE80211_NODE_HT) {
1988 frm = ieee80211_add_htcap(frm, ni);
1989 frm = ieee80211_add_htinfo(frm, ni);
1991 bss->
ieslen = htole32(frm - (uint8_t *)fixed);
1992 bss->
len = htole32(((frm - buf) + 3) & ~3);
1994 "%s: sending join bss command to %s chan %d\n",
2007 "%s: sending disconnect command\n", __func__);
2034 struct ieee80211com *ic = &sc->
sc_ic;
2035 struct ieee80211_frame *wh;
2037 struct ieee80211_rx_stats rxs;
2042 if (__predict_false(
len <
sizeof(*bss)))
2047 if (__predict_false(
ieslen > (uint32_t)(
len -
sizeof(*bss))))
2051 "%s: found BSS %s: len=%d chan=%d inframode=%d "
2052 "networktype=%d privacy=%d, RSSI=%d\n",
2057 le32toh(bss->
rssi));
2061 if (__predict_false(
ieslen > (
size_t)(MCLBYTES -
sizeof(*wh))))
2063 pktlen =
sizeof(*wh) +
ieslen;
2064 m = m_get2(pktlen, M_NOWAIT, MT_DATA, M_PKTHDR);
2065 if (__predict_false(m == NULL))
2067 wh = mtod(m,
struct ieee80211_frame *);
2068 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
2069 IEEE80211_FC0_SUBTYPE_BEACON;
2070 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
2071 USETW(wh->i_dur, 0);
2072 IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr);
2073 IEEE80211_ADDR_COPY(wh->i_addr2, bss->
macaddr);
2074 IEEE80211_ADDR_COPY(wh->i_addr3, bss->
macaddr);
2075 *(uint16_t *)wh->i_seq = 0;
2076 memcpy(&wh[1], (uint8_t *)&bss[1],
ieslen);
2079 m->m_pkthdr.len = m->m_len = pktlen;
2082 bzero(&rxs,
sizeof(rxs));
2083 rxs.r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
2084 rxs.r_flags |= IEEE80211_R_BAND;
2085 rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
2087 rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, IEEE80211_CHAN_2GHZ);
2088 rxs.c_band = IEEE80211_CHAN_2GHZ;
2090 rxs.c_rssi = le32toh(bss->
rssi) / 2;
2092 if (ieee80211_add_rx_params(m, &rxs) == 0)
2097 ieee80211_input_mimo_all(ic, m);
2104 struct ieee80211com *ic = &sc->
sc_ic;
2105 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2106 struct ieee80211_node *ni = vap->iv_bss;
2111 if (__predict_false(
len <
sizeof(*rsp)))
2117 "%s: Rx join BSS event len=%d res=%d\n",
2118 __func__,
len, res);
2126 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
2132 if (tmp >= vap->iv_max_aid) {
2137 "%s: associated with %s associd=%d\n",
2138 __func__, ether_sprintf(rsp->
bss.
macaddr), tmp);
2140 ni->ni_associd = tmp | 0xc000;
2147 ieee80211_new_state(vap, IEEE80211_S_RUN,
2148 IEEE80211_FC0_SUBTYPE_ASSOC_RESP);
2155 struct ieee80211com *ic = &sc->
sc_ic;
2156 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2158 struct ieee80211_node *ni;
2160 if (
len <
sizeof(*ba)) {
2161 device_printf(sc->
sc_dev,
"%s: short read (%d)\n", __func__,
len);
2172 (
int) le16toh(ba->
ssn));
2176 ni = ieee80211_ref_node(vap->iv_bss);
2177 ieee80211_ampdu_rx_start_ext(ni, ba->
tid, le16toh(ba->
ssn) >> 4, 32);
2178 ieee80211_free_node(ni);
2184 struct ieee80211com *ic = &sc->
sc_ic;
2185 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2188 "%s: Rx event code=%d len=%d\n", __func__, code,
len);
2195 "%s: %s scan done, found %d BSS\n",
2197 le32toh(*(uint32_t *)buf));
2203 ieee80211_cancel_scan(vap);
2210 ieee80211_scan_done(vap);
2215 if (vap->iv_state == IEEE80211_S_AUTH)
2220 "%s: disassociated from %s\n", __func__,
2221 ether_sprintf(buf));
2222 if (vap->iv_state == IEEE80211_S_RUN &&
2223 IEEE80211_ADDR_EQ(vap->iv_bss->ni_bssid, buf)) {
2225 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1);
2231 "%s: WPS PBC pushed.\n", __func__);
2241 device_printf(sc->
sc_dev,
"%s: unhandled code (%d)\n", __func__, code);
2261 if (__predict_false(
len <
sizeof(*cmd)))
2265 cmdsz = le16toh(cmd->
len);
2266 if (__predict_false(
len <
sizeof(*cmd) + cmdsz))
2274 buf +=
sizeof(*cmd) + cmdsz;
2275 len -=
sizeof(*cmd) + cmdsz;
2282 static const int8_t cckoff[] = { 14, -2, -20, -40 };
2290 rpt = (cck->
agc_rpt >> 6) & 0x3;
2292 rssi = cckoff[rpt] - rssi;
2295 rssi = ((le32toh(phy->
phydw1) >> 1) & 0x7f) - 106;
2304 struct ieee80211com *ic = &sc->
sc_ic;
2312 "%s: RX flags error (%s)\n", __func__,
2317 pktlen =
MS(
rxdw0, R92S_RXDW0_PKTLEN);
2318 if (__predict_false(pktlen <
sizeof (
struct ieee80211_frame_ack))) {
2320 "%s: frame is too short: %d\n", __func__, pktlen);
2324 m = m_get2(totlen, M_NOWAIT, MT_DATA, M_PKTHDR);
2325 if (__predict_false(m == NULL)) {
2326 device_printf(sc->
sc_dev,
2327 "%s: could not allocate RX mbuf, totlen %d\n",
2333 memcpy(mtod(m, uint8_t *), (uint8_t *)stat, totlen);
2334 m->m_pkthdr.len = m->m_len = totlen;
2338 counter_u64_add(ic->ic_ierrors, 1);
2354static struct ieee80211_node *
2357 struct ieee80211com *ic = &sc->
sc_ic;
2358 struct ieee80211_frame_min *wh;
2359 struct ieee80211_rx_stats rxs;
2362 uint8_t cipher, rate;
2370 rate =
MS(
rxdw3, R92S_RXDW3_RATE);
2371 cipher =
MS(
rxdw0, R92S_RXDW0_CIPHER);
2372 infosz =
MS(
rxdw0, R92S_RXDW0_INFOSZ) * 8;
2389 "%s: TCP/IP checksums: %schecked / %schecked\n",
2402 m->m_pkthdr.csum_flags = CSUM_IP_CHECKED;
2403 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
2410 m->m_pkthdr.csum_flags |= CSUM_DATA_VALID;
2411 m->m_pkthdr.csum_flags |= CSUM_PSEUDO_HDR;
2412 m->m_pkthdr.csum_data = 0xffff;
2419 bzero(&rxs,
sizeof(rxs));
2422 rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
2428 rxs.c_rate = ridx2rate[rate];
2430 rxs.c_pktflags |= IEEE80211_RX_F_CCK;
2432 rxs.c_pktflags |= IEEE80211_RX_F_OFDM;
2434 rxs.c_rate = IEEE80211_RATE_MCS | (rate - 12);
2435 rxs.c_pktflags |= IEEE80211_RX_F_HT;
2438 if (ieee80211_radiotap_active(ic)) {
2453 (void) ieee80211_add_rx_params(m, &rxs);
2456 m_adj(m,
sizeof(*stat) + infosz);
2457 wh = mtod(m,
struct ieee80211_frame_min *);
2458 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) &&
2460 m->m_flags |= M_WEP;
2464 "%s: Rx frame len %d, rate %d, infosz %d\n",
2465 __func__, m->m_len, rate, infosz);
2467 if (m->m_len >=
sizeof(*wh))
2468 return (ieee80211_find_rxnode(ic, wh));
2478 int totlen, pktlen, infosz, npkts;
2479 struct mbuf *m, *m0 = NULL, *prevm = NULL;
2490 npkts =
MS(le32toh(stat->
rxdw2), R92S_RXDW2_PKTCNT);
2492 "%s: Rx %d frames in one chunk\n", __func__, npkts);
2495 while (npkts-- > 0) {
2496 if (__predict_false(
len <
sizeof(*stat)))
2501 pktlen =
MS(
rxdw0, R92S_RXDW0_PKTLEN);
2502 if (__predict_false(pktlen == 0))
2505 infosz =
MS(
rxdw0, R92S_RXDW0_INFOSZ) * 8;
2508 totlen =
sizeof(*stat) + infosz + pktlen;
2509 if (__predict_false(totlen >
len))
2523 totlen = (totlen + 127) & ~127;
2535 struct ieee80211com *ic = &sc->
sc_ic;
2541 if (__predict_false(
len <
sizeof(*stat))) {
2543 counter_u64_add(ic->ic_ierrors, 1);
2548 if ((le32toh(stat->
rxdw1) & 0x1ff) == 0x1ff) {
2559 struct epoch_tracker et;
2561 struct ieee80211com *ic = &sc->
sc_ic;
2562 struct ieee80211_node *ni;
2563 struct mbuf *m = NULL, *
next;
2570 data = STAILQ_FIRST(&
sc->sc_rx_active);
2573 STAILQ_REMOVE_HEAD(&
sc->sc_rx_active,
next);
2575 STAILQ_INSERT_TAIL(&
sc->sc_rx_inactive,
data,
next);
2579 data = STAILQ_FIRST(&
sc->sc_rx_inactive);
2581 KASSERT(
m == NULL, (
"mbuf isn't NULL"));
2584 STAILQ_REMOVE_HEAD(&
sc->sc_rx_inactive,
next);
2585 STAILQ_INSERT_TAIL(&
sc->sc_rx_active,
data,
next);
2594 NET_EPOCH_ENTER(et);
2603 if (
ni->ni_flags & IEEE80211_NODE_HT)
2604 m->m_flags |= M_AMPDU;
2605 (void)ieee80211_input_mimo(
ni,
m);
2606 ieee80211_free_node(
ni);
2608 (
void)ieee80211_input_mimo_all(ic,
m);
2617 data = STAILQ_FIRST(&
sc->sc_rx_active);
2619 STAILQ_REMOVE_HEAD(&
sc->sc_rx_active,
next);
2620 STAILQ_INSERT_TAIL(&
sc->sc_rx_inactive,
data,
next);
2624 counter_u64_add(ic->ic_ierrors, 1);
2645 ieee80211_tx_complete(
data->ni,
data->m, 0);
2656 struct ieee80211com *ic = &sc->
sc_ic;
2663 data = STAILQ_FIRST(&
sc->sc_tx_active[which]);
2668 STAILQ_REMOVE_HEAD(&
sc->sc_tx_active[which],
next);
2674 data = STAILQ_FIRST(&
sc->sc_tx_pending[which]);
2677 "%s: empty pending queue sc %p\n", __func__,
sc);
2680 STAILQ_REMOVE_HEAD(&
sc->sc_tx_pending[which],
next);
2681 STAILQ_INSERT_TAIL(&
sc->sc_tx_active[which],
data,
next);
2684 "%s: submitting transfer %p\n",
2690 data = STAILQ_FIRST(&
sc->sc_tx_active[which]);
2692 STAILQ_REMOVE_HEAD(&
sc->sc_tx_active[which],
next);
2696 counter_u64_add(ic->ic_oerrors, 1);
2752 struct mbuf *m0,
struct rsu_data *data)
2754 const struct ieee80211_txparam *tp = ni->ni_txparms;
2755 struct ieee80211vap *vap = ni->ni_vap;
2756 struct ieee80211_frame *wh;
2757 struct ieee80211_key *
k = NULL;
2759 uint8_t rate, ridx,
type, cipher, qos;
2769 wh = mtod(m0,
struct ieee80211_frame *);
2770 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
2771 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
2774 __func__,
data, m0);
2777 if (
type == IEEE80211_FC0_TYPE_MGT ||
2778 type == IEEE80211_FC0_TYPE_CTL ||
2779 (m0->m_flags & M_EAPOL) != 0)
2780 rate = tp->mgmtrate;
2782 rate = tp->mcastrate;
2783 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
2784 rate = tp->ucastrate;
2789 ridx = rate2ridx(rate);
2791 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
2792 k = ieee80211_crypto_encap(ni, m0);
2794 device_printf(sc->
sc_dev,
2795 "ieee80211_crypto_encap returns NULL.\n");
2799 wh = mtod(m0,
struct ieee80211_frame *);
2803 if (IEEE80211_QOS_HAS_SEQ(wh)) {
2805 prio = M_WME_GETAC(m0);
2808 qos = ((
const struct ieee80211_qosframe *)wh)->i_qos[0];
2821 case IEEE80211_FC0_TYPE_CTL:
2822 case IEEE80211_FC0_TYPE_MGT:
2840 memset(txd, 0,
sizeof(*txd));
2842 txd->
txdw0 |= htole32(
2843 SM(R92S_TXDW0_PKTLEN, m0->m_pkthdr.len) |
2844 SM(R92S_TXDW0_OFFSET,
sizeof(*txd)) |
2847 txd->
txdw1 |= htole32(
2851 if (
k != NULL && !(
k->wk_flags & IEEE80211_KEY_SWENCRYPT)) {
2852 switch (
k->wk_cipher->ic_cipher) {
2853 case IEEE80211_CIPHER_WEP:
2856 case IEEE80211_CIPHER_TKIP:
2859 case IEEE80211_CIPHER_AES_CCM:
2865 txd->
txdw1 |= htole32(
2866 SM(R92S_TXDW1_CIPHER, cipher) |
2867 SM(R92S_TXDW1_KEYIDX,
k->wk_keyix));
2874 if (!ismcast && (!qos || (qos & IEEE80211_QOS_ACKPOLICY) !=
2875 IEEE80211_QOS_ACKPOLICY_NOACK)) {
2877 txd->
txdw2 |= htole32(
SM(R92S_TXDW2_RTY_LMT, tp->maxretry));
2883 txd->
txdw5 |= htole32(
SM(R92S_TXDW5_DATARATE_FB_LMT, 0x1f));
2884 txd->
txdw5 |= htole32(
SM(R92S_TXDW5_DATARATE, ridx));
2892 txd->
txdw3 |= htole32(
SM(R92S_TXDW3_SEQ, prio));
2894 if (ieee80211_radiotap_active_vap(vap)) {
2898 ieee80211_radiotap_tx(vap, m0);
2901 xferlen =
sizeof(*txd) + m0->m_pkthdr.len;
2902 KASSERT(xferlen <=
RSU_TXBUFSZ, (
"%s: invalid length", __func__));
2903 m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&txd[1]);
2905 data->buflen = xferlen;
2908 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which],
data,
next);
2934 "%s: mbufq_enable: failed (%d)\n",
2952 struct ieee80211_node *ni;
2955 while ((m = mbufq_dequeue(&sc->
sc_snd)) != NULL) {
2956 ni = (
struct ieee80211_node *)m->m_pkthdr.rcvif;
2957 m->m_pkthdr.rcvif = NULL;
2958 ieee80211_free_node(ni);
2966 struct ieee80211_node *ni;
2972 while ((m = mbufq_dequeue(&sc->
sc_snd)) != NULL) {
2976 "%s: failed to get buffer\n", __func__);
2977 mbufq_prepend(&sc->
sc_snd, m);
2981 ni = (
struct ieee80211_node *)m->m_pkthdr.rcvif;
2982 m->m_pkthdr.rcvif = NULL;
2986 "%s: failed to transmit\n", __func__);
2987 if_inc_counter(ni->ni_vap->iv_ifp,
2988 IFCOUNTER_OERRORS, 1);
2990 ieee80211_free_node(ni);
3001 taskqueue_enqueue(taskqueue_thread, &sc->
tx_task);
3008 struct ifreq *ifr = (
struct ifreq *)
data;
3015 struct ieee80211vap *vap;
3018 rxmask = ifr->ifr_reqcap & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
3023 rxmask != (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
3028 rxmask = IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6;
3039 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
3040 struct ifnet *ifp = vap->iv_ifp;
3042 ifp->if_capenable &=
3043 ~(IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6);
3044 ifp->if_capenable |= rxmask;
3046 IEEE80211_UNLOCK(ic);
3062 if (ic->ic_nrunning > 0) {
3064 ieee80211_start_all(ic);
3066 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3068 ieee80211_stop(vap);
3257 for (ntries = 0; ntries < 20; ntries++) {
3266 "%s: TxDMA is not ready\n",
3322 memset(txd, 0,
sizeof(*txd));
3329 txd->txdw0 |= htole32(
SM(R92S_TXDW0_PKTLEN, mlen));
3330 memcpy(&txd[1], buf, mlen);
3331 data->buflen =
sizeof(*txd) + mlen;
3333 "%s: starting transfer %p\n",
3335 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[which],
data,
next);
3350 struct ieee80211com *ic = &sc->
sc_ic;
3351 const uint8_t *imem, *emem;
3352 uint32_t imemsz, ememsz;
3353 const struct firmware *fw;
3360 "%s: Firmware already loaded\n",
3367 if ((fw = firmware_get(
"rsu-rtl8712fw")) == NULL) {
3368 device_printf(sc->
sc_dev,
3369 "%s: failed load firmware of file rsu-rtl8712fw\n",
3375 size = fw->datasize;
3376 if (
size <
sizeof(*hdr)) {
3377 device_printf(sc->
sc_dev,
"firmware too short\n");
3382 if (hdr->
signature != htole16(0x8712) &&
3384 device_printf(sc->
sc_dev,
3385 "invalid firmware signature 0x%x\n",
3395 if (hdr->
privsz != htole32(
sizeof(dmem))) {
3396 device_printf(sc->
sc_dev,
"unsupported firmware image\n");
3402 ememsz = le32toh(hdr->
sramsz);
3404 if (
imemsz > (
size_t)(
size -
sizeof(*hdr)) ||
3405 ememsz > (
size_t)(
size -
sizeof(*hdr) -
imemsz)) {
3406 device_printf(sc->
sc_dev,
"firmware too short\n");
3410 imem = (
const uint8_t *)&hdr[1];
3416 device_printf(sc->
sc_dev,
3417 "could not load firmware section %s\n",
"IMEM");
3421 for (ntries = 0; ntries != 50; ntries++) {
3428 device_printf(sc->
sc_dev,
"timeout waiting for IMEM transfer\n");
3435 device_printf(sc->
sc_dev,
3436 "could not load firmware section %s\n",
"EMEM");
3440 for (ntries = 0; ntries != 50; ntries++) {
3447 device_printf(sc->
sc_dev,
"timeout waiting for EMEM transfer\n");
3455 device_printf(sc->
sc_dev,
"could not enable system clock\n");
3462 device_printf(sc->
sc_dev,
3463 "could not enable microcontroller\n");
3468 for (ntries = 0; ntries < 100; ntries++) {
3473 if (ntries == 100) {
3474 device_printf(sc->
sc_dev,
3475 "timeout waiting for microcontroller\n");
3481 memset(&dmem, 0,
sizeof(dmem));
3489 dmem.
bw40_en = !! (ic->ic_htcaps & IEEE80211_HTCAP_CHWIDTH40);
3499 device_printf(sc->
sc_dev,
3500 "could not load firmware section %s\n",
"DMEM");
3504 for (ntries = 0; ntries < 100; ntries++) {
3509 if (ntries == 100) {
3510 device_printf(sc->
sc_dev,
"timeout waiting for %s transfer\n",
3516 for (ntries = 0; ntries < 60; ntries++) {
3522 device_printf(sc->
sc_dev,
3523 "timeout waiting for firmware readiness\n");
3528 firmware_put(fw, FIRMWARE_UNLOAD);
3534 const struct ieee80211_bpf_params *params)
3536 struct ieee80211com *ic = ni->ni_ic;
3575 reg &= ~R92S_RCR_AICV;
3596 struct ieee80211com *ic = &sc->
sc_ic;
3597 uint32_t mask_all, mask_min;
3609 if (ic->ic_opmode == IEEE80211_M_MONITOR) {
3618 if (ic->ic_promisc == 0 && ic->ic_opmode != IEEE80211_M_MONITOR)
3627 struct ieee80211com *ic = &sc->
sc_ic;
3628 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3629 uint8_t macaddr[IEEE80211_ADDR_LEN];
3675 IEEE80211_ADDR_COPY(macaddr, vap ? vap->iv_myaddr : ic->ic_macaddr);
3683 ether_sprintf(macaddr));
3685 IEEE80211_ADDR_LEN);
3687 device_printf(sc->
sc_dev,
"could not set MAC address\n");
3697 device_printf(sc->
sc_dev,
"could not set PS mode\n");
3737 taskqueue_cancel_timeout(taskqueue_thread, &sc->
calib_task, NULL);
3738 taskqueue_cancel(taskqueue_thread, &sc->
tx_task, NULL);
static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "USB DWC OTG")
SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, phy_type, CTLFLAG_RDTUN, &dwc_otg_phy_type, 0, "DWC OTG PHY TYPE - 0/1/2/3 - ULPI/HSIC/INTERNAL/UTMI+")
struct ehci_hw_softc __aligned
static void rsu_tx_task(void *, int)
static int rsu_write_region_1(struct rsu_softc *, uint16_t, uint8_t *, int)
static int rsu_ioctl_net(struct ieee80211com *, u_long, void *)
static void rsu_free_rx_list(struct rsu_softc *)
static void rsu_rx_multi_event(struct rsu_softc *, uint8_t *, int)
static void rsu_event_survey(struct rsu_softc *, uint8_t *, int)
static int rsu_read_region_1(struct rsu_softc *, uint16_t, uint8_t *, int)
static struct rsu_data * rsu_getbuf(struct rsu_softc *)
static int rsu_site_survey(struct rsu_softc *, struct ieee80211_scan_ssid *)
static void rsu_set_channel(struct ieee80211com *)
static void rsu_update_mcast(struct ieee80211com *)
static uint32_t rsu_read_4(struct rsu_softc *, uint16_t)
static void rsu_getradiocaps(struct ieee80211com *, int, int *, struct ieee80211_channel[])
static void rsu_vap_delete(struct ieee80211vap *)
static int rsu_monitor_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static int8_t rsu_get_rssi(struct rsu_softc *, int, void *)
static usb_callback_t rsu_bulk_tx_callback_h2c
static void rsu_bulk_tx_callback_sub(struct usb_xfer *xfer, usb_error_t error, uint8_t which)
static const struct usb_config rsu_config[RSU_N_TRANSFER]
static uint32_t rsu_get_tsf_high(struct rsu_softc *)
static void rsu_power_off(struct rsu_softc *sc)
static usb_error_t rsu_do_request(struct rsu_softc *, struct usb_device_request *, void *)
TUNABLE_INT("hw.usb.rsu.enable_11n", &rsu_enable_11n)
static int rsu_set_key_group(struct rsu_softc *, const struct ieee80211_key *)
#define RSU_DPRINTF(_sc, _flg,...)
static int rsu_set_fw_power_state(struct rsu_softc *sc, int state)
static driver_t rsu_driver
static void rsu_write_1(struct rsu_softc *, uint16_t, uint8_t)
static device_attach_t rsu_attach
static int rsu_reinit_static_keys(struct rsu_softc *)
static struct ieee80211_node * rsu_rx_frame(struct rsu_softc *, struct mbuf *)
static int rsu_enable_11n
static uint32_t rsu_get_tsf_low(struct rsu_softc *)
static device_method_t rsu_methods[]
static int rsu_alloc_tx_list(struct rsu_softc *)
static void rsu_calib_task(void *, int)
static void rsu_txeof(struct usb_xfer *, struct rsu_data *)
static void rsu_update_promisc(struct ieee80211com *)
static void rsu_scan_start(struct ieee80211com *)
static usb_callback_t rsu_bulk_tx_callback_be_bk
static int rsu_fw_cmd(struct rsu_softc *, uint8_t, void *, int)
static int rsu_delete_key(struct rsu_softc *sc, ieee80211_keyix)
static int rsu_key_delete(struct ieee80211vap *, const struct ieee80211_key *)
static void _rsu_start(struct rsu_softc *)
static struct mbuf * rsu_rx_multi_frame(struct rsu_softc *, uint8_t *, int)
static int rsu_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap)
static void rsu_free_tx_list(struct rsu_softc *)
static int rsu_hwrssi_to_rssi(struct rsu_softc *, int hw_rssi)
static const STRUCT_USB_HOST_ID rsu_devs[]
static int rsu_disconnect(struct rsu_softc *)
static int rsu_send_mgmt(struct ieee80211_node *ni, int type, int arg)
static devclass_t rsu_devclass
static int rsu_fw_iocmd(struct rsu_softc *, uint32_t)
static void rsu_rxfilter_refresh(struct rsu_softc *)
static void rsu_rxfilter_set(struct rsu_softc *, uint32_t, uint32_t)
static int rsu_key_alloc(struct ieee80211vap *, struct ieee80211_key *, ieee80211_keyix *, ieee80211_keyix *)
static int rsu_alloc_list(struct rsu_softc *sc, struct rsu_data data[], int ndata, int maxsz)
static void rsu_update_chw(struct ieee80211com *ic)
static void rsu_scan_end(struct ieee80211com *)
static void rsu_stop(struct rsu_softc *)
CTASSERT(MCLBYTES > sizeof(struct ieee80211_frame))
MODULE_DEPEND(rsu, wlan, 1, 1, 1)
static void rsu_parent(struct ieee80211com *)
static usb_callback_t rsu_bulk_rx_callback
static int rsu_cam_read(struct rsu_softc *, uint8_t, uint32_t *)
static void rsu_rxfilter_init(struct rsu_softc *)
static int rsu_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *)
static int rsu_set_key_pair(struct rsu_softc *, const struct ieee80211_key *)
static void rsu_freebuf(struct rsu_softc *, struct rsu_data *)
static int rsu_key_set(struct ieee80211vap *, const struct ieee80211_key *)
static int rsu_read_rom(struct rsu_softc *)
static device_probe_t rsu_match
static int rsu_alloc_rx_list(struct rsu_softc *)
static int rsu_init(struct rsu_softc *)
static uint8_t rsu_wme_ac_xfer_map[4]
static void rsu_ms_delay(struct rsu_softc *, int)
static struct mbuf * rsu_rxeof(struct usb_xfer *, struct rsu_data *)
static struct mbuf * rsu_rx_copy_to_mbuf(struct rsu_softc *, struct r92s_rx_stat *, int)
DRIVER_MODULE(rsu, uhub, rsu_driver, rsu_devclass, NULL, 0)
static void rsu_start(struct rsu_softc *)
static int rsu_process_key(struct ieee80211vap *, const struct ieee80211_key *, int)
static int rsu_fw_loadsection(struct rsu_softc *sc, const uint8_t *buf, int len)
static int rsu_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static int rsu_join_bss(struct rsu_softc *, struct ieee80211_node *)
static void rsu_event_addba_req_report(struct rsu_softc *sc, uint8_t *buf, int len)
static uint8_t rsu_efuse_read_1(struct rsu_softc *, uint16_t)
static void rsu_write_4(struct rsu_softc *, uint16_t, uint32_t)
static uint8_t rsu_get_multi_pos(const uint8_t[])
static struct ieee80211vap * rsu_vap_create(struct ieee80211com *, const char name[], int, enum ieee80211_opmode, int, const uint8_t bssid[], const uint8_t mac[])
static int rsu_transmit(struct ieee80211com *, struct mbuf *)
static void rsu_scan_curchan(struct ieee80211_scan_state *, unsigned long)
static void rsu_power_on_acut(struct rsu_softc *sc)
static uint8_t rsu_crypto_mode(struct rsu_softc *, u_int, int)
static u_int rsu_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
static struct rsu_data * _rsu_getbuf(struct rsu_softc *)
static void rsu_event_join_bss(struct rsu_softc *, uint8_t *, int)
static void rsu_scan_mindwell(struct ieee80211_scan_state *)
static usb_callback_t rsu_bulk_tx_callback_vi_vo
static uint8_t rsu_read_1(struct rsu_softc *, uint16_t)
static int rsu_wme_update(struct ieee80211com *ic)
static void rsu_write_2(struct rsu_softc *, uint16_t, uint16_t)
static void rsu_set_led(struct rsu_softc *, int)
USB_PNP_HOST_INFO(rsu_devs)
static device_detach_t rsu_detach
static void rsu_free_list(struct rsu_softc *, struct rsu_data[], int)
static void rsu_set_multi(struct rsu_softc *)
static uint16_t rsu_read_2(struct rsu_softc *, uint16_t)
static void rsu_delete_key_pair_cb(void *, int)
static int rsu_tx_start(struct rsu_softc *, struct ieee80211_node *, struct mbuf *, struct rsu_data *)
static void rsu_power_on_bcut(struct rsu_softc *sc)
static void rsu_drain_mbufq(struct rsu_softc *sc)
static void rsu_rx_event(struct rsu_softc *, uint8_t, uint8_t *, int)
static int rsu_load_firmware(struct rsu_softc *sc)
static int rsu_key_check(struct rsu_softc *, ieee80211_keyix, int)
static void rsu_cam_write(struct rsu_softc *, uint8_t, uint32_t)
#define R92S_EVT_JOIN_BSS
#define R92S_CMD_SET_OPMODE
#define R92S_RXDW3_IPCHKRPT
#define R92S_GPIOSEL_GPIO_JTAG
#define R92S_TCR_DMEM_CODE_DONE
#define R92S_TXDW1_QSEL_H2C
#define R92S_CMD_SITE_SURVEY
#define R92S_TXDW1_NONQOS
#define R92S_USB_HRPWM_PS_ALL_ON
#define RSU_DELKEY_BMAP_UNLOCK(_sc)
#define R92S_TXDW1_CIPHER_TKIP
#define R92S_VCS_TYPE_AUTO
#define R92S_HCI_SEL_8172
#define RSU_DELKEY_BMAP_LOCK_INIT(_sc)
#define R92S_CMD_SET_MAC_ADDRESS
#define R92S_KEY_ALGO_NONE
#define R92S_RXDW0_CRCERR
#define RSU_TX_LIST_COUNT
#define R92S_TXDW2_RTY_LMT_ENA
#define R92S_USB_HRPWM_PS_ST_ACTIVE
#define R92S_TCR_EMEM_CHK_RPT
#define R92S_CAM_CTL0(entry)
#define R92S_CMD_SET_PWR_MODE
#define R92S_TCR_EMEM_CODE_DONE
#define R92S_KEY_ALGO_INVALID
#define RSU_RX_LIST_COUNT
#define R92S_AFE_XTAL_CTRL
#define RSU_DELKEY_BMAP_LOCK(_sc)
static const uint8_t rsu_ac2qid[WME_NUM_AC]
#define R92S_TCR_IMEM_RDY
#define R92S_TCR_IMEM_CODE_DONE
#define RSU_RX_RADIOTAP_PRESENT
#define R92S_RXDW3_TCPCHKVALID
#define R92S_AFE_MISC_BGEN
#define R92S_VCS_MODE_RTS_CTS
#define R92S_CMD_SET_AUTH
#define R92S_EFUSE_CTRL_VALID
#define R92S_KEY_ALGO_AES
#define R92S_TXDW1_CIPHER_AES
#define NDIS802_11INFRASTRUCTURE
#define R92S_TCR_IMEM_CHK_RPT
#define R92S_CMD_SET_CHANNEL
#define R92S_TXDW1_CIPHER_WEP
#define R92S_CMD_DISCONNECT
#define R92S_SYS_CPU_CLKSEL
#define RW(var, field, val)
#define R92S_CMD_SET_STA_KEY
#define R92S_EVT_ADDBA_REQ_REPORT
#define R92S_AFE_MISC_I32_EN
#define R92S_AUTHMODE_OPEN
#define R92S_TXDW4_DRVRATE
#define R92S_AFE_MISC_MBEN
#define R92S_CAMCMD_WRITE
#define R92S_RCR_TCP_OFFLD_EN
#define R92S_RCR_APP_PHYSTS
#define R92S_KEY_ALGO_WEP40
#define R92S_RXDW0_ICVERR
#define RSU_TX_RADIOTAP_PRESENT
#define R92S_CMD_ADDBA_REQ
#define R92S_CAM_ENTRY_LIMIT
#define R92S_AFE_PLL_CTRL
#define R92S_LDOV12D_CTRL
#define R92S_RXFLTMAP_MGT_DEF
#define R92S_KEY_ALGO_WEP104
#define R92S_KEY_ALGO_TKIP
#define RSU_ASSERT_LOCKED(sc)
#define R92S_MAC_PINMUX_CTRL
#define R92S_PS_MODE_DTIM
#define NDIS802_11AUTOUNKNOWN
#define R92S_PS_MODE_ACTIVE
#define RSU_DELKEY_BMAP_LOCK_DESTROY(_sc)
#define R92S_AUTHMODE_WPA
#define R92S_RXFLTMAP_MGT
#define R92S_TXDW2_BMCAST
#define R92S_SYS_ISO_CTRL
#define R92S_RXDW3_TCPCHKRPT
#define R92S_CMD_JOIN_BSS
#define R92S_TXDW1_CIPHER_NONE
#define R92S_EVT_SURVEY_DONE
#define R92S_PS_MODE_RADIOOFF
#define R92S_CAMCMD_POLLING
struct ndis_802_11_configuration config
uint8_t macaddr[IEEE80211_ADDR_LEN]
struct ndis_802_11_ssid ssid
uint8_t mac_addr[IEEE80211_ADDR_LEN]
struct ndis_wlan_bssid_ex bss
uint8_t key[IEEE80211_KEYBUF_SIZE]
uint8_t key[IEEE80211_KEYBUF_SIZE]
struct ieee80211_node * ni
struct timeout_task calib_task
struct ieee80211com sc_ic
u_int sc_rx_checksum_enable
const struct ieee80211_key * group_keys[IEEE80211_WEP_NKID]
struct rsu_data sc_tx[RSU_TX_LIST_COUNT]
uint8_t keys_bmap[R92S_CAM_ENTRY_BYTES]
struct usb_xfer * sc_xfer[RSU_N_TRANSFER]
struct usb_device * sc_udev
uint8_t free_keys_bmap[R92S_CAM_ENTRY_BYTES]
struct rsu_data sc_rx[RSU_RX_LIST_COUNT]
int(* newstate)(struct ieee80211vap *, enum ieee80211_state, int)
enum usb_hc_mode usb_mode
struct usbd_lookup_info info
struct usb_device * device
struct usb_interface_descriptor * idesc
#define UT_WRITE_VENDOR_DEVICE
#define UT_READ_VENDOR_DEVICE
struct usb_interface * usbd_get_iface(struct usb_device *udev, uint8_t iface_index)
const char * usbd_errstr(usb_error_t err)
int usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, struct usb_attach_arg *uaa)
usb_error_t usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx, struct usb_device_request *req, void *data, uint16_t flags, uint16_t *actlen, usb_timeout_t timeout)
void usbd_transfer_submit(struct usb_xfer *xfer)
void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup)
void usbd_xfer_set_frame_data(struct usb_xfer *xfer, usb_frcount_t frindex, void *ptr, usb_frlength_t len)
usb_error_t usbd_transfer_setup(struct usb_device *udev, const uint8_t *ifaces, struct usb_xfer **ppxfer, const struct usb_config *setup_start, uint16_t n_setup, void *priv_sc, struct mtx *xfer_mtx)
void usbd_transfer_start(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_transfer_stop(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
usb_frlength_t usbd_xfer_max_len(struct usb_xfer *xfer)
void device_set_usb_desc(device_t dev)
void usb_pause_mtx(struct mtx *mtx, int timo)
#define USB_ST_TRANSFERRED
#define USB_MS_TO_TICKS(ms)
void() usb_callback_t(struct usb_xfer *, usb_error_t)
#define STRUCT_USB_HOST_ID
#define USB_GET_DRIVER_INFO(did)
#define USB_GET_STATE(xfer)