Lines Matching +full:ext +full:- +full:fem +full:- +full:name

3 /*-
98 device_printf(sc->sc_dev, __VA_ARGS__); \
217 .name = "otus",
275 if (uaa->usb_mode != USB_MODE_HOST ||
276 uaa->info.bIfaceIndex != 0 ||
277 uaa->info.bConfigIndex != 0)
292 sc->sc_udev = uaa->device;
293 sc->sc_dev = self;
295 mtx_init(&sc->sc_mtx, device_get_nameunit(self), MTX_NETWORK_LOCK,
298 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->scan_to, 0, otus_next_scan, sc);
299 TIMEOUT_TASK_INIT(taskqueue_thread, &sc->calib_to, 0, otus_calibrate_to, sc);
300 TASK_INIT(&sc->tx_task, 0, otus_tx_task, sc);
301 mbufq_init(&sc->sc_snd, ifqmaxlen);
304 error = usbd_transfer_setup(uaa->device, &iface_index, sc->sc_xfer,
305 otus_config, OTUS_N_XFER, sc, &sc->sc_mtx);
307 device_printf(sc->sc_dev,
314 device_printf(sc->sc_dev, "%s: could not open pipes\n",
328 mtx_destroy(&sc->sc_mtx);
336 struct ieee80211com *ic = &sc->sc_ic;
340 usbd_transfer_unsetup(sc->sc_xfer, OTUS_N_XFER);
342 taskqueue_drain_timeout(taskqueue_thread, &sc->scan_to);
343 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_to);
344 taskqueue_drain(taskqueue_thread, &sc->tx_task);
349 usb_rem_wait_task(sc->sc_udev, &sc->sc_task);
351 usbd_ref_wait(sc->sc_udev);
355 mtx_destroy(&sc->sc_mtx);
367 otus_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
375 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
379 vap = &uvp->vap;
381 if (ieee80211_vap_setup(ic, vap, name, unit, opmode,
389 uvp->newstate = vap->iv_newstate;
390 vap->iv_newstate = otus_newstate;
392 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_8;
393 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K;
400 ic->ic_opmode = opmode;
418 struct otus_softc *sc = ic->ic_softc;
421 if (ic->ic_nrunning > 0) {
422 if (!sc->sc_running) {
428 } else if (sc->sc_running)
442 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
443 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif;
444 m->m_pkthdr.rcvif = NULL;
454 taskqueue_enqueue(taskqueue_thread, &sc->tx_task);
460 struct otus_softc *sc = ic->ic_softc;
464 if (! sc->sc_running) {
470 error = mbufq_enqueue(&sc->sc_snd, m);
496 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
501 mbufq_prepend(&sc->sc_snd, m);
505 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
506 m->m_pkthdr.rcvif = NULL;
511 if_inc_counter(ni->ni_vap->iv_ifp,
535 struct ieee80211com *ic= ni->ni_ic;
536 struct otus_softc *sc = ic->ic_softc;
542 if (! sc->sc_running) {
578 struct otus_softc *sc = ic->ic_softc;
581 ic->ic_curchan->ic_freq);
584 (void) otus_set_chan(sc, ic->ic_curchan, 0);
592 /* For now, no A-MPDU TX support in the driver */
613 struct otus_softc *sc = ic->ic_softc;
621 struct ieee80211com *ic = &sc->sc_ic;
629 device_printf(sc->sc_dev, "%s: could not load %s firmware\n",
640 device_printf(sc->sc_dev, "%s: could not load %s firmware\n",
653 if (usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx, &req, NULL,
656 device_printf(sc->sc_dev,
666 device_printf(sc->sc_dev,
672 device_printf(sc->sc_dev,
681 device_printf(sc->sc_dev,
689 sc->txmask = sc->eeprom.baseEepHeader.txMask;
690 sc->rxmask = sc->eeprom.baseEepHeader.rxMask;
691 sc->capflags = sc->eeprom.baseEepHeader.opCapFlags;
692 IEEE80211_ADDR_COPY(ic->ic_macaddr, sc->eeprom.baseEepHeader.macAddr);
693 sc->sc_led_newstate = otus_led_newstate_type3; /* XXX */
695 if (sc->txmask == 0x5)
696 ic->ic_txstream = 2;
698 ic->ic_txstream = 1;
700 if (sc->rxmask == 0x5)
701 ic->ic_rxstream = 2;
703 ic->ic_rxstream = 1;
705 device_printf(sc->sc_dev,
707 (sc->capflags & AR5416_OPFLAGS_11A) ?
708 0x9104 : ((sc->txmask == 0x5) ? 0x9102 : 0x9101),
709 (sc->txmask == 0x5) ? 2 : 1, (sc->rxmask == 0x5) ? 2 : 1,
710 ether_sprintf(ic->ic_macaddr));
712 ic->ic_softc = sc;
713 ic->ic_name = device_get_nameunit(sc->sc_dev);
714 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
715 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */
718 ic->ic_caps =
726 IEEE80211_C_FF | /* Atheros fast-frames supported. */
728 IEEE80211_C_SWAMSDUTX | /* Do software A-MSDU TX */
731 ic->ic_htcaps =
740 otus_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
741 ic->ic_channels);
744 ic->ic_raw_xmit = otus_raw_xmit;
745 ic->ic_scan_start = otus_scan_start;
746 ic->ic_scan_end = otus_scan_end;
747 ic->ic_set_channel = otus_set_channel;
748 ic->ic_getradiocaps = otus_getradiocaps;
749 ic->ic_vap_create = otus_vap_create;
750 ic->ic_vap_delete = otus_vap_delete;
751 ic->ic_update_mcast = otus_update_mcast;
752 ic->ic_update_promisc = otus_update_mcast;
753 ic->ic_parent = otus_parent;
754 ic->ic_transmit = otus_transmit;
755 ic->ic_update_chw = otus_update_chw;
756 ic->ic_ampdu_enable = otus_ampdu_enable;
757 ic->ic_wme.wme_update = otus_updateedca;
758 ic->ic_newassoc = otus_newassoc;
759 ic->ic_node_alloc = otus_node_alloc;
762 ic->ic_set_key = otus_set_key;
763 ic->ic_delete_key = otus_delete_key;
766 ieee80211_radiotap_attach(ic, &sc->sc_txtap.wt_ihdr,
767 sizeof(sc->sc_txtap), OTUS_TX_RADIOTAP_PRESENT,
768 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap),
778 struct otus_softc *sc = ic->ic_softc;
783 if (sc->eeprom.baseEepHeader.opCapFlags & AR5416_OPFLAGS_11G) {
790 if (sc->eeprom.baseEepHeader.opCapFlags & AR5416_OPFLAGS_11A) {
794 &ar_chans[14], nitems(ar_chans) - 14, bands, 0);
799 otus_load_firmware(struct otus_softc *sc, const char *name, uint32_t addr)
809 if ((fw = firmware_get(name)) == NULL) {
810 device_printf(sc->sc_dev,
811 "%s: failed loadfirmware of file %s\n", __func__, name);
821 ptr = __DECONST(char *, fw->data);
822 size = fw->datasize;
829 if (usbd_do_request_flags(sc->sc_udev, &sc->sc_mtx,
836 size -= mlen;
843 device_printf(sc->sc_dev,
844 "%s: %s: error=%d\n", __func__, name, error);
860 device_printf(sc->sc_dev,
867 device_printf(sc->sc_dev, "%s: could not allocate Tx xfers\n",
873 device_printf(sc->sc_dev, "%s: could not allocate Rx xfers\n",
880 usbd_transfer_start(sc->sc_xfer[OTUS_BULK_RX]);
881 usbd_transfer_start(sc->sc_xfer[OTUS_BULK_IRQ]);
899 usbd_transfer_unsetup(sc->sc_xfer, OTUS_N_XFER);
911 if (dp->buf != NULL) {
912 free(dp->buf, M_USBDEV);
913 dp->buf = NULL;
926 dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT | M_ZERO);
927 dp->odata = NULL;
928 if (dp->buf == NULL) {
929 device_printf(sc->sc_dev,
947 error = otus_alloc_cmd_list(sc, sc->sc_cmd, OTUS_CMD_LIST_COUNT,
952 STAILQ_INIT(&sc->sc_cmd_active);
953 STAILQ_INIT(&sc->sc_cmd_inactive);
954 STAILQ_INIT(&sc->sc_cmd_pending);
955 STAILQ_INIT(&sc->sc_cmd_waiting);
958 STAILQ_INSERT_HEAD(&sc->sc_cmd_inactive, &sc->sc_cmd[i],
972 STAILQ_INIT(&sc->sc_cmd_active);
973 STAILQ_INIT(&sc->sc_cmd_inactive);
974 STAILQ_INIT(&sc->sc_cmd_pending);
975 STAILQ_INIT(&sc->sc_cmd_waiting);
977 otus_free_cmd_list(sc, sc->sc_cmd, OTUS_CMD_LIST_COUNT);
988 dp->sc = sc;
989 dp->m = NULL;
990 dp->buf = malloc(maxsz, M_USBDEV, M_NOWAIT | M_ZERO);
991 if (dp->buf == NULL) {
992 device_printf(sc->sc_dev,
997 dp->ni = NULL;
1011 error = otus_alloc_list(sc, sc->sc_rx, OTUS_RX_LIST_COUNT,
1016 STAILQ_INIT(&sc->sc_rx_active);
1017 STAILQ_INIT(&sc->sc_rx_inactive);
1020 STAILQ_INSERT_HEAD(&sc->sc_rx_inactive, &sc->sc_rx[i], next);
1030 error = otus_alloc_list(sc, sc->sc_tx, OTUS_TX_LIST_COUNT,
1035 STAILQ_INIT(&sc->sc_tx_inactive);
1038 STAILQ_INIT(&sc->sc_tx_active[i]);
1039 STAILQ_INIT(&sc->sc_tx_pending[i]);
1043 STAILQ_INSERT_HEAD(&sc->sc_tx_inactive, &sc->sc_tx[i], next);
1055 STAILQ_INIT(&sc->sc_tx_inactive);
1058 STAILQ_INIT(&sc->sc_tx_active[i]);
1059 STAILQ_INIT(&sc->sc_tx_pending[i]);
1062 otus_free_list(sc, sc->sc_tx, OTUS_TX_LIST_COUNT);
1069 STAILQ_INIT(&sc->sc_rx_inactive);
1070 STAILQ_INIT(&sc->sc_rx_active);
1072 otus_free_list(sc, sc->sc_rx, OTUS_RX_LIST_COUNT);
1083 if (dp->buf != NULL) {
1084 free(dp->buf, M_USBDEV);
1085 dp->buf = NULL;
1087 if (dp->ni != NULL) {
1088 ieee80211_free_node(dp->ni);
1089 dp->ni = NULL;
1099 bf = STAILQ_FIRST(&sc->sc_tx_inactive);
1101 STAILQ_REMOVE_HEAD(&sc->sc_tx_inactive, next);
1124 STAILQ_INSERT_TAIL(&sc->sc_tx_inactive, bf, next);
1132 bf = STAILQ_FIRST(&sc->sc_cmd_inactive);
1134 STAILQ_REMOVE_HEAD(&sc->sc_cmd_inactive, next_cmd);
1149 device_printf(sc->sc_dev, "%s: no tx cmd buffers\n",
1160 STAILQ_INSERT_TAIL(&sc->sc_cmd_inactive, bf, next_cmd);
1169 if (usbd_is_dying(sc->sc_udev))
1172 usbd_ref_incr(sc->sc_udev);
1174 if (sc->sc_ic.ic_state == IEEE80211_S_SCAN)
1175 ieee80211_next_scan(&sc->sc_ic.ic_if);
1177 usbd_ref_decr(sc->sc_udev);
1185 struct ieee80211com *ic = vap->iv_ic;
1186 struct otus_softc *sc = ic->ic_softc;
1189 ostate = vap->iv_state;
1190 OTUS_DPRINTF(sc, OTUS_DEBUG_STATE, "%s: %s -> %s\n", __func__,
1206 if (ic->ic_opmode == IEEE80211_M_STA) {
1213 &sc->calib_to, hz);
1222 sc->sc_led_newstate(sc);
1226 return (uvp->newstate(vap, nstate, arg));
1239 /* Always bulk-out a multiple of 4 bytes. */
1242 device_printf(sc->sc_dev, "%s: command (0x%02x) size (%d) > %d\n",
1252 device_printf(sc->sc_dev, "%s: failed to get buf\n",
1257 hdr = (struct ar_cmd_hdr *)cmd->buf;
1258 hdr->code = code;
1259 hdr->len = ilen;
1260 hdr->token = ++sc->token; /* Don't care about endianness. */
1261 cmd->token = hdr->token;
1267 __func__, code, ilen, hdr->token);
1269 cmd->odata = odata;
1270 cmd->odatalen = odatalen;
1271 cmd->buflen = xferlen;
1274 STAILQ_INSERT_TAIL(&sc->sc_cmd_pending, cmd, next_cmd);
1275 usbd_transfer_start(sc->sc_xfer[OTUS_BULK_CMD]);
1278 error = msleep(cmd, &sc->sc_mtx, PCATCH, "otuscmd", hz);
1288 device_printf(sc->sc_dev,
1301 sc->write_buf[sc->write_idx].reg = htole32(reg);
1302 sc->write_buf[sc->write_idx].val = htole32(val);
1304 if (++sc->write_idx > (AR_MAX_WRITE_IDX-1))
1315 if (sc->write_idx == 0)
1320 sc->write_idx);
1322 error = otus_cmd(sc, AR_CMD_WREG, sc->write_buf,
1323 sizeof (sc->write_buf[0]) * sc->write_idx, NULL, 0);
1324 sc->write_idx = 0;
1346 eep = (uint8_t *)&sc->eeprom;
1348 for (i = 0; i < sizeof (sc->eeprom) / 32; i++) {
1362 struct ieee80211com *ic = ni->ni_ic;
1363 struct otus_softc *sc = ic->ic_softc;
1367 isnew, ether_sprintf(ni->ni_macaddr));
1369 on->tx_done = 0;
1370 on->tx_err = 0;
1371 on->tx_retries = 0;
1384 hdr->code, hdr->len, hdr->token);
1390 while ((cmd = STAILQ_FIRST(&sc->sc_cmd_waiting)) != NULL) {
1391 STAILQ_REMOVE_HEAD(&sc->sc_cmd_waiting, next_cmd);
1396 (int) hdr->token,
1397 (int) cmd->token);
1398 if (hdr->token == cmd->token) {
1400 if (cmd->odata != NULL) {
1401 if (hdr->len != cmd->odatalen) {
1402 device_printf(sc->sc_dev,
1405 (int) hdr->code,
1406 (int) hdr->len,
1407 (int) cmd->odatalen);
1409 memcpy(cmd->odata, &hdr[1],
1410 MIN(cmd->odatalen, hdr->len));
1415 STAILQ_INSERT_TAIL(&sc->sc_cmd_inactive, cmd, next_cmd);
1422 struct ieee80211com *ic = &sc->sc_ic;
1433 if (__predict_false(sizeof (*hdr) + hdr->len > len ||
1434 sizeof (*hdr) + hdr->len > 64)) {
1436 "cmd too large %d\n", hdr->len);
1443 hdr->code);
1450 if ((hdr->code & 0xc0) != 0xc0) {
1456 switch (hdr->code & 0x3f) {
1464 ni = ieee80211_find_node(&ic->ic_sta, tx->macaddr);
1466 device_printf(sc->sc_dev,
1469 ether_sprintf(tx->macaddr));
1475 ether_sprintf(tx->macaddr), le16toh(tx->status),
1476 le32toh(tx->phy));
1478 switch (le16toh(tx->status)) {
1482 ieee80211_ratectl_tx_complete(ni->ni_vap, ni,
1491 OTUS_NODE(ni)->tx_retries++;
1494 OTUS_NODE(ni)->tx_err++;
1504 * This is "tell driver to reset baseband" from ar9170-fw.
1508 * reaches '5' - I guess the firmware authors thought that
1512 device_printf(sc->sc_dev,
1515 hdr->code, hdr->len);
1522 * This may be a single MPDU, or it may be a sub-frame from an A-MPDU.
1528 struct ieee80211com *ic = &sc->sc_ic;
1540 device_printf(sc->sc_dev, "%s: %*D\n",
1541 __func__, len, buf, "-");
1545 * Before any data path stuff - check to see if this is a command
1548 * All bits in the PLCP header are set to 1 for non-MPDU.
1553 len - AR_PLCP_HDR_LEN);
1558 * First step - get the status for the given frame.
1560 * an A-MPDU subframe.
1564 "%s: sub-xfer too short (no mac_status) (len %d)\n",
1566 counter_u64_add(ic->ic_ierrors, 1);
1574 mac_status = (struct ar_rx_macstatus *)(buf + len - sizeof(*mac_status));
1575 len -= sizeof(*mac_status);
1578 __func__, mac_status->status);
1581 * Next - check the MAC status before doing anything else.
1584 * from both into sc->ar_last_rx_plcp[] so it can be reused.
1586 if (((mac_status->status & AR_RX_STATUS_MPDU_MASK) == AR_RX_STATUS_MPDU_SINGLE) ||
1587 ((mac_status->status & AR_RX_STATUS_MPDU_MASK) == AR_RX_STATUS_MPDU_FIRST)) {
1594 "%s sub-xfer too short (no mac+plcp) (len %d\n)",
1596 counter_u64_add(ic->ic_ierrors, 1);
1599 memcpy(sc->ar_last_rx_plcp, buf, AR_PLCP_HDR_LEN);
1606 len -= AR_PLCP_HDR_LEN;
1610 * Next - see if we have a PHY status.
1612 * The PHY status is at the end of the final A-MPDU subframe
1618 if (((mac_status->status & AR_RX_STATUS_MPDU_MASK) == AR_RX_STATUS_MPDU_SINGLE) ||
1619 ((mac_status->status & AR_RX_STATUS_MPDU_MASK) == AR_RX_STATUS_MPDU_LAST)) {
1622 "%s sub-xfer too short (no phy status) (len %d\n)",
1624 counter_u64_add(ic->ic_ierrors, 1);
1634 (buf + len - sizeof(*phy_status));
1635 len -= sizeof(*phy_status);
1647 if (__predict_false((mac_status->error & ~AR_RX_ERROR_BAD_RA) != 0)) {
1648 OTUS_DPRINTF(sc, OTUS_DEBUG_RXDONE, "error frame 0x%02x\n", mac_status->error);
1649 if (mac_status->error & AR_RX_ERROR_FCS) {
1651 } else if (mac_status->error & AR_RX_ERROR_MMIC) {
1654 ieee80211_notify_michael_failure(ni->ni_vap, wh, keyidx);
1656 device_printf(sc->sc_dev, "%s: MIC failure\n", __func__);
1658 counter_u64_add(ic->ic_ierrors, 1);
1677 counter_u64_add(ic->ic_ierrors, 1);
1681 len -= IEEE80211_CRC_LEN; /* strip 802.11 FCS */
1693 counter_u64_add(ic->ic_ierrors, 1);
1699 device_printf(sc->sc_dev, "%s: failed m_get2() (len=%d)\n",
1701 counter_u64_add(ic->ic_ierrors, 1);
1707 m->m_pkthdr.len = m->m_len = len;
1715 if (m->m_len < IEEE80211_MIN_LEN) {
1724 rxs.c_nf = sc->sc_nf[0]; /* XXX chain 0 != combined rssi/nf */
1727 rxs.c_rssi = phy_status->rssi;
1731 counter_u64_add(ic->ic_ierrors, 1);
1736 STAILQ_INSERT_TAIL(&rxq->mq_head, m, m_stailqpkt);
1742 rxi.rxi_rssi = tail->rssi;
1756 caddr_t buf = data->buf;
1767 device_printf(sc->sc_dev, "%s: %*D\n",
1768 __func__, len, buf, "-");
1773 if (__predict_false(head->tag != htole16(AR_RX_HEAD_TAG))) {
1775 "tag not valid 0x%x\n", le16toh(head->tag));
1778 hlen = le16toh(head->len);
1786 /* Process sub-xfer. */
1789 /* Next sub-xfer is aligned on a 32-bit boundary. */
1796 len -= hlen;
1805 struct ieee80211com *ic = &sc->sc_ic;
1817 device_printf(sc->sc_dev, "%s: called; state=%d; error=%d\n",
1825 data = STAILQ_FIRST(&sc->sc_rx_active);
1828 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
1830 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1838 data = STAILQ_FIRST(&sc->sc_rx_inactive);
1843 STAILQ_REMOVE_HEAD(&sc->sc_rx_inactive, next);
1844 STAILQ_INSERT_TAIL(&sc->sc_rx_active, data, next);
1845 usbd_xfer_set_frame_data(xfer, 0, data->buf,
1859 if (ni->ni_flags & IEEE80211_NODE_HT)
1860 m->m_flags |= M_AMPDU;
1873 data = STAILQ_FIRST(&sc->sc_rx_active);
1875 STAILQ_REMOVE_HEAD(&sc->sc_rx_active, next);
1876 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next);
1880 counter_u64_add(ic->ic_ierrors, 1);
1897 if (sc->sc_tx_n_active == 0) {
1898 device_printf(sc->sc_dev,
1902 sc->sc_tx_n_active--;
1905 if (data->m) {
1908 ieee80211_tx_complete(data->ni, data->m, 0);
1909 data->m = NULL;
1910 data->ni = NULL;
1923 __func__, cmd, cmd->odata);
1926 * Non-response commands still need wakeup so the caller
1930 if (cmd->odata) {
1931 STAILQ_INSERT_TAIL(&sc->sc_cmd_waiting, cmd, next_cmd);
1943 struct ieee80211com *ic = &sc->sc_ic;
1950 data = STAILQ_FIRST(&sc->sc_tx_active[which]);
1955 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next);
1961 data = STAILQ_FIRST(&sc->sc_tx_pending[which]);
1965 sc->sc_tx_n_active = 0;
1968 STAILQ_REMOVE_HEAD(&sc->sc_tx_pending[which], next);
1969 STAILQ_INSERT_TAIL(&sc->sc_tx_active[which], data, next);
1970 usbd_xfer_set_frame_data(xfer, 0, data->buf, data->buflen);
1974 sc->sc_tx_n_active++;
1977 data = STAILQ_FIRST(&sc->sc_tx_active[which]);
1979 STAILQ_REMOVE_HEAD(&sc->sc_tx_active[which], next);
1983 counter_u64_add(ic->ic_oerrors, 1);
1996 * threshold, ensure we age fast-frames out so they're
1999 if (sc->sc_tx_n_active < 2) {
2000 /* XXX ew - net80211 should defer this for us! */
2018 struct ieee80211com *ic = &sc->sc_ic;
2026 cmd = STAILQ_FIRST(&sc->sc_cmd_active);
2031 STAILQ_REMOVE_HEAD(&sc->sc_cmd_active, next_cmd);
2036 cmd = STAILQ_FIRST(&sc->sc_cmd_pending);
2042 STAILQ_REMOVE_HEAD(&sc->sc_cmd_pending, next_cmd);
2043 STAILQ_INSERT_TAIL(&sc->sc_cmd_active, cmd, next_cmd);
2044 usbd_xfer_set_frame_data(xfer, 0, cmd->buf, cmd->buflen);
2046 "%s: submitting transfer %p; buf=%p, buflen=%d\n", __func__, cmd, cmd->buf, cmd->buflen);
2050 cmd = STAILQ_FIRST(&sc->sc_cmd_active);
2052 STAILQ_REMOVE_HEAD(&sc->sc_cmd_active, next_cmd);
2122 is_2ghz = !! (IEEE80211_IS_CHAN_2GHZ(sc->sc_ic.ic_curchan));
2157 device_printf(sc->sc_dev, "%s: unknown rate '%d'\n",
2192 struct ieee80211_ratectl_tx_stats *txs = &sc->sc_txs;
2195 txs->flags = IEEE80211_RATECTL_TX_STATS_NODE |
2197 txs->ni = ni;
2198 txs->nframes = on->tx_done;
2199 txs->nsuccess = on->tx_done - on->tx_err;
2200 txs->nretries = on->tx_retries;
2202 ieee80211_ratectl_tx_update(ni->ni_vap, txs);
2203 on->tx_done = on->tx_err = on->tx_retries = 0;
2211 * ac = params->ibp_pri & 3;
2212 * rate = params->ibp_rate0;
2213 * params->ibp_flags & IEEE80211_BPF_NOACK
2214 * params->ibp_flags & IEEE80211_BPF_RTS
2215 * params->ibp_flags & IEEE80211_BPF_CTS
2216 * tx->rts_ntries = params->ibp_try1;
2217 * tx->data_ntries = params->ibp_try0;
2223 const struct ieee80211_txparam *tp = ni->ni_txparms;
2224 struct ieee80211com *ic = &sc->sc_ic;
2225 struct ieee80211vap *vap = ni->ni_vap;
2235 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
2238 device_printf(sc->sc_dev,
2248 xferlen = sizeof (*head) + m->m_pkthdr.len;
2250 device_printf(sc->sc_dev,
2262 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
2270 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
2271 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
2275 rate = otus_rate_to_hw_rate(sc, params->ibp_rate0);
2276 else if (!!(m->m_flags & M_EAPOL) || type != IEEE80211_FC0_TYPE_DATA)
2277 rate = otus_rate_to_hw_rate(sc, tp->mgmtrate);
2279 rate = otus_rate_to_hw_rate(sc, tp->mcastrate);
2280 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
2281 rate = otus_rate_to_hw_rate(sc, tp->ucastrate);
2284 rate = otus_rate_to_hw_rate(sc, ni->ni_txrate);
2299 if (m->m_pkthdr.len + IEEE80211_CRC_LEN >= vap->iv_rtsthreshold)
2302 if (ic->ic_htprotmode == IEEE80211_PROT_RTSCTS)
2304 } else if (ic->ic_flags & IEEE80211_F_USEPROT) {
2305 if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
2307 else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
2316 phyctl |= AR_TX_PHY_ANTMSK(sc->txmask);
2323 phyctl |= AR_TX_PHY_ANTMSK(sc->txmask);
2326 phyctl |= AR_TX_PHY_ANTMSK(sc->txmask);
2334 OTUS_NODE(ni)->tx_done++;
2337 head = (struct ar_tx_head *)data->buf;
2338 head->len = htole16(m->m_pkthdr.len + IEEE80211_CRC_LEN);
2339 head->macctl = htole16(macctl);
2340 head->phyctl = htole32(phyctl);
2342 m_copydata(m, 0, m->m_pkthdr.len, (caddr_t)&head[1]);
2344 data->buflen = xferlen;
2345 data->ni = ni;
2346 data->m = m;
2350 __func__, m, data, le16toh(head->len), macctl, phyctl,
2351 (int) rate, (int) ni->ni_txrate);
2354 STAILQ_INSERT_TAIL(&sc->sc_tx_pending[OTUS_BULK_TX], data, next);
2355 usbd_transfer_start(sc->sc_xfer[OTUS_BULK_TX]);
2375 hashes[1] |= 1 << (val - 32);
2383 struct ieee80211com *ic = &sc->sc_ic;
2387 if (ic->ic_allmulti > 0 || ic->ic_promisc > 0 ||
2388 ic->ic_opmode == IEEE80211_M_MONITOR) {
2395 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
2396 if_foreach_llmaddr(vap->iv_ifp, otus_hash_maddr,
2402 bit = enm->enm_addrlo[5] >> 2;
2406 hashes[1] |= 1 << (bit - 32);
2425 struct otus_softc *sc = ic->ic_softc;
2430 * when scheduling this so we have a more time-correct view
2442 #define EXP2(val) ((1 << (val)) - 1)
2445 struct ieee80211com *ic = &sc->sc_ic;
2500 struct ieee80211com *ic = &sc->sc_ic;
2598 return sc->phy_vals[i];
2603 * Update PHY's programming based on vendor-specific data stored in EEPROM.
2604 * This is for FEM-type devices only.
2613 eep = &sc->eeprom.modalHeader[0];
2615 eep = &sc->eeprom.modalHeader[1];
2620 tmp = le32toh(eep->antCtrlCommon);
2623 tmp = le32toh(eep->antCtrlChain[0]);
2626 tmp = le32toh(eep->antCtrlChain[1]);
2629 if (1 /* sc->sc_sco == AR_SCO_SCN */) {
2632 tmp |= (eep->switchSettling & 0x7f) << 7;
2638 tmp |= eep->pgaDesiredSize << 8 | eep->adcDesiredSize;
2641 tmp = eep->txEndToXpaOff << 24 | eep->txEndToXpaOff << 16 |
2642 eep->txFrameToXpaOn << 8 | eep->txFrameToXpaOn;
2647 tmp |= eep->txEndToRxOn << 16;
2652 tmp |= (eep->thresh62 & 0x7f) << 12;
2657 tmp |= (eep->txRxAttenCh[0] & 0x3f) << 12;
2662 tmp |= (eep->txRxAttenCh[1] & 0x3f) << 12;
2667 tmp |= (eep->rxTxMarginCh[0] & 0x3f) << 18;
2670 tmp |= (eep->bswMargin[0] & 0xf) << 10;
2676 tmp |= (eep->rxTxMarginCh[1] & 0x3f) << 18;
2681 tmp |= (eep->iqCalICh[0] & 0x3f) << 5 | (eep->iqCalQCh[0] & 0x1f);
2686 tmp |= (eep->iqCalICh[1] & 0x3f) << 5 | (eep->iqCalQCh[1] & 0x1f);
2691 tmp |= (eep->xpd & 0xf) << 16;
2717 sc->phy_vals = vals;
2719 if (sc->eeprom.baseEepHeader.deviceType == 0x80) /* FEM */
2763 chansel = (c->ic_freq - 4800) / 5;
2770 if (c->ic_freq == 2484) { /* CH 14 */
2772 chansel = 10 + (c->ic_freq - 2274) / 5;
2774 chansel = 16 + (c->ic_freq - 2272) / 5;
2780 /* Write bits 0-4 of d0 and d1. */
2783 /* Write bits 5-7 of d0 and d1. */
2798 /* exponent = 14 - floor(log2(coeff)) */
2799 for (exp = 31; exp > 0; exp--)
2803 exp = 14 - (exp - COEFF_SCALE_SHIFT);
2806 man = coeff + (1 << (COEFF_SCALE_SHIFT - exp - 1));
2808 *mantissa = man >> (COEFF_SCALE_SHIFT - exp);
2809 *exponent = exp - 16;
2816 struct ieee80211com *ic = &sc->sc_ic;
2828 "setting channel %d (%dMHz)\n", chan, c->ic_freq);
2846 if (sc->bb_reset || c->ic_flags != sc->sc_curchan->ic_flags) {
2850 otus_write(sc, AR_PWR_REG_RESET, sc->bb_reset ? 0x800 : 0x400);
2856 sc->bb_reset = 0;
2859 device_printf(sc->sc_dev,
2873 device_printf(sc->sc_dev,
2886 tmp = (sc->txmask == 0x5) ? 0x340 : 0x240;
2892 cmd.freq = htole32((uint32_t)c->ic_freq * 1000);
2896 coeff = (100 << 24) / c->ic_freq;
2920 sc->bb_reset = 1;
2924 device_printf(sc->sc_dev, "calibration status=0x%x\n",
2927 /* Sign-extend 9-bit NF values. */
2928 device_printf(sc->sc_dev,
2931 device_printf(sc->sc_dev,
2932 "noisefloor ext chain %d=%d\n", i,
2938 sc->sc_nf[i] = ((((int32_t)le32toh(rsp.nf[i])) << 4) >> 23);
2940 sc->sc_curchan = c;
2950 struct otus_softc *sc = ic->ic_softc;
2954 if ((ic->ic_if.if_flags & (IFF_UP | IFF_RUNNING)) !=
2960 cmd.associd = (ni != NULL) ? ni->ni_associd : 0;
2969 struct ieee80211_key *k = &cmd->key;
2975 if (k->k_flags & IEEE80211_KEY_GROUP) {
2976 key.uid = htole16(k->k_id);
2977 IEEE80211_ADDR_COPY(key.macaddr, sc->sc_ic.ic_myaddr);
2980 key.uid = htole16(OTUS_UID(cmd->associd));
2981 IEEE80211_ADDR_COPY(key.macaddr, ni->ni_macaddr);
2985 switch (k->k_cipher) {
3002 memcpy(key.key, k->k_key, MIN(k->k_len, 16));
3004 if (error != 0 || k->k_cipher != IEEE80211_CIPHER_TKIP)
3009 memcpy(key.key, k->k_key + 16, 16);
3017 struct otus_softc *sc = ic->ic_softc;
3020 if (!(ic->ic_if.if_flags & IFF_RUNNING) ||
3021 ic->ic_state != IEEE80211_S_RUN)
3026 cmd.associd = (ni != NULL) ? ni->ni_associd : 0;
3034 struct ieee80211_key *k = &cmd->key;
3037 if (k->k_flags & IEEE80211_KEY_GROUP)
3038 uid = htole32(k->k_id);
3040 uid = htole32(OTUS_UID(cmd->associd));
3055 device_printf(sc->sc_dev, "%s: called\n", __func__);
3056 struct ieee80211com *ic = &sc->sc_ic;
3059 if (usbd_is_dying(sc->sc_udev))
3062 usbd_ref_incr(sc->sc_udev);
3064 ni = ic->ic_bss;
3065 ieee80211_amrr_choose(&sc->amrr, ni, &((struct otus_node *)ni)->amn);
3067 if (!usbd_is_dying(sc->sc_udev))
3068 timeout_add_sec(&sc->calib_to, 1);
3070 usbd_ref_decr(sc->sc_udev);
3099 /* Default single-LED. */
3104 device_printf(sc->sc_dev, "%s: TODO\n", __func__);
3107 /* NETGEAR, dual-LED. */
3112 device_printf(sc->sc_dev, "%s: TODO\n", __func__);
3115 /* NETGEAR, single-LED/3 colors (blue, red, purple.) */
3120 struct ieee80211com *ic = &sc->sc_ic;
3121 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3123 uint32_t state = sc->led_state;
3129 } else if (vap->iv_state == IEEE80211_S_INIT) {
3131 } else if (vap->iv_state == IEEE80211_S_RUN) {
3133 if (IEEE80211_IS_CHAN_2GHZ(sc->sc_curchan))
3140 if (IEEE80211_IS_CHAN_2GHZ(sc->sc_curchan))
3145 if (state != sc->led_state) {
3148 sc->led_state = state;
3161 struct ieee80211com *ic = &sc->sc_ic;
3175 * address assigned, ensure it gets reset to all-zero.
3178 vap = TAILQ_FIRST(&ic->ic_vaps);
3179 macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr;
3181 switch (ic->ic_opmode) {
3184 ni = ieee80211_ref_node(vap->iv_bss);
3185 IEEE80211_ADDR_COPY(bssid, ni->ni_bssid);
3220 // struct ieee80211com *ic = &sc->sc_ic;
3225 if (ic->ic_allmulti > 0 || ic->ic_promisc > 0 ||
3226 ic->ic_opmode == IEEE80211_M_MONITOR) {
3240 struct ieee80211com *ic = &sc->sc_ic;
3253 device_printf(sc->sc_dev,
3262 sc->bb_reset = 1; /* Force cold reset. */
3264 if ((error = otus_set_chan(sc, ic->ic_curchan, 0)) != 0) {
3266 device_printf(sc->sc_dev,
3275 sc->sc_running = 1;
3291 sc->sc_running = 0;
3292 sc->sc_tx_timer = 0;
3295 taskqueue_drain_timeout(taskqueue_thread, &sc->scan_to);
3296 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_to);
3297 taskqueue_drain(taskqueue_thread, &sc->tx_task);
3300 sc->sc_running = 0;