31#include <sys/eventhandler.h>
32#include <sys/sockio.h>
33#include <sys/sysctl.h>
37#include <sys/kernel.h>
38#include <sys/socket.h>
40#include <sys/malloc.h>
41#include <sys/module.h>
43#include <sys/endian.h>
44#include <sys/linker.h>
45#include <sys/firmware.h>
50#include <net/if_var.h>
51#include <net/if_arp.h>
52#include <net/ethernet.h>
54#include <net/if_media.h>
55#include <net/if_types.h>
57#include <netinet/in.h>
58#include <netinet/in_systm.h>
59#include <netinet/in_var.h>
60#include <netinet/if_ether.h>
61#include <netinet/ip.h>
63#include <net80211/ieee80211_var.h>
64#include <net80211/ieee80211_regdomain.h>
65#include <net80211/ieee80211_radiotap.h>
66#include <net80211/ieee80211_ratectl.h>
67#ifdef IEEE80211_SUPPORT_SUPERG
68#include <net80211/ieee80211_superg.h>
75#define USB_DEBUG_VAR run_debug
88static SYSCTL_NODE(_hw_usb, OID_AUTO, run, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
94 RUN_DEBUG_XMIT = 0x00000001,
95 RUN_DEBUG_XMIT_DESC = 0x00000002,
96 RUN_DEBUG_RECV = 0x00000004,
97 RUN_DEBUG_RECV_DESC = 0x00000008,
98 RUN_DEBUG_STATE = 0x00000010,
99 RUN_DEBUG_RATE = 0x00000020,
100 RUN_DEBUG_USB = 0x00000040,
101 RUN_DEBUG_FIRMWARE = 0x00000080,
102 RUN_DEBUG_BEACON = 0x00000100,
103 RUN_DEBUG_INTR = 0x00000200,
104 RUN_DEBUG_TEMP = 0x00000400,
105 RUN_DEBUG_ROM = 0x00000800,
106 RUN_DEBUG_KEY = 0x00001000,
107 RUN_DEBUG_TXPWR = 0x00002000,
108 RUN_DEBUG_RSSI = 0x00004000,
109 RUN_DEBUG_RESET = 0x00008000,
110 RUN_DEBUG_CALIB = 0x00010000,
111 RUN_DEBUG_CMD = 0x00020000,
112 RUN_DEBUG_ANY = 0xffffffff
115#define RUN_DPRINTF(_sc, _m, ...) do { \
116 if (run_debug & (_m)) \
117 device_printf((_sc)->sc_dev, __VA_ARGS__); \
120#define RUN_DPRINTF(_sc, _m, ...) do { (void) _sc; } while (0)
123#define IEEE80211_HAS_ADDR4(wh) IEEE80211_IS_DSTODS(wh)
129#define RUN_CMDQ_GET(c) (atomic_fetchadd_32((c), 1) & RUN_CMDQ_MASQ)
132#define RUN_DEV(v,p) { USB_VP(USB_VENDOR_##v, USB_PRODUCT_##v##_##p) }
133#define RUN_DEV_EJECT(v,p) \
134 { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, RUN_EJECT) }
192 RUN_DEV(CISCOLINKSYS2, RT3070),
193 RUN_DEV(CISCOLINKSYS3, RT3070),
194 RUN_DEV(CONCEPTRONIC2, RT2870_1),
195 RUN_DEV(CONCEPTRONIC2, RT2870_2),
196 RUN_DEV(CONCEPTRONIC2, RT2870_3),
197 RUN_DEV(CONCEPTRONIC2, RT2870_4),
198 RUN_DEV(CONCEPTRONIC2, RT2870_5),
199 RUN_DEV(CONCEPTRONIC2, RT2870_6),
200 RUN_DEV(CONCEPTRONIC2, RT2870_7),
201 RUN_DEV(CONCEPTRONIC2, RT2870_8),
202 RUN_DEV(CONCEPTRONIC2, RT3070_1),
203 RUN_DEV(CONCEPTRONIC2, RT3070_2),
204 RUN_DEV(CONCEPTRONIC2, VIGORN61),
205 RUN_DEV(COREGA, CGWLUSB300GNM),
292 RUN_DEV(PLANEX2, GWUS300MINIS),
382 const char [IFNAMSIZ],
int,
enum ieee80211_opmode,
int,
383 const uint8_t [IEEE80211_ADDR_LEN],
384 const uint8_t [IEEE80211_ADDR_LEN]);
400 const uint8_t *,
int);
415static struct ieee80211_node *
run_node_alloc(
struct ieee80211vap *,
416 const uint8_t mac[IEEE80211_ADDR_LEN]);
418static int run_newstate(
struct ieee80211vap *,
enum ieee80211_state,
int);
421static int run_key_set(
struct ieee80211vap *,
struct ieee80211_key *);
423static int run_key_delete(
struct ieee80211vap *,
struct ieee80211_key *);
430static void run_recv_mgmt(
struct ieee80211_node *,
struct mbuf *,
int,
431 const struct ieee80211_rx_stats *,
int,
int);
437 struct ieee80211_node *);
439 struct ieee80211_node *);
441 struct ieee80211_node *,
int,
int);
443 struct ieee80211_node *,
444 const struct ieee80211_bpf_params *);
445static int run_raw_xmit(
struct ieee80211_node *,
struct mbuf *,
446 const struct ieee80211_bpf_params *);
447static int run_transmit(
struct ieee80211com *,
struct mbuf *);
463 struct ieee80211_channel[]);
505 struct ieee80211_tx_ampdu *tap);
512 enum ieee80211_phytype
phy;
518 { 2, 0, IEEE80211_T_DS, 0, 314, 314 },
519 { 4, 1, IEEE80211_T_DS, 1, 258, 162 },
520 { 11, 2, IEEE80211_T_DS, 2, 223, 127 },
521 { 22, 3, IEEE80211_T_DS, 3, 213, 117 },
524 { 12, 0, IEEE80211_T_OFDM, 4, 60, 60 },
525 { 18, 1, IEEE80211_T_OFDM, 4, 52, 52 },
526 { 24, 2, IEEE80211_T_OFDM, 6, 48, 48 },
527 { 36, 3, IEEE80211_T_OFDM, 6, 44, 44 },
528 { 48, 4, IEEE80211_T_OFDM, 8, 44, 44 },
529 { 72, 5, IEEE80211_T_OFDM, 8, 40, 40 },
530 { 96, 6, IEEE80211_T_OFDM, 8, 40, 40 },
531 { 108, 7, IEEE80211_T_OFDM, 8, 40, 40 },
534 { 0x80, 0, IEEE80211_T_HT, 4, 60, 60 },
535 { 0x81, 1, IEEE80211_T_HT, 4, 60, 60 },
536 { 0x82, 2, IEEE80211_T_HT, 4, 60, 60 },
537 { 0x83, 3, IEEE80211_T_HT, 4, 60, 60 },
538 { 0x84, 4, IEEE80211_T_HT, 4, 60, 60 },
539 { 0x85, 5, IEEE80211_T_HT, 4, 60, 60 },
540 { 0x86, 6, IEEE80211_T_HT, 4, 60, 60 },
541 { 0x87, 7, IEEE80211_T_HT, 4, 60, 60 },
544 { 0x88, 8, IEEE80211_T_HT, 4, 60, 60 },
545 { 0x89, 9, IEEE80211_T_HT, 4, 60, 60 },
546 { 0x8a, 10, IEEE80211_T_HT, 4, 60, 60 },
547 { 0x8b, 11, IEEE80211_T_HT, 4, 60, 60 },
548 { 0x8c, 12, IEEE80211_T_HT, 4, 60, 60 },
549 { 0x8d, 13, IEEE80211_T_HT, 4, 60, 60 },
550 { 0x8e, 14, IEEE80211_T_HT, 4, 60, 60 },
551 { 0x8f, 15, IEEE80211_T_HT, 4, 60, 60 },
554 { 0x90, 16, IEEE80211_T_HT, 4, 60, 60 },
555 { 0x91, 17, IEEE80211_T_HT, 4, 60, 60 },
556 { 0x92, 18, IEEE80211_T_HT, 4, 60, 60 },
557 { 0x93, 19, IEEE80211_T_HT, 4, 60, 60 },
558 { 0x94, 20, IEEE80211_T_HT, 4, 60, 60 },
559 { 0x95, 21, IEEE80211_T_HT, 4, 60, 60 },
560 { 0x96, 22, IEEE80211_T_HT, 4, 60, 60 },
561 { 0x97, 23, IEEE80211_T_HT, 4, 60, 60 },
565#define RT2860_RIDX_CCK1 0
566#define RT2860_RIDX_CCK11 3
567#define RT2860_RIDX_OFDM6 4
568#define RT2860_RIDX_MCS0 12
569#define RT2860_RIDX_MAX 36
593 0xe0, 0x1f, 0x38, 0x32, 0x08, 0x28, 0x19, 0x0a, 0xff, 0x00,
594 0x16, 0x10, 0x10, 0x0b, 0x36, 0x2c, 0x26, 0x24, 0x42, 0x36,
595 0x30, 0x2d, 0x4c, 0x46, 0x3d, 0x40, 0x3e, 0x42, 0x3d, 0x40,
596 0x3c, 0x34, 0x2c, 0x2f, 0x3c, 0x35, 0x2e, 0x2a, 0x49, 0x41,
597 0x36, 0x31, 0x30, 0x30, 0x0e, 0x0d, 0x28, 0x21, 0x1c, 0x16,
598 0x50, 0x4a, 0x43, 0x40, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
599 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600 0x00, 0x00, 0x7d, 0x14, 0x32, 0x2c, 0x36, 0x4c, 0x43, 0x2c,
601 0x2e, 0x36, 0x30, 0x6e
604static const struct rfprog {
663 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
673 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
683 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
693 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
703 .flags = {.pipe_bof = 1,.force_short_xfer = 1,.no_pipe_ok = 1,},
713 .flags = {.pipe_bof = 1,.force_short_xfer = 1,.no_pipe_ok = 1,},
722 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
755 run_etag = EVENTHANDLER_REGISTER(usb_dev_configured,
759 EVENTHANDLER_DEREGISTER(usb_dev_configured,
run_etag);
785 struct run_softc *sc = device_get_softc(self);
787 struct ieee80211com *ic = &sc->
sc_ic;
799 MTX_NETWORK_LOCK, MTX_DEF);
800 mbufq_init(&sc->
sc_snd, ifqmaxlen);
807 device_printf(self,
"could not allocate USB transfers, "
815 for (ntries = 0; ntries < 100; ntries++) {
820 if (ver != 0 && ver != 0xffffffff)
826 "timeout waiting for NIC to initialize\n");
837 "MAC/BBP RT%04X (rev 0x%04X), RF %s (MIMO %dT%dR), address %s\n",
844 ic->ic_name = device_get_nameunit(self);
845 ic->ic_phytype = IEEE80211_T_OFDM;
846 ic->ic_opmode = IEEE80211_M_STA;
851 IEEE80211_C_MONITOR |
856 IEEE80211_C_SHPREAMBLE |
858 IEEE80211_C_SWAMSDUTX |
867 device_printf(sc->
sc_dev,
"[HT] Enabling 802.11n\n");
870 IEEE80211_HTC_AMPDU |
871 IEEE80211_HTC_AMSDU |
872 IEEE80211_HTCAP_MAXAMSDU_3839 |
873 IEEE80211_HTCAP_SMPS_OFF;
880 IEEE80211_CRYPTO_WEP |
881 IEEE80211_CRYPTO_AES_CCM |
882 IEEE80211_CRYPTO_TKIPMIC |
883 IEEE80211_CRYPTO_TKIP;
885 ic->ic_flags |= IEEE80211_F_DATAPAD;
886 ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS;
891 ieee80211_ifattach(ic);
911 ieee80211_radiotap_attach(ic,
912 &sc->sc_txtap.wt_ihdr,
sizeof(sc->sc_txtap),
914 &sc->sc_rxtap.wr_ihdr,
sizeof(sc->sc_rxtap),
922 ieee80211_announce(ic);
935 struct ieee80211_node *ni;
938 while ((m = mbufq_dequeue(&sc->
sc_snd)) != NULL) {
939 ni = (
struct ieee80211_node *)m->m_pkthdr.rcvif;
940 m->m_pkthdr.rcvif = NULL;
941 ieee80211_free_node(ni);
949 struct run_softc *sc = device_get_softc(self);
950 struct ieee80211com *ic = &sc->
sc_ic;
972 if (sc->
sc_ic.ic_softc == sc) {
977 ieee80211_ifdetach(ic);
985static struct ieee80211vap *
987 enum ieee80211_opmode opmode,
int flags,
988 const uint8_t bssid[IEEE80211_ADDR_LEN],
989 const uint8_t mac[IEEE80211_ADDR_LEN])
993 struct ieee80211vap *vap;
997 device_printf(sc->
sc_dev,
"number of VAPs maxed out\n");
1002 case IEEE80211_M_STA:
1004 flags |= IEEE80211_CLONE_NOBEACONS;
1006 case IEEE80211_M_IBSS:
1007 case IEEE80211_M_MONITOR:
1008 case IEEE80211_M_HOSTAP:
1009 case IEEE80211_M_MBSS:
1011 if (!TAILQ_EMPTY(&ic->ic_vaps))
1014 case IEEE80211_M_WDS:
1015 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next){
1016 if(vap->iv_opmode != IEEE80211_M_HOSTAP)
1019 flags &= ~IEEE80211_CLONE_BSSID;
1023 device_printf(sc->
sc_dev,
1024 "wds only supported in ap mode\n");
1029 device_printf(sc->
sc_dev,
"unknown opmode %d\n", opmode);
1033 rvp = malloc(
sizeof(
struct run_vap), M_80211_VAP, M_WAITOK | M_ZERO);
1036 if (ieee80211_vap_setup(ic, vap,
name, unit, opmode, flags,
1039 free(rvp, M_80211_VAP);
1050 if (ic->ic_rxstream > 1)
1051 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K;
1053 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K;
1054 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_2;
1068 if (opmode == IEEE80211_M_IBSS) {
1073 ieee80211_ratectl_init(vap);
1074 ieee80211_ratectl_setinterval(vap, 1000 );
1089 ic->ic_opmode = opmode;
1091 if (opmode == IEEE80211_M_HOSTAP)
1094 RUN_DPRINTF(sc, RUN_DEBUG_STATE,
"rvp_id=%d bmap=%x rvp_cnt=%d\n",
1104 struct ieee80211com *ic;
1127 "vap=%p rvp_id=%d bmap=%x rvp_cnt=%d\n",
1132 ieee80211_ratectl_deinit(vap);
1133 ieee80211_vap_detach(vap);
1134 free(rvp, M_80211_VAP);
1155 RUN_DPRINTF(sc, RUN_DEBUG_CMD,
"cmdq_exec=%d pending=%d\n",
1180 memset(pq, 0,
sizeof(*pq));
1182 STAILQ_INIT(&pq->
tx_qh);
1183 STAILQ_INIT(&pq->
tx_fh);
1200 STAILQ_INIT(&pq->
tx_fh);
1201 STAILQ_INIT(&pq->
tx_qh);
1206 if (
data->m != NULL) {
1210 if (
data->ni != NULL) {
1211 ieee80211_free_node(
data->ni);
1221 const struct firmware *fw;
1225 const uint64_t *temp;
1229 fw = firmware_get(
"runfw");
1232 device_printf(sc->
sc_dev,
1233 "failed loadfirmware of file %s\n",
"runfw");
1237 if (fw->datasize != 8192) {
1238 device_printf(sc->
sc_dev,
1239 "invalid firmware size (should be 8KB)\n");
1251 if ((sc->
mac_ver) != 0x2860 &&
1260 if (bytes != be64toh(0xffffff0210280210ULL)) {
1261 device_printf(sc->
sc_dev,
"firmware checksum failed\n");
1280 device_printf(sc->
sc_dev,
"firmware reset failed\n");
1293 for (ntries = 0; ntries < 1000; ntries++) {
1300 if (ntries == 1000) {
1301 device_printf(sc->
sc_dev,
1302 "timeout waiting for MCU to initialize\n");
1306 device_printf(sc->
sc_dev,
"firmware %s ver. %u.%u loaded\n",
1307 (base == fw->data) ?
"RT2870" :
"RT3071",
1308 *(base + 4092), *(base + 4093));
1311 firmware_put(fw, FIRMWARE_UNLOAD);
1343 "Control request failed, %s (retrying)\n",
1358 *
val = le32toh(tmp);
1412 KASSERT((
len & 1) == 0, (
"run_write_region_1: Data too long.\n"));
1413 for (i = 0; i <
len &&
error == 0; i += 2)
1452 KASSERT((
len & 3) == 0, (
"run_set_region_4: Invalid data length.\n"));
1453 for (i = 0; i <
len &&
error == 0; i += 4)
1480 for (ntries = 0; ntries < 100; ntries++) {
1499 tmp >>= (8 * (
addr & 0x3));
1500 *
val = (
addr & 1) ? tmp >> 16 : tmp & 0xffff;
1528 *
val = le16toh(tmp);
1547 for (ntries = 0; ntries < 10; ntries++) {
1565 for (ntries = 0; ntries < 100; ntries++) {
1578 for (ntries = 0; ntries < 100; ntries++) {
1597 for (ntries = 0; ntries < 10; ntries++) {
1616 for (ntries = 0; ntries < 10; ntries++) {
1629 for (ntries = 0; ntries < 10; ntries++) {
1648 for (ntries = 0; ntries < 10; ntries++) {
1670 for (ntries = 0; ntries < 100; ntries++) {
1689static __inline uint32_t
1694 for (i = 0; i < 8; i++) {
1701 b32 = b32 >> 4 | b4 << 28;
1734 for (i = 0; i < 14; i += 2) {
1738 sc->
txpow1[i + 0] = (int8_t)(
val & 0xff);
1744 sc->
txpow2[i + 0] = (int8_t)(
val & 0xff);
1750 sc->
txpow3[i + 0] = (int8_t)(
val & 0xff);
1755 for (i = 0; i < 14; i++) {
1766 for (i = 0; i < 40; i += 2) {
1768 sc->
txpow1[i + 14] = (int8_t)(
val & 0xff);
1769 sc->
txpow1[i + 15] = (int8_t)(
val >> 8);
1772 sc->
txpow2[i + 14] = (int8_t)(
val & 0xff);
1773 sc->
txpow2[i + 15] = (int8_t)(
val >> 8);
1778 sc->
txpow3[i + 14] = (int8_t)(
val & 0xff);
1779 sc->
txpow3[i + 15] = (int8_t)(
val >> 8);
1791 for (i = 0; i < 14; i += 2) {
1793 sc->
txpow1[i + 0] = (int8_t)(
val & 0xff);
1799 sc->
txpow2[i + 0] = (int8_t)(
val & 0xff);
1804 for (i = 0; i < 14; i++) {
1815 }
else if (sc->
mac_ver < 0x5390) {
1820 "chan %d: power1=%d, power2=%d\n",
1824 for (i = 0; i < 40; i += 2) {
1826 sc->
txpow1[i + 14] = (int8_t)(
val & 0xff);
1827 sc->
txpow1[i + 15] = (int8_t)(
val >> 8);
1830 sc->
txpow2[i + 14] = (int8_t)(
val & 0xff);
1831 sc->
txpow2[i + 15] = (int8_t)(
val >> 8);
1834 for (i = 0; i < 40; i++ ) {
1836 if (sc->
txpow1[14 + i] < -7 || sc->
txpow1[14 + i] > 15)
1838 if (sc->
txpow2[14 + i] < -7 || sc->
txpow2[14 + i] > 15)
1842 "chan %d: power1=%d, power2=%d\n",
1851 struct ieee80211com *ic = &sc->
sc_ic;
1852 int8_t delta_2ghz, delta_5ghz;
1861 RUN_DPRINTF(sc, RUN_DEBUG_ROM,
"EFUSE_CTRL=0x%08x\n", tmp);
1869 "EEPROM rev=%d, FAE=%d\n",
val >> 8,
val & 0xff);
1873 ic->ic_macaddr[0] =
val & 0xff;
1874 ic->ic_macaddr[1] =
val >> 8;
1876 ic->ic_macaddr[2] =
val & 0xff;
1877 ic->ic_macaddr[3] =
val >> 8;
1879 ic->ic_macaddr[4] =
val & 0xff;
1880 ic->ic_macaddr[5] =
val >> 8;
1884 for (i = 0; i < 10; i++) {
1893 for (i = 0; i < 10; i++) {
1907 sc->
freq = ((
val & 0xff) != 0xff) ?
val & 0xff : 0;
1908 RUN_DPRINTF(sc, RUN_DEBUG_ROM,
"EEPROM freq offset %d\n",
1913 if (
val >> 8 != 0xff) {
1925 sc->
led[0] = 0x5555;
1926 sc->
led[1] = 0x2221;
1927 sc->
led[2] = 0x5627;
1930 "EEPROM LED mode=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n",
1939 if (
val == 0xffff) {
1940 device_printf(sc->
sc_dev,
1941 "invalid EEPROM antenna info, using default\n");
1947 }
else if (sc->
mac_ver >= 0x3070) {
1967 RUN_DPRINTF(sc, RUN_DEBUG_ROM,
"EEPROM RF rev=0x%04x chains=%dT%dR\n",
1974 if ((
val >> 8) != 0xff)
1976 if ((
val & 0xff) != 0xff) {
1993 delta_2ghz = delta_5ghz = 0;
1994 if ((
val & 0xff) != 0xff && (
val & 0x80)) {
1995 delta_2ghz =
val & 0xf;
1997 delta_2ghz = -delta_2ghz;
2000 if ((
val & 0xff) != 0xff && (
val & 0x80)) {
2001 delta_5ghz =
val & 0xf;
2003 delta_5ghz = -delta_5ghz;
2006 "power compensation=%d (2GHz), %d (5GHz)\n", delta_2ghz, delta_5ghz);
2008 for (ridx = 0; ridx < 5; ridx++) {
2014 reg |= (uint32_t)
val << 16;
2021 "ridx %d: power 20MHz=0x%08x, 40MHz/2GHz=0x%08x, "
2022 "40MHz/5GHz=0x%08x\n", ridx, sc->
txpow20mhz[ridx],
2042 if ((
val & 0xff) != 0xff)
2045 RUN_DPRINTF(sc, RUN_DEBUG_ROM,
"tx mixer gain=%u (2GHz)\n",
2064 if ((
val & 0xff) != 0xff)
2066 RUN_DPRINTF(sc, RUN_DEBUG_ROM,
"tx mixer gain=%u (5GHz)\n",
2082 if (sc->
lna[2] == 0 || sc->
lna[2] == 0xff) {
2084 "invalid LNA for channel group %d\n", 2);
2087 if (sc->
lna[3] == 0 || sc->
lna[3] == 0xff) {
2089 "invalid LNA for channel group %d\n", 3);
2094 for (ant = 0; ant < 3; ant++) {
2097 "invalid RSSI%d offset: %d (2GHz)\n",
2103 "invalid RSSI%d offset: %d (5GHz)\n",
2111static struct ieee80211_node *
2114 return malloc(
sizeof (
struct run_node), M_80211_NODE,
2121 struct ieee80211vap *vap = ifp->if_softc;
2122 struct ieee80211com *ic = vap->iv_ic;
2123 const struct ieee80211_txparam *tp;
2130 error = ieee80211_media_change(ifp);
2136 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
2137 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) {
2138 struct ieee80211_node *ni;
2142 rate = ic->ic_sup_rates[ic->ic_curmode].
2143 rs_rates[tp->ucastrate] & IEEE80211_RATE_VAL;
2148 ni = ieee80211_ref_node(vap->iv_bss);
2151 RUN_DPRINTF(sc, RUN_DEBUG_RATE,
"rate=%d, fix_ridx=%d\n",
2153 ieee80211_free_node(
ni);
2157 if ((ifp->if_flags & IFF_UP) &&
2169run_newstate(
struct ieee80211vap *vap,
enum ieee80211_state nstate,
int arg)
2171 const struct ieee80211_txparam *tp;
2172 struct ieee80211com *ic = vap->iv_ic;
2175 enum ieee80211_state ostate;
2178 uint8_t restart_ratectl = 0;
2179 uint8_t bid = 1 << rvp->
rvp_id;
2181 ostate =
vap->iv_state;
2183 ieee80211_state_name[ostate],
2184 ieee80211_state_name[nstate]);
2186 IEEE80211_UNLOCK(ic);
2193 if (ostate == IEEE80211_S_RUN) {
2199 case IEEE80211_S_INIT:
2200 restart_ratectl = 1;
2202 if (ostate != IEEE80211_S_RUN)
2213 case IEEE80211_S_RUN:
2216 restart_ratectl = 1;
2223 switch (
vap->iv_opmode) {
2224 case IEEE80211_M_HOSTAP:
2225 case IEEE80211_M_MBSS:
2227 ic->ic_opmode =
vap->iv_opmode;
2230 case IEEE80211_M_IBSS:
2233 ic->ic_opmode =
vap->iv_opmode;
2236 case IEEE80211_M_STA:
2239 ic->ic_opmode =
vap->iv_opmode;
2243 (uint8_t *)sta,
sizeof sta);
2247 ic->ic_opmode =
vap->iv_opmode;
2251 if (
vap->iv_opmode != IEEE80211_M_MONITOR) {
2252 struct ieee80211_node *ni;
2254 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) {
2263 ni = ieee80211_ref_node(vap->iv_bss);
2264 IEEE80211_ADDR_COPY(sc->
sc_bssid, ni->ni_bssid);
2266 ieee80211_free_node(ni);
2270 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)];
2271 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE)
2278 (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan) ?
2283 RUN_DPRINTF(sc, RUN_DEBUG_STATE,
"undefined state\n");
2288 if ((sc->
ratectl_run = ratectl) && restart_ratectl)
2294 return(rvp->
newstate(vap, nstate, arg));
2300 struct chanAccParams chp;
2302 const struct wmeParams *ac;
2305 ieee80211_wme_ic_getparams(ic, &chp);
2306 ac = chp.cap_wmeParams;
2310 for (aci = 0; aci < WME_NUM_AC; aci++) {
2312 ac[aci].wmep_logcwmax << 16 |
2313 ac[aci].wmep_logcwmin << 12 |
2314 ac[aci].wmep_aifsn << 8 |
2315 ac[aci].wmep_txopLimit);
2316 if (
error)
goto err;
2321 ac[WME_AC_VO].wmep_aifsn << 12 |
2322 ac[WME_AC_VI].wmep_aifsn << 8 |
2323 ac[WME_AC_BK].wmep_aifsn << 4 |
2324 ac[WME_AC_BE].wmep_aifsn);
2325 if (
error)
goto err;
2327 ac[WME_AC_VO].wmep_logcwmin << 12 |
2328 ac[WME_AC_VI].wmep_logcwmin << 8 |
2329 ac[WME_AC_BK].wmep_logcwmin << 4 |
2330 ac[WME_AC_BE].wmep_logcwmin);
2331 if (
error)
goto err;
2333 ac[WME_AC_VO].wmep_logcwmax << 12 |
2334 ac[WME_AC_VI].wmep_logcwmax << 8 |
2335 ac[WME_AC_BK].wmep_logcwmax << 4 |
2336 ac[WME_AC_BE].wmep_logcwmax);
2337 if (
error)
goto err;
2339 ac[WME_AC_BK].wmep_txopLimit << 16 |
2340 ac[WME_AC_BE].wmep_txopLimit);
2341 if (
error)
goto err;
2343 ac[WME_AC_VO].wmep_txopLimit << 16 |
2344 ac[WME_AC_VI].wmep_txopLimit);
2349 RUN_DPRINTF(sc, RUN_DEBUG_USB,
"WME update failed\n");
2358 struct ieee80211vap *vap = cmdq->
arg1;
2359 struct ieee80211_key *
k = cmdq->
k;
2360 struct ieee80211com *ic = vap->iv_ic;
2362 struct ieee80211_node *ni;
2363 u_int cipher =
k->wk_cipher->ic_cipher;
2365 uint16_t base, associd;
2366 uint8_t mode, wcid, iv[8];
2370 if (vap->iv_opmode == IEEE80211_M_HOSTAP)
2371 ni = ieee80211_find_vap_node(&ic->ic_sta, vap, cmdq->
mac);
2374 associd = (ni != NULL) ? ni->ni_associd : 0;
2378 case IEEE80211_CIPHER_WEP:
2379 if(
k->wk_keylen < 8)
2384 case IEEE80211_CIPHER_TKIP:
2387 case IEEE80211_CIPHER_AES_CCM:
2391 RUN_DPRINTF(sc, RUN_DEBUG_KEY,
"undefined case\n");
2396 "associd=%x, keyix=%d, mode=%x, type=%s, tx=%s, rx=%s\n",
2397 associd,
k->wk_keyix, mode,
2398 (
k->wk_flags & IEEE80211_KEY_GROUP) ?
"group" :
"pairwise",
2399 (
k->wk_flags & IEEE80211_KEY_XMIT) ?
"on" :
"off",
2400 (
k->wk_flags & IEEE80211_KEY_RECV) ?
"on" :
"off");
2402 if (
k->wk_flags & IEEE80211_KEY_GROUP) {
2406 wcid = (vap->iv_opmode == IEEE80211_M_STA) ?
2411 if (cipher == IEEE80211_CIPHER_TKIP) {
2424 if (!(
k->wk_flags & IEEE80211_KEY_GROUP) ||
2425 (
k->wk_flags & (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV))) {
2427 if (cipher == IEEE80211_CIPHER_WEP) {
2428 memset(iv, 0,
sizeof iv);
2429 iv[3] = vap->iv_def_txkey << 6;
2431 if (cipher == IEEE80211_CIPHER_TKIP) {
2432 iv[0] =
k->wk_keytsc >> 8;
2433 iv[1] = (iv[0] | 0x20) & 0x7f;
2434 iv[2] =
k->wk_keytsc;
2436 iv[0] =
k->wk_keytsc;
2437 iv[1] =
k->wk_keytsc >> 8;
2440 iv[3] =
k->wk_keyix << 6 | IEEE80211_WEP_EXTIV;
2441 iv[4] =
k->wk_keytsc >> 16;
2442 iv[5] =
k->wk_keytsc >> 24;
2443 iv[6] =
k->wk_keytsc >> 32;
2444 iv[7] =
k->wk_keytsc >> 40;
2450 if (
k->wk_flags & IEEE80211_KEY_GROUP) {
2454 attr &= ~(0xf << (
k->wk_keyix * 4));
2455 attr |= mode << (
k->wk_keyix * 4);
2483 struct ieee80211com *ic = vap->iv_ic;
2488 RUN_DPRINTF(sc, RUN_DEBUG_KEY,
"cmdq_store=%d\n", i);
2493 IEEE80211_ADDR_COPY(sc->
cmdq[i].
mac,
k->wk_macaddr);
2500 if (vap->iv_opmode == IEEE80211_M_HOSTAP) {
2519 struct ieee80211_key *
k = &cmdq->
key;
2525 if (
k->wk_flags & IEEE80211_KEY_GROUP) {
2527 RUN_DPRINTF(sc, RUN_DEBUG_KEY,
"removing group key\n");
2529 attr &= ~(0xf << (
k->wk_keyix * 4));
2534 "removing key for wcid %x\n",
k->wk_pad);
2552 struct ieee80211com *ic = vap->iv_ic;
2554 struct ieee80211_key *k0;
2564 RUN_DPRINTF(sc, RUN_DEBUG_KEY,
"cmdq_store=%d\n", i);
2569 k0->wk_flags =
k->wk_flags;
2570 k0->wk_keyix =
k->wk_keyix;
2572 k0->wk_pad =
k->wk_pad;
2593 struct ieee80211com *ic = &sc->
sc_ic;
2594 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2599 if (sc->
rvp_cnt > 1 || vap->iv_opmode != IEEE80211_M_STA) {
2627 uint16_t (*wstat)[3];
2628 uint8_t wcid, mcs, pid;
2636 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"tx stat 0x%08x\n", stat);
2662 counter_u64_add(sc->
sc_ic.ic_oerrors, 1);
2670 if ((
retry = pid -1 - mcs) > 0) {
2684 struct ieee80211_ratectl_tx_stats *txs = &sc->
sc_txs;
2685 struct ieee80211vap *vap = ni->ni_vap;
2688 uint16_t (*wstat)[3];
2694 if (sc->
rvp_cnt <= 1 && vap->iv_opmode == IEEE80211_M_STA &&
2698 txs->flags = IEEE80211_RATECTL_TX_STATS_NODE |
2699 IEEE80211_RATECTL_TX_STATS_RETRIES;
2701 if (sc->
rvp_cnt <= 1 && (vap->iv_opmode == IEEE80211_M_IBSS ||
2702 vap->iv_opmode == IEEE80211_M_STA)) {
2710 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS,
2711 le16toh(sta[0].
error.fail));
2713 txs->nretries = le16toh(sta[1].
tx.retry);
2714 txs->nsuccess = le16toh(sta[1].
tx.success);
2716 txs->nframes = txs->nretries + txs->nsuccess +
2717 le16toh(sta[0].
error.fail);
2720 "retrycnt=%d success=%d failcnt=%d\n",
2721 txs->nretries, txs->nsuccess, le16toh(sta[0].
error.fail));
2733 "retrycnt=%d txcnt=%d success=%d\n",
2734 txs->nretries, txs->nframes, txs->nsuccess);
2736 memset(wstat, 0,
sizeof(*wstat));
2739 ieee80211_ratectl_tx_update(vap, txs);
2740 ieee80211_ratectl_rate(ni, NULL, 0);
2757 struct ieee80211_node *ni = cmdq->
arg1;
2758 struct run_softc *sc = ni->ni_vap->iv_ic->ic_softc;
2764 ni->ni_macaddr, IEEE80211_ADDR_LEN);
2773 struct ieee80211vap *vap = ni->ni_vap;
2774 struct ieee80211com *ic = vap->iv_ic;
2780 wcid = (vap->iv_opmode == IEEE80211_M_STA) ?
2784 device_printf(sc->
sc_dev,
"wcid=%d out of range\n", wcid);
2789 if (isnew && ni->ni_associd != 0) {
2795 RUN_DPRINTF(sc, RUN_DEBUG_STATE,
"cmdq_store=%d\n", cnt);
2804 "new assoc isnew=%d associd=%x addr=%s\n",
2805 isnew, ni->ni_associd, ether_sprintf(ni->ni_macaddr));
2807 rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate;
2814 "rate=%d, mgmt_ridx=%d\n", rate, rn->
mgt_ridx);
2825static __inline uint8_t
2828 uint8_t rxchain = 0;
2831 if (rxwi->
rssi[1] > rxwi->
rssi[rxchain])
2834 if (rxwi->
rssi[2] > rxwi->
rssi[rxchain])
2842 const struct ieee80211_rx_stats *rxs,
int rssi,
int nf)
2844 struct ieee80211vap *vap = ni->ni_vap;
2845 struct run_softc *sc = vap->iv_ic->ic_softc;
2847 uint64_t ni_tstamp, rx_tstamp;
2849 rvp->
recv_mgmt(ni, m, subtype, rxs, rssi, nf);
2851 if (
vap->iv_state == IEEE80211_S_RUN &&
2852 (subtype == IEEE80211_FC0_SUBTYPE_BEACON ||
2853 subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)) {
2854 ni_tstamp = le64toh(ni->ni_tstamp.tsf);
2858 rx_tstamp = le64toh(rx_tstamp);
2860 if (ni_tstamp >= rx_tstamp) {
2861 RUN_DPRINTF(sc, RUN_DEBUG_RECV | RUN_DEBUG_BEACON,
2862 "ibss merge, tsf %ju tstamp %ju\n",
2863 (uintmax_t)rx_tstamp, (uintmax_t)ni_tstamp);
2864 (void) ieee80211_ibss_merge(ni);
2872 struct ieee80211com *ic = &sc->
sc_ic;
2873 struct ieee80211_frame *wh;
2874 struct ieee80211_node *ni;
2875 struct epoch_tracker et;
2879 uint16_t
len, rxwisize;
2885 rxwisize +=
sizeof(uint64_t);
2886 else if (sc->
mac_ver == 0x3593)
2887 rxwisize +=
sizeof(uint32_t);
2889 if (__predict_false(dmalen <
2890 rxwisize +
sizeof(
struct ieee80211_frame_ack))) {
2892 "payload is too short: dma length %u < %zu\n",
2893 dmalen, rxwisize +
sizeof(
struct ieee80211_frame_ack));
2898 len = le16toh(rxwi->
len) & 0xfff;
2900 if (__predict_false(
len > dmalen - rxwisize)) {
2902 "bad RXWI length %u > %u\n",
len, dmalen);
2907 rxd = (
struct rt2870_rxd *)(mtod(m, caddr_t) + dmalen);
2918 "received RT2860_RX_L2PAD frame\n");
2922 m->m_data += rxwisize;
2923 m->m_pkthdr.len = m->m_len =
len;
2925 wh = mtod(m,
struct ieee80211_frame *);
2927 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 &&
2929 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
2930 m->m_flags |= M_WEP;
2933 if (
len >=
sizeof(
struct ieee80211_frame_min)) {
2934 ni = ieee80211_find_rxnode(ic,
2935 mtod(m,
struct ieee80211_frame_min *));
2939 if(ni && ni->ni_flags & IEEE80211_NODE_HT) {
2940 m->m_flags |= M_AMPDU;
2946 ieee80211_notify_michael_failure(ni->ni_vap, wh,
2949 "MIC error. Someone is lying.\n");
2954 rssi = rxwi->
rssi[ant];
2957 if (__predict_false(ieee80211_radiotap_active(ic))) {
2963 tap->
wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD;
2971 phy = le16toh(rxwi->
phy);
2975 case 0: tap->
wr_rate = 2;
break;
2976 case 1: tap->
wr_rate = 4;
break;
2977 case 2: tap->
wr_rate = 11;
break;
2978 case 3: tap->
wr_rate = 22;
break;
2981 tap->
wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
2985 case 0: tap->
wr_rate = 12;
break;
2986 case 1: tap->
wr_rate = 18;
break;
2987 case 2: tap->
wr_rate = 24;
break;
2988 case 3: tap->
wr_rate = 36;
break;
2989 case 4: tap->
wr_rate = 48;
break;
2990 case 5: tap->
wr_rate = 72;
break;
2991 case 6: tap->
wr_rate = 96;
break;
2992 case 7: tap->
wr_rate = 108;
break;
2998 NET_EPOCH_ENTER(et);
3000 (void)ieee80211_input(ni, m, rssi, nf);
3001 ieee80211_free_node(ni);
3003 (void)ieee80211_input_all(ic, m, rssi, nf);
3011 counter_u64_add(ic->ic_ierrors, 1);
3018 struct ieee80211com *ic = &sc->
sc_ic;
3019 struct mbuf *m = NULL;
3021 uint32_t dmalen, mbuf_len;
3027 rxwisize +=
sizeof(uint64_t);
3028 else if (sc->
mac_ver == 0x3593)
3029 rxwisize +=
sizeof(uint32_t);
3037 "rx done, actlen=%d\n", xferlen);
3039 if (xferlen < (
int)(
sizeof(uint32_t) + rxwisize +
3041 RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB,
3042 "xfer too short %d\n", xferlen);
3052 if (sc->
rx_m == NULL) {
3053 sc->
rx_m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR,
3056 if (sc->
rx_m == NULL) {
3058 RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB,
3059 "could not allocate mbuf - idle with stall\n");
3060 counter_u64_add(ic->ic_ierrors, 1);
3081 device_printf(sc->
sc_dev,
"device timeout\n");
3082 counter_u64_add(ic->ic_ierrors, 1);
3085 if (sc->
rx_m != NULL) {
3099 m->m_pkthdr.len = m->m_len = xferlen;
3103 dmalen = le32toh(*mtod(m, uint32_t *)) & 0xffff;
3105 if ((dmalen >= (uint32_t)-8) || (dmalen == 0) ||
3106 ((dmalen & 3) != 0)) {
3107 RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB,
3108 "bad DMA length %u\n", dmalen);
3111 if ((dmalen + 8) > (uint32_t)xferlen) {
3112 RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB,
3113 "bad DMA length %u > %d\n",
3114 dmalen + 8, xferlen);
3119 if ((xferlen -= dmalen + 8) <= 8) {
3122 m->m_pkthdr.len = m->m_len -= 4;
3128 mbuf_len = dmalen +
sizeof(
struct rt2870_rxd);
3129 if (__predict_false(mbuf_len > MCLBYTES)) {
3130 RUN_DPRINTF(sc, RUN_DEBUG_RECV_DESC | RUN_DEBUG_USB,
3131 "payload is too big: mbuf_len %u\n", mbuf_len);
3132 counter_u64_add(ic->ic_ierrors, 1);
3137 m0 = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
3138 if (__predict_false(m0 == NULL)) {
3140 "could not allocate mbuf\n");
3141 counter_u64_add(ic->ic_ierrors, 1);
3145 mbuf_len, mtod(m0, caddr_t));
3146 m0->m_pkthdr.len = m0->m_len = mbuf_len;
3150 m->m_data += mbuf_len + 4;
3151 m->m_pkthdr.len = m->m_len -= mbuf_len + 4;
3157#ifdef IEEE80211_SUPPORT_SUPERG
3158 ieee80211_ff_age_all(ic, 100);
3168 ieee80211_tx_complete(
data->ni,
data->m, txerr);
3181 struct ieee80211com *ic = &sc->
sc_ic;
3183 struct ieee80211vap *vap = NULL;
3196 "transfer complete: %d bytes @ index %d\n", actlen,
index);
3213 sizeof(
data->desc) +
sizeof(uint32_t) :
sizeof(
data->desc);
3214 if ((m->m_pkthdr.len +
3216 RUN_DPRINTF(sc, RUN_DEBUG_XMIT_DESC | RUN_DEBUG_USB,
3217 "data overflow, %u bytes\n", m->m_pkthdr.len);
3225 size += m->m_pkthdr.len;
3234 vap =
data->ni->ni_vap;
3235 if (ieee80211_radiotap_active_vap(vap)) {
3236 const struct ieee80211_frame *wh;
3242 wh = mtod(m,
struct ieee80211_frame *);
3244 IEEE80211_QOS_HAS_SEQ(wh);
3250 tap->
wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
3252 tap->
wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD;
3254 ieee80211_radiotap_tx(vap, m);
3258 "sending frame len=%u/%u @ index %d\n",
3275 if(
data->ni != NULL)
3276 vap =
data->ni->ni_vap;
3282 vap = TAILQ_FIRST(&ic->ic_vaps);
3286 device_printf(sc->
sc_dev,
"device timeout\n");
3289 "cmdq_store=%d\n", i);
3305#ifdef IEEE80211_SUPPORT_SUPERG
3310 ieee80211_ff_flush_all(ic);
3355 struct mbuf *m =
data->m;
3356 struct ieee80211com *ic = &sc->
sc_ic;
3357 struct ieee80211vap *vap =
data->ni->ni_vap;
3358 struct ieee80211_frame *wh;
3361 uint16_t xferlen, txwisize;
3363 uint8_t ridx =
data->ridx;
3369 txwisize = (sc->
mac_ver == 0x5592) ?
3370 sizeof(*txwi) +
sizeof(uint32_t) :
sizeof(*txwi);
3371 xferlen = txwisize + m->m_pkthdr.len;
3374 xferlen = (xferlen + 3) & ~3;
3377 txd->
len = htole16(xferlen);
3379 wh = mtod(m,
struct ieee80211_frame *);
3392 txwi->
len = htole16(m->m_pkthdr.len -
pad);
3396 (ic->ic_flags & IEEE80211_F_SHPREAMBLE))
3404 txwi->
phy = htole16(mcs);
3407 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) &&
3408 ((m->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) ||
3409 ((ic->ic_flags & IEEE80211_F_USEPROT) &&
3411 ((ic->ic_htprotmode == IEEE80211_PROT_RTSCTS) &&
3417 if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh))
3425 struct ieee80211com *ic = &sc->
sc_ic;
3426 struct ieee80211vap *vap = ni->ni_vap;
3427 struct ieee80211_frame *wh;
3428 const struct ieee80211_txparam *tp = ni->ni_txparms;
3446 wh = mtod(m,
struct ieee80211_frame *);
3448 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
3456 if ((hasqos = IEEE80211_QOS_HAS_SEQ(wh))) {
3459 frm = ieee80211_getqos(wh);
3460 qos = le16toh(*(
const uint16_t *)frm);
3461 tid = qos & IEEE80211_QOS_TID;
3462 qid = TID_TO_WME_AC(tid);
3470 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"qos %d\tqid %d\ttid %d\tqflags %x\n",
3471 qos, qid, tid, qflags);
3474 if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
3475 type != IEEE80211_FC0_TYPE_DATA || m->m_flags & M_EAPOL) {
3477 ridx = (ic->ic_curmode == IEEE80211_MODE_11A || ic->ic_curmode == IEEE80211_MODE_11NA) ?
3481 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
3488 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) &&
3489 (!hasqos || (qos & IEEE80211_QOS_ACKPOLICY) !=
3490 IEEE80211_QOS_ACKPOLICY_NOACK)) {
3492 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
3496 USETW(wh->i_dur, dur);
3501 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"tx ring %d is full\n", qid);
3510 txd->
flags = qflags;
3513 if (IEEE80211_IS_MULTICAST(wh->i_addr1))
3516 txwi->
wcid = (vap->iv_opmode == IEEE80211_M_STA) ?
3542 if (sc->
rvp_cnt > 1 || vap->iv_opmode == IEEE80211_M_HOSTAP ||
3543 vap->iv_opmode == IEEE80211_M_MBSS) {
3565 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"cmdq_store=%d\n", i);
3577 "sending data frame len=%d rate=%d qid=%d\n",
3578 m->m_pkthdr.len + (
int)(
sizeof(
struct rt2870_txd) +
3587 struct ieee80211com *ic = &sc->
sc_ic;
3590 struct ieee80211_frame *wh;
3600 wh = mtod(m,
struct ieee80211_frame *);
3604 (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) ==
3605 (IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_PROBE_RESP))
3607 else if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) {
3611 ic->ic_flags & IEEE80211_F_SHPREAMBLE);
3612 USETW(wh->i_dur, dur);
3626 txwi->
flags = wflags;
3636 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"sending mgt frame len=%d rate=%d\n",
3637 m->m_pkthdr.len + (
int)(
sizeof(
struct rt2870_txd) +
3649 const struct mbuf *m,
struct ieee80211_node *ni,
int prot,
int rate)
3651 struct ieee80211com *ic = ni->ni_ic;
3668 mprot = ieee80211_alloc_prot(ni, m, rate, prot);
3669 if (mprot == NULL) {
3670 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1);
3671 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"could not allocate mbuf\n");
3675 protrate = ieee80211_ctl_rate(ic->ic_rt, rate);
3678 if (prot == IEEE80211_PROT_RTSCTS)
3689 txwi->
flags = wflags;
3694 data->ni = ieee80211_ref_node(ni);
3704 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"sending prot len=%u rate=%u\n",
3705 m->m_pkthdr.len, rate);
3716 const struct ieee80211_bpf_params *params)
3718 struct ieee80211com *ic = ni->ni_ic;
3724 uint8_t opflags = 0;
3730 KASSERT(params != NULL, (
"no raw xmit params"));
3732 rate = params->ibp_rate0;
3733 if (!ieee80211_isratevalid(ic->ic_rt, rate)) {
3738 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
3740 if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) {
3742 params->ibp_flags & IEEE80211_BPF_RTS ?
3743 IEEE80211_PROT_RTSCTS : IEEE80211_PROT_CTSONLY,
3755 "sending raw frame, but tx ring is full\n");
3767 txwi->
txop = opflags;
3780 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"sending raw frame len=%u rate=%u\n",
3781 m->m_pkthdr.len, rate);
3792 const struct ieee80211_bpf_params *params)
3794 struct run_softc *sc = ni->ni_ic->ic_softc;
3805 if (params == NULL) {
3808 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"mgt tx failed\n");
3814 RUN_DPRINTF(sc, RUN_DEBUG_XMIT,
"tx with param failed\n");
3855 struct ieee80211_node *ni;
3863 while ((m = mbufq_dequeue(&sc->
sc_snd)) != NULL) {
3864 ni = (
struct ieee80211_node *)m->m_pkthdr.rcvif;
3865 if (
run_tx(sc, m, ni) != 0) {
3866 mbufq_prepend(&sc->
sc_snd, m);
3884 if (ic->ic_nrunning > 0) {
3894 ieee80211_start_all(ic);
3906 else if (
chan <= 64) {
3910 }
else if (
chan <= 138) {
3914 }
else if (
chan <= 165) {
3927 }
else if (
chan <= 64) {
3931 }
else if (
chan <= 138) {
3935 }
else if (
chan <= 165) {
3948 }
else if (
chan <= 64) {
3952 }
else if (
chan <= 138) {
3956 }
else if (
chan <= 165) {
3969 }
else if (
chan <= 64) {
3973 }
else if (
chan <= 138) {
3977 }
else if (
chan <= 165) {
4058 }
else if (sc->
mac_ver >= 0x5390)
4062 (sc->
mac_ver == 0x3593) ? 0x62 : 0x84);
4085 }
else if (sc->
mac_ver == 0x3572)
4089 (sc->
mac_ver == 0x3593) ? 0x82 : 0xf2);
4104 tmp |= 1 << 29 | 1 << 28;
4137 tmp = (tmp & ~0x00009090) | 0x00000090;
4144 agc = 0x1c + sc->
lna[0] * 2;
4146 agc = 0x2e + sc->
lna[0];
4149 agc = 0x24 + sc->
lna[group] * 2;
4151 agc = 0x22 + (sc->
lna[group] * 5) / 3;
4153 agc = 0x32 + (sc->
lna[group] * 5) / 3;
4163 int8_t txpow1, txpow2;
4173 r2 |= 1 << 17 | 1 << 6;
4186 txpow1 = (txpow1 > 0xf) ? (0xf) : (txpow1);
4187 r3 |= (txpow1 << 10) | (1 << 9);
4192 r3 |= (txpow1 << 10);
4195 txpow2 = (txpow2 > 0xf) ? (0xf) : (txpow2);
4196 r4 |= (txpow2 << 7) | (1 << 6);
4199 r4 |= (txpow2 << 7);
4203 r3 |= (txpow1 << 9);
4206 r4 |= (txpow2 << 6);
4232 int8_t txpow1, txpow2;
4256 rf = (rf & ~0x1f) | txpow1;
4261 rf = (rf & ~0x1f) | txpow2;
4267 rf |= 1 << 7 | 1 << 5;
4271 rf |= 1 << 6 | 1 << 4;
4278 rf = (rf & ~0x7f) | sc->
freq;
4297 int8_t txpow1, txpow2;
4322 rf |= (
chan <= 14) ? 0x08 : 0x04;
4327 rf &= ~(0x08 | 0x04);
4328 rf |= (
chan <= 14) ? 0x04 : 0x08;
4335 rf = 0xe0 | (txpow1 & 0xc) << 1 | (txpow1 & 0x3);
4342 rf = 0xe0 | (txpow2 & 0xc) << 1 | (txpow2 & 0x3);
4349 rf |= 1 << 7 | 1 << 5;
4353 rf |= 1 << 6 | 1 << 4;
4360 rf = (rf & ~0x7f) | sc->
freq;
4370 rf = (
chan <= 14) ? 0xd8 : ((rf & ~0xc8) | 0x14);
4374 rf = (
chan <= 14) ? 0xc3 : 0xc0;
4396 else if (
chan <= 64)
4398 else if (
chan <= 128)
4407 else if (
chan <= 64)
4409 else if (
chan <= 128)
4418 else if (
chan <= 64)
4447 int8_t txpow1, txpow2, txpow3;
4477 rf |= (
chan <= 14) ? 0x44 : 0x48;
4483 rf = 0x40 | ((txpow1 & 0x18) << 1) | (txpow1 & 0x07);
4489 rf = 0x40 | ((txpow2 & 0x18) << 1) | (txpow2 & 0x07);
4495 rf = 0x40 | ((txpow3 & 0x18) << 1) | (txpow3 & 0x07);
4512 rf = (rf & ~0x06) | (h20mhz << 1) | (h20mhz << 2);
4532 else if (
chan <= 128)
4539 rf = (rf & ~0x18) | 0x10;
4546 rf = (rf & ~0x03) | 0x01;
4551 rf |= (
chan <= 14) ? 0x14 : 0x10;
4556 rf |= (
chan <= 14) ? 0x60 : 0x40;
4561 rf |= (
chan <= 14) ? 0x0c : 0x08;
4569 rf |= (
chan <= 14) ? 0x6c : 0x3c;
4577 rf &= ~RT5390_VCOCAL;
4583 else if (
chan <= 64)
4585 else if (
chan <= 128)
4592 else if (
chan <= 64)
4594 else if (
chan <= 128)
4607 int8_t txpow1, txpow2;
4625 rf = (rf & ~0x3f) | (txpow1 & 0x3f);
4627 if ((rf & 0x3f) > 0x27)
4628 rf = (rf & ~0x3f) | 0x27;
4633 rf = (rf & ~0x3f) | (txpow2 & 0x3f);
4635 if ((rf & 0x3f) > 0x27)
4636 rf = (rf & ~0x3f) | 0x27;
4697 else if (
chan == 12)
4719 uint8_t
reg, rf, txpow_bound;
4720 int8_t txpow1, txpow2;
4744 rf |= ((freqs->
n & 0x0100) >> 8) << 4;
4750 rf |= (freqs->
k & 0x0f);
4756 rf |= ((freqs->
m - 0x8) & 0x3) << 2;
4760 rf |= (((freqs->
m - 0x8) & 0x4) >> 2) << 7;
4766 rf |= (freqs->
r - 0x1);
4776 rf = (
chan <= 10) ? 0x07 : 0x06;
4814 rf = (rf & ~0x3f) | (txpow1 & 0x3f);
4815 if ((rf & 0x3f) > txpow_bound)
4816 rf = (rf & ~0x3f) | txpow_bound;
4821 rf &= ~(1 << 7 | 1 << 6);
4823 rf = (rf & ~0x3f) | (txpow2 & 0x3f);
4824 if ((rf & 0x3f) > txpow_bound)
4825 rf = (rf & ~0x3f) | txpow_bound;
4881 struct ieee80211com *ic = &sc->
sc_ic;
4884 chan = ieee80211_chan2ieee(ic, c);
4885 if (
chan == 0 ||
chan == IEEE80211_CHAN_ANY)
4890 else if (sc->
mac_ver >= 0x5390)
4892 else if (sc->
mac_ver == 0x3593)
4894 else if (sc->
mac_ver == 0x3572)
4896 else if (sc->
mac_ver >= 0x3070)
4904 else if (
chan <= 64)
4906 else if (
chan <= 128)
4937 int maxchans,
int *nchans,
struct ieee80211_channel chans[])
4940 uint8_t bands[IEEE80211_MODE_BYTES];
4942 memset(bands, 0,
sizeof(bands));
4943 setbit(bands, IEEE80211_MODE_11B);
4944 setbit(bands, IEEE80211_MODE_11G);
4946 setbit(bands, IEEE80211_MODE_11NG);
4949 ieee80211_add_channels_default_2ghz(chans, maxchans, nchans, bands, 0);
4954 setbit(bands, IEEE80211_MODE_11A);
4956 setbit(bands, IEEE80211_MODE_11NA);
4958 ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
5001 struct ieee80211com *ic = vap->iv_ic;
5002 struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
5003 struct ieee80211_node *ni = vap->iv_bss;
5010 case IEEE80211_BEACON_ERP:
5013 case IEEE80211_BEACON_HTINFO:
5016 case IEEE80211_BEACON_TIM:
5023 setbit(bo->bo_flags, item);
5029 ieee80211_beacon_update(ni, rvp->
beacon_mbuf, mcast);
5032 RUN_DPRINTF(sc, RUN_DEBUG_BEACON,
"cmdq_store=%d\n", i);
5043 struct ieee80211vap *vap = arg;
5044 struct ieee80211_node *ni = vap->iv_bss;
5046 struct ieee80211com *ic = vap->iv_ic;
5053 if (ni->ni_chan == IEEE80211_CHAN_ANYC)
5055 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC)
5069 memset(&txwi, 0,
sizeof(txwi));
5071 txwi.
len = htole16(m->m_pkthdr.len);
5074 ridx = (ic->ic_curmode == IEEE80211_MODE_11A) ?
5083 txwisize = (sc->
mac_ver == 0x5592) ?
5084 sizeof(txwi) +
sizeof(uint32_t) :
sizeof(txwi);
5088 mtod(m, uint8_t *), (m->m_pkthdr.len + 1) & ~1);
5098 RUN_DPRINTF(sc, RUN_DEBUG_BEACON,
"cmdq_store=%d\n", i);
5107 struct ieee80211com *ic = arg;
5113 tmp |= (ic->ic_curmode == IEEE80211_MODE_11A) ?
5119 if (ic->ic_flags & IEEE80211_F_USEPROT) {
5120 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
5122 else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
5131 struct ieee80211vap *vap = arg;
5132 struct run_softc *sc = vap->iv_ic->ic_softc;
5136 if(vap->iv_state == IEEE80211_S_RUN &&
5137 vap->iv_opmode != IEEE80211_M_STA)
5139 else if (vap->iv_state == IEEE80211_S_SCAN) {
5141 "timeout caused by scan\n");
5143 ieee80211_cancel_scan(vap);
5146 "timeout by unknown cause\n");
5162 RUN_DPRINTF(sc, RUN_DEBUG_RESET,
"debug reg %08x\n", tmp);
5163 if ((tmp & (1 << 29)) && (tmp & (1 << 7 | 1 << 5))) {
5165 "CTS-to-self livelock detected\n");
5181 if (sc->
sc_ic.ic_promisc > 0)
5182 tmp &= ~RT2860_DROP_UC_NOME;
5186 RUN_DPRINTF(sc, RUN_DEBUG_RECV,
"%s promiscuous mode\n",
5187 (sc->
sc_ic.ic_promisc > 0) ?
"entering" :
"leaving");
5206 struct ieee80211com *ic = &sc->
sc_ic;
5207 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
5210 RUN_DPRINTF(sc, RUN_DEBUG_BEACON,
"rvp_id=%d ic_opmode=%d\n",
5211 RUN_VAP(vap)->rvp_id, ic->ic_opmode);
5215 tmp |= vap->iv_bss->ni_intval * 16;
5218 if (ic->ic_opmode == IEEE80211_M_STA) {
5224 }
else if (ic->ic_opmode == IEEE80211_M_IBSS) {
5231 }
else if (ic->ic_opmode == IEEE80211_M_HOSTAP ||
5232 ic->ic_opmode == IEEE80211_M_MBSS) {
5238 "Enabling TSF failed. undefined opmode\n");
5279#define CCK(mcs) (mcs)
5280#define OFDM(mcs) (1 << 3 | (mcs))
5303 struct ieee80211com *ic = &sc->
sc_ic;
5307 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
5310 tmp &= ~RT2860_CCK_SHORT_EN;
5317 struct ieee80211com *ic = &sc->
sc_ic;
5320 if (ic->ic_curmode == IEEE80211_MODE_11B)
5322 else if (ic->ic_curmode == IEEE80211_MODE_11A)
5332 which | (sc->
leds & 0x7f));
5339 bssid[0] | bssid[1] << 8 | bssid[2] << 16 | bssid[3] << 24);
5341 bssid[4] | bssid[5] << 8);
5350 addr[4] |
addr[5] << 8 | 0xff << 16);
5360 RUN_DPRINTF(sc, RUN_DEBUG_BEACON,
"cmdq_store=%d\n", i);
5372 struct ieee80211com *ic = arg;
5378 tmp |= IEEE80211_GET_SLOTTIME(ic);
5390 struct ieee80211com *ic = &sc->
sc_ic;
5391 struct ieee80211_channel *c = ic->ic_curchan;
5394 if (IEEE80211_IS_CHAN_5GHZ(c)) {
5395 u_int
chan = ieee80211_chan2ieee(ic, c);
5400 delta -= sc->
lna[1];
5401 else if (
chan <= 128)
5402 delta -= sc->
lna[2];
5404 delta -= sc->
lna[3];
5408 return (-12 - delta - rssi);
5472 int i,
error, ntries;
5476 for (ntries = 0; ntries < 20; ntries++) {
5479 if (bbp0 != 0 && bbp0 != 0xff)
5523 uint8_t bbp4, mingain, rf, target;
5552 tmp = (tmp & ~0x0f000000) | 0x0d000000;
5555 }
else if (sc->
mac_ver == 0x3071) {
5572 }
else if (sc->
mac_ver == 0x3572) {
5578 tmp = (tmp & ~0x1f000000) | 0x0d000000;
5584 tmp = (tmp & ~0x1f000000) | 0x01000000;
5595 target = (sc->
mac_ver < 0x3071) ? 0x16 : 0x13;
5606 target = (sc->
mac_ver < 0x3071) ? 0x19 : 0x15;
5625 rf &= ~RT3070_TX_LO1;
5630 mingain = (sc->
mac_ver == 0x3070) ? 1 : 2;
5672 tmp &= ~(1 << 4 | 1 << 7);
5695 tmp = (tmp & ~0x1f000000) | 0x0d000000;
5698 tmp = (tmp & ~0x1f000000) | 0x01000000;
5738 }
else if (sc->
mac_ver == 0x5392) {
5781 uint8_t bbp55_pb, bbp55_sb, delta;
5786 rf24 = (rf24 & 0xc0) |
init;
5795 for (ntries = 0; ntries < 100; ntries++) {
5809 for (ntries = 0; ntries < 100; ntries++) {
5816 delta = bbp55_pb - bbp55_sb;
5869 }
else if (sc->
mac_ver == 0x3071) {
5893 }
else if (sc->
mac_ver == 0x3070) {
5912 for (i = 0; i < 10; i++) {
5913 if (sc->
rf[i].
reg == 0 || sc->
rf[i].
reg == 0xff)
5954 rf = (rf & ~0x18) | 0x10;
6024 rf = (rf & ~0x18) | 0x10;
6040 struct ieee80211com *ic = &sc->
sc_ic;
6045 for (ntries = 0; ntries < 200; ntries++) {
6067 if (ic->ic_opmode != IEEE80211_M_MONITOR) {
6072 if (ic->ic_opmode == IEEE80211_M_STA)
6090 rf = (rf & ~0x7f) | (sc->
freq & 0x7f);
6100 struct ieee80211com *ic = &sc->
sc_ic;
6101 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
6108 if (ic->ic_nrunning > 1)
6114 device_printf(sc->
sc_dev,
"could not load 8051 microcode\n");
6118 for (ntries = 0; ntries < 100; ntries++) {
6121 if (tmp != 0 && tmp != 0xffffffff)
6133 for (ntries = 0; ntries < 100; ntries++) {
6140 if (ntries == 100) {
6141 device_printf(sc->
sc_dev,
"timeout waiting for DMA engine\n");
6157 device_printf(sc->
sc_dev,
"could not reset chipset\n");
6164 for (ridx = 0; ridx < 5; ridx++) {
6189 }
else if (sc->
mac_ver == 0x3593) {
6192 }
else if (sc->
mac_ver >= 0x3070) {
6199 for (ntries = 0; ntries < 100; ntries++) {
6215 device_printf(sc->
sc_dev,
"could not initialize BBP\n");
6236 tmp = (tmp & ~0xff) | 0x1e;
6247 for (i = 0; i < 10; i++) {
6265 else if (sc->
mac_ver == 0x3593)
6267 else if (sc->
mac_ver >= 0x3070)
6272 bbp3 &= ~(1 << 3 | 1 << 4);
6282 bbp1 &= ~(1 << 3 | 1 << 4);
6287 else if (sc->
mac_ver == 0x3593)
6289 else if (sc->
mac_ver >= 0x3070)
6349 if (sc->
rx_m != NULL) {
6360 for (ntries = 0; ntries < 100; ntries++) {
6367 if (ntries == 100) {
6368 device_printf(sc->
sc_dev,
"timeout waiting for DMA engine\n");
6378 for (ntries = 0; ntries < 100; ntries++) {
6381 "Cannot read Tx queue count\n");
6386 "All Tx cleared\n");
6393 "There are still pending Tx\n");
6415 printf(
"%s: TODO\n", __func__);
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+")
static int run_rt3070_filter_calib(struct run_softc *, uint8_t, uint8_t, uint8_t *)
static const struct @105 rt3593_def_rf[]
static usb_callback_t run_bulk_rx_callback
static void run_scan_start(struct ieee80211com *)
static usb_callback_t run_bulk_tx_callback5
static device_detach_t run_detach
static void run_rt3572_set_chan(struct run_softc *, u_int)
static void run_rt2870_set_chan(struct run_softc *, u_int)
static void run_enable_tsf(struct run_softc *)
static void run_init_locked(struct run_softc *)
static const struct @106 rt5592_chan_5ghz[]
static int run_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *)
static void run_setup_tx_list(struct run_softc *, struct run_endpoint_queue *)
static void run_reset_livelock(struct run_softc *)
static void run_recv_mgmt(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *, int, int)
static const struct @103 rt5390_def_bbp[]
static const STRUCT_USB_HOST_ID run_devs[]
static void run_newassoc_cb(void *)
static void run_rt5390_set_chan(struct run_softc *, u_int)
static void run_rt5592_set_chan(struct run_softc *, u_int)
static int run_reset(struct run_softc *)
static void run_key_delete_cb(void *)
static void run_iq_calib(struct run_softc *, u_int)
static struct ieee80211_node * run_node_alloc(struct ieee80211vap *, const uint8_t mac[IEEE80211_ADDR_LEN])
MODULE_DEPEND(run, wlan, 1, 1, 1)
static void run_adjust_freq_offset(struct run_softc *)
static void run_set_rx_antenna(struct run_softc *, int)
static void run_set_leds(struct run_softc *, uint16_t)
static int run_write_region_1(struct run_softc *, uint16_t, const uint8_t *, int)
static void run_start(struct run_softc *)
static int run_rt3070_rf_read(struct run_softc *, uint8_t, uint8_t *)
static const struct @105 rt3070_def_rf[]
static void run_rt5390_rf_setup(struct run_softc *)
#define RUN_DPRINTF(_sc, _m,...)
static void run_set_macaddr(struct run_softc *, const uint8_t *)
static void run_set_bssid(struct run_softc *, const uint8_t *)
static int run_key_set(struct ieee80211vap *, struct ieee80211_key *)
static void run_usb_timeout_cb(void *)
static void run_update_beacon(struct ieee80211vap *, int)
static void run_scan_end(struct ieee80211com *)
static void run_disable_tsf(struct run_softc *)
static int run_read_region_1(struct run_softc *, uint16_t, uint8_t *, int)
static void run_rt3593_rf_setup(struct run_softc *)
static void run_bulk_tx_callbackN(struct usb_xfer *xfer, usb_error_t error, u_int index)
static driver_t run_driver
USB_PNP_HOST_INFO(run_devs)
static __inline uint32_t b4inc(uint32_t b32, int8_t delta)
static int run_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap)
#define IEEE80211_HAS_ADDR4(wh)
static int run_eeprom_read_2(struct run_softc *, uint16_t, uint16_t *)
static int run_tx_param(struct run_softc *, struct mbuf *, struct ieee80211_node *, const struct ieee80211_bpf_params *)
static int run_bbp_write(struct run_softc *, uint8_t, uint8_t)
static void run_update_beacon_cb(void *)
static void run_updateslot(struct ieee80211com *)
static const struct @105 rt5392_def_rf[]
static int run_load_microcode(struct run_softc *)
static const struct rfprog rt2860_rf2850[]
static int run_driver_loaded(struct module *, int, void *)
#define RUN_DEV_EJECT(v, p)
static void run_set_channel(struct ieee80211com *)
static int run_rt3070_rf_write(struct run_softc *, uint8_t, uint8_t)
static void run_drain_mbufq(struct run_softc *sc)
static const struct rt5592_freqs rt5592_freqs_40mhz[]
static const struct @103 rt5592_def_bbp[]
static void run_stop(void *)
static int run_set_chan(struct run_softc *, struct ieee80211_channel *)
static void run_rt3070_set_chan(struct run_softc *, u_int)
static void run_update_mcast(struct ieee80211com *)
static int run_txrx_enable(struct run_softc *)
static int run_rt3070_rf_init(struct run_softc *)
static const struct @105 rt5592_def_rf[]
static int8_t run_rssi2dbm(struct run_softc *, uint8_t, uint8_t)
static const struct @103 rt2860_def_bbp[]
static const uint8_t rt5592_bbp_r196[]
static void run_get_txpower(struct run_softc *)
static void run_update_chw(struct ieee80211com *ic)
static device_probe_t run_match
#define RT2860_RIDX_OFDM6
static device_method_t run_methods[]
static int run_bbp_init(struct run_softc *)
static int run_write_2(struct run_softc *, uint16_t, uint16_t)
static usb_callback_t run_bulk_tx_callback3
static void run_set_basicrates(struct run_softc *)
static int run_set_region_4(struct run_softc *, uint16_t, uint32_t, int)
static usb_callback_t run_bulk_tx_callback2
static const struct @105 rt5592_2ghz_def_rf[]
static int run_tx_mgt(struct run_softc *, struct mbuf *, struct ieee80211_node *)
static void run_ratectl_cb(void *, int)
static const struct @105 rt5592_5ghz_def_rf[]
static usb_callback_t run_bulk_tx_callback1
static int run_read(struct run_softc *, uint16_t, uint32_t *)
static void run_autoinst(void *, struct usb_device *, struct usb_attach_arg *)
static int run_transmit(struct ieee80211com *, struct mbuf *)
static void run_enable_tsf_sync(struct run_softc *)
static void run_updateprot_cb(void *)
static void run_delay(struct run_softc *, u_int)
static const struct @105 rt5390_def_rf[]
static void run_unsetup_tx_list(struct run_softc *, struct run_endpoint_queue *)
static void run_rt3593_get_txpower(struct run_softc *)
static __inline uint8_t run_maxrssi_chain(struct run_softc *sc, const struct rt2860_rxwi *rxwi)
static usb_callback_t run_bulk_tx_callback4
static int run_efuse_read(struct run_softc *, uint16_t, uint16_t *, int)
static void run_vap_delete(struct ieee80211vap *)
static void run_get_tsf(struct run_softc *, uint64_t *)
static int run_rt2870_rf_write(struct run_softc *, uint32_t)
static __inline int run_srom_read(struct run_softc *sc, uint16_t addr, uint16_t *val)
static void run_iter_func(void *, struct ieee80211_node *)
static int run_read_eeprom(struct run_softc *)
static void run_rt3593_set_chan(struct run_softc *, u_int)
static usb_callback_t run_bulk_tx_callback0
static void run_rx_frame(struct run_softc *, struct mbuf *, uint32_t)
static const struct rt2860_rate rt2860_rates[]
static const struct @102 rt2870_def_mac[]
static int run_sendprot(struct run_softc *, const struct mbuf *, struct ieee80211_node *, int, int)
static void run_update_promisc(struct ieee80211com *)
static const struct usb_config run_config[RUN_N_XFER]
static int run_bbp_read(struct run_softc *, uint8_t, uint8_t *)
static const struct rt5592_freqs rt5592_freqs_20mhz[]
static void run_key_set_cb(void *)
static int run_tx(struct run_softc *, struct mbuf *, struct ieee80211_node *)
static void run_cmdq_cb(void *, int)
static void run_parent(struct ieee80211com *)
static int run_efuse_read_2(struct run_softc *, uint16_t, uint16_t *)
static void run_rt3070_rf_setup(struct run_softc *)
static void run_drain_fifo(void *)
static void run_select_chan_group(struct run_softc *, int)
static const char * run_get_rf(uint16_t)
static device_attach_t run_attach
static void run_tx_free(struct run_endpoint_queue *pq, struct run_tx_data *, int)
static void run_enable_mrr(struct run_softc *)
static void run_ratectl_to(void *)
static void run_set_txpreamble(struct run_softc *)
static void run_updateslot_cb(void *)
static void run_set_tx_desc(struct run_softc *, struct run_tx_data *)
static devclass_t run_devclass
static eventhandler_tag run_etag
static int run_wme_update(struct ieee80211com *)
DRIVER_MODULE(run, uhub, run_driver, run_devclass, run_driver_loaded, NULL)
static int run_media_change(struct ifnet *)
static void run_rt3593_rf_init(struct run_softc *)
struct @104 rt3070_freqs[]
static void run_rt5390_rf_init(struct run_softc *)
static int run_newstate(struct ieee80211vap *, enum ieee80211_state, int)
static const struct @105 rt3572_def_rf[]
static void run_newassoc(struct ieee80211_node *, int)
static usb_error_t run_do_request(struct run_softc *, struct usb_device_request *, void *)
static int run_mcu_cmd(struct run_softc *, uint8_t, uint16_t)
static void run_updateprot(struct ieee80211com *)
static struct ieee80211vap * run_vap_create(struct ieee80211com *, const char[IFNAMSIZ], int, enum ieee80211_opmode, int, const uint8_t[IEEE80211_ADDR_LEN], const uint8_t[IEEE80211_ADDR_LEN])
#define RT2860_RIDX_CCK11
static void run_getradiocaps(struct ieee80211com *, int, int *, struct ieee80211_channel[])
static void run_set_agc(struct run_softc *, uint8_t)
static int run_key_delete(struct ieee80211vap *, struct ieee80211_key *)
static void run_rt5390_bbp_init(struct run_softc *)
static int run_write(struct run_softc *, uint16_t, uint32_t)
static void run_update_promisc_locked(struct run_softc *)
#define RT2860_H2M_INTSRC
#define RT5390_EEPROM_IQ_GAIN_CAL_TX1_2GHZ
#define RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH100_TO_CH138_5GHZ
#define RT2860_EEPROM_CONFIG
#define RT3070_GPIO_SWITCH
#define RT5390_EEPROM_RF_IQ_IMBALANCE_COMPENSATION_CTL
#define RT3593_EEPROM_RSSI2_2GHZ
#define RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH100_TO_CH138_5GHZ
#define RT5390_MAC_IF_CTRL
#define RT2860_MODE_WEP40
#define RT2860_DROP_CFEND
#define RT2860_DROP_VER_ERR
#define RT2860_TX_PID_SHIFT
#define RT2860_EEPROM_DELTAPWR
#define RT2860_BBP_CSR_KICK
#define RT2860_PROT_CTRL_RTS_CTS
#define RT3593_EEPROM_RSSI1_2GHZ
#define RT2860_H2M_MAILBOX
#define RT3593_EEPROM_LED2
#define RT2860_LED_LINK_2GHZ
#define RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH100_TO_CH138_5GHZ
#define RT2860_TBTT_TIMER_EN
#define RT2860_LG_FBK_CFG0
#define RT2860_IFACE_INDEX
#define RT2860_EEPROM_PWR5GHZ_BASE2
#define RT2860_HT_FBK_CFG1
#define RT2860_LED_LINK_5GHZ
#define RT2860_PHY_HT_MIX
#define RT2860_TX_PIN_CFG
#define RT2860_WCID_ENTRY(wcid)
#define RT2860_H2M_MAILBOX_STATUS
#define RT2860_DROP_UC_NOME
#define RT3593_EEPROM_PWR5GHZ_BASE3
#define RT2860_EEPROM_LED2
#define RT2860_USB_RX_AGG_LMT(x)
#define RT5592_5GHZ_DEF_RF
#define RT2860_OFDM_PROT_CFG
#define RT3593_EEPROM_FREQ_LEDS
#define RT2860_EEPROM_MAC23
#define RT2860_MAC_ADDR_DW0
#define RT2860_TX2Q_PCNT_MASK
#define RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH36_TO_CH64_5GHZ
#define RT2860_TX_SW_CFG0
#define RT2860_LNA_PE1_EN
#define RT2860_EEPROM_PWR5GHZ_BASE1
#define RT2860_EEPROM_RSSI2_5GHZ
#define RT3070_EFSROM_AIN_SHIFT
#define RT2860_MCU_CMD_RFRESET
#define RT5390_EEPROM_IQ_PHASE_CAL_TX0_2GHZ
#define RT2860_5G_BAND_SEL_P
#define RT2860_H2M_MAILBOX_CID
#define RT2860_LNA_PE0_EN
#define RT2860_USB_DMA_CFG
#define RT2860_PA_PE_G1_EN
#define RT3593_EEPROM_PWR5GHZ_BASE2
#define RT2860_PA_PE_A1_EN
#define RT3070_EFSROM_KICK
#define RT2860_TX_PWR_CFG(ridx)
#define RT2860_DROP_CTRL_RSV
#define RT2860_WMM_TXOP1_CFG
#define RT2860_RX_FILTR_CFG
#define RT2860_TX_TXOP_HT
#define RT2860_TXQ_MCS_SHIFT
#define RT2860_MAC_SYS_CTRL
#define RT2860_TXQ_WCID_SHIFT
#define RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH140_TO_CH165_5GHZ
#define RT2860_PA_PE_G0_EN
#define RT2860_LEGACY_BASIC_RATE
#define RT3593_EEPROM_RSSI1_5GHZ
#define RT2860_TX_DMA_BUSY
#define RT5592_DEBUG_INDEX
#define RT2860_MAC_ADDR_DW1
#define RT2860_BCN_TIME_CFG
#define RT2860_EEPROM_LED3
#define RT2860_MAC_BSSID_DW1
#define RT3070_EFSROM_MODE_MASK
#define RT2860_WMM_AIFSN_CFG
#define RT2860_TOKEN_NO_INTR
#define RT2860_CCK_PROT_CFG
#define RT2860_AUTO_RSP_CFG
#define RT3593_EEPROM_LED1
#define RT5390_EEPROM_IQ_GAIN_CAL_TX0_2GHZ
#define RT2860_TXOP_ALLOW_ALL
#define RT2860_CTS_40M_MODE_EN
#define RT2860_EEPROM_VERSION
#define RT2860_WPDMA_GLO_CFG
#define RT2860_EEPROM_PWR2GHZ_BASE1
#define RT2860_H2M_BBPAGENT
#define RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH36_TO_CH64_5GHZ
#define RT2860_TX_SW_CFG2
#define RT2860_TX_STA_CNT0
#define RT3593_EEPROM_PWR2GHZ_BASE1
#define RT2860_TX_TXOP_BACKOFF
#define RT5390_EEPROM_IQ_PHASE_CAL_TX1_2GHZ
#define RT2860_DROP_CFACK
#define RT2860_MAC_STATUS_REG
#define RT5390_EEPROM_IQ_GAIN_CAL_TX0_CH36_TO_CH64_5GHZ
#define RT2860_SKEY_MODE_0_7
#define RT2860_EEPROM_MAC01
#define RT3070_EFUSE_CTRL
#define RT2860_MCU_CMD_LED3
#define RT2860_EDCA_AC_CFG(aci)
#define RT2860_TX_QSEL_EDCA
#define RT2860_EEPROM_PWR2GHZ_BASE2
#define RT2860_WMM_CWMIN_CFG
#define RT2860_EEPROM_LED1
#define RT2860_LG_FBK_CFG1
#define RT2860_USB_RX_AGG_TO(x)
#define RT2860_TXQ_PID_SHIFT
#define RT2860_TXQ_ACKREQ
#define RT2860_DROP_CRC_ERR
#define RT2860_EEPROM_FREQ_LEDS
#define RT2860_MCU_CMD_LED1
#define RT2860_EEPROM_RPWR
#define RT2860_BAC_ACKPOLICY_EN
#define RT5592_RF5592_20MHZ
#define RT2860_TSF_TIMER_EN
#define RT2860_CCK_SHORT_EN
#define RT2860_EEPROM_RSSI2_2GHZ
#define RT2860_PA_PE_A0_EN
#define RT2860_TSF_SYNC_MODE_SHIFT
#define RT2860_TX_SW_CFG1
#define RT3070_RF_CSR_CFG
#define RT2860_MAC_BSSID_DW0
#define RT2860_EEPROM_BBP_BASE
#define RT2860_WMM_CWMAX_CFG
#define RT2860_5G_BAND_SEL_N
#define RT2860_RX_DMA_BUSY
#define RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH100_TO_CH138_5GHZ
#define RT2860_WMM_TXOP0_CFG
#define RT3593_AUTOTUNE_BYPASS
#define RT3593_EEPROM_FREQ
#define RT2860_WCID_ATTR(wcid)
#define RT5390_EEPROM_IQ_GAIN_CAL_TX1_CH140_TO_CH165_5GHZ
#define RT2860_MODE_AES_CCMP
#define RT2860_USB_RX_AGG_EN
#define RT3593_EEPROM_PWR2GHZ_BASE2
#define RT2860_DROP_PSPOLL
#define RT2860_US_CYC_CNT
#define RT2860_TSF_TIMER_DW0
#define RT2860_EEPROM_ANTENNA
#define RT2860_RX_PKEY_EN
#define RT2870_READ_REGION_1
#define RT3593_EEPROM_RSSI2_5GHZ
#define RT2860_TXOP_CTRL_CFG
#define RT2860_MCU_CMD_ANTSEL
#define RT3593_EEPROM_LED3
#define RT2860_PROT_NAV_SHORT
#define RT2860_MCU_CMD_LED2
#define RT2860_MCU_CMD_LEDS
#define RT2860_IVEIV(wcid)
#define RT5592_2GHZ_DEF_RF
#define RT2860_TX_QSEL_HCCA
#define RT2860_RF_CSR_CFG0
#define RT2860_TX_WB_DDONE
static const uint8_t run_chan_5ghz[]
#define RT2860_TXOP_HLDR_ET
#define RT2860_BKOFF_SLOT_CFG
#define RT2860_ASIC_VER_ID
#define RT3593_EEPROM_PWR2GHZ_BASE3
#define RT2870_WRITE_REGION_1
#define RT2860_TX_STATUS_BUSY
#define RT3593_EEPROM_LNA
#define RT2860_EEPROM_RSSI1_2GHZ
#define RT2860_EEPROM_LNA
#define RT2860_AUTO_RSP_EN
#define RT2860_MAX_LEN_CFG
#define RT2860_TXRXQ_PCNT
#define RT2860_EEPROM_MAC45
#define RT5390_EEPROM_RF_IQ_COMPENSATION_CTL
#define RT3070_EFUSE_DATA3
#define RT2860_MODE_WEP104
#define RT2860_DROP_PHY_ERR
#define RT2860_BBP_CSR_CFG
#define RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH140_TO_CH165_5GHZ
#define RT5390_EEPROM_IQ_PHASE_CAL_TX1_CH140_TO_CH165_5GHZ
#define RT3593_EEPROM_PWR5GHZ_BASE1
#define RT3070_EFSROM_AIN_MASK
#define RT2860_EEPROM_RSSI1_5GHZ
#define RT2860_DLY_PAPE_EN_SHIFT
#define RT2860_SKEY(vap, kidx)
#define RT2860_RF_REG_CTRL
#define RT3070_EFUSE_AOUT_MASK
#define RT2860_TX_BAND_CFG
#define RT5592_RF5592_40MHZ
#define RT5390_EEPROM_IQ_PHASE_CAL_TX0_CH36_TO_CH64_5GHZ
#define RT2860_RX_STATUS_BUSY
#define RT2860_PKEY(wcid)
#define RT2870_EEPROM_READ
#define RT3071_EEPROM_RF_BASE
#define RT3593_EEPROM_LNA_5GHZ
#define RT2860_PROT_CTRL_CTS
#define RT2860_BBP_CSR_READ
#define RT2860_TX_STAT_FIFO
#define RT2860_TX_TXOP_SIFS
#define RT2860_BCN_BASE(vap)
#define RUN_RX_RADIOTAP_PRESENT
#define RUN_LOCK_ASSERT(sc, t)
#define RUN_FLAG_FWLOAD_NEEDED
#define RUN_TX_RING_COUNT
#define RUN_TX_RADIOTAP_PRESENT
#define RUN_AID2WCID(aid)
enum ieee80211_phytype phy
uint8_t mac[IEEE80211_ADDR_LEN]
struct run_tx_data_head tx_fh
struct run_tx_data_head tx_qh
struct run_tx_data tx_data[RUN_TX_RING_COUNT]
uint32_t txpow40mhz_5ghz[5]
int(* sc_srom_read)(struct run_softc *, uint16_t, uint16_t *)
struct ieee80211com sc_ic
struct usb_callout ratectl_ch
uint16_t wcid_stats[RT2870_WCID_MAX+1][3]
struct run_softc::@112 rf[10]
struct usb_xfer * sc_xfer[RUN_N_XFER]
struct run_cmdq cmdq[RUN_CMDQ_MAX]
uint32_t txpow40mhz_2ghz[5]
struct usb_device * sc_udev
struct ieee80211_ratectl_tx_stats sc_txs
struct run_endpoint_queue sc_epq[RUN_EP_QUEUES]
struct run_softc::@112 bbp[10]
uint8_t sc_bssid[IEEE80211_ADDR_LEN]
void(* recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *, int, int)
int(* newstate)(struct ieee80211vap *, enum ieee80211_state, int)
struct mbuf * beacon_mbuf
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
void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len)
void usbd_copy_in(struct usb_page_cache *cache, usb_frlength_t offset, const void *ptr, usb_frlength_t len)
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 usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method)
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_xfer_set_frames(struct usb_xfer *xfer, usb_frcount_t n)
void * usbd_xfer_get_priv(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)
void usbd_xfer_set_frame_len(struct usb_xfer *xfer, usb_frcount_t frindex, usb_frlength_t len)
struct usb_page_cache * usbd_xfer_get_frame(struct usb_xfer *xfer, usb_frcount_t frindex)
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_set_priv(struct usb_xfer *xfer, void *ptr)
void usbd_transfer_drain(struct usb_xfer *xfer)
void * usbd_xfer_softc(struct usb_xfer *xfer)
void usbd_xfer_set_stall(struct usb_xfer *xfer)
void usbd_xfer_status(struct usb_xfer *xfer, int *actlen, int *sumlen, int *aframes, int *nframes)
void device_set_usb_desc(device_t dev)
void usb_pause_mtx(struct mtx *mtx, int timo)
#define usb_callout_init_mtx(c, m, f)
#define usb_callout_reset(c,...)
#define usb_callout_drain(c)
#define USB_ST_TRANSFERRED
void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len)
#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_callout_stop(c)
#define USB_GET_STATE(xfer)
#define usbd_do_request(u, m, r, d)