Lines Matching +full:timeout +full:- +full:tap +full:- +full:ms
4 /*-
6 * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
105 usbd_do_request_flags((sc)->sc_udev, &(sc)->sc_mtx, req, data, 0, NULL, 5000)
262 .timeout = 10000, /* 10 seconds */
280 .timeout = 1000, /* 1 second */
318 if (uaa->usb_mode != USB_MODE_HOST) in zyd_match()
320 if (uaa->info.bConfigIndex != ZYD_CONFIG_INDEX) in zyd_match()
322 if (uaa->info.bIfaceIndex != ZYD_IFACE_INDEX) in zyd_match()
333 struct ieee80211com *ic = &sc->sc_ic; in zyd_attach()
337 if (uaa->info.bcdDevice < 0x4330) { in zyd_attach()
340 uaa->info.bcdDevice); in zyd_attach()
345 sc->sc_dev = dev; in zyd_attach()
346 sc->sc_udev = uaa->device; in zyd_attach()
347 sc->sc_macrev = USB_GET_DRIVER_INFO(uaa); in zyd_attach()
349 mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), in zyd_attach()
351 STAILQ_INIT(&sc->sc_rqh); in zyd_attach()
352 mbufq_init(&sc->sc_snd, ifqmaxlen); in zyd_attach()
355 error = usbd_transfer_setup(uaa->device, in zyd_attach()
356 &iface_index, sc->sc_xfer, zyd_config, in zyd_attach()
357 ZYD_N_TRANSFER, sc, &sc->sc_mtx); in zyd_attach()
366 device_printf(sc->sc_dev, "could not read EEPROM\n"); in zyd_attach()
372 ic->ic_softc = sc; in zyd_attach()
373 ic->ic_name = device_get_nameunit(dev); in zyd_attach()
374 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in zyd_attach()
375 ic->ic_opmode = IEEE80211_M_STA; in zyd_attach()
378 ic->ic_caps = in zyd_attach()
387 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in zyd_attach()
389 zyd_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in zyd_attach()
390 ic->ic_channels); in zyd_attach()
393 ic->ic_raw_xmit = zyd_raw_xmit; in zyd_attach()
394 ic->ic_scan_start = zyd_scan_start; in zyd_attach()
395 ic->ic_scan_end = zyd_scan_end; in zyd_attach()
396 ic->ic_getradiocaps = zyd_getradiocaps; in zyd_attach()
397 ic->ic_set_channel = zyd_set_channel; in zyd_attach()
398 ic->ic_vap_create = zyd_vap_create; in zyd_attach()
399 ic->ic_vap_delete = zyd_vap_delete; in zyd_attach()
400 ic->ic_update_mcast = zyd_update_mcast; in zyd_attach()
401 ic->ic_update_promisc = zyd_update_mcast; in zyd_attach()
402 ic->ic_parent = zyd_parent; in zyd_attach()
403 ic->ic_transmit = zyd_transmit; in zyd_attach()
406 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in zyd_attach()
408 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in zyd_attach()
428 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in zyd_drain_mbufq()
429 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in zyd_drain_mbufq()
430 m->m_pkthdr.rcvif = NULL; in zyd_drain_mbufq()
440 struct ieee80211com *ic = &sc->sc_ic; in zyd_detach()
448 sc->sc_flags |= ZYD_FLAG_DETACHED; in zyd_detach()
450 STAILQ_INIT(&sc->tx_q); in zyd_detach()
451 STAILQ_INIT(&sc->tx_free); in zyd_detach()
456 usbd_transfer_drain(sc->sc_xfer[x]); in zyd_detach()
464 usbd_transfer_unsetup(sc->sc_xfer, ZYD_N_TRANSFER); in zyd_detach()
466 if (ic->ic_softc == sc) in zyd_detach()
468 mtx_destroy(&sc->sc_mtx); in zyd_detach()
482 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in zyd_vap_create()
485 vap = &zvp->vap; in zyd_vap_create()
496 zvp->newstate = vap->iv_newstate; in zyd_vap_create()
497 vap->iv_newstate = zyd_newstate; in zyd_vap_create()
505 ic->ic_opmode = opmode; in zyd_vap_create()
522 struct zyd_softc *sc = data->sc; in zyd_tx_free()
524 if (data->m != NULL) { in zyd_tx_free()
525 ieee80211_tx_complete(data->ni, data->m, txerr); in zyd_tx_free()
526 data->m = NULL; in zyd_tx_free()
527 data->ni = NULL; in zyd_tx_free()
529 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in zyd_tx_free()
530 sc->tx_nfree++; in zyd_tx_free()
539 sc->tx_nfree = 0; in zyd_setup_tx_list()
540 STAILQ_INIT(&sc->tx_q); in zyd_setup_tx_list()
541 STAILQ_INIT(&sc->tx_free); in zyd_setup_tx_list()
544 data = &sc->tx_data[i]; in zyd_setup_tx_list()
546 data->sc = sc; in zyd_setup_tx_list()
547 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in zyd_setup_tx_list()
548 sc->tx_nfree++; in zyd_setup_tx_list()
559 sc->tx_nfree = 0; in zyd_unsetup_tx_list()
560 STAILQ_INIT(&sc->tx_q); in zyd_unsetup_tx_list()
561 STAILQ_INIT(&sc->tx_free); in zyd_unsetup_tx_list()
565 data = &sc->tx_data[i]; in zyd_unsetup_tx_list()
567 if (data->m != NULL) { in zyd_unsetup_tx_list()
568 m_freem(data->m); in zyd_unsetup_tx_list()
569 data->m = NULL; in zyd_unsetup_tx_list()
571 if (data->ni != NULL) { in zyd_unsetup_tx_list()
572 ieee80211_free_node(data->ni); in zyd_unsetup_tx_list()
573 data->ni = NULL; in zyd_unsetup_tx_list()
582 struct ieee80211com *ic = vap->iv_ic; in zyd_newstate()
583 struct zyd_softc *sc = ic->ic_softc; in zyd_newstate()
586 DPRINTF(sc, ZYD_DEBUG_STATE, "%s: %s -> %s\n", __func__, in zyd_newstate()
587 ieee80211_state_name[vap->iv_state], in zyd_newstate()
594 zyd_set_chan(sc, ic->ic_curchan); in zyd_newstate()
597 if (vap->iv_opmode == IEEE80211_M_MONITOR) in zyd_newstate()
606 zyd_write32_m(sc, sc->sc_fwbase + ZYD_FW_LINK_STATUS, 1); in zyd_newstate()
608 IEEE80211_ADDR_COPY(sc->sc_bssid, vap->iv_bss->ni_bssid); in zyd_newstate()
609 zyd_set_bssid(sc, sc->sc_bssid); in zyd_newstate()
617 return (zvp->newstate(vap, nstate, arg)); in zyd_newstate()
627 struct ieee80211com *ic = &sc->sc_ic; in zyd_intr_read_callback()
628 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in zyd_intr_read_callback()
630 struct zyd_cmd *cmd = &sc->sc_ibuf; in zyd_intr_read_callback()
642 switch (le16toh(cmd->code)) { in zyd_intr_read_callback()
646 (struct zyd_notif_retry *)cmd->data; in zyd_intr_read_callback()
647 uint16_t count = le16toh(retry->count); in zyd_intr_read_callback()
651 le16toh(retry->rate), ether_sprintf(retry->macaddr), in zyd_intr_read_callback()
660 ni = ieee80211_find_txnode(vap, retry->macaddr); in zyd_intr_read_callback()
663 &sc->sc_txs; in zyd_intr_read_callback()
666 txs->flags = in zyd_intr_read_callback()
668 txs->long_retries = retrycnt; in zyd_intr_read_callback()
670 txs->status = in zyd_intr_read_callback()
673 txs->status = in zyd_intr_read_callback()
682 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, in zyd_intr_read_callback()
690 if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT) in zyd_intr_read_callback()
693 datalen = actlen - sizeof(cmd->code); in zyd_intr_read_callback()
694 datalen -= 2; /* XXX: padding? */ in zyd_intr_read_callback()
696 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_read_callback()
700 if (rqp->olen != datalen) in zyd_intr_read_callback()
702 count = rqp->olen / sizeof(struct zyd_pair); in zyd_intr_read_callback()
704 if (*(((const uint16_t *)rqp->idata) + i) != in zyd_intr_read_callback()
705 (((struct zyd_pair *)cmd->data) + i)->reg) in zyd_intr_read_callback()
710 /* copy answer into caller-supplied buffer */ in zyd_intr_read_callback()
711 memcpy(rqp->odata, cmd->data, rqp->olen); in zyd_intr_read_callback()
714 rqp, rqp->olen, (char *)rqp->odata, ":"); in zyd_intr_read_callback()
719 device_printf(sc->sc_dev, in zyd_intr_read_callback()
721 datalen, cmd->data, ":"); in zyd_intr_read_callback()
726 device_printf(sc->sc_dev, "unknown notification %x\n", in zyd_intr_read_callback()
727 le16toh(cmd->code)); in zyd_intr_read_callback()
761 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_write_callback()
764 (rqp->flags & ZYD_CMD_FLAG_READ) == 0) in zyd_intr_write_callback()
771 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_write_callback()
772 if (rqp->flags & ZYD_CMD_FLAG_SENT) in zyd_intr_write_callback()
776 usbd_copy_in(pc, 0, rqp->cmd, rqp->ilen); in zyd_intr_write_callback()
778 usbd_xfer_set_frame_len(xfer, 0, rqp->ilen); in zyd_intr_write_callback()
780 rqp->flags |= ZYD_CMD_FLAG_SENT; in zyd_intr_write_callback()
821 STAILQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); in zyd_cmd()
822 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_RD]); in zyd_cmd()
823 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_WR]); in zyd_cmd()
826 error = mtx_sleep(&rq, &sc->sc_mtx, 0 , "zydcmd", hz); in zyd_cmd()
828 device_printf(sc->sc_dev, "command timeout\n"); in zyd_cmd()
829 STAILQ_REMOVE(&sc->sc_rqh, &rq, zyd_rq, rq); in zyd_cmd()
893 struct zyd_rf *rf = &sc->sc_rf; in zyd_rfwrite()
902 req.width = htole16(rf->width); in zyd_rfwrite()
903 for (i = 0; i < rf->width; i++) { in zyd_rfwrite()
905 if (val & (1 << (rf->width - 1 - i))) in zyd_rfwrite()
908 error = zyd_cmd(sc, ZYD_CMD_RFCFG, &req, 4 + 2 * rf->width, NULL, 0, 0); in zyd_rfwrite()
957 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_init()
962 /* init RF-dependent PHY registers */ in zyd_rfmd_init()
980 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_switch_radio()
992 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_set_channel()
997 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_rfmd_set_channel()
1000 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_rfmd_set_channel()
1014 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_init()
1026 /* init RF-dependent PHY registers */ in zyd_al2230_init()
1030 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { in zyd_al2230_init()
1042 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) in zyd_al2230_init()
1071 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_fini()
1077 if (sc->sc_newphy != 0) in zyd_al2230_fini()
1088 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_init_b()
1103 /* init RF-dependent PHY registers */ in zyd_al2230_init_b()
1107 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { in zyd_al2230_init_b()
1124 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) in zyd_al2230_init_b()
1157 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_switch_radio()
1158 int error, on251 = (sc->sc_macrev == ZYD_ZD1211) ? 0x3f : 0x7f; in zyd_al2230_switch_radio()
1170 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_set_channel()
1178 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_al2230_set_channel()
1181 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_al2230_set_channel()
1184 error = zyd_rfwrite(sc, rfprog[chan - 1].r3); in zyd_al2230_set_channel()
1198 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_set_channel_b()
1207 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r1); in zyd_al2230_set_channel_b()
1210 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r2); in zyd_al2230_set_channel_b()
1213 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r3); in zyd_al2230_set_channel_b()
1231 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_bandedge6()
1232 struct ieee80211com *ic = &sc->sc_ic; in zyd_al2230_bandedge6()
1251 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_init()
1261 /* init RF-dependent PHY registers, part one */ in zyd_al7230B_init()
1270 /* init RF-dependent PHY registers, part two */ in zyd_al7230B_init()
1279 /* init RF-dependent PHY registers, part three */ in zyd_al7230B_init()
1290 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_switch_radio()
1301 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_set_channel()
1322 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_al7230B_set_channel()
1325 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_al7230B_set_channel()
1345 struct zyd_softc *sc = rf->rf_sc; in zyd_al2210_init()
1353 /* init RF-dependent PHY registers */ in zyd_al2210_init()
1386 struct zyd_softc *sc = rf->rf_sc; in zyd_al2210_set_channel()
1400 error = zyd_rfwrite(sc, rfprog[chan - 1]); in zyd_al2210_set_channel()
1416 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_init()
1420 int i, idx = -1, error; in zyd_gct_init()
1423 /* init RF-dependent PHY registers */ in zyd_gct_init()
1437 for (i = 0; i < (int)(nitems(vco) - 1); i++) { in zyd_gct_init()
1451 if (idx == -1) { in zyd_gct_init()
1460 rf->idx = idx; in zyd_gct_init()
1470 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_mode()
1486 int error, idx = chan - 1; in zyd_gct_set_channel_synth()
1487 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_set_channel_synth()
1502 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_write()
1511 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_switch_radio()
1519 on ? ((sc->sc_macrev == ZYD_ZD1211B) ? 0x7f : 0x3f) : 0x2f); in zyd_gct_switch_radio()
1528 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_set_channel()
1538 error = zyd_gct_write(rf, (rf->idx == -1) ? 0x6662 : in zyd_gct_set_channel()
1539 vco[rf->idx][((chan - 1) / 2)]); in zyd_gct_set_channel()
1558 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_txgain()
1560 uint8_t idx = sc->sc_pwrint[chan - 1]; in zyd_gct_txgain()
1563 device_printf(sc->sc_dev, "could not set TX gain (%d %#x)\n", in zyd_gct_txgain()
1577 struct zyd_softc *sc = rf->rf_sc; in zyd_maxim2_init()
1583 /* init RF-dependent PHY registers */ in zyd_maxim2_init()
1612 struct zyd_softc *sc = rf->rf_sc; in zyd_maxim2_set_channel()
1626 /* init RF-dependent PHY registers */ in zyd_maxim2_set_channel()
1634 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_maxim2_set_channel()
1637 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_maxim2_set_channel()
1641 /* init maxim2 radio - skipping the two first values */ in zyd_maxim2_set_channel()
1655 struct zyd_rf *rf = &sc->sc_rf; in zyd_rf_attach()
1657 rf->rf_sc = sc; in zyd_rf_attach()
1658 rf->update_pwr = 1; in zyd_rf_attach()
1662 rf->init = zyd_rfmd_init; in zyd_rf_attach()
1663 rf->switch_radio = zyd_rfmd_switch_radio; in zyd_rf_attach()
1664 rf->set_channel = zyd_rfmd_set_channel; in zyd_rf_attach()
1665 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1669 if (sc->sc_macrev == ZYD_ZD1211B) { in zyd_rf_attach()
1670 rf->init = zyd_al2230_init_b; in zyd_rf_attach()
1671 rf->set_channel = zyd_al2230_set_channel_b; in zyd_rf_attach()
1673 rf->init = zyd_al2230_init; in zyd_rf_attach()
1674 rf->set_channel = zyd_al2230_set_channel; in zyd_rf_attach()
1676 rf->switch_radio = zyd_al2230_switch_radio; in zyd_rf_attach()
1677 rf->bandedge6 = zyd_al2230_bandedge6; in zyd_rf_attach()
1678 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1681 rf->init = zyd_al7230B_init; in zyd_rf_attach()
1682 rf->switch_radio = zyd_al7230B_switch_radio; in zyd_rf_attach()
1683 rf->set_channel = zyd_al7230B_set_channel; in zyd_rf_attach()
1684 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1687 rf->init = zyd_al2210_init; in zyd_rf_attach()
1688 rf->switch_radio = zyd_al2210_switch_radio; in zyd_rf_attach()
1689 rf->set_channel = zyd_al2210_set_channel; in zyd_rf_attach()
1690 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1694 rf->init = zyd_gct_init; in zyd_rf_attach()
1695 rf->switch_radio = zyd_gct_switch_radio; in zyd_rf_attach()
1696 rf->set_channel = zyd_gct_set_channel; in zyd_rf_attach()
1697 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1698 rf->update_pwr = 0; in zyd_rf_attach()
1701 rf->init = zyd_maxim2_init; in zyd_rf_attach()
1702 rf->switch_radio = zyd_maxim2_switch_radio; in zyd_rf_attach()
1703 rf->set_channel = zyd_maxim2_set_channel; in zyd_rf_attach()
1704 rf->width = 18; /* 18-bit RF values */ in zyd_rf_attach()
1707 device_printf(sc->sc_dev, in zyd_rf_attach()
1733 struct zyd_rf *rf = &sc->sc_rf; in zyd_hw_init()
1738 zyd_read16_m(sc, ZYD_FIRMWARE_BASE_ADDR, &sc->sc_fwbase); in zyd_hw_init()
1740 sc->sc_fwbase); in zyd_hw_init()
1743 zyd_read16_m(sc, sc->sc_fwbase + ZYD_FW_FIRMWARE_REV, &sc->sc_fwrev); in zyd_hw_init()
1746 /* set mandatory rates - XXX assumes 802.11b/g */ in zyd_hw_init()
1753 device_printf(sc->sc_dev, "could not read EEPROM\n"); in zyd_hw_init()
1761 phyp = (sc->sc_macrev == ZYD_ZD1211B) ? zyd_def_phyB : zyd_def_phy; in zyd_hw_init()
1762 for (; phyp->reg != 0; phyp++) in zyd_hw_init()
1763 zyd_write16_m(sc, phyp->reg, phyp->val); in zyd_hw_init()
1764 if (sc->sc_macrev == ZYD_ZD1211 && sc->sc_fix_cr157 != 0) { in zyd_hw_init()
1794 if (sc->sc_macrev == ZYD_ZD1211) { in zyd_hw_init()
1809 /* init beacon interval to 100ms */ in zyd_hw_init()
1813 if ((error = zyd_rf_attach(sc, sc->sc_rfrev)) != 0) { in zyd_hw_init()
1814 device_printf(sc->sc_dev, "could not attach RF, rev 0x%x\n", in zyd_hw_init()
1815 sc->sc_rfrev); in zyd_hw_init()
1823 error = (*rf->init)(rf); in zyd_hw_init()
1825 device_printf(sc->sc_dev, in zyd_hw_init()
1834 device_printf(sc->sc_dev, "could not read EEPROM\n"); in zyd_hw_init()
1848 sc->sc_rfrev = tmp & 0x0f; in zyd_read_pod()
1849 sc->sc_ledtype = (tmp >> 4) & 0x01; in zyd_read_pod()
1850 sc->sc_al2230s = (tmp >> 7) & 0x01; in zyd_read_pod()
1851 sc->sc_cckgain = (tmp >> 8) & 0x01; in zyd_read_pod()
1852 sc->sc_fix_cr157 = (tmp >> 13) & 0x01; in zyd_read_pod()
1853 sc->sc_parev = (tmp >> 16) & 0x0f; in zyd_read_pod()
1854 sc->sc_bandedge6 = (tmp >> 21) & 0x01; in zyd_read_pod()
1855 sc->sc_newphy = (tmp >> 31) & 0x01; in zyd_read_pod()
1856 sc->sc_txled = ((tmp & (1 << 24)) && (tmp & (1 << 29))) ? 0 : 1; in zyd_read_pod()
1870 sc->sc_pwrcal[i * 2] = val >> 8; in zyd_read_eeprom()
1871 sc->sc_pwrcal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1873 sc->sc_pwrint[i * 2] = val >> 8; in zyd_read_eeprom()
1874 sc->sc_pwrint[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1876 sc->sc_ofdm36_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1877 sc->sc_ofdm36_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1879 sc->sc_ofdm48_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1880 sc->sc_ofdm48_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1882 sc->sc_ofdm54_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1883 sc->sc_ofdm54_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1901 error = zyd_do_request(sc, &req, sc->sc_ic.ic_macaddr); in zyd_get_macaddr()
1903 device_printf(sc->sc_dev, "could not read EEPROM: %s\n", in zyd_get_macaddr()
1941 struct zyd_rf *rf = &sc->sc_rf; in zyd_switch_radio()
1947 error = (*rf->switch_radio)(rf, on); in zyd_switch_radio()
1980 hash[1] |= 1 << (v - 32); in zyd_hash_maddr()
1988 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_multi()
1992 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) in zyd_set_multi()
1998 if (ic->ic_opmode == IEEE80211_M_MONITOR || ic->ic_allmulti > 0 || in zyd_set_multi()
1999 ic->ic_promisc > 0) { in zyd_set_multi()
2005 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in zyd_set_multi()
2006 if_foreach_llmaddr(vap->iv_ifp, zyd_hash_maddr, &hash); in zyd_set_multi()
2014 device_printf(sc->sc_dev, in zyd_set_multi()
2021 struct zyd_softc *sc = ic->ic_softc; in zyd_update_mcast()
2031 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_rxfilter()
2034 switch (ic->ic_opmode) { in zyd_set_rxfilter()
2056 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_chan()
2057 struct zyd_rf *rf = &sc->sc_rf; in zyd_set_chan()
2064 device_printf(sc->sc_dev, in zyd_set_chan()
2073 error = (*rf->set_channel)(rf, chan); in zyd_set_chan()
2077 if (rf->update_pwr) { in zyd_set_chan()
2079 zyd_write16_m(sc, ZYD_CR31, sc->sc_pwrint[chan - 1]); in zyd_set_chan()
2081 if (sc->sc_macrev == ZYD_ZD1211B) { in zyd_set_chan()
2083 sc->sc_ofdm36_cal[chan - 1]); in zyd_set_chan()
2085 sc->sc_ofdm48_cal[chan - 1]); in zyd_set_chan()
2087 sc->sc_ofdm54_cal[chan - 1]); in zyd_set_chan()
2088 zyd_write16_m(sc, ZYD_CR68, sc->sc_pwrcal[chan - 1]); in zyd_set_chan()
2093 if (sc->sc_cckgain) { in zyd_set_chan()
2098 if (sc->sc_bandedge6 && rf->bandedge6 != NULL) { in zyd_set_chan()
2099 error = (*rf->bandedge6)(rf, c); in zyd_set_chan()
2109 sc->sc_rxtap.wr_chan_freq = sc->sc_txtap.wt_chan_freq = in zyd_set_chan()
2110 htole16(c->ic_freq); in zyd_set_chan()
2111 sc->sc_rxtap.wr_chan_flags = sc->sc_txtap.wt_chan_flags = in zyd_set_chan()
2112 htole16(c->ic_flags); in zyd_set_chan()
2124 sc->sc_atim_wnd = val; in zyd_set_beacon_interval()
2126 sc->sc_pre_tbtt = val; in zyd_set_beacon_interval()
2127 sc->sc_bcn_int = bintval; in zyd_set_beacon_interval()
2129 if (sc->sc_bcn_int <= 5) in zyd_set_beacon_interval()
2130 sc->sc_bcn_int = 5; in zyd_set_beacon_interval()
2131 if (sc->sc_pre_tbtt < 4 || sc->sc_pre_tbtt >= sc->sc_bcn_int) in zyd_set_beacon_interval()
2132 sc->sc_pre_tbtt = sc->sc_bcn_int - 1; in zyd_set_beacon_interval()
2133 if (sc->sc_atim_wnd >= sc->sc_pre_tbtt) in zyd_set_beacon_interval()
2134 sc->sc_atim_wnd = sc->sc_pre_tbtt - 1; in zyd_set_beacon_interval()
2136 zyd_write32_m(sc, ZYD_CR_ATIM_WND_PERIOD, sc->sc_atim_wnd); in zyd_set_beacon_interval()
2137 zyd_write32_m(sc, ZYD_CR_PRE_TBTT, sc->sc_pre_tbtt); in zyd_set_beacon_interval()
2138 zyd_write32_m(sc, ZYD_CR_BCN_INTERVAL, sc->sc_bcn_int); in zyd_set_beacon_interval()
2147 struct ieee80211com *ic = &sc->sc_ic; in zyd_rx_data()
2156 device_get_nameunit(sc->sc_dev), len); in zyd_rx_data()
2157 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2162 usbd_copy_out(pc, offset + len - sizeof(stat), &stat, sizeof(stat)); in zyd_rx_data()
2167 device_get_nameunit(sc->sc_dev), stat.flags); in zyd_rx_data()
2168 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2173 rlen = len - sizeof(struct zyd_plcphdr) - in zyd_rx_data()
2174 sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN; in zyd_rx_data()
2179 device_get_nameunit(sc->sc_dev), rlen); in zyd_rx_data()
2180 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2188 device_get_nameunit(sc->sc_dev)); in zyd_rx_data()
2189 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2192 m->m_pkthdr.len = m->m_len = rlen; in zyd_rx_data()
2196 struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap; in zyd_rx_data() local
2198 tap->wr_flags = 0; in zyd_rx_data()
2200 tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; in zyd_rx_data()
2203 tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; in zyd_rx_data()
2204 tap->wr_rate = ieee80211_plcp2rate(plcp.signal, in zyd_rx_data()
2207 tap->wr_antsignal = stat.rssi + -95; in zyd_rx_data()
2208 tap->wr_antnoise = -95; /* XXX */ in zyd_rx_data()
2212 sc->sc_rx_data[sc->sc_rx_count].rssi = rssi; in zyd_rx_data()
2213 sc->sc_rx_data[sc->sc_rx_count].m = m; in zyd_rx_data()
2214 sc->sc_rx_count++; in zyd_rx_data()
2221 struct ieee80211com *ic = &sc->sc_ic; in zyd_bulk_read_callback()
2234 sc->sc_rx_count = 0; in zyd_bulk_read_callback()
2238 usbd_copy_out(pc, actlen - sizeof(desc), &desc, sizeof(desc)); in zyd_bulk_read_callback()
2243 "%s: received multi-frame transfer\n", __func__); in zyd_bulk_read_callback()
2253 /* next frame is aligned on a 32-bit boundary */ in zyd_bulk_read_callback()
2258 actlen -= len16; in zyd_bulk_read_callback()
2262 "%s: received single-frame transfer\n", __func__); in zyd_bulk_read_callback()
2278 for (i = 0; i < sc->sc_rx_count; i++) { in zyd_bulk_read_callback()
2279 rssi = sc->sc_rx_data[i].rssi; in zyd_bulk_read_callback()
2280 m = sc->sc_rx_data[i].m; in zyd_bulk_read_callback()
2281 sc->sc_rx_data[i].m = NULL; in zyd_bulk_read_callback()
2283 nf = -95; /* XXX */ in zyd_bulk_read_callback()
2313 /* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */ in zyd_plcp_signal()
2330 /* CCK rates (NB: not IEEE std, device-specific) */ in zyd_plcp_signal()
2341 device_printf(sc->sc_dev, "unsupported rate %d\n", rate); in zyd_plcp_signal()
2370 data = STAILQ_FIRST(&sc->tx_q); in zyd_bulk_write_callback()
2372 STAILQ_REMOVE_HEAD(&sc->tx_q, next); in zyd_bulk_write_callback()
2373 m = data->m; in zyd_bulk_write_callback()
2375 if (m->m_pkthdr.len > (int)ZYD_MAX_TXBUFSZ) { in zyd_bulk_write_callback()
2377 m->m_pkthdr.len); in zyd_bulk_write_callback()
2378 m->m_pkthdr.len = ZYD_MAX_TXBUFSZ; in zyd_bulk_write_callback()
2381 usbd_copy_in(pc, 0, &data->desc, ZYD_TX_DESC_SIZE); in zyd_bulk_write_callback()
2383 m->m_pkthdr.len); in zyd_bulk_write_callback()
2385 vap = data->ni->ni_vap; in zyd_bulk_write_callback()
2387 struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; in zyd_bulk_write_callback() local
2389 tap->wt_flags = 0; in zyd_bulk_write_callback()
2390 tap->wt_rate = data->rate; in zyd_bulk_write_callback()
2395 usbd_xfer_set_frame_len(xfer, 0, ZYD_TX_DESC_SIZE + m->m_pkthdr.len); in zyd_bulk_write_callback()
2406 counter_u64_add(sc->sc_ic.ic_oerrors, 1); in zyd_bulk_write_callback()
2414 device_printf(sc->sc_dev, "device timeout\n"); in zyd_bulk_write_callback()
2419 * introduces a 50 ms delay: in zyd_bulk_write_callback()
2431 struct ieee80211vap *vap = ni->ni_vap; in zyd_tx_start()
2432 struct ieee80211com *ic = ni->ni_ic; in zyd_tx_start()
2436 const struct ieee80211_txparam *tp = ni->ni_txparms; in zyd_tx_start()
2445 data = STAILQ_FIRST(&sc->tx_free); in zyd_tx_start()
2446 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in zyd_tx_start()
2447 sc->tx_nfree--; in zyd_tx_start()
2449 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in zyd_tx_start()
2450 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in zyd_tx_start()
2454 (m0->m_flags & M_EAPOL) != 0) { in zyd_tx_start()
2455 rate = tp->mgmtrate; in zyd_tx_start()
2459 rate = tp->mcastrate; in zyd_tx_start()
2460 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in zyd_tx_start()
2461 rate = tp->ucastrate; in zyd_tx_start()
2468 ieee80211_output_seqno_assign(ni, -1, m0); in zyd_tx_start()
2470 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in zyd_tx_start()
2479 data->ni = ni; in zyd_tx_start()
2480 data->m = m0; in zyd_tx_start()
2481 data->rate = rate; in zyd_tx_start()
2484 desc = &data->desc; in zyd_tx_start()
2486 desc->phy = phy; in zyd_tx_start()
2488 desc->phy |= ZYD_TX_PHY_OFDM; in zyd_tx_start()
2489 if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) in zyd_tx_start()
2490 desc->phy |= ZYD_TX_PHY_5GHZ; in zyd_tx_start()
2491 } else if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) in zyd_tx_start()
2492 desc->phy |= ZYD_TX_PHY_SHPREAMBLE; in zyd_tx_start()
2494 totlen = m0->m_pkthdr.len + IEEE80211_CRC_LEN; in zyd_tx_start()
2495 desc->len = htole16(totlen); in zyd_tx_start()
2497 desc->flags = ZYD_TX_FLAG_BACKOFF; in zyd_tx_start()
2500 if (totlen > vap->iv_rtsthreshold) { in zyd_tx_start()
2501 desc->flags |= ZYD_TX_FLAG_RTS; in zyd_tx_start()
2503 (ic->ic_flags & IEEE80211_F_USEPROT)) { in zyd_tx_start()
2504 if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in zyd_tx_start()
2505 desc->flags |= ZYD_TX_FLAG_CTS_TO_SELF; in zyd_tx_start()
2506 else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in zyd_tx_start()
2507 desc->flags |= ZYD_TX_FLAG_RTS; in zyd_tx_start()
2510 desc->flags |= ZYD_TX_FLAG_MULTICAST; in zyd_tx_start()
2512 desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL); in zyd_tx_start()
2516 if (sc->sc_macrev == ZYD_ZD1211) in zyd_tx_start()
2518 desc->pktlen = htole16(pktlen); in zyd_tx_start()
2522 desc->plcp_length = htole16(bits / ratediv[phy]); in zyd_tx_start()
2523 desc->plcp_service = 0; in zyd_tx_start()
2525 desc->plcp_service |= ZYD_PLCP_LENGEXT; in zyd_tx_start()
2526 desc->nextlen = 0; in zyd_tx_start()
2529 struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; in zyd_tx_start() local
2531 tap->wt_flags = 0; in zyd_tx_start()
2532 tap->wt_rate = rate; in zyd_tx_start()
2539 device_get_nameunit(sc->sc_dev), (size_t)m0->m_pkthdr.len, in zyd_tx_start()
2542 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in zyd_tx_start()
2543 usbd_transfer_start(sc->sc_xfer[ZYD_BULK_WR]); in zyd_tx_start()
2551 struct zyd_softc *sc = ic->ic_softc; in zyd_transmit()
2555 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) { in zyd_transmit()
2559 error = mbufq_enqueue(&sc->sc_snd, m); in zyd_transmit()
2578 while (sc->tx_nfree > 0 && (m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in zyd_start()
2579 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in zyd_start()
2582 if_inc_counter(ni->ni_vap->iv_ifp, in zyd_start()
2594 struct ieee80211com *ic = ni->ni_ic; in zyd_raw_xmit()
2595 struct zyd_softc *sc = ic->ic_softc; in zyd_raw_xmit()
2599 if (!(sc->sc_flags & ZYD_FLAG_RUNNING)) { in zyd_raw_xmit()
2604 if (sc->tx_nfree == 0) { in zyd_raw_xmit()
2627 struct zyd_softc *sc = ic->ic_softc; in zyd_parent()
2631 if (sc->sc_flags & ZYD_FLAG_DETACHED) { in zyd_parent()
2635 if (ic->ic_nrunning > 0) { in zyd_parent()
2636 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) { in zyd_parent()
2641 } else if (sc->sc_flags & ZYD_FLAG_RUNNING) in zyd_parent()
2651 struct ieee80211com *ic = &sc->sc_ic; in zyd_init_locked()
2652 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in zyd_init_locked()
2659 if (!(sc->sc_flags & ZYD_FLAG_INITONCE)) { in zyd_init_locked()
2662 device_printf(sc->sc_dev, in zyd_init_locked()
2668 cd = usbd_get_config_descriptor(sc->sc_udev); in zyd_init_locked()
2669 error = usbd_req_set_config(sc->sc_udev, &sc->sc_mtx, in zyd_init_locked()
2670 cd->bConfigurationValue); in zyd_init_locked()
2672 device_printf(sc->sc_dev, "reset failed, continuing\n"); in zyd_init_locked()
2676 device_printf(sc->sc_dev, in zyd_init_locked()
2681 device_printf(sc->sc_dev, in zyd_init_locked()
2684 (sc->sc_macrev == ZYD_ZD1211) ? "": "B", in zyd_init_locked()
2685 sc->sc_fwrev >> 8, sc->sc_fwrev & 0xff, in zyd_init_locked()
2686 zyd_rf_name(sc->sc_rfrev), sc->sc_al2230s, sc->sc_parev, in zyd_init_locked()
2687 sc->sc_ledtype, sc->sc_bandedge6, sc->sc_newphy, in zyd_init_locked()
2688 sc->sc_cckgain, sc->sc_fix_cr157); in zyd_init_locked()
2692 sc->sc_regdomain = val >> 16; in zyd_init_locked()
2694 sc->sc_regdomain); in zyd_init_locked()
2701 sc->sc_flags |= ZYD_FLAG_INITONCE; in zyd_init_locked()
2704 if (sc->sc_flags & ZYD_FLAG_RUNNING) in zyd_init_locked()
2708 vap ? vap->iv_myaddr : ic->ic_macaddr, ":"); in zyd_init_locked()
2709 error = zyd_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); in zyd_init_locked()
2714 if (ic->ic_curmode == IEEE80211_MODE_11B) in zyd_init_locked()
2716 else if (ic->ic_curmode == IEEE80211_MODE_11A) in zyd_init_locked()
2735 zyd_set_chan(sc, ic->ic_curchan); in zyd_init_locked()
2745 sc->sc_flags |= ZYD_FLAG_RUNNING; in zyd_init_locked()
2746 usbd_xfer_set_stall(sc->sc_xfer[ZYD_BULK_WR]); in zyd_init_locked()
2747 usbd_transfer_start(sc->sc_xfer[ZYD_BULK_RD]); in zyd_init_locked()
2748 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_RD]); in zyd_init_locked()
2763 sc->sc_flags &= ~ZYD_FLAG_RUNNING; in zyd_stop()
2770 usbd_transfer_drain(sc->sc_xfer[ZYD_BULK_WR]); in zyd_stop()
2771 usbd_transfer_drain(sc->sc_xfer[ZYD_BULK_RD]); in zyd_stop()
2777 if (!(sc->sc_flags & ZYD_FLAG_INITONCE)) in zyd_stop()
2802 if (sc->sc_flags & ZYD_FLAG_FWLOADED) in zyd_loadfirmware()
2805 if (sc->sc_macrev == ZYD_ZD1211) { in zyd_loadfirmware()
2836 size -= mlen; in zyd_loadfirmware()
2848 sc->sc_flags |= ZYD_FLAG_FWLOADED; in zyd_loadfirmware()
2856 struct zyd_softc *sc = ic->ic_softc; in zyd_scan_start()
2867 struct zyd_softc *sc = ic->ic_softc; in zyd_scan_end()
2871 zyd_set_bssid(sc, sc->sc_bssid); in zyd_scan_end()
2890 struct zyd_softc *sc = ic->ic_softc; in zyd_set_channel()
2893 zyd_set_chan(sc, ic->ic_curchan); in zyd_set_channel()