Lines Matching +full:efuse +full:- +full:settings

1 /*-
5 * Copyright (c) 2013-2014 Kevin Lo
21 /*-
115 device_printf((_sc)->sc_dev, __VA_ARGS__); \
531 /* MCS - single stream */
541 /* MCS - 2 streams */
551 /* MCS - 3 streams */
732 if (uaa->dev_state != UAA_DEV_READY) in run_autoinst()
738 id = iface->idesc; in run_autoinst()
739 if (id == NULL || id->bInterfaceClass != UICLASS_MASS) in run_autoinst()
745 uaa->dev_state = UAA_DEV_EJECTING; in run_autoinst()
770 if (uaa->usb_mode != USB_MODE_HOST) in run_match()
772 if (uaa->info.bConfigIndex != 0) in run_match()
774 if (uaa->info.bIfaceIndex != RT2860_IFACE_INDEX) in run_match()
785 struct ieee80211com *ic = &sc->sc_ic; in run_attach()
791 sc->sc_udev = uaa->device; in run_attach()
792 sc->sc_dev = self; in run_attach()
794 sc->sc_flags |= RUN_FLAG_FWLOAD_NEEDED; in run_attach()
796 mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), in run_attach()
798 mbufq_init(&sc->sc_snd, ifqmaxlen); in run_attach()
802 error = usbd_transfer_setup(uaa->device, &iface_index, in run_attach()
803 sc->sc_xfer, run_config, RUN_N_XFER, sc, &sc->sc_mtx); in run_attach()
823 device_printf(sc->sc_dev, in run_attach()
828 sc->mac_ver = ver >> 16; in run_attach()
829 sc->mac_rev = ver & 0xffff; in run_attach()
834 device_printf(sc->sc_dev, in run_attach()
836 sc->mac_ver, sc->mac_rev, run_get_rf(sc->rf_rev), in run_attach()
837 sc->ntxchains, sc->nrxchains, ether_sprintf(ic->ic_macaddr)); in run_attach()
841 ic->ic_softc = sc; in run_attach()
842 ic->ic_name = device_get_nameunit(self); in run_attach()
843 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in run_attach()
844 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ in run_attach()
847 ic->ic_caps = in run_attach()
852 IEEE80211_C_WDS | /* 4-address traffic works */ in run_attach()
856 IEEE80211_C_SWAMSDUTX | /* Do software A-MSDU TX */ in run_attach()
857 IEEE80211_C_FF | /* Atheros fast-frames */ in run_attach()
864 if (sc->rf_rev != RT3070_RF_2020) { in run_attach()
865 device_printf(sc->sc_dev, "[HT] Enabling 802.11n\n"); in run_attach()
866 ic->ic_htcaps = in run_attach()
873 ic->ic_rxstream = sc->nrxchains; in run_attach()
874 ic->ic_txstream = sc->ntxchains; in run_attach()
877 ic->ic_cryptocaps = in run_attach()
883 ic->ic_flags |= IEEE80211_F_DATAPAD; in run_attach()
884 ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS; in run_attach()
886 run_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in run_attach()
887 ic->ic_channels); in run_attach()
891 ic->ic_scan_start = run_scan_start; in run_attach()
892 ic->ic_scan_end = run_scan_end; in run_attach()
893 ic->ic_set_channel = run_set_channel; in run_attach()
894 ic->ic_getradiocaps = run_getradiocaps; in run_attach()
895 ic->ic_node_alloc = run_node_alloc; in run_attach()
896 ic->ic_newassoc = run_newassoc; in run_attach()
897 ic->ic_updateslot = run_updateslot; in run_attach()
898 ic->ic_update_mcast = run_update_mcast; in run_attach()
899 ic->ic_wme.wme_update = run_wme_update; in run_attach()
900 ic->ic_raw_xmit = run_raw_xmit; in run_attach()
901 ic->ic_update_promisc = run_update_promisc; in run_attach()
902 ic->ic_vap_create = run_vap_create; in run_attach()
903 ic->ic_vap_delete = run_vap_delete; in run_attach()
904 ic->ic_transmit = run_transmit; in run_attach()
905 ic->ic_parent = run_parent; in run_attach()
906 ic->ic_update_chw = run_update_chw; in run_attach()
907 ic->ic_ampdu_enable = run_ampdu_enable; in run_attach()
910 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in run_attach()
912 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in run_attach()
915 TASK_INIT(&sc->cmdq_task, 0, run_cmdq_cb, sc); in run_attach()
916 TASK_INIT(&sc->ratectl_task, 0, run_ratectl_cb, sc); in run_attach()
917 usb_callout_init_mtx(&sc->ratectl_ch, &sc->sc_mtx, 0); in run_attach()
936 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in run_drain_mbufq()
937 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in run_drain_mbufq()
938 m->m_pkthdr.rcvif = NULL; in run_drain_mbufq()
948 struct ieee80211com *ic = &sc->sc_ic; in run_detach()
952 sc->sc_detached = 1; in run_detach()
956 usbd_transfer_unsetup(sc->sc_xfer, RUN_N_XFER); in run_detach()
959 sc->ratectl_run = RUN_RATECTL_OFF; in run_detach()
960 sc->cmdq_run = sc->cmdq_key_set = RUN_CMDQ_ABORT; in run_detach()
964 run_unsetup_tx_list(sc, &sc->sc_epq[i]); in run_detach()
970 if (sc->sc_ic.ic_softc == sc) { in run_detach()
972 usb_callout_drain(&sc->ratectl_ch); in run_detach()
973 ieee80211_draintask(ic, &sc->cmdq_task); in run_detach()
974 ieee80211_draintask(ic, &sc->ratectl_task); in run_detach()
978 mtx_destroy(&sc->sc_mtx); in run_detach()
989 struct run_softc *sc = ic->ic_softc; in run_vap_create()
994 if (sc->rvp_cnt >= RUN_VAP_MAX) { in run_vap_create()
995 device_printf(sc->sc_dev, "number of VAPs maxed out\n"); in run_vap_create()
1009 if (!TAILQ_EMPTY(&ic->ic_vaps)) in run_vap_create()
1013 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next){ in run_vap_create()
1014 if(vap->iv_opmode != IEEE80211_M_HOSTAP) in run_vap_create()
1021 device_printf(sc->sc_dev, in run_vap_create()
1027 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in run_vap_create()
1032 vap = &rvp->vap; in run_vap_create()
1041 vap->iv_update_beacon = run_update_beacon; in run_vap_create()
1042 vap->iv_max_aid = RT2870_WCID_MAX; in run_vap_create()
1048 if (ic->ic_rxstream > 1) in run_vap_create()
1049 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in run_vap_create()
1051 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_32K; in run_vap_create()
1052 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_2; /* 2uS */ in run_vap_create()
1060 vap->iv_key_delete = (void *)run_key_delete; in run_vap_create()
1061 vap->iv_key_set = (void *)run_key_set; in run_vap_create()
1064 rvp->newstate = vap->iv_newstate; in run_vap_create()
1065 vap->iv_newstate = run_newstate; in run_vap_create()
1067 rvp->recv_mgmt = vap->iv_recv_mgmt; in run_vap_create()
1068 vap->iv_recv_mgmt = run_recv_mgmt; in run_vap_create()
1080 if((sc->rvp_bmap & 1 << i) == 0){ in run_vap_create()
1081 sc->rvp_bmap |= 1 << i; in run_vap_create()
1082 rvp->rvp_id = i; in run_vap_create()
1086 if (sc->rvp_cnt++ == 0) in run_vap_create()
1087 ic->ic_opmode = opmode; in run_vap_create()
1090 sc->cmdq_run = RUN_CMDQ_GO; in run_vap_create()
1093 rvp->rvp_id, sc->rvp_bmap, sc->rvp_cnt); in run_vap_create()
1109 ic = vap->iv_ic; in run_vap_delete()
1110 sc = ic->ic_softc; in run_vap_delete()
1114 m_freem(rvp->beacon_mbuf); in run_vap_delete()
1115 rvp->beacon_mbuf = NULL; in run_vap_delete()
1117 rvp_id = rvp->rvp_id; in run_vap_delete()
1118 sc->ratectl_run &= ~(1 << rvp_id); in run_vap_delete()
1119 sc->rvp_bmap &= ~(1 << rvp_id); in run_vap_delete()
1122 --sc->rvp_cnt; in run_vap_delete()
1126 vap, rvp_id, sc->rvp_bmap, sc->rvp_cnt); in run_vap_delete()
1138 * here is all-for-one taskqueue callback function. This function
1151 for (i = sc->cmdq_exec; sc->cmdq[i].func && pending; in run_cmdq_cb()
1152 i = sc->cmdq_exec, pending--) { in run_cmdq_cb()
1155 if (sc->cmdq_run == RUN_CMDQ_GO) { in run_cmdq_cb()
1160 if (sc->cmdq[i].arg0) in run_cmdq_cb()
1161 sc->cmdq[i].func(sc->cmdq[i].arg0); in run_cmdq_cb()
1163 sc->cmdq[i].func(&sc->cmdq[i]); in run_cmdq_cb()
1165 sc->cmdq[i].arg0 = NULL; in run_cmdq_cb()
1166 sc->cmdq[i].func = NULL; in run_cmdq_cb()
1167 sc->cmdq_exec++; in run_cmdq_cb()
1168 sc->cmdq_exec &= RUN_CMDQ_MASQ; in run_cmdq_cb()
1180 STAILQ_INIT(&pq->tx_qh); in run_setup_tx_list()
1181 STAILQ_INIT(&pq->tx_fh); in run_setup_tx_list()
1183 for (data = &pq->tx_data[0]; in run_setup_tx_list()
1184 data < &pq->tx_data[RUN_TX_RING_COUNT]; data++) { in run_setup_tx_list()
1185 data->sc = sc; in run_setup_tx_list()
1186 STAILQ_INSERT_TAIL(&pq->tx_fh, data, next); in run_setup_tx_list()
1188 pq->tx_nfree = RUN_TX_RING_COUNT; in run_setup_tx_list()
1197 pq->tx_nfree = 0; in run_unsetup_tx_list()
1198 STAILQ_INIT(&pq->tx_fh); in run_unsetup_tx_list()
1199 STAILQ_INIT(&pq->tx_qh); in run_unsetup_tx_list()
1202 for (data = &pq->tx_data[0]; in run_unsetup_tx_list()
1203 data < &pq->tx_data[RUN_TX_RING_COUNT]; data++) { in run_unsetup_tx_list()
1204 if (data->m != NULL) { in run_unsetup_tx_list()
1205 m_freem(data->m); in run_unsetup_tx_list()
1206 data->m = NULL; in run_unsetup_tx_list()
1208 if (data->ni != NULL) { in run_unsetup_tx_list()
1209 ieee80211_free_node(data->ni); in run_unsetup_tx_list()
1210 data->ni = NULL; in run_unsetup_tx_list()
1230 device_printf(sc->sc_dev, in run_load_microcode()
1235 if (fw->datasize != 8192) { in run_load_microcode()
1236 device_printf(sc->sc_dev, in run_load_microcode()
1244 * run-rt2870 (8KB) contains both, in run_load_microcode()
1248 base = fw->data; in run_load_microcode()
1249 if ((sc->mac_ver) != 0x2860 && in run_load_microcode()
1250 (sc->mac_ver) != 0x2872 && in run_load_microcode()
1251 (sc->mac_ver) != 0x3070) { in run_load_microcode()
1256 temp = fw->data; in run_load_microcode()
1259 device_printf(sc->sc_dev, "firmware checksum failed\n"); in run_load_microcode()
1265 if (sc->sc_flags & RUN_FLAG_FWLOAD_NEEDED) { in run_load_microcode()
1276 if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) in run_load_microcode()
1278 device_printf(sc->sc_dev, "firmware reset failed\n"); in run_load_microcode()
1299 device_printf(sc->sc_dev, in run_load_microcode()
1304 device_printf(sc->sc_dev, "firmware %s ver. %u.%u loaded\n", in run_load_microcode()
1305 (base == fw->data) ? "RT2870" : "RT3071", in run_load_microcode()
1323 return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)); in run_reset()
1335 while (ntries--) { in run_do_request()
1336 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in run_do_request()
1421 * firmware. Limit amount of data passed to 64-bytes at a in run_write_region_1()
1439 len -= delta; in run_write_region_1()
1468 /*- in run_efuse_read()
1469 * Read one 16-byte block into registers EFUSE_DATA[0-3]: in run_efuse_read()
1492 /* determine to which 32-bit register our 16-bit word belongs */ in run_efuse_read()
1493 reg = RT3070_EFUSE_DATA3 - (addr & 0xc); in run_efuse_read()
1503 /* Read 16-bit from eFUSE ROM for RT3xxx. */
1524 error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, &tmp); in run_eeprom_read_2()
1535 /* either eFUSE ROM or EEPROM */ in run_srom_read()
1536 return sc->sc_srom_read(sc, addr, val); in run_srom_read()
1684 * Add `delta' (signed) to each 4-bit sub-word of a 32-bit word.
1685 * Used to adjust per-rate Tx power registers.
1731 /* Read power settings for 2GHz channels. */ in run_rt3593_get_txpower()
1733 addr = (sc->ntxchains == 3) ? RT3593_EEPROM_PWR2GHZ_BASE1 : in run_rt3593_get_txpower()
1736 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1737 sc->txpow1[i + 1] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1739 addr = (sc->ntxchains == 3) ? RT3593_EEPROM_PWR2GHZ_BASE2 : in run_rt3593_get_txpower()
1742 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1743 sc->txpow2[i + 1] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1745 if (sc->ntxchains == 3) { in run_rt3593_get_txpower()
1748 sc->txpow3[i + 0] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1749 sc->txpow3[i + 1] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1754 if (sc->txpow1[i] > 31) in run_rt3593_get_txpower()
1755 sc->txpow1[i] = 5; in run_rt3593_get_txpower()
1756 if (sc->txpow2[i] > 31) in run_rt3593_get_txpower()
1757 sc->txpow2[i] = 5; in run_rt3593_get_txpower()
1758 if (sc->ntxchains == 3) { in run_rt3593_get_txpower()
1759 if (sc->txpow3[i] > 31) in run_rt3593_get_txpower()
1760 sc->txpow3[i] = 5; in run_rt3593_get_txpower()
1763 /* Read power settings for 5GHz channels. */ in run_rt3593_get_txpower()
1766 sc->txpow1[i + 14] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1767 sc->txpow1[i + 15] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1770 sc->txpow2[i + 14] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1771 sc->txpow2[i + 15] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1773 if (sc->ntxchains == 3) { in run_rt3593_get_txpower()
1776 sc->txpow3[i + 14] = (int8_t)(val & 0xff); in run_rt3593_get_txpower()
1777 sc->txpow3[i + 15] = (int8_t)(val >> 8); in run_rt3593_get_txpower()
1788 /* Read power settings for 2GHz channels. */ in run_get_txpower()
1791 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in run_get_txpower()
1792 sc->txpow1[i + 1] = (int8_t)(val >> 8); in run_get_txpower()
1794 if (sc->mac_ver != 0x5390) { in run_get_txpower()
1797 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in run_get_txpower()
1798 sc->txpow2[i + 1] = (int8_t)(val >> 8); in run_get_txpower()
1803 if (sc->mac_ver >= 0x5390) { in run_get_txpower()
1804 if (sc->txpow1[i] < 0 || sc->txpow1[i] > 39) in run_get_txpower()
1805 sc->txpow1[i] = 5; in run_get_txpower()
1807 if (sc->txpow1[i] < 0 || sc->txpow1[i] > 31) in run_get_txpower()
1808 sc->txpow1[i] = 5; in run_get_txpower()
1810 if (sc->mac_ver > 0x5390) { in run_get_txpower()
1811 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 39) in run_get_txpower()
1812 sc->txpow2[i] = 5; in run_get_txpower()
1813 } else if (sc->mac_ver < 0x5390) { in run_get_txpower()
1814 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31) in run_get_txpower()
1815 sc->txpow2[i] = 5; in run_get_txpower()
1819 rt2860_rf2850[i].chan, sc->txpow1[i], sc->txpow2[i]); in run_get_txpower()
1821 /* Read power settings for 5GHz channels. */ in run_get_txpower()
1824 sc->txpow1[i + 14] = (int8_t)(val & 0xff); in run_get_txpower()
1825 sc->txpow1[i + 15] = (int8_t)(val >> 8); in run_get_txpower()
1828 sc->txpow2[i + 14] = (int8_t)(val & 0xff); in run_get_txpower()
1829 sc->txpow2[i + 15] = (int8_t)(val >> 8); in run_get_txpower()
1833 if (sc->mac_ver != 0x5592) { in run_get_txpower()
1834 if (sc->txpow1[14 + i] < -7 || sc->txpow1[14 + i] > 15) in run_get_txpower()
1835 sc->txpow1[14 + i] = 5; in run_get_txpower()
1836 if (sc->txpow2[14 + i] < -7 || sc->txpow2[14 + i] > 15) in run_get_txpower()
1837 sc->txpow2[14 + i] = 5; in run_get_txpower()
1841 rt2860_rf2850[14 + i].chan, sc->txpow1[14 + i], in run_get_txpower()
1842 sc->txpow2[14 + i]); in run_get_txpower()
1849 struct ieee80211com *ic = &sc->sc_ic; in run_read_eeprom()
1855 /* check whether the ROM is eFUSE ROM or EEPROM */ in run_read_eeprom()
1856 sc->sc_srom_read = run_eeprom_read_2; in run_read_eeprom()
1857 if (sc->mac_ver >= 0x3070) { in run_read_eeprom()
1860 if ((tmp & RT3070_SEL_EFUSE) || sc->mac_ver == 0x3593) in run_read_eeprom()
1861 sc->sc_srom_read = run_efuse_read_2; in run_read_eeprom()
1871 ic->ic_macaddr[0] = val & 0xff; in run_read_eeprom()
1872 ic->ic_macaddr[1] = val >> 8; in run_read_eeprom()
1874 ic->ic_macaddr[2] = val & 0xff; in run_read_eeprom()
1875 ic->ic_macaddr[3] = val >> 8; in run_read_eeprom()
1877 ic->ic_macaddr[4] = val & 0xff; in run_read_eeprom()
1878 ic->ic_macaddr[5] = val >> 8; in run_read_eeprom()
1880 if (sc->mac_ver < 0x3593) { in run_read_eeprom()
1881 /* read vender BBP settings */ in run_read_eeprom()
1884 sc->bbp[i].val = val & 0xff; in run_read_eeprom()
1885 sc->bbp[i].reg = val >> 8; in run_read_eeprom()
1887 "BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val); in run_read_eeprom()
1889 if (sc->mac_ver >= 0x3071) { in run_read_eeprom()
1890 /* read vendor RF settings */ in run_read_eeprom()
1894 sc->rf[i].val = val & 0xff; in run_read_eeprom()
1895 sc->rf[i].reg = val >> 8; in run_read_eeprom()
1897 sc->rf[i].reg, sc->rf[i].val); in run_read_eeprom()
1903 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : in run_read_eeprom()
1905 sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0; in run_read_eeprom()
1907 sc->freq & 0xff); in run_read_eeprom()
1909 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_FREQ_LEDS : in run_read_eeprom()
1913 sc->leds = val >> 8; in run_read_eeprom()
1914 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED1 : in run_read_eeprom()
1915 RT3593_EEPROM_LED1, &sc->led[0]); in run_read_eeprom()
1916 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED2 : in run_read_eeprom()
1917 RT3593_EEPROM_LED2, &sc->led[1]); in run_read_eeprom()
1918 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LED3 : in run_read_eeprom()
1919 RT3593_EEPROM_LED3, &sc->led[2]); in run_read_eeprom()
1921 /* broken EEPROM, use default settings */ in run_read_eeprom()
1922 sc->leds = 0x01; in run_read_eeprom()
1923 sc->led[0] = 0x5555; in run_read_eeprom()
1924 sc->led[1] = 0x2221; in run_read_eeprom()
1925 sc->led[2] = 0x5627; /* differs from RT2860 */ in run_read_eeprom()
1929 sc->leds, sc->led[0], sc->led[1], sc->led[2]); in run_read_eeprom()
1932 if (sc->mac_ver == 0x5390 || sc->mac_ver ==0x5392) in run_read_eeprom()
1938 device_printf(sc->sc_dev, in run_read_eeprom()
1940 if (sc->mac_ver == 0x3572) { in run_read_eeprom()
1942 sc->rf_rev = RT3070_RF_3052; in run_read_eeprom()
1943 sc->ntxchains = 2; in run_read_eeprom()
1944 sc->nrxchains = 2; in run_read_eeprom()
1945 } else if (sc->mac_ver >= 0x3070) { in run_read_eeprom()
1947 sc->rf_rev = RT3070_RF_3020; in run_read_eeprom()
1948 sc->ntxchains = 1; in run_read_eeprom()
1949 sc->nrxchains = 1; in run_read_eeprom()
1952 sc->rf_rev = RT2860_RF_2820; in run_read_eeprom()
1953 sc->ntxchains = 1; in run_read_eeprom()
1954 sc->nrxchains = 2; in run_read_eeprom()
1957 if (sc->mac_ver == 0x5390 || sc->mac_ver ==0x5392) { in run_read_eeprom()
1958 sc->rf_rev = val; in run_read_eeprom()
1961 sc->rf_rev = (val >> 8) & 0xf; in run_read_eeprom()
1962 sc->ntxchains = (val >> 4) & 0xf; in run_read_eeprom()
1963 sc->nrxchains = val & 0xf; in run_read_eeprom()
1966 sc->rf_rev, sc->ntxchains, sc->nrxchains); in run_read_eeprom()
1973 sc->patch_dac = (val >> 15) & 1; in run_read_eeprom()
1975 sc->ext_5ghz_lna = (val >> 3) & 1; in run_read_eeprom()
1976 sc->ext_2ghz_lna = (val >> 2) & 1; in run_read_eeprom()
1978 sc->calib_2ghz = sc->calib_5ghz = (val >> 1) & 1; in run_read_eeprom()
1980 sc->rfswitch = val & 1; in run_read_eeprom()
1983 /* Read Tx power settings. */ in run_read_eeprom()
1984 if (sc->mac_ver == 0x3593) in run_read_eeprom()
1995 delta_2ghz = -delta_2ghz; in run_read_eeprom()
2001 delta_5ghz = -delta_5ghz; in run_read_eeprom()
2014 sc->txpow20mhz[ridx] = reg; in run_read_eeprom()
2015 sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); in run_read_eeprom()
2016 sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); in run_read_eeprom()
2020 "40MHz/5GHz=0x%08x\n", ridx, sc->txpow20mhz[ridx], in run_read_eeprom()
2021 sc->txpow40mhz_2ghz[ridx], sc->txpow40mhz_5ghz[ridx]); in run_read_eeprom()
2025 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI1_2GHZ : in run_read_eeprom()
2027 sc->rssi_2ghz[0] = val & 0xff; /* Ant A */ in run_read_eeprom()
2028 sc->rssi_2ghz[1] = val >> 8; /* Ant B */ in run_read_eeprom()
2029 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI2_2GHZ : in run_read_eeprom()
2031 if (sc->mac_ver >= 0x3070) { in run_read_eeprom()
2032 if (sc->mac_ver == 0x3593) { in run_read_eeprom()
2033 sc->txmixgain_2ghz = 0; in run_read_eeprom()
2034 sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ in run_read_eeprom()
2041 sc->txmixgain_2ghz = val & 0x7; in run_read_eeprom()
2044 sc->txmixgain_2ghz); in run_read_eeprom()
2046 sc->rssi_2ghz[2] = val & 0xff; /* Ant C */ in run_read_eeprom()
2047 if (sc->mac_ver == 0x3593) in run_read_eeprom()
2049 sc->lna[2] = val >> 8; /* channel group 2 */ in run_read_eeprom()
2051 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI1_5GHZ : in run_read_eeprom()
2053 sc->rssi_5ghz[0] = val & 0xff; /* Ant A */ in run_read_eeprom()
2054 sc->rssi_5ghz[1] = val >> 8; /* Ant B */ in run_read_eeprom()
2055 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_RSSI2_5GHZ : in run_read_eeprom()
2057 if (sc->mac_ver == 0x3572) { in run_read_eeprom()
2063 sc->txmixgain_5ghz = val & 0x7; in run_read_eeprom()
2065 sc->txmixgain_5ghz); in run_read_eeprom()
2067 sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ in run_read_eeprom()
2068 if (sc->mac_ver == 0x3593) { in run_read_eeprom()
2069 sc->txmixgain_5ghz = 0; in run_read_eeprom()
2072 sc->lna[3] = val >> 8; /* channel group 3 */ in run_read_eeprom()
2074 run_srom_read(sc, (sc->mac_ver != 0x3593) ? RT2860_EEPROM_LNA : in run_read_eeprom()
2076 sc->lna[0] = val & 0xff; /* channel group 0 */ in run_read_eeprom()
2077 sc->lna[1] = val >> 8; /* channel group 1 */ in run_read_eeprom()
2080 if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { in run_read_eeprom()
2083 sc->lna[2] = sc->lna[1]; in run_read_eeprom()
2085 if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { in run_read_eeprom()
2088 sc->lna[3] = sc->lna[1]; in run_read_eeprom()
2093 if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { in run_read_eeprom()
2096 ant + 1, sc->rssi_2ghz[ant]); in run_read_eeprom()
2097 sc->rssi_2ghz[ant] = 0; in run_read_eeprom()
2099 if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { in run_read_eeprom()
2102 ant + 1, sc->rssi_5ghz[ant]); in run_read_eeprom()
2103 sc->rssi_5ghz[ant] = 0; in run_read_eeprom()
2120 struct ieee80211com *ic = vap->iv_ic; in run_media_change()
2122 struct run_softc *sc = ic->ic_softc; in run_media_change()
2134 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; in run_media_change()
2135 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { in run_media_change()
2140 rate = ic->ic_sup_rates[ic->ic_curmode]. in run_media_change()
2141 rs_rates[tp->ucastrate] & IEEE80211_RATE_VAL; in run_media_change()
2146 ni = ieee80211_ref_node(vap->iv_bss); in run_media_change()
2148 rn->fix_ridx = ridx; in run_media_change()
2150 rate, rn->fix_ridx); in run_media_change()
2170 struct ieee80211com *ic = vap->iv_ic; in run_newstate()
2171 struct run_softc *sc = ic->ic_softc; in run_newstate()
2177 uint8_t bid = 1 << rvp->rvp_id; in run_newstate()
2179 ostate = vap->iv_state; in run_newstate()
2180 RUN_DPRINTF(sc, RUN_DEBUG_STATE, "%s -> %s\n", in run_newstate()
2187 ratectl = sc->ratectl_run; /* remember current state */ in run_newstate()
2188 sc->ratectl_run = RUN_RATECTL_OFF; in run_newstate()
2189 usb_callout_stop(&sc->ratectl_ch); in run_newstate()
2204 sc->runbmap &= ~bid; in run_newstate()
2207 if (--sc->running == 0) in run_newstate()
2212 if (!(sc->runbmap & bid)) { in run_newstate()
2213 if(sc->running++) in run_newstate()
2215 sc->runbmap |= bid; in run_newstate()
2218 m_freem(rvp->beacon_mbuf); in run_newstate()
2219 rvp->beacon_mbuf = NULL; in run_newstate()
2221 switch (vap->iv_opmode) { in run_newstate()
2224 sc->ap_running |= bid; in run_newstate()
2225 ic->ic_opmode = vap->iv_opmode; in run_newstate()
2229 sc->adhoc_running |= bid; in run_newstate()
2230 if (!sc->ap_running) in run_newstate()
2231 ic->ic_opmode = vap->iv_opmode; in run_newstate()
2235 sc->sta_running |= bid; in run_newstate()
2236 if (!sc->ap_running && !sc->adhoc_running) in run_newstate()
2237 ic->ic_opmode = vap->iv_opmode; in run_newstate()
2245 ic->ic_opmode = vap->iv_opmode; in run_newstate()
2249 if (vap->iv_opmode != IEEE80211_M_MONITOR) { in run_newstate()
2252 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { in run_newstate()
2255 return (-1); in run_newstate()
2261 ni = ieee80211_ref_node(vap->iv_bss); in run_newstate()
2262 IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid); in run_newstate()
2263 run_set_bssid(sc, sc->sc_bssid); in run_newstate()
2268 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; in run_newstate()
2269 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) in run_newstate()
2276 (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan) ? in run_newstate()
2286 if ((sc->ratectl_run = ratectl) && restart_ratectl) in run_newstate()
2287 usb_callout_reset(&sc->ratectl_ch, hz, run_ratectl_to, sc); in run_newstate()
2292 return(rvp->newstate(vap, nstate, arg)); in run_newstate()
2299 struct run_softc *sc = ic->ic_softc; in run_wme_update()
2356 struct ieee80211vap *vap = cmdq->arg1; in run_key_set_cb()
2357 struct ieee80211_key *k = cmdq->k; in run_key_set_cb()
2358 struct ieee80211com *ic = vap->iv_ic; in run_key_set_cb()
2359 struct run_softc *sc = ic->ic_softc; in run_key_set_cb()
2361 u_int cipher = k->wk_cipher->ic_cipher; in run_key_set_cb()
2368 if (vap->iv_opmode == IEEE80211_M_HOSTAP) in run_key_set_cb()
2369 ni = ieee80211_find_vap_node(&ic->ic_sta, vap, cmdq->mac); in run_key_set_cb()
2371 ni = vap->iv_bss; in run_key_set_cb()
2372 associd = (ni != NULL) ? ni->ni_associd : 0; in run_key_set_cb()
2377 if(k->wk_keylen < 8) in run_key_set_cb()
2395 associd, k->wk_keyix, mode, in run_key_set_cb()
2396 (k->wk_flags & IEEE80211_KEY_GROUP) ? "group" : "pairwise", in run_key_set_cb()
2397 (k->wk_flags & IEEE80211_KEY_XMIT) ? "on" : "off", in run_key_set_cb()
2398 (k->wk_flags & IEEE80211_KEY_RECV) ? "on" : "off"); in run_key_set_cb()
2400 if (k->wk_flags & IEEE80211_KEY_GROUP) { in run_key_set_cb()
2402 base = RT2860_SKEY(RUN_VAP(vap)->rvp_id, k->wk_keyix); in run_key_set_cb()
2404 wcid = (vap->iv_opmode == IEEE80211_M_STA) ? in run_key_set_cb()
2410 if(run_write_region_1(sc, base, k->wk_key, 16)) in run_key_set_cb()
2412 if(run_write_region_1(sc, base + 16, &k->wk_key[16], 8)) /* wk_txmic */ in run_key_set_cb()
2414 if(run_write_region_1(sc, base + 24, &k->wk_key[24], 8)) /* wk_rxmic */ in run_key_set_cb()
2417 /* roundup len to 16-bit: XXX fix write_region_1() instead */ in run_key_set_cb()
2418 if(run_write_region_1(sc, base, k->wk_key, (k->wk_keylen + 1) & ~1)) in run_key_set_cb()
2422 if (!(k->wk_flags & IEEE80211_KEY_GROUP) || in run_key_set_cb()
2423 (k->wk_flags & (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV))) { in run_key_set_cb()
2427 iv[3] = vap->iv_def_txkey << 6; in run_key_set_cb()
2430 iv[0] = k->wk_keytsc >> 8; in run_key_set_cb()
2432 iv[2] = k->wk_keytsc; in run_key_set_cb()
2434 iv[0] = k->wk_keytsc; in run_key_set_cb()
2435 iv[1] = k->wk_keytsc >> 8; in run_key_set_cb()
2438 iv[3] = k->wk_keyix << 6 | IEEE80211_WEP_EXTIV; in run_key_set_cb()
2439 iv[4] = k->wk_keytsc >> 16; in run_key_set_cb()
2440 iv[5] = k->wk_keytsc >> 24; in run_key_set_cb()
2441 iv[6] = k->wk_keytsc >> 32; in run_key_set_cb()
2442 iv[7] = k->wk_keytsc >> 40; in run_key_set_cb()
2448 if (k->wk_flags & IEEE80211_KEY_GROUP) { in run_key_set_cb()
2452 attr &= ~(0xf << (k->wk_keyix * 4)); in run_key_set_cb()
2453 attr |= mode << (k->wk_keyix * 4); in run_key_set_cb()
2465 /* TODO create a pass-thru key entry? */ in run_key_set_cb()
2468 k->wk_pad = wcid; in run_key_set_cb()
2481 struct ieee80211com *ic = vap->iv_ic; in run_key_set()
2482 struct run_softc *sc = ic->ic_softc; in run_key_set()
2485 i = RUN_CMDQ_GET(&sc->cmdq_store); in run_key_set()
2487 sc->cmdq[i].func = run_key_set_cb; in run_key_set()
2488 sc->cmdq[i].arg0 = NULL; in run_key_set()
2489 sc->cmdq[i].arg1 = vap; in run_key_set()
2490 sc->cmdq[i].k = k; in run_key_set()
2491 IEEE80211_ADDR_COPY(sc->cmdq[i].mac, k->wk_macaddr); in run_key_set()
2492 ieee80211_runtask(ic, &sc->cmdq_task); in run_key_set()
2498 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { in run_key_set()
2500 sc->cmdq_key_set = RUN_CMDQ_GO; in run_key_set()
2516 struct run_softc *sc = cmdq->arg1; in run_key_delete_cb()
2517 struct ieee80211_key *k = &cmdq->key; in run_key_delete_cb()
2523 if (k->wk_flags & IEEE80211_KEY_GROUP) { in run_key_delete_cb()
2527 attr &= ~(0xf << (k->wk_keyix * 4)); in run_key_delete_cb()
2532 "removing key for wcid %x\n", k->wk_pad); in run_key_delete_cb()
2534 wcid = k->wk_pad; in run_key_delete_cb()
2541 k->wk_pad = 0; in run_key_delete_cb()
2550 struct ieee80211com *ic = vap->iv_ic; in run_key_delete()
2551 struct run_softc *sc = ic->ic_softc; in run_key_delete()
2561 i = RUN_CMDQ_GET(&sc->cmdq_store); in run_key_delete()
2563 sc->cmdq[i].func = run_key_delete_cb; in run_key_delete()
2564 sc->cmdq[i].arg0 = NULL; in run_key_delete()
2565 sc->cmdq[i].arg1 = sc; in run_key_delete()
2566 k0 = &sc->cmdq[i].key; in run_key_delete()
2567 k0->wk_flags = k->wk_flags; in run_key_delete()
2568 k0->wk_keyix = k->wk_keyix; in run_key_delete()
2570 k0->wk_pad = k->wk_pad; in run_key_delete()
2571 ieee80211_runtask(ic, &sc->cmdq_task); in run_key_delete()
2582 ieee80211_runtask(&sc->sc_ic, &sc->ratectl_task); in run_ratectl_to()
2591 struct ieee80211com *ic = &sc->sc_ic; in run_ratectl_cb()
2592 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in run_ratectl_cb()
2597 if (sc->rvp_cnt > 1 || vap->iv_opmode != IEEE80211_M_STA) { in run_ratectl_cb()
2612 ieee80211_iterate_nodes(&ic->ic_sta, run_iter_func, sc); in run_ratectl_cb()
2615 if(sc->ratectl_run != RUN_RATECTL_OFF) in run_ratectl_cb()
2616 usb_callout_reset(&sc->ratectl_ch, hz, run_ratectl_to, sc); in run_ratectl_cb()
2646 * Even though each stat is Tx-complete-status like format, in run_drain_fifo()
2655 wstat = &(sc->wcid_stats[wcid]); in run_drain_fifo()
2660 counter_u64_add(sc->sc_ic.ic_oerrors, 1); in run_drain_fifo()
2668 if ((retry = pid -1 - mcs) > 0) { in run_drain_fifo()
2673 RUN_DPRINTF(sc, RUN_DEBUG_XMIT, "count=%d\n", sc->fifo_cnt); in run_drain_fifo()
2675 sc->fifo_cnt = 0; in run_drain_fifo()
2682 struct ieee80211_ratectl_tx_stats *txs = &sc->sc_txs; in run_iter_func()
2683 struct ieee80211vap *vap = ni->ni_vap; in run_iter_func()
2692 if (sc->rvp_cnt <= 1 && vap->iv_opmode == IEEE80211_M_STA && in run_iter_func()
2693 ni != vap->iv_bss) in run_iter_func()
2696 txs->flags = IEEE80211_RATECTL_TX_STATS_NODE | in run_iter_func()
2698 txs->ni = ni; in run_iter_func()
2699 if (sc->rvp_cnt <= 1 && (vap->iv_opmode == IEEE80211_M_IBSS || in run_iter_func()
2700 vap->iv_opmode == IEEE80211_M_STA)) { in run_iter_func()
2708 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, in run_iter_func()
2711 txs->nretries = le16toh(sta[1].tx.retry); in run_iter_func()
2712 txs->nsuccess = le16toh(sta[1].tx.success); in run_iter_func()
2714 txs->nframes = txs->nretries + txs->nsuccess + in run_iter_func()
2719 txs->nretries, txs->nsuccess, le16toh(sta[0].error.fail)); in run_iter_func()
2721 wstat = &(sc->wcid_stats[RUN_AID2WCID(ni->ni_associd)]); in run_iter_func()
2723 if (wstat == &(sc->wcid_stats[0]) || in run_iter_func()
2724 wstat > &(sc->wcid_stats[RT2870_WCID_MAX])) in run_iter_func()
2727 txs->nretries = (*wstat)[RUN_RETRY]; in run_iter_func()
2728 txs->nsuccess = (*wstat)[RUN_SUCCESS]; in run_iter_func()
2729 txs->nframes = (*wstat)[RUN_TXCNT]; in run_iter_func()
2732 txs->nretries, txs->nframes, txs->nsuccess); in run_iter_func()
2741 if (rt2860_rates[ridx].rate == ni->ni_txrate) in run_iter_func()
2743 rn->amrr_ridx = ridx; in run_iter_func()
2748 RUN_DPRINTF(sc, RUN_DEBUG_RATE, "rate=%d, ridx=%d\n", ni->ni_txrate, rn->amrr_ridx); in run_iter_func()
2755 struct ieee80211_node *ni = cmdq->arg1; in run_newassoc_cb()
2756 struct run_softc *sc = ni->ni_vap->iv_ic->ic_softc; in run_newassoc_cb()
2757 uint8_t wcid = cmdq->wcid; in run_newassoc_cb()
2762 ni->ni_macaddr, IEEE80211_ADDR_LEN); in run_newassoc_cb()
2764 memset(&(sc->wcid_stats[wcid]), 0, sizeof(sc->wcid_stats[wcid])); in run_newassoc_cb()
2771 struct ieee80211vap *vap = ni->ni_vap; in run_newassoc()
2772 struct ieee80211com *ic = vap->iv_ic; in run_newassoc()
2773 struct run_softc *sc = ic->ic_softc; in run_newassoc()
2778 wcid = (vap->iv_opmode == IEEE80211_M_STA) ? in run_newassoc()
2779 1 : RUN_AID2WCID(ni->ni_associd); in run_newassoc()
2782 device_printf(sc->sc_dev, "wcid=%d out of range\n", wcid); in run_newassoc()
2787 if (isnew && ni->ni_associd != 0) { in run_newassoc()
2792 uint32_t cnt = RUN_CMDQ_GET(&sc->cmdq_store); in run_newassoc()
2794 sc->cmdq[cnt].func = run_newassoc_cb; in run_newassoc()
2795 sc->cmdq[cnt].arg0 = NULL; in run_newassoc()
2796 sc->cmdq[cnt].arg1 = ni; in run_newassoc()
2797 sc->cmdq[cnt].wcid = wcid; in run_newassoc()
2798 ieee80211_runtask(ic, &sc->cmdq_task); in run_newassoc()
2803 isnew, ni->ni_associd, ether_sprintf(ni->ni_macaddr)); in run_newassoc()
2805 rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate; in run_newassoc()
2810 rn->mgt_ridx = ridx; in run_newassoc()
2812 "rate=%d, mgmt_ridx=%d\n", rate, rn->mgt_ridx); in run_newassoc()
2815 if(sc->ratectl_run != RUN_RATECTL_OFF) in run_newassoc()
2816 usb_callout_reset(&sc->ratectl_ch, hz, run_ratectl_to, sc); in run_newassoc()
2828 if (sc->nrxchains > 1) { in run_maxrssi_chain()
2829 if (rxwi->rssi[1] > rxwi->rssi[rxchain]) in run_maxrssi_chain()
2831 if (sc->nrxchains > 2) in run_maxrssi_chain()
2832 if (rxwi->rssi[2] > rxwi->rssi[rxchain]) in run_maxrssi_chain()
2842 struct ieee80211vap *vap = ni->ni_vap; in run_recv_mgmt()
2843 struct run_softc *sc = vap->iv_ic->ic_softc; in run_recv_mgmt()
2847 rvp->recv_mgmt(ni, m, subtype, rxs, rssi, nf); in run_recv_mgmt()
2849 if (vap->iv_state == IEEE80211_S_RUN && in run_recv_mgmt()
2852 ni_tstamp = le64toh(ni->ni_tstamp.tsf); in run_recv_mgmt()
2870 struct ieee80211com *ic = &sc->sc_ic; in run_rx_frame()
2881 if (sc->mac_ver == 0x5592) in run_rx_frame()
2883 else if (sc->mac_ver == 0x3593) in run_rx_frame()
2895 len = le16toh(rxwi->len) & 0xfff; in run_rx_frame()
2897 if (__predict_false(len > dmalen - rxwisize)) { in run_rx_frame()
2905 flags = le32toh(rxd->flags); in run_rx_frame()
2919 m->m_data += rxwisize; in run_rx_frame()
2920 m->m_pkthdr.len = m->m_len = len; in run_rx_frame()
2924 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) != 0 && in run_rx_frame()
2926 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in run_rx_frame()
2927 m->m_flags |= M_WEP; in run_rx_frame()
2936 if(ni && ni->ni_flags & IEEE80211_NODE_HT) { in run_rx_frame()
2937 m->m_flags |= M_AMPDU; in run_rx_frame()
2943 ieee80211_notify_michael_failure(ni->ni_vap, wh, in run_rx_frame()
2944 rxwi->keyidx); in run_rx_frame()
2951 rssi = rxwi->rssi[ant]; in run_rx_frame()
2955 struct run_rx_radiotap_header *tap = &sc->sc_rxtap; in run_rx_frame()
2958 tap->wr_flags = 0; in run_rx_frame()
2960 tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; in run_rx_frame()
2961 tap->wr_antsignal = rssi; in run_rx_frame()
2962 tap->wr_antenna = ant; in run_rx_frame()
2963 tap->wr_dbm_antsignal = run_rssi2dbm(sc, rssi, ant); in run_rx_frame()
2964 tap->wr_rate = 2; /* in case it can't be found below */ in run_rx_frame()
2966 run_get_tsf(sc, &tap->wr_tsf); in run_rx_frame()
2968 phy = le16toh(rxwi->phy); in run_rx_frame()
2972 case 0: tap->wr_rate = 2; break; in run_rx_frame()
2973 case 1: tap->wr_rate = 4; break; in run_rx_frame()
2974 case 2: tap->wr_rate = 11; break; in run_rx_frame()
2975 case 3: tap->wr_rate = 22; break; in run_rx_frame()
2978 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in run_rx_frame()
2982 case 0: tap->wr_rate = 12; break; in run_rx_frame()
2983 case 1: tap->wr_rate = 18; break; in run_rx_frame()
2984 case 2: tap->wr_rate = 24; break; in run_rx_frame()
2985 case 3: tap->wr_rate = 36; break; in run_rx_frame()
2986 case 4: tap->wr_rate = 48; break; in run_rx_frame()
2987 case 5: tap->wr_rate = 72; break; in run_rx_frame()
2988 case 6: tap->wr_rate = 96; break; in run_rx_frame()
2989 case 7: tap->wr_rate = 108; break; in run_rx_frame()
3006 counter_u64_add(ic->ic_ierrors, 1); in run_rx_frame()
3013 struct ieee80211com *ic = &sc->sc_ic; in run_bulk_rx_callback()
3021 if (sc->mac_ver == 0x5592) in run_bulk_rx_callback()
3023 else if (sc->mac_ver == 0x3593) in run_bulk_rx_callback()
3041 m = sc->rx_m; in run_bulk_rx_callback()
3042 sc->rx_m = NULL; in run_bulk_rx_callback()
3047 if (sc->rx_m == NULL) { in run_bulk_rx_callback()
3048 sc->rx_m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, in run_bulk_rx_callback()
3051 if (sc->rx_m == NULL) { in run_bulk_rx_callback()
3054 "could not allocate mbuf - idle with stall\n"); in run_bulk_rx_callback()
3055 counter_u64_add(ic->ic_ierrors, 1); in run_bulk_rx_callback()
3065 mtod(sc->rx_m, caddr_t), RUN_MAX_RXSZ); in run_bulk_rx_callback()
3076 device_printf(sc->sc_dev, "device timeout\n"); in run_bulk_rx_callback()
3077 counter_u64_add(ic->ic_ierrors, 1); in run_bulk_rx_callback()
3080 if (sc->rx_m != NULL) { in run_bulk_rx_callback()
3081 m_freem(sc->rx_m); in run_bulk_rx_callback()
3082 sc->rx_m = NULL; in run_bulk_rx_callback()
3094 m->m_pkthdr.len = m->m_len = xferlen; in run_bulk_rx_callback()
3100 if ((dmalen >= (uint32_t)-8) || (dmalen == 0) || in run_bulk_rx_callback()
3114 if ((xferlen -= dmalen + 8) <= 8) { in run_bulk_rx_callback()
3115 /* trim 32-bit DMA-len header */ in run_bulk_rx_callback()
3116 m->m_data += 4; in run_bulk_rx_callback()
3117 m->m_pkthdr.len = m->m_len -= 4; in run_bulk_rx_callback()
3127 counter_u64_add(ic->ic_ierrors, 1); in run_bulk_rx_callback()
3136 counter_u64_add(ic->ic_ierrors, 1); in run_bulk_rx_callback()
3139 m_copydata(m, 4 /* skip 32-bit DMA-len header */, in run_bulk_rx_callback()
3141 m0->m_pkthdr.len = m0->m_len = mbuf_len; in run_bulk_rx_callback()
3145 m->m_data += mbuf_len + 4; in run_bulk_rx_callback()
3146 m->m_pkthdr.len = m->m_len -= mbuf_len + 4; in run_bulk_rx_callback()
3163 ieee80211_tx_complete(data->ni, data->m, txerr); in run_tx_free()
3165 data->m = NULL; in run_tx_free()
3166 data->ni = NULL; in run_tx_free()
3168 STAILQ_INSERT_TAIL(&pq->tx_fh, data, next); in run_tx_free()
3169 pq->tx_nfree++; in run_tx_free()
3176 struct ieee80211com *ic = &sc->sc_ic; in run_bulk_tx_callbackN()
3180 struct run_endpoint_queue *pq = &sc->sc_epq[index]; in run_bulk_tx_callbackN()
3200 data = STAILQ_FIRST(&pq->tx_qh); in run_bulk_tx_callbackN()
3204 STAILQ_REMOVE_HEAD(&pq->tx_qh, next); in run_bulk_tx_callbackN()
3206 m = data->m; in run_bulk_tx_callbackN()
3207 size = (sc->mac_ver == 0x5592) ? in run_bulk_tx_callbackN()
3208 sizeof(data->desc) + sizeof(uint32_t) : sizeof(data->desc); in run_bulk_tx_callbackN()
3209 if ((m->m_pkthdr.len + in run_bulk_tx_callbackN()
3212 "data overflow, %u bytes\n", m->m_pkthdr.len); in run_bulk_tx_callbackN()
3218 usbd_copy_in(pc, 0, &data->desc, size); in run_bulk_tx_callbackN()
3219 usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len); in run_bulk_tx_callbackN()
3220 size += m->m_pkthdr.len; in run_bulk_tx_callbackN()
3222 * Align end on a 4-byte boundary, pad 8 bytes (CRC + in run_bulk_tx_callbackN()
3223 * 4-byte padding), and be sure to zero those trailing in run_bulk_tx_callbackN()
3226 usbd_frame_zero(pc, size, ((-size) & 3) + 8); in run_bulk_tx_callbackN()
3227 size += ((-size) & 3) + 8; in run_bulk_tx_callbackN()
3229 vap = data->ni->ni_vap; in run_bulk_tx_callbackN()
3232 struct run_tx_radiotap_header *tap = &sc->sc_txtap; in run_bulk_tx_callbackN()
3234 (struct rt2860_txwi *)(&data->desc + sizeof(struct rt2870_txd)); in run_bulk_tx_callbackN()
3241 tap->wt_flags = 0; in run_bulk_tx_callbackN()
3242 tap->wt_rate = rt2860_rates[data->ridx].rate; in run_bulk_tx_callbackN()
3243 tap->wt_hwqueue = index; in run_bulk_tx_callbackN()
3244 if (le16toh(txwi->phy) & RT2860_PHY_SHPRE) in run_bulk_tx_callbackN()
3245 tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in run_bulk_tx_callbackN()
3247 tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; in run_bulk_tx_callbackN()
3254 m->m_pkthdr.len, size, index); in run_bulk_tx_callbackN()
3270 if(data->ni != NULL) in run_bulk_tx_callbackN()
3271 vap = data->ni->ni_vap; in run_bulk_tx_callbackN()
3277 vap = TAILQ_FIRST(&ic->ic_vaps); in run_bulk_tx_callbackN()
3281 device_printf(sc->sc_dev, "device timeout\n"); in run_bulk_tx_callbackN()
3282 uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); in run_bulk_tx_callbackN()
3285 sc->cmdq[i].func = run_usb_timeout_cb; in run_bulk_tx_callbackN()
3286 sc->cmdq[i].arg0 = vap; in run_bulk_tx_callbackN()
3287 ieee80211_runtask(ic, &sc->cmdq_task); in run_bulk_tx_callbackN()
3303 if (pq->tx_nfree >= RUN_TX_RING_COUNT) { in run_bulk_tx_callbackN()
3350 struct mbuf *m = data->m; in run_set_tx_desc()
3351 struct ieee80211com *ic = &sc->sc_ic; in run_set_tx_desc()
3352 struct ieee80211vap *vap = data->ni->ni_vap; in run_set_tx_desc()
3358 uint8_t ridx = data->ridx; in run_set_tx_desc()
3364 txwisize = (sc->mac_ver == 0x5592) ? in run_set_tx_desc()
3366 xferlen = txwisize + m->m_pkthdr.len; in run_set_tx_desc()
3368 /* roundup to 32-bit alignment */ in run_set_tx_desc()
3371 txd = (struct rt2870_txd *)&data->desc; in run_set_tx_desc()
3372 txd->len = htole16(xferlen); in run_set_tx_desc()
3378 * are nicely aligned to 32-bit. So, no L2 padding. in run_set_tx_desc()
3387 txwi->len = htole16(m->m_pkthdr.len - pad); in run_set_tx_desc()
3391 (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) in run_set_tx_desc()
3399 txwi->phy = htole16(mcs); in run_set_tx_desc()
3401 /* check if RTS/CTS or CTS-to-self protection is required */ in run_set_tx_desc()
3402 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && in run_set_tx_desc()
3403 ((m->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) || in run_set_tx_desc()
3404 ((ic->ic_flags & IEEE80211_F_USEPROT) && in run_set_tx_desc()
3406 ((ic->ic_htprotmode == IEEE80211_PROT_RTSCTS) && in run_set_tx_desc()
3408 txwi->txop |= RT2860_TX_TXOP_HT; in run_set_tx_desc()
3410 txwi->txop |= RT2860_TX_TXOP_BACKOFF; in run_set_tx_desc()
3412 if (vap->iv_opmode != IEEE80211_M_STA && !IEEE80211_QOS_HAS_SEQ(wh)) in run_set_tx_desc()
3413 txwi->xflags |= RT2860_TX_NSEQ; in run_set_tx_desc()
3420 struct ieee80211com *ic = &sc->sc_ic; in run_tx()
3421 struct ieee80211vap *vap = ni->ni_vap; in run_tx()
3423 const struct ieee80211_txparam *tp = ni->ni_txparms; in run_tx()
3443 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in run_tx()
3448 * Update 03-14-2009: some devices like the Planex GW-US300MiniS in run_tx()
3469 if (IEEE80211_IS_MULTICAST(wh->i_addr1) || in run_tx()
3470 type != IEEE80211_FC0_TYPE_DATA || m->m_flags & M_EAPOL) { in run_tx()
3472 ridx = (ic->ic_curmode == IEEE80211_MODE_11A || ic->ic_curmode == IEEE80211_MODE_11NA) ? in run_tx()
3476 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in run_tx()
3477 ridx = rn->fix_ridx; in run_tx()
3479 ridx = rn->amrr_ridx; in run_tx()
3483 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && in run_tx()
3487 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) in run_tx()
3491 USETW(wh->i_dur, dur); in run_tx()
3495 if (sc->sc_epq[qid].tx_nfree < 3) { in run_tx()
3497 return (-1); in run_tx()
3500 data = STAILQ_FIRST(&sc->sc_epq[qid].tx_fh); in run_tx()
3501 STAILQ_REMOVE_HEAD(&sc->sc_epq[qid].tx_fh, next); in run_tx()
3502 sc->sc_epq[qid].tx_nfree--; in run_tx()
3504 txd = (struct rt2870_txd *)&data->desc; in run_tx()
3505 txd->flags = qflags; in run_tx()
3507 txwi->xflags = xflags; in run_tx()
3508 if (IEEE80211_IS_MULTICAST(wh->i_addr1)) in run_tx()
3509 txwi->wcid = 0; in run_tx()
3511 txwi->wcid = (vap->iv_opmode == IEEE80211_M_STA) ? in run_tx()
3512 1 : RUN_AID2WCID(ni->ni_associd); in run_tx()
3515 txwi->flags = 0; in run_tx()
3516 txwi->txop = 0; in run_tx()
3518 data->m = m; in run_tx()
3519 data->ni = ni; in run_tx()
3520 data->ridx = ridx; in run_tx()
3527 * * TX_STA_CNT0 for all-TX-in-one stats. in run_tx()
3529 * To use FIFO stats, we need to store MCS into the driver-private in run_tx()
3537 if (sc->rvp_cnt > 1 || vap->iv_opmode == IEEE80211_M_HOSTAP || in run_tx()
3538 vap->iv_opmode == IEEE80211_M_MBSS) { in run_tx()
3540 txwi->len |= htole16(pid << RT2860_TX_PID_SHIFT); in run_tx()
3544 * USB devices, so we simulate FIFO-is-full interrupt here. in run_tx()
3554 if (sc->fifo_cnt++ == 10) { in run_tx()
3557 * with a non-sleepable lock, tcpinp. So, need to defer. in run_tx()
3559 uint32_t i = RUN_CMDQ_GET(&sc->cmdq_store); in run_tx()
3561 sc->cmdq[i].func = run_drain_fifo; in run_tx()
3562 sc->cmdq[i].arg0 = sc; in run_tx()
3563 ieee80211_runtask(ic, &sc->cmdq_task); in run_tx()
3567 STAILQ_INSERT_TAIL(&sc->sc_epq[qid].tx_qh, data, next); in run_tx()
3569 usbd_transfer_start(sc->sc_xfer[qid]); in run_tx()
3573 m->m_pkthdr.len + (int)(sizeof(struct rt2870_txd) + in run_tx()
3582 struct ieee80211com *ic = &sc->sc_ic; in run_tx_mgt()
3589 uint8_t ridx = rn->mgt_ridx; in run_tx_mgt()
3600 else if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in run_tx_mgt()
3603 dur = ieee80211_ack_duration(ic->ic_rt, rt2860_rates[ridx].rate, in run_tx_mgt()
3604 ic->ic_flags & IEEE80211_F_SHPREAMBLE); in run_tx_mgt()
3605 USETW(wh->i_dur, dur); in run_tx_mgt()
3608 if (sc->sc_epq[0].tx_nfree == 0) in run_tx_mgt()
3611 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in run_tx_mgt()
3612 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in run_tx_mgt()
3613 sc->sc_epq[0].tx_nfree--; in run_tx_mgt()
3615 txd = (struct rt2870_txd *)&data->desc; in run_tx_mgt()
3616 txd->flags = RT2860_TX_QSEL_EDCA; in run_tx_mgt()
3618 txwi->wcid = 0xff; in run_tx_mgt()
3619 txwi->flags = wflags; in run_tx_mgt()
3620 txwi->xflags = xflags; in run_tx_mgt()
3621 txwi->txop = 0; /* clear leftover garbage bits */ in run_tx_mgt()
3623 data->m = m; in run_tx_mgt()
3624 data->ni = ni; in run_tx_mgt()
3625 data->ridx = ridx; in run_tx_mgt()
3630 m->m_pkthdr.len + (int)(sizeof(struct rt2870_txd) + in run_tx_mgt()
3633 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in run_tx_mgt()
3635 usbd_transfer_start(sc->sc_xfer[0]); in run_tx_mgt()
3644 struct ieee80211com *ic = ni->ni_ic; in run_sendprot()
3657 if (sc->sc_epq[0].tx_nfree == 0) in run_sendprot()
3663 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); in run_sendprot()
3668 protrate = ieee80211_ctl_rate(ic->ic_rt, rate); in run_sendprot()
3674 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in run_sendprot()
3675 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in run_sendprot()
3676 sc->sc_epq[0].tx_nfree--; in run_sendprot()
3678 txd = (struct rt2870_txd *)&data->desc; in run_sendprot()
3679 txd->flags = RT2860_TX_QSEL_EDCA; in run_sendprot()
3681 txwi->wcid = 0xff; in run_sendprot()
3682 txwi->flags = wflags; in run_sendprot()
3683 txwi->xflags = xflags; in run_sendprot()
3684 txwi->txop = 0; /* clear leftover garbage bits */ in run_sendprot()
3686 data->m = mprot; in run_sendprot()
3687 data->ni = ieee80211_ref_node(ni); in run_sendprot()
3693 data->ridx = ridx; in run_sendprot()
3698 m->m_pkthdr.len, rate); in run_sendprot()
3700 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in run_sendprot()
3702 usbd_transfer_start(sc->sc_xfer[0]); in run_sendprot()
3711 struct ieee80211com *ic = ni->ni_ic; in run_tx_param()
3725 rate = params->ibp_rate0; in run_tx_param()
3726 if (!ieee80211_isratevalid(ic->ic_rt, rate)) { in run_tx_param()
3731 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) in run_tx_param()
3733 if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) { in run_tx_param()
3735 params->ibp_flags & IEEE80211_BPF_RTS ? in run_tx_param()
3745 if (sc->sc_epq[0].tx_nfree == 0) { in run_tx_param()
3751 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in run_tx_param()
3752 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in run_tx_param()
3753 sc->sc_epq[0].tx_nfree--; in run_tx_param()
3755 txd = (struct rt2870_txd *)&data->desc; in run_tx_param()
3756 txd->flags = RT2860_TX_QSEL_EDCA; in run_tx_param()
3758 txwi->wcid = 0xff; in run_tx_param()
3759 txwi->xflags = xflags; in run_tx_param()
3760 txwi->txop = opflags; in run_tx_param()
3761 txwi->flags = 0; /* clear leftover garbage bits */ in run_tx_param()
3763 data->m = m; in run_tx_param()
3764 data->ni = ni; in run_tx_param()
3769 data->ridx = ridx; in run_tx_param()
3774 m->m_pkthdr.len, rate); in run_tx_param()
3776 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in run_tx_param()
3778 usbd_transfer_start(sc->sc_xfer[0]); in run_tx_param()
3787 struct run_softc *sc = ni->ni_ic->ic_softc; in run_raw_xmit()
3793 if (!(sc->sc_flags & RUN_RUNNING)) { in run_raw_xmit()
3826 struct run_softc *sc = ic->ic_softc; in run_transmit()
3830 if ((sc->sc_flags & RUN_RUNNING) == 0) { in run_transmit()
3834 error = mbufq_enqueue(&sc->sc_snd, m); in run_transmit()
3853 if ((sc->sc_flags & RUN_RUNNING) == 0) in run_start()
3856 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in run_start()
3857 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in run_start()
3859 mbufq_prepend(&sc->sc_snd, m); in run_start()
3868 struct run_softc *sc = ic->ic_softc; in run_parent()
3872 if (sc->sc_detached) { in run_parent()
3877 if (ic->ic_nrunning > 0) { in run_parent()
3878 if (!(sc->sc_flags & RUN_RUNNING)) { in run_parent()
3883 } else if ((sc->sc_flags & RUN_RUNNING) && sc->rvp_cnt <= 1) in run_parent()
3996 if (sc->mac_ver == 0x3572) { in run_set_agc()
4013 run_bbp_write(sc, 62, 0x37 - sc->lna[group]); in run_select_chan_group()
4014 run_bbp_write(sc, 63, 0x37 - sc->lna[group]); in run_select_chan_group()
4015 run_bbp_write(sc, 64, 0x37 - sc->lna[group]); in run_select_chan_group()
4016 if (sc->mac_ver < 0x3572) in run_select_chan_group()
4019 if (sc->mac_ver == 0x3593) { in run_select_chan_group()
4025 if (sc->ext_2ghz_lna) { in run_select_chan_group()
4026 if (sc->mac_ver >= 0x5390) in run_select_chan_group()
4033 if (sc->mac_ver == 0x5592) { in run_select_chan_group()
4051 } else if (sc->mac_ver >= 0x5390) in run_select_chan_group()
4055 (sc->mac_ver == 0x3593) ? 0x62 : 0x84); in run_select_chan_group()
4060 if (sc->mac_ver == 0x5592) { in run_select_chan_group()
4078 } else if (sc->mac_ver == 0x3572) in run_select_chan_group()
4082 (sc->mac_ver == 0x3593) ? 0x82 : 0xf2); in run_select_chan_group()
4083 if (sc->ext_5ghz_lna) in run_select_chan_group()
4096 if (sc->mac_ver == 0x3593) in run_select_chan_group()
4098 if (sc->nrxchains > 1) in run_select_chan_group()
4102 if (sc->ntxchains > 1) in run_select_chan_group()
4104 if (sc->mac_ver == 0x3593) { in run_select_chan_group()
4105 if (sc->ntxchains > 2) in run_select_chan_group()
4110 if (sc->ntxchains > 1) in run_select_chan_group()
4113 if (sc->mac_ver == 0x3572) { in run_select_chan_group()
4120 if (sc->mac_ver == 0x5592) { in run_select_chan_group()
4125 if (sc->mac_ver == 0x3593) { in run_select_chan_group()
4136 if (sc->mac_ver >= 0x3070) in run_select_chan_group()
4137 agc = 0x1c + sc->lna[0] * 2; in run_select_chan_group()
4139 agc = 0x2e + sc->lna[0]; in run_select_chan_group()
4141 if (sc->mac_ver == 0x5592) in run_select_chan_group()
4142 agc = 0x24 + sc->lna[group] * 2; in run_select_chan_group()
4143 else if (sc->mac_ver == 0x3572 || sc->mac_ver == 0x3593) in run_select_chan_group()
4144 agc = 0x22 + (sc->lna[group] * 5) / 3; in run_select_chan_group()
4146 agc = 0x32 + (sc->lna[group] * 5) / 3; in run_select_chan_group()
4159 /* find the settings for this channel (we know it exists) */ in run_rt2870_set_chan()
4163 if (sc->ntxchains == 1) in run_rt2870_set_chan()
4165 if (sc->nrxchains == 1) in run_rt2870_set_chan()
4167 else if (sc->nrxchains == 2) in run_rt2870_set_chan()
4171 txpow1 = sc->txpow1[i]; in run_rt2870_set_chan()
4172 txpow2 = sc->txpow2[i]; in run_rt2870_set_chan()
4176 r4 = (rfprog[i].r4 & ~(0x001f87c0)) | (sc->freq << 15); in run_rt2870_set_chan()
4229 /* find the settings for this channel (we know it exists) */ in run_rt3070_set_chan()
4233 txpow1 = sc->txpow1[i]; in run_rt3070_set_chan()
4234 txpow2 = sc->txpow2[i]; in run_rt3070_set_chan()
4259 if (sc->ntxchains == 1) in run_rt3070_set_chan()
4261 else if (sc->ntxchains == 2) in run_rt3070_set_chan()
4263 if (sc->nrxchains == 1) in run_rt3070_set_chan()
4265 else if (sc->nrxchains == 2) in run_rt3070_set_chan()
4271 rf = (rf & ~0x7f) | sc->freq; in run_rt3070_set_chan()
4276 rf = (rf & ~0x3f) | sc->rf24_20mhz; in run_rt3070_set_chan()
4279 rf = (rf & ~0x3f) | sc->rf24_20mhz; in run_rt3070_set_chan()
4295 /* find the settings for this channel (we know it exists) */ in run_rt3572_set_chan()
4299 txpow1 = sc->txpow1[i]; in run_rt3572_set_chan()
4300 txpow2 = sc->txpow2[i]; in run_rt3572_set_chan()
4303 run_bbp_write(sc, 25, sc->bbp25); in run_rt3572_set_chan()
4304 run_bbp_write(sc, 26, sc->bbp26); in run_rt3572_set_chan()
4341 if (sc->ntxchains == 1) in run_rt3572_set_chan()
4343 else if (sc->ntxchains == 2) in run_rt3572_set_chan()
4345 if (sc->nrxchains == 1) in run_rt3572_set_chan()
4347 else if (sc->nrxchains == 2) in run_rt3572_set_chan()
4353 rf = (rf & ~0x7f) | sc->freq; in run_rt3572_set_chan()
4357 rf = sc->rf24_20mhz; in run_rt3572_set_chan()
4379 rf = 0x48 | sc->txmixgain_2ghz; in run_rt3572_set_chan()
4381 rf = 0x78 | sc->txmixgain_5ghz; in run_rt3572_set_chan()
4444 /* find the settings for this channel (we know it exists) */ in run_rt3593_set_chan()
4448 txpow1 = sc->txpow1[i]; in run_rt3593_set_chan()
4449 txpow2 = sc->txpow2[i]; in run_rt3593_set_chan()
4450 txpow3 = (sc->ntxchains == 3) ? sc->txpow3[i] : 0; in run_rt3593_set_chan()
4453 run_bbp_write(sc, 25, sc->bbp25); in run_rt3593_set_chan()
4454 run_bbp_write(sc, 26, sc->bbp26); in run_rt3593_set_chan()
4492 if (sc->ntxchains == 3) in run_rt3593_set_chan()
4503 h20mhz = (sc->rf24_20mhz & 0x20) >> 5; in run_rt3593_set_chan()
4604 /* find the settings for this channel (we know it exists) */ in run_rt5390_set_chan()
4608 txpow1 = sc->txpow1[i]; in run_rt5390_set_chan()
4609 txpow2 = sc->txpow2[i]; in run_rt5390_set_chan()
4624 if (sc->mac_ver == 0x5392) { in run_rt5390_set_chan()
4635 if (sc->mac_ver == 0x5392) in run_rt5390_set_chan()
4639 if (sc->mac_ver != 0x5392) { in run_rt5390_set_chan()
4650 if (sc->mac_ver == 0x5392) { in run_rt5390_set_chan()
4652 if (sc->mac_rev >= 0x0223) { in run_rt5390_set_chan()
4681 if (sc->mac_rev >= 0x0502) { in run_rt5390_set_chan()
4720 /* find the settings for this channel (we know it exists) */ in run_rt5592_set_chan()
4724 txpow1 = sc->txpow1[i]; in run_rt5592_set_chan()
4725 txpow2 = sc->txpow2[i]; in run_rt5592_set_chan()
4734 run_rt3070_rf_write(sc, 8, freqs->n & 0xff); in run_rt5592_set_chan()
4737 rf |= ((freqs->n & 0x0100) >> 8) << 4; in run_rt5592_set_chan()
4743 rf |= (freqs->k & 0x0f); in run_rt5592_set_chan()
4749 rf |= ((freqs->m - 0x8) & 0x3) << 2; in run_rt5592_set_chan()
4753 rf |= (((freqs->m - 0x8) & 0x4) >> 2) << 7; in run_rt5592_set_chan()
4759 rf |= (freqs->r - 0x1); in run_rt5592_set_chan()
4777 * G-band bit<7:6>=1:0, bit<5:0> range from 0x0 ~ 0x27. in run_rt5592_set_chan()
4797 * A-band bit<7:6>=1:1, bit<5:0> range from 0x0 ~ 0x2b. in run_rt5592_set_chan()
4824 if (sc->ntxchains > 1) in run_rt5592_set_chan()
4826 if (sc->nrxchains > 1) in run_rt5592_set_chan()
4851 if (sc->rf_rev == RT5390_RF_5370) { in run_set_rx_antenna()
4860 if (sc->rf_rev == RT5390_RF_5370) { in run_set_rx_antenna()
4874 struct ieee80211com *ic = &sc->sc_ic; in run_set_chan()
4881 if (sc->mac_ver == 0x5592) in run_set_chan()
4883 else if (sc->mac_ver >= 0x5390) in run_set_chan()
4885 else if (sc->mac_ver == 0x3593) in run_set_chan()
4887 else if (sc->mac_ver == 0x3572) in run_set_chan()
4889 else if (sc->mac_ver >= 0x3070) in run_set_chan()
4910 if (sc->mac_ver >= 0x5392) in run_set_chan()
4919 struct run_softc *sc = ic->ic_softc; in run_set_channel()
4922 run_set_chan(sc, ic->ic_curchan); in run_set_channel()
4932 struct run_softc *sc = ic->ic_softc; in run_getradiocaps()
4938 if (sc->rf_rev != RT3070_RF_2020) in run_getradiocaps()
4944 if (sc->rf_rev == RT2860_RF_2750 || sc->rf_rev == RT2860_RF_2850 || in run_getradiocaps()
4945 sc->rf_rev == RT3070_RF_3052 || sc->rf_rev == RT3593_RF_3053 || in run_getradiocaps()
4946 sc->rf_rev == RT5592_RF_5592) { in run_getradiocaps()
4948 if (sc->rf_rev != RT3070_RF_2020) in run_getradiocaps()
4959 struct run_softc *sc = ic->ic_softc; in run_scan_start()
4975 struct run_softc *sc = ic->ic_softc; in run_scan_end()
4980 run_set_bssid(sc, sc->sc_bssid); in run_scan_end()
4989 * (non-sleepable thread)
4994 struct ieee80211com *ic = vap->iv_ic; in run_update_beacon()
4995 struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; in run_update_beacon()
4996 struct ieee80211_node *ni = vap->iv_bss; in run_update_beacon()
4997 struct run_softc *sc = ic->ic_softc; in run_update_beacon()
5016 setbit(bo->bo_flags, item); in run_update_beacon()
5017 if (rvp->beacon_mbuf == NULL) { in run_update_beacon()
5018 rvp->beacon_mbuf = ieee80211_beacon_alloc(ni); in run_update_beacon()
5019 if (rvp->beacon_mbuf == NULL) in run_update_beacon()
5022 ieee80211_beacon_update(ni, rvp->beacon_mbuf, mcast); in run_update_beacon()
5024 i = RUN_CMDQ_GET(&sc->cmdq_store); in run_update_beacon()
5026 sc->cmdq[i].func = run_update_beacon_cb; in run_update_beacon()
5027 sc->cmdq[i].arg0 = vap; in run_update_beacon()
5028 ieee80211_runtask(ic, &sc->cmdq_task); in run_update_beacon()
5037 struct ieee80211_node *ni = vap->iv_bss; in run_update_beacon_cb()
5039 struct ieee80211com *ic = vap->iv_ic; in run_update_beacon_cb()
5040 struct run_softc *sc = ic->ic_softc; in run_update_beacon_cb()
5046 if (ni->ni_chan == IEEE80211_CHAN_ANYC) in run_update_beacon_cb()
5048 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) in run_update_beacon_cb()
5055 if (rvp->beacon_mbuf == NULL) { in run_update_beacon_cb()
5056 rvp->beacon_mbuf = ieee80211_beacon_alloc(ni); in run_update_beacon_cb()
5057 if (rvp->beacon_mbuf == NULL) in run_update_beacon_cb()
5060 m = rvp->beacon_mbuf; in run_update_beacon_cb()
5064 txwi.len = htole16(m->m_pkthdr.len); in run_update_beacon_cb()
5067 ridx = (ic->ic_curmode == IEEE80211_MODE_11A) ? in run_update_beacon_cb()
5076 txwisize = (sc->mac_ver == 0x5592) ? in run_update_beacon_cb()
5078 run_write_region_1(sc, RT2860_BCN_BASE(rvp->rvp_id), (uint8_t *)&txwi, in run_update_beacon_cb()
5080 run_write_region_1(sc, RT2860_BCN_BASE(rvp->rvp_id) + txwisize, in run_update_beacon_cb()
5081 mtod(m, uint8_t *), (m->m_pkthdr.len + 1) & ~1); in run_update_beacon_cb()
5087 struct run_softc *sc = ic->ic_softc; in run_updateprot()
5090 i = RUN_CMDQ_GET(&sc->cmdq_store); in run_updateprot()
5092 sc->cmdq[i].func = run_updateprot_cb; in run_updateprot()
5093 sc->cmdq[i].arg0 = ic; in run_updateprot()
5094 ieee80211_runtask(ic, &sc->cmdq_task); in run_updateprot()
5101 struct run_softc *sc = ic->ic_softc; in run_updateprot_cb()
5106 tmp |= (ic->ic_curmode == IEEE80211_MODE_11A) ? in run_updateprot_cb()
5112 if (ic->ic_flags & IEEE80211_F_USEPROT) { in run_updateprot_cb()
5113 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in run_updateprot_cb()
5115 else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in run_updateprot_cb()
5125 struct run_softc *sc = vap->iv_ic->ic_softc; in run_usb_timeout_cb()
5129 if(vap->iv_state == IEEE80211_S_RUN && in run_usb_timeout_cb()
5130 vap->iv_opmode != IEEE80211_M_STA) in run_usb_timeout_cb()
5132 else if (vap->iv_state == IEEE80211_S_SCAN) { in run_usb_timeout_cb()
5151 * can run into a livelock and start sending CTS-to-self frames like in run_reset_livelock()
5158 "CTS-to-self livelock detected\n"); in run_reset_livelock()
5174 if (sc->sc_ic.ic_promisc > 0) in run_update_promisc_locked()
5180 (sc->sc_ic.ic_promisc > 0) ? "entering" : "leaving"); in run_update_promisc_locked()
5186 struct run_softc *sc = ic->ic_softc; in run_update_promisc()
5188 if ((sc->sc_flags & RUN_RUNNING) == 0) in run_update_promisc()
5199 struct ieee80211com *ic = &sc->sc_ic; in run_enable_tsf_sync()
5200 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in run_enable_tsf_sync()
5204 RUN_VAP(vap)->rvp_id, ic->ic_opmode); in run_enable_tsf_sync()
5208 tmp |= vap->iv_bss->ni_intval * 16; in run_enable_tsf_sync()
5211 if (ic->ic_opmode == IEEE80211_M_STA) { in run_enable_tsf_sync()
5217 } else if (ic->ic_opmode == IEEE80211_M_IBSS) { in run_enable_tsf_sync()
5224 } else if (ic->ic_opmode == IEEE80211_M_HOSTAP || in run_enable_tsf_sync()
5225 ic->ic_opmode == IEEE80211_M_MBSS) { in run_enable_tsf_sync()
5275 OFDM(6) << 28 | /* 54->48 */ in run_enable_mrr()
5276 OFDM(5) << 24 | /* 48->36 */ in run_enable_mrr()
5277 OFDM(4) << 20 | /* 36->24 */ in run_enable_mrr()
5278 OFDM(3) << 16 | /* 24->18 */ in run_enable_mrr()
5279 OFDM(2) << 12 | /* 18->12 */ in run_enable_mrr()
5280 OFDM(1) << 8 | /* 12-> 9 */ in run_enable_mrr()
5281 OFDM(0) << 4 | /* 9-> 6 */ in run_enable_mrr()
5282 OFDM(0)); /* 6-> 6 */ in run_enable_mrr()
5285 CCK(2) << 12 | /* 11->5.5 */ in run_enable_mrr()
5286 CCK(1) << 8 | /* 5.5-> 2 */ in run_enable_mrr()
5287 CCK(0) << 4 | /* 2-> 1 */ in run_enable_mrr()
5288 CCK(0)); /* 1-> 1 */ in run_enable_mrr()
5296 struct ieee80211com *ic = &sc->sc_ic; in run_set_txpreamble()
5300 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) in run_set_txpreamble()
5310 struct ieee80211com *ic = &sc->sc_ic; in run_set_basicrates()
5313 if (ic->ic_curmode == IEEE80211_MODE_11B) in run_set_basicrates()
5315 else if (ic->ic_curmode == IEEE80211_MODE_11A) in run_set_basicrates()
5325 which | (sc->leds & 0x7f)); in run_set_leds()
5349 struct run_softc *sc = ic->ic_softc; in run_updateslot()
5352 i = RUN_CMDQ_GET(&sc->cmdq_store); in run_updateslot()
5354 sc->cmdq[i].func = run_updateslot_cb; in run_updateslot()
5355 sc->cmdq[i].arg0 = ic; in run_updateslot()
5356 ieee80211_runtask(ic, &sc->cmdq_task); in run_updateslot()
5366 struct run_softc *sc = ic->ic_softc; in run_updateslot_cb()
5383 struct ieee80211com *ic = &sc->sc_ic; in run_rssi2dbm()
5384 struct ieee80211_channel *c = ic->ic_curchan; in run_rssi2dbm()
5389 delta = sc->rssi_5ghz[rxchain]; in run_rssi2dbm()
5393 delta -= sc->lna[1]; in run_rssi2dbm()
5395 delta -= sc->lna[2]; in run_rssi2dbm()
5397 delta -= sc->lna[3]; in run_rssi2dbm()
5399 delta = sc->rssi_2ghz[rxchain] - sc->lna[0]; in run_rssi2dbm()
5401 return (-12 - delta - rssi); in run_rssi2dbm()
5412 if (sc->nrxchains > 1) in run_rt5390_bbp_init()
5419 if (sc->mac_ver == 0x5592) { in run_rt5390_bbp_init()
5434 if (sc->mac_ver == 0x5392) { in run_rt5390_bbp_init()
5448 if (sc->mac_ver == 0x5592 && sc->mac_rev >= 0x0221) { in run_rt5390_bbp_init()
5454 if (sc->mac_ver == 0x5390) in run_rt5390_bbp_init()
5479 if (sc->mac_ver >= 0x5390) in run_bbp_init()
5488 if (sc->mac_ver == 0x3593) { in run_bbp_init()
5497 if (sc->mac_ver == 0x2860 && sc->mac_rev != 0x0101) in run_bbp_init()
5500 if (sc->mac_ver >= 0x3070 && (sc->mac_ver != 0x3593 && in run_bbp_init()
5501 sc->mac_ver != 0x5592)) { in run_bbp_init()
5505 } else if (sc->mac_ver == 0x2860 && sc->mac_rev == 0x0100) { in run_bbp_init()
5526 if (sc->mac_ver == 0x3572) { in run_rt3070_rf_init()
5538 if (sc->mac_ver == 0x3070 && sc->mac_rev < 0x0201) { in run_rt3070_rf_init()
5548 } else if (sc->mac_ver == 0x3071) { in run_rt3070_rf_init()
5555 if (sc->mac_rev < 0x0211) in run_rt3070_rf_init()
5565 } else if (sc->mac_ver == 0x3572) { in run_rt3070_rf_init()
5574 if (sc->mac_rev < 0x0211 || !sc->patch_dac) { in run_rt3070_rf_init()
5587 sc->rf24_20mhz = 0x1f; /* default value */ in run_rt3070_rf_init()
5588 target = (sc->mac_ver < 0x3071) ? 0x16 : 0x13; in run_rt3070_rf_init()
5589 run_rt3070_filter_calib(sc, 0x07, target, &sc->rf24_20mhz); in run_rt3070_rf_init()
5598 sc->rf24_40mhz = 0x2f; /* default value */ in run_rt3070_rf_init()
5599 target = (sc->mac_ver < 0x3071) ? 0x19 : 0x15; in run_rt3070_rf_init()
5600 run_rt3070_filter_calib(sc, 0x27, target, &sc->rf24_40mhz); in run_rt3070_rf_init()
5606 if (sc->mac_ver == 0x3572) { in run_rt3070_rf_init()
5608 run_bbp_read(sc, 25, &sc->bbp25); in run_rt3070_rf_init()
5609 run_bbp_read(sc, 26, &sc->bbp26); in run_rt3070_rf_init()
5610 } else if (sc->mac_rev < 0x0201 || sc->mac_rev < 0x0211) in run_rt3070_rf_init()
5616 if (sc->mac_ver == 0x3070 || sc->mac_ver == 0x3071) { in run_rt3070_rf_init()
5619 if ((sc->mac_ver == 0x3070 || in run_rt3070_rf_init()
5620 (sc->mac_ver == 0x3071 && sc->mac_rev >= 0x0211)) && in run_rt3070_rf_init()
5621 !sc->ext_2ghz_lna) in run_rt3070_rf_init()
5623 mingain = (sc->mac_ver == 0x3070) ? 1 : 2; in run_rt3070_rf_init()
5624 if (sc->txmixgain_2ghz >= mingain) in run_rt3070_rf_init()
5625 rf = (rf & ~0x7) | sc->txmixgain_2ghz; in run_rt3070_rf_init()
5629 if (sc->mac_ver == 0x3071) { in run_rt3070_rf_init()
5645 if (sc->mac_ver == 0x3070 || sc->mac_ver == 0x3071) { in run_rt3070_rf_init()
5649 if (sc->mac_rev < 0x0211) in run_rt3070_rf_init()
5694 sc->rf24_20mhz = 0x1f; in run_rt3593_rf_init()
5695 sc->rf24_40mhz = 0x2f; in run_rt3593_rf_init()
5698 run_bbp_read(sc, 25, &sc->bbp25); in run_rt3593_rf_init()
5699 run_bbp_read(sc, 26, &sc->bbp26); in run_rt3593_rf_init()
5713 if (sc->mac_ver == 0x5390) { in run_rt5390_rf_init()
5724 if (sc->mac_ver == 0x5592) { in run_rt5390_rf_init()
5731 } else if (sc->mac_ver == 0x5392) { in run_rt5390_rf_init()
5736 if (sc->mac_rev >= 0x0223) { in run_rt5390_rf_init()
5749 if (sc->mac_rev >= 0x0502) { in run_rt5390_rf_init()
5759 sc->rf24_20mhz = 0x1f; /* default value */ in run_rt5390_rf_init()
5760 sc->rf24_40mhz = (sc->mac_ver == 0x5592) ? 0 : 0x2f; in run_rt5390_rf_init()
5762 if (sc->mac_rev < 0x0211) in run_rt5390_rf_init()
5809 delta = bbp55_pb - bbp55_sb; in run_rt3070_filter_calib()
5819 rf24--; /* backtrack */ in run_rt3070_filter_calib()
5840 if (sc->mac_ver == 0x3572) { in run_rt3070_rf_setup()
5842 if (sc->mac_rev >= 0x0201) in run_rt3070_rf_setup()
5846 if (sc->ntxchains == 1) in run_rt3070_rf_setup()
5848 if (sc->nrxchains == 1) in run_rt3070_rf_setup()
5852 if (sc->mac_rev >= 0x0211) { in run_rt3070_rf_setup()
5859 rf = (rf & ~0x07) | sc->txmixgain_2ghz; in run_rt3070_rf_setup()
5862 } else if (sc->mac_ver == 0x3071) { in run_rt3070_rf_setup()
5863 if (sc->mac_rev >= 0x0211) { in run_rt3070_rf_setup()
5873 if (sc->ntxchains == 1) in run_rt3070_rf_setup()
5875 if (sc->nrxchains == 1) in run_rt3070_rf_setup()
5880 if (sc->mac_rev < 0x0211) { in run_rt3070_rf_setup()
5882 sc->patch_dac ? 0x2c : 0x0f); in run_rt3070_rf_setup()
5886 } else if (sc->mac_ver == 0x3070) { in run_rt3070_rf_setup()
5887 if (sc->mac_rev >= 0x0201) { in run_rt3070_rf_setup()
5896 if (sc->mac_rev < 0x0201) { in run_rt3070_rf_setup()
5904 if (sc->mac_ver >= 0x3071) { in run_rt3070_rf_setup()
5906 if (sc->rf[i].reg == 0 || sc->rf[i].reg == 0xff) in run_rt3070_rf_setup()
5908 run_rt3070_rf_write(sc, sc->rf[i].reg, sc->rf[i].val); in run_rt3070_rf_setup()
5918 if (sc->mac_rev >= 0x0211) { in run_rt3593_rf_setup()
5923 if (sc->mac_rev < 0x0211) { in run_rt3593_rf_setup()
5925 sc->patch_dac ? 0x2c : 0x0f); in run_rt3593_rf_setup()
5934 ((sc->txmixgain_2ghz & 0x07) << 2); in run_rt3593_rf_setup()
5952 if (sc->nrxchains > 1) in run_rt3593_rf_setup()
5988 if (sc->mac_rev >= 0x0211) { in run_rt5390_rf_setup()
5992 if (sc->mac_ver != 0x5592) { in run_rt5390_rf_setup()
6000 if (sc->ntxchains == 1) in run_rt5390_rf_setup()
6002 if (sc->nrxchains == 1) in run_rt5390_rf_setup()
6020 if (sc->mac_ver != 0x5592) { in run_rt5390_rf_setup()
6022 if (sc->mac_rev < 0x0211) { in run_rt5390_rf_setup()
6024 sc->patch_dac ? 0x2c : 0x0f); in run_rt5390_rf_setup()
6033 struct ieee80211com *ic = &sc->sc_ic; in run_txrx_enable()
6060 if (ic->ic_opmode != IEEE80211_M_MONITOR) { in run_txrx_enable()
6065 if (ic->ic_opmode == IEEE80211_M_STA) in run_txrx_enable()
6083 rf = (rf & ~0x7f) | (sc->freq & 0x7f); in run_adjust_freq_offset()
6093 struct ieee80211com *ic = &sc->sc_ic; in run_init_locked()
6094 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in run_init_locked()
6101 if (ic->ic_nrunning > 1) in run_init_locked()
6107 device_printf(sc->sc_dev, "could not load 8051 microcode\n"); in run_init_locked()
6122 run_setup_tx_list(sc, &sc->sc_epq[i]); in run_init_locked()
6124 run_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); in run_init_locked()
6134 device_printf(sc->sc_dev, "timeout waiting for DMA engine\n"); in run_init_locked()
6141 /* turn off PME_OEN to solve high-current issue */ in run_init_locked()
6150 device_printf(sc->sc_dev, "could not reset chipset\n"); in run_init_locked()
6158 if (sc->txpow20mhz[ridx] == 0xffffffff) in run_init_locked()
6160 run_write(sc, RT2860_TX_PWR_CFG(ridx), sc->txpow20mhz[ridx]); in run_init_locked()
6169 if (sc->mac_ver >= 0x5390) { in run_init_locked()
6172 if (sc->mac_ver >= 0x5392) { in run_init_locked()
6174 if (sc->mac_ver == 0x5592) { in run_init_locked()
6182 } else if (sc->mac_ver == 0x3593) { in run_init_locked()
6185 } else if (sc->mac_ver >= 0x3070) { in run_init_locked()
6208 device_printf(sc->sc_dev, "could not initialize BBP\n"); in run_init_locked()
6221 if (sc->cmdq_key_set != RUN_CMDQ_GO) { in run_init_locked()
6232 if (sc->mac_rev != 0x0101) in run_init_locked()
6238 /* write vendor-specific BBP values (from EEPROM) */ in run_init_locked()
6239 if (sc->mac_ver < 0x3593) { in run_init_locked()
6241 if (sc->bbp[i].reg == 0 || sc->bbp[i].reg == 0xff) in run_init_locked()
6243 run_bbp_write(sc, sc->bbp[i].reg, sc->bbp[i].val); in run_init_locked()
6248 if (sc->rf_rev == RT3070_RF_3020 || sc->rf_rev == RT5390_RF_5370) in run_init_locked()
6252 (void)run_mcu_cmd(sc, RT2860_MCU_CMD_LED1, sc->led[0]); in run_init_locked()
6253 (void)run_mcu_cmd(sc, RT2860_MCU_CMD_LED2, sc->led[1]); in run_init_locked()
6254 (void)run_mcu_cmd(sc, RT2860_MCU_CMD_LED3, sc->led[2]); in run_init_locked()
6256 if (sc->mac_ver >= 0x5390) in run_init_locked()
6258 else if (sc->mac_ver == 0x3593) in run_init_locked()
6260 else if (sc->mac_ver >= 0x3070) in run_init_locked()
6263 /* disable non-existing Rx chains */ in run_init_locked()
6266 if (sc->nrxchains == 2) in run_init_locked()
6268 else if (sc->nrxchains == 3) in run_init_locked()
6272 /* disable non-existing Tx chains */ in run_init_locked()
6274 if (sc->ntxchains == 1) in run_init_locked()
6278 if (sc->mac_ver >= 0x5390) in run_init_locked()
6280 else if (sc->mac_ver == 0x3593) in run_init_locked()
6282 else if (sc->mac_ver >= 0x3070) in run_init_locked()
6286 run_set_chan(sc, ic->ic_curchan); in run_init_locked()
6298 sc->sc_flags |= RUN_RUNNING; in run_init_locked()
6299 sc->cmdq_run = RUN_CMDQ_GO; in run_init_locked()
6302 usbd_xfer_set_stall(sc->sc_xfer[i]); in run_init_locked()
6304 usbd_transfer_start(sc->sc_xfer[RUN_BULK_RX]); in run_init_locked()
6325 if (sc->sc_flags & RUN_RUNNING) in run_stop()
6328 sc->sc_flags &= ~RUN_RUNNING; in run_stop()
6330 sc->ratectl_run = RUN_RATECTL_OFF; in run_stop()
6331 sc->cmdq_run = sc->cmdq_key_set; in run_stop()
6336 usbd_transfer_drain(sc->sc_xfer[i]); in run_stop()
6342 if (sc->rx_m != NULL) { in run_stop()
6343 m_free(sc->rx_m); in run_stop()
6344 sc->rx_m = NULL; in run_stop()
6361 device_printf(sc->sc_dev, "timeout waiting for DMA engine\n"); in run_stop()
6394 run_unsetup_tx_list(sc, &sc->sc_epq[i]); in run_stop()
6400 usb_pause_mtx(mtx_owned(&sc->sc_mtx) ? in run_delay()
6401 &sc->sc_mtx : NULL, USB_MS_TO_TICKS(ms)); in run_delay()
6415 /* For now, no A-MPDU TX support in the driver */ in run_ampdu_enable()