Lines Matching +full:txpower +full:- +full:5 +full:g
2 /*-
22 /*-
87 ((rssi) - (RAL_NOISE_FLOOR + RAL_RSSI_CORR)) : 0)
306 * For dual-band RF, RF registers R1 and R4 also depend on channel number;
319 { 5, 0x08808, 0x00461, 0x00282 },
411 if (uaa->usb_mode != USB_MODE_HOST) in ural_match()
413 if (uaa->info.bConfigIndex != 0) in ural_match()
415 if (uaa->info.bIfaceIndex != RAL_IFACE_INDEX) in ural_match()
426 struct ieee80211com *ic = &sc->sc_ic; in ural_attach()
431 sc->sc_udev = uaa->device; in ural_attach()
432 sc->sc_dev = self; in ural_attach()
434 mtx_init(&sc->sc_mtx, device_get_nameunit(self), in ural_attach()
436 mbufq_init(&sc->sc_snd, ifqmaxlen); in ural_attach()
439 error = usbd_transfer_setup(uaa->device, in ural_attach()
440 &iface_index, sc->sc_xfer, ural_config, in ural_attach()
441 URAL_N_TRANSFER, sc, &sc->sc_mtx); in ural_attach()
450 sc->asic_rev = ural_read(sc, RAL_MAC_CSR0); in ural_attach()
457 sc->asic_rev, ural_get_rf(sc->rf_rev)); in ural_attach()
459 ic->ic_softc = sc; in ural_attach()
460 ic->ic_name = device_get_nameunit(self); in ural_attach()
461 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in ural_attach()
464 ic->ic_caps = in ural_attach()
476 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in ural_attach()
478 ural_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in ural_attach()
479 ic->ic_channels); in ural_attach()
482 ic->ic_update_promisc = ural_update_promisc; in ural_attach()
483 ic->ic_raw_xmit = ural_raw_xmit; in ural_attach()
484 ic->ic_scan_start = ural_scan_start; in ural_attach()
485 ic->ic_scan_end = ural_scan_end; in ural_attach()
486 ic->ic_getradiocaps = ural_getradiocaps; in ural_attach()
487 ic->ic_set_channel = ural_set_channel; in ural_attach()
488 ic->ic_parent = ural_parent; in ural_attach()
489 ic->ic_transmit = ural_transmit; in ural_attach()
490 ic->ic_vap_create = ural_vap_create; in ural_attach()
491 ic->ic_vap_delete = ural_vap_delete; in ural_attach()
494 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in ural_attach()
496 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in ural_attach()
513 struct ieee80211com *ic = &sc->sc_ic; in ural_detach()
517 sc->sc_detached = 1; in ural_detach()
521 usbd_transfer_unsetup(sc->sc_xfer, URAL_N_TRANSFER); in ural_detach()
528 if (ic->ic_softc == sc) in ural_detach()
530 mbufq_drain(&sc->sc_snd); in ural_detach()
531 mtx_destroy(&sc->sc_mtx); in ural_detach()
543 while (ntries--) { in ural_do_request()
544 err = usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, in ural_do_request()
563 struct ural_softc *sc = ic->ic_softc; in ural_vap_create()
567 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in ural_vap_create()
570 vap = &uvp->vap; in ural_vap_create()
581 uvp->newstate = vap->iv_newstate; in ural_vap_create()
582 vap->iv_newstate = ural_newstate; in ural_vap_create()
584 usb_callout_init_mtx(&uvp->ratectl_ch, &sc->sc_mtx, 0); in ural_vap_create()
585 TASK_INIT(&uvp->ratectl_task, 0, ural_ratectl_task, uvp); in ural_vap_create()
592 ic->ic_opmode = opmode; in ural_vap_create()
600 struct ieee80211com *ic = vap->iv_ic; in ural_vap_delete()
602 usb_callout_drain(&uvp->ratectl_ch); in ural_vap_delete()
603 ieee80211_draintask(ic, &uvp->ratectl_task); in ural_vap_delete()
612 struct ural_softc *sc = data->sc; in ural_tx_free()
614 if (data->m != NULL) { in ural_tx_free()
615 ieee80211_tx_complete(data->ni, data->m, txerr); in ural_tx_free()
616 data->m = NULL; in ural_tx_free()
617 data->ni = NULL; in ural_tx_free()
619 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in ural_tx_free()
620 sc->tx_nfree++; in ural_tx_free()
629 sc->tx_nfree = 0; in ural_setup_tx_list()
630 STAILQ_INIT(&sc->tx_q); in ural_setup_tx_list()
631 STAILQ_INIT(&sc->tx_free); in ural_setup_tx_list()
634 data = &sc->tx_data[i]; in ural_setup_tx_list()
636 data->sc = sc; in ural_setup_tx_list()
637 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in ural_setup_tx_list()
638 sc->tx_nfree++; in ural_setup_tx_list()
649 sc->tx_nfree = 0; in ural_unsetup_tx_list()
650 STAILQ_INIT(&sc->tx_q); in ural_unsetup_tx_list()
651 STAILQ_INIT(&sc->tx_free); in ural_unsetup_tx_list()
655 data = &sc->tx_data[i]; in ural_unsetup_tx_list()
657 if (data->m != NULL) { in ural_unsetup_tx_list()
658 m_freem(data->m); in ural_unsetup_tx_list()
659 data->m = NULL; in ural_unsetup_tx_list()
661 if (data->ni != NULL) { in ural_unsetup_tx_list()
662 ieee80211_free_node(data->ni); in ural_unsetup_tx_list()
663 data->ni = NULL; in ural_unsetup_tx_list()
672 struct ieee80211com *ic = vap->iv_ic; in ural_newstate()
673 struct ural_softc *sc = ic->ic_softc; in ural_newstate()
678 DPRINTF("%s -> %s\n", in ural_newstate()
679 ieee80211_state_name[vap->iv_state], in ural_newstate()
684 usb_callout_stop(&uvp->ratectl_ch); in ural_newstate()
688 if (vap->iv_state == IEEE80211_S_RUN) { in ural_newstate()
698 ni = ieee80211_ref_node(vap->iv_bss); in ural_newstate()
700 if (vap->iv_opmode != IEEE80211_M_MONITOR) { in ural_newstate()
701 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) in ural_newstate()
706 ural_set_basicrates(sc, ic->ic_bsschan); in ural_newstate()
707 IEEE80211_ADDR_COPY(sc->sc_bssid, ni->ni_bssid); in ural_newstate()
708 ural_set_bssid(sc, sc->sc_bssid); in ural_newstate()
711 if (vap->iv_opmode == IEEE80211_M_HOSTAP || in ural_newstate()
712 vap->iv_opmode == IEEE80211_M_IBSS) { in ural_newstate()
715 device_printf(sc->sc_dev, in ural_newstate()
721 device_printf(sc->sc_dev, in ural_newstate()
730 if (vap->iv_opmode != IEEE80211_M_MONITOR) in ural_newstate()
737 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_curchan)]; in ural_newstate()
738 if (tp->ucastrate == IEEE80211_FIXED_RATE_NONE) in ural_newstate()
748 return (uvp->newstate(vap, nstate, arg)); in ural_newstate()
754 return (-1); in ural_newstate()
781 data = STAILQ_FIRST(&sc->tx_q); in ural_bulk_write_callback()
783 STAILQ_REMOVE_HEAD(&sc->tx_q, next); in ural_bulk_write_callback()
784 m = data->m; in ural_bulk_write_callback()
786 if (m->m_pkthdr.len > (int)(RAL_FRAME_SIZE + RAL_TX_DESC_SIZE)) { in ural_bulk_write_callback()
788 m->m_pkthdr.len); in ural_bulk_write_callback()
789 m->m_pkthdr.len = (RAL_FRAME_SIZE + RAL_TX_DESC_SIZE); in ural_bulk_write_callback()
792 usbd_copy_in(pc, 0, &data->desc, RAL_TX_DESC_SIZE); in ural_bulk_write_callback()
794 m->m_pkthdr.len); in ural_bulk_write_callback()
796 vap = data->ni->ni_vap; in ural_bulk_write_callback()
798 struct ural_tx_radiotap_header *tap = &sc->sc_txtap; in ural_bulk_write_callback()
800 tap->wt_flags = 0; in ural_bulk_write_callback()
801 tap->wt_rate = data->rate; in ural_bulk_write_callback()
802 tap->wt_antenna = sc->tx_ant; in ural_bulk_write_callback()
808 len = (RAL_TX_DESC_SIZE + m->m_pkthdr.len + 1) & ~1; in ural_bulk_write_callback()
813 m->m_pkthdr.len, len); in ural_bulk_write_callback()
839 device_printf(sc->sc_dev, "device timeout\n"); in ural_bulk_write_callback()
848 struct ieee80211com *ic = &sc->sc_ic; in ural_bulk_read_callback()
865 device_get_nameunit(sc->sc_dev), len); in ural_bulk_read_callback()
866 counter_u64_add(ic->ic_ierrors, 1); in ural_bulk_read_callback()
870 len -= RAL_RX_DESC_SIZE; in ural_bulk_read_callback()
873 usbd_copy_out(pc, len, &sc->sc_rx_desc, RAL_RX_DESC_SIZE); in ural_bulk_read_callback()
875 rssi = URAL_RSSI(sc->sc_rx_desc.rssi); in ural_bulk_read_callback()
877 flags = le32toh(sc->sc_rx_desc.flags); in ural_bulk_read_callback()
884 DPRINTFN(5, "PHY or CRC error\n"); in ural_bulk_read_callback()
885 counter_u64_add(ic->ic_ierrors, 1); in ural_bulk_read_callback()
892 counter_u64_add(ic->ic_ierrors, 1); in ural_bulk_read_callback()
898 m->m_pkthdr.len = m->m_len = (flags >> 16) & 0xfff; in ural_bulk_read_callback()
901 struct ural_rx_radiotap_header *tap = &sc->sc_rxtap; in ural_bulk_read_callback()
904 tap->wr_flags = 0; in ural_bulk_read_callback()
905 tap->wr_rate = ieee80211_plcp2rate(sc->sc_rx_desc.rate, in ural_bulk_read_callback()
908 tap->wr_antenna = sc->rx_ant; in ural_bulk_read_callback()
909 tap->wr_antsignal = nf + rssi; in ural_bulk_read_callback()
910 tap->wr_antnoise = nf; in ural_bulk_read_callback()
913 m_adj(m, -IEEE80211_CRC_LEN); in ural_bulk_read_callback()
954 /* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */ in ural_plcp_signal()
964 /* CCK rates (NB: not IEEE std, device-specific) */ in ural_plcp_signal()
977 struct ieee80211com *ic = &sc->sc_ic; in ural_setup_tx_desc()
981 desc->flags = htole32(flags); in ural_setup_tx_desc()
982 desc->flags |= htole32(RAL_TX_NEWSEQ); in ural_setup_tx_desc()
983 desc->flags |= htole32(len << 16); in ural_setup_tx_desc()
985 desc->wme = htole16(RAL_AIFSN(2) | RAL_LOGCWMIN(3) | RAL_LOGCWMAX(5)); in ural_setup_tx_desc()
986 desc->wme |= htole16(RAL_IVOFFSET(sizeof (struct ieee80211_frame))); in ural_setup_tx_desc()
989 desc->plcp_signal = ural_plcp_signal(rate); in ural_setup_tx_desc()
990 desc->plcp_service = 4; in ural_setup_tx_desc()
993 if (ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM) { in ural_setup_tx_desc()
994 desc->flags |= htole32(RAL_TX_OFDM); in ural_setup_tx_desc()
997 desc->plcp_length_hi = plcp_length >> 6; in ural_setup_tx_desc()
998 desc->plcp_length_lo = plcp_length & 0x3f; in ural_setup_tx_desc()
1006 desc->plcp_service |= RAL_PLCP_LENGEXT; in ural_setup_tx_desc()
1008 desc->plcp_length_hi = plcp_length >> 8; in ural_setup_tx_desc()
1009 desc->plcp_length_lo = plcp_length & 0xff; in ural_setup_tx_desc()
1011 if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) in ural_setup_tx_desc()
1012 desc->plcp_signal |= 0x08; in ural_setup_tx_desc()
1015 desc->iv = 0; in ural_setup_tx_desc()
1016 desc->eiv = 0; in ural_setup_tx_desc()
1024 struct ieee80211vap *vap = ni->ni_vap; in ural_tx_bcn()
1025 struct ieee80211com *ic = ni->ni_ic; in ural_tx_bcn()
1029 if (sc->tx_nfree == 0) { in ural_tx_bcn()
1034 if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) { in ural_tx_bcn()
1039 data = STAILQ_FIRST(&sc->tx_free); in ural_tx_bcn()
1040 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in ural_tx_bcn()
1041 sc->tx_nfree--; in ural_tx_bcn()
1042 tp = &vap->iv_txparms[ieee80211_chan2mode(ic->ic_bsschan)]; in ural_tx_bcn()
1044 data->m = m0; in ural_tx_bcn()
1045 data->ni = ni; in ural_tx_bcn()
1046 data->rate = tp->mgmtrate; in ural_tx_bcn()
1048 ural_setup_tx_desc(sc, &data->desc, in ural_tx_bcn()
1049 RAL_TX_IFS_NEWBACKOFF | RAL_TX_TIMESTAMP, m0->m_pkthdr.len, in ural_tx_bcn()
1050 tp->mgmtrate); in ural_tx_bcn()
1053 m0->m_pkthdr.len, tp->mgmtrate); in ural_tx_bcn()
1055 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in ural_tx_bcn()
1056 usbd_transfer_start(sc->sc_xfer[URAL_BULK_WR]); in ural_tx_bcn()
1064 const struct ieee80211_txparam *tp = ni->ni_txparms; in ural_tx_mgt()
1065 struct ieee80211com *ic = ni->ni_ic; in ural_tx_mgt()
1074 data = STAILQ_FIRST(&sc->tx_free); in ural_tx_mgt()
1075 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in ural_tx_mgt()
1076 sc->tx_nfree--; in ural_tx_mgt()
1078 ieee80211_output_seqno_assign(ni, -1, m0); in ural_tx_mgt()
1081 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in ural_tx_mgt()
1090 data->m = m0; in ural_tx_mgt()
1091 data->ni = ni; in ural_tx_mgt()
1092 data->rate = tp->mgmtrate; in ural_tx_mgt()
1095 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in ural_tx_mgt()
1098 dur = ieee80211_ack_duration(ic->ic_rt, tp->mgmtrate, in ural_tx_mgt()
1099 ic->ic_flags & IEEE80211_F_SHPREAMBLE); in ural_tx_mgt()
1100 USETW(wh->i_dur, dur); in ural_tx_mgt()
1107 ural_setup_tx_desc(sc, &data->desc, flags, m0->m_pkthdr.len, tp->mgmtrate); in ural_tx_mgt()
1110 m0->m_pkthdr.len, tp->mgmtrate); in ural_tx_mgt()
1112 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in ural_tx_mgt()
1113 usbd_transfer_start(sc->sc_xfer[URAL_BULK_WR]); in ural_tx_mgt()
1122 struct ieee80211com *ic = ni->ni_ic; in ural_sendprot()
1129 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); in ural_sendprot()
1130 device_printf(sc->sc_dev, in ural_sendprot()
1135 protrate = ieee80211_ctl_rate(ic->ic_rt, rate); in ural_sendprot()
1140 data = STAILQ_FIRST(&sc->tx_free); in ural_sendprot()
1141 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in ural_sendprot()
1142 sc->tx_nfree--; in ural_sendprot()
1144 data->m = mprot; in ural_sendprot()
1145 data->ni = ieee80211_ref_node(ni); in ural_sendprot()
1146 data->rate = protrate; in ural_sendprot()
1147 ural_setup_tx_desc(sc, &data->desc, flags, mprot->m_pkthdr.len, protrate); in ural_sendprot()
1149 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in ural_sendprot()
1150 usbd_transfer_start(sc->sc_xfer[URAL_BULK_WR]); in ural_sendprot()
1159 struct ieee80211com *ic = ni->ni_ic; in ural_tx_raw()
1168 rate = params->ibp_rate0; in ural_tx_raw()
1169 if (!ieee80211_isratevalid(ic->ic_rt, rate)) { in ural_tx_raw()
1174 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) in ural_tx_raw()
1176 if (params->ibp_flags & (IEEE80211_BPF_RTS|IEEE80211_BPF_CTS)) { in ural_tx_raw()
1178 params->ibp_flags & IEEE80211_BPF_RTS ? in ural_tx_raw()
1181 if (error || sc->tx_nfree == 0) { in ural_tx_raw()
1188 data = STAILQ_FIRST(&sc->tx_free); in ural_tx_raw()
1189 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in ural_tx_raw()
1190 sc->tx_nfree--; in ural_tx_raw()
1192 data->m = m0; in ural_tx_raw()
1193 data->ni = ni; in ural_tx_raw()
1194 data->rate = rate; in ural_tx_raw()
1197 ural_setup_tx_desc(sc, &data->desc, flags, m0->m_pkthdr.len, rate); in ural_tx_raw()
1200 m0->m_pkthdr.len, rate); in ural_tx_raw()
1202 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in ural_tx_raw()
1203 usbd_transfer_start(sc->sc_xfer[URAL_BULK_WR]); in ural_tx_raw()
1211 struct ieee80211vap *vap = ni->ni_vap; in ural_tx_data()
1212 struct ieee80211com *ic = ni->ni_ic; in ural_tx_data()
1215 const struct ieee80211_txparam *tp = ni->ni_txparms; in ural_tx_data()
1225 if (m0->m_flags & M_EAPOL) in ural_tx_data()
1226 rate = tp->mgmtrate; in ural_tx_data()
1227 else if (IEEE80211_IS_MULTICAST(wh->i_addr1)) in ural_tx_data()
1228 rate = tp->mcastrate; in ural_tx_data()
1229 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in ural_tx_data()
1230 rate = tp->ucastrate; in ural_tx_data()
1236 ieee80211_output_seqno_assign(ni, -1, m0); in ural_tx_data()
1238 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in ural_tx_data()
1248 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in ural_tx_data()
1250 if (m0->m_pkthdr.len + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) in ural_tx_data()
1252 else if ((ic->ic_flags & IEEE80211_F_USEPROT) && in ural_tx_data()
1253 ieee80211_rate2phytype(ic->ic_rt, rate) == IEEE80211_T_OFDM) in ural_tx_data()
1254 prot = ic->ic_protmode; in ural_tx_data()
1257 if (error || sc->tx_nfree == 0) { in ural_tx_data()
1265 data = STAILQ_FIRST(&sc->tx_free); in ural_tx_data()
1266 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in ural_tx_data()
1267 sc->tx_nfree--; in ural_tx_data()
1269 data->m = m0; in ural_tx_data()
1270 data->ni = ni; in ural_tx_data()
1271 data->rate = rate; in ural_tx_data()
1273 if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { in ural_tx_data()
1277 dur = ieee80211_ack_duration(ic->ic_rt, rate, in ural_tx_data()
1278 ic->ic_flags & IEEE80211_F_SHPREAMBLE); in ural_tx_data()
1279 USETW(wh->i_dur, dur); in ural_tx_data()
1282 ural_setup_tx_desc(sc, &data->desc, flags, m0->m_pkthdr.len, rate); in ural_tx_data()
1285 m0->m_pkthdr.len, rate); in ural_tx_data()
1287 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in ural_tx_data()
1288 usbd_transfer_start(sc->sc_xfer[URAL_BULK_WR]); in ural_tx_data()
1296 struct ural_softc *sc = ic->ic_softc; in ural_transmit()
1300 if (!sc->sc_running) { in ural_transmit()
1304 error = mbufq_enqueue(&sc->sc_snd, m); in ural_transmit()
1323 if (sc->sc_running == 0) in ural_start()
1326 while (sc->tx_nfree >= RAL_TX_MINFREE && in ural_start()
1327 (m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in ural_start()
1328 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; in ural_start()
1330 if_inc_counter(ni->ni_vap->iv_ifp, in ural_start()
1341 struct ural_softc *sc = ic->ic_softc; in ural_parent()
1345 if (sc->sc_detached) { in ural_parent()
1349 if (ic->ic_nrunning > 0) { in ural_parent()
1350 if (sc->sc_running == 0) { in ural_parent()
1355 } else if (sc->sc_running) in ural_parent()
1376 device_printf(sc->sc_dev, "could not set test mode: %s\n", in ural_set_testmode()
1395 device_printf(sc->sc_dev, "could not read EEPROM: %s\n", in ural_eeprom_read()
1415 device_printf(sc->sc_dev, "could not read MAC register: %s\n", in ural_read()
1437 device_printf(sc->sc_dev, "could not read MAC register: %s\n", in ural_read_multi()
1456 device_printf(sc->sc_dev, "could not write MAC register: %s\n", in ural_write()
1475 device_printf(sc->sc_dev, "could not write MAC register: %s\n", in ural_write_multi()
1493 device_printf(sc->sc_dev, "could not write to BBP\n"); in ural_bbp_write()
1517 device_printf(sc->sc_dev, "could not read BBP\n"); in ural_bbp_read()
1537 device_printf(sc->sc_dev, "could not write to RF\n"); in ural_rf_write()
1546 sc->rf_regs[reg] = val; in ural_rf_write()
1548 DPRINTFN(15, "RF R[%u] <- 0x%05x\n", reg & 0x3, val & 0xfffff); in ural_rf_write()
1554 struct ural_softc *sc = ic->ic_softc; in ural_scan_start()
1565 struct ural_softc *sc = ic->ic_softc; in ural_scan_end()
1569 ural_set_bssid(sc, sc->sc_bssid); in ural_scan_end()
1578 struct ural_softc *sc = ic->ic_softc; in ural_getradiocaps()
1586 if (sc->rf_rev == RAL_RF_5222) { in ural_getradiocaps()
1596 struct ural_softc *sc = ic->ic_softc; in ural_set_channel()
1599 ural_set_chan(sc, ic->ic_curchan); in ural_set_channel()
1606 struct ieee80211com *ic = &sc->sc_ic; in ural_set_chan()
1615 power = min(sc->txpow[chan - 1], 31); in ural_set_chan()
1619 /* adjust txpower using ifconfig settings */ in ural_set_chan()
1620 power -= (100 - ic->ic_txpowlimit) / 8; in ural_set_chan()
1622 DPRINTFN(2, "setting channel to %u, txpower to %u\n", chan, power); in ural_set_chan()
1624 switch (sc->rf_rev) { in ural_set_chan()
1627 ural_rf_write(sc, RAL_RF2, ural_rf2522_r2[chan - 1]); in ural_set_chan()
1633 ural_rf_write(sc, RAL_RF2, ural_rf2523_r2[chan - 1]); in ural_set_chan()
1640 ural_rf_write(sc, RAL_RF2, ural_rf2524_r2[chan - 1]); in ural_set_chan()
1647 ural_rf_write(sc, RAL_RF2, ural_rf2525_hi_r2[chan - 1]); in ural_set_chan()
1652 ural_rf_write(sc, RAL_RF2, ural_rf2525_r2[chan - 1]); in ural_set_chan()
1659 ural_rf_write(sc, RAL_RF2, ural_rf2525e_r2[chan - 1]); in ural_set_chan()
1665 ural_rf_write(sc, RAL_RF2, ural_rf2526_hi_r2[chan - 1]); in ural_set_chan()
1669 ural_rf_write(sc, RAL_RF2, ural_rf2526_r2[chan - 1]); in ural_set_chan()
1674 /* dual-band RF */ in ural_set_chan()
1685 if (ic->ic_opmode != IEEE80211_M_MONITOR && in ural_set_chan()
1686 (ic->ic_flags & IEEE80211_F_SCAN) == 0) { in ural_set_chan()
1712 * Disable RF auto-tuning.
1719 if (sc->rf_rev != RAL_RF_2523) { in ural_disable_rf_tune()
1720 tmp = sc->rf_regs[RAL_RF1] & ~RAL_RF1_AUTOTUNE; in ural_disable_rf_tune()
1724 tmp = sc->rf_regs[RAL_RF3] & ~RAL_RF3_AUTOTUNE; in ural_disable_rf_tune()
1731 * Refer to IEEE Std 802.11-1999 pp. 123 for more information on TSF
1737 struct ieee80211com *ic = &sc->sc_ic; in ural_enable_tsf_sync()
1738 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in ural_enable_tsf_sync()
1744 tmp = (16 * vap->iv_bss->ni_intval) << 4; in ural_enable_tsf_sync()
1747 logcwmin = (ic->ic_opmode == IEEE80211_M_IBSS) ? 2 : 0; in ural_enable_tsf_sync()
1748 preload = (ic->ic_opmode == IEEE80211_M_IBSS) ? 320 : 6; in ural_enable_tsf_sync()
1754 if (ic->ic_opmode == IEEE80211_M_STA) in ural_enable_tsf_sync()
1771 #define RAL_RXTX_TURNAROUND 5 /* us */
1775 struct ieee80211com *ic = &sc->sc_ic; in ural_update_slot()
1784 if (ic->ic_curmode == IEEE80211_MODE_11B) { in ural_update_slot()
1785 sifs = 16 - RAL_RXTX_TURNAROUND; in ural_update_slot()
1788 sifs = 10 - RAL_RXTX_TURNAROUND; in ural_update_slot()
1800 struct ieee80211com *ic = &sc->sc_ic; in ural_set_txpreamble()
1806 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE) in ural_set_txpreamble()
1821 /* 11g basic rates: 1, 2, 5.5, 11, 6, 12, 24Mbps */ in ural_set_basicrates()
1840 tmp = bssid[4] | bssid[5] << 8; in ural_set_bssid()
1857 tmp = addr[4] | addr[5] << 8; in ural_set_macaddr()
1871 if (sc->sc_ic.ic_promisc == 0) in ural_setpromisc()
1876 DPRINTF("%s promiscuous mode\n", sc->sc_ic.ic_promisc ? in ural_setpromisc()
1883 struct ural_softc *sc = ic->ic_softc; in ural_update_promisc()
1886 if (sc->sc_running) in ural_update_promisc()
1909 struct ieee80211com *ic = &sc->sc_ic; in ural_read_eeprom()
1914 sc->rf_rev = (val >> 11) & 0x7; in ural_read_eeprom()
1915 sc->hw_radio = (val >> 10) & 0x1; in ural_read_eeprom()
1916 sc->led_mode = (val >> 6) & 0x7; in ural_read_eeprom()
1917 sc->rx_ant = (val >> 4) & 0x3; in ural_read_eeprom()
1918 sc->tx_ant = (val >> 2) & 0x3; in ural_read_eeprom()
1919 sc->nb_ant = val & 0x3; in ural_read_eeprom()
1922 ural_eeprom_read(sc, RAL_EEPROM_ADDRESS, ic->ic_macaddr, 6); in ural_read_eeprom()
1925 ural_eeprom_read(sc, RAL_EEPROM_BBP_BASE, sc->bbp_prom, 2 * 16); in ural_read_eeprom()
1927 /* read Tx power for all b/g channels */ in ural_read_eeprom()
1928 ural_eeprom_read(sc, RAL_EEPROM_TXPOWER, sc->txpow, 14); in ural_read_eeprom()
1944 device_printf(sc->sc_dev, "timeout waiting for BBP\n"); in ural_bbp_init()
1955 if (sc->bbp_prom[i].reg == 0xff) in ural_bbp_init()
1957 ural_bbp_write(sc, sc->bbp_prom[i].reg, sc->bbp_prom[i].val); in ural_bbp_init()
1979 if (sc->rf_rev == RAL_RF_2525E || sc->rf_rev == RAL_RF_2526 || in ural_set_txantenna()
1980 sc->rf_rev == RAL_RF_5222) in ural_set_txantenna()
2007 if (sc->rf_rev == RAL_RF_2525E || sc->rf_rev == RAL_RF_2526) in ural_set_rxantenna()
2016 struct ieee80211com *ic = &sc->sc_ic; in ural_init()
2017 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in ural_init()
2042 device_printf(sc->sc_dev, in ural_init()
2056 ural_set_chan(sc, ic->ic_curchan); in ural_init()
2059 ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof sc->sta); in ural_init()
2061 ural_set_txantenna(sc, sc->tx_ant); in ural_init()
2062 ural_set_rxantenna(sc, sc->rx_ant); in ural_init()
2064 ural_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); in ural_init()
2073 if (ic->ic_opmode != IEEE80211_M_MONITOR) { in ural_init()
2075 if (ic->ic_opmode != IEEE80211_M_HOSTAP) in ural_init()
2077 if (ic->ic_promisc == 0) in ural_init()
2082 sc->sc_running = 1; in ural_init()
2083 usbd_xfer_set_stall(sc->sc_xfer[URAL_BULK_WR]); in ural_init()
2084 usbd_transfer_start(sc->sc_xfer[URAL_BULK_RD]); in ural_init()
2096 sc->sc_running = 0; in ural_stop()
2102 usbd_transfer_drain(sc->sc_xfer[URAL_BULK_WR]); in ural_stop()
2103 usbd_transfer_drain(sc->sc_xfer[URAL_BULK_RD]); in ural_stop()
2123 struct ieee80211com *ic = ni->ni_ic; in ural_raw_xmit()
2124 struct ural_softc *sc = ic->ic_softc; in ural_raw_xmit()
2128 if (!sc->sc_running) { in ural_raw_xmit()
2133 if (sc->tx_nfree < RAL_TX_MINFREE) { in ural_raw_xmit()
2164 struct ieee80211vap *vap = ni->ni_vap; in ural_ratectl_start()
2168 ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof sc->sta); in ural_ratectl_start()
2170 usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); in ural_ratectl_start()
2177 struct ieee80211vap *vap = &uvp->vap; in ural_ratectl_timeout()
2178 struct ieee80211com *ic = vap->iv_ic; in ural_ratectl_timeout()
2180 ieee80211_runtask(ic, &uvp->ratectl_task); in ural_ratectl_timeout()
2187 struct ieee80211vap *vap = &uvp->vap; in ural_ratectl_task()
2188 struct ural_softc *sc = vap->iv_ic->ic_softc; in ural_ratectl_task()
2189 struct ieee80211_ratectl_tx_stats *txs = &sc->sc_txs; in ural_ratectl_task()
2194 ural_read_multi(sc, RAL_STA_CSR0, sc->sta, sizeof(sc->sta)); in ural_ratectl_task()
2196 txs->flags = IEEE80211_RATECTL_TX_STATS_RETRIES; in ural_ratectl_task()
2197 txs->nsuccess = sc->sta[7] + /* TX ok w/o retry */ in ural_ratectl_task()
2198 sc->sta[8]; /* TX ok w/ retry */ in ural_ratectl_task()
2199 fail = sc->sta[9]; /* TX retry-fail count */ in ural_ratectl_task()
2200 txs->nframes = txs->nsuccess + fail; in ural_ratectl_task()
2202 txs->nretries = sc->sta[8] + fail; in ural_ratectl_task()
2206 /* count TX retry-fail as Tx errors */ in ural_ratectl_task()
2207 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, fail); in ural_ratectl_task()
2209 usb_callout_reset(&uvp->ratectl_ch, hz, ural_ratectl_timeout, uvp); in ural_ratectl_task()
2217 usb_pause_mtx(&sc->sc_mtx, timeout); in ural_pause()