Lines Matching refs:sc

182 static void	ath_txq_init(struct ath_softc *sc, struct ath_txq *, int);
187 static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq,
259 ath_legacy_attach_comp_func(struct ath_softc *sc) in ath_legacy_attach_comp_func() argument
267 switch (sc->sc_txqsetup &~ (1<<sc->sc_cabq->axq_qnum)) { in ath_legacy_attach_comp_func()
269 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc); in ath_legacy_attach_comp_func()
272 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc); in ath_legacy_attach_comp_func()
275 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc); in ath_legacy_attach_comp_func()
289 _ath_power_setpower(struct ath_softc *sc, int power_state, const char *file, int line) in _ath_power_setpower() argument
291 ATH_LOCK_ASSERT(sc); in _ath_power_setpower()
293 sc->sc_target_powerstate = power_state; in _ath_power_setpower()
295 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n", in _ath_power_setpower()
300 sc->sc_powersave_refcnt); in _ath_power_setpower()
302 if (sc->sc_powersave_refcnt == 0 && in _ath_power_setpower()
303 power_state != sc->sc_cur_powerstate) { in _ath_power_setpower()
304 sc->sc_cur_powerstate = power_state; in _ath_power_setpower()
305 ath_hal_setpower(sc->sc_ah, power_state); in _ath_power_setpower()
315 if (sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_setpower()
316 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_setpower()
317 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_setpower()
318 sc->sc_target_selfgen_state); in _ath_power_setpower()
332 _ath_power_set_selfgen(struct ath_softc *sc, int power_state, const char *file, int line) in _ath_power_set_selfgen() argument
335 ATH_LOCK_ASSERT(sc); in _ath_power_set_selfgen()
337 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n", in _ath_power_set_selfgen()
342 sc->sc_target_selfgen_state); in _ath_power_set_selfgen()
344 sc->sc_target_selfgen_state = power_state; in _ath_power_set_selfgen()
353 if (sc->sc_cur_powerstate == HAL_PM_AWAKE) { in _ath_power_set_selfgen()
354 ath_hal_setselfgenpower(sc->sc_ah, power_state); in _ath_power_set_selfgen()
368 _ath_power_set_power_state(struct ath_softc *sc, int power_state, const char *file, int line) in _ath_power_set_power_state() argument
370 ATH_LOCK_ASSERT(sc); in _ath_power_set_power_state()
372 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n", in _ath_power_set_power_state()
377 sc->sc_powersave_refcnt); in _ath_power_set_power_state()
379 sc->sc_powersave_refcnt++; in _ath_power_set_power_state()
381 if (power_state != sc->sc_cur_powerstate) { in _ath_power_set_power_state()
382 ath_hal_setpower(sc->sc_ah, power_state); in _ath_power_set_power_state()
383 sc->sc_cur_powerstate = power_state; in _ath_power_set_power_state()
388 if (sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_set_power_state()
389 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_set_power_state()
390 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_set_power_state()
391 sc->sc_target_selfgen_state); in _ath_power_set_power_state()
404 _ath_power_restore_power_state(struct ath_softc *sc, const char *file, int line) in _ath_power_restore_power_state() argument
407 ATH_LOCK_ASSERT(sc); in _ath_power_restore_power_state()
409 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) refcnt=%d, target state=%d\n", in _ath_power_restore_power_state()
413 sc->sc_powersave_refcnt, in _ath_power_restore_power_state()
414 sc->sc_target_powerstate); in _ath_power_restore_power_state()
416 if (sc->sc_powersave_refcnt == 0) in _ath_power_restore_power_state()
417 device_printf(sc->sc_dev, "%s: refcnt=0?\n", __func__); in _ath_power_restore_power_state()
419 sc->sc_powersave_refcnt--; in _ath_power_restore_power_state()
421 if (sc->sc_powersave_refcnt == 0 && in _ath_power_restore_power_state()
422 sc->sc_target_powerstate != sc->sc_cur_powerstate) { in _ath_power_restore_power_state()
423 sc->sc_cur_powerstate = sc->sc_target_powerstate; in _ath_power_restore_power_state()
424 ath_hal_setpower(sc->sc_ah, sc->sc_target_powerstate); in _ath_power_restore_power_state()
430 if (sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_restore_power_state()
431 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_restore_power_state()
432 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_restore_power_state()
433 sc->sc_target_selfgen_state); in _ath_power_restore_power_state()
450 ath_setup_hal_config(struct ath_softc *sc, HAL_OPS_CONFIG *ah_config) in ath_setup_hal_config() argument
454 if (sc->sc_pci_devinfo & (ATH_PCI_CUS198 | ATH_PCI_CUS230)) { in ath_setup_hal_config()
461 device_printf(sc->sc_dev, "configuring for %s\n", in ath_setup_hal_config()
462 (sc->sc_pci_devinfo & ATH_PCI_CUS198) ? in ath_setup_hal_config()
466 if (sc->sc_pci_devinfo & ATH_PCI_CUS217) in ath_setup_hal_config()
467 device_printf(sc->sc_dev, "CUS217 card detected\n"); in ath_setup_hal_config()
469 if (sc->sc_pci_devinfo & ATH_PCI_CUS252) in ath_setup_hal_config()
470 device_printf(sc->sc_dev, "CUS252 card detected\n"); in ath_setup_hal_config()
472 if (sc->sc_pci_devinfo & ATH_PCI_AR9565_1ANT) in ath_setup_hal_config()
473 device_printf(sc->sc_dev, "WB335 1-ANT card detected\n"); in ath_setup_hal_config()
475 if (sc->sc_pci_devinfo & ATH_PCI_AR9565_2ANT) in ath_setup_hal_config()
476 device_printf(sc->sc_dev, "WB335 2-ANT card detected\n"); in ath_setup_hal_config()
478 if (sc->sc_pci_devinfo & ATH_PCI_KILLER) in ath_setup_hal_config()
479 device_printf(sc->sc_dev, "Killer Wireless card detected\n"); in ath_setup_hal_config()
488 if (sc->sc_pci_devinfo & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { in ath_setup_hal_config()
489 if (!(sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV)) in ath_setup_hal_config()
493 if (sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV) { in ath_setup_hal_config()
495 device_printf(sc->sc_dev, "Set BT/WLAN RX diversity capability\n"); in ath_setup_hal_config()
499 if (sc->sc_pci_devinfo & ATH_PCI_D3_L1_WAR) { in ath_setup_hal_config()
501 device_printf(sc->sc_dev, "Enable WAR for ASPM D3/L1\n"); in ath_setup_hal_config()
505 if (sc->sc_pci_devinfo & ATH9K_PCI_NO_PLL_PWRSAVE) { in ath_setup_hal_config()
507 device_printf(sc->sc_dev, "Disable PLL PowerSave\n"); in ath_setup_hal_config()
519 ath_fetch_mac_kenv(struct ath_softc *sc, uint8_t *macaddr) in ath_fetch_mac_kenv() argument
533 device_get_name(sc->sc_dev), in ath_fetch_mac_kenv()
534 device_get_unit(sc->sc_dev)); in ath_fetch_mac_kenv()
542 device_printf(sc->sc_dev, in ath_fetch_mac_kenv()
572 ath_attach(u_int16_t devid, struct ath_softc *sc) in ath_attach() argument
574 struct ieee80211com *ic = &sc->sc_ic; in ath_attach()
582 DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); in ath_attach()
584 ic->ic_softc = sc; in ath_attach()
585 ic->ic_name = device_get_nameunit(sc->sc_dev); in ath_attach()
594 ath_setup_hal_config(sc, &ah_config); in ath_attach()
596 ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, in ath_attach()
597 sc->sc_eepromdata, &ah_config, &status); in ath_attach()
599 device_printf(sc->sc_dev, in ath_attach()
604 sc->sc_ah = ah; in ath_attach()
605 sc->sc_invalid = 0; /* ready to go, enable interrupt handling */ in ath_attach()
607 sc->sc_debug = ath_debug; in ath_attach()
616 if (ath_hal_hasedma(sc->sc_ah)) { in ath_attach()
617 sc->sc_isedma = 1; in ath_attach()
618 ath_recv_setup_edma(sc); in ath_attach()
619 ath_xmit_setup_edma(sc); in ath_attach()
621 ath_recv_setup_legacy(sc); in ath_attach()
622 ath_xmit_setup_legacy(sc); in ath_attach()
625 if (ath_hal_hasmybeacon(sc->sc_ah)) { in ath_attach()
626 sc->sc_do_mybeacon = 1; in ath_attach()
636 sc->sc_mrretry = ath_hal_setupxtxdesc(ah, NULL, 0,0, 0,0, 0,0); in ath_attach()
644 sc->sc_needmib = 1; in ath_attach()
649 sc->sc_keymax = ath_hal_keycachesize(ah); in ath_attach()
650 if (sc->sc_keymax > ATH_KEYMAX) { in ath_attach()
651 device_printf(sc->sc_dev, in ath_attach()
653 ATH_KEYMAX, sc->sc_keymax); in ath_attach()
654 sc->sc_keymax = ATH_KEYMAX; in ath_attach()
660 for (i = 0; i < sc->sc_keymax; i++) in ath_attach()
666 error = ath_getchannels(sc); in ath_attach()
673 ath_rate_setup(sc, IEEE80211_MODE_11A); in ath_attach()
674 ath_rate_setup(sc, IEEE80211_MODE_11B); in ath_attach()
675 ath_rate_setup(sc, IEEE80211_MODE_11G); in ath_attach()
676 ath_rate_setup(sc, IEEE80211_MODE_TURBO_A); in ath_attach()
677 ath_rate_setup(sc, IEEE80211_MODE_TURBO_G); in ath_attach()
678 ath_rate_setup(sc, IEEE80211_MODE_STURBO_A); in ath_attach()
679 ath_rate_setup(sc, IEEE80211_MODE_11NA); in ath_attach()
680 ath_rate_setup(sc, IEEE80211_MODE_11NG); in ath_attach()
681 ath_rate_setup(sc, IEEE80211_MODE_HALF); in ath_attach()
682 ath_rate_setup(sc, IEEE80211_MODE_QUARTER); in ath_attach()
685 ath_setcurmode(sc, IEEE80211_MODE_11A); in ath_attach()
690 error = ath_desc_alloc(sc); in ath_attach()
692 device_printf(sc->sc_dev, in ath_attach()
696 error = ath_txdma_setup(sc); in ath_attach()
698 device_printf(sc->sc_dev, in ath_attach()
706 error = ath_rxdma_setup(sc); in ath_attach()
708 device_printf(sc->sc_dev, in ath_attach()
713 callout_init_mtx(&sc->sc_cal_ch, &sc->sc_mtx, 0); in ath_attach()
714 callout_init_mtx(&sc->sc_wd_ch, &sc->sc_mtx, 0); in ath_attach()
716 ATH_TXBUF_LOCK_INIT(sc); in ath_attach()
718 sc->sc_tq = taskqueue_create("ath_taskq", M_NOWAIT, in ath_attach()
719 taskqueue_thread_enqueue, &sc->sc_tq); in ath_attach()
720 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", in ath_attach()
721 device_get_nameunit(sc->sc_dev)); in ath_attach()
723 TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); in ath_attach()
724 TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); in ath_attach()
725 TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); in ath_attach()
726 TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc); in ath_attach()
727 TASK_INIT(&sc->sc_txqtask, 0, ath_txq_sched_tasklet, sc); in ath_attach()
728 TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc); in ath_attach()
738 sc->sc_bhalq = ath_beaconq_setup(sc); in ath_attach()
739 if (sc->sc_bhalq == (u_int) -1) { in ath_attach()
740 device_printf(sc->sc_dev, in ath_attach()
745 sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0); in ath_attach()
746 if (sc->sc_cabq == NULL) { in ath_attach()
747 device_printf(sc->sc_dev, "unable to setup CAB xmit queue!\n"); in ath_attach()
752 if (!ath_tx_setup(sc, WME_AC_BK, HAL_WME_AC_BK)) { in ath_attach()
753 device_printf(sc->sc_dev, in ath_attach()
759 if (!ath_tx_setup(sc, WME_AC_BE, HAL_WME_AC_BE) || in ath_attach()
760 !ath_tx_setup(sc, WME_AC_VI, HAL_WME_AC_VI) || in ath_attach()
761 !ath_tx_setup(sc, WME_AC_VO, HAL_WME_AC_VO)) { in ath_attach()
769 if (sc->sc_ac2q[WME_AC_VI] != NULL) in ath_attach()
770 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]); in ath_attach()
771 if (sc->sc_ac2q[WME_AC_BE] != NULL) in ath_attach()
772 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]); in ath_attach()
773 sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
774 sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
775 sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
784 sc->sc_tx.xmit_attach_comp_func(sc); in ath_attach()
792 sc->sc_setdefantenna = ath_setdefantenna; in ath_attach()
793 sc->sc_rc = ath_rate_attach(sc); in ath_attach()
794 if (sc->sc_rc == NULL) { in ath_attach()
800 if (! ath_dfs_attach(sc)) { in ath_attach()
801 device_printf(sc->sc_dev, in ath_attach()
808 if (ath_spectral_attach(sc) < 0) { in ath_attach()
809 device_printf(sc->sc_dev, in ath_attach()
816 if (ath_btcoex_attach(sc) < 0) { in ath_attach()
817 device_printf(sc->sc_dev, in ath_attach()
824 if (ath_lna_div_attach(sc) < 0) { in ath_attach()
825 device_printf(sc->sc_dev, in ath_attach()
832 TASK_INIT(&sc->sc_dfstask, 0, ath_dfs_tasklet, sc); in ath_attach()
835 sc->sc_blinking = 0; in ath_attach()
836 sc->sc_ledstate = 1; in ath_attach()
837 sc->sc_ledon = 0; /* low true */ in ath_attach()
838 sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ in ath_attach()
839 callout_init(&sc->sc_ledtimer, 1); in ath_attach()
852 sc->sc_hardled = (1 == 0); in ath_attach()
853 sc->sc_led_net_pin = -1; in ath_attach()
854 sc->sc_led_pwr_pin = -1; in ath_attach()
860 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); in ath_attach()
861 ath_led_config(sc); in ath_attach()
914 sc->sc_splitmic = 1; in ath_attach()
921 sc->sc_wmetkipmic = 1; in ath_attach()
923 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR); in ath_attach()
927 if (ath_hal_hasmcastkeysearch(sc->sc_ah) && in ath_attach()
928 !ath_hal_getmcastkeysearch(sc->sc_ah)) { in ath_attach()
929 ath_hal_setmcastkeysearch(sc->sc_ah, 1); in ath_attach()
931 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); in ath_attach()
938 setbit(sc->sc_keymap, i); in ath_attach()
939 setbit(sc->sc_keymap, i+64); in ath_attach()
940 if (sc->sc_splitmic) { in ath_attach()
941 setbit(sc->sc_keymap, i+32); in ath_attach()
942 setbit(sc->sc_keymap, i+32+64); in ath_attach()
958 if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK]) in ath_attach()
965 sc->sc_hasbmask = ath_hal_hasbssidmask(ah); in ath_attach()
966 sc->sc_hasbmatch = ath_hal_hasbssidmatch(ah); in ath_attach()
967 sc->sc_hastsfadd = ath_hal_hastsfadjust(ah); in ath_attach()
968 sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah); in ath_attach()
969 sc->sc_rxtsf32 = ath_hal_has_long_rxdesc_tsf(ah); in ath_attach()
970 sc->sc_hasenforcetxop = ath_hal_hasenforcetxop(ah); in ath_attach()
971 sc->sc_rx_lnamixer = ath_hal_hasrxlnamixer(ah); in ath_attach()
972 sc->sc_hasdivcomb = ath_hal_hasdivantcomb(ah); in ath_attach()
991 sc->sc_txq_data_minfree = 10; in ath_attach()
997 sc->sc_txq_mcastq_maxdepth = ath_txbuf; in ath_attach()
1002 sc->sc_txq_node_psq_maxdepth = 16; in ath_attach()
1009 sc->sc_txq_node_maxdepth = MAX(64, ath_txbuf / 4); in ath_attach()
1012 sc->sc_cabq_enable = 1; in ath_attach()
1022 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1023 device_get_unit(sc->sc_dev), "rx_chainmask", in ath_attach()
1025 device_printf(sc->sc_dev, "Setting RX chainmask to 0x%x\n", in ath_attach()
1027 (void) ath_hal_setrxchainmask(sc->sc_ah, rx_chainmask); in ath_attach()
1029 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1030 device_get_unit(sc->sc_dev), "tx_chainmask", in ath_attach()
1032 device_printf(sc->sc_dev, "Setting TX chainmask to 0x%x\n", in ath_attach()
1034 (void) ath_hal_settxchainmask(sc->sc_ah, tx_chainmask); in ath_attach()
1042 ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask); in ath_attach()
1043 ath_hal_gettxchainmask(ah, &sc->sc_txchainmask); in ath_attach()
1049 sc->sc_mrrprot = 0; /* XXX should be a capability */ in ath_attach()
1055 &sc->sc_ent_cfg) == HAL_OK) in ath_attach()
1056 sc->sc_use_ent = 1; in ath_attach()
1066 device_printf(sc->sc_dev, "[HT] enabling HT modes\n"); in ath_attach()
1068 sc->sc_mrrprot = 1; /* XXX should be a capability */ in ath_attach()
1086 device_printf(sc->sc_dev, in ath_attach()
1114 sc->sc_rx_stbc = 1; in ath_attach()
1115 device_printf(sc->sc_dev, in ath_attach()
1121 sc->sc_tx_stbc = 1; in ath_attach()
1122 device_printf(sc->sc_dev, in ath_attach()
1128 &sc->sc_rts_aggr_limit); in ath_attach()
1129 if (sc->sc_rts_aggr_limit != (64 * 1024)) in ath_attach()
1130 device_printf(sc->sc_dev, in ath_attach()
1132 sc->sc_rts_aggr_limit / 1024); in ath_attach()
1134 device_printf(sc->sc_dev, in ath_attach()
1142 sc->sc_hwq_limit_aggr = ATH_AGGR_MIN_QDEPTH; in ath_attach()
1143 sc->sc_hwq_limit_nonaggr = ATH_NONAGGR_MIN_QDEPTH; in ath_attach()
1144 sc->sc_tid_hwq_lo = ATH_AGGR_SCHED_LOW; in ath_attach()
1145 sc->sc_tid_hwq_hi = ATH_AGGR_SCHED_HIGH; in ath_attach()
1146 sc->sc_aggr_limit = ATH_AGGR_MAXSIZE; in ath_attach()
1147 sc->sc_delim_min_pad = 0; in ath_attach()
1156 sc->sc_ah->ah_config.ah_serialise_reg_war = 1; in ath_attach()
1157 device_printf(sc->sc_dev, in ath_attach()
1164 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_HP]); in ath_attach()
1165 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_LP]); in ath_attach()
1176 sc->sc_defant = ath_hal_getdefantenna(ah); in ath_attach()
1182 sc->sc_hasveol = ath_hal_hasveol(ah); in ath_attach()
1185 if (ath_fetch_mac_kenv(sc, ic->ic_macaddr) == 0) { in ath_attach()
1192 if (sc->sc_hasbmask) in ath_attach()
1193 ath_hal_getbssidmask(ah, sc->sc_hwbssidmask); in ath_attach()
1196 ic->ic_max_keyix = sc->sc_keymax; in ath_attach()
1201 sc->sc_opmode = HAL_M_STA; in ath_attach()
1216 sc->sc_node_free = ic->ic_node_free; in ath_attach()
1218 sc->sc_node_cleanup = ic->ic_node_cleanup; in ath_attach()
1226 sc->sc_addba_request = ic->ic_addba_request; in ath_attach()
1227 sc->sc_addba_response = ic->ic_addba_response; in ath_attach()
1228 sc->sc_addba_stop = ic->ic_addba_stop; in ath_attach()
1229 sc->sc_bar_response = ic->ic_bar_response; in ath_attach()
1230 sc->sc_addba_response_timeout = ic->ic_addba_response_timeout; in ath_attach()
1247 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 0, in ath_attach()
1249 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 1, in ath_attach()
1256 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), in ath_attach()
1258 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), in ath_attach()
1266 if_ath_alq_init(&sc->sc_alq, device_get_nameunit(sc->sc_dev)); in ath_attach()
1267 if_ath_alq_setcfg(&sc->sc_alq, in ath_attach()
1268 sc->sc_ah->ah_macVersion, in ath_attach()
1269 sc->sc_ah->ah_macRev, in ath_attach()
1270 sc->sc_ah->ah_phyRev, in ath_attach()
1271 sc->sc_ah->ah_magic); in ath_attach()
1278 ath_sysctlattach(sc); in ath_attach()
1279 ath_sysctl_stats_attach(sc); in ath_attach()
1280 ath_sysctl_hal_attach(sc); in ath_attach()
1284 ath_announce(sc); in ath_attach()
1289 ATH_LOCK(sc); in ath_attach()
1290 ath_power_setpower(sc, HAL_PM_FULL_SLEEP); in ath_attach()
1291 ATH_UNLOCK(sc); in ath_attach()
1295 ath_tx_cleanup(sc); in ath_attach()
1296 ath_desc_free(sc); in ath_attach()
1297 ath_txdma_teardown(sc); in ath_attach()
1298 ath_rxdma_teardown(sc); in ath_attach()
1302 sc->sc_invalid = 1; in ath_attach()
1307 ath_detach(struct ath_softc *sc) in ath_detach() argument
1330 ATH_LOCK(sc); in ath_detach()
1331 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_detach()
1332 ath_power_setpower(sc, HAL_PM_AWAKE); in ath_detach()
1337 ath_stop(sc); in ath_detach()
1338 ATH_UNLOCK(sc); in ath_detach()
1340 ieee80211_ifdetach(&sc->sc_ic); in ath_detach()
1341 taskqueue_free(sc->sc_tq); in ath_detach()
1343 if (sc->sc_tx99 != NULL) in ath_detach()
1344 sc->sc_tx99->detach(sc->sc_tx99); in ath_detach()
1346 ath_rate_detach(sc->sc_rc); in ath_detach()
1348 if_ath_alq_tidyup(&sc->sc_alq); in ath_detach()
1350 ath_lna_div_detach(sc); in ath_detach()
1351 ath_btcoex_detach(sc); in ath_detach()
1352 ath_spectral_detach(sc); in ath_detach()
1353 ath_dfs_detach(sc); in ath_detach()
1354 ath_desc_free(sc); in ath_detach()
1355 ath_txdma_teardown(sc); in ath_detach()
1356 ath_rxdma_teardown(sc); in ath_detach()
1357 ath_tx_cleanup(sc); in ath_detach()
1358 ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ in ath_detach()
1370 assign_address(struct ath_softc *sc, uint8_t mac[IEEE80211_ADDR_LEN], int clone) in assign_address() argument
1374 if (clone && sc->sc_hasbmask) { in assign_address()
1377 if ((sc->sc_bssidmask & (1<<i)) == 0) in assign_address()
1383 sc->sc_bssidmask |= 1<<i; in assign_address()
1384 sc->sc_hwbssidmask[0] &= ~mac[0]; in assign_address()
1386 sc->sc_nbssid0++; in assign_address()
1390 reclaim_address(struct ath_softc *sc, const uint8_t mac[IEEE80211_ADDR_LEN]) in reclaim_address() argument
1395 if (i != 0 || --sc->sc_nbssid0 == 0) { in reclaim_address()
1396 sc->sc_bssidmask &= ~(1<<i); in reclaim_address()
1400 if (sc->sc_bssidmask & (1<<i)) in reclaim_address()
1402 sc->sc_hwbssidmask[0] |= mask; in reclaim_address()
1413 assign_bslot(struct ath_softc *sc) in assign_bslot() argument
1419 if (sc->sc_bslot[slot] == NULL) { in assign_bslot()
1420 if (sc->sc_bslot[(slot+1)%ATH_BCBUF] == NULL && in assign_bslot()
1421 sc->sc_bslot[(slot-1)%ATH_BCBUF] == NULL) in assign_bslot()
1435 struct ath_softc *sc = ic->ic_softc; in ath_vap_create() local
1446 ATH_LOCK(sc); in ath_vap_create()
1450 if (sc->sc_nstavaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1451 device_printf(sc->sc_dev, "only 1 sta vap supported\n"); in ath_vap_create()
1454 if (sc->sc_nvaps) { in ath_vap_create()
1469 if (sc->sc_nvaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1470 device_printf(sc->sc_dev, in ath_vap_create()
1479 if (sc->sc_nvaps != 0) { in ath_vap_create()
1480 device_printf(sc->sc_dev, in ath_vap_create()
1490 if (sc->sc_nvaps != 0 && ic->ic_opmode != opmode) { in ath_vap_create()
1505 if (sc->sc_nvaps != 0 && ic->ic_opmode == IEEE80211_M_STA) { in ath_vap_create()
1506 device_printf(sc->sc_dev, in ath_vap_create()
1516 if (sc->sc_nvaps == 0) in ath_vap_create()
1522 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in ath_vap_create()
1528 if (needbeacon & TAILQ_EMPTY(&sc->sc_bbuf)) { in ath_vap_create()
1529 device_printf(sc->sc_dev, "no beacon buffer available\n"); in ath_vap_create()
1535 assign_address(sc, mac, flags & IEEE80211_CLONE_BSSID); in ath_vap_create()
1536 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1541 ATH_UNLOCK(sc); in ath_vap_create()
1543 ATH_LOCK(sc); in ath_vap_create()
1545 device_printf(sc->sc_dev, "%s: error %d creating vap\n", in ath_vap_create()
1598 avp->av_bcbuf = TAILQ_FIRST(&sc->sc_bbuf); in ath_vap_create()
1599 TAILQ_REMOVE(&sc->sc_bbuf, avp->av_bcbuf, bf_list); in ath_vap_create()
1600 if (opmode != IEEE80211_M_IBSS || !sc->sc_hasveol) { in ath_vap_create()
1605 avp->av_bslot = assign_bslot(sc); in ath_vap_create()
1606 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL, in ath_vap_create()
1608 sc->sc_bslot[avp->av_bslot] = vap; in ath_vap_create()
1609 sc->sc_nbcnvaps++; in ath_vap_create()
1611 if (sc->sc_hastsfadd && sc->sc_nbcnvaps > 0) { in ath_vap_create()
1617 sc->sc_stagbeacons = 1; in ath_vap_create()
1619 ath_txq_init(sc, &avp->av_mcastq, ATH_TXQ_SWQ); in ath_vap_create()
1624 sc->sc_nvaps++; in ath_vap_create()
1626 sc->sc_nstavaps++; in ath_vap_create()
1628 sc->sc_nmeshvaps++; in ath_vap_create()
1632 sc->sc_opmode = HAL_M_IBSS; in ath_vap_create()
1635 sc->sc_opmode = HAL_M_STA; in ath_vap_create()
1640 sc->sc_tdma = 1; in ath_vap_create()
1642 sc->sc_stagbeacons = 0; in ath_vap_create()
1652 sc->sc_opmode = HAL_M_HOSTAP; in ath_vap_create()
1655 sc->sc_opmode = HAL_M_MONITOR; in ath_vap_create()
1661 if (sc->sc_hastsfadd) { in ath_vap_create()
1665 ath_hal_settsfadjust(sc->sc_ah, sc->sc_stagbeacons); in ath_vap_create()
1671 sc->sc_swbmiss = 1; in ath_vap_create()
1673 ATH_UNLOCK(sc); in ath_vap_create()
1680 reclaim_address(sc, mac); in ath_vap_create()
1681 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1684 ATH_UNLOCK(sc); in ath_vap_create()
1692 struct ath_softc *sc = ic->ic_softc; in ath_vap_delete() local
1693 struct ath_hal *ah = sc->sc_ah; in ath_vap_delete()
1696 ATH_LOCK(sc); in ath_vap_delete()
1697 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_vap_delete()
1698 ATH_UNLOCK(sc); in ath_vap_delete()
1700 DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); in ath_vap_delete()
1701 if (sc->sc_running) { in ath_vap_delete()
1709 ath_stoprecv(sc, 1); /* stop recv side */ in ath_vap_delete()
1710 ath_draintxq(sc, ATH_RESET_DEFAULT); /* stop hw xmit side */ in ath_vap_delete()
1734 ath_draintxq(sc, ATH_RESET_DEFAULT); in ath_vap_delete()
1736 ATH_LOCK(sc); in ath_vap_delete()
1744 sc->sc_bslot[avp->av_bslot] = NULL; in ath_vap_delete()
1745 sc->sc_nbcnvaps--; in ath_vap_delete()
1747 ath_beacon_return(sc, avp->av_bcbuf); in ath_vap_delete()
1749 if (sc->sc_nbcnvaps == 0) { in ath_vap_delete()
1750 sc->sc_stagbeacons = 0; in ath_vap_delete()
1751 if (sc->sc_hastsfadd) in ath_vap_delete()
1752 ath_hal_settsfadjust(sc->sc_ah, 0); in ath_vap_delete()
1757 ath_tx_draintxq(sc, &avp->av_mcastq); in ath_vap_delete()
1763 sc->sc_nstavaps--; in ath_vap_delete()
1764 if (sc->sc_nstavaps == 0 && sc->sc_swbmiss) in ath_vap_delete()
1765 sc->sc_swbmiss = 0; in ath_vap_delete()
1768 reclaim_address(sc, vap->iv_myaddr); in ath_vap_delete()
1769 ath_hal_setbssidmask(ah, sc->sc_hwbssidmask); in ath_vap_delete()
1771 sc->sc_nmeshvaps--; in ath_vap_delete()
1774 sc->sc_nvaps--; in ath_vap_delete()
1777 if (sc->sc_tdma && sc->sc_nvaps == 0) { in ath_vap_delete()
1778 sc->sc_tdma = 0; in ath_vap_delete()
1779 sc->sc_swbmiss = 0; in ath_vap_delete()
1784 if (sc->sc_running) { in ath_vap_delete()
1789 if (ath_startrecv(sc) != 0) in ath_vap_delete()
1790 device_printf(sc->sc_dev, in ath_vap_delete()
1792 if (sc->sc_beacons) { /* restart beacons */ in ath_vap_delete()
1794 if (sc->sc_tdma) in ath_vap_delete()
1795 ath_tdma_config(sc, NULL); in ath_vap_delete()
1798 ath_beacon_config(sc, NULL); in ath_vap_delete()
1800 ath_hal_intrset(ah, sc->sc_imask); in ath_vap_delete()
1804 ath_power_restore_power_state(sc); in ath_vap_delete()
1805 ATH_UNLOCK(sc); in ath_vap_delete()
1809 ath_suspend(struct ath_softc *sc) in ath_suspend() argument
1811 struct ieee80211com *ic = &sc->sc_ic; in ath_suspend()
1813 sc->sc_resume_up = ic->ic_nrunning != 0; in ath_suspend()
1830 ath_hal_intrset(sc->sc_ah, 0); in ath_suspend()
1831 taskqueue_block(sc->sc_tq); in ath_suspend()
1833 ATH_LOCK(sc); in ath_suspend()
1834 callout_stop(&sc->sc_cal_ch); in ath_suspend()
1835 ATH_UNLOCK(sc); in ath_suspend()
1842 ath_hal_enablepcie(sc->sc_ah, 1, 1); in ath_suspend()
1852 ath_reset_keycache(struct ath_softc *sc) in ath_reset_keycache() argument
1854 struct ieee80211com *ic = &sc->sc_ic; in ath_reset_keycache()
1855 struct ath_hal *ah = sc->sc_ah; in ath_reset_keycache()
1858 ATH_LOCK(sc); in ath_reset_keycache()
1859 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_reset_keycache()
1860 for (i = 0; i < sc->sc_keymax; i++) in ath_reset_keycache()
1862 ath_power_restore_power_state(sc); in ath_reset_keycache()
1863 ATH_UNLOCK(sc); in ath_reset_keycache()
1872 ath_update_chainmasks(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_update_chainmasks() argument
1879 sc->sc_cur_rxchainmask = sc->sc_rxchainmask; in ath_update_chainmasks()
1881 sc->sc_cur_txchainmask = sc->sc_txchainmask; in ath_update_chainmasks()
1883 sc->sc_cur_txchainmask = 1; in ath_update_chainmasks()
1886 DPRINTF(sc, ATH_DEBUG_RESET, in ath_update_chainmasks()
1889 sc->sc_cur_txchainmask, in ath_update_chainmasks()
1890 sc->sc_cur_rxchainmask); in ath_update_chainmasks()
1894 ath_resume(struct ath_softc *sc) in ath_resume() argument
1896 struct ieee80211com *ic = &sc->sc_ic; in ath_resume()
1897 struct ath_hal *ah = sc->sc_ah; in ath_resume()
1906 ath_update_chainmasks(sc, in ath_resume()
1907 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan); in ath_resume()
1908 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_resume()
1909 sc->sc_cur_rxchainmask); in ath_resume()
1912 ATH_LOCK(sc); in ath_resume()
1913 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_resume()
1914 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_resume()
1915 ath_power_setpower(sc, HAL_PM_AWAKE); in ath_resume()
1916 ATH_UNLOCK(sc); in ath_resume()
1918 ath_hal_reset(ah, sc->sc_opmode, in ath_resume()
1919 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan, in ath_resume()
1921 ath_reset_keycache(sc); in ath_resume()
1923 ATH_RX_LOCK(sc); in ath_resume()
1924 sc->sc_rx_stopped = 1; in ath_resume()
1925 sc->sc_rx_resetted = 1; in ath_resume()
1926 ATH_RX_UNLOCK(sc); in ath_resume()
1929 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_resume()
1932 ath_spectral_enable(sc, ic->ic_curchan); in ath_resume()
1937 ath_btcoex_enable(sc, ic->ic_curchan); in ath_resume()
1943 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_resume()
1944 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_resume()
1946 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_resume()
1949 ath_led_config(sc); in ath_resume()
1952 if (sc->sc_resume_up) in ath_resume()
1955 ATH_LOCK(sc); in ath_resume()
1956 ath_power_restore_power_state(sc); in ath_resume()
1957 ATH_UNLOCK(sc); in ath_resume()
1963 ath_shutdown(struct ath_softc *sc) in ath_shutdown() argument
1966 ATH_LOCK(sc); in ath_shutdown()
1967 ath_stop(sc); in ath_shutdown()
1968 ATH_UNLOCK(sc); in ath_shutdown()
1978 struct ath_softc *sc = arg; in ath_intr() local
1979 struct ath_hal *ah = sc->sc_ah; in ath_intr()
1987 ATH_PCU_LOCK(sc); in ath_intr()
1988 if (sc->sc_inreset_cnt) { in ath_intr()
1992 DPRINTF(sc, ATH_DEBUG_ANY, in ath_intr()
1995 ATH_PCU_UNLOCK(sc); in ath_intr()
1999 if (sc->sc_invalid) { in ath_intr()
2004 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid; ignored\n", __func__); in ath_intr()
2005 ATH_PCU_UNLOCK(sc); in ath_intr()
2009 ATH_PCU_UNLOCK(sc); in ath_intr()
2013 ATH_LOCK(sc); in ath_intr()
2014 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_intr()
2015 ATH_UNLOCK(sc); in ath_intr()
2017 if (sc->sc_ic.ic_nrunning == 0 && sc->sc_running == 0) { in ath_intr()
2020 DPRINTF(sc, ATH_DEBUG_ANY, "%s: ic_nrunning %d sc_running %d\n", in ath_intr()
2021 __func__, sc->sc_ic.ic_nrunning, sc->sc_running); in ath_intr()
2024 ATH_PCU_UNLOCK(sc); in ath_intr()
2026 ATH_LOCK(sc); in ath_intr()
2027 ath_power_restore_power_state(sc); in ath_intr()
2028 ATH_UNLOCK(sc); in ath_intr()
2039 DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status); in ath_intr()
2040 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1, "ath_intr: mask=0x%.8x", status); in ath_intr()
2042 if_ath_alq_post_intr(&sc->sc_alq, status, ah->ah_intrstate, in ath_intr()
2046 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 5, in ath_intr()
2060 sc->sc_intr_stats.sync_intr[i]++; in ath_intr()
2063 status &= sc->sc_imask; /* discard unasked for bits */ in ath_intr()
2067 ATH_PCU_UNLOCK(sc); in ath_intr()
2069 ATH_LOCK(sc); in ath_intr()
2070 ath_power_restore_power_state(sc); in ath_intr()
2071 ATH_UNLOCK(sc); in ath_intr()
2080 sc->sc_intr_cnt++; in ath_intr()
2081 ATH_PCU_UNLOCK(sc); in ath_intr()
2089 sc->sc_stats.ast_hardware++; in ath_intr()
2091 taskqueue_enqueue(sc->sc_tq, &sc->sc_fataltask); in ath_intr()
2101 if (sc->sc_tdma) { in ath_intr()
2102 if (sc->sc_tdmaswba == 0) { in ath_intr()
2103 struct ieee80211com *ic = &sc->sc_ic; in ath_intr()
2106 ath_tdma_beacon_send(sc, vap); in ath_intr()
2107 sc->sc_tdmaswba = in ath_intr()
2110 sc->sc_tdmaswba--; in ath_intr()
2114 ath_beacon_proc(sc, 0); in ath_intr()
2121 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2127 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL"); in ath_intr()
2128 if (! sc->sc_isedma) { in ath_intr()
2129 ATH_PCU_LOCK(sc); in ath_intr()
2135 sc->sc_stats.ast_rxeol++; in ath_intr()
2145 imask = sc->sc_imask; in ath_intr()
2159 if (! sc->sc_kickpcu) in ath_intr()
2160 sc->sc_rxlink = NULL; in ath_intr()
2161 sc->sc_kickpcu = 1; in ath_intr()
2162 ATH_PCU_UNLOCK(sc); in ath_intr()
2169 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2172 sc->sc_stats.ast_txurn++; in ath_intr()
2181 sc->sc_stats.ast_rx_intr++; in ath_intr()
2182 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2185 sc->sc_stats.ast_tx_intr++; in ath_intr()
2191 if (! sc->sc_isedma) { in ath_intr()
2192 ATH_PCU_LOCK(sc); in ath_intr()
2194 ath_hal_gettxintrtxqs(sc->sc_ah, &txqs); in ath_intr()
2195 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 3, in ath_intr()
2198 sc->sc_txq_active, in ath_intr()
2199 sc->sc_txq_active | txqs); in ath_intr()
2200 sc->sc_txq_active |= txqs; in ath_intr()
2201 ATH_PCU_UNLOCK(sc); in ath_intr()
2203 taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask); in ath_intr()
2206 sc->sc_stats.ast_bmiss++; in ath_intr()
2207 taskqueue_enqueue(sc->sc_tq, &sc->sc_bmisstask); in ath_intr()
2210 sc->sc_stats.ast_tx_timeout++; in ath_intr()
2212 sc->sc_stats.ast_tx_cst++; in ath_intr()
2214 sc->sc_stats.ast_mib++; in ath_intr()
2215 ATH_PCU_LOCK(sc); in ath_intr()
2225 ath_hal_mibevent(ah, &sc->sc_halstats); in ath_intr()
2232 if (sc->sc_kickpcu == 0) in ath_intr()
2233 ath_hal_intrset(ah, sc->sc_imask); in ath_intr()
2234 ATH_PCU_UNLOCK(sc); in ath_intr()
2238 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXORN"); in ath_intr()
2239 sc->sc_stats.ast_rxorn++; in ath_intr()
2242 device_printf(sc->sc_dev, "%s: TSFOOR\n", __func__); in ath_intr()
2243 sc->sc_syncbeacon = 1; in ath_intr()
2246 ATH_PCU_LOCK(sc); in ath_intr()
2247 sc->sc_intr_cnt--; in ath_intr()
2248 ATH_PCU_UNLOCK(sc); in ath_intr()
2250 ATH_LOCK(sc); in ath_intr()
2251 ath_power_restore_power_state(sc); in ath_intr()
2252 ATH_UNLOCK(sc); in ath_intr()
2258 struct ath_softc *sc = arg; in ath_fatal_proc() local
2263 if (sc->sc_invalid) in ath_fatal_proc()
2266 device_printf(sc->sc_dev, "hardware error; resetting\n"); in ath_fatal_proc()
2272 if (ath_hal_getfatalstate(sc->sc_ah, &sp, &len)) { in ath_fatal_proc()
2275 device_printf(sc->sc_dev, in ath_fatal_proc()
2279 ath_reset(sc, ATH_RESET_NOLOSS); in ath_fatal_proc()
2285 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_bmiss_vap() local
2301 ATH_LOCK(sc); in ath_bmiss_vap()
2302 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_bmiss_vap()
2303 ATH_UNLOCK(sc); in ath_bmiss_vap()
2306 u_int64_t lastrx = sc->sc_lastrx; in ath_bmiss_vap()
2307 u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah); in ath_bmiss_vap()
2312 DPRINTF(sc, ATH_DEBUG_BEACON, in ath_bmiss_vap()
2319 sc->sc_stats.ast_bmiss_phantom++; in ath_bmiss_vap()
2321 ATH_LOCK(sc); in ath_bmiss_vap()
2322 ath_power_restore_power_state(sc); in ath_bmiss_vap()
2323 ATH_UNLOCK(sc); in ath_bmiss_vap()
2333 ATH_LOCK(sc); in ath_bmiss_vap()
2334 ath_power_restore_power_state(sc); in ath_bmiss_vap()
2335 ATH_UNLOCK(sc); in ath_bmiss_vap()
2340 sc->sc_syncbeacon = 1; in ath_bmiss_vap()
2362 struct ath_softc *sc = arg; in ath_bmiss_proc() local
2365 DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending); in ath_bmiss_proc()
2367 ATH_LOCK(sc); in ath_bmiss_proc()
2368 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_bmiss_proc()
2369 ATH_UNLOCK(sc); in ath_bmiss_proc()
2371 ath_beacon_miss(sc); in ath_bmiss_proc()
2379 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) { in ath_bmiss_proc()
2380 ath_reset(sc, ATH_RESET_NOLOSS); in ath_bmiss_proc()
2381 device_printf(sc->sc_dev, in ath_bmiss_proc()
2384 ath_reset(sc, ATH_RESET_NOLOSS); in ath_bmiss_proc()
2385 ieee80211_beacon_miss(&sc->sc_ic); in ath_bmiss_proc()
2389 sc->sc_syncbeacon = 1; in ath_bmiss_proc()
2391 ATH_LOCK(sc); in ath_bmiss_proc()
2392 ath_power_restore_power_state(sc); in ath_bmiss_proc()
2393 ATH_UNLOCK(sc); in ath_bmiss_proc()
2403 ath_settkipmic(struct ath_softc *sc) in ath_settkipmic() argument
2405 struct ieee80211com *ic = &sc->sc_ic; in ath_settkipmic()
2407 if ((ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP) && !sc->sc_wmetkipmic) { in ath_settkipmic()
2409 ath_hal_settkipmic(sc->sc_ah, AH_FALSE); in ath_settkipmic()
2412 ath_hal_settkipmic(sc->sc_ah, AH_TRUE); in ath_settkipmic()
2419 ath_init(struct ath_softc *sc) in ath_init() argument
2421 struct ieee80211com *ic = &sc->sc_ic; in ath_init()
2422 struct ath_hal *ah = sc->sc_ah; in ath_init()
2425 ATH_LOCK_ASSERT(sc); in ath_init()
2430 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_init()
2431 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_init()
2432 ath_power_setpower(sc, HAL_PM_AWAKE); in ath_init()
2438 ath_stop(sc); in ath_init()
2447 ath_settkipmic(sc); in ath_init()
2448 ath_update_chainmasks(sc, ic->ic_curchan); in ath_init()
2449 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_init()
2450 sc->sc_cur_rxchainmask); in ath_init()
2452 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, in ath_init()
2454 device_printf(sc->sc_dev, in ath_init()
2459 ATH_RX_LOCK(sc); in ath_init()
2460 sc->sc_rx_stopped = 1; in ath_init()
2461 sc->sc_rx_resetted = 1; in ath_init()
2462 ATH_RX_UNLOCK(sc); in ath_init()
2464 ath_chan_change(sc, ic->ic_curchan); in ath_init()
2467 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_init()
2470 ath_spectral_enable(sc, ic->ic_curchan); in ath_init()
2475 ath_btcoex_enable(sc, ic->ic_curchan); in ath_init()
2481 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_init()
2482 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_init()
2484 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_init()
2490 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_init()
2491 sc->sc_lastlongcal = ticks; in ath_init()
2492 sc->sc_resetcal = 1; in ath_init()
2493 sc->sc_lastcalreset = 0; in ath_init()
2494 sc->sc_lastani = ticks; in ath_init()
2495 sc->sc_lastshortcal = ticks; in ath_init()
2496 sc->sc_doresetcal = AH_FALSE; in ath_init()
2502 sc->sc_beacons = 0; in ath_init()
2511 if (ath_startrecv(sc) != 0) { in ath_init()
2512 device_printf(sc->sc_dev, "unable to start recv logic\n"); in ath_init()
2513 ath_power_restore_power_state(sc); in ath_init()
2520 sc->sc_imask = HAL_INT_RX | HAL_INT_TX in ath_init()
2528 if (sc->sc_isedma) in ath_init()
2529 sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); in ath_init()
2536 if (! sc->sc_isedma) in ath_init()
2537 sc->sc_imask |= HAL_INT_RXEOL; in ath_init()
2543 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) in ath_init()
2544 sc->sc_imask |= HAL_INT_MIB; in ath_init()
2553 sc->sc_imask |= HAL_INT_TSFOOR; in ath_init()
2557 sc->sc_imask |= HAL_INT_GTT; in ath_init()
2559 DPRINTF(sc, ATH_DEBUG_RESET, "%s: imask=0x%x\n", in ath_init()
2560 __func__, sc->sc_imask); in ath_init()
2562 sc->sc_running = 1; in ath_init()
2563 callout_reset(&sc->sc_wd_ch, hz, ath_watchdog, sc); in ath_init()
2564 ath_hal_intrset(ah, sc->sc_imask); in ath_init()
2566 ath_power_restore_power_state(sc); in ath_init()
2572 ath_stop(struct ath_softc *sc) in ath_stop() argument
2574 struct ath_hal *ah = sc->sc_ah; in ath_stop()
2576 ATH_LOCK_ASSERT(sc); in ath_stop()
2581 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_stop()
2583 if (sc->sc_running) { in ath_stop()
2600 if (sc->sc_tx99 != NULL) in ath_stop()
2601 sc->sc_tx99->stop(sc->sc_tx99); in ath_stop()
2603 callout_stop(&sc->sc_wd_ch); in ath_stop()
2604 sc->sc_wd_timer = 0; in ath_stop()
2605 sc->sc_running = 0; in ath_stop()
2606 if (!sc->sc_invalid) { in ath_stop()
2607 if (sc->sc_softled) { in ath_stop()
2608 callout_stop(&sc->sc_ledtimer); in ath_stop()
2609 ath_hal_gpioset(ah, sc->sc_ledpin, in ath_stop()
2610 !sc->sc_ledon); in ath_stop()
2611 sc->sc_blinking = 0; in ath_stop()
2616 if (!sc->sc_invalid) { in ath_stop()
2617 ath_stoprecv(sc, 1); in ath_stop()
2620 sc->sc_rxlink = NULL; in ath_stop()
2621 ath_draintxq(sc, ATH_RESET_DEFAULT); in ath_stop()
2622 ath_beacon_free(sc); /* XXX not needed */ in ath_stop()
2626 ath_power_restore_power_state(sc); in ath_stop()
2639 ath_txrx_stop_locked(struct ath_softc *sc) in ath_txrx_stop_locked() argument
2643 ATH_UNLOCK_ASSERT(sc); in ath_txrx_stop_locked()
2644 ATH_PCU_LOCK_ASSERT(sc); in ath_txrx_stop_locked()
2652 while (sc->sc_rxproc_cnt || sc->sc_txproc_cnt || in ath_txrx_stop_locked()
2653 sc->sc_txstart_cnt || sc->sc_intr_cnt) { in ath_txrx_stop_locked()
2656 msleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", in ath_txrx_stop_locked()
2662 device_printf(sc->sc_dev, in ath_txrx_stop_locked()
2670 ath_txrx_stop(struct ath_softc *sc)
2672 ATH_UNLOCK_ASSERT(sc);
2673 ATH_PCU_UNLOCK_ASSERT(sc);
2675 ATH_PCU_LOCK(sc);
2676 ath_txrx_stop_locked(sc);
2677 ATH_PCU_UNLOCK(sc);
2682 ath_txrx_start(struct ath_softc *sc) in ath_txrx_start() argument
2685 taskqueue_unblock(sc->sc_tq); in ath_txrx_start()
2706 ath_reset_grablock(struct ath_softc *sc, int dowait) in ath_reset_grablock() argument
2711 ATH_PCU_LOCK_ASSERT(sc); in ath_reset_grablock()
2713 if (sc->sc_inreset_cnt == 0) { in ath_reset_grablock()
2721 ATH_PCU_UNLOCK(sc); in ath_reset_grablock()
2728 ATH_PCU_LOCK(sc); in ath_reset_grablock()
2736 sc->sc_inreset_cnt++; in ath_reset_grablock()
2739 device_printf(sc->sc_dev, in ath_reset_grablock()
2744 device_printf(sc->sc_dev, in ath_reset_grablock()
2760 ath_reset(struct ath_softc *sc, ATH_RESET_TYPE reset_type) in ath_reset() argument
2762 struct ieee80211com *ic = &sc->sc_ic; in ath_reset()
2763 struct ath_hal *ah = sc->sc_ah; in ath_reset()
2767 DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); in ath_reset()
2770 ATH_PCU_UNLOCK_ASSERT(sc); in ath_reset()
2771 ATH_UNLOCK_ASSERT(sc); in ath_reset()
2774 taskqueue_block(sc->sc_tq); in ath_reset()
2779 ATH_LOCK(sc); in ath_reset()
2780 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_reset()
2781 ATH_UNLOCK(sc); in ath_reset()
2783 ATH_PCU_LOCK(sc); in ath_reset()
2791 if (ath_reset_grablock(sc, 1) == 0) { in ath_reset()
2792 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_reset()
2803 ath_txrx_stop_locked(sc); in ath_reset()
2805 ATH_PCU_UNLOCK(sc); in ath_reset()
2812 ath_stoprecv(sc, (reset_type != ATH_RESET_NOLOSS)); in ath_reset()
2813 ath_rx_flush(sc); in ath_reset()
2820 ath_draintxq(sc, reset_type); /* stop xmit side */ in ath_reset()
2822 ath_settkipmic(sc); /* configure TKIP MIC handling */ in ath_reset()
2824 ath_update_chainmasks(sc, ic->ic_curchan); in ath_reset()
2825 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_reset()
2826 sc->sc_cur_rxchainmask); in ath_reset()
2827 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, in ath_reset()
2829 device_printf(sc->sc_dev, in ath_reset()
2832 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_reset()
2834 ATH_RX_LOCK(sc); in ath_reset()
2835 sc->sc_rx_stopped = 1; in ath_reset()
2836 sc->sc_rx_resetted = 1; in ath_reset()
2837 ATH_RX_UNLOCK(sc); in ath_reset()
2840 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_reset()
2843 ath_spectral_enable(sc, ic->ic_curchan); in ath_reset()
2848 ath_btcoex_enable(sc, ic->ic_curchan); in ath_reset()
2854 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_reset()
2855 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_reset()
2857 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_reset()
2859 if (ath_startrecv(sc) != 0) /* restart recv */ in ath_reset()
2860 device_printf(sc->sc_dev, in ath_reset()
2867 ath_chan_change(sc, ic->ic_curchan); in ath_reset()
2868 if (sc->sc_beacons) { /* restart beacons */ in ath_reset()
2870 if (sc->sc_tdma) in ath_reset()
2871 ath_tdma_config(sc, NULL); in ath_reset()
2874 ath_beacon_config(sc, NULL); in ath_reset()
2889 ATH_PCU_LOCK(sc); in ath_reset()
2890 sc->sc_inreset_cnt--; in ath_reset()
2891 sc->sc_txstart_cnt++; in ath_reset()
2893 ath_hal_intrset(ah, sc->sc_imask); in ath_reset()
2894 ATH_PCU_UNLOCK(sc); in ath_reset()
2906 ath_txrx_start(sc); in ath_reset()
2913 if (ATH_TXQ_SETUP(sc, i)) { in ath_reset()
2914 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_reset()
2915 ath_txq_restart_dma(sc, &sc->sc_txq[i]); in ath_reset()
2916 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_reset()
2918 ATH_TX_LOCK(sc); in ath_reset()
2919 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_reset()
2920 ATH_TX_UNLOCK(sc); in ath_reset()
2925 ATH_LOCK(sc); in ath_reset()
2926 ath_power_restore_power_state(sc); in ath_reset()
2927 ATH_UNLOCK(sc); in ath_reset()
2929 ATH_PCU_LOCK(sc); in ath_reset()
2930 sc->sc_txstart_cnt--; in ath_reset()
2931 ATH_PCU_UNLOCK(sc); in ath_reset()
2938 ath_tx_kick(sc); /* restart xmit */ in ath_reset()
2946 struct ath_softc *sc = ic->ic_softc; in ath_reset_vap() local
2947 struct ath_hal *ah = sc->sc_ah; in ath_reset_vap()
2961 return ath_reset(sc, ATH_RESET_FULL); in ath_reset_vap()
2965 _ath_getbuf_locked(struct ath_softc *sc, ath_buf_type_t btype) in _ath_getbuf_locked() argument
2969 ATH_TXBUF_LOCK_ASSERT(sc); in _ath_getbuf_locked()
2972 bf = TAILQ_FIRST(&sc->sc_txbuf_mgmt); in _ath_getbuf_locked()
2974 bf = TAILQ_FIRST(&sc->sc_txbuf); in _ath_getbuf_locked()
2977 sc->sc_stats.ast_tx_getnobuf++; in _ath_getbuf_locked()
2980 sc->sc_stats.ast_tx_getbusybuf++; in _ath_getbuf_locked()
2987 TAILQ_REMOVE(&sc->sc_txbuf_mgmt, bf, bf_list); in _ath_getbuf_locked()
2989 TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list); in _ath_getbuf_locked()
2990 sc->sc_txbuf_cnt--; in _ath_getbuf_locked()
2997 if (sc->sc_txbuf_cnt < 0) { in _ath_getbuf_locked()
2998 device_printf(sc->sc_dev, in _ath_getbuf_locked()
3001 sc->sc_txbuf_cnt = 0; in _ath_getbuf_locked()
3009 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__, in _ath_getbuf_locked()
3010 TAILQ_FIRST(&sc->sc_txbuf) == NULL ? in _ath_getbuf_locked()
3032 if (sc->sc_isedma) { in _ath_getbuf_locked()
3033 bf->bf_descid = sc->sc_txbuf_descid; in _ath_getbuf_locked()
3034 sc->sc_txbuf_descid++; in _ath_getbuf_locked()
3055 ath_buf_clone(struct ath_softc *sc, struct ath_buf *bf) in ath_buf_clone() argument
3059 tbf = ath_getbuf(sc, in ath_buf_clone()
3092 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_buf_clone()
3094 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_buf_clone()
3107 ath_getbuf(struct ath_softc *sc, ath_buf_type_t btype) in ath_getbuf() argument
3111 ATH_TXBUF_LOCK(sc); in ath_getbuf()
3112 bf = _ath_getbuf_locked(sc, btype); in ath_getbuf()
3118 bf = _ath_getbuf_locked(sc, ATH_BUFTYPE_NORMAL); in ath_getbuf()
3119 ATH_TXBUF_UNLOCK(sc); in ath_getbuf()
3121 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: stop queue\n", __func__); in ath_getbuf()
3122 sc->sc_stats.ast_tx_qstop++; in ath_getbuf()
3136 struct ath_softc *sc = ic->ic_softc; in ath_transmit() local
3146 ATH_PCU_LOCK(sc); in ath_transmit()
3147 if (sc->sc_inreset_cnt > 0) { in ath_transmit()
3148 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3150 ATH_PCU_UNLOCK(sc); in ath_transmit()
3151 sc->sc_stats.ast_tx_qstop++; in ath_transmit()
3152 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: OACTIVE, finish"); in ath_transmit()
3155 sc->sc_txstart_cnt++; in ath_transmit()
3156 ATH_PCU_UNLOCK(sc); in ath_transmit()
3159 ATH_LOCK(sc); in ath_transmit()
3160 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_transmit()
3161 ATH_UNLOCK(sc); in ath_transmit()
3163 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_transmit: start"); in ath_transmit()
3168 ATH_TX_LOCK(sc); in ath_transmit()
3189 (ATH_NODE(ni)->an_swq_depth > sc->sc_txq_node_maxdepth)) { in ath_transmit()
3190 sc->sc_stats.ast_tx_nodeq_overflow++; in ath_transmit()
3212 (sc->sc_txbuf_cnt <= sc->sc_txq_data_minfree)) { in ath_transmit()
3213 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3229 bf = ath_getbuf(sc, ATH_BUFTYPE_MGMT); in ath_transmit()
3231 bf = ath_getbuf(sc, ATH_BUFTYPE_NORMAL); in ath_transmit()
3240 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3258 !ath_txfrag_setup(sc, &frags, m, ni)) { in ath_transmit()
3259 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3261 sc->sc_stats.ast_tx_nofrag++; in ath_transmit()
3330 if (ath_tx_start(sc, ni, bf, m)) { in ath_transmit()
3336 ATH_TXBUF_LOCK(sc); in ath_transmit()
3337 ath_returnbuf_head(sc, bf); in ath_transmit()
3342 ath_txfrag_cleanup(sc, &frags, ni); in ath_transmit()
3343 ATH_TXBUF_UNLOCK(sc); in ath_transmit()
3358 ath_tx_update_tim(sc, ni, 1); in ath_transmit()
3366 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3384 sc->sc_wd_timer = 5; in ath_transmit()
3387 ATH_TX_UNLOCK(sc); in ath_transmit()
3392 ATH_PCU_LOCK(sc); in ath_transmit()
3393 sc->sc_txstart_cnt--; in ath_transmit()
3394 ATH_PCU_UNLOCK(sc); in ath_transmit()
3397 ATH_LOCK(sc); in ath_transmit()
3398 ath_power_restore_power_state(sc); in ath_transmit()
3399 ATH_UNLOCK(sc); in ath_transmit()
3401 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_transmit: finished"); in ath_transmit()
3423 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_begin() local
3425 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); in ath_key_update_begin()
3426 taskqueue_block(sc->sc_tq); in ath_key_update_begin()
3432 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_end() local
3434 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); in ath_key_update_end()
3435 taskqueue_unblock(sc->sc_tq); in ath_key_update_end()
3441 struct ath_softc *sc = ic->ic_softc; in ath_update_promisc() local
3445 ATH_LOCK(sc); in ath_update_promisc()
3446 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_update_promisc()
3447 rfilt = ath_calcrxfilter(sc); in ath_update_promisc()
3448 ath_hal_setrxfilter(sc->sc_ah, rfilt); in ath_update_promisc()
3449 ath_power_restore_power_state(sc); in ath_update_promisc()
3450 ATH_UNLOCK(sc); in ath_update_promisc()
3452 DPRINTF(sc, ATH_DEBUG_MODE, "%s: RX filter 0x%x\n", __func__, rfilt); in ath_update_promisc()
3461 ath_update_mcast_hw(struct ath_softc *sc) in ath_update_mcast_hw() argument
3463 struct ieee80211com *ic = &sc->sc_ic; in ath_update_mcast_hw()
3501 ath_hal_setmcastfilter(sc->sc_ah, mfilt[0], mfilt[1]); in ath_update_mcast_hw()
3503 DPRINTF(sc, ATH_DEBUG_MODE, "%s: MC filter %08x:%08x\n", in ath_update_mcast_hw()
3514 struct ath_softc *sc = ic->ic_softc; in ath_update_mcast() local
3516 ATH_LOCK(sc); in ath_update_mcast()
3517 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_update_mcast()
3518 ATH_UNLOCK(sc); in ath_update_mcast()
3520 ath_update_mcast_hw(sc); in ath_update_mcast()
3522 ATH_LOCK(sc); in ath_update_mcast()
3523 ath_power_restore_power_state(sc); in ath_update_mcast()
3524 ATH_UNLOCK(sc); in ath_update_mcast()
3528 ath_mode_init(struct ath_softc *sc) in ath_mode_init() argument
3530 struct ieee80211com *ic = &sc->sc_ic; in ath_mode_init()
3531 struct ath_hal *ah = sc->sc_ah; in ath_mode_init()
3535 rfilt = ath_calcrxfilter(sc); in ath_mode_init()
3545 ath_update_mcast_hw(sc); in ath_mode_init()
3552 ath_setslottime(struct ath_softc *sc) in ath_setslottime() argument
3554 struct ieee80211com *ic = &sc->sc_ic; in ath_setslottime()
3555 struct ath_hal *ah = sc->sc_ah; in ath_setslottime()
3572 DPRINTF(sc, ATH_DEBUG_RESET, in ath_setslottime()
3578 ATH_LOCK(sc); in ath_setslottime()
3579 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_setslottime()
3581 ath_power_restore_power_state(sc); in ath_setslottime()
3582 sc->sc_updateslot = OK; in ath_setslottime()
3583 ATH_UNLOCK(sc); in ath_setslottime()
3593 struct ath_softc *sc = ic->ic_softc; in ath_updateslot() local
3604 sc->sc_updateslot = UPDATE; in ath_updateslot()
3606 ath_setslottime(sc); in ath_updateslot()
3637 struct ath_softc *sc = arg; in ath_reset_proc() local
3640 device_printf(sc->sc_dev, "%s: resetting\n", __func__); in ath_reset_proc()
3642 ath_reset(sc, ATH_RESET_NOLOSS); in ath_reset_proc()
3651 struct ath_softc *sc = arg; in ath_bstuck_proc() local
3654 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) in ath_bstuck_proc()
3655 device_printf(sc->sc_dev, "bb hang detected (0x%x)\n", hangs); in ath_bstuck_proc()
3658 if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_STUCK_BEACON)) in ath_bstuck_proc()
3659 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_STUCK_BEACON, 0, NULL); in ath_bstuck_proc()
3662 device_printf(sc->sc_dev, "stuck beacon; resetting (bmiss count %u)\n", in ath_bstuck_proc()
3663 sc->sc_bmisscount); in ath_bstuck_proc()
3664 sc->sc_stats.ast_bstuck++; in ath_bstuck_proc()
3669 ath_reset(sc, ATH_RESET_NOLOSS); in ath_bstuck_proc()
3673 ath_desc_alloc(struct ath_softc *sc) in ath_desc_alloc() argument
3677 error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf, in ath_desc_alloc()
3678 "tx", sc->sc_tx_desclen, ath_txbuf, ATH_MAX_SCATTER); in ath_desc_alloc()
3682 sc->sc_txbuf_cnt = ath_txbuf; in ath_desc_alloc()
3684 error = ath_descdma_setup(sc, &sc->sc_txdma_mgmt, &sc->sc_txbuf_mgmt, in ath_desc_alloc()
3685 "tx_mgmt", sc->sc_tx_desclen, ath_txbuf_mgmt, in ath_desc_alloc()
3688 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3697 error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf, in ath_desc_alloc()
3698 "beacon", sc->sc_tx_desclen, ATH_BCBUF, 1); in ath_desc_alloc()
3700 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3701 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_alloc()
3702 &sc->sc_txbuf_mgmt); in ath_desc_alloc()
3709 ath_desc_free(struct ath_softc *sc) in ath_desc_free() argument
3712 if (sc->sc_bdma.dd_desc_len != 0) in ath_desc_free()
3713 ath_descdma_cleanup(sc, &sc->sc_bdma, &sc->sc_bbuf); in ath_desc_free()
3714 if (sc->sc_txdma.dd_desc_len != 0) in ath_desc_free()
3715 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_free()
3716 if (sc->sc_txdma_mgmt.dd_desc_len != 0) in ath_desc_free()
3717 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_free()
3718 &sc->sc_txbuf_mgmt); in ath_desc_free()
3725 struct ath_softc *sc = ic->ic_softc; in ath_node_alloc() local
3726 const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; in ath_node_alloc()
3734 ath_rate_node_init(sc, an); in ath_node_alloc()
3738 device_get_nameunit(sc->sc_dev), an); in ath_node_alloc()
3742 ath_tx_tid_init(sc, an); in ath_node_alloc()
3744 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, mac, ":", an); in ath_node_alloc()
3752 struct ath_softc *sc = ic->ic_softc; in ath_node_cleanup() local
3754 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, in ath_node_cleanup()
3758 ath_tx_node_flush(sc, ATH_NODE(ni)); in ath_node_cleanup()
3759 ath_rate_node_cleanup(sc, ATH_NODE(ni)); in ath_node_cleanup()
3760 sc->sc_node_cleanup(ni); in ath_node_cleanup()
3767 struct ath_softc *sc = ic->ic_softc; in ath_node_free() local
3769 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, in ath_node_free()
3772 sc->sc_node_free(ni); in ath_node_free()
3779 struct ath_softc *sc = ic->ic_softc; in ath_node_getsignal() local
3780 struct ath_hal *ah = sc->sc_ah; in ath_node_getsignal()
3793 ath_setdefantenna(struct ath_softc *sc, u_int antenna) in ath_setdefantenna() argument
3795 struct ath_hal *ah = sc->sc_ah; in ath_setdefantenna()
3799 if (sc->sc_defant != antenna) in ath_setdefantenna()
3800 sc->sc_stats.ast_ant_defswitch++; in ath_setdefantenna()
3801 sc->sc_defant = antenna; in ath_setdefantenna()
3802 sc->sc_rxotherant = 0; in ath_setdefantenna()
3806 ath_txq_init(struct ath_softc *sc, struct ath_txq *txq, int qnum) in ath_txq_init() argument
3814 txq->axq_softc = sc; in ath_txq_init()
3818 ATH_TXQ_LOCK_INIT(sc, txq); in ath_txq_init()
3825 ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) in ath_txq_setup() argument
3827 struct ath_hal *ah = sc->sc_ah; in ath_txq_setup()
3848 if (sc->sc_isedma) in ath_txq_setup()
3863 if (qnum >= nitems(sc->sc_txq)) { in ath_txq_setup()
3864 device_printf(sc->sc_dev, in ath_txq_setup()
3866 qnum, nitems(sc->sc_txq)); in ath_txq_setup()
3870 if (!ATH_TXQ_SETUP(sc, qnum)) { in ath_txq_setup()
3871 ath_txq_init(sc, &sc->sc_txq[qnum], qnum); in ath_txq_setup()
3872 sc->sc_txqsetup |= 1<<qnum; in ath_txq_setup()
3874 return &sc->sc_txq[qnum]; in ath_txq_setup()
3887 ath_tx_setup(struct ath_softc *sc, int ac, int haltype) in ath_tx_setup() argument
3891 if (ac >= nitems(sc->sc_ac2q)) { in ath_tx_setup()
3892 device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", in ath_tx_setup()
3893 ac, nitems(sc->sc_ac2q)); in ath_tx_setup()
3896 txq = ath_txq_setup(sc, HAL_TX_QUEUE_DATA, haltype); in ath_tx_setup()
3899 sc->sc_ac2q[ac] = txq; in ath_tx_setup()
3909 ath_txq_update(struct ath_softc *sc, int ac) in ath_txq_update() argument
3912 struct ieee80211com *ic = &sc->sc_ic; in ath_txq_update()
3913 struct ath_txq *txq = sc->sc_ac2q[ac]; in ath_txq_update()
3915 struct ath_hal *ah = sc->sc_ah; in ath_txq_update()
3920 if (sc->sc_tdma) { in ath_txq_update()
3939 qi.tqi_readyTime = sc->sc_tdmaslotlen; in ath_txq_update()
3962 DPRINTF(sc, ATH_DEBUG_RESET, in ath_txq_update()
3968 device_printf(sc->sc_dev, "unable to update hardware queue " in ath_txq_update()
3984 struct ath_softc *sc = ic->ic_softc; in ath_wme_update() local
3986 return !ath_txq_update(sc, WME_AC_BE) || in ath_wme_update()
3987 !ath_txq_update(sc, WME_AC_BK) || in ath_wme_update()
3988 !ath_txq_update(sc, WME_AC_VI) || in ath_wme_update()
3989 !ath_txq_update(sc, WME_AC_VO) ? EIO : 0; in ath_wme_update()
3996 ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_cleanupq() argument
3999 ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum); in ath_tx_cleanupq()
4000 sc->sc_txqsetup &= ~(1<<txq->axq_qnum); in ath_tx_cleanupq()
4008 ath_tx_cleanup(struct ath_softc *sc) in ath_tx_cleanup() argument
4012 ATH_TXBUF_LOCK_DESTROY(sc); in ath_tx_cleanup()
4014 if (ATH_TXQ_SETUP(sc, i)) in ath_tx_cleanup()
4015 ath_tx_cleanupq(sc, &sc->sc_txq[i]); in ath_tx_cleanup()
4023 ath_tx_findrix(const struct ath_softc *sc, uint8_t rate) in ath_tx_findrix() argument
4025 int rix = sc->sc_rixmap[rate]; in ath_tx_findrix()
4031 ath_tx_update_stats(struct ath_softc *sc, struct ath_tx_status *ts, in ath_tx_update_stats() argument
4035 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_update_stats()
4040 sc->sc_stats.ast_ant_tx[txant]++; in ath_tx_update_stats()
4041 sc->sc_ant_tx[txant]++; in ath_tx_update_stats()
4043 sc->sc_stats.ast_tx_altrate++; in ath_tx_update_stats()
4051 sc->sc_stats.ast_tx_xretries++; in ath_tx_update_stats()
4053 sc->sc_stats.ast_tx_fifoerr++; in ath_tx_update_stats()
4055 sc->sc_stats.ast_tx_filtered++; in ath_tx_update_stats()
4057 sc->sc_stats.ast_tx_xtxop++; in ath_tx_update_stats()
4059 sc->sc_stats.ast_tx_timerexpired++; in ath_tx_update_stats()
4062 sc->sc_stats.ast_ff_txerr++; in ath_tx_update_stats()
4066 sc->sc_stats.ast_tx_desccfgerr++; in ath_tx_update_stats()
4076 sc->sc_stats.ast_tx_data_underrun++; in ath_tx_update_stats()
4078 sc->sc_stats.ast_tx_delim_underrun++; in ath_tx_update_stats()
4082 sc->sc_stats.ast_tx_shortretry += sr; in ath_tx_update_stats()
4083 sc->sc_stats.ast_tx_longretry += lr; in ath_tx_update_stats()
4093 ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) in ath_tx_default_comp() argument
4106 device_printf(sc->sc_dev, in ath_tx_default_comp()
4113 device_printf(sc->sc_dev, in ath_tx_default_comp()
4135 ATH_TX_LOCK(sc); in ath_tx_default_comp()
4136 ath_tx_update_tim(sc, bf->bf_node, 0); in ath_tx_default_comp()
4137 ATH_TX_UNLOCK(sc); in ath_tx_default_comp()
4146 ath_tx_freebuf(sc, bf, st); in ath_tx_default_comp()
4153 ath_tx_update_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni, in ath_tx_update_ratectrl() argument
4168 ath_rate_tx_complete(sc, an, rc, ts, frmlen, nframes, nbad); in ath_tx_update_ratectrl()
4181 ath_tx_process_buf_completion(struct ath_softc *sc, struct ath_txq *txq, in ath_tx_process_buf_completion() argument
4186 ATH_TX_UNLOCK_ASSERT(sc); in ath_tx_process_buf_completion()
4192 ath_tx_update_stats(sc, ts, bf); in ath_tx_process_buf_completion()
4210 ath_tx_update_ratectrl(sc, ni, in ath_tx_process_buf_completion()
4215 ath_tx_default_comp(sc, bf, 0); in ath_tx_process_buf_completion()
4217 bf->bf_comp(sc, bf, 0); in ath_tx_process_buf_completion()
4228 ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq, int dosched) in ath_tx_processq() argument
4230 struct ath_hal *ah = sc->sc_ah; in ath_tx_processq()
4236 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_processq()
4241 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %u head %p link %p\n", in ath_tx_processq()
4243 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4246 ATH_KTR(sc, ATH_KTR_TXCOMP, 4, in ath_tx_processq()
4249 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4267 if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) in ath_tx_processq()
4268 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4270 else if ((sc->sc_debug & ATH_DEBUG_RESET) && (dosched == 0)) in ath_tx_processq()
4271 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4275 if (if_ath_alq_checkdebug(&sc->sc_alq, in ath_tx_processq()
4277 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS, in ath_tx_processq()
4278 sc->sc_tx_statuslen, in ath_tx_processq()
4284 ATH_KTR(sc, ATH_KTR_TXCOMP, 3, in ath_tx_processq()
4296 device_printf(sc->sc_dev, in ath_tx_processq()
4304 device_printf(sc->sc_dev, in ath_tx_processq()
4334 ATH_KTR(sc, ATH_KTR_TXCOMP, 5, in ath_tx_processq()
4345 sc->sc_stats.ast_tx_rssi = ts->ts_rssi; in ath_tx_processq()
4346 ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, in ath_tx_processq()
4354 ath_tx_process_buf_completion(sc, txq, ts, bf); in ath_tx_processq()
4368 ATH_TX_LOCK(sc); in ath_tx_processq()
4369 ath_txq_sched(sc, txq); in ath_tx_processq()
4370 ATH_TX_UNLOCK(sc); in ath_tx_processq()
4373 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_processq()
4389 struct ath_softc *sc = arg; in ath_tx_proc_q0() local
4392 ATH_PCU_LOCK(sc); in ath_tx_proc_q0()
4393 sc->sc_txproc_cnt++; in ath_tx_proc_q0()
4394 txqs = sc->sc_txq_active; in ath_tx_proc_q0()
4395 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0()
4396 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0()
4398 ATH_LOCK(sc); in ath_tx_proc_q0()
4399 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc_q0()
4400 ATH_UNLOCK(sc); in ath_tx_proc_q0()
4402 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_proc_q0()
4405 if (TXQACTIVE(txqs, 0) && ath_tx_processq(sc, &sc->sc_txq[0], 1)) in ath_tx_proc_q0()
4407 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0()
4408 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0()
4409 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0()
4410 sc->sc_wd_timer = 0; in ath_tx_proc_q0()
4412 if (sc->sc_softled) in ath_tx_proc_q0()
4413 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0()
4415 ATH_PCU_LOCK(sc); in ath_tx_proc_q0()
4416 sc->sc_txproc_cnt--; in ath_tx_proc_q0()
4417 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0()
4419 ATH_LOCK(sc); in ath_tx_proc_q0()
4420 ath_power_restore_power_state(sc); in ath_tx_proc_q0()
4421 ATH_UNLOCK(sc); in ath_tx_proc_q0()
4423 ath_tx_kick(sc); in ath_tx_proc_q0()
4433 struct ath_softc *sc = arg; in ath_tx_proc_q0123() local
4437 ATH_PCU_LOCK(sc); in ath_tx_proc_q0123()
4438 sc->sc_txproc_cnt++; in ath_tx_proc_q0123()
4439 txqs = sc->sc_txq_active; in ath_tx_proc_q0123()
4440 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0123()
4441 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0123()
4443 ATH_LOCK(sc); in ath_tx_proc_q0123()
4444 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc_q0123()
4445 ATH_UNLOCK(sc); in ath_tx_proc_q0123()
4447 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_proc_q0123()
4455 nacked += ath_tx_processq(sc, &sc->sc_txq[0], 1); in ath_tx_proc_q0123()
4457 nacked += ath_tx_processq(sc, &sc->sc_txq[1], 1); in ath_tx_proc_q0123()
4459 nacked += ath_tx_processq(sc, &sc->sc_txq[2], 1); in ath_tx_proc_q0123()
4461 nacked += ath_tx_processq(sc, &sc->sc_txq[3], 1); in ath_tx_proc_q0123()
4462 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0123()
4463 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0123()
4465 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0123()
4467 sc->sc_wd_timer = 0; in ath_tx_proc_q0123()
4469 if (sc->sc_softled) in ath_tx_proc_q0123()
4470 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0123()
4472 ATH_PCU_LOCK(sc); in ath_tx_proc_q0123()
4473 sc->sc_txproc_cnt--; in ath_tx_proc_q0123()
4474 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0123()
4476 ATH_LOCK(sc); in ath_tx_proc_q0123()
4477 ath_power_restore_power_state(sc); in ath_tx_proc_q0123()
4478 ATH_UNLOCK(sc); in ath_tx_proc_q0123()
4480 ath_tx_kick(sc); in ath_tx_proc_q0123()
4489 struct ath_softc *sc = arg; in ath_tx_proc() local
4493 ATH_PCU_LOCK(sc); in ath_tx_proc()
4494 sc->sc_txproc_cnt++; in ath_tx_proc()
4495 txqs = sc->sc_txq_active; in ath_tx_proc()
4496 sc->sc_txq_active &= ~txqs; in ath_tx_proc()
4497 ATH_PCU_UNLOCK(sc); in ath_tx_proc()
4499 ATH_LOCK(sc); in ath_tx_proc()
4500 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc()
4501 ATH_UNLOCK(sc); in ath_tx_proc()
4503 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, "ath_tx_proc: txqs=0x%08x", txqs); in ath_tx_proc()
4510 if (ATH_TXQ_SETUP(sc, i) && TXQACTIVE(txqs, i)) in ath_tx_proc()
4511 nacked += ath_tx_processq(sc, &sc->sc_txq[i], 1); in ath_tx_proc()
4513 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc()
4515 sc->sc_wd_timer = 0; in ath_tx_proc()
4517 if (sc->sc_softled) in ath_tx_proc()
4518 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc()
4520 ATH_PCU_LOCK(sc); in ath_tx_proc()
4521 sc->sc_txproc_cnt--; in ath_tx_proc()
4522 ATH_PCU_UNLOCK(sc); in ath_tx_proc()
4524 ATH_LOCK(sc); in ath_tx_proc()
4525 ath_power_restore_power_state(sc); in ath_tx_proc()
4526 ATH_UNLOCK(sc); in ath_tx_proc()
4528 ath_tx_kick(sc); in ath_tx_proc()
4538 struct ath_softc *sc = arg; in ath_txq_sched_tasklet() local
4542 ATH_PCU_LOCK(sc); in ath_txq_sched_tasklet()
4544 if (sc->sc_inreset_cnt > 0) { in ath_txq_sched_tasklet()
4545 device_printf(sc->sc_dev, in ath_txq_sched_tasklet()
4547 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4551 sc->sc_txproc_cnt++; in ath_txq_sched_tasklet()
4552 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4554 ATH_LOCK(sc); in ath_txq_sched_tasklet()
4555 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_txq_sched_tasklet()
4556 ATH_UNLOCK(sc); in ath_txq_sched_tasklet()
4558 ATH_TX_LOCK(sc); in ath_txq_sched_tasklet()
4560 if (ATH_TXQ_SETUP(sc, i)) { in ath_txq_sched_tasklet()
4561 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_txq_sched_tasklet()
4564 ATH_TX_UNLOCK(sc); in ath_txq_sched_tasklet()
4566 ATH_LOCK(sc); in ath_txq_sched_tasklet()
4567 ath_power_restore_power_state(sc); in ath_txq_sched_tasklet()
4568 ATH_UNLOCK(sc); in ath_txq_sched_tasklet()
4570 ATH_PCU_LOCK(sc); in ath_txq_sched_tasklet()
4571 sc->sc_txproc_cnt--; in ath_txq_sched_tasklet()
4572 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4576 ath_returnbuf_tail(struct ath_softc *sc, struct ath_buf *bf) in ath_returnbuf_tail() argument
4579 ATH_TXBUF_LOCK_ASSERT(sc); in ath_returnbuf_tail()
4582 TAILQ_INSERT_TAIL(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_tail()
4584 TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_tail()
4585 sc->sc_txbuf_cnt++; in ath_returnbuf_tail()
4586 if (sc->sc_txbuf_cnt > ath_txbuf) { in ath_returnbuf_tail()
4587 device_printf(sc->sc_dev, in ath_returnbuf_tail()
4591 sc->sc_txbuf_cnt = ath_txbuf; in ath_returnbuf_tail()
4597 ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf) in ath_returnbuf_head() argument
4600 ATH_TXBUF_LOCK_ASSERT(sc); in ath_returnbuf_head()
4603 TAILQ_INSERT_HEAD(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_head()
4605 TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_head()
4606 sc->sc_txbuf_cnt++; in ath_returnbuf_head()
4607 if (sc->sc_txbuf_cnt > ATH_TXBUF) { in ath_returnbuf_head()
4608 device_printf(sc->sc_dev, in ath_returnbuf_head()
4612 sc->sc_txbuf_cnt = ATH_TXBUF; in ath_returnbuf_head()
4621 ath_txq_freeholdingbuf(struct ath_softc *sc, struct ath_txq *txq) in ath_txq_freeholdingbuf() argument
4623 ATH_TXBUF_UNLOCK_ASSERT(sc); in ath_txq_freeholdingbuf()
4631 ATH_TXBUF_LOCK(sc); in ath_txq_freeholdingbuf()
4632 ath_returnbuf_tail(sc, txq->axq_holdingbf); in ath_txq_freeholdingbuf()
4633 ATH_TXBUF_UNLOCK(sc); in ath_txq_freeholdingbuf()
4643 ath_txq_addholdingbuf(struct ath_softc *sc, struct ath_buf *bf) in ath_txq_addholdingbuf() argument
4647 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_txq_addholdingbuf()
4649 ATH_TXBUF_UNLOCK_ASSERT(sc); in ath_txq_addholdingbuf()
4656 device_printf(sc->sc_dev, "%s: bf=%p: invalid tx queue (%d)\n", in ath_txq_addholdingbuf()
4661 ath_returnbuf_tail(sc, bf); in ath_txq_addholdingbuf()
4664 ath_txq_freeholdingbuf(sc, txq); in ath_txq_addholdingbuf()
4686 ath_freebuf(struct ath_softc *sc, struct ath_buf *bf) in ath_freebuf() argument
4690 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_freebuf()
4700 ath_txq_addholdingbuf(sc, bf); in ath_freebuf()
4708 ATH_TXBUF_LOCK(sc); in ath_freebuf()
4709 ath_returnbuf_tail(sc, bf); in ath_freebuf()
4710 ATH_TXBUF_UNLOCK(sc); in ath_freebuf()
4720 ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status) in ath_tx_freebuf() argument
4731 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_tx_freebuf()
4733 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_tx_freebuf()
4740 ath_freebuf(sc, bf); in ath_tx_freebuf()
4747 ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_draintxq_get_one() argument
4765 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
4781 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
4802 ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_draintxq() argument
4805 struct ath_hal *ah = sc->sc_ah; in ath_tx_draintxq()
4816 bf = ath_tx_draintxq_get_one(sc, txq); in ath_tx_draintxq()
4824 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_tx_draintxq()
4825 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_draintxq()
4834 if (! sc->sc_isedma) { in ath_tx_draintxq()
4839 ath_printtxbuf(sc, bf, txq->axq_qnum, ix, status); in ath_tx_draintxq()
4856 bf->bf_comp(sc, bf, 1); in ath_tx_draintxq()
4858 ath_tx_default_comp(sc, bf, 1); in ath_tx_draintxq()
4865 ath_txq_freeholdingbuf(sc, txq); in ath_tx_draintxq()
4872 ath_tx_txq_drain(sc, txq); in ath_tx_draintxq()
4876 ath_tx_stopdma(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_stopdma() argument
4878 struct ath_hal *ah = sc->sc_ah; in ath_tx_stopdma()
4882 DPRINTF(sc, ATH_DEBUG_RESET, in ath_tx_stopdma()
4899 if ((sc->sc_debug & ATH_DEBUG_RESET) in ath_tx_stopdma()
4901 ath_printtxbuf(sc, txq->axq_holdingbf, txq->axq_qnum, 0, 0); in ath_tx_stopdma()
4907 ath_stoptxdma(struct ath_softc *sc) in ath_stoptxdma() argument
4909 struct ath_hal *ah = sc->sc_ah; in ath_stoptxdma()
4913 if (sc->sc_invalid) in ath_stoptxdma()
4916 if (!sc->sc_invalid) { in ath_stoptxdma()
4918 DPRINTF(sc, ATH_DEBUG_RESET, "%s: tx queue [%u] %p, link %p\n", in ath_stoptxdma()
4919 __func__, sc->sc_bhalq, in ath_stoptxdma()
4920 (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq), in ath_stoptxdma()
4924 (void) ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_stoptxdma()
4928 if (ATH_TXQ_SETUP(sc, i)) { in ath_stoptxdma()
4929 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_stoptxdma()
4930 ath_tx_stopdma(sc, &sc->sc_txq[i]); in ath_stoptxdma()
4931 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_stoptxdma()
4941 ath_tx_dump(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_dump() argument
4943 struct ath_hal *ah = sc->sc_ah; in ath_tx_dump()
4947 if (! (sc->sc_debug & ATH_DEBUG_RESET)) in ath_tx_dump()
4950 device_printf(sc->sc_dev, "%s: Q%d: begin\n", in ath_tx_dump()
4953 ath_printtxbuf(sc, bf, txq->axq_qnum, i, in ath_tx_dump()
4958 device_printf(sc->sc_dev, "%s: Q%d: end\n", in ath_tx_dump()
4967 ath_legacy_tx_drain(struct ath_softc *sc, ATH_RESET_TYPE reset_type) in ath_legacy_tx_drain() argument
4969 struct ath_hal *ah = sc->sc_ah; in ath_legacy_tx_drain()
4973 (void) ath_stoptxdma(sc); in ath_legacy_tx_drain()
4983 if (ATH_TXQ_SETUP(sc, i)) { in ath_legacy_tx_drain()
4985 if (sc->sc_debug & ATH_DEBUG_RESET) in ath_legacy_tx_drain()
4986 ath_tx_dump(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
4989 ath_tx_processq(sc, &sc->sc_txq[i], 0); in ath_legacy_tx_drain()
4990 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
4995 ath_txq_freeholdingbuf(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5002 bf_last = ATH_TXQ_LAST(&sc->sc_txq[i], in ath_legacy_tx_drain()
5007 &sc->sc_txq[i].axq_link); in ath_legacy_tx_drain()
5009 sc->sc_txq[i].axq_link = NULL; in ath_legacy_tx_drain()
5011 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
5013 ath_tx_draintxq(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5017 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_legacy_tx_drain()
5018 struct ath_buf *bf = TAILQ_FIRST(&sc->sc_bbuf); in ath_legacy_tx_drain()
5020 ath_printtxbuf(sc, bf, sc->sc_bhalq, 0, in ath_legacy_tx_drain()
5023 ieee80211_dump_pkt(&sc->sc_ic, in ath_legacy_tx_drain()
5029 sc->sc_wd_timer = 0; in ath_legacy_tx_drain()
5036 ath_chan_change(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_chan_change() argument
5045 if (mode != sc->sc_curmode) in ath_chan_change()
5046 ath_setcurmode(sc, mode); in ath_chan_change()
5047 sc->sc_curchan = chan; in ath_chan_change()
5057 ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_chan_set() argument
5059 struct ieee80211com *ic = &sc->sc_ic; in ath_chan_set()
5060 struct ath_hal *ah = sc->sc_ah; in ath_chan_set()
5064 ATH_PCU_UNLOCK_ASSERT(sc); in ath_chan_set()
5065 ATH_UNLOCK_ASSERT(sc); in ath_chan_set()
5068 taskqueue_block(sc->sc_tq); in ath_chan_set()
5070 ATH_PCU_LOCK(sc); in ath_chan_set()
5076 if (ath_reset_grablock(sc, 1) == 0) { in ath_chan_set()
5077 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_chan_set()
5082 ath_txrx_stop_locked(sc); in ath_chan_set()
5084 ATH_PCU_UNLOCK(sc); in ath_chan_set()
5086 DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, flags 0x%x)\n", in ath_chan_set()
5089 if (chan != sc->sc_curchan) { in ath_chan_set()
5100 ath_stoprecv(sc, 1); /* turn off frame recv */ in ath_chan_set()
5104 ath_rx_flush(sc); in ath_chan_set()
5105 ath_draintxq(sc, ATH_RESET_NOLOSS); in ath_chan_set()
5109 ath_draintxq(sc, ATH_RESET_FULL); /* clear pending tx frames */ in ath_chan_set()
5111 ath_update_chainmasks(sc, chan); in ath_chan_set()
5112 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_chan_set()
5113 sc->sc_cur_rxchainmask); in ath_chan_set()
5114 if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, in ath_chan_set()
5116 device_printf(sc->sc_dev, "%s: unable to reset " in ath_chan_set()
5123 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_chan_set()
5125 ATH_RX_LOCK(sc); in ath_chan_set()
5126 sc->sc_rx_stopped = 1; in ath_chan_set()
5127 sc->sc_rx_resetted = 1; in ath_chan_set()
5128 ATH_RX_UNLOCK(sc); in ath_chan_set()
5131 ath_dfs_radar_enable(sc, chan); in ath_chan_set()
5134 ath_spectral_enable(sc, chan); in ath_chan_set()
5140 ath_btcoex_enable(sc, ic->ic_curchan); in ath_chan_set()
5146 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_chan_set()
5147 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_chan_set()
5149 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_chan_set()
5154 if (ath_startrecv(sc) != 0) { in ath_chan_set()
5155 device_printf(sc->sc_dev, in ath_chan_set()
5165 ath_chan_change(sc, chan); in ath_chan_set()
5171 if (sc->sc_beacons) { /* restart beacons */ in ath_chan_set()
5173 if (sc->sc_tdma) in ath_chan_set()
5174 ath_tdma_config(sc, NULL); in ath_chan_set()
5177 ath_beacon_config(sc, NULL); in ath_chan_set()
5184 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5189 ATH_PCU_LOCK(sc); in ath_chan_set()
5190 sc->sc_inreset_cnt--; in ath_chan_set()
5192 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5193 ATH_PCU_UNLOCK(sc); in ath_chan_set()
5195 ath_txrx_start(sc); in ath_chan_set()
5208 struct ath_softc *sc = arg; in ath_calibrate() local
5209 struct ath_hal *ah = sc->sc_ah; in ath_calibrate()
5210 struct ieee80211com *ic = &sc->sc_ic; in ath_calibrate()
5215 ATH_LOCK_ASSERT(sc); in ath_calibrate()
5220 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_calibrate()
5223 if (sc->sc_inreset_cnt) in ath_calibrate()
5228 longCal = (ticks - sc->sc_lastlongcal >= ath_longcalinterval*hz); in ath_calibrate()
5229 aniCal = (ticks - sc->sc_lastani >= ath_anicalinterval*hz/1000); in ath_calibrate()
5230 if (sc->sc_doresetcal) in ath_calibrate()
5231 shortCal = (ticks - sc->sc_lastshortcal >= ath_shortcalinterval*hz/1000); in ath_calibrate()
5233 …DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: shortCal=%d; longCal=%d; aniCal=%d\n", __func__, shortCal, l… in ath_calibrate()
5235 sc->sc_stats.ast_ani_cal++; in ath_calibrate()
5236 sc->sc_lastani = ticks; in ath_calibrate()
5237 ath_hal_ani_poll(ah, sc->sc_curchan); in ath_calibrate()
5241 sc->sc_stats.ast_per_cal++; in ath_calibrate()
5242 sc->sc_lastlongcal = ticks; in ath_calibrate()
5248 DPRINTF(sc, ATH_DEBUG_CALIBRATE, in ath_calibrate()
5250 sc->sc_stats.ast_per_rfgain++; in ath_calibrate()
5251 sc->sc_resetcal = 0; in ath_calibrate()
5252 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5253 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_calibrate()
5254 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_calibrate()
5255 ath_power_restore_power_state(sc); in ath_calibrate()
5262 if (sc->sc_resetcal) { in ath_calibrate()
5263 (void) ath_hal_calreset(ah, sc->sc_curchan); in ath_calibrate()
5264 sc->sc_lastcalreset = ticks; in ath_calibrate()
5265 sc->sc_lastshortcal = ticks; in ath_calibrate()
5266 sc->sc_resetcal = 0; in ath_calibrate()
5267 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5274 if (ath_hal_calibrateN(ah, sc->sc_curchan, longCal, &isCalDone)) { in ath_calibrate()
5282 DPRINTF(sc, ATH_DEBUG_ANY, in ath_calibrate()
5284 __func__, sc->sc_curchan->ic_freq); in ath_calibrate()
5285 sc->sc_stats.ast_per_calfail++; in ath_calibrate()
5288 sc->sc_lastshortcal = ticks; in ath_calibrate()
5300 sc->sc_lastshortcal = ticks; in ath_calibrate()
5302 if (sc->sc_opmode != HAL_M_HOSTAP) in ath_calibrate()
5304 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5308 if (sc->sc_lastcalreset == 0) in ath_calibrate()
5309 sc->sc_lastcalreset = sc->sc_lastlongcal; in ath_calibrate()
5310 else if (ticks - sc->sc_lastcalreset >= ath_resetcalinterval*hz) in ath_calibrate()
5311 sc->sc_resetcal = 1; /* setup reset next trip */ in ath_calibrate()
5312 sc->sc_doresetcal = AH_FALSE; in ath_calibrate()
5319 DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: next +%u (%sisCalDone)\n", in ath_calibrate()
5321 callout_reset(&sc->sc_cal_ch, nextcal, ath_calibrate, sc); in ath_calibrate()
5323 DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: calibration disabled\n", in ath_calibrate()
5330 ath_power_restore_power_state(sc); in ath_calibrate()
5336 struct ath_softc *sc = ic->ic_softc; in ath_scan_start() local
5337 struct ath_hal *ah = sc->sc_ah; in ath_scan_start()
5343 ATH_LOCK(sc); in ath_scan_start()
5344 sc->sc_scanning = 1; in ath_scan_start()
5345 sc->sc_syncbeacon = 0; in ath_scan_start()
5346 rfilt = ath_calcrxfilter(sc); in ath_scan_start()
5347 ATH_UNLOCK(sc); in ath_scan_start()
5349 ATH_PCU_LOCK(sc); in ath_scan_start()
5352 ATH_PCU_UNLOCK(sc); in ath_scan_start()
5354 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0\n", in ath_scan_start()
5361 struct ath_softc *sc = ic->ic_softc; in ath_scan_end() local
5362 struct ath_hal *ah = sc->sc_ah; in ath_scan_end()
5365 ATH_LOCK(sc); in ath_scan_end()
5366 sc->sc_scanning = 0; in ath_scan_end()
5367 rfilt = ath_calcrxfilter(sc); in ath_scan_end()
5368 ATH_UNLOCK(sc); in ath_scan_end()
5370 ATH_PCU_LOCK(sc); in ath_scan_end()
5372 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_scan_end()
5375 ATH_PCU_UNLOCK(sc); in ath_scan_end()
5377 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n", in ath_scan_end()
5378 __func__, rfilt, ether_sprintf(sc->sc_curbssid), in ath_scan_end()
5379 sc->sc_curaid); in ath_scan_end()
5401 struct ath_softc *sc = ic->ic_softc; in ath_update_chw() local
5403 DPRINTF(sc, ATH_DEBUG_STATE, "%s: called\n", __func__); in ath_update_chw()
5411 struct ath_softc *sc = ic->ic_softc; in ath_set_channel() local
5413 ATH_LOCK(sc); in ath_set_channel()
5414 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_set_channel()
5415 ATH_UNLOCK(sc); in ath_set_channel()
5417 (void) ath_chan_set(sc, ic->ic_curchan); in ath_set_channel()
5424 ATH_LOCK(sc); in ath_set_channel()
5425 if (!sc->sc_scanning && ic->ic_curchan == ic->ic_bsschan) in ath_set_channel()
5426 sc->sc_syncbeacon = 1; in ath_set_channel()
5427 ath_power_restore_power_state(sc); in ath_set_channel()
5428 ATH_UNLOCK(sc); in ath_set_channel()
5453 struct ath_softc *sc = ic->ic_softc; in ath_newstate() local
5455 struct ath_hal *ah = sc->sc_ah; in ath_newstate()
5473 DPRINTF(sc, ATH_DEBUG_STATE, "%s: %s -> %s\n", __func__, in ath_newstate()
5487 ATH_LOCK(sc); in ath_newstate()
5497 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
5502 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_newstate()
5508 callout_stop(&sc->sc_cal_ch); in ath_newstate()
5509 ATH_UNLOCK(sc); in ath_newstate()
5525 ATH_LOCK(sc); in ath_newstate()
5526 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
5527 ath_power_setpower(sc, HAL_PM_AWAKE); in ath_newstate()
5528 ATH_UNLOCK(sc); in ath_newstate()
5531 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS)); in ath_newstate()
5532 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
5533 sc->sc_beacons = 0; in ath_newstate()
5534 taskqueue_unblock(sc->sc_tq); in ath_newstate()
5538 rfilt = ath_calcrxfilter(sc); in ath_newstate()
5548 sc->sc_curaid = ni->ni_associd; in ath_newstate()
5549 IEEE80211_ADDR_COPY(sc->sc_curbssid, ni->ni_bssid); in ath_newstate()
5550 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_newstate()
5552 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n", in ath_newstate()
5553 __func__, rfilt, ether_sprintf(sc->sc_curbssid), sc->sc_curaid); in ath_newstate()
5582 DPRINTF(sc, ATH_DEBUG_STATE, in ath_newstate()
5607 ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_newstate()
5609 error = ath_beacon_alloc(sc, ni); in ath_newstate()
5622 sc->sc_syncbeacon = 1; in ath_newstate()
5623 } else if (!sc->sc_beacons) { in ath_newstate()
5626 ath_tdma_config(sc, vap); in ath_newstate()
5629 ath_beacon_config(sc, vap); in ath_newstate()
5630 sc->sc_beacons = 1; in ath_newstate()
5651 DPRINTF(sc, ATH_DEBUG_BEACON, in ath_newstate()
5653 sc->sc_syncbeacon = 1; in ath_newstate()
5656 ath_beacon_config(sc, vap); in ath_newstate()
5670 sc->sc_beacons = 1; in ath_newstate()
5679 ath_hal_intrset(ah, sc->sc_imask); in ath_newstate()
5694 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
5695 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
5696 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
5701 ATH_LOCK(sc); in ath_newstate()
5702 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
5703 ath_power_setpower(sc, HAL_PM_AWAKE); in ath_newstate()
5711 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_newstate()
5713 DPRINTF(sc, ATH_DEBUG_CALIBRATE, in ath_newstate()
5716 ATH_UNLOCK(sc); in ath_newstate()
5718 taskqueue_unblock(sc->sc_tq); in ath_newstate()
5728 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
5730 ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL); in ath_newstate()
5731 taskqueue_block(sc->sc_tq); in ath_newstate()
5732 sc->sc_beacons = 0; in ath_newstate()
5740 if (sc->sc_nvaps == 1 && in ath_newstate()
5742 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=%d\n", __func__, sc->sc_syncbeacon); in ath_newstate()
5743 ATH_LOCK(sc); in ath_newstate()
5748 ath_power_setselfgen(sc, HAL_PM_NETWORK_SLEEP); in ath_newstate()
5758 if (sc->sc_syncbeacon == 0) { in ath_newstate()
5759 ath_power_setpower(sc, HAL_PM_NETWORK_SLEEP); in ath_newstate()
5761 ATH_UNLOCK(sc); in ath_newstate()
5771 ATH_LOCK(sc); in ath_newstate()
5772 ath_power_restore_power_state(sc); in ath_newstate()
5773 ATH_UNLOCK(sc); in ath_newstate()
5789 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_setup_stationkey() local
5808 ath_keyset(sc, vap, &ni->ni_ucastkey, vap->iv_bss); in ath_setup_stationkey()
5822 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_newassoc() local
5825 an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate); in ath_newassoc()
5826 an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate); in ath_newassoc()
5828 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: reassoc; isnew=%d, is_powersave=%d\n", in ath_newassoc()
5836 ath_rate_newassoc(sc, an, isnew); in ath_newassoc()
5840 (vap->iv_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey && in ath_newassoc()
5854 DPRINTF(sc, ATH_DEBUG_NODE, in ath_newassoc()
5862 ath_tx_node_reassoc(sc, an); in ath_newassoc()
5866 ath_tx_node_wakeup(sc, an); in ath_newassoc()
5874 struct ath_softc *sc = ic->ic_softc; in ath_setregdomain() local
5875 struct ath_hal *ah = sc->sc_ah; in ath_setregdomain()
5878 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, in ath_setregdomain()
5886 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: failed, status %u\n", in ath_setregdomain()
5898 struct ath_softc *sc = ic->ic_softc; in ath_getradiocaps() local
5899 struct ath_hal *ah = sc->sc_ah; in ath_getradiocaps()
5901 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: use rd %u cc %d\n", in ath_getradiocaps()
5911 ath_getchannels(struct ath_softc *sc) in ath_getchannels() argument
5913 struct ieee80211com *ic = &sc->sc_ic; in ath_getchannels()
5914 struct ath_hal *ah = sc->sc_ah; in ath_getchannels()
5923 device_printf(sc->sc_dev, in ath_getchannels()
5928 (void) ath_hal_getregdomain(ah, &sc->sc_eerd); in ath_getchannels()
5929 ath_hal_getcountrycode(ah, &sc->sc_eecc); /* NB: cannot fail */ in ath_getchannels()
5932 ic->ic_regdomain.regdomain = (uint16_t) sc->sc_eerd; in ath_getchannels()
5933 ic->ic_regdomain.country = (uint16_t) sc->sc_eecc; in ath_getchannels()
5940 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, in ath_getchannels()
5942 __func__, sc->sc_eerd, sc->sc_eecc, in ath_getchannels()
5949 ath_rate_setup(struct ath_softc *sc, u_int mode) in ath_rate_setup() argument
5951 struct ath_hal *ah = sc->sc_ah; in ath_rate_setup()
5986 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid mode %u\n", in ath_rate_setup()
5990 sc->sc_rates[mode] = rt; in ath_rate_setup()
5995 ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) in ath_setcurmode() argument
6022 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); in ath_setcurmode()
6023 rt = sc->sc_rates[mode]; in ath_setcurmode()
6028 sc->sc_rixmap[ieeerate] = i; in ath_setcurmode()
6030 sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; in ath_setcurmode()
6032 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); in ath_setcurmode()
6033 for (i = 0; i < nitems(sc->sc_hwmap); i++) { in ath_setcurmode()
6035 sc->sc_hwmap[i].ledon = (500 * hz) / 1000; in ath_setcurmode()
6036 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; in ath_setcurmode()
6039 sc->sc_hwmap[i].ieeerate = in ath_setcurmode()
6042 sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS; in ath_setcurmode()
6043 sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; in ath_setcurmode()
6046 sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ath_setcurmode()
6047 sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags; in ath_setcurmode()
6049 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) in ath_setcurmode()
6053 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000; in ath_setcurmode()
6054 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000; in ath_setcurmode()
6056 sc->sc_currates = rt; in ath_setcurmode()
6057 sc->sc_curmode = mode; in ath_setcurmode()
6063 sc->sc_protrix = ath_tx_findrix(sc, 2*2); in ath_setcurmode()
6065 sc->sc_protrix = ath_tx_findrix(sc, 2*1); in ath_setcurmode()
6072 struct ath_softc *sc = arg; in ath_watchdog() local
6073 struct ieee80211com *ic = &sc->sc_ic; in ath_watchdog()
6076 ATH_LOCK_ASSERT(sc); in ath_watchdog()
6078 if (sc->sc_wd_timer != 0 && --sc->sc_wd_timer == 0) { in ath_watchdog()
6081 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_watchdog()
6083 if (ath_hal_gethangstate(sc->sc_ah, 0xffff, &hangs) && in ath_watchdog()
6085 device_printf(sc->sc_dev, "%s hang detected (0x%x)\n", in ath_watchdog()
6088 device_printf(sc->sc_dev, "device timeout\n"); in ath_watchdog()
6091 sc->sc_stats.ast_watchdog++; in ath_watchdog()
6093 ath_power_restore_power_state(sc); in ath_watchdog()
6103 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_watchdog()
6106 callout_schedule(&sc->sc_wd_ch, hz); in ath_watchdog()
6112 struct ath_softc *sc = ic->ic_softc; in ath_parent() local
6115 ATH_LOCK(sc); in ath_parent()
6122 if (sc->sc_running) { in ath_parent()
6123 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_parent()
6124 ath_mode_init(sc); in ath_parent()
6125 ath_power_restore_power_state(sc); in ath_parent()
6126 } else if (!sc->sc_invalid) { in ath_parent()
6136 error = ath_init(sc); in ath_parent()
6139 ath_stop(sc); in ath_parent()
6140 if (!sc->sc_invalid) in ath_parent()
6141 ath_power_setpower(sc, HAL_PM_FULL_SLEEP); in ath_parent()
6143 ATH_UNLOCK(sc); in ath_parent()
6147 if (sc->sc_tx99 != NULL) in ath_parent()
6148 sc->sc_tx99->start(sc->sc_tx99); in ath_parent()
6159 ath_announce(struct ath_softc *sc) in ath_announce() argument
6161 struct ath_hal *ah = sc->sc_ah; in ath_announce()
6163 device_printf(sc->sc_dev, "AR%s mac %d.%d RF%s phy %d.%d\n", in ath_announce()
6166 device_printf(sc->sc_dev, "2GHz radio: 0x%.4x; 5GHz radio: 0x%.4x\n", in ath_announce()
6171 struct ath_txq *txq = sc->sc_ac2q[i]; in ath_announce()
6172 device_printf(sc->sc_dev, in ath_announce()
6176 device_printf(sc->sc_dev, "Use hw queue %u for CAB traffic\n", in ath_announce()
6177 sc->sc_cabq->axq_qnum); in ath_announce()
6178 device_printf(sc->sc_dev, "Use hw queue %u for beacons\n", in ath_announce()
6179 sc->sc_bhalq); in ath_announce()
6182 device_printf(sc->sc_dev, "using %u rx buffers\n", ath_rxbuf); in ath_announce()
6184 device_printf(sc->sc_dev, "using %u tx buffers\n", ath_txbuf); in ath_announce()
6185 if (sc->sc_mcastkey && bootverbose) in ath_announce()
6186 device_printf(sc->sc_dev, "using multicast key search\n"); in ath_announce()
6192 struct ath_softc *sc = (struct ath_softc *) p; in ath_dfs_tasklet() local
6193 struct ieee80211com *ic = &sc->sc_ic; in ath_dfs_tasklet()
6200 if (ath_dfs_process_radar_event(sc, sc->sc_curchan)) { in ath_dfs_tasklet()
6208 ieee80211_dfs_notify_radar(ic, sc->sc_curchan); in ath_dfs_tasklet()
6225 struct ath_softc *sc = ic->ic_softc; in ath_node_powersave() local
6230 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d\n", in ath_node_powersave()
6238 ath_tx_node_sleep(sc, an); in ath_node_powersave()
6240 ath_tx_node_wakeup(sc, an); in ath_node_powersave()
6292 struct ath_softc *sc = ic->ic_softc; in ath_node_set_tim() local
6297 ATH_TX_LOCK(sc); in ath_node_set_tim()
6308 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6327 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6333 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6335 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6342 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6346 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6353 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6359 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6366 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6374 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6375 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6421 ath_tx_update_tim(struct ath_softc *sc, struct ieee80211_node *ni, in ath_tx_update_tim() argument
6442 ATH_TX_LOCK_ASSERT(sc); in ath_tx_update_tim()
6448 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_tx_update_tim()
6467 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_tx_update_tim()
6497 struct ath_softc *sc = ic->ic_softc; in ath_node_recv_pspoll() local
6542 ATH_TX_LOCK(sc); in ath_node_recv_pspoll()
6549 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
6554 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
6574 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
6575 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
6595 ath_tx_tid_sched(sc, atid); in ath_node_recv_pspoll()
6601 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
6602 taskqueue_enqueue(sc->sc_tq, &sc->sc_txqtask); in ath_node_recv_pspoll()
6603 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
6612 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
6617 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()