Lines Matching +full:timeout +full:- +full:tap +full:- +full:ms
1 /*-
2 * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr>
3 * Copyright (c) 2013-2014 Kevin Lo
111 device_printf((_sc)->sc_dev, __VA_ARGS__); \
254 struct ieee80211_tx_ampdu *tap);
298 .timeout = 5000, /* ms */
308 .timeout = 5000, /* ms */
318 .timeout = 5000, /* ms */
328 .timeout = 5000, /* ms */
338 .timeout = 5000, /* ms */
348 .timeout = 5000, /* ms */
371 .timeout = 5000, /* ms */
387 if (uaa->dev_state != UAA_DEV_READY) in mtw_autoinst()
393 id = iface->idesc; in mtw_autoinst()
394 if (id == NULL || id->bInterfaceClass != UICLASS_MASS) in mtw_autoinst()
400 uaa->dev_state = UAA_DEV_EJECTING; in mtw_autoinst()
441 if (sc->asic_ver == 0x7612) in mtw_wlan_enable()
450 if (sc->asic_ver == 0x7612) { in mtw_wlan_enable()
486 error = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, &req, &tmp, 0, in mtw_read_cfg()
501 if (uaa->usb_mode != USB_MODE_HOST) in mtw_match()
503 if (uaa->info.bConfigIndex != 0) in mtw_match()
505 if (uaa->info.bIfaceIndex != 0) in mtw_match()
516 struct ieee80211com *ic = &sc->sc_ic; in mtw_attach()
524 sc->sc_udev = uaa->device; in mtw_attach()
525 sc->sc_dev = self; in mtw_attach()
526 sc->sc_sent = 0; in mtw_attach()
528 mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), in mtw_attach()
533 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in mtw_attach()
534 mtw_config, MTW_N_XFER, sc, &sc->sc_mtx); in mtw_attach()
536 device_printf(sc->sc_dev, in mtw_attach()
543 sc->txd_fw[i] = (struct mtw_txd_fw *) in mtw_attach()
548 sc->sc_idx = 0; in mtw_attach()
549 mbufq_init(&sc->sc_snd, ifqmaxlen); in mtw_attach()
553 device_printf(sc->sc_dev, "could not enable WLAN core\n"); in mtw_attach()
568 device_printf(sc->sc_dev, in mtw_attach()
569 "timeout waiting for NIC to initialize\n"); in mtw_attach()
572 sc->asic_ver = ver >> 16; in mtw_attach()
573 sc->asic_rev = ver & 0xffff; in mtw_attach()
575 if (sc->asic_ver != 0x7601) { in mtw_attach()
576 device_printf(sc->sc_dev, in mtw_attach()
578 sc->asic_rev); in mtw_attach()
585 sc->mac_rev = tmp & 0xffff; in mtw_attach()
588 ret = msleep(&sc->fwloading, &sc->sc_mtx, 0, "fwload", 3 * hz); in mtw_attach()
589 if (ret == EWOULDBLOCK || sc->fwloading != 1) { in mtw_attach()
590 device_printf(sc->sc_dev, in mtw_attach()
591 "timeout waiting for MCU to initialize\n"); in mtw_attach()
595 sc->sc_srom_read = mtw_efuse_read_2; in mtw_attach()
599 device_printf(sc->sc_dev, in mtw_attach()
601 sc->asic_ver, sc->mac_rev, mtw_get_rf(sc->rf_rev), sc->ntxchains, in mtw_attach()
602 sc->nrxchains, ether_sprintf(ic->ic_macaddr)); in mtw_attach()
610 ic->ic_softc = sc; in mtw_attach()
611 ic->ic_name = device_get_nameunit(self); in mtw_attach()
612 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in mtw_attach()
613 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ in mtw_attach()
615 ic->ic_caps = IEEE80211_C_STA | /* station mode supported */ in mtw_attach()
619 IEEE80211_C_WDS | /* 4-address traffic works */ in mtw_attach()
625 device_printf(sc->sc_dev, "[HT] Enabling 802.11n\n"); in mtw_attach()
626 ic->ic_htcaps = IEEE80211_HTC_HT in mtw_attach()
632 ic->ic_rxstream = sc->nrxchains; in mtw_attach()
633 ic->ic_txstream = sc->ntxchains; in mtw_attach()
635 ic->ic_cryptocaps = IEEE80211_CRYPTO_WEP | IEEE80211_CRYPTO_AES_CCM | in mtw_attach()
639 ic->ic_flags |= IEEE80211_F_DATAPAD; in mtw_attach()
640 ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS; in mtw_attach()
641 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in mtw_attach()
643 mtw_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in mtw_attach()
644 ic->ic_channels); in mtw_attach()
648 ic->ic_scan_start = mtw_scan_start; in mtw_attach()
649 ic->ic_scan_end = mtw_scan_end; in mtw_attach()
650 ic->ic_set_channel = mtw_set_channel; in mtw_attach()
651 ic->ic_getradiocaps = mtw_getradiocaps; in mtw_attach()
652 ic->ic_node_alloc = mtw_node_alloc; in mtw_attach()
653 ic->ic_newassoc = mtw_newassoc; in mtw_attach()
654 ic->ic_update_mcast = mtw_update_mcast; in mtw_attach()
655 ic->ic_updateslot = mtw_updateslot; in mtw_attach()
656 ic->ic_wme.wme_update = mtw_wme_update; in mtw_attach()
657 ic->ic_raw_xmit = mtw_raw_xmit; in mtw_attach()
658 ic->ic_update_promisc = mtw_update_promisc; in mtw_attach()
659 ic->ic_vap_create = mtw_vap_create; in mtw_attach()
660 ic->ic_vap_delete = mtw_vap_delete; in mtw_attach()
661 ic->ic_transmit = mtw_transmit; in mtw_attach()
662 ic->ic_parent = mtw_parent; in mtw_attach()
664 ic->ic_update_chw = mtw_update_chw; in mtw_attach()
665 ic->ic_ampdu_enable = mtw_ampdu_enable; in mtw_attach()
667 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr, in mtw_attach()
668 sizeof(sc->sc_txtap), MTW_TX_RADIOTAP_PRESENT, in mtw_attach()
669 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in mtw_attach()
671 TASK_INIT(&sc->cmdq_task, 0, mtw_cmdq_cb, sc); in mtw_attach()
672 TASK_INIT(&sc->ratectl_task, 0, mtw_ratectl_cb, sc); in mtw_attach()
673 usb_callout_init_mtx(&sc->ratectl_ch, &sc->sc_mtx, 0); in mtw_attach()
693 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in mtw_drain_mbufq()
694 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in mtw_drain_mbufq()
695 m->m_pkthdr.rcvif = NULL; in mtw_drain_mbufq()
705 struct ieee80211com *ic = &sc->sc_ic; in mtw_detach()
710 sc->sc_detached = 1; in mtw_detach()
716 usbd_transfer_drain(sc->sc_xfer[i]); in mtw_detach()
719 sc->ratectl_run = MTW_RATECTL_OFF; in mtw_detach()
720 sc->cmdq_run = sc->cmdq_key_set = MTW_CMDQ_ABORT; in mtw_detach()
723 if (ic->ic_nrunning > 0) in mtw_detach()
725 mtw_unsetup_tx_list(sc, &sc->sc_epq[i]); in mtw_detach()
730 if (sc->sc_ic.ic_softc == sc) { in mtw_detach()
732 usb_callout_drain(&sc->ratectl_ch); in mtw_detach()
733 ieee80211_draintask(ic, &sc->cmdq_task); in mtw_detach()
734 ieee80211_draintask(ic, &sc->ratectl_task); in mtw_detach()
738 free(sc->txd_fw[i], M_USBDEV); in mtw_detach()
741 mtx_destroy(&sc->sc_mtx); in mtw_detach()
752 struct mtw_softc *sc = ic->ic_softc; in mtw_vap_create()
757 if (sc->rvp_cnt >= MTW_VAP_MAX) { in mtw_vap_create()
758 device_printf(sc->sc_dev, "number of VAPs maxed out\n"); in mtw_vap_create()
772 if (!TAILQ_EMPTY(&ic->ic_vaps)) in mtw_vap_create()
776 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { in mtw_vap_create()
777 if (vap->iv_opmode != IEEE80211_M_HOSTAP) in mtw_vap_create()
784 device_printf(sc->sc_dev, in mtw_vap_create()
790 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in mtw_vap_create()
795 vap = &rvp->vap; in mtw_vap_create()
804 vap->iv_update_beacon = mtw_update_beacon; in mtw_vap_create()
805 vap->iv_max_aid = MTW_WCID_MAX; in mtw_vap_create()
811 if (ic->ic_rxstream > 1) in mtw_vap_create()
812 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in mtw_vap_create()
814 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in mtw_vap_create()
815 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_2; /* 2uS */ in mtw_vap_create()
823 vap->iv_key_delete = (void *)mtw_key_delete; in mtw_vap_create()
824 vap->iv_key_set = (void *)mtw_key_set; in mtw_vap_create()
827 rvp->newstate = vap->iv_newstate; in mtw_vap_create()
828 vap->iv_newstate = mtw_newstate; in mtw_vap_create()
830 rvp->recv_mgmt = vap->iv_recv_mgmt; in mtw_vap_create()
831 vap->iv_recv_mgmt = mtw_recv_mgmt; in mtw_vap_create()
843 if ((sc->rvp_bmap & 1 << i) == 0) { in mtw_vap_create()
844 sc->rvp_bmap |= 1 << i; in mtw_vap_create()
845 rvp->rvp_id = i; in mtw_vap_create()
849 if (sc->rvp_cnt++ == 0) in mtw_vap_create()
850 ic->ic_opmode = opmode; in mtw_vap_create()
853 sc->cmdq_run = MTW_CMDQ_GO; in mtw_vap_create()
856 rvp->rvp_id, sc->rvp_bmap, sc->rvp_cnt); in mtw_vap_create()
872 ic = vap->iv_ic; in mtw_vap_delete()
873 sc = ic->ic_softc; in mtw_vap_delete()
876 m_freem(rvp->beacon_mbuf); in mtw_vap_delete()
877 rvp->beacon_mbuf = NULL; in mtw_vap_delete()
879 rvp_id = rvp->rvp_id; in mtw_vap_delete()
880 sc->ratectl_run &= ~(1 << rvp_id); in mtw_vap_delete()
881 sc->rvp_bmap &= ~(1 << rvp_id); in mtw_vap_delete()
884 --sc->rvp_cnt; in mtw_vap_delete()
887 "vap=%p rvp_id=%d bmap=%x rvp_cnt=%d\n", vap, rvp_id, sc->rvp_bmap, in mtw_vap_delete()
888 sc->rvp_cnt); in mtw_vap_delete()
900 * here is all-for-one taskqueue callback function. This function
912 for (i = sc->cmdq_exec; sc->cmdq[i].func && pending; in mtw_cmdq_cb()
913 i = sc->cmdq_exec, pending--) { in mtw_cmdq_cb()
916 if (sc->cmdq_run == MTW_CMDQ_GO) { in mtw_cmdq_cb()
921 if (sc->cmdq[i].arg0) in mtw_cmdq_cb()
922 sc->cmdq[i].func(sc->cmdq[i].arg0); in mtw_cmdq_cb()
924 sc->cmdq[i].func(&sc->cmdq[i]); in mtw_cmdq_cb()
926 sc->cmdq[i].arg0 = NULL; in mtw_cmdq_cb()
927 sc->cmdq[i].func = NULL; in mtw_cmdq_cb()
928 sc->cmdq_exec++; in mtw_cmdq_cb()
929 sc->cmdq_exec &= MTW_CMDQ_MASQ; in mtw_cmdq_cb()
941 STAILQ_INIT(&pq->tx_qh); in mtw_setup_tx_list()
942 STAILQ_INIT(&pq->tx_fh); in mtw_setup_tx_list()
944 for (data = &pq->tx_data[0]; data < &pq->tx_data[MTW_TX_RING_COUNT]; in mtw_setup_tx_list()
946 data->sc = sc; in mtw_setup_tx_list()
947 STAILQ_INSERT_TAIL(&pq->tx_fh, data, next); in mtw_setup_tx_list()
949 pq->tx_nfree = MTW_TX_RING_COUNT; in mtw_setup_tx_list()
957 pq->tx_nfree = 0; in mtw_unsetup_tx_list()
959 STAILQ_INIT(&pq->tx_fh); in mtw_unsetup_tx_list()
960 STAILQ_INIT(&pq->tx_qh); in mtw_unsetup_tx_list()
963 for (data = &pq->tx_data[0]; data < &pq->tx_data[MTW_TX_RING_COUNT]; in mtw_unsetup_tx_list()
965 if (data->m != NULL) { in mtw_unsetup_tx_list()
966 m_freem(data->m); in mtw_unsetup_tx_list()
967 data->m = NULL; in mtw_unsetup_tx_list()
969 if (data->ni != NULL) { in mtw_unsetup_tx_list()
970 ieee80211_free_node(data->ni); in mtw_unsetup_tx_list()
971 data->ni = NULL; in mtw_unsetup_tx_list()
987 int error = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, &req, buf, in mtw_write_ivb()
1005 error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, &val); in mtw_write_cfg()
1012 // if (sc->asic_ver == 0x7612) in mtw_usb_dma_write()
1035 // struct usb_attach_arg *uaa = device_get_ivars(sc->sc_dev); in mtw_ucode_write()
1038 if (sc->asic_ver == 0x7612 && offset >= 0x90000) in mtw_ucode_write()
1041 xfer = usbd_alloc_xfer(sc->sc_udev); in mtw_ucode_write()
1066 sc->txd_fw[idx]->len = htole16(mlen); in mtw_ucode_write()
1067 sc->txd_fw[idx]->flags = htole16(MTW_TXD_DATA | MTW_TXD_MCU); in mtw_ucode_write()
1069 memcpy(&sc->txd_fw[idx]->fw, fw, mlen); in mtw_ucode_write()
1075 // sc->sc_fw_data[idx]->len=htole16(mlen); in mtw_ucode_write()
1079 // memcpy(sc->sc_fw_data[idx].buf, fw, mlen); in mtw_ucode_write()
1082 len -= mlen; in mtw_ucode_write()
1086 sc->sc_sent = 0; in mtw_ucode_write()
1087 memcpy(sc->sc_ivb_1, ivb, MTW_MCU_IVB_LEN); in mtw_ucode_write()
1089 usbd_transfer_start(sc->sc_xfer[7]); in mtw_ucode_write()
1107 device_printf(sc->sc_dev, "version:0x%hx\n", sc->asic_ver); in mtw_load_microcode()
1113 if (sc->asic_ver == 0x7612) { in mtw_load_microcode()
1114 fwname = "mtw-mt7662u_rom_patch"; in mtw_load_microcode()
1118 device_printf(sc->sc_dev, in mtw_load_microcode()
1123 size = firmware->datasize; in mtw_load_microcode()
1126 firmware->data; in mtw_load_microcode()
1127 hdr = (const struct mtw_ucode_hdr *)&fw->hdr; in mtw_load_microcode()
1128 // memcpy(fw,(const unsigned char*)firmware->data + in mtw_load_microcode()
1129 // 0x1e,size-0x1e); in mtw_load_microcode()
1130 ilen = size - 0x1e; in mtw_load_microcode()
1134 if ((error = mtw_ucode_write(sc, firmware->data, fw->ivb, ilen, in mtw_load_microcode()
1144 if (sc->asic_ver == 0x7612) { in mtw_load_microcode()
1145 fwname = "mtw-mt7662u"; in mtw_load_microcode()
1148 } else if (sc->asic_ver == 0x7610) { in mtw_load_microcode()
1156 device_printf(sc->sc_dev, in mtw_load_microcode()
1163 size = firmware->datasize; in mtw_load_microcode()
1165 const struct mtw_ucode *fw = (const struct mtw_ucode *)firmware->data; in mtw_load_microcode()
1168 device_printf(sc->sc_dev, "firmware header too short\n"); in mtw_load_microcode()
1172 hdr = (const struct mtw_ucode_hdr *)&fw->hdr; in mtw_load_microcode()
1174 if (size < sizeof(struct mtw_ucode_hdr) + le32toh(hdr->ilm_len) + in mtw_load_microcode()
1175 le32toh(hdr->dlm_len)) { in mtw_load_microcode()
1176 device_printf(sc->sc_dev, "firmware payload too short\n"); in mtw_load_microcode()
1180 ilen = le32toh(hdr->ilm_len) - MTW_MCU_IVB_LEN; in mtw_load_microcode()
1181 dlen = le32toh(hdr->dlm_len); in mtw_load_microcode()
1184 device_printf(sc->sc_dev, "firmware payload too large\n"); in mtw_load_microcode()
1192 if ((error = mtw_ucode_write(sc, fw->data, fw->ivb, ilen, iofs)) != 0) in mtw_load_microcode()
1193 device_printf(sc->sc_dev, "Could not write ucode errro=%d\n", in mtw_load_microcode()
1196 device_printf(sc->sc_dev, "loaded firmware ver %.8x %.8x %s\n", in mtw_load_microcode()
1197 le32toh(hdr->fw_ver), le32toh(hdr->build_ver), hdr->build_time); in mtw_load_microcode()
1211 while (ntries--) { in mtw_do_request()
1212 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, req, data, in mtw_do_request()
1213 0, NULL, 2000); // ms seconds in mtw_do_request()
1262 return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)); in mtw_write_2()
1289 return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, buf)); in mtw_write_region_1()
1316 * Read one 16-byte block into registers EFUSE_DATA[0-3]: in mtw_efuse_read_2()
1339 // determine to which 32-bit register our 16-bit word belongs in mtw_efuse_read_2()
1352 return (sc->sc_srom_read(sc, addr, val)); in mtw_srom_read()
1409 sc->sc_idx = 0; in mtw_mcu_cmd()
1410 sc->txd_fw[sc->sc_idx]->len = htole16( in mtw_mcu_cmd()
1412 sc->txd_fw[sc->sc_idx]->flags = htole16(MTW_TXD_CMD | MTW_TXD_MCU | in mtw_mcu_cmd()
1415 memset(&sc->txd_fw[sc->sc_idx]->fw, 0, 2004); in mtw_mcu_cmd()
1416 memcpy(&sc->txd_fw[sc->sc_idx]->fw, buf, len); in mtw_mcu_cmd()
1417 usbd_transfer_start(sc->sc_xfer[7]); in mtw_mcu_cmd()
1422 * Add `delta' (signed) to each 4-bit sub-word of a 32-bit word.
1423 * Used to adjust per-rate Tx power registers.
1450 sc->txpow1[i + 0] = (int8_t)(val & 0xff); in mtw_get_txpower()
1451 sc->txpow1[i + 1] = (int8_t)(val >> 8); in mtw_get_txpower()
1453 sc->txpow2[i + 0] = (int8_t)(val & 0xff); in mtw_get_txpower()
1454 sc->txpow2[i + 1] = (int8_t)(val >> 8); in mtw_get_txpower()
1458 if (sc->txpow1[i] < 0 || sc->txpow1[i] > 27) in mtw_get_txpower()
1459 sc->txpow1[i] = 5; in mtw_get_txpower()
1460 if (sc->txpow2[i] < 0 || sc->txpow2[i] > 27) in mtw_get_txpower()
1461 sc->txpow2[i] = 5; in mtw_get_txpower()
1464 sc->txpow1[i], sc->txpow2[i]); in mtw_get_txpower()
1477 struct ieee80211com *ic = &sc->sc_ic; in mtw_read_eeprom()
1482 sc->sc_srom_read = mtw_efuse_read_2; in mtw_read_eeprom()
1486 sc->rf_rev = val; in mtw_read_eeprom()
1488 sc->ntxchains = (val >> 4) & 0xf; in mtw_read_eeprom()
1489 sc->nrxchains = val & 0xf; in mtw_read_eeprom()
1491 sc->rf_rev, sc->ntxchains, sc->nrxchains); in mtw_read_eeprom()
1500 ic->ic_macaddr[0] = val & 0xff; in mtw_read_eeprom()
1501 ic->ic_macaddr[1] = val >> 8; in mtw_read_eeprom()
1503 ic->ic_macaddr[2] = val & 0xff; in mtw_read_eeprom()
1504 ic->ic_macaddr[3] = val >> 8; in mtw_read_eeprom()
1506 ic->ic_macaddr[4] = val & 0xff; in mtw_read_eeprom()
1507 ic->ic_macaddr[5] = val >> 8; in mtw_read_eeprom()
1520 device_printf(sc->sc_dev, "EEPROM CFG 0x%04x\n", val); in mtw_read_eeprom()
1522 sc->ext_5ghz_lna = (val >> 3) & 1; in mtw_read_eeprom()
1523 sc->ext_2ghz_lna = (val >> 2) & 1; in mtw_read_eeprom()
1525 sc->calib_2ghz = sc->calib_5ghz = (val >> 1) & 1; in mtw_read_eeprom()
1527 sc->rfswitch = val & 1; in mtw_read_eeprom()
1533 sc->rf_freq_offset = val; in mtw_read_eeprom()
1535 sc->rf_freq_offset = 0; in mtw_read_eeprom()
1537 sc->rf_freq_offset); in mtw_read_eeprom()
1548 delta_2ghz = -delta_2ghz; in mtw_read_eeprom()
1554 delta_5ghz = -delta_5ghz; in mtw_read_eeprom()
1568 sc->txpow20mhz[ridx] = reg; in mtw_read_eeprom()
1569 sc->txpow40mhz_2ghz[ridx] = b4inc(reg, delta_2ghz); in mtw_read_eeprom()
1570 sc->txpow40mhz_5ghz[ridx] = b4inc(reg, delta_5ghz); in mtw_read_eeprom()
1575 ridx, sc->txpow20mhz[ridx], sc->txpow40mhz_2ghz[ridx], in mtw_read_eeprom()
1576 sc->txpow40mhz_5ghz[ridx]); in mtw_read_eeprom()
1582 sc->rssi_2ghz[0] = val & 0xff; /* Ant A */ in mtw_read_eeprom()
1583 sc->rssi_2ghz[1] = val >> 8; /* Ant B */ in mtw_read_eeprom()
1590 sc->txmixgain_2ghz = val & 0x7; in mtw_read_eeprom()
1592 sc->txmixgain_2ghz); in mtw_read_eeprom()
1593 sc->lna[2] = val >> 8; /* channel group 2 */ in mtw_read_eeprom()
1595 sc->rssi_5ghz[0] = val & 0xff; /* Ant A */ in mtw_read_eeprom()
1596 sc->rssi_5ghz[1] = val >> 8; /* Ant B */ in mtw_read_eeprom()
1598 sc->rssi_5ghz[2] = val & 0xff; /* Ant C */ in mtw_read_eeprom()
1600 sc->lna[3] = val >> 8; /* channel group 3 */ in mtw_read_eeprom()
1603 sc->lna[0] = val & 0xff; /* channel group 0 */ in mtw_read_eeprom()
1604 sc->lna[1] = val >> 8; /* channel group 1 */ in mtw_read_eeprom()
1605 MTW_DPRINTF(sc, MTW_DEBUG_ROM, "LNA0 0x%x\n", sc->lna[0]); in mtw_read_eeprom()
1608 if (sc->lna[2] == 0 || sc->lna[2] == 0xff) { in mtw_read_eeprom()
1611 sc->lna[2] = sc->lna[1]; in mtw_read_eeprom()
1613 if (sc->lna[3] == 0 || sc->lna[3] == 0xff) { in mtw_read_eeprom()
1616 sc->lna[3] = sc->lna[1]; in mtw_read_eeprom()
1621 if (sc->rssi_2ghz[ant] < -10 || sc->rssi_2ghz[ant] > 10) { in mtw_read_eeprom()
1624 sc->rssi_2ghz[ant]); in mtw_read_eeprom()
1625 sc->rssi_2ghz[ant] = 0; in mtw_read_eeprom()
1627 if (sc->rssi_5ghz[ant] < -10 || sc->rssi_5ghz[ant] > 10) { in mtw_read_eeprom()
1630 sc->rssi_5ghz[ant]); in mtw_read_eeprom()
1631 sc->rssi_5ghz[ant] = 0; in mtw_read_eeprom()
1640 struct ieee80211com *ic = vap->iv_ic; in mtw_media_change()
1642 struct mtw_softc *sc = ic->ic_softc; in mtw_media_change()
1647 //tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; in mtw_media_change()
1648 tp = &vap->iv_txparms[ic->ic_curmode]; in mtw_media_change()
1649 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { in mtw_media_change()
1654 ic->ic_sup_rates[ic->ic_curmode].rs_rates[tp->ucastrate] & in mtw_media_change()
1660 ni = ieee80211_ref_node(vap->iv_bss); in mtw_media_change()
1662 rn->fix_ridx = ridx; in mtw_media_change()
1665 rn->fix_ridx); in mtw_media_change()
1694 struct ieee80211com *ic = vap->iv_ic; in mtw_newstate()
1695 struct mtw_softc *sc = ic->ic_softc; in mtw_newstate()
1701 uint8_t bid = 1 << rvp->rvp_id; in mtw_newstate()
1704 ostate = vap->iv_state; in mtw_newstate()
1705 MTW_DPRINTF(sc, MTW_DEBUG_STATE, "%s -> %s\n", in mtw_newstate()
1709 ratectl = sc->ratectl_run; /* remember current state */ in mtw_newstate()
1710 usb_callout_stop(&sc->ratectl_ch); in mtw_newstate()
1711 sc->ratectl_run = MTW_RATECTL_OFF; in mtw_newstate()
1723 sc->runbmap &= ~bid; in mtw_newstate()
1726 if (--sc->running == 0) in mtw_newstate()
1731 if (!(sc->runbmap & bid)) { in mtw_newstate()
1732 if (sc->running++) in mtw_newstate()
1734 sc->runbmap |= bid; in mtw_newstate()
1737 m_freem(rvp->beacon_mbuf); in mtw_newstate()
1738 rvp->beacon_mbuf = NULL; in mtw_newstate()
1740 switch (vap->iv_opmode) { in mtw_newstate()
1743 sc->ap_running |= bid; in mtw_newstate()
1744 ic->ic_opmode = vap->iv_opmode; in mtw_newstate()
1748 sc->adhoc_running |= bid; in mtw_newstate()
1749 if (!sc->ap_running) in mtw_newstate()
1750 ic->ic_opmode = vap->iv_opmode; in mtw_newstate()
1754 sc->sta_running |= bid; in mtw_newstate()
1755 if (!sc->ap_running && !sc->adhoc_running) in mtw_newstate()
1756 ic->ic_opmode = vap->iv_opmode; in mtw_newstate()
1764 ic->ic_opmode = vap->iv_opmode; in mtw_newstate()
1768 if (vap->iv_opmode != IEEE80211_M_MONITOR) { in mtw_newstate()
1771 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { in mtw_newstate()
1774 return (-1); in mtw_newstate()
1780 ni = ieee80211_ref_node(vap->iv_bss); in mtw_newstate()
1781 IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid); in mtw_newstate()
1782 mtw_set_bssid(sc, sc->sc_bssid); in mtw_newstate()
1787 tp = &vap->iv_txparms[ieee80211_chan2mode( in mtw_newstate()
1788 ic->ic_curchan)]; in mtw_newstate()
1789 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) in mtw_newstate()
1802 if ((sc->ratectl_run = ratectl) && restart_ratectl) { in mtw_newstate()
1803 usb_callout_reset(&sc->ratectl_ch, hz, mtw_ratectl_to, sc); in mtw_newstate()
1807 return (rvp->newstate(vap, nstate, arg)); in mtw_newstate()
1814 struct mtw_softc *sc = ic->ic_softc; in mtw_wme_update()
1866 struct ieee80211com *ic = vap->iv_ic; in mtw_key_set()
1867 struct mtw_softc *sc = ic->ic_softc; in mtw_key_set()
1870 i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_key_set()
1872 sc->cmdq[i].func = mtw_key_set_cb; in mtw_key_set()
1873 sc->cmdq[i].arg0 = NULL; in mtw_key_set()
1874 sc->cmdq[i].arg1 = vap; in mtw_key_set()
1875 sc->cmdq[i].k = k; in mtw_key_set()
1876 IEEE80211_ADDR_COPY(sc->cmdq[i].mac, k->wk_macaddr); in mtw_key_set()
1877 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_key_set()
1883 if (vap->iv_opmode == IEEE80211_M_HOSTAP) { in mtw_key_set()
1885 sc->cmdq_key_set = MTW_CMDQ_GO; in mtw_key_set()
1895 struct ieee80211vap *vap = cmdq->arg1; in mtw_key_set_cb()
1896 struct ieee80211_key *k = cmdq->k; in mtw_key_set_cb()
1897 struct ieee80211com *ic = vap->iv_ic; in mtw_key_set_cb()
1898 struct mtw_softc *sc = ic->ic_softc; in mtw_key_set_cb()
1900 u_int cipher = k->wk_cipher->ic_cipher; in mtw_key_set_cb()
1906 if (vap->iv_opmode == IEEE80211_M_HOSTAP) in mtw_key_set_cb()
1907 ni = ieee80211_find_vap_node(&ic->ic_sta, vap, cmdq->mac); in mtw_key_set_cb()
1909 ni = vap->iv_bss; in mtw_key_set_cb()
1914 if (k->wk_keylen < 8) in mtw_key_set_cb()
1930 if (k->wk_flags & IEEE80211_KEY_GROUP) { in mtw_key_set_cb()
1932 base = MTW_SKEY(0, k->wk_keyix); in mtw_key_set_cb()
1934 wcid = (ni != NULL) ? MTW_AID2WCID(ni->ni_associd) : 0; in mtw_key_set_cb()
1939 mtw_write_region_1(sc, base, k->wk_key, 16); in mtw_key_set_cb()
1940 mtw_write_region_1(sc, base + 16, &k->wk_key[24], 8); in mtw_key_set_cb()
1941 mtw_write_region_1(sc, base + 24, &k->wk_key[16], 8); in mtw_key_set_cb()
1943 /* roundup len to 16-bit: XXX fix write_region_1() instead */ in mtw_key_set_cb()
1944 mtw_write_region_1(sc, base, k->wk_key, in mtw_key_set_cb()
1945 (k->wk_keylen + 1) & ~1); in mtw_key_set_cb()
1948 if (!(k->wk_flags & IEEE80211_KEY_GROUP) || in mtw_key_set_cb()
1949 (k->wk_flags & (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV))) { in mtw_key_set_cb()
1953 iv[3] = vap->iv_def_txkey << 6; in mtw_key_set_cb()
1956 iv[0] = k->wk_keytsc >> 8; in mtw_key_set_cb()
1958 iv[2] = k->wk_keytsc; in mtw_key_set_cb()
1960 iv[0] = k->wk_keytsc; in mtw_key_set_cb()
1961 iv[1] = k->wk_keytsc >> 8; in mtw_key_set_cb()
1964 iv[3] = k->wk_keyix << 6 | IEEE80211_WEP_EXTIV; in mtw_key_set_cb()
1965 iv[4] = k->wk_keytsc >> 16; in mtw_key_set_cb()
1966 iv[5] = k->wk_keytsc >> 24; in mtw_key_set_cb()
1967 iv[6] = k->wk_keytsc >> 32; in mtw_key_set_cb()
1968 iv[7] = k->wk_keytsc >> 40; in mtw_key_set_cb()
1973 if (k->wk_flags & IEEE80211_KEY_GROUP) { in mtw_key_set_cb()
1976 attr &= ~(0xf << (k->wk_keyix * 4)); in mtw_key_set_cb()
1977 attr |= mode << (k->wk_keyix * 4); in mtw_key_set_cb()
1997 k->wk_pad = wcid; in mtw_key_set_cb()
2009 struct mtw_softc *sc = cmdq->arg1; in mtw_key_delete_cb()
2010 struct ieee80211_key *k = &cmdq->key; in mtw_key_delete_cb()
2016 if (k->wk_flags & IEEE80211_KEY_GROUP) { in mtw_key_delete_cb()
2020 attr &= ~(0xf << (k->wk_keyix * 4)); in mtw_key_delete_cb()
2025 k->wk_pad); in mtw_key_delete_cb()
2027 wcid = k->wk_pad; in mtw_key_delete_cb()
2033 k->wk_pad = 0; in mtw_key_delete_cb()
2042 struct ieee80211com *ic = vap->iv_ic; in mtw_key_delete()
2043 struct mtw_softc *sc = ic->ic_softc; in mtw_key_delete()
2046 if (sc->sc_flags & MTW_RUNNING) in mtw_key_delete()
2055 i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_key_delete()
2057 sc->cmdq[i].func = mtw_key_delete_cb; in mtw_key_delete()
2058 sc->cmdq[i].arg0 = NULL; in mtw_key_delete()
2059 sc->cmdq[i].arg1 = sc; in mtw_key_delete()
2060 k0 = &sc->cmdq[i].key; in mtw_key_delete()
2061 k0->wk_flags = k->wk_flags; in mtw_key_delete()
2062 k0->wk_keyix = k->wk_keyix; in mtw_key_delete()
2064 k0->wk_pad = k->wk_pad; in mtw_key_delete()
2065 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_key_delete()
2074 ieee80211_runtask(&sc->sc_ic, &sc->ratectl_task); in mtw_ratectl_to()
2075 /* next timeout will be rescheduled in the callback task */ in mtw_ratectl_to()
2084 struct ieee80211com *ic = &sc->sc_ic; in mtw_ratectl_cb()
2085 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in mtw_ratectl_cb()
2090 ieee80211_iterate_nodes(&ic->ic_sta, mtw_iter_func, sc); in mtw_ratectl_cb()
2092 usb_callout_reset(&sc->ratectl_ch, hz, mtw_ratectl_to, sc); in mtw_ratectl_cb()
2123 * Even though each stat is Tx-complete-status like format, in mtw_drain_fifo()
2133 wstat = &(sc->wcid_stats[wcid]); in mtw_drain_fifo()
2138 counter_u64_add(sc->sc_ic.ic_oerrors, 1); in mtw_drain_fifo()
2146 if ((retry = pid - 1 - mcs) > 0) { in mtw_drain_fifo()
2151 MTW_DPRINTF(sc, MTW_DEBUG_XMIT, "count=%d\n", sc->fifo_cnt); in mtw_drain_fifo()
2153 sc->fifo_cnt = 0; in mtw_drain_fifo()
2161 struct ieee80211_ratectl_tx_stats *txs = &sc->sc_txs; in mtw_iter_func()
2162 struct ieee80211vap *vap = ni->ni_vap; in mtw_iter_func()
2170 if (sc->rvp_cnt <= 1 && vap->iv_opmode == IEEE80211_M_STA && in mtw_iter_func()
2171 ni != vap->iv_bss) in mtw_iter_func()
2174 txs->flags = IEEE80211_RATECTL_TX_STATS_NODE | in mtw_iter_func()
2176 txs->ni = ni; in mtw_iter_func()
2177 if (sc->rvp_cnt <= 1 && in mtw_iter_func()
2178 (vap->iv_opmode == IEEE80211_M_IBSS || in mtw_iter_func()
2179 vap->iv_opmode == IEEE80211_M_STA)) { in mtw_iter_func()
2190 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, in mtw_iter_func()
2193 txs->nretries = (le32toh(sta[1]) >> 16); in mtw_iter_func()
2194 txs->nsuccess = (le32toh(sta[1]) & 0xffff); in mtw_iter_func()
2196 txs->nframes = txs->nsuccess + (le32toh(sta[0]) & 0xffff); in mtw_iter_func()
2199 "retrycnt=%d success=%d failcnt=%d\n", txs->nretries, in mtw_iter_func()
2200 txs->nsuccess, le32toh(sta[0]) & 0xffff); in mtw_iter_func()
2202 wstat = &(sc->wcid_stats[MTW_AID2WCID(ni->ni_associd)]); in mtw_iter_func()
2204 if (wstat == &(sc->wcid_stats[0]) || in mtw_iter_func()
2205 wstat > &(sc->wcid_stats[MTW_WCID_MAX])) in mtw_iter_func()
2208 txs->nretries = (*wstat)[MTW_RETRY]; in mtw_iter_func()
2209 txs->nsuccess = (*wstat)[MTW_SUCCESS]; in mtw_iter_func()
2210 txs->nframes = (*wstat)[MTW_TXCNT]; in mtw_iter_func()
2212 "wstat retrycnt=%d txcnt=%d success=%d\n", txs->nretries, in mtw_iter_func()
2213 txs->nframes, txs->nsuccess); in mtw_iter_func()
2230 rn->amrr_ridx = ridx; in mtw_iter_func()
2235 txrate, rn->amrr_ridx); in mtw_iter_func()
2242 struct ieee80211_node *ni = cmdq->arg1; in mtw_newassoc_cb()
2243 struct mtw_softc *sc = ni->ni_vap->iv_ic->ic_softc; in mtw_newassoc_cb()
2245 uint8_t wcid = cmdq->wcid; in mtw_newassoc_cb()
2249 mtw_write_region_1(sc, MTW_WCID_ENTRY(wcid), ni->ni_macaddr, in mtw_newassoc_cb()
2252 memset(&(sc->wcid_stats[wcid]), 0, sizeof(sc->wcid_stats[wcid])); in mtw_newassoc_cb()
2260 struct ieee80211vap *vap = ni->ni_vap; in mtw_newassoc()
2261 struct ieee80211com *ic = vap->iv_ic; in mtw_newassoc()
2262 struct mtw_softc *sc = ic->ic_softc; in mtw_newassoc()
2269 wcid = MTW_AID2WCID(ni->ni_associd); in mtw_newassoc()
2272 device_printf(sc->sc_dev, "wcid=%d out of range\n", wcid); in mtw_newassoc()
2277 if (isnew && ni->ni_associd != 0) { in mtw_newassoc()
2279 * This function could is called though timeout function. in mtw_newassoc()
2283 uint32_t cnt = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_newassoc()
2285 sc->cmdq[cnt].func = mtw_newassoc_cb; in mtw_newassoc()
2286 sc->cmdq[cnt].arg0 = NULL; in mtw_newassoc()
2287 sc->cmdq[cnt].arg1 = ni; in mtw_newassoc()
2288 sc->cmdq[cnt].wcid = wcid; in mtw_newassoc()
2289 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_newassoc()
2293 "new assoc isnew=%d associd=%x addr=%s\n", isnew, ni->ni_associd, in mtw_newassoc()
2294 ether_sprintf(ni->ni_macaddr)); in mtw_newassoc()
2295 rate = vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)].mgmtrate; in mtw_newassoc()
2300 mn->mgt_ridx = ridx; in mtw_newassoc()
2304 if (sc->ratectl_run != MTW_RATECTL_OFF) { in mtw_newassoc()
2305 usb_callout_reset(&sc->ratectl_ch, hz, &mtw_ratectl_to, sc); in mtw_newassoc()
2319 if (sc->nrxchains > 1) { in mtw_maxrssi_chain()
2320 if (rxwi->rssi[1] > rxwi->rssi[rxchain]) in mtw_maxrssi_chain()
2322 if (sc->nrxchains > 2) in mtw_maxrssi_chain()
2323 if (rxwi->rssi[2] > rxwi->rssi[rxchain]) in mtw_maxrssi_chain()
2338 struct ieee80211vap *vap = ni->ni_vap; in mtw_recv_mgmt()
2339 struct mtw_softc *sc = vap->iv_ic->ic_softc; in mtw_recv_mgmt()
2343 rvp->recv_mgmt(ni, m, subtype, rxs, rssi, nf); in mtw_recv_mgmt()
2345 if (vap->iv_state == IEEE80211_S_RUN && in mtw_recv_mgmt()
2348 ni_tstamp = le64toh(ni->ni_tstamp.tsf); in mtw_recv_mgmt()
2365 struct ieee80211com *ic = &sc->sc_ic; in mtw_rx_frame()
2387 len = le16toh(rxwi->len) & 0xfff; in mtw_rx_frame()
2388 flags = le32toh(rxwi->flags); in mtw_rx_frame()
2389 if (__predict_false(len > dmalen - rxwisize)) { in mtw_rx_frame()
2407 m->m_data += rxwisize; in mtw_rx_frame()
2408 m->m_pkthdr.len = m->m_len = len; in mtw_rx_frame()
2411 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in mtw_rx_frame()
2412 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in mtw_rx_frame()
2413 m->m_flags |= M_WEP; in mtw_rx_frame()
2422 if (ni && ni->ni_flags & IEEE80211_NODE_HT) { in mtw_rx_frame()
2423 m->m_flags |= M_AMPDU; in mtw_rx_frame()
2429 ieee80211_notify_michael_failure(ni->ni_vap, wh, in mtw_rx_frame()
2430 rxwi->keyidx); in mtw_rx_frame()
2437 rssi = rxwi->rssi[ant]; in mtw_rx_frame()
2441 struct mtw_rx_radiotap_header *tap = &sc->sc_rxtap; in mtw_rx_frame() local
2444 tap->wr_flags = 0; in mtw_rx_frame()
2446 tap->wr_flags |= IEEE80211_RADIOTAP_F_DATAPAD; in mtw_rx_frame()
2447 tap->wr_antsignal = rssi; in mtw_rx_frame()
2448 tap->wr_antenna = ant; in mtw_rx_frame()
2449 tap->wr_dbm_antsignal = mtw_rssi2dbm(sc, rssi, ant); in mtw_rx_frame()
2450 tap->wr_rate = 2; /* in case it can't be found below */ in mtw_rx_frame()
2454 phy = le16toh(rxwi->phy); in mtw_rx_frame()
2459 tap->wr_rate = 2; in mtw_rx_frame()
2462 tap->wr_rate = 4; in mtw_rx_frame()
2465 tap->wr_rate = 11; in mtw_rx_frame()
2468 tap->wr_rate = 22; in mtw_rx_frame()
2472 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in mtw_rx_frame()
2477 tap->wr_rate = 12; in mtw_rx_frame()
2480 tap->wr_rate = 18; in mtw_rx_frame()
2483 tap->wr_rate = 24; in mtw_rx_frame()
2486 tap->wr_rate = 36; in mtw_rx_frame()
2489 tap->wr_rate = 48; in mtw_rx_frame()
2492 tap->wr_rate = 72; in mtw_rx_frame()
2495 tap->wr_rate = 96; in mtw_rx_frame()
2498 tap->wr_rate = 108; in mtw_rx_frame()
2518 counter_u64_add(ic->ic_ierrors, 1); in mtw_rx_frame()
2525 struct ieee80211com *ic = &sc->sc_ic; in mtw_bulk_rx_callback()
2549 m = sc->rx_m; in mtw_bulk_rx_callback()
2550 sc->rx_m = NULL; in mtw_bulk_rx_callback()
2556 if (sc->rx_m == NULL) { in mtw_bulk_rx_callback()
2557 sc->rx_m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, in mtw_bulk_rx_callback()
2560 if (sc->rx_m == NULL) { in mtw_bulk_rx_callback()
2564 "could not allocate mbuf - idle with stall\n"); in mtw_bulk_rx_callback()
2565 counter_u64_add(ic->ic_ierrors, 1); in mtw_bulk_rx_callback()
2575 mtod(sc->rx_m, caddr_t), MTW_MAX_RXSZ); in mtw_bulk_rx_callback()
2589 device_printf(sc->sc_dev, "device timeout %s\n", in mtw_bulk_rx_callback()
2591 counter_u64_add(ic->ic_ierrors, 1); in mtw_bulk_rx_callback()
2594 if (sc->rx_m != NULL) { in mtw_bulk_rx_callback()
2595 m_freem(sc->rx_m); in mtw_bulk_rx_callback()
2596 sc->rx_m = NULL; in mtw_bulk_rx_callback()
2608 m->m_pkthdr.len = m->m_len = xferlen; in mtw_bulk_rx_callback()
2614 if ((dmalen >= (uint32_t)-8) || (dmalen == 0) || in mtw_bulk_rx_callback()
2627 if ((xferlen -= dmalen + 8) <= 8) { in mtw_bulk_rx_callback()
2628 /* trim 32-bit DMA-len header */ in mtw_bulk_rx_callback()
2629 m->m_data += 4; in mtw_bulk_rx_callback()
2630 m->m_pkthdr.len = m->m_len -= 4; in mtw_bulk_rx_callback()
2640 counter_u64_add(ic->ic_ierrors, 1); in mtw_bulk_rx_callback()
2649 counter_u64_add(ic->ic_ierrors, 1); in mtw_bulk_rx_callback()
2652 m_copydata(m, 4 /* skip 32-bit DMA-len header */, mbuf_len, in mtw_bulk_rx_callback()
2654 m0->m_pkthdr.len = m0->m_len = mbuf_len; in mtw_bulk_rx_callback()
2658 m->m_data += mbuf_len + 4; in mtw_bulk_rx_callback()
2659 m->m_pkthdr.len = m->m_len -= mbuf_len + 4; in mtw_bulk_rx_callback()
2675 ieee80211_tx_complete(data->ni, data->m, txerr); in mtw_tx_free()
2676 data->m = NULL; in mtw_tx_free()
2677 data->ni = NULL; in mtw_tx_free()
2679 STAILQ_INSERT_TAIL(&pq->tx_fh, data, next); in mtw_tx_free()
2680 pq->tx_nfree++; in mtw_tx_free()
2686 struct ieee80211com *ic = &sc->sc_ic; in mtw_bulk_tx_callbackN()
2690 struct mtw_endpoint_queue *pq = &sc->sc_epq[index]; in mtw_bulk_tx_callbackN()
2709 data = STAILQ_FIRST(&pq->tx_qh); in mtw_bulk_tx_callbackN()
2713 STAILQ_REMOVE_HEAD(&pq->tx_qh, next); in mtw_bulk_tx_callbackN()
2715 m = data->m; in mtw_bulk_tx_callbackN()
2717 size = sizeof(data->desc); in mtw_bulk_tx_callbackN()
2718 if ((m->m_pkthdr.len + size + 3 + 8) > MTW_MAX_TXSZ) { in mtw_bulk_tx_callbackN()
2720 "data overflow, %u bytes\n", m->m_pkthdr.len); in mtw_bulk_tx_callbackN()
2726 usbd_copy_in(pc, 0, &data->desc, size); in mtw_bulk_tx_callbackN()
2727 usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len); in mtw_bulk_tx_callbackN()
2728 size += m->m_pkthdr.len; in mtw_bulk_tx_callbackN()
2730 * Align end on a 4-byte boundary, pad 8 bytes (CRC + in mtw_bulk_tx_callbackN()
2731 * 4-byte padding), and be sure to zero those trailing in mtw_bulk_tx_callbackN()
2734 usbd_frame_zero(pc, size, ((-size) & 3) + MTW_DMA_PAD); in mtw_bulk_tx_callbackN()
2735 size += ((-size) & 3) + MTW_DMA_PAD; in mtw_bulk_tx_callbackN()
2737 vap = data->ni->ni_vap; in mtw_bulk_tx_callbackN()
2740 struct mtw_tx_radiotap_header *tap = &sc->sc_txtap; in mtw_bulk_tx_callbackN() local
2742 (struct mtw_txwi *)(&data->desc + in mtw_bulk_tx_callbackN()
2750 tap->wt_flags = 0; in mtw_bulk_tx_callbackN()
2751 tap->wt_rate = rt2860_rates[data->ridx].rate; in mtw_bulk_tx_callbackN()
2752 tap->wt_hwqueue = index; in mtw_bulk_tx_callbackN()
2753 if (le16toh(txwi->phy) & MTW_PHY_SHPRE) in mtw_bulk_tx_callbackN()
2754 tap->wt_flags |= IEEE80211_RADIOTAP_F_SHORTPRE; in mtw_bulk_tx_callbackN()
2756 tap->wt_flags |= IEEE80211_RADIOTAP_F_DATAPAD; in mtw_bulk_tx_callbackN()
2762 "sending frame len=%u/%u @ index %d\n", m->m_pkthdr.len, in mtw_bulk_tx_callbackN()
2779 if (data->ni != NULL) in mtw_bulk_tx_callbackN()
2780 vap = data->ni->ni_vap; in mtw_bulk_tx_callbackN()
2786 vap = TAILQ_FIRST(&ic->ic_vaps); in mtw_bulk_tx_callbackN()
2790 device_printf(sc->sc_dev, "device timeout %s\n", in mtw_bulk_tx_callbackN()
2792 uint32_t i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_bulk_tx_callbackN()
2795 sc->cmdq[i].func = mtw_usb_timeout_cb; in mtw_bulk_tx_callbackN()
2796 sc->cmdq[i].arg0 = vap; in mtw_bulk_tx_callbackN()
2797 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_bulk_tx_callbackN()
2803 * introduces a 50 ms delay: in mtw_bulk_tx_callbackN()
2813 if (pq->tx_nfree >= MTW_TX_RING_COUNT) { in mtw_bulk_tx_callbackN()
2836 sc->sc_sent += actlen; in mtw_fw_callback()
2837 memset(sc->txd_fw[sc->sc_idx], 0, actlen); in mtw_fw_callback()
2839 if (actlen < 0x2c44 && sc->sc_idx == 0) { in mtw_fw_callback()
2842 if (sc->sc_idx == 3) { in mtw_fw_callback()
2844 if ((error = mtw_write_ivb(sc, sc->sc_ivb_1, in mtw_fw_callback()
2846 device_printf(sc->sc_dev, in mtw_fw_callback()
2854 device_printf(sc->sc_dev, in mtw_fw_callback()
2861 sc->fwloading = 1; in mtw_fw_callback()
2868 sc->fwloading = 0; in mtw_fw_callback()
2869 wakeup(&sc->fwloading); in mtw_fw_callback()
2874 sc->sc_idx++; in mtw_fw_callback()
2880 dlen = sc->txd_fw[sc->sc_idx]->len; in mtw_fw_callback()
2882 mtw_write_cfg(sc, MTW_MCU_DMA_ADDR, 0x40 + sc->sc_sent); in mtw_fw_callback()
2886 usbd_xfer_set_frame_data(xfer, 0, sc->txd_fw[sc->sc_idx], dlen); in mtw_fw_callback()
2888 // usbd_xfer_set_priv(xfer,sc->txd[sc->sc_idx]); in mtw_fw_callback()
2893 device_printf(sc->sc_dev, "%s:%d %s\n", __FILE__, __LINE__, in mtw_fw_callback()
2895 sc->fwloading = 0; in mtw_fw_callback()
2896 wakeup(&sc->fwloading); in mtw_fw_callback()
2951 struct mbuf *m = data->m; in mtw_set_tx_desc()
2952 struct ieee80211com *ic = &sc->sc_ic; in mtw_set_tx_desc()
2953 struct ieee80211vap *vap = data->ni->ni_vap; in mtw_set_tx_desc()
2959 uint8_t ridx = data->ridx; in mtw_set_tx_desc()
2966 xferlen = txwisize + m->m_pkthdr.len; in mtw_set_tx_desc()
2968 /* roundup to 32-bit alignment */ in mtw_set_tx_desc()
2971 txd = (struct mtw_txd *)&data->desc; in mtw_set_tx_desc()
2972 txd->len = htole16(xferlen); in mtw_set_tx_desc()
2978 * are nicely aligned to 32-bit. So, no L2 padding. in mtw_set_tx_desc()
2987 txwi->len = htole16(m->m_pkthdr.len - pad); in mtw_set_tx_desc()
2991 (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) in mtw_set_tx_desc()
2999 txwi->phy = htole16(mcs); in mtw_set_tx_desc()
3001 /* check if RTS/CTS or CTS-to-self protection is required */ in mtw_set_tx_desc()
3002 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && in mtw_set_tx_desc()
3003 ((m->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) || in mtw_set_tx_desc()
3004 ((ic->ic_flags & IEEE80211_F_USEPROT) && in mtw_set_tx_desc()
3006 ((ic->ic_htprotmode == IEEE80211_PROT_RTSCTS) && in mtw_set_tx_desc()
3008 txwi->txop |= MTW_TX_TXOP_HT; in mtw_set_tx_desc()
3010 txwi->txop |= MTW_TX_TXOP_BACKOFF; in mtw_set_tx_desc()
3018 struct ieee80211com *ic = &sc->sc_ic; in mtw_tx()
3019 struct ieee80211vap *vap = ni->ni_vap; in mtw_tx()
3023 //const struct ieee80211_txparam *tp = ni->ni_txparms; in mtw_tx()
3043 const struct ieee80211_txparam *tp = ni->ni_txparms; in mtw_tx()
3044 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in mtw_tx()
3054 //device_printf(sc->sc_dev,"JSS:frm:%d",*frm); in mtw_tx()
3071 if (IEEE80211_IS_MULTICAST(wh->i_addr1) || in mtw_tx()
3072 type != IEEE80211_FC0_TYPE_DATA || m->m_flags & M_EAPOL) { in mtw_tx()
3074 ridx = (ic->ic_curmode == IEEE80211_MODE_11A in mtw_tx()
3075 || ic->ic_curmode == IEEE80211_MODE_11NA) ? in mtw_tx()
3082 if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { in mtw_tx()
3083 ridx = rn->fix_ridx; in mtw_tx()
3086 ridx = rn->amrr_ridx; in mtw_tx()
3096 if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && in mtw_tx()
3101 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) in mtw_tx()
3105 USETW(wh->i_dur, dur); in mtw_tx()
3108 if (sc->sc_epq[qid].tx_nfree < 3) { in mtw_tx()
3110 return (-1); in mtw_tx()
3113 data = STAILQ_FIRST(&sc->sc_epq[qid].tx_fh); in mtw_tx()
3114 STAILQ_REMOVE_HEAD(&sc->sc_epq[qid].tx_fh, next); in mtw_tx()
3115 sc->sc_epq[qid].tx_nfree--; in mtw_tx()
3117 txd = (struct mtw_txd *)&data->desc; in mtw_tx()
3118 txd->flags = qflags; in mtw_tx()
3121 txwi->xflags = xflags; in mtw_tx()
3122 txwi->wcid = (type == IEEE80211_FC0_TYPE_DATA) ? in mtw_tx()
3124 MTW_AID2WCID(ni->ni_associd) : in mtw_tx()
3128 txwi->flags = 0; in mtw_tx()
3129 txwi->txop = 0; in mtw_tx()
3131 data->m = m; in mtw_tx()
3132 data->ni = ni; in mtw_tx()
3133 data->ridx = ridx; in mtw_tx()
3135 ieee80211_output_seqno_assign(ni, -1, m); in mtw_tx()
3142 * * TX_STA_CNT0 for all-TX-in-one stats. in mtw_tx()
3144 * To use FIFO stats, we need to store MCS into the driver-private in mtw_tx()
3155 if (sc->rvp_cnt > 1 || vap->iv_opmode == IEEE80211_M_HOSTAP || in mtw_tx()
3156 vap->iv_opmode == IEEE80211_M_MBSS) { in mtw_tx()
3160 * USB devices, so we simulate FIFO-is-full interrupt here. in mtw_tx()
3161 * Ralink recommends to drain FIFO stats every 100 ms, but 16 in mtw_tx()
3169 if (sc->fifo_cnt++ == 10) { in mtw_tx()
3172 * with a non-sleepable lock, tcpinp. So, need to defer. in mtw_tx()
3174 uint32_t i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_tx()
3176 sc->cmdq[i].func = mtw_drain_fifo; in mtw_tx()
3177 sc->cmdq[i].arg0 = sc; in mtw_tx()
3178 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_tx()
3182 STAILQ_INSERT_TAIL(&sc->sc_epq[qid].tx_qh, data, next); in mtw_tx()
3183 usbd_transfer_start(sc->sc_xfer[mtw_wme_ac_xfer_map[qid]]); in mtw_tx()
3187 m->m_pkthdr.len + in mtw_tx()
3197 struct ieee80211com *ic = &sc->sc_ic; in mtw_tx_mgt()
3205 uint8_t ridx = rn->mgt_ridx; in mtw_tx_mgt()
3214 if ((wh->i_fc[0] & in mtw_tx_mgt()
3218 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in mtw_tx_mgt()
3221 dur = ieee80211_ack_duration(ic->ic_rt, rt2860_rates[ridx].rate, in mtw_tx_mgt()
3222 ic->ic_flags & IEEE80211_F_SHPREAMBLE); in mtw_tx_mgt()
3223 USETW(wh->i_dur, dur); in mtw_tx_mgt()
3225 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in mtw_tx_mgt()
3226 if (sc->sc_epq[0].tx_nfree == 0) in mtw_tx_mgt()
3229 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in mtw_tx_mgt()
3230 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in mtw_tx_mgt()
3231 sc->sc_epq[0].tx_nfree--; in mtw_tx_mgt()
3233 txd = (struct mtw_txd *)&data->desc; in mtw_tx_mgt()
3234 txd->flags = htole16( in mtw_tx_mgt()
3237 txd->flags |= htole16(MTW_TXD_WIV); in mtw_tx_mgt()
3240 txwi->wcid = 0xff; in mtw_tx_mgt()
3241 txwi->xflags = xflags; in mtw_tx_mgt()
3242 txwi->flags = wflags; in mtw_tx_mgt()
3244 txwi->txop = 0; /* clear leftover garbage bits */ in mtw_tx_mgt()
3246 data->m = m; in mtw_tx_mgt()
3247 data->ni = ni; in mtw_tx_mgt()
3248 data->ridx = ridx; in mtw_tx_mgt()
3251 m->m_pkthdr.len + in mtw_tx_mgt()
3255 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in mtw_tx_mgt()
3257 usbd_transfer_start(sc->sc_xfer[MTW_BULK_TX_BE]); in mtw_tx_mgt()
3266 struct ieee80211com *ic = ni->ni_ic; in mtw_sendprot()
3279 if (sc->sc_epq[0].tx_nfree == 0) in mtw_sendprot()
3285 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); in mtw_sendprot()
3290 protrate = ieee80211_ctl_rate(ic->ic_rt, rate); in mtw_sendprot()
3296 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in mtw_sendprot()
3297 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in mtw_sendprot()
3298 sc->sc_epq[0].tx_nfree--; in mtw_sendprot()
3300 txd = (struct mtw_txd *)&data->desc; in mtw_sendprot()
3301 txd->flags = RT2860_TX_QSEL_EDCA; in mtw_sendprot()
3303 txwi->wcid = 0xff; in mtw_sendprot()
3304 txwi->flags = wflags; in mtw_sendprot()
3305 txwi->xflags = xflags; in mtw_sendprot()
3306 txwi->txop = 0; /* clear leftover garbage bits */ in mtw_sendprot()
3308 data->m = mprot; in mtw_sendprot()
3309 data->ni = ieee80211_ref_node(ni); in mtw_sendprot()
3315 data->ridx = ridx; in mtw_sendprot()
3319 m->m_pkthdr.len, rate); in mtw_sendprot()
3321 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in mtw_sendprot()
3323 usbd_transfer_start(sc->sc_xfer[0]); in mtw_sendprot()
3332 struct ieee80211com *ic = ni->ni_ic; in mtw_tx_param()
3346 rate = params->ibp_rate0; in mtw_tx_param()
3347 if (!ieee80211_isratevalid(ic->ic_rt, rate)) { in mtw_tx_param()
3352 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) in mtw_tx_param()
3354 if (params->ibp_flags & (IEEE80211_BPF_RTS | IEEE80211_BPF_CTS)) { in mtw_tx_param()
3356 params->ibp_flags & IEEE80211_BPF_RTS ? in mtw_tx_param()
3361 device_printf(sc->sc_dev, "%s:%d %d\n", __FILE__, in mtw_tx_param()
3368 if (sc->sc_epq[0].tx_nfree == 0) { in mtw_tx_param()
3374 data = STAILQ_FIRST(&sc->sc_epq[0].tx_fh); in mtw_tx_param()
3375 STAILQ_REMOVE_HEAD(&sc->sc_epq[0].tx_fh, next); in mtw_tx_param()
3376 sc->sc_epq[0].tx_nfree--; in mtw_tx_param()
3378 txd = (struct mtw_txd *)&data->desc; in mtw_tx_param()
3379 txd->flags = htole16( in mtw_tx_param()
3381 // txd->flags = htole16(MTW_TXD_QSEL_EDCA); in mtw_tx_param()
3383 txwi->wcid = 0xff; in mtw_tx_param()
3384 txwi->xflags = xflags; in mtw_tx_param()
3385 txwi->txop = opflags; in mtw_tx_param()
3386 txwi->flags = 0; /* clear leftover garbage bits */ in mtw_tx_param()
3388 data->m = m; in mtw_tx_param()
3389 data->ni = ni; in mtw_tx_param()
3394 data->ridx = ridx; in mtw_tx_param()
3396 ieee80211_output_seqno_assign(ni, -1, m); in mtw_tx_param()
3401 m->m_pkthdr.len, rate); in mtw_tx_param()
3403 STAILQ_INSERT_TAIL(&sc->sc_epq[0].tx_qh, data, next); in mtw_tx_param()
3405 usbd_transfer_start(sc->sc_xfer[MTW_BULK_RAW_TX]); in mtw_tx_param()
3414 struct mtw_softc *sc = ni->ni_ic->ic_softc; in mtw_raw_xmit()
3418 if (!(sc->sc_flags & MTW_RUNNING)) { in mtw_raw_xmit()
3453 struct mtw_softc *sc = ic->ic_softc; in mtw_transmit()
3456 if ((sc->sc_flags & MTW_RUNNING) == 0) { in mtw_transmit()
3460 error = mbufq_enqueue(&sc->sc_snd, m); in mtw_transmit()
3479 if ((sc->sc_flags & MTW_RUNNING) == 0) { in mtw_start()
3483 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in mtw_start()
3484 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in mtw_start()
3486 mbufq_prepend(&sc->sc_snd, m); in mtw_start()
3496 struct mtw_softc *sc = ic->ic_softc; in mtw_parent()
3499 if (sc->sc_detached) { in mtw_parent()
3504 if (!(sc->sc_flags & MTW_RUNNING) && ic->ic_nrunning > 0) { in mtw_parent()
3510 if (!(sc->sc_flags & MTW_RUNNING) && ic->ic_nrunning > 0) { in mtw_parent()
3515 if ((sc->sc_flags & MTW_RUNNING) && sc->rvp_cnt <= 1 && in mtw_parent()
3516 ic->ic_nrunning == 0) { in mtw_parent()
3560 if (sc->asic_ver == 0x7601) in mtw_rf_write()
3622 if (sc->asic_ver == 0x7601) in mtw_rf_read()
3659 txpow1 = sc->txpow1[i]; in mt7601_set_chan()
3668 mtw_bbp_write(sc, 62, 0x37 - sc->lna[0]); in mt7601_set_chan()
3669 mtw_bbp_write(sc, 63, 0x37 - sc->lna[0]); in mt7601_set_chan()
3670 mtw_bbp_write(sc, 64, 0x37 - sc->lna[0]); in mt7601_set_chan()
3689 struct ieee80211com *ic = &sc->sc_ic; in mtw_set_chan()
3706 if (group != sc->sc_chan_group || !sc->sc_bw_calibrated) in mtw_set_chan()
3709 sc->sc_chan_group = group; in mtw_set_chan()
3712 if (sc->asic_ver == 0x7601) in mtw_set_chan()
3722 struct mtw_softc *sc = ic->ic_softc; in mtw_set_channel()
3725 mtw_set_chan(sc, ic->ic_curchan); in mtw_set_channel()
3735 // struct mtw_softc *sc = ic->ic_softc; in mtw_getradiocaps()
3750 struct mtw_softc *sc = ic->ic_softc; in mtw_scan_start()
3764 struct mtw_softc *sc = ic->ic_softc; in mtw_scan_end()
3769 mtw_set_bssid(sc, sc->sc_bssid); in mtw_scan_end()
3778 * (non-sleepable thread)
3783 struct ieee80211com *ic = vap->iv_ic; in mtw_update_beacon()
3784 struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off; in mtw_update_beacon()
3785 struct ieee80211_node *ni = vap->iv_bss; in mtw_update_beacon()
3786 struct mtw_softc *sc = ic->ic_softc; in mtw_update_beacon()
3805 setbit(bo->bo_flags, item); in mtw_update_beacon()
3806 if (rvp->beacon_mbuf == NULL) { in mtw_update_beacon()
3807 rvp->beacon_mbuf = ieee80211_beacon_alloc(ni); in mtw_update_beacon()
3808 if (rvp->beacon_mbuf == NULL) in mtw_update_beacon()
3811 ieee80211_beacon_update(ni, rvp->beacon_mbuf, mcast); in mtw_update_beacon()
3813 i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_update_beacon()
3815 sc->cmdq[i].func = mtw_update_beacon_cb; in mtw_update_beacon()
3816 sc->cmdq[i].arg0 = vap; in mtw_update_beacon()
3817 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_update_beacon()
3827 struct ieee80211_node *ni = vap->iv_bss; in mtw_update_beacon_cb()
3829 struct ieee80211com *ic = vap->iv_ic; in mtw_update_beacon_cb()
3830 struct mtw_softc *sc = ic->ic_softc; in mtw_update_beacon_cb()
3835 if (ni->ni_chan == IEEE80211_CHAN_ANYC) in mtw_update_beacon_cb()
3837 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) in mtw_update_beacon_cb()
3844 if (rvp->beacon_mbuf == NULL) { in mtw_update_beacon_cb()
3845 rvp->beacon_mbuf = ieee80211_beacon_alloc(ni); in mtw_update_beacon_cb()
3846 if (rvp->beacon_mbuf == NULL) in mtw_update_beacon_cb()
3849 m = rvp->beacon_mbuf; in mtw_update_beacon_cb()
3853 txwi.len = htole16(m->m_pkthdr.len); in mtw_update_beacon_cb()
3856 ridx = (ic->ic_curmode == IEEE80211_MODE_11A) ? MTW_RIDX_OFDM6 : in mtw_update_beacon_cb()
3868 (m->m_pkthdr.len + 1) & ~1); in mtw_update_beacon_cb()
3874 struct mtw_softc *sc = ic->ic_softc; in mtw_updateprot()
3877 i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_updateprot()
3879 sc->cmdq[i].func = mtw_updateprot_cb; in mtw_updateprot()
3880 sc->cmdq[i].arg0 = ic; in mtw_updateprot()
3881 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_updateprot()
3889 struct mtw_softc *sc = ic->ic_softc; in mtw_updateprot_cb()
3894 tmp |= (ic->ic_curmode == IEEE80211_MODE_11A) ? in mtw_updateprot_cb()
3900 if (ic->ic_flags & IEEE80211_F_USEPROT) { in mtw_updateprot_cb()
3901 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in mtw_updateprot_cb()
3903 else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in mtw_updateprot_cb()
3913 struct mtw_softc *sc = vap->iv_ic->ic_softc; in mtw_usb_timeout_cb()
3917 if (vap->iv_state == IEEE80211_S_SCAN) { in mtw_usb_timeout_cb()
3919 "timeout caused by scan\n"); in mtw_usb_timeout_cb()
3924 "timeout by unknown cause\n"); in mtw_usb_timeout_cb()
3939 return (usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in mtw_reset()
3954 if (sc->sc_ic.ic_promisc > 0) in mtw_update_promisc_locked()
3960 (sc->sc_ic.ic_promisc > 0) ? "entering" : "leaving"); in mtw_update_promisc_locked()
3966 struct mtw_softc *sc = ic->ic_softc; in mtw_update_promisc()
3968 if ((sc->sc_flags & MTW_RUNNING) == 0) in mtw_update_promisc()
3979 struct ieee80211com *ic = &sc->sc_ic; in mtw_enable_tsf_sync()
3980 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in mtw_enable_tsf_sync()
3985 tmp |= vap->iv_bss->ni_intval * 16; in mtw_enable_tsf_sync()
3992 device_printf(sc->sc_dev, "enable_tsf_sync failed error:%d\n", in mtw_enable_tsf_sync()
4005 OFDM(6) << 28 | /* 54->48 */ in mtw_enable_mrr()
4006 OFDM(5) << 24 | /* 48->36 */ in mtw_enable_mrr()
4007 OFDM(4) << 20 | /* 36->24 */ in mtw_enable_mrr()
4008 OFDM(3) << 16 | /* 24->18 */ in mtw_enable_mrr()
4009 OFDM(2) << 12 | /* 18->12 */ in mtw_enable_mrr()
4010 OFDM(1) << 8 | /* 12-> 9 */ in mtw_enable_mrr()
4011 OFDM(0) << 4 | /* 9-> 6 */ in mtw_enable_mrr()
4012 OFDM(0)); /* 6-> 6 */ in mtw_enable_mrr()
4015 CCK(2) << 12 | /* 11->5.5 */ in mtw_enable_mrr()
4016 CCK(1) << 8 | /* 5.5-> 2 */ in mtw_enable_mrr()
4017 CCK(0) << 4 | /* 2-> 1 */ in mtw_enable_mrr()
4018 CCK(0)); /* 1-> 1 */ in mtw_enable_mrr()
4026 struct ieee80211com *ic = &sc->sc_ic; in mtw_set_txpreamble()
4030 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) in mtw_set_txpreamble()
4040 struct ieee80211com *ic = &sc->sc_ic; in mtw_set_basicrates()
4043 if (ic->ic_curmode == IEEE80211_MODE_11B) in mtw_set_basicrates()
4045 else if (ic->ic_curmode == IEEE80211_MODE_11A) in mtw_set_basicrates()
4071 struct mtw_softc *sc = ic->ic_softc; in mtw_updateslot()
4074 i = MTW_CMDQ_GET(&sc->cmdq_store); in mtw_updateslot()
4076 sc->cmdq[i].func = mtw_updateslot_cb; in mtw_updateslot()
4077 sc->cmdq[i].arg0 = ic; in mtw_updateslot()
4078 ieee80211_runtask(ic, &sc->cmdq_task); in mtw_updateslot()
4088 struct mtw_softc *sc = ic->ic_softc; in mtw_updateslot_cb()
4104 struct ieee80211com *ic = &sc->sc_ic; in mtw_rssi2dbm()
4105 struct ieee80211_channel *c = ic->ic_curchan; in mtw_rssi2dbm()
4110 delta = sc->rssi_5ghz[rxchain]; in mtw_rssi2dbm()
4114 delta -= sc->lna[1]; in mtw_rssi2dbm()
4116 delta -= sc->lna[2]; in mtw_rssi2dbm()
4118 delta -= sc->lna[3]; in mtw_rssi2dbm()
4120 delta = sc->rssi_2ghz[rxchain] - sc->lna[0]; in mtw_rssi2dbm()
4122 return (-12 - delta - rssi); in mtw_rssi2dbm()
4153 sc->sc_bw_calibrated = 0; in mt7601_bbp_init()
4190 struct ieee80211com *ic = &sc->sc_ic; in mtw_txrx_enable()
4211 /* enable Rx bulk aggregation (set timeout and limit) */ in mtw_txrx_enable()
4218 if (ic->ic_opmode != IEEE80211_M_MONITOR) { in mtw_txrx_enable()
4222 if (ic->ic_opmode == IEEE80211_M_STA) in mtw_txrx_enable()
4327 if (sc->sc_rf_calibrated) in mt7601_rf_setup()
4335 mtw_rf_write(sc, 0, 12, sc->rf_freq_offset); in mt7601_rf_setup()
4340 sc->bbp_temp = rf; in mt7601_rf_setup()
4341 device_printf(sc->sc_dev, "BBP temp 0x%x\n", rf); in mt7601_rf_setup()
4378 sc->sc_rf_calibrated = 1; in mt7601_rf_setup()
4408 struct ieee80211com *ic = &sc->sc_ic; in mtw_init_locked()
4409 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in mtw_init_locked()
4412 if (ic->ic_nrunning > 1) in mtw_init_locked()
4417 mtw_setup_tx_list(sc, &sc->sc_epq[i]); in mtw_init_locked()
4427 device_printf(sc->sc_dev, "timeout waiting for DMA engine\n"); in mtw_init_locked()
4442 if (sc->asic_ver == 0x7601) { in mtw_init_locked()
4463 mtw_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); in mtw_init_locked()
4488 if (sc->asic_ver == 0x7601) in mtw_init_locked()
4507 if (sc->txpow20mhz[ridx] == 0xffffffff) in mtw_init_locked()
4509 mtw_write(sc, MTW_TX_PWR_CFG(ridx), sc->txpow20mhz[ridx]); in mtw_init_locked()
4531 if (sc->asic_ver == 0x7601) in mtw_init_locked()
4535 if (sc->asic_ver == 0x7601) in mtw_init_locked()
4539 device_printf(sc->sc_dev, "could not initialize BBP\n"); in mtw_init_locked()
4547 device_printf(sc->sc_dev, "could not initialize RF\n"); in mtw_init_locked()
4552 mtw_set_chan(sc, ic->ic_curchan); in mtw_init_locked()
4557 sc->sc_flags |= MTW_RUNNING; in mtw_init_locked()
4558 sc->cmdq_run = MTW_CMDQ_GO; in mtw_init_locked()
4560 usbd_xfer_set_stall(sc->sc_xfer[i]); in mtw_init_locked()
4562 usbd_transfer_start(sc->sc_xfer[MTW_BULK_RX]); in mtw_init_locked()
4586 sc->sc_flags &= ~MTW_RUNNING; in mtw_stop()
4588 sc->ratectl_run = MTW_RATECTL_OFF; in mtw_stop()
4589 sc->cmdq_run = sc->cmdq_key_set; in mtw_stop()
4594 usbd_transfer_drain(sc->sc_xfer[i]); in mtw_stop()
4600 if (sc->rx_m != NULL) { in mtw_stop()
4601 m_free(sc->rx_m); in mtw_stop()
4602 sc->rx_m = NULL; in mtw_stop()
4619 device_printf(sc->sc_dev, "timeout waiting for DMA engine\n"); in mtw_stop()
4653 mtw_delay(struct mtw_softc *sc, u_int ms) in mtw_delay() argument
4655 usb_pause_mtx(mtx_owned(&sc->sc_mtx) ? &sc->sc_mtx : NULL, in mtw_delay()
4656 USB_MS_TO_TICKS(ms)); in mtw_delay()
4667 mtw_ampdu_enable(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap) in mtw_ampdu_enable() argument
4670 /* For now, no A-MPDU TX support in the driver */ in mtw_ampdu_enable()