Lines Matching +full:sens +full:-

1 /*-
86 if (sc->sc_debug & (m)) \
231 0x23, 0x88, 0x7c, 0xa5, /* -82dbm */
232 0x23, 0x88, 0x7c, 0xb5, /* -82dbm */
233 0x23, 0x88, 0x7c, 0xc5, /* -82dbm */
234 0x33, 0x80, 0x79, 0xc5, /* -78dbm */
235 0x43, 0x78, 0x76, 0xc5, /* -74dbm */
236 0x53, 0x60, 0x73, 0xc5, /* -70dbm */
237 0x63, 0x58, 0x70, 0xc5, /* -66dbm */
316 0x23, 0x15, 0xa5, /* -82-1dbm */
317 0x23, 0x15, 0xb5, /* -82-2dbm */
318 0x23, 0x15, 0xc5, /* -82-3dbm */
319 0x33, 0x15, 0xc5, /* -78dbm */
320 0x43, 0x15, 0xc5, /* -74dbm */
321 0x53, 0x15, 0xc5, /* -70dbm */
322 0x63, 0x15, 0xc5, /* -66dbm */
776 if (uaa->usb_mode != USB_MODE_HOST) in urtw_match()
778 if (uaa->info.bConfigIndex != URTW_CONFIG_INDEX) in urtw_match()
780 if (uaa->info.bIfaceIndex != URTW_IFACE_INDEX) in urtw_match()
793 struct ieee80211com *ic = &sc->sc_ic; in urtw_attach()
801 sc->sc_dev = dev; in urtw_attach()
802 sc->sc_udev = uaa->device; in urtw_attach()
804 sc->sc_flags |= URTW_RTL8187B; in urtw_attach()
806 sc->sc_debug = urtw_debug; in urtw_attach()
809 mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), MTX_NETWORK_LOCK, in urtw_attach()
811 usb_callout_init_mtx(&sc->sc_led_ch, &sc->sc_mtx, 0); in urtw_attach()
812 TASK_INIT(&sc->sc_led_task, 0, urtw_ledtask, sc); in urtw_attach()
813 TASK_INIT(&sc->sc_updateslot_task, 0, urtw_updateslottask, sc); in urtw_attach()
814 callout_init(&sc->sc_watchdog_ch, 0); in urtw_attach()
815 mbufq_init(&sc->sc_snd, ifqmaxlen); in urtw_attach()
817 if (sc->sc_flags & URTW_RTL8187B) { in urtw_attach()
825 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer, in urtw_attach()
826 setup_start, n_setup, sc, &sc->sc_mtx); in urtw_attach()
834 if (sc->sc_flags & URTW_RTL8187B) { in urtw_attach()
835 sc->sc_tx_dma_buf = in urtw_attach()
836 usbd_xfer_get_frame_buffer(sc->sc_xfer[ in urtw_attach()
839 sc->sc_tx_dma_buf = in urtw_attach()
840 usbd_xfer_get_frame_buffer(sc->sc_xfer[ in urtw_attach()
847 sc->sc_epromtype = (data & URTW_RX_9356SEL) ? URTW_EEPROM_93C56 : in urtw_attach()
865 sc->sc_rts_retry = URTW_DEFAULT_RTS_RETRY; in urtw_attach()
866 sc->sc_tx_retry = URTW_DEFAULT_TX_RETRY; in urtw_attach()
867 sc->sc_currate = URTW_RIDX_CCK11; in urtw_attach()
868 sc->sc_preamble_mode = urtw_preamble_mode; in urtw_attach()
870 ic->ic_softc = sc; in urtw_attach()
871 ic->ic_name = device_get_nameunit(dev); in urtw_attach()
872 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in urtw_attach()
873 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ in urtw_attach()
876 ic->ic_caps = in urtw_attach()
887 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in urtw_attach()
889 urtw_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in urtw_attach()
890 ic->ic_channels); in urtw_attach()
893 ic->ic_raw_xmit = urtw_raw_xmit; in urtw_attach()
894 ic->ic_scan_start = urtw_scan_start; in urtw_attach()
895 ic->ic_scan_end = urtw_scan_end; in urtw_attach()
896 ic->ic_getradiocaps = urtw_getradiocaps; in urtw_attach()
897 ic->ic_set_channel = urtw_set_channel; in urtw_attach()
898 ic->ic_updateslot = urtw_updateslot; in urtw_attach()
899 ic->ic_vap_create = urtw_vap_create; in urtw_attach()
900 ic->ic_vap_delete = urtw_vap_delete; in urtw_attach()
901 ic->ic_update_promisc = urtw_update_promisc; in urtw_attach()
902 ic->ic_update_mcast = urtw_update_mcast; in urtw_attach()
903 ic->ic_parent = urtw_parent; in urtw_attach()
904 ic->ic_transmit = urtw_transmit; in urtw_attach()
907 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in urtw_attach()
909 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in urtw_attach()
920 usbd_transfer_unsetup(sc->sc_xfer, (sc->sc_flags & URTW_RTL8187B) ? in urtw_attach()
930 struct ieee80211com *ic = &sc->sc_ic; in urtw_detach()
936 sc->sc_flags |= URTW_DETACHED; in urtw_detach()
940 ieee80211_draintask(ic, &sc->sc_updateslot_task); in urtw_detach()
941 ieee80211_draintask(ic, &sc->sc_led_task); in urtw_detach()
943 usb_callout_drain(&sc->sc_led_ch); in urtw_detach()
944 callout_drain(&sc->sc_watchdog_ch); in urtw_detach()
946 n_xfers = (sc->sc_flags & URTW_RTL8187B) ? in urtw_detach()
951 STAILQ_INIT(&sc->sc_tx_active); in urtw_detach()
952 STAILQ_INIT(&sc->sc_tx_inactive); in urtw_detach()
953 STAILQ_INIT(&sc->sc_tx_pending); in urtw_detach()
955 STAILQ_INIT(&sc->sc_rx_active); in urtw_detach()
956 STAILQ_INIT(&sc->sc_rx_inactive); in urtw_detach()
961 usbd_transfer_drain(sc->sc_xfer[x]); in urtw_detach()
970 usbd_transfer_unsetup(sc->sc_xfer, n_xfers); in urtw_detach()
973 mbufq_drain(&sc->sc_snd); in urtw_detach()
974 mtx_destroy(&sc->sc_mtx); in urtw_detach()
981 urtw_free_data_list(sc, sc->sc_tx, URTW_TX_DATA_LIST_COUNT, 0); in urtw_free_tx_data_list()
987 urtw_free_data_list(sc, sc->sc_rx, URTW_RX_DATA_LIST_COUNT, 1); in urtw_free_rx_data_list()
1000 if (dp->m != NULL) { in urtw_free_data_list()
1001 m_freem(dp->m); in urtw_free_data_list()
1002 dp->m = NULL; in urtw_free_data_list()
1003 dp->buf = NULL; in urtw_free_data_list()
1006 dp->buf = NULL; in urtw_free_data_list()
1008 if (dp->ni != NULL) { in urtw_free_data_list()
1009 ieee80211_free_node(dp->ni); in urtw_free_data_list()
1010 dp->ni = NULL; in urtw_free_data_list()
1024 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in urtw_vap_create()
1027 vap = &uvp->vap; in urtw_vap_create()
1038 uvp->newstate = vap->iv_newstate; in urtw_vap_create()
1039 vap->iv_newstate = urtw_newstate; in urtw_vap_create()
1044 ic->ic_opmode = opmode; in urtw_vap_create()
1065 if (sc->sc_flags & URTW_RUNNING) in urtw_init()
1068 error = (sc->sc_flags & URTW_RTL8187B) ? urtw_adapter_start_b(sc) : in urtw_init()
1074 sc->sc_txtimer = 0; in urtw_init()
1076 if (!(sc->sc_flags & URTW_INIT_ONCE)) { in urtw_init()
1083 sc->sc_flags |= URTW_INIT_ONCE; in urtw_init()
1093 if (sc->sc_flags & URTW_RTL8187B) in urtw_init()
1094 usbd_transfer_start(sc->sc_xfer[URTW_8187B_BULK_TX_STATUS]); in urtw_init()
1096 sc->sc_flags |= URTW_RUNNING; in urtw_init()
1098 callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); in urtw_init()
1137 error = sc->sc_rf_init(sc); in urtw_adapter_start_b()
1205 struct ieee80211com *ic = &sc->sc_ic; in urtw_adapter_start()
1206 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in urtw_adapter_start()
1227 macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; in urtw_adapter_start()
1247 error = sc->sc_rf_init(sc); in urtw_adapter_start()
1250 if (sc->sc_rf_set_sens != NULL) in urtw_adapter_start()
1251 sc->sc_rf_set_sens(sc, sc->sc_sens); in urtw_adapter_start()
1287 usb_pause_mtx(&sc->sc_mtx, USB_MS_TO_TICKS(delay)); in urtw_pause_ms()
1309 device_printf(sc->sc_dev, "reset timeout\n"); in urtw_8187b_cmd_reset()
1325 while (ntries--) { in urtw_do_request()
1326 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in urtw_do_request()
1347 sc->sc_flags &= ~URTW_RUNNING; in urtw_stop()
1356 error = sc->sc_rf_stop(sc); in urtw_stop()
1370 device_printf(sc->sc_dev, "failed to stop (%s)\n", in urtw_stop()
1373 usb_callout_stop(&sc->sc_led_ch); in urtw_stop()
1374 callout_stop(&sc->sc_watchdog_ch); in urtw_stop()
1386 max = (sc->sc_flags & URTW_RTL8187B) ? URTW_8187B_N_XFERS : in urtw_abort_xfers()
1391 usbd_transfer_stop(sc->sc_xfer[i]); in urtw_abort_xfers()
1397 struct urtw_softc *sc = ic->ic_softc; in urtw_parent()
1401 if (sc->sc_flags & URTW_DETACHED) { in urtw_parent()
1406 if (ic->ic_nrunning > 0) { in urtw_parent()
1407 if (sc->sc_flags & URTW_RUNNING) { in urtw_parent()
1408 if (ic->ic_promisc > 0 || ic->ic_allmulti > 0) in urtw_parent()
1414 } else if (sc->sc_flags & URTW_RUNNING) in urtw_parent()
1424 struct urtw_softc *sc = ic->ic_softc; in urtw_transmit()
1428 if ((sc->sc_flags & URTW_RUNNING) == 0) { in urtw_transmit()
1432 error = mbufq_enqueue(&sc->sc_snd, m); in urtw_transmit()
1452 if ((sc->sc_flags & URTW_RUNNING) == 0) in urtw_start()
1455 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in urtw_start()
1458 mbufq_prepend(&sc->sc_snd, m); in urtw_start()
1462 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in urtw_start()
1463 m->m_pkthdr.rcvif = NULL; in urtw_start()
1466 if_inc_counter(ni->ni_vap->iv_ifp, in urtw_start()
1468 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); in urtw_start()
1473 sc->sc_txtimer = 5; in urtw_start()
1474 callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); in urtw_start()
1487 dp->sc = sc; in urtw_alloc_data_list()
1489 dp->m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); in urtw_alloc_data_list()
1490 if (dp->m == NULL) { in urtw_alloc_data_list()
1491 device_printf(sc->sc_dev, in urtw_alloc_data_list()
1496 dp->buf = mtod(dp->m, uint8_t *); in urtw_alloc_data_list()
1498 dp->m = NULL; in urtw_alloc_data_list()
1499 dp->buf = ((uint8_t *)dma_buf) + in urtw_alloc_data_list()
1502 dp->ni = NULL; in urtw_alloc_data_list()
1516 sc->sc_rx, URTW_RX_DATA_LIST_COUNT, in urtw_alloc_rx_data_list()
1521 STAILQ_INIT(&sc->sc_rx_active); in urtw_alloc_rx_data_list()
1522 STAILQ_INIT(&sc->sc_rx_inactive); in urtw_alloc_rx_data_list()
1525 STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next); in urtw_alloc_rx_data_list()
1536 sc->sc_tx, URTW_TX_DATA_LIST_COUNT, URTW_TX_MAXSIZE, in urtw_alloc_tx_data_list()
1537 sc->sc_tx_dma_buf /* no mbufs */); in urtw_alloc_tx_data_list()
1541 STAILQ_INIT(&sc->sc_tx_active); in urtw_alloc_tx_data_list()
1542 STAILQ_INIT(&sc->sc_tx_inactive); in urtw_alloc_tx_data_list()
1543 STAILQ_INIT(&sc->sc_tx_pending); in urtw_alloc_tx_data_list()
1546 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], in urtw_alloc_tx_data_list()
1556 struct ieee80211com *ic = ni->ni_ic; in urtw_raw_xmit()
1557 struct urtw_softc *sc = ic->ic_softc; in urtw_raw_xmit()
1561 if (!(sc->sc_flags & URTW_RUNNING)) { in urtw_raw_xmit()
1574 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, bf, next); in urtw_raw_xmit()
1580 sc->sc_txtimer = 5; in urtw_raw_xmit()
1613 struct urtw_softc *sc = ic->ic_softc; in urtw_set_channel()
1623 if (!(sc->sc_flags & URTW_RUNNING)) in urtw_set_channel()
1626 if (sc->sc_curchan != NULL && sc->sc_curchan == ic->ic_curchan) in urtw_set_channel()
1639 error = sc->sc_rf_set_chan(sc, ieee80211_chan2ieee(ic, ic->ic_curchan)); in urtw_set_channel()
1653 sc->sc_curchan = ic->ic_curchan; in urtw_set_channel()
1656 device_printf(sc->sc_dev, "could not change the channel\n"); in urtw_set_channel()
1662 struct urtw_softc *sc = ic->ic_softc; in urtw_update_promisc()
1665 if (sc->sc_flags & URTW_RUNNING) in urtw_update_promisc()
1683 const struct ieee80211_txparam *tp = ni->ni_txparms; in urtw_tx_start()
1684 struct ieee80211com *ic = &sc->sc_ic; in urtw_tx_start()
1685 struct ieee80211vap *vap = ni->ni_vap; in urtw_tx_start()
1687 sc->sc_xfer[URTW_8187B_BULK_TX_BE], in urtw_tx_start()
1688 sc->sc_xfer[URTW_8187B_BULK_TX_BK], in urtw_tx_start()
1689 sc->sc_xfer[URTW_8187B_BULK_TX_VI], in urtw_tx_start()
1690 sc->sc_xfer[URTW_8187B_BULK_TX_VO] in urtw_tx_start()
1701 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in urtw_tx_start()
1702 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in urtw_tx_start()
1706 ieee80211_output_seqno_assign(ni, -1, m0); in urtw_tx_start()
1711 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in urtw_tx_start()
1714 device_printf(sc->sc_dev, in urtw_tx_start()
1726 struct urtw_tx_radiotap_header *tap = &sc->sc_txtap; in urtw_tx_start()
1728 tap->wt_flags = 0; in urtw_tx_start()
1733 (m0->m_flags & M_EAPOL) != 0) { in urtw_tx_start()
1734 rate = tp->mgmtrate; in urtw_tx_start()
1738 rate = tp->mcastrate; in urtw_tx_start()
1739 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in urtw_tx_start()
1740 rate = tp->ucastrate; in urtw_tx_start()
1742 rate = urtw_rtl2rate(sc->sc_currate); in urtw_tx_start()
1745 sc->sc_stats.txrates[sc->sc_currate]++; in urtw_tx_start()
1748 txdur = pkttime = urtw_compute_txtime(m0->m_pkthdr.len + in urtw_tx_start()
1752 if ((m0->m_pkthdr.len + 4) > vap->iv_rtsthreshold) { in urtw_tx_start()
1757 pkttime = urtw_compute_txtime(m0->m_pkthdr.len + in urtw_tx_start()
1764 pkttime = urtw_compute_txtime(m0->m_pkthdr.len + in urtw_tx_start()
1769 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) in urtw_tx_start()
1770 dur = urtw_compute_txtime(m0->m_pkthdr.len + in urtw_tx_start()
1777 USETW(wh->i_dur, dur); in urtw_tx_start()
1779 xferlen = m0->m_pkthdr.len; in urtw_tx_start()
1780 xferlen += (sc->sc_flags & URTW_RTL8187B) ? (4 * 8) : (4 * 3); in urtw_tx_start()
1784 memset(data->buf, 0, URTW_TX_MAXSIZE); in urtw_tx_start()
1785 flags = m0->m_pkthdr.len & 0xfff; in urtw_tx_start()
1787 if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && in urtw_tx_start()
1788 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) && in urtw_tx_start()
1789 (sc->sc_preamble_mode == URTW_PREAMBLE_MODE_SHORT) && in urtw_tx_start()
1790 (sc->sc_currate != 0)) in urtw_tx_start()
1792 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) in urtw_tx_start()
1795 flags |= (sc->sc_currate & 0xf) << URTW_TX_FLAG_TXRATE_SHIFT; in urtw_tx_start()
1797 if (sc->sc_flags & URTW_RTL8187B) { in urtw_tx_start()
1800 tx = (struct urtw_8187b_txhdr *)data->buf; in urtw_tx_start()
1806 tx->rtsdur = rtsdur; in urtw_tx_start()
1808 tx->flag = htole32(flags); in urtw_tx_start()
1809 tx->txdur = txdur; in urtw_tx_start()
1811 tx->retry = 1; in urtw_tx_start()
1813 tx->retry = URTW_TX_MAXRETRY; in urtw_tx_start()
1814 m_copydata(m0, 0, m0->m_pkthdr.len, (uint8_t *)(tx + 1)); in urtw_tx_start()
1818 tx = (struct urtw_8187l_txhdr *)data->buf; in urtw_tx_start()
1821 tx->rtsdur = rtsdur; in urtw_tx_start()
1824 tx->flag = htole32(flags); in urtw_tx_start()
1825 tx->retry = 3; /* CW minimum */ in urtw_tx_start()
1826 tx->retry |= 7 << 4; /* CW maximum */ in urtw_tx_start()
1827 tx->retry |= URTW_TX_MAXRETRY << 8; /* retry limitation */ in urtw_tx_start()
1828 m_copydata(m0, 0, m0->m_pkthdr.len, (uint8_t *)(tx + 1)); in urtw_tx_start()
1831 data->buflen = xferlen; in urtw_tx_start()
1832 data->ni = ni; in urtw_tx_start()
1833 data->m = m0; in urtw_tx_start()
1835 if (sc->sc_flags & URTW_RTL8187B) { in urtw_tx_start()
1839 xfer = sc->sc_xfer[URTW_8187B_BULK_TX_EP12]; in urtw_tx_start()
1849 sc->sc_xfer[URTW_8187L_BULK_TX_LOW] : in urtw_tx_start()
1850 sc->sc_xfer[URTW_8187L_BULK_TX_NORMAL]; in urtw_tx_start()
1852 STAILQ_INSERT_TAIL(&sc->sc_tx_pending, data, next); in urtw_tx_start()
1857 device_printf(sc->sc_dev, "could not control LED (%d)\n", in urtw_tx_start()
1865 struct ieee80211com *ic = vap->iv_ic; in urtw_newstate()
1866 struct urtw_softc *sc = ic->ic_softc; in urtw_newstate()
1871 DPRINTF(sc, URTW_DEBUG_STATE, "%s: %s -> %s\n", __func__, in urtw_newstate()
1872 ieee80211_state_name[vap->iv_state], in urtw_newstate()
1875 sc->sc_state = nstate; in urtw_newstate()
1879 usb_callout_stop(&sc->sc_led_ch); in urtw_newstate()
1880 callout_stop(&sc->sc_watchdog_ch); in urtw_newstate()
1889 ni = ieee80211_ref_node(vap->iv_bss); in urtw_newstate()
1891 urtw_write32_m(sc, URTW_BSSID, ((uint32_t *)ni->ni_bssid)[0]); in urtw_newstate()
1893 ((uint16_t *)ni->ni_bssid)[2]); in urtw_newstate()
1902 device_printf(sc->sc_dev, in urtw_newstate()
1912 return (uvp->newstate(vap, nstate, arg)); in urtw_newstate()
1919 struct ieee80211com *ic = &sc->sc_ic; in urtw_watchdog()
1921 if (sc->sc_txtimer > 0) { in urtw_watchdog()
1922 if (--sc->sc_txtimer == 0) { in urtw_watchdog()
1923 device_printf(sc->sc_dev, "device timeout\n"); in urtw_watchdog()
1924 counter_u64_add(ic->ic_oerrors, 1); in urtw_watchdog()
1928 callout_reset(&sc->sc_watchdog_ch, hz, urtw_watchdog, sc); in urtw_watchdog()
1980 struct ieee80211com *ic = &sc->sc_ic; in urtw_update_msr()
1987 if (sc->sc_state == IEEE80211_S_RUN) { in urtw_update_msr()
1988 switch (ic->ic_opmode) { in urtw_update_msr()
1992 if (sc->sc_flags & URTW_RTL8187B) in urtw_update_msr()
2004 ic->ic_opmode); in urtw_update_msr()
2121 struct ieee80211com *ic = &sc->sc_ic; in urtw_get_macaddr()
2128 ic->ic_macaddr[0] = data & 0xff; in urtw_get_macaddr()
2129 ic->ic_macaddr[1] = (data & 0xff00) >> 8; in urtw_get_macaddr()
2133 ic->ic_macaddr[2] = data & 0xff; in urtw_get_macaddr()
2134 ic->ic_macaddr[3] = (data & 0xff00) >> 8; in urtw_get_macaddr()
2138 ic->ic_macaddr[4] = data & 0xff; in urtw_get_macaddr()
2139 ic->ic_macaddr[5] = (data & 0xff00) >> 8; in urtw_get_macaddr()
2168 if (sc->sc_epromtype == URTW_EEPROM_93C56) { in urtw_eprom_read32()
2203 (*data) |= (data16 << (15 - i)); in urtw_eprom_read32()
2312 sc->sc_txpwr_cck_base = data & 0xf; in urtw_get_txpwr()
2313 sc->sc_txpwr_ofdm_base = (data >> 4) & 0xf; in urtw_get_txpwr()
2319 sc->sc_txpwr_cck[i] = data & 0xf; in urtw_get_txpwr()
2320 sc->sc_txpwr_cck[i + 1] = (data & 0xf00) >> 8; in urtw_get_txpwr()
2321 sc->sc_txpwr_ofdm[i] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2322 sc->sc_txpwr_ofdm[i + 1] = (data & 0xf000) >> 12; in urtw_get_txpwr()
2328 sc->sc_txpwr_cck[i + 6] = data & 0xf; in urtw_get_txpwr()
2329 sc->sc_txpwr_cck[i + 6 + 1] = (data & 0xf00) >> 8; in urtw_get_txpwr()
2330 sc->sc_txpwr_ofdm[i + 6] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2331 sc->sc_txpwr_ofdm[i + 6 + 1] = (data & 0xf000) >> 12; in urtw_get_txpwr()
2333 if (sc->sc_flags & URTW_RTL8187B) { in urtw_get_txpwr()
2337 sc->sc_txpwr_cck[1 + 6 + 4] = data & 0xf; in urtw_get_txpwr()
2338 sc->sc_txpwr_ofdm[1 + 6 + 4] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2342 sc->sc_txpwr_cck[2 + 6 + 4] = data & 0xf; in urtw_get_txpwr()
2343 sc->sc_txpwr_ofdm[2 + 6 + 4] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2347 sc->sc_txpwr_cck[3 + 6 + 4] = data & 0xf; in urtw_get_txpwr()
2348 sc->sc_txpwr_cck[3 + 6 + 4 + 1] = (data & 0xf00) >> 8; in urtw_get_txpwr()
2349 sc->sc_txpwr_ofdm[3 + 6 + 4] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2350 sc->sc_txpwr_ofdm[3 + 6 + 4 + 1] = (data & 0xf000) >> 12; in urtw_get_txpwr()
2357 sc->sc_txpwr_cck[i + 6 + 4] = data & 0xf; in urtw_get_txpwr()
2358 sc->sc_txpwr_cck[i + 6 + 4 + 1] = (data & 0xf00) >> 8; in urtw_get_txpwr()
2359 sc->sc_txpwr_ofdm[i + 6 + 4] = (data & 0xf0) >> 4; in urtw_get_txpwr()
2360 sc->sc_txpwr_ofdm[i + 6 + 4 + 1] = (data & 0xf000) >> 12; in urtw_get_txpwr()
2375 if (sc->sc_flags & URTW_RTL8187B) { in urtw_get_rfchip()
2379 sc->sc_flags |= URTW_RTL8187B_REV_B; in urtw_get_rfchip()
2382 sc->sc_flags |= URTW_RTL8187B_REV_D; in urtw_get_rfchip()
2385 sc->sc_flags |= URTW_RTL8187B_REV_E; in urtw_get_rfchip()
2388 device_printf(sc->sc_dev, "unknown type: %#x\n", data8); in urtw_get_rfchip()
2389 sc->sc_flags |= URTW_RTL8187B_REV_B; in urtw_get_rfchip()
2396 sc->sc_flags |= URTW_RTL8187B; in urtw_get_rfchip()
2401 device_printf(sc->sc_dev, "unknown RTL8187L type: %#x\n", in urtw_get_rfchip()
2416 sc->sc_rf_init = urtw_8225_rf_init; in urtw_get_rfchip()
2417 sc->sc_rf_set_sens = urtw_8225_rf_set_sens; in urtw_get_rfchip()
2418 sc->sc_rf_set_chan = urtw_8225_rf_set_chan; in urtw_get_rfchip()
2419 sc->sc_rf_stop = urtw_8225_rf_stop; in urtw_get_rfchip()
2421 sc->sc_rf_init = urtw_8225v2_rf_init; in urtw_get_rfchip()
2422 sc->sc_rf_set_chan = urtw_8225v2_rf_set_chan; in urtw_get_rfchip()
2423 sc->sc_rf_stop = urtw_8225_rf_stop; in urtw_get_rfchip()
2425 sc->sc_max_sens = URTW_8225_RF_MAX_SENS; in urtw_get_rfchip()
2426 sc->sc_sens = URTW_8225_RF_DEF_SENS; in urtw_get_rfchip()
2429 sc->sc_rf_init = urtw_8225v2b_rf_init; in urtw_get_rfchip()
2430 sc->sc_rf_set_chan = urtw_8225v2b_rf_set_chan; in urtw_get_rfchip()
2431 sc->sc_max_sens = URTW_8225_RF_MAX_SENS; in urtw_get_rfchip()
2432 sc->sc_sens = URTW_8225_RF_DEF_SENS; in urtw_get_rfchip()
2433 sc->sc_rf_stop = urtw_8225_rf_stop; in urtw_get_rfchip()
2442 device_printf(sc->sc_dev, "%s rf %s hwrev %s\n", in urtw_get_rfchip()
2443 (sc->sc_flags & URTW_RTL8187B) ? "rtl8187b" : "rtl8187l", in urtw_get_rfchip()
2446 (sc->sc_flags & URTW_RTL8187B) ? ((data8 == 0) ? "b" : in urtw_get_rfchip()
2459 urtw_read8_m(sc, URTW_PSR, &sc->sc_psr); in urtw_led_init()
2466 sc->sc_strategy = URTW_SW_LED_MODE1; in urtw_led_init()
2469 sc->sc_strategy = URTW_SW_LED_MODE3; in urtw_led_init()
2472 sc->sc_strategy = URTW_HW_LED; in urtw_led_init()
2477 sc->sc_strategy = URTW_SW_LED_MODE0; in urtw_led_init()
2481 sc->sc_gpio_ledpin = URTW_LED_PIN_GPIO0; in urtw_led_init()
2755 urtw_8225_rf_set_sens(struct urtw_softc *sc, int sens) in urtw_8225_rf_set_sens() argument
2759 if (sens < 0 || sens > 6) in urtw_8225_rf_set_sens()
2760 return -1; in urtw_8225_rf_set_sens()
2762 if (sens > 4) in urtw_8225_rf_set_sens()
2769 sens = 6 - sens; in urtw_8225_rf_set_sens()
2770 error = urtw_8225_setgain(sc, sens); in urtw_8225_rf_set_sens()
2774 urtw_8187_write_phy_cck(sc, 0x41, urtw_8225_threshold[sens]); in urtw_8225_rf_set_sens()
2786 uint8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff; in urtw_8225_set_txpwrlvl()
2787 uint8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff; in urtw_8225_set_txpwrlvl()
2791 ofdm_pwrlvl_max = 25; /* 12 -> 25 */ in urtw_8225_set_txpwrlvl()
2810 ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ? in urtw_8225_set_txpwrlvl()
2847 if (sc->sc_flags & URTW_RTL8187B) { in urtw_8225_rf_stop()
2934 device_printf(sc->sc_dev, "expect 0xe6!! (0x%x)\n", data32); in urtw_8225v2_rf_init()
2946 device_printf(sc->sc_dev, "RF calibration failed\n"); in urtw_8225v2_rf_init()
3102 uint8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff; in urtw_8225v2_set_txpwrlvl()
3103 uint8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff; in urtw_8225v2_set_txpwrlvl()
3108 cck_pwrlvl += sc->sc_txpwr_cck_base; in urtw_8225v2_set_txpwrlvl()
3121 ofdm_pwrlvl = (ofdm_pwrlvl > (ofdm_pwrlvl_max - ofdm_pwrlvl_min)) ? in urtw_8225v2_set_txpwrlvl()
3123 ofdm_pwrlvl += sc->sc_txpwr_ofdm_base; in urtw_8225v2_set_txpwrlvl()
3201 struct ieee80211com *ic = &sc->sc_ic; in urtw_8225v2b_rf_init()
3202 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in urtw_8225v2b_rf_init()
3238 urtw_write8_m(sc, URTW_ACM_CONTROL, sc->sc_acmctl); in urtw_8225v2b_rf_init()
3251 macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; in urtw_8225v2b_rf_init()
3382 uint8_t cck_pwrlvl = sc->sc_txpwr_cck[chan] & 0xff; in urtw_8225v2b_set_txpwrlvl()
3383 uint8_t ofdm_pwrlvl = sc->sc_txpwr_ofdm[chan] & 0xff; in urtw_8225v2b_set_txpwrlvl()
3388 ((sc->sc_flags & URTW_RTL8187B_REV_B) ? cck_pwrlvl_max : 22) : in urtw_8225v2b_set_txpwrlvl()
3389 (cck_pwrlvl + ((sc->sc_flags & URTW_RTL8187B_REV_B) ? 0 : 7)); in urtw_8225v2b_set_txpwrlvl()
3390 cck_pwrlvl += sc->sc_txpwr_cck_base; in urtw_8225v2b_set_txpwrlvl()
3395 if (sc->sc_flags & URTW_RTL8187B_REV_B) in urtw_8225v2b_set_txpwrlvl()
3411 ((sc->sc_flags & URTW_RTL8187B_REV_B) ? 17 : 25) : in urtw_8225v2b_set_txpwrlvl()
3412 (ofdm_pwrlvl + ((sc->sc_flags & URTW_RTL8187B_REV_B) ? 2 : 10)); in urtw_8225v2b_set_txpwrlvl()
3413 ofdm_pwrlvl += sc->sc_txpwr_ofdm_base; in urtw_8225v2b_set_txpwrlvl()
3419 if (sc->sc_flags & URTW_RTL8187B_REV_B) { in urtw_8225v2b_set_txpwrlvl()
3576 device_printf(sc->sc_dev, "reset timeout\n"); in urtw_reset()
3600 switch (sc->sc_strategy) { in urtw_led_ctl()
3615 "unsupported LED mode %d\n", sc->sc_strategy); in urtw_led_ctl()
3629 sc->sc_gpio_ledstate = URTW_LED_POWER_ON_BLINK; in urtw_led_mode0()
3632 if (sc->sc_gpio_ledinprogress == 1) in urtw_led_mode0()
3635 sc->sc_gpio_ledstate = URTW_LED_BLINK_NORMAL; in urtw_led_mode0()
3636 sc->sc_gpio_blinktime = 2; in urtw_led_mode0()
3639 sc->sc_gpio_ledstate = URTW_LED_ON; in urtw_led_mode0()
3647 switch (sc->sc_gpio_ledstate) { in urtw_led_mode0()
3649 if (sc->sc_gpio_ledinprogress != 0) in urtw_led_mode0()
3654 if (sc->sc_gpio_ledinprogress != 0) in urtw_led_mode0()
3656 sc->sc_gpio_ledinprogress = 1; in urtw_led_mode0()
3657 sc->sc_gpio_blinkstate = (sc->sc_gpio_ledon != 0) ? in urtw_led_mode0()
3659 usb_callout_reset(&sc->sc_led_ch, hz, urtw_led_ch, sc); in urtw_led_mode0()
3668 "unknown LED status 0x%x", sc->sc_gpio_ledstate); in urtw_led_mode0()
3698 switch (sc->sc_gpio_ledpin) { in urtw_led_on()
3706 sc->sc_gpio_ledpin); in urtw_led_on()
3717 sc->sc_gpio_ledon = 1; in urtw_led_on()
3728 switch (sc->sc_gpio_ledpin) { in urtw_led_off()
3737 sc->sc_gpio_ledpin); in urtw_led_off()
3748 sc->sc_gpio_ledon = 0; in urtw_led_off()
3758 struct ieee80211com *ic = &sc->sc_ic; in urtw_led_ch()
3760 ieee80211_runtask(ic, &sc->sc_led_task); in urtw_led_ch()
3768 if (sc->sc_strategy != URTW_SW_LED_MODE0) { in urtw_ledtask()
3771 sc->sc_strategy); in urtw_ledtask()
3785 if (sc->sc_gpio_blinkstate == URTW_LED_ON) in urtw_led_blink()
3789 sc->sc_gpio_blinktime--; in urtw_led_blink()
3790 if (sc->sc_gpio_blinktime == 0) in urtw_led_blink()
3793 if (sc->sc_gpio_ledstate != URTW_LED_BLINK_NORMAL && in urtw_led_blink()
3794 sc->sc_gpio_ledstate != URTW_LED_BLINK_SLOWLY && in urtw_led_blink()
3795 sc->sc_gpio_ledstate != URTW_LED_BLINK_CM3) in urtw_led_blink()
3799 if (sc->sc_gpio_ledstate == URTW_LED_ON && in urtw_led_blink()
3800 sc->sc_gpio_ledon == 0) in urtw_led_blink()
3802 else if (sc->sc_gpio_ledstate == URTW_LED_OFF && in urtw_led_blink()
3803 sc->sc_gpio_ledon == 1) in urtw_led_blink()
3806 sc->sc_gpio_blinktime = 0; in urtw_led_blink()
3807 sc->sc_gpio_ledinprogress = 0; in urtw_led_blink()
3811 sc->sc_gpio_blinkstate = (sc->sc_gpio_blinkstate != URTW_LED_ON) ? in urtw_led_blink()
3814 switch (sc->sc_gpio_ledstate) { in urtw_led_blink()
3816 usb_callout_reset(&sc->sc_led_ch, hz, urtw_led_ch, sc); in urtw_led_blink()
3821 sc->sc_gpio_ledstate); in urtw_led_blink()
3833 usbd_transfer_start((sc->sc_flags & URTW_RTL8187B) ? in urtw_rx_enable()
3834 sc->sc_xfer[URTW_8187B_BULK_RX] : sc->sc_xfer[URTW_8187L_BULK_RX]); in urtw_rx_enable()
3840 if ((sc->sc_flags & URTW_RTL8187B) == 0) { in urtw_rx_enable()
3855 if (sc->sc_flags & URTW_RTL8187B) { in urtw_tx_enable()
3887 data |= sc->sc_tx_retry << URTW_TX_DPRETRY_SHIFT; in urtw_tx_enable()
3888 data |= sc->sc_rts_retry << URTW_TX_RTSRETRY_SHIFT; in urtw_tx_enable()
3904 struct ieee80211com *ic = &sc->sc_ic; in urtw_rx_setconf()
3910 if (sc->sc_flags & URTW_RTL8187B) { in urtw_rx_setconf()
3920 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in urtw_rx_setconf()
3924 if (sc->sc_crcmon == 1 && ic->ic_opmode == IEEE80211_M_MONITOR) in urtw_rx_setconf()
3935 if (ic->ic_opmode == IEEE80211_M_MONITOR || in urtw_rx_setconf()
3936 ic->ic_promisc > 0 || ic->ic_allmulti > 0) { in urtw_rx_setconf()
3956 struct urtw_softc *sc = data->sc; in urtw_rxeof()
3957 struct ieee80211com *ic = &sc->sc_ic; in urtw_rxeof()
3963 if (sc->sc_flags & URTW_RTL8187B) { in urtw_rxeof()
3969 rx = (struct urtw_8187b_rxhdr *)(data->buf + in urtw_rxeof()
3970 (actlen - (sizeof(struct urtw_8187b_rxhdr)))); in urtw_rxeof()
3971 flen = le32toh(rx->flag) & 0xfff; in urtw_rxeof()
3972 if (flen > actlen - sizeof(*rx)) in urtw_rxeof()
3975 rate = (le32toh(rx->flag) >> URTW_RX_FLAG_RXRATE_SHIFT) & 0xf; in urtw_rxeof()
3977 rssi = rx->rssi & URTW_RX_RSSI_MASK; in urtw_rxeof()
3978 noise = rx->noise; in urtw_rxeof()
3981 mactime = rx->mactime; in urtw_rxeof()
3988 rx = (struct urtw_8187l_rxhdr *)(data->buf + in urtw_rxeof()
3989 (actlen - (sizeof(struct urtw_8187l_rxhdr)))); in urtw_rxeof()
3990 flen = le32toh(rx->flag) & 0xfff; in urtw_rxeof()
3991 if (flen > actlen - sizeof(*rx)) in urtw_rxeof()
3994 rate = (le32toh(rx->flag) >> URTW_RX_FLAG_RXRATE_SHIFT) & 0xf; in urtw_rxeof()
3996 rssi = rx->rssi & URTW_RX_8187L_RSSI_MASK; in urtw_rxeof()
3997 noise = rx->noise; in urtw_rxeof()
4000 mactime = rx->mactime; in urtw_rxeof()
4010 m = data->m; in urtw_rxeof()
4011 data->m = mnew; in urtw_rxeof()
4012 data->buf = mtod(mnew, uint8_t *); in urtw_rxeof()
4015 m->m_pkthdr.len = m->m_len = flen - IEEE80211_CRC_LEN; in urtw_rxeof()
4018 struct urtw_rx_radiotap_header *tap = &sc->sc_rxtap; in urtw_rxeof()
4020 tap->wr_tsf = mactime; in urtw_rxeof()
4021 tap->wr_flags = 0; in urtw_rxeof()
4022 tap->wr_dbm_antsignal = (int8_t)rssi; in urtw_rxeof()
4027 sc->sc_currate = (rate > 0) ? rate : sc->sc_currate; in urtw_rxeof()
4035 counter_u64_add(ic->ic_ierrors, 1); in urtw_rxeof()
4043 struct ieee80211com *ic = &sc->sc_ic; in urtw_bulk_rx_callback()
4047 int8_t nf = -95; in urtw_bulk_rx_callback()
4054 data = STAILQ_FIRST(&sc->sc_rx_active); in urtw_bulk_rx_callback()
4057 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in urtw_bulk_rx_callback()
4059 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in urtw_bulk_rx_callback()
4063 data = STAILQ_FIRST(&sc->sc_rx_inactive); in urtw_bulk_rx_callback()
4068 STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next); in urtw_bulk_rx_callback()
4069 STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next); in urtw_bulk_rx_callback()
4070 usbd_xfer_set_frame_data(xfer, 0, data->buf, in urtw_bulk_rx_callback()
4081 if (m->m_pkthdr.len >= in urtw_bulk_rx_callback()
4100 data = STAILQ_FIRST(&sc->sc_rx_active); in urtw_bulk_rx_callback()
4102 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next); in urtw_bulk_rx_callback()
4103 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); in urtw_bulk_rx_callback()
4107 counter_u64_add(ic->ic_ierrors, 1); in urtw_bulk_rx_callback()
4121 struct ieee80211com *ic = &sc->sc_ic; in urtw_txstatus_eof()
4130 val = le64toh(sc->sc_txstatus); in urtw_txstatus_eof()
4135 counter_u64_add(ic->ic_oerrors, 1); in urtw_txstatus_eof()
4145 struct ieee80211com *ic = &sc->sc_ic; in urtw_bulk_tx_status_callback()
4156 memcpy(dma_buf, &sc->sc_txstatus, sizeof(uint64_t)); in urtw_bulk_tx_status_callback()
4163 counter_u64_add(ic->ic_ierrors, 1); in urtw_bulk_tx_status_callback()
4177 if (data->m) { in urtw_txeof()
4179 ieee80211_tx_complete(data->ni, data->m, 0); in urtw_txeof()
4180 data->m = NULL; in urtw_txeof()
4181 data->ni = NULL; in urtw_txeof()
4183 sc->sc_txtimer = 0; in urtw_txeof()
4196 data = STAILQ_FIRST(&sc->sc_tx_active); in urtw_bulk_tx_callback()
4199 STAILQ_REMOVE_HEAD(&sc->sc_tx_active, next); in urtw_bulk_tx_callback()
4201 STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, data, next); in urtw_bulk_tx_callback()
4205 data = STAILQ_FIRST(&sc->sc_tx_pending); in urtw_bulk_tx_callback()
4211 STAILQ_REMOVE_HEAD(&sc->sc_tx_pending, next); in urtw_bulk_tx_callback()
4212 STAILQ_INSERT_TAIL(&sc->sc_tx_active, data, next); in urtw_bulk_tx_callback()
4214 usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen); in urtw_bulk_tx_callback()
4220 data = STAILQ_FIRST(&sc->sc_tx_active); in urtw_bulk_tx_callback()
4223 if (data->ni != NULL) { in urtw_bulk_tx_callback()
4224 if_inc_counter(data->ni->ni_vap->iv_ifp, in urtw_bulk_tx_callback()
4226 ieee80211_free_node(data->ni); in urtw_bulk_tx_callback()
4227 data->ni = NULL; in urtw_bulk_tx_callback()
4242 bf = STAILQ_FIRST(&sc->sc_tx_inactive); in _urtw_getbuf()
4244 STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next); in _urtw_getbuf()
4325 struct urtw_softc *sc = ic->ic_softc; in urtw_updateslot()
4327 ieee80211_runtask(ic, &sc->sc_updateslot_task); in urtw_updateslot()
4334 struct ieee80211com *ic = &sc->sc_ic; in urtw_updateslottask()
4338 if ((sc->sc_flags & URTW_RUNNING) == 0) { in urtw_updateslottask()
4342 if (sc->sc_flags & URTW_RTL8187B) { in urtw_updateslottask()
4344 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) in urtw_updateslottask()
4352 if (sc->sc_state == IEEE80211_S_ASSOC && in urtw_updateslottask()
4353 ic->ic_flags & IEEE80211_F_SHSLOT) in urtw_updateslottask()
4357 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) { in urtw_updateslottask()
4359 urtw_write8_m(sc, URTW_EIFS, 0x5b - 0x14); in urtw_updateslottask()
4363 urtw_write8_m(sc, URTW_EIFS, 0x5b - 0x24); in urtw_updateslottask()
4379 struct urtw_stats *stats = &sc->sc_stats; in urtw_sysctl_node()
4381 ctx = device_get_sysctl_ctx(sc->sc_dev); in urtw_sysctl_node()
4382 child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sc_dev)); in urtw_sysctl_node()
4392 URTW_SYSCTL_STAT_ADD32(ctx, child, "1m", &stats->txrates[0], in urtw_sysctl_node()
4394 URTW_SYSCTL_STAT_ADD32(ctx, child, "2m", &stats->txrates[1], in urtw_sysctl_node()
4396 URTW_SYSCTL_STAT_ADD32(ctx, child, "5.5m", &stats->txrates[2], in urtw_sysctl_node()
4398 URTW_SYSCTL_STAT_ADD32(ctx, child, "6m", &stats->txrates[4], in urtw_sysctl_node()
4400 URTW_SYSCTL_STAT_ADD32(ctx, child, "9m", &stats->txrates[5], in urtw_sysctl_node()
4402 URTW_SYSCTL_STAT_ADD32(ctx, child, "11m", &stats->txrates[3], in urtw_sysctl_node()
4404 URTW_SYSCTL_STAT_ADD32(ctx, child, "12m", &stats->txrates[6], in urtw_sysctl_node()
4406 URTW_SYSCTL_STAT_ADD32(ctx, child, "18m", &stats->txrates[7], in urtw_sysctl_node()
4408 URTW_SYSCTL_STAT_ADD32(ctx, child, "24m", &stats->txrates[8], in urtw_sysctl_node()
4410 URTW_SYSCTL_STAT_ADD32(ctx, child, "36m", &stats->txrates[9], in urtw_sysctl_node()
4412 URTW_SYSCTL_STAT_ADD32(ctx, child, "48m", &stats->txrates[10], in urtw_sysctl_node()
4414 URTW_SYSCTL_STAT_ADD32(ctx, child, "54m", &stats->txrates[11], in urtw_sysctl_node()