Lines Matching +full:rate +full:- +full:np +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)
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 zyd_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in zyd_attach()
388 ic->ic_channels); in zyd_attach()
391 ic->ic_raw_xmit = zyd_raw_xmit; in zyd_attach()
392 ic->ic_scan_start = zyd_scan_start; in zyd_attach()
393 ic->ic_scan_end = zyd_scan_end; in zyd_attach()
394 ic->ic_getradiocaps = zyd_getradiocaps; in zyd_attach()
395 ic->ic_set_channel = zyd_set_channel; in zyd_attach()
396 ic->ic_vap_create = zyd_vap_create; in zyd_attach()
397 ic->ic_vap_delete = zyd_vap_delete; in zyd_attach()
398 ic->ic_update_mcast = zyd_update_mcast; in zyd_attach()
399 ic->ic_update_promisc = zyd_update_mcast; in zyd_attach()
400 ic->ic_parent = zyd_parent; in zyd_attach()
401 ic->ic_transmit = zyd_transmit; in zyd_attach()
404 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in zyd_attach()
406 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in zyd_attach()
426 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in zyd_drain_mbufq()
427 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in zyd_drain_mbufq()
428 m->m_pkthdr.rcvif = NULL; in zyd_drain_mbufq()
438 struct ieee80211com *ic = &sc->sc_ic; in zyd_detach()
446 sc->sc_flags |= ZYD_FLAG_DETACHED; in zyd_detach()
448 STAILQ_INIT(&sc->tx_q); in zyd_detach()
449 STAILQ_INIT(&sc->tx_free); in zyd_detach()
454 usbd_transfer_drain(sc->sc_xfer[x]); in zyd_detach()
462 usbd_transfer_unsetup(sc->sc_xfer, ZYD_N_TRANSFER); in zyd_detach()
464 if (ic->ic_softc == sc) in zyd_detach()
466 mtx_destroy(&sc->sc_mtx); in zyd_detach()
480 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in zyd_vap_create()
483 vap = &zvp->vap; in zyd_vap_create()
494 zvp->newstate = vap->iv_newstate; in zyd_vap_create()
495 vap->iv_newstate = zyd_newstate; in zyd_vap_create()
503 ic->ic_opmode = opmode; in zyd_vap_create()
520 struct zyd_softc *sc = data->sc; in zyd_tx_free()
522 if (data->m != NULL) { in zyd_tx_free()
523 ieee80211_tx_complete(data->ni, data->m, txerr); in zyd_tx_free()
524 data->m = NULL; in zyd_tx_free()
525 data->ni = NULL; in zyd_tx_free()
527 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in zyd_tx_free()
528 sc->tx_nfree++; in zyd_tx_free()
537 sc->tx_nfree = 0; in zyd_setup_tx_list()
538 STAILQ_INIT(&sc->tx_q); in zyd_setup_tx_list()
539 STAILQ_INIT(&sc->tx_free); in zyd_setup_tx_list()
542 data = &sc->tx_data[i]; in zyd_setup_tx_list()
544 data->sc = sc; in zyd_setup_tx_list()
545 STAILQ_INSERT_TAIL(&sc->tx_free, data, next); in zyd_setup_tx_list()
546 sc->tx_nfree++; in zyd_setup_tx_list()
557 sc->tx_nfree = 0; in zyd_unsetup_tx_list()
558 STAILQ_INIT(&sc->tx_q); in zyd_unsetup_tx_list()
559 STAILQ_INIT(&sc->tx_free); in zyd_unsetup_tx_list()
563 data = &sc->tx_data[i]; in zyd_unsetup_tx_list()
565 if (data->m != NULL) { in zyd_unsetup_tx_list()
566 m_freem(data->m); in zyd_unsetup_tx_list()
567 data->m = NULL; in zyd_unsetup_tx_list()
569 if (data->ni != NULL) { in zyd_unsetup_tx_list()
570 ieee80211_free_node(data->ni); in zyd_unsetup_tx_list()
571 data->ni = NULL; in zyd_unsetup_tx_list()
580 struct ieee80211com *ic = vap->iv_ic; in zyd_newstate()
581 struct zyd_softc *sc = ic->ic_softc; in zyd_newstate()
584 DPRINTF(sc, ZYD_DEBUG_STATE, "%s: %s -> %s\n", __func__, in zyd_newstate()
585 ieee80211_state_name[vap->iv_state], in zyd_newstate()
592 zyd_set_chan(sc, ic->ic_curchan); in zyd_newstate()
595 if (vap->iv_opmode == IEEE80211_M_MONITOR) in zyd_newstate()
604 zyd_write32_m(sc, sc->sc_fwbase + ZYD_FW_LINK_STATUS, 1); in zyd_newstate()
606 IEEE80211_ADDR_COPY(sc->sc_bssid, vap->iv_bss->ni_bssid); in zyd_newstate()
607 zyd_set_bssid(sc, sc->sc_bssid); in zyd_newstate()
615 return (zvp->newstate(vap, nstate, arg)); in zyd_newstate()
625 struct ieee80211com *ic = &sc->sc_ic; in zyd_intr_read_callback()
626 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in zyd_intr_read_callback()
628 struct zyd_cmd *cmd = &sc->sc_ibuf; in zyd_intr_read_callback()
640 switch (le16toh(cmd->code)) { in zyd_intr_read_callback()
644 (struct zyd_notif_retry *)cmd->data; in zyd_intr_read_callback()
645 uint16_t count = le16toh(retry->count); in zyd_intr_read_callback()
648 "retry intr: rate=0x%x addr=%s count=%d (0x%x)\n", in zyd_intr_read_callback()
649 le16toh(retry->rate), ether_sprintf(retry->macaddr), in zyd_intr_read_callback()
658 ni = ieee80211_find_txnode(vap, retry->macaddr); in zyd_intr_read_callback()
661 &sc->sc_txs; in zyd_intr_read_callback()
664 txs->flags = in zyd_intr_read_callback()
666 txs->long_retries = retrycnt; in zyd_intr_read_callback()
668 txs->status = in zyd_intr_read_callback()
671 txs->status = in zyd_intr_read_callback()
680 if_inc_counter(vap->iv_ifp, IFCOUNTER_OERRORS, in zyd_intr_read_callback()
688 if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT) in zyd_intr_read_callback()
691 datalen = actlen - sizeof(cmd->code); in zyd_intr_read_callback()
692 datalen -= 2; /* XXX: padding? */ in zyd_intr_read_callback()
694 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_read_callback()
698 if (rqp->olen != datalen) in zyd_intr_read_callback()
700 count = rqp->olen / sizeof(struct zyd_pair); in zyd_intr_read_callback()
702 if (*(((const uint16_t *)rqp->idata) + i) != in zyd_intr_read_callback()
703 (((struct zyd_pair *)cmd->data) + i)->reg) in zyd_intr_read_callback()
708 /* copy answer into caller-supplied buffer */ in zyd_intr_read_callback()
709 memcpy(rqp->odata, cmd->data, rqp->olen); in zyd_intr_read_callback()
712 rqp, rqp->olen, (char *)rqp->odata, ":"); in zyd_intr_read_callback()
717 device_printf(sc->sc_dev, in zyd_intr_read_callback()
719 datalen, cmd->data, ":"); in zyd_intr_read_callback()
724 device_printf(sc->sc_dev, "unknown notification %x\n", in zyd_intr_read_callback()
725 le16toh(cmd->code)); in zyd_intr_read_callback()
759 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_write_callback()
762 (rqp->flags & ZYD_CMD_FLAG_READ) == 0) in zyd_intr_write_callback()
769 STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { in zyd_intr_write_callback()
770 if (rqp->flags & ZYD_CMD_FLAG_SENT) in zyd_intr_write_callback()
774 usbd_copy_in(pc, 0, rqp->cmd, rqp->ilen); in zyd_intr_write_callback()
776 usbd_xfer_set_frame_len(xfer, 0, rqp->ilen); in zyd_intr_write_callback()
778 rqp->flags |= ZYD_CMD_FLAG_SENT; in zyd_intr_write_callback()
819 STAILQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); in zyd_cmd()
820 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_RD]); in zyd_cmd()
821 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_WR]); in zyd_cmd()
824 error = mtx_sleep(&rq, &sc->sc_mtx, 0 , "zydcmd", hz); in zyd_cmd()
826 device_printf(sc->sc_dev, "command timeout\n"); in zyd_cmd()
827 STAILQ_REMOVE(&sc->sc_rqh, &rq, zyd_rq, rq); in zyd_cmd()
891 struct zyd_rf *rf = &sc->sc_rf; in zyd_rfwrite()
900 req.width = htole16(rf->width); in zyd_rfwrite()
901 for (i = 0; i < rf->width; i++) { in zyd_rfwrite()
903 if (val & (1 << (rf->width - 1 - i))) in zyd_rfwrite()
906 error = zyd_cmd(sc, ZYD_CMD_RFCFG, &req, 4 + 2 * rf->width, NULL, 0, 0); in zyd_rfwrite()
955 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_init()
960 /* init RF-dependent PHY registers */ in zyd_rfmd_init()
978 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_switch_radio()
990 struct zyd_softc *sc = rf->rf_sc; in zyd_rfmd_set_channel()
995 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_rfmd_set_channel()
998 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_rfmd_set_channel()
1012 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_init()
1024 /* init RF-dependent PHY registers */ in zyd_al2230_init()
1028 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { in zyd_al2230_init()
1040 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) in zyd_al2230_init()
1069 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_fini()
1075 if (sc->sc_newphy != 0) in zyd_al2230_fini()
1086 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_init_b()
1101 /* init RF-dependent PHY registers */ in zyd_al2230_init_b()
1105 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) { in zyd_al2230_init_b()
1122 if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) in zyd_al2230_init_b()
1155 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_switch_radio()
1156 int error, on251 = (sc->sc_macrev == ZYD_ZD1211) ? 0x3f : 0x7f; in zyd_al2230_switch_radio()
1168 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_set_channel()
1176 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_al2230_set_channel()
1179 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_al2230_set_channel()
1182 error = zyd_rfwrite(sc, rfprog[chan - 1].r3); in zyd_al2230_set_channel()
1196 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_set_channel_b()
1205 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r1); in zyd_al2230_set_channel_b()
1208 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r2); in zyd_al2230_set_channel_b()
1211 error = zyd_rfwrite_cr(sc, rfprog[chan - 1].r3); in zyd_al2230_set_channel_b()
1229 struct zyd_softc *sc = rf->rf_sc; in zyd_al2230_bandedge6()
1230 struct ieee80211com *ic = &sc->sc_ic; in zyd_al2230_bandedge6()
1249 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_init()
1259 /* init RF-dependent PHY registers, part one */ in zyd_al7230B_init()
1268 /* init RF-dependent PHY registers, part two */ in zyd_al7230B_init()
1277 /* init RF-dependent PHY registers, part three */ in zyd_al7230B_init()
1288 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_switch_radio()
1299 struct zyd_softc *sc = rf->rf_sc; in zyd_al7230B_set_channel()
1320 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_al7230B_set_channel()
1323 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_al7230B_set_channel()
1343 struct zyd_softc *sc = rf->rf_sc; in zyd_al2210_init()
1351 /* init RF-dependent PHY registers */ in zyd_al2210_init()
1384 struct zyd_softc *sc = rf->rf_sc; in zyd_al2210_set_channel()
1398 error = zyd_rfwrite(sc, rfprog[chan - 1]); in zyd_al2210_set_channel()
1414 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_init()
1418 int i, idx = -1, error; in zyd_gct_init()
1421 /* init RF-dependent PHY registers */ in zyd_gct_init()
1435 for (i = 0; i < (int)(nitems(vco) - 1); i++) { in zyd_gct_init()
1449 if (idx == -1) { in zyd_gct_init()
1458 rf->idx = idx; in zyd_gct_init()
1468 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_mode()
1484 int error, idx = chan - 1; in zyd_gct_set_channel_synth()
1485 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_set_channel_synth()
1500 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_write()
1509 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_switch_radio()
1517 on ? ((sc->sc_macrev == ZYD_ZD1211B) ? 0x7f : 0x3f) : 0x2f); in zyd_gct_switch_radio()
1526 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_set_channel()
1536 error = zyd_gct_write(rf, (rf->idx == -1) ? 0x6662 : in zyd_gct_set_channel()
1537 vco[rf->idx][((chan - 1) / 2)]); in zyd_gct_set_channel()
1556 struct zyd_softc *sc = rf->rf_sc; in zyd_gct_txgain()
1558 uint8_t idx = sc->sc_pwrint[chan - 1]; in zyd_gct_txgain()
1561 device_printf(sc->sc_dev, "could not set TX gain (%d %#x)\n", in zyd_gct_txgain()
1575 struct zyd_softc *sc = rf->rf_sc; in zyd_maxim2_init()
1581 /* init RF-dependent PHY registers */ in zyd_maxim2_init()
1610 struct zyd_softc *sc = rf->rf_sc; in zyd_maxim2_set_channel()
1624 /* init RF-dependent PHY registers */ in zyd_maxim2_set_channel()
1632 error = zyd_rfwrite(sc, rfprog[chan - 1].r1); in zyd_maxim2_set_channel()
1635 error = zyd_rfwrite(sc, rfprog[chan - 1].r2); in zyd_maxim2_set_channel()
1639 /* init maxim2 radio - skipping the two first values */ in zyd_maxim2_set_channel()
1653 struct zyd_rf *rf = &sc->sc_rf; in zyd_rf_attach()
1655 rf->rf_sc = sc; in zyd_rf_attach()
1656 rf->update_pwr = 1; in zyd_rf_attach()
1660 rf->init = zyd_rfmd_init; in zyd_rf_attach()
1661 rf->switch_radio = zyd_rfmd_switch_radio; in zyd_rf_attach()
1662 rf->set_channel = zyd_rfmd_set_channel; in zyd_rf_attach()
1663 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1667 if (sc->sc_macrev == ZYD_ZD1211B) { in zyd_rf_attach()
1668 rf->init = zyd_al2230_init_b; in zyd_rf_attach()
1669 rf->set_channel = zyd_al2230_set_channel_b; in zyd_rf_attach()
1671 rf->init = zyd_al2230_init; in zyd_rf_attach()
1672 rf->set_channel = zyd_al2230_set_channel; in zyd_rf_attach()
1674 rf->switch_radio = zyd_al2230_switch_radio; in zyd_rf_attach()
1675 rf->bandedge6 = zyd_al2230_bandedge6; in zyd_rf_attach()
1676 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1679 rf->init = zyd_al7230B_init; in zyd_rf_attach()
1680 rf->switch_radio = zyd_al7230B_switch_radio; in zyd_rf_attach()
1681 rf->set_channel = zyd_al7230B_set_channel; in zyd_rf_attach()
1682 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1685 rf->init = zyd_al2210_init; in zyd_rf_attach()
1686 rf->switch_radio = zyd_al2210_switch_radio; in zyd_rf_attach()
1687 rf->set_channel = zyd_al2210_set_channel; in zyd_rf_attach()
1688 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1692 rf->init = zyd_gct_init; in zyd_rf_attach()
1693 rf->switch_radio = zyd_gct_switch_radio; in zyd_rf_attach()
1694 rf->set_channel = zyd_gct_set_channel; in zyd_rf_attach()
1695 rf->width = 24; /* 24-bit RF values */ in zyd_rf_attach()
1696 rf->update_pwr = 0; in zyd_rf_attach()
1699 rf->init = zyd_maxim2_init; in zyd_rf_attach()
1700 rf->switch_radio = zyd_maxim2_switch_radio; in zyd_rf_attach()
1701 rf->set_channel = zyd_maxim2_set_channel; in zyd_rf_attach()
1702 rf->width = 18; /* 18-bit RF values */ in zyd_rf_attach()
1705 device_printf(sc->sc_dev, in zyd_rf_attach()
1731 struct zyd_rf *rf = &sc->sc_rf; in zyd_hw_init()
1736 zyd_read16_m(sc, ZYD_FIRMWARE_BASE_ADDR, &sc->sc_fwbase); in zyd_hw_init()
1738 sc->sc_fwbase); in zyd_hw_init()
1741 zyd_read16_m(sc, sc->sc_fwbase + ZYD_FW_FIRMWARE_REV, &sc->sc_fwrev); in zyd_hw_init()
1744 /* set mandatory rates - XXX assumes 802.11b/g */ in zyd_hw_init()
1751 device_printf(sc->sc_dev, "could not read EEPROM\n"); in zyd_hw_init()
1759 phyp = (sc->sc_macrev == ZYD_ZD1211B) ? zyd_def_phyB : zyd_def_phy; in zyd_hw_init()
1760 for (; phyp->reg != 0; phyp++) in zyd_hw_init()
1761 zyd_write16_m(sc, phyp->reg, phyp->val); in zyd_hw_init()
1762 if (sc->sc_macrev == ZYD_ZD1211 && sc->sc_fix_cr157 != 0) { in zyd_hw_init()
1792 if (sc->sc_macrev == ZYD_ZD1211) { in zyd_hw_init()
1807 /* init beacon interval to 100ms */ in zyd_hw_init()
1811 if ((error = zyd_rf_attach(sc, sc->sc_rfrev)) != 0) { in zyd_hw_init()
1812 device_printf(sc->sc_dev, "could not attach RF, rev 0x%x\n", in zyd_hw_init()
1813 sc->sc_rfrev); in zyd_hw_init()
1821 error = (*rf->init)(rf); in zyd_hw_init()
1823 device_printf(sc->sc_dev, in zyd_hw_init()
1832 device_printf(sc->sc_dev, "could not read EEPROM\n"); in zyd_hw_init()
1846 sc->sc_rfrev = tmp & 0x0f; in zyd_read_pod()
1847 sc->sc_ledtype = (tmp >> 4) & 0x01; in zyd_read_pod()
1848 sc->sc_al2230s = (tmp >> 7) & 0x01; in zyd_read_pod()
1849 sc->sc_cckgain = (tmp >> 8) & 0x01; in zyd_read_pod()
1850 sc->sc_fix_cr157 = (tmp >> 13) & 0x01; in zyd_read_pod()
1851 sc->sc_parev = (tmp >> 16) & 0x0f; in zyd_read_pod()
1852 sc->sc_bandedge6 = (tmp >> 21) & 0x01; in zyd_read_pod()
1853 sc->sc_newphy = (tmp >> 31) & 0x01; in zyd_read_pod()
1854 sc->sc_txled = ((tmp & (1 << 24)) && (tmp & (1 << 29))) ? 0 : 1; in zyd_read_pod()
1868 sc->sc_pwrcal[i * 2] = val >> 8; in zyd_read_eeprom()
1869 sc->sc_pwrcal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1871 sc->sc_pwrint[i * 2] = val >> 8; in zyd_read_eeprom()
1872 sc->sc_pwrint[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1874 sc->sc_ofdm36_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1875 sc->sc_ofdm36_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1877 sc->sc_ofdm48_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1878 sc->sc_ofdm48_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1880 sc->sc_ofdm54_cal[i * 2] = val >> 8; in zyd_read_eeprom()
1881 sc->sc_ofdm54_cal[i * 2 + 1] = val & 0xff; in zyd_read_eeprom()
1899 error = zyd_do_request(sc, &req, sc->sc_ic.ic_macaddr); in zyd_get_macaddr()
1901 device_printf(sc->sc_dev, "could not read EEPROM: %s\n", in zyd_get_macaddr()
1939 struct zyd_rf *rf = &sc->sc_rf; in zyd_switch_radio()
1945 error = (*rf->switch_radio)(rf, on); in zyd_switch_radio()
1978 hash[1] |= 1 << (v - 32); in zyd_hash_maddr()
1986 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_multi()
1990 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) in zyd_set_multi()
1996 if (ic->ic_opmode == IEEE80211_M_MONITOR || ic->ic_allmulti > 0 || in zyd_set_multi()
1997 ic->ic_promisc > 0) { in zyd_set_multi()
2003 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in zyd_set_multi()
2004 if_foreach_llmaddr(vap->iv_ifp, zyd_hash_maddr, &hash); in zyd_set_multi()
2012 device_printf(sc->sc_dev, in zyd_set_multi()
2019 struct zyd_softc *sc = ic->ic_softc; in zyd_update_mcast()
2029 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_rxfilter()
2032 switch (ic->ic_opmode) { in zyd_set_rxfilter()
2054 struct ieee80211com *ic = &sc->sc_ic; in zyd_set_chan()
2055 struct zyd_rf *rf = &sc->sc_rf; in zyd_set_chan()
2062 device_printf(sc->sc_dev, in zyd_set_chan()
2071 error = (*rf->set_channel)(rf, chan); in zyd_set_chan()
2075 if (rf->update_pwr) { in zyd_set_chan()
2077 zyd_write16_m(sc, ZYD_CR31, sc->sc_pwrint[chan - 1]); in zyd_set_chan()
2079 if (sc->sc_macrev == ZYD_ZD1211B) { in zyd_set_chan()
2081 sc->sc_ofdm36_cal[chan - 1]); in zyd_set_chan()
2083 sc->sc_ofdm48_cal[chan - 1]); in zyd_set_chan()
2085 sc->sc_ofdm54_cal[chan - 1]); in zyd_set_chan()
2086 zyd_write16_m(sc, ZYD_CR68, sc->sc_pwrcal[chan - 1]); in zyd_set_chan()
2091 if (sc->sc_cckgain) { in zyd_set_chan()
2096 if (sc->sc_bandedge6 && rf->bandedge6 != NULL) { in zyd_set_chan()
2097 error = (*rf->bandedge6)(rf, c); in zyd_set_chan()
2107 sc->sc_rxtap.wr_chan_freq = sc->sc_txtap.wt_chan_freq = in zyd_set_chan()
2108 htole16(c->ic_freq); in zyd_set_chan()
2109 sc->sc_rxtap.wr_chan_flags = sc->sc_txtap.wt_chan_flags = in zyd_set_chan()
2110 htole16(c->ic_flags); in zyd_set_chan()
2122 sc->sc_atim_wnd = val; in zyd_set_beacon_interval()
2124 sc->sc_pre_tbtt = val; in zyd_set_beacon_interval()
2125 sc->sc_bcn_int = bintval; in zyd_set_beacon_interval()
2127 if (sc->sc_bcn_int <= 5) in zyd_set_beacon_interval()
2128 sc->sc_bcn_int = 5; in zyd_set_beacon_interval()
2129 if (sc->sc_pre_tbtt < 4 || sc->sc_pre_tbtt >= sc->sc_bcn_int) in zyd_set_beacon_interval()
2130 sc->sc_pre_tbtt = sc->sc_bcn_int - 1; in zyd_set_beacon_interval()
2131 if (sc->sc_atim_wnd >= sc->sc_pre_tbtt) in zyd_set_beacon_interval()
2132 sc->sc_atim_wnd = sc->sc_pre_tbtt - 1; in zyd_set_beacon_interval()
2134 zyd_write32_m(sc, ZYD_CR_ATIM_WND_PERIOD, sc->sc_atim_wnd); in zyd_set_beacon_interval()
2135 zyd_write32_m(sc, ZYD_CR_PRE_TBTT, sc->sc_pre_tbtt); in zyd_set_beacon_interval()
2136 zyd_write32_m(sc, ZYD_CR_BCN_INTERVAL, sc->sc_bcn_int); in zyd_set_beacon_interval()
2145 struct ieee80211com *ic = &sc->sc_ic; in zyd_rx_data()
2154 device_get_nameunit(sc->sc_dev), len); in zyd_rx_data()
2155 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2160 usbd_copy_out(pc, offset + len - sizeof(stat), &stat, sizeof(stat)); in zyd_rx_data()
2165 device_get_nameunit(sc->sc_dev), stat.flags); in zyd_rx_data()
2166 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2171 rlen = len - sizeof(struct zyd_plcphdr) - in zyd_rx_data()
2172 sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN; in zyd_rx_data()
2177 device_get_nameunit(sc->sc_dev), rlen); in zyd_rx_data()
2178 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2186 device_get_nameunit(sc->sc_dev)); in zyd_rx_data()
2187 counter_u64_add(ic->ic_ierrors, 1); in zyd_rx_data()
2190 m->m_pkthdr.len = m->m_len = rlen; in zyd_rx_data()
2194 struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap; in zyd_rx_data()
2196 tap->wr_flags = 0; in zyd_rx_data()
2198 tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; in zyd_rx_data()
2201 tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; in zyd_rx_data()
2202 tap->wr_rate = ieee80211_plcp2rate(plcp.signal, in zyd_rx_data()
2205 tap->wr_antsignal = stat.rssi + -95; in zyd_rx_data()
2206 tap->wr_antnoise = -95; /* XXX */ in zyd_rx_data()
2210 sc->sc_rx_data[sc->sc_rx_count].rssi = rssi; in zyd_rx_data()
2211 sc->sc_rx_data[sc->sc_rx_count].m = m; in zyd_rx_data()
2212 sc->sc_rx_count++; in zyd_rx_data()
2219 struct ieee80211com *ic = &sc->sc_ic; in zyd_bulk_read_callback()
2232 sc->sc_rx_count = 0; in zyd_bulk_read_callback()
2236 usbd_copy_out(pc, actlen - sizeof(desc), &desc, sizeof(desc)); in zyd_bulk_read_callback()
2241 "%s: received multi-frame transfer\n", __func__); in zyd_bulk_read_callback()
2251 /* next frame is aligned on a 32-bit boundary */ in zyd_bulk_read_callback()
2256 actlen -= len16; in zyd_bulk_read_callback()
2260 "%s: received single-frame transfer\n", __func__); in zyd_bulk_read_callback()
2276 for (i = 0; i < sc->sc_rx_count; i++) { in zyd_bulk_read_callback()
2277 rssi = sc->sc_rx_data[i].rssi; in zyd_bulk_read_callback()
2278 m = sc->sc_rx_data[i].m; in zyd_bulk_read_callback()
2279 sc->sc_rx_data[i].m = NULL; in zyd_bulk_read_callback()
2281 nf = -95; /* XXX */ in zyd_bulk_read_callback()
2308 zyd_plcp_signal(struct zyd_softc *sc, int rate) in zyd_plcp_signal() argument
2310 switch (rate) { in zyd_plcp_signal()
2311 /* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */ in zyd_plcp_signal()
2328 /* CCK rates (NB: not IEEE std, device-specific) */ in zyd_plcp_signal()
2339 device_printf(sc->sc_dev, "unsupported rate %d\n", rate); in zyd_plcp_signal()
2368 data = STAILQ_FIRST(&sc->tx_q); in zyd_bulk_write_callback()
2370 STAILQ_REMOVE_HEAD(&sc->tx_q, next); in zyd_bulk_write_callback()
2371 m = data->m; in zyd_bulk_write_callback()
2373 if (m->m_pkthdr.len > (int)ZYD_MAX_TXBUFSZ) { in zyd_bulk_write_callback()
2375 m->m_pkthdr.len); in zyd_bulk_write_callback()
2376 m->m_pkthdr.len = ZYD_MAX_TXBUFSZ; in zyd_bulk_write_callback()
2379 usbd_copy_in(pc, 0, &data->desc, ZYD_TX_DESC_SIZE); in zyd_bulk_write_callback()
2381 m->m_pkthdr.len); in zyd_bulk_write_callback()
2383 vap = data->ni->ni_vap; in zyd_bulk_write_callback()
2385 struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; in zyd_bulk_write_callback()
2387 tap->wt_flags = 0; in zyd_bulk_write_callback()
2388 tap->wt_rate = data->rate; in zyd_bulk_write_callback()
2393 usbd_xfer_set_frame_len(xfer, 0, ZYD_TX_DESC_SIZE + m->m_pkthdr.len); in zyd_bulk_write_callback()
2404 counter_u64_add(sc->sc_ic.ic_oerrors, 1); in zyd_bulk_write_callback()
2412 device_printf(sc->sc_dev, "device timeout\n"); in zyd_bulk_write_callback()
2417 * introduces a 50 ms delay: in zyd_bulk_write_callback()
2429 struct ieee80211vap *vap = ni->ni_vap; in zyd_tx_start()
2430 struct ieee80211com *ic = ni->ni_ic; in zyd_tx_start()
2434 const struct ieee80211_txparam *tp = ni->ni_txparms; in zyd_tx_start()
2436 int rate, totlen, type, ismcast; in zyd_tx_start() local
2443 data = STAILQ_FIRST(&sc->tx_free); in zyd_tx_start()
2444 STAILQ_REMOVE_HEAD(&sc->tx_free, next); in zyd_tx_start()
2445 sc->tx_nfree--; in zyd_tx_start()
2447 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in zyd_tx_start()
2448 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK; in zyd_tx_start()
2452 (m0->m_flags & M_EAPOL) != 0) { in zyd_tx_start()
2453 rate = tp->mgmtrate; in zyd_tx_start()
2457 rate = tp->mcastrate; in zyd_tx_start()
2458 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) in zyd_tx_start()
2459 rate = tp->ucastrate; in zyd_tx_start()
2462 rate = ieee80211_node_get_txrate_dot11rate(ni); in zyd_tx_start()
2466 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in zyd_tx_start()
2475 data->ni = ni; in zyd_tx_start()
2476 data->m = m0; in zyd_tx_start()
2477 data->rate = rate; in zyd_tx_start()
2480 desc = &data->desc; in zyd_tx_start()
2481 phy = zyd_plcp_signal(sc, rate); in zyd_tx_start()
2482 desc->phy = phy; in zyd_tx_start()
2483 if (ZYD_RATE_IS_OFDM(rate)) { in zyd_tx_start()
2484 desc->phy |= ZYD_TX_PHY_OFDM; in zyd_tx_start()
2485 if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) in zyd_tx_start()
2486 desc->phy |= ZYD_TX_PHY_5GHZ; in zyd_tx_start()
2487 } else if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) in zyd_tx_start()
2488 desc->phy |= ZYD_TX_PHY_SHPREAMBLE; in zyd_tx_start()
2490 totlen = m0->m_pkthdr.len + IEEE80211_CRC_LEN; in zyd_tx_start()
2491 desc->len = htole16(totlen); in zyd_tx_start()
2493 desc->flags = ZYD_TX_FLAG_BACKOFF; in zyd_tx_start()
2496 if (totlen > vap->iv_rtsthreshold) { in zyd_tx_start()
2497 desc->flags |= ZYD_TX_FLAG_RTS; in zyd_tx_start()
2498 } else if (ZYD_RATE_IS_OFDM(rate) && in zyd_tx_start()
2499 (ic->ic_flags & IEEE80211_F_USEPROT)) { in zyd_tx_start()
2500 if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in zyd_tx_start()
2501 desc->flags |= ZYD_TX_FLAG_CTS_TO_SELF; in zyd_tx_start()
2502 else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in zyd_tx_start()
2503 desc->flags |= ZYD_TX_FLAG_RTS; in zyd_tx_start()
2506 desc->flags |= ZYD_TX_FLAG_MULTICAST; in zyd_tx_start()
2508 desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL); in zyd_tx_start()
2512 if (sc->sc_macrev == ZYD_ZD1211) in zyd_tx_start()
2514 desc->pktlen = htole16(pktlen); in zyd_tx_start()
2516 bits = (rate == 11) ? (totlen * 16) + 10 : in zyd_tx_start()
2517 ((rate == 22) ? (totlen * 8) + 10 : (totlen * 8)); in zyd_tx_start()
2518 desc->plcp_length = htole16(bits / ratediv[phy]); in zyd_tx_start()
2519 desc->plcp_service = 0; in zyd_tx_start()
2520 if (rate == 22 && (bits % 11) > 0 && (bits % 11) <= 3) in zyd_tx_start()
2521 desc->plcp_service |= ZYD_PLCP_LENGEXT; in zyd_tx_start()
2522 desc->nextlen = 0; in zyd_tx_start()
2525 struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; in zyd_tx_start()
2527 tap->wt_flags = 0; in zyd_tx_start()
2528 tap->wt_rate = rate; in zyd_tx_start()
2534 "%s: sending data frame len=%zu rate=%u\n", in zyd_tx_start()
2535 device_get_nameunit(sc->sc_dev), (size_t)m0->m_pkthdr.len, in zyd_tx_start()
2536 rate); in zyd_tx_start()
2538 STAILQ_INSERT_TAIL(&sc->tx_q, data, next); in zyd_tx_start()
2539 usbd_transfer_start(sc->sc_xfer[ZYD_BULK_WR]); in zyd_tx_start()
2547 struct zyd_softc *sc = ic->ic_softc; in zyd_transmit()
2551 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) { in zyd_transmit()
2555 error = mbufq_enqueue(&sc->sc_snd, m); in zyd_transmit()
2574 while (sc->tx_nfree > 0 && (m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in zyd_start()
2575 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; in zyd_start()
2578 if_inc_counter(ni->ni_vap->iv_ifp, in zyd_start()
2590 struct ieee80211com *ic = ni->ni_ic; in zyd_raw_xmit()
2591 struct zyd_softc *sc = ic->ic_softc; in zyd_raw_xmit()
2595 if (!(sc->sc_flags & ZYD_FLAG_RUNNING)) { in zyd_raw_xmit()
2600 if (sc->tx_nfree == 0) { in zyd_raw_xmit()
2623 struct zyd_softc *sc = ic->ic_softc; in zyd_parent()
2627 if (sc->sc_flags & ZYD_FLAG_DETACHED) { in zyd_parent()
2631 if (ic->ic_nrunning > 0) { in zyd_parent()
2632 if ((sc->sc_flags & ZYD_FLAG_RUNNING) == 0) { in zyd_parent()
2637 } else if (sc->sc_flags & ZYD_FLAG_RUNNING) in zyd_parent()
2647 struct ieee80211com *ic = &sc->sc_ic; in zyd_init_locked()
2648 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in zyd_init_locked()
2655 if (!(sc->sc_flags & ZYD_FLAG_INITONCE)) { in zyd_init_locked()
2658 device_printf(sc->sc_dev, in zyd_init_locked()
2664 cd = usbd_get_config_descriptor(sc->sc_udev); in zyd_init_locked()
2665 error = usbd_req_set_config(sc->sc_udev, &sc->sc_mtx, in zyd_init_locked()
2666 cd->bConfigurationValue); in zyd_init_locked()
2668 device_printf(sc->sc_dev, "reset failed, continuing\n"); in zyd_init_locked()
2672 device_printf(sc->sc_dev, in zyd_init_locked()
2677 device_printf(sc->sc_dev, in zyd_init_locked()
2679 "BE%x NP%x Gain%x F%x\n", in zyd_init_locked()
2680 (sc->sc_macrev == ZYD_ZD1211) ? "": "B", in zyd_init_locked()
2681 sc->sc_fwrev >> 8, sc->sc_fwrev & 0xff, in zyd_init_locked()
2682 zyd_rf_name(sc->sc_rfrev), sc->sc_al2230s, sc->sc_parev, in zyd_init_locked()
2683 sc->sc_ledtype, sc->sc_bandedge6, sc->sc_newphy, in zyd_init_locked()
2684 sc->sc_cckgain, sc->sc_fix_cr157); in zyd_init_locked()
2688 sc->sc_regdomain = val >> 16; in zyd_init_locked()
2690 sc->sc_regdomain); in zyd_init_locked()
2697 sc->sc_flags |= ZYD_FLAG_INITONCE; in zyd_init_locked()
2700 if (sc->sc_flags & ZYD_FLAG_RUNNING) in zyd_init_locked()
2704 vap ? vap->iv_myaddr : ic->ic_macaddr, ":"); in zyd_init_locked()
2705 error = zyd_set_macaddr(sc, vap ? vap->iv_myaddr : ic->ic_macaddr); in zyd_init_locked()
2710 if (ic->ic_curmode == IEEE80211_MODE_11B) in zyd_init_locked()
2712 else if (ic->ic_curmode == IEEE80211_MODE_11A) in zyd_init_locked()
2731 zyd_set_chan(sc, ic->ic_curchan); in zyd_init_locked()
2741 sc->sc_flags |= ZYD_FLAG_RUNNING; in zyd_init_locked()
2742 usbd_xfer_set_stall(sc->sc_xfer[ZYD_BULK_WR]); in zyd_init_locked()
2743 usbd_transfer_start(sc->sc_xfer[ZYD_BULK_RD]); in zyd_init_locked()
2744 usbd_transfer_start(sc->sc_xfer[ZYD_INTR_RD]); in zyd_init_locked()
2759 sc->sc_flags &= ~ZYD_FLAG_RUNNING; in zyd_stop()
2766 usbd_transfer_drain(sc->sc_xfer[ZYD_BULK_WR]); in zyd_stop()
2767 usbd_transfer_drain(sc->sc_xfer[ZYD_BULK_RD]); in zyd_stop()
2773 if (!(sc->sc_flags & ZYD_FLAG_INITONCE)) in zyd_stop()
2798 if (sc->sc_flags & ZYD_FLAG_FWLOADED) in zyd_loadfirmware()
2801 if (sc->sc_macrev == ZYD_ZD1211) { in zyd_loadfirmware()
2832 size -= mlen; in zyd_loadfirmware()
2844 sc->sc_flags |= ZYD_FLAG_FWLOADED; in zyd_loadfirmware()
2852 struct zyd_softc *sc = ic->ic_softc; in zyd_scan_start()
2863 struct zyd_softc *sc = ic->ic_softc; in zyd_scan_end()
2867 zyd_set_bssid(sc, sc->sc_bssid); in zyd_scan_end()
2886 struct zyd_softc *sc = ic->ic_softc; in zyd_set_channel()
2889 zyd_set_chan(sc, ic->ic_curchan); in zyd_set_channel()