Lines Matching +full:4 +full:ghz +full:- +full:coexistence

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2005-2006 Sam Leffler, Errno Consulting
33 /*-
266 for (ident = iwi_ident_table; ident->name != NULL; ident++) { in iwi_probe()
267 if (pci_get_vendor(dev) == ident->vendor && in iwi_probe()
268 pci_get_device(dev) == ident->device) { in iwi_probe()
269 device_set_desc(dev, ident->name); in iwi_probe()
280 struct ieee80211com *ic = &sc->sc_ic; in iwi_attach()
284 sc->sc_dev = dev; in iwi_attach()
285 sc->sc_ledevent = ticks; in iwi_attach()
288 mbufq_init(&sc->sc_snd, ifqmaxlen); in iwi_attach()
290 sc->sc_unr = new_unrhdr(1, IWI_MAX_IBSSNODE-1, &sc->sc_mtx); in iwi_attach()
292 TASK_INIT(&sc->sc_radiontask, 0, iwi_radio_on, sc); in iwi_attach()
293 TASK_INIT(&sc->sc_radiofftask, 0, iwi_radio_off, sc); in iwi_attach()
294 TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc); in iwi_attach()
295 TASK_INIT(&sc->sc_disassoctask, 0, iwi_disassoc, sc); in iwi_attach()
296 TASK_INIT(&sc->sc_monitortask, 0, iwi_monitor_scan, sc); in iwi_attach()
298 callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0); in iwi_attach()
299 callout_init_mtx(&sc->sc_rftimer, &sc->sc_mtx, 0); in iwi_attach()
303 /* enable bus-mastering */ in iwi_attach()
307 sc->mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, RF_ACTIVE); in iwi_attach()
308 if (sc->mem == NULL) { in iwi_attach()
313 sc->sc_st = rman_get_bustag(sc->mem); in iwi_attach()
314 sc->sc_sh = rman_get_bushandle(sc->mem); in iwi_attach()
317 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &i, in iwi_attach()
319 if (sc->irq == NULL) { in iwi_attach()
332 if (iwi_alloc_cmd_ring(sc, &sc->cmdq, IWI_CMD_RING_COUNT) != 0) { in iwi_attach()
337 for (i = 0; i < 4; i++) { in iwi_attach()
338 error = iwi_alloc_tx_ring(sc, &sc->txq[i], IWI_TX_RING_COUNT, in iwi_attach()
339 IWI_CSR_TX1_RIDX + i * 4, in iwi_attach()
340 IWI_CSR_TX1_WIDX + i * 4); in iwi_attach()
348 if (iwi_alloc_rx_ring(sc, &sc->rxq, IWI_RX_RING_COUNT) != 0) { in iwi_attach()
355 ic->ic_softc = sc; in iwi_attach()
356 ic->ic_name = device_get_nameunit(dev); in iwi_attach()
357 ic->ic_opmode = IEEE80211_M_STA; in iwi_attach()
358 ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ in iwi_attach()
361 ic->ic_caps = in iwi_attach()
376 ic->ic_macaddr[0] = val & 0xff; in iwi_attach()
377 ic->ic_macaddr[1] = val >> 8; in iwi_attach()
379 ic->ic_macaddr[2] = val & 0xff; in iwi_attach()
380 ic->ic_macaddr[3] = val >> 8; in iwi_attach()
382 ic->ic_macaddr[4] = val & 0xff; in iwi_attach()
383 ic->ic_macaddr[5] = val >> 8; in iwi_attach()
385 iwi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans, in iwi_attach()
386 ic->ic_channels); in iwi_attach()
390 ic->ic_node_alloc = iwi_node_alloc; in iwi_attach()
391 sc->sc_node_free = ic->ic_node_free; in iwi_attach()
392 ic->ic_node_free = iwi_node_free; in iwi_attach()
393 ic->ic_raw_xmit = iwi_raw_xmit; in iwi_attach()
394 ic->ic_scan_start = iwi_scan_start; in iwi_attach()
395 ic->ic_scan_end = iwi_scan_end; in iwi_attach()
396 ic->ic_set_channel = iwi_set_channel; in iwi_attach()
397 ic->ic_scan_curchan = iwi_scan_curchan; in iwi_attach()
398 ic->ic_scan_mindwell = iwi_scan_mindwell; in iwi_attach()
399 ic->ic_wme.wme_update = iwi_wme_update; in iwi_attach()
401 ic->ic_vap_create = iwi_vap_create; in iwi_attach()
402 ic->ic_vap_delete = iwi_vap_delete; in iwi_attach()
403 ic->ic_ioctl = iwi_ioctl; in iwi_attach()
404 ic->ic_transmit = iwi_transmit; in iwi_attach()
405 ic->ic_parent = iwi_parent; in iwi_attach()
406 ic->ic_getradiocaps = iwi_getradiocaps; in iwi_attach()
409 &sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap), in iwi_attach()
411 &sc->sc_rxtap.wr_ihdr, sizeof(sc->sc_rxtap), in iwi_attach()
420 error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE, in iwi_attach()
421 NULL, iwi_intr, sc, &sc->sc_ih); in iwi_attach()
441 struct ieee80211com *ic = &sc->sc_ic; in iwi_detach()
443 bus_teardown_intr(dev, sc->irq, sc->sc_ih); in iwi_detach()
446 ieee80211_draintask(ic, &sc->sc_radiontask); in iwi_detach()
447 ieee80211_draintask(ic, &sc->sc_radiofftask); in iwi_detach()
448 ieee80211_draintask(ic, &sc->sc_restarttask); in iwi_detach()
449 ieee80211_draintask(ic, &sc->sc_disassoctask); in iwi_detach()
450 ieee80211_draintask(ic, &sc->sc_monitortask); in iwi_detach()
459 iwi_free_cmd_ring(sc, &sc->cmdq); in iwi_detach()
460 iwi_free_tx_ring(sc, &sc->txq[0]); in iwi_detach()
461 iwi_free_tx_ring(sc, &sc->txq[1]); in iwi_detach()
462 iwi_free_tx_ring(sc, &sc->txq[2]); in iwi_detach()
463 iwi_free_tx_ring(sc, &sc->txq[3]); in iwi_detach()
464 iwi_free_rx_ring(sc, &sc->rxq); in iwi_detach()
466 bus_release_resource(dev, SYS_RES_IRQ, rman_get_rid(sc->irq), sc->irq); in iwi_detach()
468 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->mem), in iwi_detach()
469 sc->mem); in iwi_detach()
471 delete_unrhdr(sc->sc_unr); in iwi_detach()
472 mbufq_drain(&sc->sc_snd); in iwi_detach()
485 struct iwi_softc *sc = ic->ic_softc; in iwi_vap_create()
490 if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */ in iwi_vap_create()
498 i = sc->fw_fw.size; in iwi_vap_create()
499 if (sc->fw_boot.size > i) in iwi_vap_create()
500 i = sc->fw_boot.size; in iwi_vap_create()
502 if (sc->fw_uc.size > i) in iwi_vap_create()
503 i = sc->fw_uc.size; in iwi_vap_create()
508 vap = &ivp->iwi_vap; in iwi_vap_create()
511 vap->iv_bmissthreshold = 24; in iwi_vap_create()
513 ivp->iwi_newstate = vap->iv_newstate; in iwi_vap_create()
514 vap->iv_newstate = iwi_newstate; in iwi_vap_create()
519 ic->ic_opmode = opmode; in iwi_vap_create()
548 ring->count = count; in iwi_alloc_cmd_ring()
549 ring->queued = 0; in iwi_alloc_cmd_ring()
550 ring->cur = ring->next = 0; in iwi_alloc_cmd_ring()
552 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, in iwi_alloc_cmd_ring()
555 NULL, NULL, &ring->desc_dmat); in iwi_alloc_cmd_ring()
557 device_printf(sc->sc_dev, "could not create desc DMA tag\n"); in iwi_alloc_cmd_ring()
561 error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc, in iwi_alloc_cmd_ring()
562 BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map); in iwi_alloc_cmd_ring()
564 device_printf(sc->sc_dev, "could not allocate DMA memory\n"); in iwi_alloc_cmd_ring()
568 error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc, in iwi_alloc_cmd_ring()
569 count * IWI_CMD_DESC_SIZE, iwi_dma_map_addr, &ring->physaddr, 0); in iwi_alloc_cmd_ring()
571 device_printf(sc->sc_dev, "could not load desc DMA map\n"); in iwi_alloc_cmd_ring()
584 ring->queued = 0; in iwi_reset_cmd_ring()
585 ring->cur = ring->next = 0; in iwi_reset_cmd_ring()
591 if (ring->desc != NULL) { in iwi_free_cmd_ring()
592 bus_dmamap_sync(ring->desc_dmat, ring->desc_map, in iwi_free_cmd_ring()
594 bus_dmamap_unload(ring->desc_dmat, ring->desc_map); in iwi_free_cmd_ring()
595 bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map); in iwi_free_cmd_ring()
598 if (ring->desc_dmat != NULL) in iwi_free_cmd_ring()
599 bus_dma_tag_destroy(ring->desc_dmat); in iwi_free_cmd_ring()
608 ring->count = count; in iwi_alloc_tx_ring()
609 ring->queued = 0; in iwi_alloc_tx_ring()
610 ring->cur = ring->next = 0; in iwi_alloc_tx_ring()
611 ring->csr_ridx = csr_ridx; in iwi_alloc_tx_ring()
612 ring->csr_widx = csr_widx; in iwi_alloc_tx_ring()
614 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, in iwi_alloc_tx_ring()
617 NULL, &ring->desc_dmat); in iwi_alloc_tx_ring()
619 device_printf(sc->sc_dev, "could not create desc DMA tag\n"); in iwi_alloc_tx_ring()
623 error = bus_dmamem_alloc(ring->desc_dmat, (void **)&ring->desc, in iwi_alloc_tx_ring()
624 BUS_DMA_NOWAIT | BUS_DMA_ZERO, &ring->desc_map); in iwi_alloc_tx_ring()
626 device_printf(sc->sc_dev, "could not allocate DMA memory\n"); in iwi_alloc_tx_ring()
630 error = bus_dmamap_load(ring->desc_dmat, ring->desc_map, ring->desc, in iwi_alloc_tx_ring()
631 count * IWI_TX_DESC_SIZE, iwi_dma_map_addr, &ring->physaddr, 0); in iwi_alloc_tx_ring()
633 device_printf(sc->sc_dev, "could not load desc DMA map\n"); in iwi_alloc_tx_ring()
637 ring->data = malloc(count * sizeof (struct iwi_tx_data), M_DEVBUF, in iwi_alloc_tx_ring()
639 if (ring->data == NULL) { in iwi_alloc_tx_ring()
640 device_printf(sc->sc_dev, "could not allocate soft data\n"); in iwi_alloc_tx_ring()
645 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in iwi_alloc_tx_ring()
647 IWI_MAX_NSEG, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); in iwi_alloc_tx_ring()
649 device_printf(sc->sc_dev, "could not create data DMA tag\n"); in iwi_alloc_tx_ring()
654 error = bus_dmamap_create(ring->data_dmat, 0, in iwi_alloc_tx_ring()
655 &ring->data[i].map); in iwi_alloc_tx_ring()
657 device_printf(sc->sc_dev, "could not create DMA map\n"); in iwi_alloc_tx_ring()
674 for (i = 0; i < ring->count; i++) { in iwi_reset_tx_ring()
675 data = &ring->data[i]; in iwi_reset_tx_ring()
677 if (data->m != NULL) { in iwi_reset_tx_ring()
678 bus_dmamap_sync(ring->data_dmat, data->map, in iwi_reset_tx_ring()
680 bus_dmamap_unload(ring->data_dmat, data->map); in iwi_reset_tx_ring()
681 m_freem(data->m); in iwi_reset_tx_ring()
682 data->m = NULL; in iwi_reset_tx_ring()
685 if (data->ni != NULL) { in iwi_reset_tx_ring()
686 ieee80211_free_node(data->ni); in iwi_reset_tx_ring()
687 data->ni = NULL; in iwi_reset_tx_ring()
691 ring->queued = 0; in iwi_reset_tx_ring()
692 ring->cur = ring->next = 0; in iwi_reset_tx_ring()
701 if (ring->desc != NULL) { in iwi_free_tx_ring()
702 bus_dmamap_sync(ring->desc_dmat, ring->desc_map, in iwi_free_tx_ring()
704 bus_dmamap_unload(ring->desc_dmat, ring->desc_map); in iwi_free_tx_ring()
705 bus_dmamem_free(ring->desc_dmat, ring->desc, ring->desc_map); in iwi_free_tx_ring()
708 if (ring->desc_dmat != NULL) in iwi_free_tx_ring()
709 bus_dma_tag_destroy(ring->desc_dmat); in iwi_free_tx_ring()
711 if (ring->data != NULL) { in iwi_free_tx_ring()
712 for (i = 0; i < ring->count; i++) { in iwi_free_tx_ring()
713 data = &ring->data[i]; in iwi_free_tx_ring()
715 if (data->m != NULL) { in iwi_free_tx_ring()
716 bus_dmamap_sync(ring->data_dmat, data->map, in iwi_free_tx_ring()
718 bus_dmamap_unload(ring->data_dmat, data->map); in iwi_free_tx_ring()
719 m_freem(data->m); in iwi_free_tx_ring()
722 if (data->ni != NULL) in iwi_free_tx_ring()
723 ieee80211_free_node(data->ni); in iwi_free_tx_ring()
725 if (data->map != NULL) in iwi_free_tx_ring()
726 bus_dmamap_destroy(ring->data_dmat, data->map); in iwi_free_tx_ring()
729 free(ring->data, M_DEVBUF); in iwi_free_tx_ring()
732 if (ring->data_dmat != NULL) in iwi_free_tx_ring()
733 bus_dma_tag_destroy(ring->data_dmat); in iwi_free_tx_ring()
742 ring->count = count; in iwi_alloc_rx_ring()
743 ring->cur = 0; in iwi_alloc_rx_ring()
745 ring->data = malloc(count * sizeof (struct iwi_rx_data), M_DEVBUF, in iwi_alloc_rx_ring()
747 if (ring->data == NULL) { in iwi_alloc_rx_ring()
748 device_printf(sc->sc_dev, "could not allocate soft data\n"); in iwi_alloc_rx_ring()
753 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0, in iwi_alloc_rx_ring()
755 1, MCLBYTES, 0, NULL, NULL, &ring->data_dmat); in iwi_alloc_rx_ring()
757 device_printf(sc->sc_dev, "could not create data DMA tag\n"); in iwi_alloc_rx_ring()
762 data = &ring->data[i]; in iwi_alloc_rx_ring()
764 error = bus_dmamap_create(ring->data_dmat, 0, &data->map); in iwi_alloc_rx_ring()
766 device_printf(sc->sc_dev, "could not create DMA map\n"); in iwi_alloc_rx_ring()
770 data->m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); in iwi_alloc_rx_ring()
771 if (data->m == NULL) { in iwi_alloc_rx_ring()
772 device_printf(sc->sc_dev, in iwi_alloc_rx_ring()
778 error = bus_dmamap_load(ring->data_dmat, data->map, in iwi_alloc_rx_ring()
779 mtod(data->m, void *), MCLBYTES, iwi_dma_map_addr, in iwi_alloc_rx_ring()
780 &data->physaddr, 0); in iwi_alloc_rx_ring()
782 device_printf(sc->sc_dev, in iwi_alloc_rx_ring()
787 data->reg = IWI_CSR_RX_BASE + i * 4; in iwi_alloc_rx_ring()
799 ring->cur = 0; in iwi_reset_rx_ring()
808 if (ring->data != NULL) { in iwi_free_rx_ring()
809 for (i = 0; i < ring->count; i++) { in iwi_free_rx_ring()
810 data = &ring->data[i]; in iwi_free_rx_ring()
812 if (data->m != NULL) { in iwi_free_rx_ring()
813 bus_dmamap_sync(ring->data_dmat, data->map, in iwi_free_rx_ring()
815 bus_dmamap_unload(ring->data_dmat, data->map); in iwi_free_rx_ring()
816 m_freem(data->m); in iwi_free_rx_ring()
819 if (data->map != NULL) in iwi_free_rx_ring()
820 bus_dmamap_destroy(ring->data_dmat, data->map); in iwi_free_rx_ring()
823 free(ring->data, M_DEVBUF); in iwi_free_rx_ring()
826 if (ring->data_dmat != NULL) in iwi_free_rx_ring()
827 bus_dma_tag_destroy(ring->data_dmat); in iwi_free_rx_ring()
845 struct ieee80211com *ic = &sc->sc_ic; in iwi_suspend()
855 struct ieee80211com *ic = &sc->sc_ic; in iwi_resume()
872 in->in_station = -1; in iwi_node_alloc()
874 return &in->in_node; in iwi_node_alloc()
880 struct ieee80211com *ic = ni->ni_ic; in iwi_node_free()
881 struct iwi_softc *sc = ic->ic_softc; in iwi_node_free()
884 if (in->in_station != -1) { in iwi_node_free()
886 ni->ni_macaddr, ":", in->in_station)); in iwi_node_free()
887 free_unr(sc->sc_unr, in->in_station); in iwi_node_free()
890 sc->sc_node_free(ni); in iwi_node_free()
901 case IWI_RATE_DS2: return 4; in iwi_cvtrate()
924 struct ieee80211com *ic = vap->iv_ic; in iwi_media_status()
925 struct iwi_softc *sc = ic->ic_softc; in iwi_media_status()
929 ni = ieee80211_ref_node(vap->iv_bss); in iwi_media_status()
930 ni->ni_txrate = in iwi_media_status()
940 struct ieee80211com *ic = vap->iv_ic; in iwi_newstate()
941 struct iwi_softc *sc = ic->ic_softc; in iwi_newstate()
944 DPRINTF(("%s: %s -> %s flags 0x%x\n", __func__, in iwi_newstate()
945 ieee80211_state_name[vap->iv_state], in iwi_newstate()
946 ieee80211_state_name[nstate], sc->flags)); in iwi_newstate()
956 if (vap->iv_state == IEEE80211_S_RUN && in iwi_newstate()
957 (sc->flags & IWI_FLAG_FW_INITED)) in iwi_newstate()
964 if (vap->iv_opmode == IEEE80211_M_IBSS && in iwi_newstate()
965 vap->iv_state == IEEE80211_S_SCAN) { in iwi_newstate()
968 * with a SCAN -> RUN transition on scan complete. in iwi_newstate()
971 * AUTH -> RUN transition and we want to do nothing. in iwi_newstate()
975 } else if (vap->iv_opmode == IEEE80211_M_MONITOR) in iwi_newstate()
976 ieee80211_runtask(ic, &sc->sc_monitortask); in iwi_newstate()
984 if (vap->iv_state == IEEE80211_S_AUTH) in iwi_newstate()
993 return ivp->iwi_newstate(vap, nstate, arg); in iwi_newstate()
1004 { 0, 2, 4, 5, 188 }, /* WME_AC_VI */
1005 { 0, 2, 3, 4, 102 } /* WME_AC_VO */
1009 { 0, 3, 4, 6, 0 }, /* WME_AC_BE */
1010 { 0, 3, 4, 10, 0 }, /* WME_AC_BK */
1011 { 0, 2, 3, 4, 94 }, /* WME_AC_VI */
1014 #define IWI_EXP2(v) htole16((1 << (v)) - 1)
1023 memset(sc->wme, 0, sizeof sc->wme); in iwi_wme_init()
1027 sc->wme[1].aifsn[ac] = wmep->wmep_aifsn; in iwi_wme_init()
1028 sc->wme[1].cwmin[ac] = IWI_EXP2(wmep->wmep_logcwmin); in iwi_wme_init()
1029 sc->wme[1].cwmax[ac] = IWI_EXP2(wmep->wmep_logcwmax); in iwi_wme_init()
1030 sc->wme[1].burst[ac] = IWI_USEC(wmep->wmep_txopLimit); in iwi_wme_init()
1031 sc->wme[1].acm[ac] = wmep->wmep_acm; in iwi_wme_init()
1035 sc->wme[2].aifsn[ac] = wmep->wmep_aifsn; in iwi_wme_init()
1036 sc->wme[2].cwmin[ac] = IWI_EXP2(wmep->wmep_logcwmin); in iwi_wme_init()
1037 sc->wme[2].cwmax[ac] = IWI_EXP2(wmep->wmep_logcwmax); in iwi_wme_init()
1038 sc->wme[2].burst[ac] = IWI_USEC(wmep->wmep_txopLimit); in iwi_wme_init()
1039 sc->wme[2].acm[ac] = wmep->wmep_acm; in iwi_wme_init()
1046 struct ieee80211com *ic = &sc->sc_ic; in iwi_wme_setparams()
1056 sc->wme[0].aifsn[ac] = wmep->wmep_aifsn; in iwi_wme_setparams()
1057 sc->wme[0].cwmin[ac] = IWI_EXP2(wmep->wmep_logcwmin); in iwi_wme_setparams()
1058 sc->wme[0].cwmax[ac] = IWI_EXP2(wmep->wmep_logcwmax); in iwi_wme_setparams()
1059 sc->wme[0].burst[ac] = IWI_USEC(wmep->wmep_txopLimit); in iwi_wme_setparams()
1060 sc->wme[0].acm[ac] = wmep->wmep_acm; in iwi_wme_setparams()
1064 return iwi_cmd(sc, IWI_CMD_SET_WME_PARAMS, sc->wme, sizeof sc->wme); in iwi_wme_setparams()
1072 struct iwi_softc *sc = ic->ic_softc; in iwi_wme_update()
1073 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwi_wme_update()
1084 if (vap->iv_state == IEEE80211_S_RUN) { in iwi_wme_update()
1099 wme.wme_len = sizeof (struct ieee80211_wme_info) - 2; in iwi_wme_setie()
1138 /* write address A7-A0 */ in iwi_read_prom_word()
1139 for (n = 7; n >= 0; n--) { in iwi_read_prom_word()
1148 /* read data Q15-Q0 */ in iwi_read_prom_word()
1150 for (n = 15; n >= 0; n--) { in iwi_read_prom_word()
1170 struct ieee80211com *ic = &sc->sc_ic; in iwi_setcurchan()
1172 sc->curchan = chan; in iwi_setcurchan()
1180 struct ieee80211com *ic = &sc->sc_ic; in iwi_frame_intr()
1187 framelen = le16toh(frame->len); in iwi_frame_intr()
1197 le16toh(frame->len), frame->chan, frame->rssi, in iwi_frame_intr()
1198 frame->rssi_dbm)); in iwi_frame_intr()
1203 le16toh(frame->len), frame->chan, frame->rssi, frame->rssi_dbm)); in iwi_frame_intr()
1205 if (frame->chan != sc->curchan) in iwi_frame_intr()
1206 iwi_setcurchan(sc, frame->chan); in iwi_frame_intr()
1216 counter_u64_add(ic->ic_ierrors, 1); in iwi_frame_intr()
1220 bus_dmamap_unload(sc->rxq.data_dmat, data->map); in iwi_frame_intr()
1222 error = bus_dmamap_load(sc->rxq.data_dmat, data->map, in iwi_frame_intr()
1223 mtod(mnew, void *), MCLBYTES, iwi_dma_map_addr, &data->physaddr, in iwi_frame_intr()
1229 error = bus_dmamap_load(sc->rxq.data_dmat, data->map, in iwi_frame_intr()
1230 mtod(data->m, void *), MCLBYTES, iwi_dma_map_addr, in iwi_frame_intr()
1231 &data->physaddr, 0); in iwi_frame_intr()
1235 device_get_name(sc->sc_dev)); in iwi_frame_intr()
1237 counter_u64_add(ic->ic_ierrors, 1); in iwi_frame_intr()
1245 m = data->m; in iwi_frame_intr()
1246 data->m = mnew; in iwi_frame_intr()
1247 CSR_WRITE_4(sc, data->reg, data->physaddr); in iwi_frame_intr()
1250 m->m_pkthdr.len = m->m_len = sizeof (struct iwi_hdr) + in iwi_frame_intr()
1255 rssi = frame->rssi_dbm; in iwi_frame_intr()
1256 nf = -95; in iwi_frame_intr()
1258 struct iwi_rx_radiotap_header *tap = &sc->sc_rxtap; in iwi_frame_intr()
1260 tap->wr_flags = 0; in iwi_frame_intr()
1261 tap->wr_antsignal = rssi; in iwi_frame_intr()
1262 tap->wr_antnoise = nf; in iwi_frame_intr()
1263 tap->wr_rate = iwi_cvtrate(frame->rate); in iwi_frame_intr()
1264 tap->wr_antenna = frame->antenna; in iwi_frame_intr()
1276 if (sc->sc_softled) { in iwi_frame_intr()
1279 * heartbeat-style blink when idle. The latter in iwi_frame_intr()
1284 sc->sc_rxrate = frame->rate; in iwi_frame_intr()
1286 } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle) in iwi_frame_intr()
1303 #define SUBTYPE(wh) ((wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) in iwi_checkforqos()
1332 while (efrm - frm > 1) { in iwi_checkforqos()
1333 IEEE80211_VERIFY_LENGTH(efrm - frm, frm[1] + 2, return); in iwi_checkforqos()
1343 ni = ieee80211_ref_node(vap->iv_bss); in iwi_checkforqos()
1344 ni->ni_capinfo = capinfo; in iwi_checkforqos()
1345 ni->ni_associd = associd & 0x3fff; in iwi_checkforqos()
1347 ni->ni_flags |= IEEE80211_NODE_QOS; in iwi_checkforqos()
1349 ni->ni_flags &= ~IEEE80211_NODE_QOS; in iwi_checkforqos()
1360 len = le16toh(notif->len); in iwi_notif_link_quality()
1362 DPRINTFN(5, ("Notification (%u) - len=%d, sizeof=%zu\n", in iwi_notif_link_quality()
1363 notif->type, in iwi_notif_link_quality()
1371 notif->type, in iwi_notif_link_quality()
1377 memcpy(&sc->sc_linkqual, lq, sizeof(sc->sc_linkqual)); in iwi_notif_link_quality()
1378 sc->sc_linkqual_valid = 1; in iwi_notif_link_quality()
1388 struct ieee80211com *ic = &sc->sc_ic; in iwi_notification_intr()
1389 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwi_notification_intr()
1396 switch (notif->type) { in iwi_notification_intr()
1401 ieee80211_ieee2mhz(chan->nchan, 0), chan->nchan)); in iwi_notification_intr()
1404 sc->sc_state_timer = 3; in iwi_notification_intr()
1410 DPRINTFN(2, ("Scan completed (%u, %u)\n", scan->nchan, in iwi_notification_intr()
1411 scan->status)); in iwi_notification_intr()
1422 if (vap->iv_opmode == IEEE80211_M_MONITOR) { in iwi_notification_intr()
1423 ieee80211_runtask(ic, &sc->sc_monitortask); in iwi_notification_intr()
1427 if (scan->status == IWI_SCAN_COMPLETED) { in iwi_notification_intr()
1435 switch (auth->state) { in iwi_notification_intr()
1438 ieee80211_new_state(vap, IEEE80211_S_ASSOC, -1); in iwi_notification_intr()
1446 sc->flags &= ~IWI_FLAG_ASSOCIATED; in iwi_notification_intr()
1447 if (vap->iv_state != IEEE80211_S_RUN) { in iwi_notification_intr()
1449 vap->iv_stats.is_rx_auth_fail++; in iwi_notification_intr()
1453 vap->iv_stats.is_rx_deauth++; in iwi_notification_intr()
1455 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in iwi_notification_intr()
1464 vap->iv_stats.is_rx_auth_fail++; in iwi_notification_intr()
1469 device_printf(sc->sc_dev, in iwi_notification_intr()
1470 "unknown authentication state %u\n", auth->state); in iwi_notification_intr()
1477 switch (assoc->state) { in iwi_notification_intr()
1479 /* re-association, do nothing */ in iwi_notification_intr()
1483 sc->flags |= IWI_FLAG_ASSOCIATED; in iwi_notification_intr()
1487 le16toh(notif->len) - sizeof(*assoc) - 1); in iwi_notification_intr()
1488 ieee80211_new_state(vap, IEEE80211_S_RUN, -1); in iwi_notification_intr()
1491 sc->flags &= ~IWI_FLAG_ASSOCIATED; in iwi_notification_intr()
1492 switch (sc->fw_state) { in iwi_notification_intr()
1496 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in iwi_notification_intr()
1502 vap->iv_stats.is_rx_disassoc++; in iwi_notification_intr()
1503 ieee80211_new_state(vap, IEEE80211_S_SCAN, -1); in iwi_notification_intr()
1508 device_printf(sc->sc_dev, in iwi_notification_intr()
1509 "unknown association state %u\n", assoc->state); in iwi_notification_intr()
1519 beacon->state, le32toh(beacon->number))); in iwi_notification_intr()
1521 if (beacon->state == IWI_BEACON_MISS) { in iwi_notification_intr()
1529 if (le32toh(beacon->number) >= vap->iv_bmissthreshold) { in iwi_notification_intr()
1531 le32toh(beacon->number), in iwi_notification_intr()
1532 vap->iv_bmissthreshold)); in iwi_notification_intr()
1533 vap->iv_stats.is_beacon_miss++; in iwi_notification_intr()
1542 ieee80211_runtask(ic, &sc->sc_disassoctask); in iwi_notification_intr()
1550 DPRINTFN(5, ("Notification (%u)\n", notif->type)); in iwi_notification_intr()
1558 notif->type, notif->flags, le16toh(notif->len))); in iwi_notification_intr()
1572 for (; sc->rxq.cur != hw;) { in iwi_rx_intr()
1573 data = &sc->rxq.data[sc->rxq.cur]; in iwi_rx_intr()
1575 bus_dmamap_sync(sc->rxq.data_dmat, data->map, in iwi_rx_intr()
1578 hdr = mtod(data->m, struct iwi_hdr *); in iwi_rx_intr()
1580 switch (hdr->type) { in iwi_rx_intr()
1582 iwi_frame_intr(sc, data, sc->rxq.cur, in iwi_rx_intr()
1592 device_printf(sc->sc_dev, "unknown hdr type %u\n", in iwi_rx_intr()
1593 hdr->type); in iwi_rx_intr()
1596 DPRINTFN(15, ("rx done idx=%u\n", sc->rxq.cur)); in iwi_rx_intr()
1598 sc->rxq.cur = (sc->rxq.cur + 1) % IWI_RX_RING_COUNT; in iwi_rx_intr()
1602 hw = (hw == 0) ? IWI_RX_RING_COUNT - 1 : hw - 1; in iwi_rx_intr()
1612 hw = CSR_READ_4(sc, txq->csr_ridx); in iwi_tx_intr()
1614 while (txq->next != hw) { in iwi_tx_intr()
1615 data = &txq->data[txq->next]; in iwi_tx_intr()
1616 DPRINTFN(15, ("tx done idx=%u\n", txq->next)); in iwi_tx_intr()
1617 bus_dmamap_sync(txq->data_dmat, data->map, in iwi_tx_intr()
1619 bus_dmamap_unload(txq->data_dmat, data->map); in iwi_tx_intr()
1620 ieee80211_tx_complete(data->ni, data->m, 0); in iwi_tx_intr()
1621 data->ni = NULL; in iwi_tx_intr()
1622 data->m = NULL; in iwi_tx_intr()
1623 txq->queued--; in iwi_tx_intr()
1624 txq->next = (txq->next + 1) % IWI_TX_RING_COUNT; in iwi_tx_intr()
1626 sc->sc_tx_timer = 0; in iwi_tx_intr()
1627 if (sc->sc_softled) in iwi_tx_intr()
1635 struct ieee80211com *ic = &sc->sc_ic; in iwi_fatal_error_intr()
1636 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwi_fatal_error_intr()
1638 device_printf(sc->sc_dev, "firmware error\n"); in iwi_fatal_error_intr()
1641 ieee80211_runtask(ic, &sc->sc_restarttask); in iwi_fatal_error_intr()
1643 sc->flags &= ~IWI_FLAG_BUSY; in iwi_fatal_error_intr()
1644 sc->sc_busy_timer = 0; in iwi_fatal_error_intr()
1652 ieee80211_runtask(&sc->sc_ic, &sc->sc_radiofftask); in iwi_radio_off_intr()
1686 sc->flags &= ~IWI_FLAG_BUSY; in iwi_intr()
1687 sc->sc_busy_timer = 0; in iwi_intr()
1692 iwi_tx_intr(sc, &sc->txq[0]); in iwi_intr()
1695 iwi_tx_intr(sc, &sc->txq[1]); in iwi_intr()
1698 iwi_tx_intr(sc, &sc->txq[2]); in iwi_intr()
1701 iwi_tx_intr(sc, &sc->txq[3]); in iwi_intr()
1707 /* XXX rate-limit */ in iwi_intr()
1708 device_printf(sc->sc_dev, "parity error\n"); in iwi_intr()
1721 if (sc->flags & IWI_FLAG_BUSY) { in iwi_cmd()
1722 device_printf(sc->sc_dev, "%s: cmd %d not sent, busy\n", in iwi_cmd()
1726 sc->flags |= IWI_FLAG_BUSY; in iwi_cmd()
1727 sc->sc_busy_timer = 2; in iwi_cmd()
1729 desc = &sc->cmdq.desc[sc->cmdq.cur]; in iwi_cmd()
1731 desc->hdr.type = IWI_HDR_TYPE_COMMAND; in iwi_cmd()
1732 desc->hdr.flags = IWI_HDR_FLAG_IRQ; in iwi_cmd()
1733 desc->type = type; in iwi_cmd()
1734 desc->len = len; in iwi_cmd()
1735 memcpy(desc->data, data, len); in iwi_cmd()
1737 bus_dmamap_sync(sc->cmdq.desc_dmat, sc->cmdq.desc_map, in iwi_cmd()
1740 DPRINTFN(2, ("sending command idx=%u type=%u len=%u\n", sc->cmdq.cur, in iwi_cmd()
1743 sc->cmdq.cur = (sc->cmdq.cur + 1) % IWI_CMD_RING_COUNT; in iwi_cmd()
1744 CSR_WRITE_4(sc, IWI_CSR_CMD_WIDX, sc->cmdq.cur); in iwi_cmd()
1746 return msleep(sc, &sc->sc_mtx, 0, "iwicmd", hz); in iwi_cmd()
1770 struct ieee80211vap *vap = ni->ni_vap; in iwi_tx_start()
1774 struct iwi_tx_ring *txq = &sc->txq[ac]; in iwi_tx_start()
1786 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in iwi_tx_start()
1791 if (vap->iv_flags & IEEE80211_F_SHPREAMBLE) in iwi_tx_start()
1803 if (vap->iv_opmode == IEEE80211_M_IBSS) { in iwi_tx_start()
1805 if (in->in_station == -1) { in iwi_tx_start()
1806 in->in_station = alloc_unr(sc->sc_unr); in iwi_tx_start()
1807 if (in->in_station == -1) { in iwi_tx_start()
1809 if_inc_counter(ni->ni_vap->iv_ifp, in iwi_tx_start()
1816 ni->ni_macaddr, in->in_station); in iwi_tx_start()
1818 staid = in->in_station; in iwi_tx_start()
1828 if (!IEEE80211_ADDR_EQ(wh->i_addr1, sc->sc_mcast)) { in iwi_tx_start()
1829 IEEE80211_ADDR_COPY(sc->sc_mcast, wh->i_addr1); in iwi_tx_start()
1830 iwi_write_ibssnode(sc, sc->sc_mcast, 0); in iwi_tx_start()
1837 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { in iwi_tx_start()
1849 struct iwi_tx_radiotap_header *tap = &sc->sc_txtap; in iwi_tx_start()
1851 tap->wt_flags = 0; in iwi_tx_start()
1856 data = &txq->data[txq->cur]; in iwi_tx_start()
1857 desc = &txq->desc[txq->cur]; in iwi_tx_start()
1860 m_copydata(m0, 0, hdrlen, (caddr_t)&desc->wh); in iwi_tx_start()
1863 error = bus_dmamap_load_mbuf_sg(txq->data_dmat, data->map, m0, segs, in iwi_tx_start()
1866 device_printf(sc->sc_dev, "could not map mbuf (error %d)\n", in iwi_tx_start()
1874 device_printf(sc->sc_dev, in iwi_tx_start()
1881 error = bus_dmamap_load_mbuf_sg(txq->data_dmat, data->map, in iwi_tx_start()
1884 device_printf(sc->sc_dev, in iwi_tx_start()
1891 data->m = m0; in iwi_tx_start()
1892 data->ni = ni; in iwi_tx_start()
1894 desc->hdr.type = IWI_HDR_TYPE_DATA; in iwi_tx_start()
1895 desc->hdr.flags = IWI_HDR_FLAG_IRQ; in iwi_tx_start()
1896 desc->station = staid; in iwi_tx_start()
1897 desc->cmd = IWI_DATA_CMD_TX; in iwi_tx_start()
1898 desc->len = htole16(m0->m_pkthdr.len); in iwi_tx_start()
1899 desc->flags = flags; in iwi_tx_start()
1900 desc->xflags = xflags; in iwi_tx_start()
1903 if (vap->iv_flags & IEEE80211_F_PRIVACY) in iwi_tx_start()
1904 desc->wep_txkey = vap->iv_def_txkey; in iwi_tx_start()
1907 desc->flags |= IWI_DATA_FLAG_NO_WEP; in iwi_tx_start()
1909 desc->nseg = htole32(nsegs); in iwi_tx_start()
1911 desc->seg_addr[i] = htole32(segs[i].ds_addr); in iwi_tx_start()
1912 desc->seg_len[i] = htole16(segs[i].ds_len); in iwi_tx_start()
1915 bus_dmamap_sync(txq->data_dmat, data->map, BUS_DMASYNC_PREWRITE); in iwi_tx_start()
1916 bus_dmamap_sync(txq->desc_dmat, txq->desc_map, BUS_DMASYNC_PREWRITE); in iwi_tx_start()
1919 ac, txq->cur, le16toh(desc->len), nsegs)); in iwi_tx_start()
1921 txq->queued++; in iwi_tx_start()
1922 txq->cur = (txq->cur + 1) % IWI_TX_RING_COUNT; in iwi_tx_start()
1923 CSR_WRITE_4(sc, txq->csr_widx, txq->cur); in iwi_tx_start()
1941 struct iwi_softc *sc = ic->ic_softc; in iwi_transmit()
1946 if (!sc->sc_running) { in iwi_transmit()
1950 error = mbufq_enqueue(&sc->sc_snd, m); in iwi_transmit()
1969 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in iwi_start()
1971 if (sc->txq[ac].queued > IWI_TX_RING_COUNT - 8) { in iwi_start()
1974 mbufq_prepend(&sc->sc_snd, m); in iwi_start()
1977 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; in iwi_start()
1979 if_inc_counter(ni->ni_vap->iv_ifp, in iwi_start()
1984 sc->sc_tx_timer = 5; in iwi_start()
1992 struct ieee80211com *ic = &sc->sc_ic; in iwi_watchdog()
1996 if (sc->sc_tx_timer > 0) { in iwi_watchdog()
1997 if (--sc->sc_tx_timer == 0) { in iwi_watchdog()
1998 device_printf(sc->sc_dev, "device timeout\n"); in iwi_watchdog()
1999 counter_u64_add(ic->ic_oerrors, 1); in iwi_watchdog()
2000 ieee80211_runtask(ic, &sc->sc_restarttask); in iwi_watchdog()
2003 if (sc->sc_state_timer > 0) { in iwi_watchdog()
2004 if (--sc->sc_state_timer == 0) { in iwi_watchdog()
2005 device_printf(sc->sc_dev, in iwi_watchdog()
2007 sc->fw_state); in iwi_watchdog()
2008 if (sc->fw_state == IWI_FW_SCANNING) in iwi_watchdog()
2009 ieee80211_cancel_scan(TAILQ_FIRST(&ic->ic_vaps)); in iwi_watchdog()
2010 ieee80211_runtask(ic, &sc->sc_restarttask); in iwi_watchdog()
2011 sc->sc_state_timer = 3; in iwi_watchdog()
2014 if (sc->sc_busy_timer > 0) { in iwi_watchdog()
2015 if (--sc->sc_busy_timer == 0) { in iwi_watchdog()
2016 device_printf(sc->sc_dev, in iwi_watchdog()
2018 ieee80211_runtask(ic, &sc->sc_restarttask); in iwi_watchdog()
2021 callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc); in iwi_watchdog()
2027 struct iwi_softc *sc = ic->ic_softc; in iwi_parent()
2032 if (ic->ic_nrunning > 0) { in iwi_parent()
2033 if (!sc->sc_running) { in iwi_parent()
2037 } else if (sc->sc_running) in iwi_parent()
2048 struct iwi_softc *sc = ic->ic_softc; in iwi_ioctl()
2056 error = copyout(&sc->sc_linkqual, ifr_data_get_ptr(ifr), in iwi_ioctl()
2060 memset(&sc->sc_linkqual, 0, in iwi_ioctl()
2089 device_printf(sc->sc_dev, "timeout waiting for master\n"); in iwi_stop_master()
2094 sc->flags &= ~IWI_FLAG_FW_INITED; in iwi_stop_master()
2117 device_printf(sc->sc_dev, in iwi_reset()
2141 const struct firmware *fp = fw->fp; in iwi_setup_ofw()
2144 if (fp->datasize < sizeof (struct iwi_firmware_ohdr)) { in iwi_setup_ofw()
2145 device_printf(sc->sc_dev, "image '%s' too small\n", fp->name); in iwi_setup_ofw()
2148 hdr = (const struct iwi_firmware_ohdr *)fp->data; in iwi_setup_ofw()
2149 if ((IWI_FW_GET_MAJOR(le32toh(hdr->version)) != IWI_FW_REQ_MAJOR) || in iwi_setup_ofw()
2150 (IWI_FW_GET_MINOR(le32toh(hdr->version)) != IWI_FW_REQ_MINOR)) { in iwi_setup_ofw()
2151 device_printf(sc->sc_dev, "version for '%s' %d.%d != %d.%d\n", in iwi_setup_ofw()
2152 fp->name, IWI_FW_GET_MAJOR(le32toh(hdr->version)), in iwi_setup_ofw()
2153 IWI_FW_GET_MINOR(le32toh(hdr->version)), IWI_FW_REQ_MAJOR, in iwi_setup_ofw()
2157 fw->data = ((const char *) fp->data) + sizeof(struct iwi_firmware_ohdr); in iwi_setup_ofw()
2158 fw->size = fp->datasize - sizeof(struct iwi_firmware_ohdr); in iwi_setup_ofw()
2159 fw->name = fp->name; in iwi_setup_ofw()
2169 if (hdr != NULL && le32toh(hdr->mode) != IWI_FW_MODE_UCODE) { in iwi_setup_oucode()
2170 device_printf(sc->sc_dev, "%s is not a ucode image\n", in iwi_setup_oucode()
2171 fw->name); in iwi_setup_oucode()
2181 if (fw->fp == NULL) in iwi_getfw()
2182 fw->fp = firmware_get(fwname); in iwi_getfw()
2183 /* NB: pre-3.0 ucode is packaged separately */ in iwi_getfw()
2184 if (uc->fp == NULL && fw->fp != NULL && fw->fp->version < 300) in iwi_getfw()
2185 uc->fp = firmware_get(ucname); in iwi_getfw()
2192 * This is necessary because we re-init the device sometimes
2194 * (e.g. from the taskqueue thread when rfkill is re-enabled).
2209 if (sc->fw_mode != opmode) in iwi_get_firmware()
2214 iwi_getfw(&sc->fw_fw, "iwi_bss", &sc->fw_uc, "iwi_ucode_bss"); in iwi_get_firmware()
2217 iwi_getfw(&sc->fw_fw, "iwi_ibss", &sc->fw_uc, "iwi_ucode_ibss"); in iwi_get_firmware()
2220 iwi_getfw(&sc->fw_fw, "iwi_monitor", in iwi_get_firmware()
2221 &sc->fw_uc, "iwi_ucode_monitor"); in iwi_get_firmware()
2224 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in iwi_get_firmware()
2227 fp = sc->fw_fw.fp; in iwi_get_firmware()
2229 device_printf(sc->sc_dev, "could not load firmware\n"); in iwi_get_firmware()
2232 if (fp->version < 300) { in iwi_get_firmware()
2240 * safeguard against mis-packaging. in iwi_get_firmware()
2242 if (sc->fw_uc.fp == NULL) { in iwi_get_firmware()
2243 device_printf(sc->sc_dev, "could not load ucode\n"); in iwi_get_firmware()
2246 if (sc->fw_boot.fp == NULL) { in iwi_get_firmware()
2247 sc->fw_boot.fp = firmware_get("iwi_boot"); in iwi_get_firmware()
2248 if (sc->fw_boot.fp == NULL) { in iwi_get_firmware()
2249 device_printf(sc->sc_dev, in iwi_get_firmware()
2254 if (sc->fw_boot.fp->version != sc->fw_fw.fp->version || in iwi_get_firmware()
2255 sc->fw_boot.fp->version != sc->fw_uc.fp->version) { in iwi_get_firmware()
2256 device_printf(sc->sc_dev, in iwi_get_firmware()
2259 sc->fw_boot.fp->name, sc->fw_boot.fp->version, in iwi_get_firmware()
2260 sc->fw_uc.fp->name, sc->fw_uc.fp->version, in iwi_get_firmware()
2261 sc->fw_fw.fp->name, sc->fw_fw.fp->version in iwi_get_firmware()
2268 if (iwi_setup_oucode(sc, &sc->fw_uc) == NULL || in iwi_get_firmware()
2269 iwi_setup_ofw(sc, &sc->fw_boot) == NULL || in iwi_get_firmware()
2270 iwi_setup_ofw(sc, &sc->fw_fw) == NULL) in iwi_get_firmware()
2276 if (fp->datasize < sizeof(struct iwi_firmware_hdr)) { in iwi_get_firmware()
2277 device_printf(sc->sc_dev, "image '%s' too small\n", in iwi_get_firmware()
2278 fp->name); in iwi_get_firmware()
2281 hdr = (const struct iwi_firmware_hdr *)fp->data; in iwi_get_firmware()
2282 if (fp->datasize < sizeof(*hdr) + le32toh(hdr->bsize) + le32toh(hdr->usize) in iwi_get_firmware()
2283 + le32toh(hdr->fsize)) { in iwi_get_firmware()
2284 device_printf(sc->sc_dev, "image '%s' too small (2)\n", in iwi_get_firmware()
2285 fp->name); in iwi_get_firmware()
2288 sc->fw_boot.data = ((const char *) fp->data) + sizeof(*hdr); in iwi_get_firmware()
2289 sc->fw_boot.size = le32toh(hdr->bsize); in iwi_get_firmware()
2290 sc->fw_boot.name = fp->name; in iwi_get_firmware()
2291 sc->fw_uc.data = sc->fw_boot.data + sc->fw_boot.size; in iwi_get_firmware()
2292 sc->fw_uc.size = le32toh(hdr->usize); in iwi_get_firmware()
2293 sc->fw_uc.name = fp->name; in iwi_get_firmware()
2294 sc->fw_fw.data = sc->fw_uc.data + sc->fw_uc.size; in iwi_get_firmware()
2295 sc->fw_fw.size = le32toh(hdr->fsize); in iwi_get_firmware()
2296 sc->fw_fw.name = fp->name; in iwi_get_firmware()
2299 device_printf(sc->sc_dev, "boot %d ucode %d fw %d bytes\n", in iwi_get_firmware()
2300 sc->fw_boot.size, sc->fw_uc.size, sc->fw_fw.size); in iwi_get_firmware()
2303 sc->fw_mode = opmode; in iwi_get_firmware()
2313 if (fw->fp != NULL) { in iwi_put_fw()
2314 firmware_put(fw->fp, FIRMWARE_UNLOAD); in iwi_put_fw()
2315 fw->fp = NULL; in iwi_put_fw()
2317 fw->data = NULL; in iwi_put_fw()
2318 fw->size = 0; in iwi_put_fw()
2319 fw->name = NULL; in iwi_put_fw()
2328 iwi_put_fw(&sc->fw_uc); in iwi_put_firmware()
2329 iwi_put_fw(&sc->fw_fw); in iwi_put_firmware()
2330 iwi_put_fw(&sc->fw_boot); in iwi_put_firmware()
2338 const char *uc = fw->data; in iwi_load_ucode()
2339 size_t size = fw->size; in iwi_load_ucode()
2352 device_printf(sc->sc_dev, "timeout waiting for master\n"); in iwi_load_ucode()
2376 for (w = (const uint16_t *)uc; size > 0; w++, size -= 2) in iwi_load_ucode()
2389 device_printf(sc->sc_dev, in iwi_load_ucode()
2418 memcpy(sc->fw_virtaddr, fw->data, fw->size); in iwi_load_firmware()
2420 /* make sure the adapter will get up-to-date values */ in iwi_load_firmware()
2421 bus_dmamap_sync(sc->fw_dmat, sc->fw_map, BUS_DMASYNC_PREWRITE); in iwi_load_firmware()
2431 src = sc->fw_physaddr; in iwi_load_firmware()
2432 p = sc->fw_virtaddr; in iwi_load_firmware()
2433 end = p + fw->size; in iwi_load_firmware()
2437 dst = GETLE32(p); p += 4; src += 4; in iwi_load_firmware()
2438 len = GETLE32(p); p += 4; src += 4; in iwi_load_firmware()
2455 len -= mlen; in iwi_load_firmware()
2477 bus_dmamap_sync(sc->fw_dmat, sc->fw_map, BUS_DMASYNC_POSTWRITE); in iwi_load_firmware()
2479 device_printf(sc->sc_dev, in iwi_load_firmware()
2481 fw->name); in iwi_load_firmware()
2498 if ((error = msleep(sc, &sc->sc_mtx, 0, "iwiinit", hz)) != 0) { in iwi_load_firmware()
2499 device_printf(sc->sc_dev, "timeout waiting for %s firmware " in iwi_load_firmware()
2500 "initialization to complete\n", fw->name); in iwi_load_firmware()
2511 if (vap->iv_flags & IEEE80211_F_PMGTON) { in iwi_setpowermode()
2512 /* XXX set more fine-grained operation */ in iwi_setpowermode()
2529 wk = &vap->iv_nw_keys[i]; in iwi_setwepkeys()
2533 wepkey.len = wk->wk_keylen; in iwi_setwepkeys()
2535 memcpy(wepkey.key, wk->wk_key, wk->wk_keylen); in iwi_setwepkeys()
2555 rs.nrates = net_rs->rs_nrates; in iwi_set_rateset()
2561 memcpy(rs.rates, net_rs->rs_rates, rs.nrates); in iwi_set_rateset()
2574 struct ieee80211com *ic = &sc->sc_ic; in iwi_config()
2575 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); in iwi_config()
2584 macaddr = vap ? vap->iv_myaddr : ic->ic_macaddr; in iwi_config()
2592 config.bluetooth_coexistence = sc->bluetooth; in iwi_config()
2594 config.antenna = sc->antenna; in iwi_config()
2596 config.answer_pbreq = (ic->ic_opmode == IEEE80211_M_IBSS) ? 1 : 0; in iwi_config()
2599 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in iwi_config()
2608 if (ic->ic_opmode == IEEE80211_M_IBSS) { in iwi_config()
2627 error = iwi_set_rateset(sc, &ic->ic_sup_rates[IEEE80211_MODE_11G], in iwi_config()
2632 error = iwi_set_rateset(sc, &ic->ic_sup_rates[IEEE80211_MODE_11A], in iwi_config()
2651 uint8_t *st = &scan->scan_type[ix / 2]; in set_scan_type()
2655 *st = (*st & 0x0f) | ((scan_type & 0xf) << 4); in set_scan_type()
2663 if (ss->ss_nssid != 0) in scan_type()
2665 if ((ss->ss_flags & IEEE80211_SCAN_ACTIVE) && in scan_type()
2666 (chan->ic_flags & IEEE80211_CHAN_PASSIVE) == 0) in scan_type()
2694 struct ieee80211com *ic = &sc->sc_ic; in iwi_scanchan()
2701 if (sc->fw_state == IWI_FW_SCANNING) { in iwi_scanchan()
2706 DPRINTF(("%s: called too early - still scanning\n", __func__)); in iwi_scanchan()
2711 ss = ic->ic_scan; in iwi_scanchan()
2714 scan.full_scan_index = htole32(++sc->sc_scangen); in iwi_scanchan()
2716 if (ic->ic_flags_ext & IEEE80211_FEXT_BGSCAN) { in iwi_scanchan()
2720 * be handled with early-termination as done by net80211 but in iwi_scanchan()
2731 if (ss->ss_nssid != 0) { in iwi_scanchan()
2732 error = iwi_cmd(sc, IWI_CMD_SET_ESSID, ss->ss_ssid[0].ssid, in iwi_scanchan()
2733 ss->ss_ssid[0].len); in iwi_scanchan()
2741 * Convert scan list to run-length encoded channel list in iwi_scanchan()
2748 band = -1; /* NB: impossible value */ in iwi_scanchan()
2749 KASSERT(ss->ss_last > 0, ("no channels")); in iwi_scanchan()
2750 for (i = 0; i < ss->ss_last; i++) { in iwi_scanchan()
2751 chan = ss->ss_chans[i]; in iwi_scanchan()
2754 if (band != -1) in iwi_scanchan()
2756 (next - bstart) | band; in iwi_scanchan()
2757 /* NB: this allocates a slot for the run-len */ in iwi_scanchan()
2768 scan.channels[bstart] = (next - bstart) | band; in iwi_scanchan()
2771 chan = ic->ic_curchan; in iwi_scanchan()
2793 run & IWI_CHAN_2GHZ ? "2.4GHz" : "5GHz"); in iwi_scanchan()
2794 for (run &= 0x3f, i++; run > 0; run--, i++) { in iwi_scanchan()
2797 scantype[(i & 1 ? type : type>>4) & 7]); in iwi_scanchan()
2822 struct ieee80211com *ic = vap->iv_ic; in iwi_auth_and_assoc()
2823 if_t ifp = vap->iv_ifp; in iwi_auth_and_assoc()
2826 struct iwi_associate *assoc = &sc->assoc; in iwi_auth_and_assoc()
2833 if (sc->flags & IWI_FLAG_ASSOCIATED) { in iwi_auth_and_assoc()
2835 return (-1); in iwi_auth_and_assoc()
2838 ni = ieee80211_ref_node(vap->iv_bss); in iwi_auth_and_assoc()
2844 if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) in iwi_auth_and_assoc()
2846 else if (IEEE80211_IS_CHAN_G(ic->ic_curchan)) in iwi_auth_and_assoc()
2848 if (IEEE80211_IS_CHAN_B(ic->ic_curchan)) in iwi_auth_and_assoc()
2851 if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) { in iwi_auth_and_assoc()
2853 config.bluetooth_coexistence = sc->bluetooth; in iwi_auth_and_assoc()
2854 config.antenna = sc->antenna; in iwi_auth_and_assoc()
2859 (vap->iv_opmode == IEEE80211_M_IBSS) ? 1 : 0; in iwi_auth_and_assoc()
2871 ieee80211_print_essid(ni->ni_essid, ni->ni_esslen); in iwi_auth_and_assoc()
2875 error = iwi_cmd(sc, IWI_CMD_SET_ESSID, ni->ni_essid, ni->ni_esslen); in iwi_auth_and_assoc()
2883 data = htole32(vap->iv_rtsthreshold); in iwi_auth_and_assoc()
2889 data = htole32(vap->iv_fragthreshold); in iwi_auth_and_assoc()
2896 error = iwi_set_rateset(sc, &ni->ni_rates, mode, in iwi_auth_and_assoc()
2903 if ((vap->iv_flags & IEEE80211_F_WME) && ni->ni_ies.wme_ie != NULL) { in iwi_auth_and_assoc()
2906 assoc->policy |= htole16(IWI_POLICY_WME); in iwi_auth_and_assoc()
2910 if (vap->iv_appie_wpa != NULL) { in iwi_auth_and_assoc()
2911 struct ieee80211_appie *ie = vap->iv_appie_wpa; in iwi_auth_and_assoc()
2913 DPRINTF(("Setting optional IE (len=%u)\n", ie->ie_len)); in iwi_auth_and_assoc()
2914 error = iwi_cmd(sc, IWI_CMD_SET_OPTIE, ie->ie_data, ie->ie_len); in iwi_auth_and_assoc()
2919 error = iwi_set_sensitivity(sc, ic->ic_node_getrssi(ni)); in iwi_auth_and_assoc()
2923 assoc->mode = mode; in iwi_auth_and_assoc()
2924 assoc->chan = ic->ic_curchan->ic_ieee; in iwi_auth_and_assoc()
2929 if ((vap->iv_flags & IEEE80211_F_PRIVACY) && in iwi_auth_and_assoc()
2930 ni->ni_authmode == IEEE80211_AUTH_SHARED) { in iwi_auth_and_assoc()
2931 assoc->auth = IWI_AUTH_SHARED; in iwi_auth_and_assoc()
2938 if (vap->iv_def_txkey != IEEE80211_KEYIX_NONE) in iwi_auth_and_assoc()
2939 assoc->auth |= vap->iv_def_txkey << 4; in iwi_auth_and_assoc()
2945 if (vap->iv_flags & IEEE80211_F_WPA) in iwi_auth_and_assoc()
2946 assoc->policy |= htole16(IWI_POLICY_WPA); in iwi_auth_and_assoc()
2947 if (vap->iv_opmode == IEEE80211_M_IBSS && ni->ni_tstamp.tsf == 0) in iwi_auth_and_assoc()
2948 assoc->type = IWI_HC_IBSS_START; in iwi_auth_and_assoc()
2950 assoc->type = IWI_HC_ASSOC; in iwi_auth_and_assoc()
2951 memcpy(assoc->tstamp, ni->ni_tstamp.data, 8); in iwi_auth_and_assoc()
2953 if (vap->iv_opmode == IEEE80211_M_IBSS) in iwi_auth_and_assoc()
2957 if (vap->iv_flags & IEEE80211_F_PRIVACY) in iwi_auth_and_assoc()
2959 if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && in iwi_auth_and_assoc()
2960 IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) in iwi_auth_and_assoc()
2962 if (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME) in iwi_auth_and_assoc()
2964 assoc->capinfo = htole16(capinfo); in iwi_auth_and_assoc()
2966 assoc->lintval = htole16(ic->ic_lintval); in iwi_auth_and_assoc()
2967 assoc->intval = htole16(ni->ni_intval); in iwi_auth_and_assoc()
2968 IEEE80211_ADDR_COPY(assoc->bssid, ni->ni_bssid); in iwi_auth_and_assoc()
2969 if (vap->iv_opmode == IEEE80211_M_IBSS) in iwi_auth_and_assoc()
2970 IEEE80211_ADDR_COPY(assoc->dst, if_getbroadcastaddr(ifp)); in iwi_auth_and_assoc()
2972 IEEE80211_ADDR_COPY(assoc->dst, ni->ni_bssid); in iwi_auth_and_assoc()
2976 assoc->type == IWI_HC_IBSS_START ? "Start" : "Join", in iwi_auth_and_assoc()
2977 assoc->bssid, ":", assoc->dst, ":", in iwi_auth_and_assoc()
2978 assoc->chan, le16toh(assoc->policy), assoc->auth, in iwi_auth_and_assoc()
2979 le16toh(assoc->capinfo), le16toh(assoc->lintval), in iwi_auth_and_assoc()
2980 le16toh(assoc->intval))); in iwi_auth_and_assoc()
3004 struct iwi_associate *assoc = &sc->assoc; in iwi_disassociate()
3006 if ((sc->flags & IWI_FLAG_ASSOCIATED) == 0) { in iwi_disassociate()
3008 return (-1); in iwi_disassociate()
3014 assoc->type = IWI_HC_DISASSOC_QUIET; in iwi_disassociate()
3016 assoc->type = IWI_HC_DISASSOC; in iwi_disassociate()
3019 assoc->bssid, ":", assoc->chan)); in iwi_disassociate()
3029 if (sc->fw_flags & IWI_FW_HAVE_PHY) in iwi_release_fw_dma()
3030 bus_dmamap_unload(sc->fw_dmat, sc->fw_map); in iwi_release_fw_dma()
3031 if (sc->fw_flags & IWI_FW_HAVE_MAP) in iwi_release_fw_dma()
3032 bus_dmamem_free(sc->fw_dmat, sc->fw_virtaddr, sc->fw_map); in iwi_release_fw_dma()
3033 if (sc->fw_flags & IWI_FW_HAVE_DMAT) in iwi_release_fw_dma()
3034 bus_dma_tag_destroy(sc->fw_dmat); in iwi_release_fw_dma()
3036 sc->fw_flags = 0; in iwi_release_fw_dma()
3037 sc->fw_dma_size = 0; in iwi_release_fw_dma()
3038 sc->fw_dmat = NULL; in iwi_release_fw_dma()
3039 sc->fw_map = NULL; in iwi_release_fw_dma()
3040 sc->fw_physaddr = 0; in iwi_release_fw_dma()
3041 sc->fw_virtaddr = NULL; in iwi_release_fw_dma()
3052 if (sc->fw_dma_size >= size) in iwi_init_fw_dma()
3054 if (bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 4, 0, in iwi_init_fw_dma()
3056 size, 1, size, 0, NULL, NULL, &sc->fw_dmat) != 0) { in iwi_init_fw_dma()
3057 device_printf(sc->sc_dev, in iwi_init_fw_dma()
3061 sc->fw_flags |= IWI_FW_HAVE_DMAT; in iwi_init_fw_dma()
3062 if (bus_dmamem_alloc(sc->fw_dmat, &sc->fw_virtaddr, 0, in iwi_init_fw_dma()
3063 &sc->fw_map) != 0) { in iwi_init_fw_dma()
3064 device_printf(sc->sc_dev, in iwi_init_fw_dma()
3068 sc->fw_flags |= IWI_FW_HAVE_MAP; in iwi_init_fw_dma()
3069 if (bus_dmamap_load(sc->fw_dmat, sc->fw_map, sc->fw_virtaddr, in iwi_init_fw_dma()
3070 size, iwi_dma_map_addr, &sc->fw_physaddr, 0) != 0) { in iwi_init_fw_dma()
3071 device_printf(sc->sc_dev, "could not load firmware DMA map\n"); in iwi_init_fw_dma()
3074 sc->fw_flags |= IWI_FW_HAVE_PHY; in iwi_init_fw_dma()
3075 sc->fw_dma_size = size; in iwi_init_fw_dma()
3091 if (sc->fw_state == IWI_FW_LOADING) { in iwi_init_locked()
3092 device_printf(sc->sc_dev, "%s: already loading\n", __func__); in iwi_init_locked()
3101 device_printf(sc->sc_dev, "could not reset adapter\n"); in iwi_init_locked()
3104 if (iwi_load_firmware(sc, &sc->fw_boot) != 0) { in iwi_init_locked()
3105 device_printf(sc->sc_dev, in iwi_init_locked()
3106 "could not load boot firmware %s\n", sc->fw_boot.name); in iwi_init_locked()
3109 if (iwi_load_ucode(sc, &sc->fw_uc) != 0) { in iwi_init_locked()
3110 device_printf(sc->sc_dev, in iwi_init_locked()
3111 "could not load microcode %s\n", sc->fw_uc.name); in iwi_init_locked()
3117 CSR_WRITE_4(sc, IWI_CSR_CMD_BASE, sc->cmdq.physaddr); in iwi_init_locked()
3118 CSR_WRITE_4(sc, IWI_CSR_CMD_SIZE, sc->cmdq.count); in iwi_init_locked()
3119 CSR_WRITE_4(sc, IWI_CSR_CMD_WIDX, sc->cmdq.cur); in iwi_init_locked()
3121 CSR_WRITE_4(sc, IWI_CSR_TX1_BASE, sc->txq[0].physaddr); in iwi_init_locked()
3122 CSR_WRITE_4(sc, IWI_CSR_TX1_SIZE, sc->txq[0].count); in iwi_init_locked()
3123 CSR_WRITE_4(sc, IWI_CSR_TX1_WIDX, sc->txq[0].cur); in iwi_init_locked()
3125 CSR_WRITE_4(sc, IWI_CSR_TX2_BASE, sc->txq[1].physaddr); in iwi_init_locked()
3126 CSR_WRITE_4(sc, IWI_CSR_TX2_SIZE, sc->txq[1].count); in iwi_init_locked()
3127 CSR_WRITE_4(sc, IWI_CSR_TX2_WIDX, sc->txq[1].cur); in iwi_init_locked()
3129 CSR_WRITE_4(sc, IWI_CSR_TX3_BASE, sc->txq[2].physaddr); in iwi_init_locked()
3130 CSR_WRITE_4(sc, IWI_CSR_TX3_SIZE, sc->txq[2].count); in iwi_init_locked()
3131 CSR_WRITE_4(sc, IWI_CSR_TX3_WIDX, sc->txq[2].cur); in iwi_init_locked()
3133 CSR_WRITE_4(sc, IWI_CSR_TX4_BASE, sc->txq[3].physaddr); in iwi_init_locked()
3134 CSR_WRITE_4(sc, IWI_CSR_TX4_SIZE, sc->txq[3].count); in iwi_init_locked()
3135 CSR_WRITE_4(sc, IWI_CSR_TX4_WIDX, sc->txq[3].cur); in iwi_init_locked()
3137 for (i = 0; i < sc->rxq.count; i++) { in iwi_init_locked()
3138 data = &sc->rxq.data[i]; in iwi_init_locked()
3139 CSR_WRITE_4(sc, data->reg, data->physaddr); in iwi_init_locked()
3142 CSR_WRITE_4(sc, IWI_CSR_RX_WIDX, sc->rxq.count - 1); in iwi_init_locked()
3144 if (iwi_load_firmware(sc, &sc->fw_fw) != 0) { in iwi_init_locked()
3145 device_printf(sc->sc_dev, in iwi_init_locked()
3146 "could not load main firmware %s\n", sc->fw_fw.name); in iwi_init_locked()
3149 sc->flags |= IWI_FLAG_FW_INITED; in iwi_init_locked()
3154 device_printf(sc->sc_dev, "unable to enable adapter\n"); in iwi_init_locked()
3158 callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc); in iwi_init_locked()
3159 sc->sc_running = 1; in iwi_init_locked()
3171 struct ieee80211com *ic = &sc->sc_ic; in iwi_init()
3178 if (sc->sc_running) in iwi_init()
3189 sc->sc_running = 0; in iwi_stop_locked()
3191 if (sc->sc_softled) { in iwi_stop_locked()
3192 callout_stop(&sc->sc_ledtimer); in iwi_stop_locked()
3193 sc->sc_blinking = 0; in iwi_stop_locked()
3195 callout_stop(&sc->sc_wdtimer); in iwi_stop_locked()
3196 callout_stop(&sc->sc_rftimer); in iwi_stop_locked()
3203 iwi_reset_cmd_ring(sc, &sc->cmdq); in iwi_stop_locked()
3204 iwi_reset_tx_ring(sc, &sc->txq[0]); in iwi_stop_locked()
3205 iwi_reset_tx_ring(sc, &sc->txq[1]); in iwi_stop_locked()
3206 iwi_reset_tx_ring(sc, &sc->txq[2]); in iwi_stop_locked()
3207 iwi_reset_tx_ring(sc, &sc->txq[3]); in iwi_stop_locked()
3208 iwi_reset_rx_ring(sc, &sc->rxq); in iwi_stop_locked()
3210 sc->sc_tx_timer = 0; in iwi_stop_locked()
3211 sc->sc_state_timer = 0; in iwi_stop_locked()
3212 sc->sc_busy_timer = 0; in iwi_stop_locked()
3213 sc->flags &= ~(IWI_FLAG_BUSY | IWI_FLAG_ASSOCIATED); in iwi_stop_locked()
3214 sc->fw_state = IWI_FW_IDLE; in iwi_stop_locked()
3250 struct ieee80211com *ic = &sc->sc_ic; in iwi_radio_on()
3252 device_printf(sc->sc_dev, "radio turned on\n"); in iwi_radio_on()
3271 ieee80211_runtask(&sc->sc_ic, &sc->sc_radiontask); in iwi_rfkill_poll()
3274 callout_reset(&sc->sc_rftimer, 2*hz, iwi_rfkill_poll, sc); in iwi_rfkill_poll()
3281 struct ieee80211com *ic = &sc->sc_ic; in iwi_radio_off()
3284 device_printf(sc->sc_dev, "radio turned off\n"); in iwi_radio_off()
3302 if (!(sc->flags & IWI_FLAG_FW_INITED)) in iwi_sysctl_stats()
3305 size = min(CSR_READ_4(sc, IWI_CSR_TABLE0_SIZE), 128 - 1); in iwi_sysctl_stats()
3326 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); in iwi_sysctlattach()
3327 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); in iwi_sysctlattach()
3338 sc->bluetooth = 0; in iwi_sysctlattach()
3340 CTLFLAG_RW, &sc->bluetooth, 0, "bluetooth coexistence"); in iwi_sysctlattach()
3342 sc->antenna = IWI_ANTENNA_AUTO; in iwi_sysctlattach()
3344 CTLFLAG_RW, &sc->antenna, 0, "antenna (0=auto)"); in iwi_sysctlattach()
3381 sc->sc_blinking = 0; in iwi_led_done()
3395 v &= ~sc->sc_ledpin; in iwi_led_off()
3397 callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, iwi_led_done, sc); in iwi_led_off()
3409 v |= sc->sc_ledpin; in iwi_led_blink()
3411 sc->sc_blinking = 1; in iwi_led_blink()
3412 sc->sc_ledoff = off; in iwi_led_blink()
3413 callout_reset(&sc->sc_ledtimer, on, iwi_led_off, sc); in iwi_led_blink()
3443 sc->sc_ledevent = ticks; /* time of last event */ in iwi_led_event()
3444 if (sc->sc_blinking) /* don't interrupt active blink */ in iwi_led_event()
3448 j = nitems(blinkrates)-1; in iwi_led_event()
3453 if (blinkrates[sc->sc_txrix].rate != txrate) { in iwi_led_event()
3454 for (j = 0; j < nitems(blinkrates)-1; j++) in iwi_led_event()
3457 sc->sc_txrix = j; in iwi_led_event()
3459 j = sc->sc_txrix; in iwi_led_event()
3462 if (blinkrates[sc->sc_rxrix].rate != sc->sc_rxrate) { in iwi_led_event()
3463 for (j = 0; j < nitems(blinkrates)-1; j++) in iwi_led_event()
3464 if (blinkrates[j].rate == sc->sc_rxrate) in iwi_led_event()
3466 sc->sc_rxrix = j; in iwi_led_event()
3468 j = sc->sc_rxrix; in iwi_led_event()
3480 int softled = sc->sc_softled; in iwi_sysctl_softled()
3484 if (error || !req->newptr) in iwi_sysctl_softled()
3487 if (softled != sc->sc_softled) { in iwi_sysctl_softled()
3490 v &= ~sc->sc_ledpin; in iwi_sysctl_softled()
3493 sc->sc_softled = softled; in iwi_sysctl_softled()
3501 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); in iwi_ledattach()
3502 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); in iwi_ledattach()
3504 sc->sc_blinking = 0; in iwi_ledattach()
3505 sc->sc_ledstate = 1; in iwi_ledattach()
3506 sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ in iwi_ledattach()
3507 callout_init_mtx(&sc->sc_ledtimer, &sc->sc_mtx, 0); in iwi_ledattach()
3513 "ledpin", CTLFLAG_RW, &sc->sc_ledpin, 0, in iwi_ledattach()
3516 "ledidle", CTLFLAG_RW, &sc->sc_ledidle, 0, in iwi_ledattach()
3520 "nictype", CTLFLAG_RD, &sc->sc_nictype, 0, in iwi_ledattach()
3523 sc->sc_ledpin = IWI_RST_LED_ACTIVITY; in iwi_ledattach()
3524 sc->sc_softled = 1; in iwi_ledattach()
3526 sc->sc_nictype = (iwi_read_prom_word(sc, IWI_EEPROM_NIC) >> 8) & 0xff; in iwi_ledattach()
3527 if (sc->sc_nictype == 1) { in iwi_ledattach()
3531 sc->sc_ledpin = IWI_RST_LED_ASSOCIATED; in iwi_ledattach()
3544 struct iwi_softc *sc = ic->ic_softc; in iwi_set_channel()
3546 if (sc->fw_state == IWI_FW_IDLE) in iwi_set_channel()
3547 iwi_setcurchan(sc, ic->ic_curchan->ic_ieee); in iwi_set_channel()
3553 struct ieee80211vap *vap = ss->ss_vap; in iwi_scan_curchan()
3554 struct iwi_softc *sc = vap->iv_ic->ic_softc; in iwi_scan_curchan()
3572 struct iwi_softc *sc = ic->ic_softc; in iwi_scan_end()
3576 sc->flags &= ~IWI_FLAG_CHANNEL_SCAN; in iwi_scan_end()
3578 if (sc->fw_state == IWI_FW_SCANNING) in iwi_scan_end()
3586 struct iwi_softc *sc = ic->ic_softc; in iwi_collect_bands()
3587 device_t dev = sc->sc_dev; in iwi_collect_bands()