Lines Matching +full:rfkill +full:- +full:pcie +full:- +full:wlan

1 /*-
309 MODULE_DEPEND(wpi, wlan, 1, 1, 1);
317 for (ident = wpi_ident_table; ident->name != NULL; ident++) {
318 if (pci_get_vendor(dev) == ident->vendor &&
319 pci_get_device(dev) == ident->device) {
320 device_set_desc(dev, ident->name);
339 sc->sc_dev = dev;
342 error = resource_int_value(device_get_name(sc->sc_dev),
343 device_get_unit(sc->sc_dev), "debug", &(sc->sc_debug));
345 sc->sc_debug = 0;
347 sc->sc_debug = 0;
356 error = pci_find_cap(dev, PCIY_EXPRESS, &sc->sc_cap_off);
358 device_printf(dev, "PCIe capability structure not found!\n");
368 for (ident = wpi_ident_table; ident->name != NULL; ident++) {
369 if (ident->subdevice &&
370 pci_get_subdevice(dev) == ident->subdevice) {
377 /* Clear device-specific "PCI retry timeout" register (41h). */
380 /* Enable bus-mastering. */
384 sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
386 if (sc->mem == NULL) {
390 sc->sc_st = rman_get_bustag(sc->mem);
391 sc->sc_sh = rman_get_bushandle(sc->mem);
399 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE |
401 if (sc->irq == NULL) {
428 /* Allocate TX rings - 4 for QoS purposes, 1 for commands. */
430 if ((error = wpi_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
448 ic = &sc->sc_ic;
449 ic->ic_softc = sc;
450 ic->ic_name = device_get_nameunit(dev);
451 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */
452 ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */
455 ic->ic_caps =
468 | IEEE80211_C_PMGT /* Station-side power mgmt */
471 ic->ic_cryptocaps =
478 if ((error = wpi_read_eeprom(sc, ic->ic_macaddr)) != 0) {
486 device_printf(sc->sc_dev, "Regulatory Domain: %.4s\n",
487 sc->domain);
488 device_printf(sc->sc_dev, "Hardware Type: %c\n",
489 sc->type > 1 ? 'B': '?');
490 device_printf(sc->sc_dev, "Hardware Revision: %c\n",
491 ((sc->rev & 0xf0) == 0xd0) ? 'D': '?');
492 device_printf(sc->sc_dev, "SKU %s support 802.11a\n",
496 check what sc->rev really represents - benjsc 20070615 */
501 ic->ic_vap_create = wpi_vap_create;
502 ic->ic_vap_delete = wpi_vap_delete;
503 ic->ic_parent = wpi_parent;
504 ic->ic_raw_xmit = wpi_raw_xmit;
505 ic->ic_transmit = wpi_transmit;
506 ic->ic_node_alloc = wpi_node_alloc;
507 sc->sc_node_free = ic->ic_node_free;
508 ic->ic_node_free = wpi_node_free;
509 ic->ic_wme.wme_update = wpi_updateedca;
510 ic->ic_update_promisc = wpi_update_promisc;
511 ic->ic_update_mcast = wpi_update_mcast;
512 ic->ic_newassoc = wpi_newassoc;
513 ic->ic_scan_start = wpi_scan_start;
514 ic->ic_scan_end = wpi_scan_end;
515 ic->ic_set_channel = wpi_set_channel;
516 ic->ic_scan_curchan = wpi_scan_curchan;
517 ic->ic_scan_mindwell = wpi_scan_mindwell;
518 ic->ic_getradiocaps = wpi_getradiocaps;
519 ic->ic_setregdomain = wpi_setregdomain;
521 sc->sc_update_rx_ring = wpi_update_rx_ring;
522 sc->sc_update_tx_ring = wpi_update_tx_ring;
527 sc->sc_txs.flags = IEEE80211_RATECTL_STATUS_PKTLEN |
531 callout_init_mtx(&sc->calib_to, &sc->rxon_mtx, 0);
532 callout_init_mtx(&sc->scan_timeout, &sc->rxon_mtx, 0);
533 callout_init_mtx(&sc->tx_timeout, &sc->txq_state_mtx, 0);
534 callout_init_mtx(&sc->watchdog_rfkill, &sc->sc_mtx, 0);
535 TASK_INIT(&sc->sc_radiooff_task, 0, wpi_radio_off, sc);
536 TASK_INIT(&sc->sc_radioon_task, 0, wpi_radio_on, sc);
543 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
544 NULL, wpi_intr, sc, &sc->sc_ih);
555 if (sc->sc_debug & WPI_DEBUG_HW)
573 struct wpi_rx_radiotap_header *rxtap = &sc->sc_rxtap;
574 struct wpi_tx_radiotap_header *txtap = &sc->sc_txtap;
577 ieee80211_radiotap_attach(&sc->sc_ic,
578 &txtap->wt_ihdr, sizeof(*txtap), WPI_TX_RADIOTAP_PRESENT,
579 &rxtap->wr_ihdr, sizeof(*rxtap), WPI_RX_RADIOTAP_PRESENT);
587 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev);
588 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev);
591 "debug", CTLFLAG_RW, &sc->sc_debug, sc->sc_debug,
599 struct wpi_buf *bcn = &wvp->wv_bcbuf;
600 struct wpi_cmd_beacon *cmd = (struct wpi_cmd_beacon *)&bcn->data;
602 cmd->id = WPI_ID_BROADCAST;
603 cmd->ofdm_mask = 0xff;
604 cmd->cck_mask = 0x0f;
605 cmd->lifetime = htole32(WPI_LIFETIME_INFINITE);
608 * XXX WPI_TX_AUTO_SEQ seems to be ignored - workaround this issue
611 cmd->flags = htole32(WPI_TX_NEED_ACK | WPI_TX_INSERT_TSTAMP);
613 bcn->code = WPI_CMD_SET_BEACON;
614 bcn->ac = WPI_CMD_QUEUE_NUM;
615 bcn->size = sizeof(struct wpi_cmd_beacon);
627 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
631 vap = &wvp->wv_vap;
640 vap->iv_key_set = wpi_key_set;
641 vap->iv_key_delete = wpi_key_delete;
643 wvp->wv_recv_mgmt = vap->iv_recv_mgmt;
644 vap->iv_recv_mgmt = wpi_ibss_recv_mgmt;
646 wvp->wv_newstate = vap->iv_newstate;
647 vap->iv_newstate = wpi_newstate;
648 vap->iv_update_beacon = wpi_update_beacon;
649 vap->iv_max_aid = WPI_ID_IBSS_MAX - WPI_ID_IBSS_MIN + 1;
655 ic->ic_opmode = opmode;
663 struct wpi_buf *bcn = &wvp->wv_bcbuf;
664 enum ieee80211_opmode opmode = vap->iv_opmode;
670 if (bcn->m != NULL)
671 m_freem(bcn->m);
683 struct ieee80211com *ic = &sc->sc_ic;
688 if (ic->ic_vap_create == wpi_vap_create) {
689 ieee80211_draintask(ic, &sc->sc_radioon_task);
690 ieee80211_draintask(ic, &sc->sc_radiooff_task);
694 callout_drain(&sc->watchdog_rfkill);
695 callout_drain(&sc->tx_timeout);
696 callout_drain(&sc->scan_timeout);
697 callout_drain(&sc->calib_to);
702 if (sc->irq != NULL) {
703 bus_teardown_intr(dev, sc->irq, sc->sc_ih);
704 bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq),
705 sc->irq);
709 if (sc->txq[0].data_dmat) {
712 wpi_free_tx_ring(sc, &sc->txq[qid]);
718 if (sc->fw_dma.tag)
721 if (sc->mem != NULL)
723 rman_get_rid(sc->mem), sc->mem);
748 struct ieee80211com *ic = &sc->sc_ic;
758 struct ieee80211com *ic = &sc->sc_ic;
760 /* Clear device-specific "PCI retry timeout" register (41h). */
787 device_printf(sc->sc_dev, "could not lock memory\n");
833 for (; count != 0; count--, data++, addr += 4)
849 for (; count > 0; count--, addr += 4)
865 for (; count > 0; count -= 2, addr++) {
874 device_printf(sc->sc_dev,
909 dma->tag = NULL;
910 dma->size = size;
912 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), alignment,
914 1, size, 0, NULL, NULL, &dma->tag);
918 error = bus_dmamem_alloc(dma->tag, (void **)&dma->vaddr,
919 BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT, &dma->map);
923 error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr, size,
924 wpi_dma_map_addr, &dma->paddr, BUS_DMA_NOWAIT);
928 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
931 *kvap = dma->vaddr;
942 if (dma->vaddr != NULL) {
943 bus_dmamap_sync(dma->tag, dma->map,
945 bus_dmamap_unload(dma->tag, dma->map);
946 bus_dmamem_free(dma->tag, dma->vaddr, dma->map);
947 dma->vaddr = NULL;
949 if (dma->tag != NULL) {
950 bus_dma_tag_destroy(dma->tag);
951 dma->tag = NULL;
962 return wpi_dma_contig_alloc(sc, &sc->shared_dma,
963 (void **)&sc->shared, sizeof (struct wpi_shared), 4096);
969 wpi_dma_contig_free(&sc->shared_dma);
973 * Allocate DMA-safe memory for firmware transfer.
978 /* Must be aligned on a 16-byte boundary. */
979 return wpi_dma_contig_alloc(sc, &sc->fw_dma, NULL,
986 wpi_dma_contig_free(&sc->fw_dma);
992 struct wpi_rx_ring *ring = &sc->rxq;
996 ring->cur = 0;
997 ring->update = 0;
1003 error = wpi_dma_contig_alloc(sc, &ring->desc_dma,
1004 (void **)&ring->desc, size, WPI_RING_DMA_ALIGN);
1006 device_printf(sc->sc_dev,
1013 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
1015 MJUMPAGESIZE, 1, MJUMPAGESIZE, 0, NULL, NULL, &ring->data_dmat);
1017 device_printf(sc->sc_dev,
1027 struct wpi_rx_data *data = &ring->data[i];
1030 error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
1032 device_printf(sc->sc_dev,
1038 data->m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE);
1039 if (data->m == NULL) {
1040 device_printf(sc->sc_dev,
1046 error = bus_dmamap_load(ring->data_dmat, data->map,
1047 mtod(data->m, void *), MJUMPAGESIZE, wpi_dma_map_addr,
1050 device_printf(sc->sc_dev,
1057 ring->desc[i] = htole32(paddr);
1060 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
1077 WPI_WRITE(sc, WPI_FH_RX_WPTR, sc->rxq.cur & ~7);
1083 struct wpi_rx_ring *ring = &sc->rxq;
1085 if (ring->update != 0) {
1095 ring->update = 1;
1106 struct wpi_rx_ring *ring = &sc->rxq;
1122 ring->cur = 0;
1123 ring->update = 0;
1129 struct wpi_rx_ring *ring = &sc->rxq;
1134 wpi_dma_contig_free(&ring->desc_dma);
1137 struct wpi_rx_data *data = &ring->data[i];
1139 if (data->m != NULL) {
1140 bus_dmamap_sync(ring->data_dmat, data->map,
1142 bus_dmamap_unload(ring->data_dmat, data->map);
1143 m_freem(data->m);
1144 data->m = NULL;
1146 if (data->map != NULL)
1147 bus_dmamap_destroy(ring->data_dmat, data->map);
1149 if (ring->data_dmat != NULL) {
1150 bus_dma_tag_destroy(ring->data_dmat);
1151 ring->data_dmat = NULL;
1162 ring->qid = qid;
1163 ring->queued = 0;
1164 ring->cur = 0;
1165 ring->pending = 0;
1166 ring->update = 0;
1172 error = wpi_dma_contig_alloc(sc, &ring->desc_dma, (void **)&ring->desc,
1175 device_printf(sc->sc_dev,
1182 sc->shared->txbase[qid] = htole32(ring->desc_dma.paddr);
1183 bus_dmamap_sync(sc->shared_dma.tag, sc->shared_dma.map,
1187 error = wpi_dma_contig_alloc(sc, &ring->cmd_dma, (void **)&ring->cmd,
1190 device_printf(sc->sc_dev,
1196 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
1198 WPI_MAX_SCATTER - 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
1200 device_printf(sc->sc_dev,
1206 paddr = ring->cmd_dma.paddr;
1208 struct wpi_tx_data *data = &ring->data[i];
1210 data->cmd_paddr = paddr;
1213 error = bus_dmamap_create(ring->data_dmat, 0, &data->map);
1215 device_printf(sc->sc_dev,
1234 WPI_WRITE(sc, WPI_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur);
1241 if (ring->update != 0) {
1249 __func__, ring->qid);
1250 ring->update = 1;
1265 struct wpi_tx_data *data = &ring->data[i];
1267 if (data->m != NULL) {
1268 bus_dmamap_sync(ring->data_dmat, data->map,
1270 bus_dmamap_unload(ring->data_dmat, data->map);
1271 m_freem(data->m);
1272 data->m = NULL;
1274 if (data->ni != NULL) {
1275 ieee80211_free_node(data->ni);
1276 data->ni = NULL;
1280 memset(ring->desc, 0, ring->desc_dma.size);
1281 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
1283 ring->queued = 0;
1284 ring->cur = 0;
1285 ring->pending = 0;
1286 ring->update = 0;
1296 wpi_dma_contig_free(&ring->desc_dma);
1297 wpi_dma_contig_free(&ring->cmd_dma);
1300 struct wpi_tx_data *data = &ring->data[i];
1302 if (data->m != NULL) {
1303 bus_dmamap_sync(ring->data_dmat, data->map,
1305 bus_dmamap_unload(ring->data_dmat, data->map);
1306 m_freem(data->m);
1308 if (data->map != NULL)
1309 bus_dmamap_destroy(ring->data_dmat, data->map);
1311 if (ring->data_dmat != NULL) {
1312 bus_dma_tag_destroy(ring->data_dmat);
1313 ring->data_dmat = NULL;
1334 device_printf(sc->sc_dev,
1341 device_printf(sc->sc_dev, "bad EEPROM signature\n");
1349 WPI_CHK(wpi_read_prom_data(sc, WPI_EEPROM_SKU_CAP, &sc->cap,
1350 sizeof(sc->cap)));
1351 WPI_CHK(wpi_read_prom_data(sc, WPI_EEPROM_REVISION, &sc->rev,
1352 sizeof(sc->rev)));
1353 WPI_CHK(wpi_read_prom_data(sc, WPI_EEPROM_TYPE, &sc->type,
1354 sizeof(sc->type)));
1356 sc->rev = le16toh(sc->rev);
1357 DPRINTF(sc, WPI_DEBUG_EEPROM, "cap=%x rev=%x type=%x\n", sc->cap,
1358 sc->rev, sc->type);
1361 WPI_CHK(wpi_read_prom_data(sc, WPI_EEPROM_DOMAIN, sc->domain,
1362 sizeof(sc->domain)));
1394 if ((channel->flags & WPI_EEPROM_CHAN_ACTIVE) == 0)
1396 if ((channel->flags & WPI_EEPROM_CHAN_IBSS) == 0)
1398 if (channel->flags & WPI_EEPROM_CHAN_RADAR) {
1415 struct wpi_eeprom_chan *channels = sc->eeprom_channels[n];
1430 for (i = 0; i < band->nchan; i++) {
1434 band->chan[i],n);
1438 chan = band->chan[i];
1446 sc->maxpwr[chan] = channels[i].maxpwr;
1450 chan, channels[i].flags, sc->maxpwr[chan], *nchans);
1461 struct ieee80211com *ic = &sc->sc_ic;
1467 error = wpi_read_prom_data(sc, band->addr, &sc->eeprom_channels[n],
1468 band->nchan * sizeof (struct wpi_eeprom_chan));
1474 wpi_read_eeprom_band(sc, n, IEEE80211_CHAN_MAX, &ic->ic_nchans,
1475 ic->ic_channels);
1477 ieee80211_sort_channels(ic->ic_channels, ic->ic_nchans);
1491 if (wpi_bands[j].chan[i] == c->ic_ieee &&
1493 return &sc->eeprom_channels[j][i];
1502 struct wpi_softc *sc = ic->ic_softc;
1517 struct wpi_softc *sc = ic->ic_softc;
1527 __func__, c->ic_ieee, c->ic_freq, c->ic_flags);
1530 c->ic_flags |= wpi_eeprom_channel_flags(channel);
1539 struct wpi_power_group *group = &sc->groups[n];
1552 group->chan = rgroup.chan;
1553 group->maxpwr = rgroup.maxpwr;
1555 group->temp = (int16_t)le16toh(rgroup.temp);
1558 "power group %d: chan=%d maxpwr=%d temp=%d\n", n, group->chan,
1559 group->maxpwr, group->temp);
1562 group->samples[i].index = rgroup.samples[i].index;
1563 group->samples[i].power = rgroup.samples[i].power;
1567 group->samples[i].index, group->samples[i].power);
1581 if ((sc->nodesmsk & (1 << newid)) == 0) {
1582 sc->nodesmsk |= 1 << newid;
1593 sc->nodesmsk |= 1 << WPI_ID_BSS;
1604 return (sc->nodesmsk >> id) & 1;
1610 sc->nodesmsk = 0;
1616 sc->nodesmsk &= ~(1 << id);
1630 wn->id = WPI_ID_UNDEFINED;
1632 return &wn->ni;
1638 struct wpi_softc *sc = ni->ni_ic->ic_softc;
1641 if (wn->id != WPI_ID_UNDEFINED) {
1643 if (wpi_check_node_entry(sc, wn->id)) {
1644 wpi_del_node_entry(sc, wn->id);
1650 sc->sc_node_free(ni);
1656 return (sc->rxon.filter & htole32(WPI_FILTER_BSS)) != 0;
1664 struct ieee80211vap *vap = ni->ni_vap;
1665 struct wpi_softc *sc = vap->iv_ic->ic_softc;
1669 wvp->wv_recv_mgmt(ni, m, subtype, rxs, rssi, nf);
1671 if (vap->iv_state == IEEE80211_S_RUN &&
1674 ni_tstamp = le64toh(ni->ni_tstamp.tsf);
1675 rx_tstamp = le64toh(sc->rx_tstamp);
1694 if (wn->id != WPI_ID_UNDEFINED) {
1695 wn->id = WPI_ID_UNDEFINED;
1697 device_printf(sc->sc_dev,
1708 struct ieee80211com *ic = &sc->sc_ic;
1712 wvp->wv_gtk = 0;
1715 ieee80211_iterate_nodes(&ic->ic_sta, wpi_restore_node, sc);
1726 struct ieee80211com *ic = vap->iv_ic;
1727 struct wpi_softc *sc = ic->ic_softc;
1733 if (nstate > IEEE80211_S_INIT && sc->sc_running == 0) {
1741 DPRINTF(sc, WPI_DEBUG_STATE, "%s: %s -> %s\n", __func__,
1742 ieee80211_state_name[vap->iv_state],
1745 if (vap->iv_state == IEEE80211_S_RUN && nstate < IEEE80211_S_RUN) {
1747 device_printf(sc->sc_dev,
1760 sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
1762 device_printf(sc->sc_dev,
1770 if (vap->iv_state != IEEE80211_S_RUN)
1775 * NB: do not optimize AUTH -> AUTH state transmission -
1776 * this will break powersave with non-QoS AP!
1781 * Also the associd must be cleared on RUN -> ASSOC
1785 device_printf(sc->sc_dev,
1793 * RUN -> RUN transition:
1797 if (vap->iv_state == IEEE80211_S_RUN) {
1798 if (vap->iv_opmode != IEEE80211_M_IBSS) {
1809 sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
1811 device_printf(sc->sc_dev,
1826 * !RUN -> RUN requires setting the association id
1831 device_printf(sc->sc_dev,
1846 return wvp->wv_newstate(vap, nstate, arg);
1859 callout_reset(&sc->calib_to, 60*hz, wpi_calib_timeout, sc);
1909 struct ieee80211com *ic = &sc->sc_ic;
1910 struct wpi_rx_ring *ring = &sc->rxq;
1924 if (__predict_false(stat->len > WPI_STAT_MAXLEN)) {
1925 device_printf(sc->sc_dev, "invalid RX statistic header\n");
1929 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);
1930 head = (struct wpi_rx_head *)((caddr_t)(stat + 1) + stat->len);
1931 len = le16toh(head->len);
1933 flags = le32toh(tail->flags);
1936 " rate %x chan %d tstamp %ju\n", __func__, ring->cur,
1937 le32toh(desc->len), len, (int8_t)stat->rssi,
1938 head->plcp, head->chan, (uintmax_t)le64toh(tail->tstamp));
1959 bus_dmamap_unload(ring->data_dmat, data->map);
1961 error = bus_dmamap_load(ring->data_dmat, data->map, mtod(m1, void *),
1964 device_printf(sc->sc_dev,
1969 error = bus_dmamap_load(ring->data_dmat, data->map,
1970 mtod(data->m, void *), MJUMPAGESIZE, wpi_dma_map_addr,
1976 ring->desc[ring->cur] = htole32(paddr);
1977 bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map,
1982 m = data->m;
1983 data->m = m1;
1985 ring->desc[ring->cur] = htole32(paddr);
1986 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
1990 m->m_data = (caddr_t)(head + 1);
1991 m->m_pkthdr.len = m->m_len = len;
1996 if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) &&
2004 m->m_flags |= M_WEP;
2012 sc->rx_tstamp = tail->tstamp;
2015 struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap;
2017 tap->wr_flags = 0;
2018 if (head->flags & htole16(WPI_STAT_FLAG_SHPREAMBLE))
2019 tap->wr_flags |= IEEE80211_RADIOTAP_F_SHORTPRE;
2020 tap->wr_dbm_antsignal = (int8_t)(stat->rssi + WPI_RSSI_OFFSET);
2021 tap->wr_dbm_antnoise = WPI_RSSI_OFFSET;
2022 tap->wr_tsft = tail->tstamp;
2023 tap->wr_antenna = (le16toh(head->flags) >> 4) & 0xf;
2024 tap->wr_rate = plcp2rate(head->plcp);
2031 (void)ieee80211_input(ni, m, stat->rssi, WPI_RSSI_OFFSET);
2035 (void)ieee80211_input_all(ic, m, stat->rssi, WPI_RSSI_OFFSET);
2043 fail1: counter_u64_add(ic->ic_ierrors, 1);
2056 struct ieee80211_ratectl_tx_status *txs = &sc->sc_txs;
2057 struct wpi_tx_ring *ring = &sc->txq[desc->qid & 0x3];
2058 struct wpi_tx_data *data = &ring->data[desc->idx];
2062 uint32_t status = le32toh(stat->status);
2064 KASSERT(data->ni != NULL, ("no node"));
2065 KASSERT(data->m != NULL, ("no mbuf"));
2071 "status %x\n", __func__, desc->qid, desc->idx, stat->ackfailcnt,
2072 stat->btkillcnt, stat->rate, le32toh(stat->duration), status);
2075 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTWRITE);
2076 bus_dmamap_unload(ring->data_dmat, data->map);
2077 m = data->m, data->m = NULL;
2078 ni = data->ni, data->ni = NULL;
2081 KASSERT(M_LEADINGSPACE(m) >= data->hdrlen, ("no frame header!"));
2082 M_PREPEND(m, data->hdrlen, M_NOWAIT);
2088 txs->pktlen = m->m_pkthdr.len;
2089 txs->short_retries = stat->rtsfailcnt;
2090 txs->long_retries = stat->ackfailcnt / WPI_NTRIES_DEFAULT;
2092 txs->status = IEEE80211_RATECTL_TX_SUCCESS;
2096 txs->status = IEEE80211_RATECTL_TX_FAIL_SHORT;
2099 txs->status = IEEE80211_RATECTL_TX_FAIL_LONG;
2102 txs->status = IEEE80211_RATECTL_TX_FAIL_EXPIRED;
2105 txs->status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED;
2114 if (--ring->queued > 0)
2115 callout_reset(&sc->tx_timeout, 5*hz, wpi_tx_timeout, sc);
2117 callout_stop(&sc->tx_timeout);
2130 struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM];
2135 "type %s len %d\n", desc->qid, desc->idx,
2136 desc->flags, wpi_cmd_str(desc->type),
2137 le32toh(desc->len));
2139 if ((desc->qid & WPI_RX_DESC_QID_MSK) != WPI_CMD_QUEUE_NUM)
2142 KASSERT(ring->queued == 0, ("ring->queued must be 0"));
2144 data = &ring->data[desc->idx];
2145 cmd = &ring->cmd[desc->idx];
2148 if (data->m != NULL) {
2149 bus_dmamap_sync(ring->data_dmat, data->map,
2151 bus_dmamap_unload(ring->data_dmat, data->map);
2152 m_freem(data->m);
2153 data->m = NULL;
2158 if (desc->type == WPI_CMD_SET_POWER_MODE) {
2159 struct wpi_pmgt_cmd *pcmd = (struct wpi_pmgt_cmd *)cmd->data;
2161 bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
2165 if (le16toh(pcmd->flags) & WPI_PS_ALLOW_SLEEP) {
2166 sc->sc_update_rx_ring = wpi_update_rx_ring_ps;
2167 sc->sc_update_tx_ring = wpi_update_tx_ring_ps;
2169 sc->sc_update_rx_ring = wpi_update_rx_ring;
2170 sc->sc_update_tx_ring = wpi_update_tx_ring;
2179 struct ieee80211com *ic = &sc->sc_ic;
2180 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2183 bus_dmamap_sync(sc->shared_dma.tag, sc->shared_dma.map,
2186 hw = le32toh(sc->shared->next) & 0xfff;
2187 hw = (hw == 0) ? WPI_RX_RING_COUNT - 1 : hw - 1;
2189 while (sc->rxq.cur != hw) {
2190 sc->rxq.cur = (sc->rxq.cur + 1) % WPI_RX_RING_COUNT;
2192 struct wpi_rx_data *data = &sc->rxq.data[sc->rxq.cur];
2195 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2197 desc = mtod(data->m, struct wpi_rx_desc *);
2201 __func__, sc->rxq.cur, desc->qid, desc->idx, desc->flags,
2202 desc->type, wpi_cmd_str(desc->type), le32toh(desc->len));
2204 if (!(desc->qid & WPI_UNSOLICITED_RX_NOTIF)) {
2209 switch (desc->type) {
2214 if (__predict_false(sc->sc_running == 0)) {
2237 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2240 misses = le32toh(miss->consecutive);
2241 expected = le32toh(miss->expected);
2242 received = le32toh(miss->received);
2243 threshold = MAX(2, vap->iv_bmissthreshold);
2247 __func__, misses, le32toh(miss->total), received,
2253 if (callout_pending(&sc->scan_timeout)) {
2258 if (vap->iv_state == IEEE80211_S_RUN &&
2259 (ic->ic_flags & IEEE80211_F_SCAN) == 0)
2273 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2279 stat->rtsfailcnt, stat->ackfailcnt,
2280 stat->btkillcnt, stat->rate, le32toh(stat->duration),
2281 le32toh(stat->status), le64toh(*tsf),
2293 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2297 "subtype=%x alive=%x\n", uc->major, uc->minor,
2298 uc->subtype, le32toh(uc->valid));
2300 if (le32toh(uc->valid) != 1) {
2301 device_printf(sc->sc_dev,
2307 sc->errptr = le32toh(uc->errptr);
2312 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2325 &sc->sc_radiooff_task);
2333 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2340 __func__, scan->chan, le32toh(scan->status));
2347 bus_dmamap_sync(sc->rxq.data_dmat, data->map,
2355 scan->nchan, scan->status, scan->chan);
2358 callout_stop(&sc->scan_timeout);
2360 if (scan->status == WPI_SCAN_ABORTED)
2368 if (sc->rxq.cur % 8 == 0) {
2370 sc->sc_update_rx_ring(sc);
2377 * from power-down sleep mode.
2385 "%s: ucode wakeup from power-down sleep\n", __func__);
2388 if (sc->rxq.update) {
2389 sc->rxq.update = 0;
2394 struct wpi_tx_ring *ring = &sc->txq[qid];
2396 if (ring->update) {
2397 ring->update = 0;
2440 DPRINTF(sc, WPI_DEBUG_REGISTER, " %-18s: 0x%08x ",
2450 DPRINTF(sc, WPI_DEBUG_REGISTER, " %-18s: 0x%08x ",
2478 if (sc->errptr < WPI_FW_DATA_BASE ||
2479 sc->errptr + sizeof (dump) >
2482 sc->errptr);
2490 count = wpi_mem_read(sc, sc->errptr);
2498 offset = sc->errptr + sizeof (uint32_t);
2523 struct wpi_tx_ring *ring = &sc->txq[i];
2524 printf(" tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n",
2525 i, ring->qid, ring->cur, ring->queued);
2528 printf(" rx ring: cur=%d\n", sc->rxq.cur);
2561 struct ieee80211com *ic = &sc->sc_ic;
2563 device_printf(sc->sc_dev, "fatal firmware error\n");
2586 /* Re-enable interrupts. */
2587 if (__predict_true(sc->sc_running))
2601 ring = &sc->txq[ac];
2603 while (ring->pending != 0) {
2604 ring->pending--;
2605 cur = (ring->cur + ring->pending) % WPI_TX_RING_COUNT;
2606 data = &ring->data[cur];
2608 bus_dmamap_sync(ring->data_dmat, data->map,
2610 bus_dmamap_unload(ring->data_dmat, data->map);
2611 m_freem(data->m);
2612 data->m = NULL;
2614 ieee80211_node_decref(data->ni);
2615 data->ni = NULL;
2637 KASSERT(buf->size <= sizeof(buf->data), ("buffer overflow"));
2641 if (__predict_false(sc->sc_running == 0)) {
2647 wh = mtod(buf->m, struct ieee80211_frame *);
2649 totlen = buf->m->m_pkthdr.len;
2650 frag = ((buf->m->m_flags & (M_FRAG | M_LASTFRAG)) == M_FRAG);
2659 pad = 4 - (hdrlen & 3);
2663 ring = &sc->txq[buf->ac];
2664 cur = (ring->cur + ring->pending) % WPI_TX_RING_COUNT;
2665 desc = &ring->desc[cur];
2666 data = &ring->data[cur];
2669 cmd = &ring->cmd[cur];
2670 cmd->code = buf->code;
2671 cmd->flags = 0;
2672 cmd->qid = ring->qid;
2673 cmd->idx = cur;
2675 memcpy(cmd->data, buf->data, buf->size);
2678 memcpy((uint8_t *)(cmd->data + buf->size), wh, hdrlen);
2679 m_adj(buf->m, hdrlen);
2681 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, buf->m,
2684 device_printf(sc->sc_dev,
2690 m1 = m_collapse(buf->m, M_NOWAIT, WPI_MAX_SCATTER - 1);
2692 device_printf(sc->sc_dev,
2697 buf->m = m1;
2699 error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map,
2700 buf->m, segs, &nsegs, BUS_DMA_NOWAIT);
2707 device_printf(sc->sc_dev,
2710 if (ring->qid < WPI_CMD_QUEUE_NUM) {
2711 if_inc_counter(buf->ni->ni_vap->iv_ifp,
2714 ieee80211_free_node(buf->ni);
2716 m_freem(buf->m);
2726 data->m = buf->m;
2727 data->ni = buf->ni;
2728 data->hdrlen = hdrlen;
2731 __func__, ring->qid, cur, totlen, nsegs);
2734 desc->nsegs = WPI_PAD32(totlen + pad) << 4 | (1 + nsegs);
2736 desc->segs[0].addr = htole32(data->cmd_paddr);
2737 desc->segs[0].len = htole32(4 + buf->size + hdrlen + pad);
2741 desc->segs[i].addr = htole32(seg->ds_addr);
2742 desc->segs[i].len = htole32(seg->ds_len);
2746 bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
2747 bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
2749 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
2752 ring->pending += 1;
2755 if (ring->qid < WPI_CMD_QUEUE_NUM) {
2757 ring->queued += ring->pending;
2758 callout_reset(&sc->tx_timeout, 5*hz, wpi_tx_timeout,
2764 ring->cur = (ring->cur + ring->pending) % WPI_TX_RING_COUNT;
2765 ring->pending = 0;
2766 sc->sc_update_tx_ring(sc, ring);
2768 (void) ieee80211_ref_node(data->ni);
2784 const struct ieee80211_txparam *tp = ni->ni_txparms;
2785 struct ieee80211vap *vap = ni->ni_vap;
2786 struct ieee80211com *ic = ni->ni_ic;
2798 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
2799 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
2804 qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
2815 (m->m_flags & M_EAPOL) != 0)
2816 rate = tp->mgmtrate;
2818 rate = tp->mcastrate;
2819 else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE)
2820 rate = tp->ucastrate;
2824 rate = ni->ni_txrate;
2828 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
2834 swcrypt = k->wk_flags & IEEE80211_KEY_SWCRYPT;
2839 totlen = m->m_pkthdr.len;
2842 struct wpi_tx_radiotap_header *tap = &sc->sc_txtap;
2844 tap->wt_flags = 0;
2845 tap->wt_rate = rate;
2847 tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
2848 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG)
2849 tap->wt_flags |= IEEE80211_RADIOTAP_F_FRAG;
2864 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG)
2867 /* Check if frame must be protected using RTS/CTS or CTS-to-self. */
2870 if (totlen + IEEE80211_CRC_LEN > vap->iv_rtsthreshold) {
2872 } else if ((ic->ic_flags & IEEE80211_F_USEPROT) &&
2874 if (ic->ic_protmode == IEEE80211_PROT_CTSONLY)
2876 else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS)
2886 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
2893 tx->timeout = htole16(3);
2895 tx->timeout = htole16(2);
2899 tx->id = WPI_ID_BROADCAST;
2901 if (wn->id == WPI_ID_UNDEFINED) {
2902 device_printf(sc->sc_dev,
2907 tx->id = wn->id;
2911 switch (k->wk_cipher->ic_cipher) {
2913 tx->security = WPI_CIPHER_CCMP;
2920 memcpy(tx->key, k->wk_key, k->wk_keylen);
2923 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) {
2924 struct mbuf *next = m->m_nextpkt;
2926 tx->lnext = htole16(next->m_pkthdr.len);
2927 tx->fnext = htole32(tx->security |
2929 WPI_NEXT_STA_ID(tx->id));
2932 tx->len = htole16(totlen);
2933 tx->flags = htole32(flags);
2934 tx->plcp = rate2plcp(rate);
2935 tx->tid = tid;
2936 tx->lifetime = htole32(WPI_LIFETIME_INFINITE);
2937 tx->ofdm_mask = 0xff;
2938 tx->cck_mask = 0x0f;
2939 tx->rts_ntries = 7;
2940 tx->data_ntries = tp->maxretry;
2955 struct ieee80211vap *vap = ni->ni_vap;
2965 type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
2968 ac = params->ibp_pri & 3;
2971 rate = params->ibp_rate0;
2976 if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
2978 if (params->ibp_flags & IEEE80211_BPF_RTS)
2980 if (params->ibp_flags & IEEE80211_BPF_CTS)
2986 if (params->ibp_flags & IEEE80211_BPF_CRYPTO) {
2992 swcrypt = k->wk_flags & IEEE80211_KEY_SWCRYPT;
2997 totlen = m->m_pkthdr.len;
3000 struct wpi_tx_radiotap_header *tap = &sc->sc_txtap;
3002 tap->wt_flags = 0;
3003 tap->wt_rate = rate;
3004 if (params->ibp_flags & IEEE80211_BPF_CRYPTO)
3005 tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
3012 uint8_t subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
3019 tx->timeout = htole16(3);
3021 tx->timeout = htole16(2);
3025 switch (k->wk_cipher->ic_cipher) {
3027 tx->security = WPI_CIPHER_CCMP;
3034 memcpy(tx->key, k->wk_key, k->wk_keylen);
3037 tx->len = htole16(totlen);
3038 tx->flags = htole32(flags);
3039 tx->plcp = rate2plcp(rate);
3040 tx->id = WPI_ID_BROADCAST;
3041 tx->lifetime = htole32(WPI_LIFETIME_INFINITE);
3042 tx->rts_ntries = params->ibp_try1;
3043 tx->data_ntries = params->ibp_try0;
3057 struct wpi_tx_ring *ring = &sc->txq[ac];
3061 retval = WPI_TX_RING_HIMARK - ring->queued;
3071 struct ieee80211com *ic = ni->ni_ic;
3072 struct wpi_softc *sc = ic->ic_softc;
3083 if (sc->sc_running == 0 || wpi_tx_ring_free_space(sc, ac) < 1) {
3084 error = sc->sc_running ? ENOBUFS : ENETDOWN;
3119 struct wpi_softc *sc = ic->ic_softc;
3129 if (__predict_false(sc->sc_running == 0)) {
3135 for (mnext = m->m_nextpkt; mnext != NULL; mnext = mnext->m_nextpkt)
3146 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
3148 mnext = m->m_nextpkt;
3150 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS,
3170 struct ieee80211com *ic = &sc->sc_ic;
3172 DPRINTF(sc, WPI_DEBUG_WATCHDOG, "RFkill Watchdog: tick\n");
3177 callout_reset(&sc->watchdog_rfkill, hz, wpi_watchdog_rfkill,
3180 ieee80211_runtask(ic, &sc->sc_radioon_task);
3187 struct ieee80211com *ic = &sc->sc_ic;
3197 struct ieee80211com *ic = &sc->sc_ic;
3206 struct wpi_softc *sc = ic->ic_softc;
3207 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3209 if (ic->ic_nrunning > 0) {
3230 struct wpi_tx_ring *ring = &sc->txq[WPI_CMD_QUEUE_NUM];
3243 if (__predict_false(sc->sc_running == 0)) {
3259 desc = &ring->desc[ring->cur];
3260 data = &ring->data[ring->cur];
3263 if (size > sizeof cmd->data) {
3275 error = bus_dmamap_load(ring->data_dmat, data->map, cmd,
3281 data->m = m;
3283 cmd = &ring->cmd[ring->cur];
3284 paddr = data->cmd_paddr;
3287 cmd->code = code;
3288 cmd->flags = 0;
3289 cmd->qid = ring->qid;
3290 cmd->idx = ring->cur;
3291 memcpy(cmd->data, buf, size);
3293 desc->nsegs = 1 + (WPI_PAD32(size) << 4);
3294 desc->segs[0].addr = htole32(paddr);
3295 desc->segs[0].len = htole32(totlen);
3297 if (size > sizeof cmd->data) {
3298 bus_dmamap_sync(ring->data_dmat, data->map,
3301 bus_dmamap_sync(ring->data_dmat, ring->cmd_dma.map,
3304 bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map,
3308 ring->cur = (ring->cur + 1) % WPI_TX_RING_COUNT;
3309 sc->sc_update_tx_ring(sc, ring);
3315 return async ? 0 : mtx_sleep(cmd, &sc->sc_mtx, PCATCH, "wpicmd", hz);
3325 * Configure HW multi-rate retries.
3330 struct ieee80211com *ic = &sc->sc_ic;
3341 (i == WPI_RIDX_CCK1) ? WPI_RIDX_CCK1 : i - 1;
3352 ((ic->ic_curmode == IEEE80211_MODE_11A) ?
3354 i - 1;
3362 device_printf(sc->sc_dev,
3370 device_printf(sc->sc_dev,
3380 struct ieee80211com *ic = ni->ni_ic;
3381 struct wpi_vap *wvp = WPI_VAP(ni->ni_vap);
3388 if (wn->id == WPI_ID_UNDEFINED)
3392 IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr);
3393 node.id = wn->id;
3394 node.plcp = (ic->ic_curmode == IEEE80211_MODE_11A) ?
3400 wn->id, ether_sprintf(ni->ni_macaddr));
3404 device_printf(sc->sc_dev,
3410 if (wvp->wv_gtk != 0) {
3413 device_printf(sc->sc_dev,
3423 * Broadcast node is used to send group-addressed and management frames.
3428 struct ieee80211com *ic = &sc->sc_ic;
3436 node.plcp = (ic->ic_curmode == IEEE80211_MODE_11A) ?
3454 wn->id = wpi_add_node_entry_sta(sc);
3457 wpi_del_node_entry(sc, wn->id);
3458 wn->id = WPI_ID_UNDEFINED;
3471 KASSERT(wn->id == WPI_ID_UNDEFINED,
3472 ("the node %d was added before", wn->id));
3476 if ((wn->id = wpi_add_node_entry_adhoc(sc)) == WPI_ID_UNDEFINED) {
3477 device_printf(sc->sc_dev, "%s: h/w table is full\n", __func__);
3482 wpi_del_node_entry(sc, wn->id);
3483 wn->id = WPI_ID_UNDEFINED;
3497 KASSERT(wn->id != WPI_ID_UNDEFINED, ("undefined node id passed"));
3502 IEEE80211_ADDR_COPY(node.macaddr, ni->ni_macaddr);
3506 wn->id, ether_sprintf(ni->ni_macaddr));
3510 device_printf(sc->sc_dev,
3512 wn->id, error);
3519 #define WPI_EXP2(x) ((1 << (x)) - 1) /* CWmin = 2^ECWmin - 1 */
3520 struct wpi_softc *sc = ic->ic_softc;
3533 cmd.ac[aci].aifsn = ac->wmep_aifsn;
3534 cmd.ac[aci].cwmin = htole16(WPI_EXP2(ac->wmep_logcwmin));
3535 cmd.ac[aci].cwmax = htole16(WPI_EXP2(ac->wmep_logcwmax));
3537 htole16(IEEE80211_TXOP_TO_US(ac->wmep_txopLimit));
3556 struct ieee80211com *ic = &sc->sc_ic;
3557 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3561 if (vap != NULL && vap->iv_opmode != IEEE80211_M_HOSTAP)
3564 if (ic->ic_promisc > 0)
3565 sc->rxon.filter |= htole32(promisc_filter);
3567 sc->rxon.filter &= ~htole32(promisc_filter);
3573 struct wpi_softc *sc = ic->ic_softc;
3576 if (sc->sc_running == 0) {
3586 device_printf(sc->sc_dev, "%s: could not send RXON\n",
3621 memcpy(&cmd.tstamp, ni->ni_tstamp.data, sizeof (uint64_t));
3622 cmd.bintval = htole16(ni->ni_intval);
3626 val = (uint64_t)ni->ni_intval * IEEE80211_DUR_TU;
3628 cmd.binitval = htole32((uint32_t)(val - mod));
3631 ni->ni_intval, le64toh(cmd.tstamp), (uint32_t)(val - mod));
3651 /* Sanity-check read value. */
3652 if (temp < -260 || temp > 25) {
3655 "out-of-range temperature reported: %d\n", temp);
3659 DPRINTF(sc, WPI_DEBUG_TEMP, "temperature %d->%d\n", sc->temp, temp);
3662 if (abs(temp - sc->temp) <= 6)
3665 sc->temp = temp;
3669 device_printf(sc->sc_dev,"could not adjust Tx power\n");
3685 chan = sc->rxon.chan;
3686 is_chan_5ghz = (sc->rxon.flags & htole32(WPI_RXON_24GHZ)) == 0;
3690 for (group = &sc->groups[1]; group < &sc->groups[4]; group++)
3691 if (chan <= group->chan)
3694 group = &sc->groups[0];
3730 /* Fixed-point arithmetic division using a n-bit fractional part. */
3736 ((y1) + fdivround(((x) - (x1)) * ((y2) - (y1)), (x2) - (x1), n))
3742 pwr = group->maxpwr / 2;
3747 pwr -= is_chan_5ghz ? 5 : 0;
3750 pwr -= is_chan_5ghz ? 10 : 7;
3753 pwr -= is_chan_5ghz ? 12 : 9;
3758 pwr = min(pwr, sc->maxpwr[chan]);
3761 for (sample = group->samples; sample < &group->samples[3]; sample++)
3764 /* Fixed-point linear interpolation using a 19-bit fractional part. */
3768 /*-
3770 * - if cooler than factory-calibrated: decrease output power
3771 * - if warmer than factory-calibrated: increase output power
3773 idx -= (sc->temp - group->temp) * 11 / 100;
3775 /* Decrease TX power for CCK rates (-5dB). */
3816 /* Retrieve PCIe Active State Power Management (ASPM). */
3817 reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, 1);
3821 cmd.rxtimeout = htole32(pmgt->rxtimeout * IEEE80211_DUR_TU);
3822 cmd.txtimeout = htole32(pmgt->txtimeout * IEEE80211_DUR_TU);
3828 skip_dtim = pmgt->skip_dtim;
3832 max = pmgt->intval[4];
3833 if (max == (uint32_t)-1)
3841 cmd.intval[i] = htole32(MIN(max, pmgt->intval[i]));
3871 rxon_assoc.flags = sc->rxon.flags;
3872 rxon_assoc.filter = sc->rxon.filter;
3873 rxon_assoc.ofdm_mask = sc->rxon.ofdm_mask;
3874 rxon_assoc.cck_mask = sc->rxon.cck_mask;
3880 device_printf(sc->sc_dev,
3887 error = wpi_cmd(sc, WPI_CMD_RXON, &sc->rxon,
3893 error = wpi_cmd(sc, WPI_CMD_RXON, &sc->rxon,
3900 device_printf(sc->sc_dev,
3908 device_printf(sc->sc_dev,
3916 device_printf(sc->sc_dev,
3931 struct ieee80211com *ic = &sc->sc_ic;
3932 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3933 struct ieee80211_channel *c = ic->ic_curchan;
3940 device_printf(sc->sc_dev,
3947 device_printf(sc->sc_dev,
3953 memset(&sc->rxon, 0, sizeof (struct wpi_rxon));
3954 IEEE80211_ADDR_COPY(sc->rxon.myaddr, vap->iv_myaddr);
3957 sc->rxon.chan = ieee80211_chan2ieee(ic, c);
3958 sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
3960 sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
3962 sc->rxon.filter = WPI_FILTER_MULTICAST;
3963 switch (ic->ic_opmode) {
3965 sc->rxon.mode = WPI_MODE_STA;
3968 sc->rxon.mode = WPI_MODE_IBSS;
3969 sc->rxon.filter |= WPI_FILTER_BEACON;
3973 sc->rxon.mode = WPI_MODE_IBSS;
3974 sc->rxon.filter |= WPI_FILTER_ASSOC | WPI_FILTER_PROMISC;
3977 sc->rxon.mode = WPI_MODE_HOSTAP;
3980 sc->rxon.mode = WPI_MODE_MONITOR;
3983 device_printf(sc->sc_dev, "unknown opmode %d\n",
3984 ic->ic_opmode);
3987 sc->rxon.filter = htole32(sc->rxon.filter);
3989 sc->rxon.cck_mask = 0x0f; /* not yet negotiated */
3990 sc->rxon.ofdm_mask = 0xff; /* not yet negotiated */
3993 device_printf(sc->sc_dev, "%s: could not send RXON\n",
4000 device_printf(sc->sc_dev, "could not setup MRR, error %d\n",
4033 struct ieee80211com *ic = &sc->sc_ic;
4034 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
4039 bintval = vap->iv_bss->ni_intval;
4042 * If it's non-zero, we should calculate the minimum of
4051 return (MIN(dwell_time, bintval - WPI_CHANNEL_TUNE_TIME * 2));
4090 struct ieee80211com *ic = &sc->sc_ic;
4091 struct ieee80211_scan_state *ss = ic->ic_scan;
4092 struct ieee80211vap *vap = ss->ss_vap;
4109 if (callout_pending(&sc->scan_timeout)) {
4110 device_printf(sc->sc_dev, "%s: called whilst scanning!\n",
4117 bintval = vap->iv_bss->ni_intval;
4126 device_printf(sc->sc_dev,
4138 hdr->quiet_time = htole16(WPI_QUIET_TIME_DEFAULT);
4139 hdr->quiet_threshold = htole16(1);
4146 hdr->max_svc = htole32(250 * IEEE80211_DUR_TU);
4147 hdr->pause_svc = htole32(wpi_get_scan_pause_time(100,
4151 hdr->filter = htole32(WPI_FILTER_MULTICAST | WPI_FILTER_BEACON);
4154 tx->flags = htole32(WPI_TX_AUTO_SEQ);
4155 tx->id = WPI_ID_BROADCAST;
4156 tx->lifetime = htole32(WPI_LIFETIME_INFINITE);
4160 tx->plcp = wpi_ridx_to_plcp[WPI_RIDX_OFDM6];
4161 rs = &ic->ic_sup_rates[IEEE80211_MODE_11A];
4163 hdr->flags = htole32(WPI_RXON_24GHZ | WPI_RXON_AUTO);
4165 tx->plcp = wpi_ridx_to_plcp[WPI_RIDX_CCK1];
4166 rs = &ic->ic_sup_rates[IEEE80211_MODE_11G];
4170 nssid = MIN(ss->ss_nssid, WPI_SCAN_MAX_ESSIDS);
4173 essids[i].len = MIN(ss->ss_ssid[i].len, IEEE80211_NWID_LEN);
4174 memcpy(essids[i].data, ss->ss_ssid[i].ssid, essids[i].len);
4176 if (sc->sc_debug & WPI_DEBUG_SCAN) {
4189 wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT |
4191 wh->i_fc[1] = IEEE80211_FC1_DIR_NODS;
4192 IEEE80211_ADDR_COPY(wh->i_addr1, ieee80211broadcastaddr);
4193 IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr);
4194 IEEE80211_ADDR_COPY(wh->i_addr3, ieee80211broadcastaddr);
4199 if (rs->rs_nrates > IEEE80211_RATE_SIZE)
4203 tx->len = htole16(frm - (uint8_t *)wh);
4211 chan->chan = ieee80211_chan2ieee(ic, c);
4212 chan->flags = 0;
4214 hdr->crc_threshold = WPI_SCAN_CRC_TH_DEFAULT;
4215 chan->flags |= WPI_CHAN_NPBREQS(nssid);
4217 hdr->crc_threshold = WPI_SCAN_CRC_TH_NEVER;
4220 chan->flags |= WPI_CHAN_ACTIVE;
4232 chan->active = htole16(dwell_active);
4233 chan->passive = htole16(dwell_passive);
4235 chan->dsp_gain = 0x6e; /* Default level */
4238 chan->rf_gain = 0x3b;
4240 chan->rf_gain = 0x28;
4243 chan->chan, IEEE80211_IS_CHAN_PASSIVE(c));
4245 hdr->nchan++;
4247 if (hdr->nchan == 1 && sc->rxon.chan == chan->chan) {
4254 chan->flags = 0;
4255 chan->passive = chan->active = hdr->quiet_time;
4257 hdr->nchan++;
4262 buflen = (uint8_t *)chan - buf;
4263 hdr->len = htole16(buflen);
4266 hdr->nchan);
4273 callout_reset(&sc->scan_timeout, 5*hz, wpi_scan_timeout, sc);
4287 struct ieee80211com *ic = vap->iv_ic;
4288 struct ieee80211_node *ni = vap->iv_bss;
4289 struct ieee80211_channel *c = ni->ni_chan;
4297 sc->rxon.associd = 0;
4298 sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
4299 IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
4300 sc->rxon.chan = ieee80211_chan2ieee(ic, c);
4301 sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
4303 sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
4304 if (ic->ic_flags & IEEE80211_F_SHSLOT)
4305 sc->rxon.flags |= htole32(WPI_RXON_SHSLOT);
4306 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
4307 sc->rxon.flags |= htole32(WPI_RXON_SHPREAMBLE);
4309 sc->rxon.cck_mask = 0;
4310 sc->rxon.ofdm_mask = 0x15;
4312 sc->rxon.cck_mask = 0x03;
4313 sc->rxon.ofdm_mask = 0;
4316 sc->rxon.cck_mask = 0x0f;
4317 sc->rxon.ofdm_mask = 0x15;
4321 sc->rxon.chan, sc->rxon.flags, sc->rxon.cck_mask,
4322 sc->rxon.ofdm_mask);
4325 device_printf(sc->sc_dev, "%s: could not send RXON\n",
4339 struct ieee80211vap *vap = &wvp->wv_vap;
4340 struct ieee80211com *ic = vap->iv_ic;
4341 struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
4342 struct wpi_buf *bcn = &wvp->wv_bcbuf;
4343 struct wpi_softc *sc = ic->ic_softc;
4344 struct wpi_cmd_beacon *cmd = (struct wpi_cmd_beacon *)&bcn->data;
4354 cmd->len = htole16(bcn->m->m_pkthdr.len);
4355 cmd->plcp = (ic->ic_curmode == IEEE80211_MODE_11A) ?
4359 if (*(bo->bo_tim) == IEEE80211_ELEMID_TIM) {
4360 tie = (struct ieee80211_tim_ie *) bo->bo_tim;
4361 ptr = mtod(bcn->m, uint8_t *);
4363 cmd->tim = htole16(bo->bo_tim - ptr);
4364 cmd->timsz = tie->tim_len;
4368 m = bcn->m;
4369 bcn->m = m_dup(m, M_NOWAIT);
4370 if (bcn->m == NULL) {
4371 device_printf(sc->sc_dev,
4378 device_printf(sc->sc_dev,
4381 m_freem(bcn->m);
4385 end: bcn->m = m;
4393 struct ieee80211vap *vap = ni->ni_vap;
4395 struct wpi_buf *bcn = &wvp->wv_bcbuf;
4401 if (ni->ni_chan == IEEE80211_CHAN_ANYC)
4406 device_printf(sc->sc_dev,
4412 if (bcn->m != NULL)
4413 m_freem(bcn->m);
4415 bcn->m = m;
4426 struct wpi_softc *sc = vap->iv_ic->ic_softc;
4428 struct wpi_buf *bcn = &wvp->wv_bcbuf;
4429 struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
4430 struct ieee80211_node *ni = vap->iv_bss;
4436 if (bcn->m == NULL) {
4437 bcn->m = ieee80211_beacon_alloc(ni);
4438 if (bcn->m == NULL) {
4439 device_printf(sc->sc_dev,
4454 setbit(bo->bo_flags, item);
4455 ieee80211_beacon_update(ni, bcn->m, mcast);
4467 struct ieee80211vap *vap = ni->ni_vap;
4468 struct wpi_softc *sc = ni->ni_ic->ic_softc;
4476 if (vap->iv_opmode != IEEE80211_M_STA && wn->id == WPI_ID_UNDEFINED) {
4478 device_printf(sc->sc_dev,
4489 struct ieee80211com *ic = vap->iv_ic;
4490 struct ieee80211_node *ni = vap->iv_bss;
4491 struct ieee80211_channel *c = ni->ni_chan;
4496 if (vap->iv_opmode == IEEE80211_M_MONITOR) {
4504 device_printf(sc->sc_dev, "%s: incomplete configuration\n",
4510 device_printf(sc->sc_dev,
4517 IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
4518 sc->rxon.associd = htole16(IEEE80211_NODE_AID(ni));
4519 sc->rxon.chan = ieee80211_chan2ieee(ic, c);
4520 sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
4522 sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
4523 if (ic->ic_flags & IEEE80211_F_SHSLOT)
4524 sc->rxon.flags |= htole32(WPI_RXON_SHSLOT);
4525 if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
4526 sc->rxon.flags |= htole32(WPI_RXON_SHPREAMBLE);
4528 sc->rxon.cck_mask = 0;
4529 sc->rxon.ofdm_mask = 0x15;
4531 sc->rxon.cck_mask = 0x03;
4532 sc->rxon.ofdm_mask = 0;
4535 sc->rxon.cck_mask = 0x0f;
4536 sc->rxon.ofdm_mask = 0x15;
4538 sc->rxon.filter |= htole32(WPI_FILTER_BSS);
4541 sc->rxon.chan, sc->rxon.flags);
4545 device_printf(sc->sc_dev, "%s: could not send RXON\n",
4551 callout_reset(&sc->calib_to, 60*hz, wpi_calib_timeout, sc);
4555 if (vap->iv_opmode == IEEE80211_M_IBSS ||
4556 vap->iv_opmode == IEEE80211_M_HOSTAP) {
4558 device_printf(sc->sc_dev,
4565 if (vap->iv_opmode == IEEE80211_M_STA) {
4571 device_printf(sc->sc_dev,
4581 /* Enable power-saving mode if requested by user. */
4582 if ((vap->iv_flags & IEEE80211_F_PMGTON) &&
4583 vap->iv_opmode != IEEE80211_M_IBSS)
4594 const struct ieee80211_cipher *cip = k->wk_cipher;
4595 struct ieee80211vap *vap = ni->ni_vap;
4596 struct wpi_softc *sc = ni->ni_ic->ic_softc;
4604 if (wpi_check_node_entry(sc, wn->id) == 0) {
4605 device_printf(sc->sc_dev, "%s: node does not exist\n",
4610 switch (cip->ic_cipher) {
4616 device_printf(sc->sc_dev, "%s: unknown cipher %d\n", __func__,
4617 cip->ic_cipher);
4621 kflags |= WPI_KFLAG_KID(k->wk_keyix);
4622 if (k->wk_flags & IEEE80211_KEY_GROUP)
4626 node.id = wn->id;
4630 memcpy(node.key, k->wk_key, k->wk_keylen);
4634 (kflags & WPI_KFLAG_MULTICAST) ? "group" : "ucast", k->wk_keyix,
4635 node.id, ether_sprintf(ni->ni_macaddr));
4639 device_printf(sc->sc_dev, "can't update node info, error %d\n",
4659 struct ieee80211vap *vap = ni->ni_vap;
4660 struct wpi_softc *sc = ni->ni_ic->ic_softc;
4664 if (vap->iv_bss == ni && wn->id == WPI_ID_UNDEFINED)
4672 device_printf(sc->sc_dev, "%s: error while setting key\n",
4680 struct ieee80211vap *vap = ni->ni_vap;
4681 struct ieee80211_key *wk = &vap->iv_nw_keys[0];
4684 for (; wk < &vap->iv_nw_keys[IEEE80211_WEP_NKID] && error; wk++)
4685 if (wk->wk_keyix != IEEE80211_KEYIX_NONE)
4694 struct ieee80211vap *vap = ni->ni_vap;
4695 struct wpi_softc *sc = ni->ni_ic->ic_softc;
4703 if (wpi_check_node_entry(sc, wn->id) == 0) {
4708 kflags = WPI_KFLAG_KID(k->wk_keyix);
4709 if (k->wk_flags & IEEE80211_KEY_GROUP)
4713 node.id = wn->id;
4720 k->wk_keyix, node.id, ether_sprintf(ni->ni_macaddr));
4724 device_printf(sc->sc_dev, "can't update node info, error %d\n",
4744 struct ieee80211vap *vap = ni->ni_vap;
4745 struct wpi_softc *sc = ni->ni_ic->ic_softc;
4749 if (vap->iv_bss == ni && wn->id == WPI_ID_UNDEFINED)
4757 device_printf(sc->sc_dev, "%s: error while deleting key\n",
4766 struct ieee80211com *ic = vap->iv_ic;
4767 struct wpi_softc *sc = ic->ic_softc;
4774 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) {
4779 if (!(k->wk_flags & IEEE80211_KEY_RECV)) {
4788 wvp->wv_gtk |= WPI_VAP_KEY(k->wk_keyix);
4790 wvp->wv_gtk &= ~WPI_VAP_KEY(k->wk_keyix);
4793 if (vap->iv_state == IEEE80211_S_RUN) {
4794 ieee80211_iterate_nodes(&ic->ic_sta,
4802 switch (vap->iv_opmode) {
4804 ni = vap->iv_bss;
4810 ni = ieee80211_find_vap_node(&ic->ic_sta, vap, k->wk_macaddr);
4818 device_printf(sc->sc_dev, "%s: unknown opmode %d\n", __func__,
4819 vap->iv_opmode);
4865 device_printf(sc->sc_dev,
4868 return EPERM; /* :-) */
4874 if ((sc->temp = (int)WPI_READ(sc, WPI_UCODE_GP2)) != 0)
4880 device_printf(sc->sc_dev,
4885 DPRINTF(sc, WPI_DEBUG_TEMP, "temperature %d\n", sc->temp);
4925 "Status Match! - ntries = %d\n", ntries);
4931 device_printf(sc->sc_dev, "%s: could not load boot firmware\n",
4947 struct wpi_fw_info *fw = &sc->fw;
4948 struct wpi_dma_info *dma = &sc->fw_dma;
4953 /* Copy initialization sections into pre-allocated DMA-safe memory. */
4954 memcpy(dma->vaddr, fw->init.data, fw->init.datasz);
4955 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
4956 memcpy(dma->vaddr + WPI_FW_DATA_MAXSZ, fw->init.text, fw->init.textsz);
4957 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
4962 wpi_prph_write(sc, WPI_BSM_DRAM_DATA_ADDR, dma->paddr);
4963 wpi_prph_write(sc, WPI_BSM_DRAM_DATA_SIZE, fw->init.datasz);
4965 dma->paddr + WPI_FW_DATA_MAXSZ);
4966 wpi_prph_write(sc, WPI_BSM_DRAM_TEXT_SIZE, fw->init.textsz);
4970 error = wpi_load_bootcode(sc, fw->boot.text, fw->boot.textsz);
4972 device_printf(sc->sc_dev, "%s: could not load boot firmware\n",
4981 if ((error = mtx_sleep(sc, &sc->sc_mtx, PCATCH, "wpiinit", hz)) != 0) {
4982 device_printf(sc->sc_dev,
4988 /* Copy runtime sections into pre-allocated DMA-safe memory. */
4989 memcpy(dma->vaddr, fw->main.data, fw->main.datasz);
4990 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
4991 memcpy(dma->vaddr + WPI_FW_DATA_MAXSZ, fw->main.text, fw->main.textsz);
4992 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_PREWRITE);
4997 wpi_prph_write(sc, WPI_BSM_DRAM_DATA_ADDR, dma->paddr);
4998 wpi_prph_write(sc, WPI_BSM_DRAM_DATA_SIZE, fw->main.datasz);
5000 dma->paddr + WPI_FW_DATA_MAXSZ);
5002 WPI_FW_UPDATED | fw->main.textsz);
5012 struct wpi_fw_info *fw = &sc->fw;
5026 device_printf(sc->sc_dev,
5031 sc->fw_fp = fp;
5033 if (fp->datasize < sizeof (struct wpi_firmware_hdr)) {
5034 device_printf(sc->sc_dev,
5035 "firmware file too short: %zu bytes\n", fp->datasize);
5040 fw->size = fp->datasize;
5041 fw->data = (const uint8_t *)fp->data;
5044 hdr = (const struct wpi_firmware_hdr *)fw->data;
5047 |HDR|<--TEXT-->|<--DATA-->|<--TEXT-->|<--DATA-->|<--TEXT-->| */
5049 fw->main.textsz = le32toh(hdr->rtextsz);
5050 fw->main.datasz = le32toh(hdr->rdatasz);
5051 fw->init.textsz = le32toh(hdr->itextsz);
5052 fw->init.datasz = le32toh(hdr->idatasz);
5053 fw->boot.textsz = le32toh(hdr->btextsz);
5054 fw->boot.datasz = 0;
5056 /* Sanity-check firmware header. */
5057 if (fw->main.textsz > WPI_FW_TEXT_MAXSZ ||
5058 fw->main.datasz > WPI_FW_DATA_MAXSZ ||
5059 fw->init.textsz > WPI_FW_TEXT_MAXSZ ||
5060 fw->init.datasz > WPI_FW_DATA_MAXSZ ||
5061 fw->boot.textsz > WPI_FW_BOOT_TEXT_MAXSZ ||
5062 (fw->boot.textsz & 3) != 0) {
5063 device_printf(sc->sc_dev, "invalid firmware header\n");
5069 if (fw->size < sizeof (*hdr) + fw->main.textsz + fw->main.datasz +
5070 fw->init.textsz + fw->init.datasz + fw->boot.textsz) {
5071 device_printf(sc->sc_dev,
5072 "firmware file too short: %zu bytes\n", fw->size);
5078 fw->main.text = (const uint8_t *)(hdr + 1);
5079 fw->main.data = fw->main.text + fw->main.textsz;
5080 fw->init.text = fw->main.data + fw->main.datasz;
5081 fw->init.data = fw->init.text + fw->init.textsz;
5082 fw->boot.text = fw->init.data + fw->init.datasz;
5087 "boot (text %u)\n", hdr->major, hdr->minor, le32toh(hdr->driver),
5088 fw->main.textsz, fw->main.datasz,
5089 fw->init.textsz, fw->init.datasz, fw->boot.textsz);
5091 DPRINTF(sc, WPI_DEBUG_FIRMWARE, "fw->main.text %p\n", fw->main.text);
5092 DPRINTF(sc, WPI_DEBUG_FIRMWARE, "fw->main.data %p\n", fw->main.data);
5093 DPRINTF(sc, WPI_DEBUG_FIRMWARE, "fw->init.text %p\n", fw->init.text);
5094 DPRINTF(sc, WPI_DEBUG_FIRMWARE, "fw->init.data %p\n", fw->init.data);
5095 DPRINTF(sc, WPI_DEBUG_FIRMWARE, "fw->boot.text %p\n", fw->boot.text);
5109 if (sc->fw_fp != NULL) {
5110 firmware_put(sc->fw_fp, FIRMWARE_UNLOAD);
5111 sc->fw_fp = NULL;
5129 device_printf(sc->sc_dev,
5151 /* Retrieve PCIe Active State Power Management (ASPM). */
5152 reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + PCIER_LINK_CTL, 1);
5153 /* Workaround for HW instability in PCIe L0->L0s->L1 transition. */
5175 /* Disable L1-Active. */
5199 device_printf(sc->sc_dev, "%s: timeout waiting for master\n",
5223 rev = pci_read_config(sc->sc_dev, PCIR_REVID, 1);
5229 if (sc->cap == 0x80)
5232 if ((sc->rev & 0xf0) == 0xd0)
5237 if (sc->type > 1)
5253 device_printf(sc->sc_dev,
5271 device_printf(sc->sc_dev, "timeout selecting power source\n");
5282 WPI_WRITE(sc, WPI_FH_RX_BASE, sc->rxq.desc_dma.paddr);
5284 WPI_WRITE(sc, WPI_FH_RX_RPTR_ADDR, sc->shared_dma.paddr +
5298 WPI_WRITE(sc, WPI_FH_RX_WPTR, (WPI_RX_RING_COUNT - 1) & ~7);
5312 WPI_WRITE(sc, WPI_FH_TX_BASE, sc->shared_dma.paddr);
5338 device_printf(sc->sc_dev,
5344 if ((error = mtx_sleep(sc, &sc->sc_mtx, PCATCH, "wpiinit", hz)) != 0) {
5345 device_printf(sc->sc_dev,
5353 /* Do post-firmware initialization. */
5401 wpi_reset_tx_ring(sc, &sc->txq[qid]);
5417 struct ieee80211com *ic = &sc->sc_ic;
5418 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
5420 device_printf(sc->sc_dev, "RF switch: radio enabled\n");
5423 callout_stop(&sc->watchdog_rfkill);
5434 struct ieee80211com *ic = &sc->sc_ic;
5435 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
5437 device_printf(sc->sc_dev, "RF switch: radio disabled\n");
5445 callout_reset(&sc->watchdog_rfkill, hz, wpi_watchdog_rfkill, sc);
5458 if (sc->sc_running != 0)
5463 device_printf(sc->sc_dev,
5465 callout_reset(&sc->watchdog_rfkill, hz, wpi_watchdog_rfkill,
5473 device_printf(sc->sc_dev,
5479 sc->sc_running = 1;
5485 device_printf(sc->sc_dev,
5493 device_printf(sc->sc_dev,
5519 if (sc->sc_running == 0)
5524 sc->sc_running = 0;
5529 callout_stop(&sc->tx_timeout);
5533 callout_stop(&sc->scan_timeout);
5534 callout_stop(&sc->calib_to);
5555 struct wpi_softc *sc = ic->ic_softc;
5566 struct wpi_softc *sc = ic->ic_softc;
5567 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
5569 if (vap->iv_state == IEEE80211_S_RUN)
5580 const struct ieee80211_channel *c = ic->ic_curchan;
5581 struct wpi_softc *sc = ic->ic_softc;
5587 sc->sc_rxtap.wr_chan_freq = htole16(c->ic_freq);
5588 sc->sc_rxtap.wr_chan_flags = htole16(c->ic_flags);
5591 sc->sc_txtap.wt_chan_freq = htole16(c->ic_freq);
5592 sc->sc_txtap.wt_chan_flags = htole16(c->ic_flags);
5599 if (ic->ic_opmode == IEEE80211_M_MONITOR) {
5601 sc->rxon.chan = ieee80211_chan2ieee(ic, c);
5603 sc->rxon.flags |= htole32(WPI_RXON_AUTO |
5606 sc->rxon.flags &= ~htole32(WPI_RXON_AUTO |
5610 device_printf(sc->sc_dev,
5625 struct ieee80211vap *vap = ss->ss_vap;
5626 struct ieee80211com *ic = vap->iv_ic;
5627 struct wpi_softc *sc = ic->ic_softc;
5631 error = wpi_scan(sc, ic->ic_curchan);