Lines Matching refs:sc

183 static void	ath_txq_init(struct ath_softc *sc, struct ath_txq *, int);
188 static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq,
261 ath_legacy_attach_comp_func(struct ath_softc *sc) in ath_legacy_attach_comp_func() argument
269 switch (sc->sc_txqsetup &~ (1<<sc->sc_cabq->axq_qnum)) { in ath_legacy_attach_comp_func()
271 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc); in ath_legacy_attach_comp_func()
274 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc); in ath_legacy_attach_comp_func()
277 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc); in ath_legacy_attach_comp_func()
299 _ath_power_setpower(struct ath_softc *sc, int power_state, int selfgen, in _ath_power_setpower() argument
302 ATH_LOCK_ASSERT(sc); in _ath_power_setpower()
304 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d, target=%d, cur=%d\n", in _ath_power_setpower()
309 sc->sc_powersave_refcnt, in _ath_power_setpower()
310 sc->sc_target_powerstate, in _ath_power_setpower()
311 sc->sc_cur_powerstate); in _ath_power_setpower()
313 sc->sc_target_powerstate = power_state; in _ath_power_setpower()
322 if ((sc->sc_powersave_refcnt == 0 || power_state == HAL_PM_AWAKE) && in _ath_power_setpower()
323 power_state != sc->sc_cur_powerstate) { in _ath_power_setpower()
324 sc->sc_cur_powerstate = power_state; in _ath_power_setpower()
325 ath_hal_setpower(sc->sc_ah, power_state); in _ath_power_setpower()
336 sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_setpower()
337 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_setpower()
338 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_setpower()
339 sc->sc_target_selfgen_state); in _ath_power_setpower()
353 _ath_power_set_selfgen(struct ath_softc *sc, int power_state, const char *file, int line) in _ath_power_set_selfgen() argument
356 ATH_LOCK_ASSERT(sc); in _ath_power_set_selfgen()
358 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n", in _ath_power_set_selfgen()
363 sc->sc_target_selfgen_state); in _ath_power_set_selfgen()
365 sc->sc_target_selfgen_state = power_state; in _ath_power_set_selfgen()
374 if (sc->sc_cur_powerstate == HAL_PM_AWAKE) { in _ath_power_set_selfgen()
375 ath_hal_setselfgenpower(sc->sc_ah, power_state); in _ath_power_set_selfgen()
389 _ath_power_set_power_state(struct ath_softc *sc, int power_state, const char *file, int line) in _ath_power_set_power_state() argument
391 ATH_LOCK_ASSERT(sc); in _ath_power_set_power_state()
393 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) state=%d, refcnt=%d\n", in _ath_power_set_power_state()
398 sc->sc_powersave_refcnt); in _ath_power_set_power_state()
400 sc->sc_powersave_refcnt++; in _ath_power_set_power_state()
406 if (power_state != sc->sc_cur_powerstate) { in _ath_power_set_power_state()
407 ath_hal_setpower(sc->sc_ah, power_state); in _ath_power_set_power_state()
408 sc->sc_cur_powerstate = power_state; in _ath_power_set_power_state()
412 if (sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_set_power_state()
413 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_set_power_state()
414 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_set_power_state()
415 sc->sc_target_selfgen_state); in _ath_power_set_power_state()
427 _ath_power_restore_power_state(struct ath_softc *sc, const char *file, int line) in _ath_power_restore_power_state() argument
430 ATH_LOCK_ASSERT(sc); in _ath_power_restore_power_state()
432 DPRINTF(sc, ATH_DEBUG_PWRSAVE, "%s: (%s:%d) refcnt=%d, target state=%d\n", in _ath_power_restore_power_state()
436 sc->sc_powersave_refcnt, in _ath_power_restore_power_state()
437 sc->sc_target_powerstate); in _ath_power_restore_power_state()
439 if (sc->sc_powersave_refcnt == 0) in _ath_power_restore_power_state()
440 device_printf(sc->sc_dev, "%s: refcnt=0?\n", __func__); in _ath_power_restore_power_state()
442 sc->sc_powersave_refcnt--; in _ath_power_restore_power_state()
444 if (sc->sc_powersave_refcnt == 0 && in _ath_power_restore_power_state()
445 sc->sc_target_powerstate != sc->sc_cur_powerstate) { in _ath_power_restore_power_state()
446 sc->sc_cur_powerstate = sc->sc_target_powerstate; in _ath_power_restore_power_state()
447 ath_hal_setpower(sc->sc_ah, sc->sc_target_powerstate); in _ath_power_restore_power_state()
453 if (sc->sc_cur_powerstate == HAL_PM_AWAKE && in _ath_power_restore_power_state()
454 sc->sc_target_selfgen_state != HAL_PM_AWAKE) { in _ath_power_restore_power_state()
455 ath_hal_setselfgenpower(sc->sc_ah, in _ath_power_restore_power_state()
456 sc->sc_target_selfgen_state); in _ath_power_restore_power_state()
473 ath_setup_hal_config(struct ath_softc *sc, HAL_OPS_CONFIG *ah_config) in ath_setup_hal_config() argument
477 if (sc->sc_pci_devinfo & (ATH_PCI_CUS198 | ATH_PCI_CUS230)) { in ath_setup_hal_config()
484 device_printf(sc->sc_dev, "configuring for %s\n", in ath_setup_hal_config()
485 (sc->sc_pci_devinfo & ATH_PCI_CUS198) ? in ath_setup_hal_config()
489 if (sc->sc_pci_devinfo & ATH_PCI_CUS217) in ath_setup_hal_config()
490 device_printf(sc->sc_dev, "CUS217 card detected\n"); in ath_setup_hal_config()
492 if (sc->sc_pci_devinfo & ATH_PCI_CUS252) in ath_setup_hal_config()
493 device_printf(sc->sc_dev, "CUS252 card detected\n"); in ath_setup_hal_config()
495 if (sc->sc_pci_devinfo & ATH_PCI_AR9565_1ANT) in ath_setup_hal_config()
496 device_printf(sc->sc_dev, "WB335 1-ANT card detected\n"); in ath_setup_hal_config()
498 if (sc->sc_pci_devinfo & ATH_PCI_AR9565_2ANT) in ath_setup_hal_config()
499 device_printf(sc->sc_dev, "WB335 2-ANT card detected\n"); in ath_setup_hal_config()
501 if (sc->sc_pci_devinfo & ATH_PCI_BT_ANT_DIV) in ath_setup_hal_config()
502 device_printf(sc->sc_dev, in ath_setup_hal_config()
505 if (sc->sc_pci_devinfo & ATH_PCI_KILLER) in ath_setup_hal_config()
506 device_printf(sc->sc_dev, "Killer Wireless card detected\n"); in ath_setup_hal_config()
515 if (sc->sc_pci_devinfo & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { in ath_setup_hal_config()
516 if (!(sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV)) in ath_setup_hal_config()
520 if (sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV) { in ath_setup_hal_config()
522 device_printf(sc->sc_dev, "Set BT/WLAN RX diversity capability\n"); in ath_setup_hal_config()
526 if (sc->sc_pci_devinfo & ATH_PCI_D3_L1_WAR) { in ath_setup_hal_config()
528 device_printf(sc->sc_dev, "Enable WAR for ASPM D3/L1\n"); in ath_setup_hal_config()
532 if (sc->sc_pci_devinfo & ATH9K_PCI_NO_PLL_PWRSAVE) { in ath_setup_hal_config()
534 device_printf(sc->sc_dev, "Disable PLL PowerSave\n"); in ath_setup_hal_config()
546 ath_fetch_mac_kenv(struct ath_softc *sc, uint8_t *macaddr) in ath_fetch_mac_kenv() argument
560 device_get_name(sc->sc_dev), in ath_fetch_mac_kenv()
561 device_get_unit(sc->sc_dev)); in ath_fetch_mac_kenv()
569 device_printf(sc->sc_dev, in ath_fetch_mac_kenv()
599 ath_attach(u_int16_t devid, struct ath_softc *sc) in ath_attach() argument
601 struct ieee80211com *ic = &sc->sc_ic; in ath_attach()
609 DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); in ath_attach()
611 ic->ic_softc = sc; in ath_attach()
612 ic->ic_name = device_get_nameunit(sc->sc_dev); in ath_attach()
621 ath_setup_hal_config(sc, &ah_config); in ath_attach()
623 ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, in ath_attach()
624 sc->sc_eepromdata, &ah_config, &status); in ath_attach()
626 device_printf(sc->sc_dev, in ath_attach()
631 sc->sc_ah = ah; in ath_attach()
632 sc->sc_invalid = 0; /* ready to go, enable interrupt handling */ in ath_attach()
634 sc->sc_debug = ath_debug; in ath_attach()
644 ATH_LOCK(sc); in ath_attach()
645 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_attach()
646 ATH_UNLOCK(sc); in ath_attach()
654 if (ath_hal_hasedma(sc->sc_ah)) { in ath_attach()
655 sc->sc_isedma = 1; in ath_attach()
656 ath_recv_setup_edma(sc); in ath_attach()
657 ath_xmit_setup_edma(sc); in ath_attach()
659 ath_recv_setup_legacy(sc); in ath_attach()
660 ath_xmit_setup_legacy(sc); in ath_attach()
663 if (ath_hal_hasmybeacon(sc->sc_ah)) { in ath_attach()
664 sc->sc_do_mybeacon = 1; in ath_attach()
674 sc->sc_mrretry = ath_hal_setupxtxdesc(ah, NULL, 0,0, 0,0, 0,0); in ath_attach()
682 sc->sc_needmib = 1; in ath_attach()
687 sc->sc_keymax = ath_hal_keycachesize(ah); in ath_attach()
688 if (sc->sc_keymax > ATH_KEYMAX) { in ath_attach()
689 device_printf(sc->sc_dev, in ath_attach()
691 ATH_KEYMAX, sc->sc_keymax); in ath_attach()
692 sc->sc_keymax = ATH_KEYMAX; in ath_attach()
698 for (i = 0; i < sc->sc_keymax; i++) in ath_attach()
704 error = ath_getchannels(sc); in ath_attach()
711 ath_rate_setup(sc, IEEE80211_MODE_11A); in ath_attach()
712 ath_rate_setup(sc, IEEE80211_MODE_11B); in ath_attach()
713 ath_rate_setup(sc, IEEE80211_MODE_11G); in ath_attach()
714 ath_rate_setup(sc, IEEE80211_MODE_TURBO_A); in ath_attach()
715 ath_rate_setup(sc, IEEE80211_MODE_TURBO_G); in ath_attach()
716 ath_rate_setup(sc, IEEE80211_MODE_STURBO_A); in ath_attach()
717 ath_rate_setup(sc, IEEE80211_MODE_11NA); in ath_attach()
718 ath_rate_setup(sc, IEEE80211_MODE_11NG); in ath_attach()
719 ath_rate_setup(sc, IEEE80211_MODE_HALF); in ath_attach()
720 ath_rate_setup(sc, IEEE80211_MODE_QUARTER); in ath_attach()
723 ath_setcurmode(sc, IEEE80211_MODE_11A); in ath_attach()
728 error = ath_desc_alloc(sc); in ath_attach()
730 device_printf(sc->sc_dev, in ath_attach()
734 error = ath_txdma_setup(sc); in ath_attach()
736 device_printf(sc->sc_dev, in ath_attach()
744 error = ath_rxdma_setup(sc); in ath_attach()
746 device_printf(sc->sc_dev, in ath_attach()
751 callout_init_mtx(&sc->sc_cal_ch, &sc->sc_mtx, 0); in ath_attach()
752 callout_init_mtx(&sc->sc_wd_ch, &sc->sc_mtx, 0); in ath_attach()
754 ATH_TXBUF_LOCK_INIT(sc); in ath_attach()
756 sc->sc_tq = taskqueue_create("ath_taskq", M_NOWAIT, in ath_attach()
757 taskqueue_thread_enqueue, &sc->sc_tq); in ath_attach()
758 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", in ath_attach()
759 device_get_nameunit(sc->sc_dev)); in ath_attach()
761 TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); in ath_attach()
762 TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); in ath_attach()
763 TASK_INIT(&sc->sc_tsfoortask, 0, ath_tsfoor_proc, sc); in ath_attach()
764 TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); in ath_attach()
765 TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc); in ath_attach()
766 TASK_INIT(&sc->sc_txqtask, 0, ath_txq_sched_tasklet, sc); in ath_attach()
767 TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc); in ath_attach()
777 sc->sc_bhalq = ath_beaconq_setup(sc); in ath_attach()
778 if (sc->sc_bhalq == (u_int) -1) { in ath_attach()
779 device_printf(sc->sc_dev, in ath_attach()
784 sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0); in ath_attach()
785 if (sc->sc_cabq == NULL) { in ath_attach()
786 device_printf(sc->sc_dev, "unable to setup CAB xmit queue!\n"); in ath_attach()
791 if (!ath_tx_setup(sc, WME_AC_BK, HAL_WME_AC_BK)) { in ath_attach()
792 device_printf(sc->sc_dev, in ath_attach()
798 if (!ath_tx_setup(sc, WME_AC_BE, HAL_WME_AC_BE) || in ath_attach()
799 !ath_tx_setup(sc, WME_AC_VI, HAL_WME_AC_VI) || in ath_attach()
800 !ath_tx_setup(sc, WME_AC_VO, HAL_WME_AC_VO)) { in ath_attach()
808 if (sc->sc_ac2q[WME_AC_VI] != NULL) in ath_attach()
809 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]); in ath_attach()
810 if (sc->sc_ac2q[WME_AC_BE] != NULL) in ath_attach()
811 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]); in ath_attach()
812 sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
813 sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
814 sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
823 sc->sc_tx.xmit_attach_comp_func(sc); in ath_attach()
831 sc->sc_setdefantenna = ath_setdefantenna; in ath_attach()
832 sc->sc_rc = ath_rate_attach(sc); in ath_attach()
833 if (sc->sc_rc == NULL) { in ath_attach()
839 if (! ath_dfs_attach(sc)) { in ath_attach()
840 device_printf(sc->sc_dev, in ath_attach()
847 if (ath_spectral_attach(sc) < 0) { in ath_attach()
848 device_printf(sc->sc_dev, in ath_attach()
855 if (ath_btcoex_attach(sc) < 0) { in ath_attach()
856 device_printf(sc->sc_dev, in ath_attach()
863 if (ath_lna_div_attach(sc) < 0) { in ath_attach()
864 device_printf(sc->sc_dev, in ath_attach()
871 TASK_INIT(&sc->sc_dfstask, 0, ath_dfs_tasklet, sc); in ath_attach()
874 sc->sc_blinking = 0; in ath_attach()
875 sc->sc_ledstate = 1; in ath_attach()
876 sc->sc_ledon = 0; /* low true */ in ath_attach()
877 sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ in ath_attach()
878 callout_init(&sc->sc_ledtimer, 1); in ath_attach()
891 sc->sc_hardled = (1 == 0); in ath_attach()
892 sc->sc_led_net_pin = -1; in ath_attach()
893 sc->sc_led_pwr_pin = -1; in ath_attach()
899 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); in ath_attach()
900 ath_led_config(sc); in ath_attach()
953 sc->sc_splitmic = 1; in ath_attach()
960 sc->sc_wmetkipmic = 1; in ath_attach()
962 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR); in ath_attach()
966 if (ath_hal_hasmcastkeysearch(sc->sc_ah) && in ath_attach()
967 !ath_hal_getmcastkeysearch(sc->sc_ah)) { in ath_attach()
968 ath_hal_setmcastkeysearch(sc->sc_ah, 1); in ath_attach()
970 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); in ath_attach()
977 setbit(sc->sc_keymap, i); in ath_attach()
978 setbit(sc->sc_keymap, i+64); in ath_attach()
979 if (sc->sc_splitmic) { in ath_attach()
980 setbit(sc->sc_keymap, i+32); in ath_attach()
981 setbit(sc->sc_keymap, i+32+64); in ath_attach()
997 if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK]) in ath_attach()
1004 sc->sc_hasbmask = ath_hal_hasbssidmask(ah); in ath_attach()
1005 sc->sc_hasbmatch = ath_hal_hasbssidmatch(ah); in ath_attach()
1006 sc->sc_hastsfadd = ath_hal_hastsfadjust(ah); in ath_attach()
1007 sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah); in ath_attach()
1012 sc->sc_rxtsf32 = 1; in ath_attach()
1015 device_printf(sc->sc_dev, "RX timestamp: %d bits\n", i); in ath_attach()
1019 device_printf(sc->sc_dev, "TX timestamp: %d bits\n", i); in ath_attach()
1022 sc->sc_hasenforcetxop = ath_hal_hasenforcetxop(ah); in ath_attach()
1023 sc->sc_rx_lnamixer = ath_hal_hasrxlnamixer(ah); in ath_attach()
1024 sc->sc_hasdivcomb = ath_hal_hasdivantcomb(ah); in ath_attach()
1041 if (sc->sc_pci_devinfo & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { in ath_attach()
1042 device_printf(sc->sc_dev, "%s: WB335: disabling LNA mixer diversity\n", in ath_attach()
1044 sc->sc_dolnadiv = 0; in ath_attach()
1065 sc->sc_txq_data_minfree = 10; in ath_attach()
1075 sc->sc_txq_mcastq_maxdepth = MIN(64, ath_txbuf / 4); in ath_attach()
1080 sc->sc_txq_node_psq_maxdepth = 16; in ath_attach()
1093 sc->sc_txq_node_maxdepth = MIN(128, ath_txbuf / 4); in ath_attach()
1096 sc->sc_cabq_enable = 1; in ath_attach()
1106 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1107 device_get_unit(sc->sc_dev), "rx_chainmask", in ath_attach()
1109 device_printf(sc->sc_dev, "Setting RX chainmask to 0x%x\n", in ath_attach()
1111 (void) ath_hal_setrxchainmask(sc->sc_ah, rx_chainmask); in ath_attach()
1113 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1114 device_get_unit(sc->sc_dev), "tx_chainmask", in ath_attach()
1116 device_printf(sc->sc_dev, "Setting TX chainmask to 0x%x\n", in ath_attach()
1118 (void) ath_hal_settxchainmask(sc->sc_ah, tx_chainmask); in ath_attach()
1126 ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask); in ath_attach()
1127 ath_hal_gettxchainmask(ah, &sc->sc_txchainmask); in ath_attach()
1133 sc->sc_mrrprot = 0; /* XXX should be a capability */ in ath_attach()
1139 &sc->sc_ent_cfg) == HAL_OK) in ath_attach()
1140 sc->sc_use_ent = 1; in ath_attach()
1151 device_printf(sc->sc_dev, "[HT] enabling HT modes\n"); in ath_attach()
1153 sc->sc_mrrprot = 1; /* XXX should be a capability */ in ath_attach()
1170 device_printf(sc->sc_dev, in ath_attach()
1198 sc->sc_rx_stbc = 1; in ath_attach()
1199 device_printf(sc->sc_dev, in ath_attach()
1205 sc->sc_tx_stbc = 1; in ath_attach()
1206 device_printf(sc->sc_dev, in ath_attach()
1212 &sc->sc_rts_aggr_limit); in ath_attach()
1213 if (sc->sc_rts_aggr_limit != (64 * 1024)) in ath_attach()
1214 device_printf(sc->sc_dev, in ath_attach()
1216 sc->sc_rts_aggr_limit / 1024); in ath_attach()
1223 sc->sc_has_ldpc = 1; in ath_attach()
1224 device_printf(sc->sc_dev, in ath_attach()
1230 device_printf(sc->sc_dev, in ath_attach()
1238 sc->sc_hwq_limit_aggr = ATH_AGGR_MIN_QDEPTH; in ath_attach()
1239 sc->sc_hwq_limit_nonaggr = ATH_NONAGGR_MIN_QDEPTH; in ath_attach()
1240 sc->sc_tid_hwq_lo = ATH_AGGR_SCHED_LOW; in ath_attach()
1241 sc->sc_tid_hwq_hi = ATH_AGGR_SCHED_HIGH; in ath_attach()
1242 sc->sc_aggr_limit = ATH_AGGR_MAXSIZE; in ath_attach()
1243 sc->sc_delim_min_pad = 0; in ath_attach()
1252 sc->sc_ah->ah_config.ah_serialise_reg_war = 1; in ath_attach()
1253 device_printf(sc->sc_dev, in ath_attach()
1260 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_HP]); in ath_attach()
1261 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_LP]); in ath_attach()
1272 sc->sc_defant = ath_hal_getdefantenna(ah); in ath_attach()
1278 sc->sc_hasveol = ath_hal_hasveol(ah); in ath_attach()
1281 if (ath_fetch_mac_kenv(sc, ic->ic_macaddr) == 0) { in ath_attach()
1288 if (sc->sc_hasbmask) in ath_attach()
1289 ath_hal_getbssidmask(ah, sc->sc_hwbssidmask); in ath_attach()
1292 ic->ic_max_keyix = sc->sc_keymax; in ath_attach()
1297 sc->sc_opmode = HAL_M_STA; in ath_attach()
1312 sc->sc_node_free = ic->ic_node_free; in ath_attach()
1314 sc->sc_node_cleanup = ic->ic_node_cleanup; in ath_attach()
1322 sc->sc_addba_request = ic->ic_addba_request; in ath_attach()
1323 sc->sc_addba_response = ic->ic_addba_response; in ath_attach()
1324 sc->sc_addba_stop = ic->ic_addba_stop; in ath_attach()
1325 sc->sc_bar_response = ic->ic_bar_response; in ath_attach()
1326 sc->sc_addba_response_timeout = ic->ic_addba_response_timeout; in ath_attach()
1344 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 0, in ath_attach()
1346 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 1, in ath_attach()
1353 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), in ath_attach()
1355 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), in ath_attach()
1363 if_ath_alq_init(&sc->sc_alq, device_get_nameunit(sc->sc_dev)); in ath_attach()
1364 if_ath_alq_setcfg(&sc->sc_alq, in ath_attach()
1365 sc->sc_ah->ah_macVersion, in ath_attach()
1366 sc->sc_ah->ah_macRev, in ath_attach()
1367 sc->sc_ah->ah_phyRev, in ath_attach()
1368 sc->sc_ah->ah_magic); in ath_attach()
1375 ath_sysctlattach(sc); in ath_attach()
1376 ath_sysctl_stats_attach(sc); in ath_attach()
1377 ath_sysctl_hal_attach(sc); in ath_attach()
1381 ath_announce(sc); in ath_attach()
1386 ATH_LOCK(sc); in ath_attach()
1387 ath_power_setpower(sc, HAL_PM_FULL_SLEEP, 1); in ath_attach()
1388 ATH_UNLOCK(sc); in ath_attach()
1392 ath_tx_cleanup(sc); in ath_attach()
1393 ath_desc_free(sc); in ath_attach()
1394 ath_txdma_teardown(sc); in ath_attach()
1395 ath_rxdma_teardown(sc); in ath_attach()
1400 sc->sc_invalid = 1; in ath_attach()
1405 ath_detach(struct ath_softc *sc) in ath_detach() argument
1428 ATH_LOCK(sc); in ath_detach()
1429 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_detach()
1430 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_detach()
1435 ath_stop(sc); in ath_detach()
1436 ATH_UNLOCK(sc); in ath_detach()
1438 ieee80211_ifdetach(&sc->sc_ic); in ath_detach()
1439 taskqueue_free(sc->sc_tq); in ath_detach()
1441 if (sc->sc_tx99 != NULL) in ath_detach()
1442 sc->sc_tx99->detach(sc->sc_tx99); in ath_detach()
1444 ath_rate_detach(sc->sc_rc); in ath_detach()
1446 if_ath_alq_tidyup(&sc->sc_alq); in ath_detach()
1448 ath_lna_div_detach(sc); in ath_detach()
1449 ath_btcoex_detach(sc); in ath_detach()
1450 ath_spectral_detach(sc); in ath_detach()
1451 ath_dfs_detach(sc); in ath_detach()
1452 ath_desc_free(sc); in ath_detach()
1453 ath_txdma_teardown(sc); in ath_detach()
1454 ath_rxdma_teardown(sc); in ath_detach()
1455 ath_tx_cleanup(sc); in ath_detach()
1456 ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ in ath_detach()
1468 assign_address(struct ath_softc *sc, uint8_t mac[IEEE80211_ADDR_LEN], int clone) in assign_address() argument
1472 if (clone && sc->sc_hasbmask) { in assign_address()
1475 if ((sc->sc_bssidmask & (1<<i)) == 0) in assign_address()
1481 sc->sc_bssidmask |= 1<<i; in assign_address()
1482 sc->sc_hwbssidmask[0] &= ~mac[0]; in assign_address()
1484 sc->sc_nbssid0++; in assign_address()
1488 reclaim_address(struct ath_softc *sc, const uint8_t mac[IEEE80211_ADDR_LEN]) in reclaim_address() argument
1493 if (i != 0 || --sc->sc_nbssid0 == 0) { in reclaim_address()
1494 sc->sc_bssidmask &= ~(1<<i); in reclaim_address()
1498 if (sc->sc_bssidmask & (1<<i)) in reclaim_address()
1500 sc->sc_hwbssidmask[0] |= mask; in reclaim_address()
1511 assign_bslot(struct ath_softc *sc) in assign_bslot() argument
1517 if (sc->sc_bslot[slot] == NULL) { in assign_bslot()
1518 if (sc->sc_bslot[(slot+1)%ATH_BCBUF] == NULL && in assign_bslot()
1519 sc->sc_bslot[(slot-1)%ATH_BCBUF] == NULL) in assign_bslot()
1533 struct ath_softc *sc = ic->ic_softc; in ath_vap_create() local
1544 ATH_LOCK(sc); in ath_vap_create()
1548 if (sc->sc_nstavaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1549 device_printf(sc->sc_dev, "only 1 sta vap supported\n"); in ath_vap_create()
1552 if (sc->sc_nvaps) { in ath_vap_create()
1567 if (sc->sc_nvaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1568 device_printf(sc->sc_dev, in ath_vap_create()
1577 if (sc->sc_nvaps != 0) { in ath_vap_create()
1578 device_printf(sc->sc_dev, in ath_vap_create()
1588 if (sc->sc_nvaps != 0 && ic->ic_opmode != opmode) { in ath_vap_create()
1603 if (sc->sc_nvaps != 0 && ic->ic_opmode == IEEE80211_M_STA) { in ath_vap_create()
1604 device_printf(sc->sc_dev, in ath_vap_create()
1614 if (sc->sc_nvaps == 0) in ath_vap_create()
1620 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in ath_vap_create()
1626 if (needbeacon & TAILQ_EMPTY(&sc->sc_bbuf)) { in ath_vap_create()
1627 device_printf(sc->sc_dev, "no beacon buffer available\n"); in ath_vap_create()
1633 assign_address(sc, mac, flags & IEEE80211_CLONE_BSSID); in ath_vap_create()
1634 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1639 ATH_UNLOCK(sc); in ath_vap_create()
1641 ATH_LOCK(sc); in ath_vap_create()
1643 device_printf(sc->sc_dev, "%s: error %d creating vap\n", in ath_vap_create()
1697 avp->av_bcbuf = TAILQ_FIRST(&sc->sc_bbuf); in ath_vap_create()
1698 TAILQ_REMOVE(&sc->sc_bbuf, avp->av_bcbuf, bf_list); in ath_vap_create()
1699 if (opmode != IEEE80211_M_IBSS || !sc->sc_hasveol) { in ath_vap_create()
1704 avp->av_bslot = assign_bslot(sc); in ath_vap_create()
1705 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL, in ath_vap_create()
1707 sc->sc_bslot[avp->av_bslot] = vap; in ath_vap_create()
1708 sc->sc_nbcnvaps++; in ath_vap_create()
1710 if (sc->sc_hastsfadd && sc->sc_nbcnvaps > 0) { in ath_vap_create()
1716 sc->sc_stagbeacons = 1; in ath_vap_create()
1718 ath_txq_init(sc, &avp->av_mcastq, ATH_TXQ_SWQ); in ath_vap_create()
1723 sc->sc_nvaps++; in ath_vap_create()
1725 sc->sc_nstavaps++; in ath_vap_create()
1727 sc->sc_nmeshvaps++; in ath_vap_create()
1731 sc->sc_opmode = HAL_M_IBSS; in ath_vap_create()
1734 sc->sc_opmode = HAL_M_STA; in ath_vap_create()
1739 sc->sc_tdma = 1; in ath_vap_create()
1741 sc->sc_stagbeacons = 0; in ath_vap_create()
1751 sc->sc_opmode = HAL_M_HOSTAP; in ath_vap_create()
1754 sc->sc_opmode = HAL_M_MONITOR; in ath_vap_create()
1760 if (sc->sc_hastsfadd) { in ath_vap_create()
1764 ath_hal_settsfadjust(sc->sc_ah, sc->sc_stagbeacons); in ath_vap_create()
1770 sc->sc_swbmiss = 1; in ath_vap_create()
1772 ATH_UNLOCK(sc); in ath_vap_create()
1779 reclaim_address(sc, mac); in ath_vap_create()
1780 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1783 ATH_UNLOCK(sc); in ath_vap_create()
1791 struct ath_softc *sc = ic->ic_softc; in ath_vap_delete() local
1792 struct ath_hal *ah = sc->sc_ah; in ath_vap_delete()
1795 ATH_LOCK(sc); in ath_vap_delete()
1796 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_vap_delete()
1797 ATH_UNLOCK(sc); in ath_vap_delete()
1799 DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); in ath_vap_delete()
1800 if (sc->sc_running) { in ath_vap_delete()
1808 ath_stoprecv(sc, 1); /* stop recv side */ in ath_vap_delete()
1809 ath_rx_flush(sc); in ath_vap_delete()
1810 ath_draintxq(sc, ATH_RESET_DEFAULT); /* stop hw xmit side */ in ath_vap_delete()
1834 ath_draintxq(sc, ATH_RESET_DEFAULT); in ath_vap_delete()
1836 ATH_LOCK(sc); in ath_vap_delete()
1844 sc->sc_bslot[avp->av_bslot] = NULL; in ath_vap_delete()
1845 sc->sc_nbcnvaps--; in ath_vap_delete()
1847 ath_beacon_return(sc, avp->av_bcbuf); in ath_vap_delete()
1849 if (sc->sc_nbcnvaps == 0) { in ath_vap_delete()
1850 sc->sc_stagbeacons = 0; in ath_vap_delete()
1851 if (sc->sc_hastsfadd) in ath_vap_delete()
1852 ath_hal_settsfadjust(sc->sc_ah, 0); in ath_vap_delete()
1857 ath_tx_draintxq(sc, &avp->av_mcastq); in ath_vap_delete()
1863 sc->sc_nstavaps--; in ath_vap_delete()
1864 if (sc->sc_nstavaps == 0 && sc->sc_swbmiss) in ath_vap_delete()
1865 sc->sc_swbmiss = 0; in ath_vap_delete()
1869 reclaim_address(sc, vap->iv_myaddr); in ath_vap_delete()
1870 ath_hal_setbssidmask(ah, sc->sc_hwbssidmask); in ath_vap_delete()
1872 sc->sc_nmeshvaps--; in ath_vap_delete()
1875 sc->sc_nvaps--; in ath_vap_delete()
1878 if (sc->sc_tdma && sc->sc_nvaps == 0) { in ath_vap_delete()
1879 sc->sc_tdma = 0; in ath_vap_delete()
1880 sc->sc_swbmiss = 0; in ath_vap_delete()
1885 if (sc->sc_running) { in ath_vap_delete()
1890 if (ath_startrecv(sc) != 0) in ath_vap_delete()
1891 device_printf(sc->sc_dev, in ath_vap_delete()
1893 if (sc->sc_beacons) { /* restart beacons */ in ath_vap_delete()
1895 if (sc->sc_tdma) in ath_vap_delete()
1896 ath_tdma_config(sc, NULL); in ath_vap_delete()
1899 ath_beacon_config(sc, NULL); in ath_vap_delete()
1901 ath_hal_intrset(ah, sc->sc_imask); in ath_vap_delete()
1905 ath_power_restore_power_state(sc); in ath_vap_delete()
1906 ATH_UNLOCK(sc); in ath_vap_delete()
1910 ath_suspend(struct ath_softc *sc) in ath_suspend() argument
1912 struct ieee80211com *ic = &sc->sc_ic; in ath_suspend()
1914 sc->sc_resume_up = ic->ic_nrunning != 0; in ath_suspend()
1931 ath_hal_intrset(sc->sc_ah, 0); in ath_suspend()
1932 taskqueue_block(sc->sc_tq); in ath_suspend()
1934 ATH_LOCK(sc); in ath_suspend()
1935 callout_stop(&sc->sc_cal_ch); in ath_suspend()
1936 ATH_UNLOCK(sc); in ath_suspend()
1943 ath_hal_enablepcie(sc->sc_ah, 1, 1); in ath_suspend()
1953 ath_reset_keycache(struct ath_softc *sc) in ath_reset_keycache() argument
1955 struct ieee80211com *ic = &sc->sc_ic; in ath_reset_keycache()
1956 struct ath_hal *ah = sc->sc_ah; in ath_reset_keycache()
1959 ATH_LOCK(sc); in ath_reset_keycache()
1960 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_reset_keycache()
1961 for (i = 0; i < sc->sc_keymax; i++) in ath_reset_keycache()
1963 ath_power_restore_power_state(sc); in ath_reset_keycache()
1964 ATH_UNLOCK(sc); in ath_reset_keycache()
1973 ath_update_chainmasks(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_update_chainmasks() argument
1980 sc->sc_cur_rxchainmask = sc->sc_rxchainmask; in ath_update_chainmasks()
1982 sc->sc_cur_txchainmask = sc->sc_txchainmask; in ath_update_chainmasks()
1984 sc->sc_cur_txchainmask = 1; in ath_update_chainmasks()
1987 DPRINTF(sc, ATH_DEBUG_RESET, in ath_update_chainmasks()
1990 sc->sc_cur_txchainmask, in ath_update_chainmasks()
1991 sc->sc_cur_rxchainmask); in ath_update_chainmasks()
1995 ath_resume(struct ath_softc *sc) in ath_resume() argument
1997 struct ieee80211com *ic = &sc->sc_ic; in ath_resume()
1998 struct ath_hal *ah = sc->sc_ah; in ath_resume()
2007 ath_update_chainmasks(sc, in ath_resume()
2008 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan); in ath_resume()
2009 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_resume()
2010 sc->sc_cur_rxchainmask); in ath_resume()
2013 ATH_LOCK(sc); in ath_resume()
2014 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_resume()
2015 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_resume()
2016 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_resume()
2017 ATH_UNLOCK(sc); in ath_resume()
2019 ath_hal_reset(ah, sc->sc_opmode, in ath_resume()
2020 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan, in ath_resume()
2022 ath_reset_keycache(sc); in ath_resume()
2024 ATH_RX_LOCK(sc); in ath_resume()
2025 sc->sc_rx_stopped = 1; in ath_resume()
2026 sc->sc_rx_resetted = 1; in ath_resume()
2027 ATH_RX_UNLOCK(sc); in ath_resume()
2030 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_resume()
2033 ath_spectral_enable(sc, ic->ic_curchan); in ath_resume()
2038 ath_btcoex_enable(sc, ic->ic_curchan); in ath_resume()
2044 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_resume()
2045 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_resume()
2047 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_resume()
2050 ath_led_config(sc); in ath_resume()
2053 if (sc->sc_resume_up) in ath_resume()
2056 ATH_LOCK(sc); in ath_resume()
2057 ath_power_restore_power_state(sc); in ath_resume()
2058 ATH_UNLOCK(sc); in ath_resume()
2064 ath_shutdown(struct ath_softc *sc) in ath_shutdown() argument
2067 ATH_LOCK(sc); in ath_shutdown()
2068 ath_stop(sc); in ath_shutdown()
2069 ATH_UNLOCK(sc); in ath_shutdown()
2079 struct ath_softc *sc = arg; in ath_intr() local
2080 struct ath_hal *ah = sc->sc_ah; in ath_intr()
2088 ATH_PCU_LOCK(sc); in ath_intr()
2089 if (sc->sc_inreset_cnt) { in ath_intr()
2093 DPRINTF(sc, ATH_DEBUG_ANY, in ath_intr()
2096 ATH_PCU_UNLOCK(sc); in ath_intr()
2100 if (sc->sc_invalid) { in ath_intr()
2105 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid; ignored\n", __func__); in ath_intr()
2106 ATH_PCU_UNLOCK(sc); in ath_intr()
2110 ATH_PCU_UNLOCK(sc); in ath_intr()
2114 ATH_LOCK(sc); in ath_intr()
2115 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_intr()
2116 ATH_UNLOCK(sc); in ath_intr()
2118 if (sc->sc_ic.ic_nrunning == 0 && sc->sc_running == 0) { in ath_intr()
2121 DPRINTF(sc, ATH_DEBUG_ANY, "%s: ic_nrunning %d sc_running %d\n", in ath_intr()
2122 __func__, sc->sc_ic.ic_nrunning, sc->sc_running); in ath_intr()
2125 ATH_PCU_UNLOCK(sc); in ath_intr()
2127 ATH_LOCK(sc); in ath_intr()
2128 ath_power_restore_power_state(sc); in ath_intr()
2129 ATH_UNLOCK(sc); in ath_intr()
2140 DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status); in ath_intr()
2141 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1, "ath_intr: mask=0x%.8x", status); in ath_intr()
2143 if_ath_alq_post_intr(&sc->sc_alq, status, ah->ah_intrstate, in ath_intr()
2147 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 5, in ath_intr()
2161 sc->sc_intr_stats.sync_intr[i]++; in ath_intr()
2164 status &= sc->sc_imask; /* discard unasked for bits */ in ath_intr()
2168 ATH_PCU_UNLOCK(sc); in ath_intr()
2170 ATH_LOCK(sc); in ath_intr()
2171 ath_power_restore_power_state(sc); in ath_intr()
2172 ATH_UNLOCK(sc); in ath_intr()
2181 sc->sc_intr_cnt++; in ath_intr()
2182 ATH_PCU_UNLOCK(sc); in ath_intr()
2190 sc->sc_stats.ast_hardware++; in ath_intr()
2192 taskqueue_enqueue(sc->sc_tq, &sc->sc_fataltask); in ath_intr()
2202 if (sc->sc_tdma) { in ath_intr()
2203 if (sc->sc_tdmaswba == 0) { in ath_intr()
2204 struct ieee80211com *ic = &sc->sc_ic; in ath_intr()
2207 ath_tdma_beacon_send(sc, vap); in ath_intr()
2208 sc->sc_tdmaswba = in ath_intr()
2211 sc->sc_tdmaswba--; in ath_intr()
2215 ath_beacon_proc(sc, 0); in ath_intr()
2222 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2228 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXEOL"); in ath_intr()
2229 if (! sc->sc_isedma) { in ath_intr()
2230 ATH_PCU_LOCK(sc); in ath_intr()
2236 sc->sc_stats.ast_rxeol++; in ath_intr()
2246 imask = sc->sc_imask; in ath_intr()
2260 if (! sc->sc_kickpcu) in ath_intr()
2261 sc->sc_rxlink = NULL; in ath_intr()
2262 sc->sc_kickpcu = 1; in ath_intr()
2263 ATH_PCU_UNLOCK(sc); in ath_intr()
2270 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2273 sc->sc_stats.ast_txurn++; in ath_intr()
2282 sc->sc_stats.ast_rx_intr++; in ath_intr()
2283 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2286 sc->sc_stats.ast_tx_intr++; in ath_intr()
2292 if (! sc->sc_isedma) { in ath_intr()
2293 ATH_PCU_LOCK(sc); in ath_intr()
2295 ath_hal_gettxintrtxqs(sc->sc_ah, &txqs); in ath_intr()
2296 ATH_KTR(sc, ATH_KTR_INTERRUPTS, 3, in ath_intr()
2299 sc->sc_txq_active, in ath_intr()
2300 sc->sc_txq_active | txqs); in ath_intr()
2301 sc->sc_txq_active |= txqs; in ath_intr()
2302 ATH_PCU_UNLOCK(sc); in ath_intr()
2304 taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask); in ath_intr()
2307 sc->sc_stats.ast_bmiss++; in ath_intr()
2308 taskqueue_enqueue(sc->sc_tq, &sc->sc_bmisstask); in ath_intr()
2311 sc->sc_stats.ast_tx_timeout++; in ath_intr()
2313 sc->sc_stats.ast_tx_cst++; in ath_intr()
2315 sc->sc_stats.ast_mib++; in ath_intr()
2316 ATH_PCU_LOCK(sc); in ath_intr()
2326 ath_hal_mibevent(ah, &sc->sc_halstats); in ath_intr()
2333 if (sc->sc_kickpcu == 0) in ath_intr()
2334 ath_hal_intrset(ah, sc->sc_imask); in ath_intr()
2335 ATH_PCU_UNLOCK(sc); in ath_intr()
2339 ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_intr: RXORN"); in ath_intr()
2340 sc->sc_stats.ast_rxorn++; in ath_intr()
2349 sc->sc_stats.ast_tsfoor++; in ath_intr()
2350 ATH_LOCK(sc); in ath_intr()
2351 ath_power_setpower(sc, HAL_PM_AWAKE, 0); in ath_intr()
2352 ATH_UNLOCK(sc); in ath_intr()
2353 taskqueue_enqueue(sc->sc_tq, &sc->sc_tsfoortask); in ath_intr()
2354 device_printf(sc->sc_dev, "%s: TSFOOR\n", __func__); in ath_intr()
2357 ath_btcoex_mci_intr(sc); in ath_intr()
2360 ATH_PCU_LOCK(sc); in ath_intr()
2361 sc->sc_intr_cnt--; in ath_intr()
2362 ATH_PCU_UNLOCK(sc); in ath_intr()
2364 ATH_LOCK(sc); in ath_intr()
2365 ath_power_restore_power_state(sc); in ath_intr()
2366 ATH_UNLOCK(sc); in ath_intr()
2372 struct ath_softc *sc = arg; in ath_fatal_proc() local
2377 if (sc->sc_invalid) in ath_fatal_proc()
2380 device_printf(sc->sc_dev, "hardware error; resetting\n"); in ath_fatal_proc()
2386 if (ath_hal_getfatalstate(sc->sc_ah, &sp, &len)) { in ath_fatal_proc()
2389 device_printf(sc->sc_dev, in ath_fatal_proc()
2393 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_FORCE_COLD); in ath_fatal_proc()
2399 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_bmiss_vap() local
2415 ATH_LOCK(sc); in ath_bmiss_vap()
2416 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_bmiss_vap()
2417 ATH_UNLOCK(sc); in ath_bmiss_vap()
2420 u_int64_t lastrx = sc->sc_lastrx; in ath_bmiss_vap()
2421 u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah); in ath_bmiss_vap()
2426 DPRINTF(sc, ATH_DEBUG_BEACON, in ath_bmiss_vap()
2433 sc->sc_stats.ast_bmiss_phantom++; in ath_bmiss_vap()
2435 ATH_LOCK(sc); in ath_bmiss_vap()
2436 ath_power_restore_power_state(sc); in ath_bmiss_vap()
2437 ATH_UNLOCK(sc); in ath_bmiss_vap()
2454 ATH_LOCK(sc); in ath_bmiss_vap()
2455 ath_power_setpower(sc, HAL_PM_AWAKE, 0); in ath_bmiss_vap()
2456 ath_power_restore_power_state(sc); in ath_bmiss_vap()
2457 ATH_UNLOCK(sc); in ath_bmiss_vap()
2459 DPRINTF(sc, ATH_DEBUG_BEACON, in ath_bmiss_vap()
2465 sc->sc_syncbeacon = 1; in ath_bmiss_vap()
2488 struct ath_softc *sc = arg; in ath_bmiss_proc() local
2491 DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending); in ath_bmiss_proc()
2493 ATH_LOCK(sc); in ath_bmiss_proc()
2494 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_bmiss_proc()
2495 ATH_UNLOCK(sc); in ath_bmiss_proc()
2497 ath_beacon_miss(sc); in ath_bmiss_proc()
2505 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) { in ath_bmiss_proc()
2506 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_BBPANIC); in ath_bmiss_proc()
2507 device_printf(sc->sc_dev, in ath_bmiss_proc()
2510 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_FORCE_COLD); in ath_bmiss_proc()
2511 ieee80211_beacon_miss(&sc->sc_ic); in ath_bmiss_proc()
2515 sc->sc_syncbeacon = 1; in ath_bmiss_proc()
2517 ATH_LOCK(sc); in ath_bmiss_proc()
2518 ath_power_restore_power_state(sc); in ath_bmiss_proc()
2519 ATH_UNLOCK(sc); in ath_bmiss_proc()
2532 struct ath_softc *sc = arg; in ath_tsfoor_proc() local
2534 DPRINTF(sc, ATH_DEBUG_ANY, "%s: pending %u\n", __func__, pending); in ath_tsfoor_proc()
2536 ATH_LOCK(sc); in ath_tsfoor_proc()
2537 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tsfoor_proc()
2538 ATH_UNLOCK(sc); in ath_tsfoor_proc()
2545 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_FORCE_COLD); in ath_tsfoor_proc()
2548 sc->sc_syncbeacon = 1; in ath_tsfoor_proc()
2550 ATH_LOCK(sc); in ath_tsfoor_proc()
2551 ath_power_restore_power_state(sc); in ath_tsfoor_proc()
2552 ATH_UNLOCK(sc); in ath_tsfoor_proc()
2562 ath_settkipmic(struct ath_softc *sc) in ath_settkipmic() argument
2564 struct ieee80211com *ic = &sc->sc_ic; in ath_settkipmic()
2566 if ((ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP) && !sc->sc_wmetkipmic) { in ath_settkipmic()
2568 ath_hal_settkipmic(sc->sc_ah, AH_FALSE); in ath_settkipmic()
2571 ath_hal_settkipmic(sc->sc_ah, AH_TRUE); in ath_settkipmic()
2578 ath_vap_clear_quiet_ie(struct ath_softc *sc) in ath_vap_clear_quiet_ie() argument
2580 struct ieee80211com *ic = &sc->sc_ic; in ath_vap_clear_quiet_ie()
2592 ath_init(struct ath_softc *sc) in ath_init() argument
2594 struct ieee80211com *ic = &sc->sc_ic; in ath_init()
2595 struct ath_hal *ah = sc->sc_ah; in ath_init()
2598 ATH_LOCK_ASSERT(sc); in ath_init()
2603 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_init()
2604 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_init()
2605 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_init()
2611 ath_stop(sc); in ath_init()
2620 ath_settkipmic(sc); in ath_init()
2621 ath_update_chainmasks(sc, ic->ic_curchan); in ath_init()
2622 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_init()
2623 sc->sc_cur_rxchainmask); in ath_init()
2625 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, in ath_init()
2627 device_printf(sc->sc_dev, in ath_init()
2632 ATH_RX_LOCK(sc); in ath_init()
2633 sc->sc_rx_stopped = 1; in ath_init()
2634 sc->sc_rx_resetted = 1; in ath_init()
2635 ATH_RX_UNLOCK(sc); in ath_init()
2638 ath_vap_clear_quiet_ie(sc); in ath_init()
2640 ath_chan_change(sc, ic->ic_curchan); in ath_init()
2643 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_init()
2646 ath_spectral_enable(sc, ic->ic_curchan); in ath_init()
2651 ath_btcoex_enable(sc, ic->ic_curchan); in ath_init()
2657 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_init()
2658 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_init()
2660 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_init()
2666 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_init()
2667 sc->sc_lastlongcal = ticks; in ath_init()
2668 sc->sc_resetcal = 1; in ath_init()
2669 sc->sc_lastcalreset = 0; in ath_init()
2670 sc->sc_lastani = ticks; in ath_init()
2671 sc->sc_lastshortcal = ticks; in ath_init()
2672 sc->sc_doresetcal = AH_FALSE; in ath_init()
2678 sc->sc_beacons = 0; in ath_init()
2687 if (ath_startrecv(sc) != 0) { in ath_init()
2688 device_printf(sc->sc_dev, "unable to start recv logic\n"); in ath_init()
2689 ath_power_restore_power_state(sc); in ath_init()
2696 sc->sc_imask = HAL_INT_RX | HAL_INT_TX in ath_init()
2704 if (sc->sc_isedma) in ath_init()
2705 sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); in ath_init()
2712 if (! sc->sc_isedma) in ath_init()
2713 sc->sc_imask |= HAL_INT_RXEOL; in ath_init()
2718 if (sc->sc_btcoex_mci) in ath_init()
2719 sc->sc_imask |= HAL_INT_MCI; in ath_init()
2725 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) in ath_init()
2726 sc->sc_imask |= HAL_INT_MIB; in ath_init()
2735 sc->sc_imask |= HAL_INT_TSFOOR; in ath_init()
2739 sc->sc_imask |= HAL_INT_GTT; in ath_init()
2741 DPRINTF(sc, ATH_DEBUG_RESET, "%s: imask=0x%x\n", in ath_init()
2742 __func__, sc->sc_imask); in ath_init()
2744 sc->sc_running = 1; in ath_init()
2745 callout_reset(&sc->sc_wd_ch, hz, ath_watchdog, sc); in ath_init()
2746 ath_hal_intrset(ah, sc->sc_imask); in ath_init()
2748 ath_power_restore_power_state(sc); in ath_init()
2754 ath_stop(struct ath_softc *sc) in ath_stop() argument
2756 struct ath_hal *ah = sc->sc_ah; in ath_stop()
2758 ATH_LOCK_ASSERT(sc); in ath_stop()
2763 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_stop()
2765 if (sc->sc_running) { in ath_stop()
2782 if (sc->sc_tx99 != NULL) in ath_stop()
2783 sc->sc_tx99->stop(sc->sc_tx99); in ath_stop()
2785 callout_stop(&sc->sc_wd_ch); in ath_stop()
2786 sc->sc_wd_timer = 0; in ath_stop()
2787 sc->sc_running = 0; in ath_stop()
2788 if (!sc->sc_invalid) { in ath_stop()
2789 if (sc->sc_softled) { in ath_stop()
2790 callout_stop(&sc->sc_ledtimer); in ath_stop()
2791 ath_hal_gpioset(ah, sc->sc_ledpin, in ath_stop()
2792 !sc->sc_ledon); in ath_stop()
2793 sc->sc_blinking = 0; in ath_stop()
2798 if (!sc->sc_invalid) { in ath_stop()
2799 ath_stoprecv(sc, 1); in ath_stop()
2802 sc->sc_rxlink = NULL; in ath_stop()
2803 ath_draintxq(sc, ATH_RESET_DEFAULT); in ath_stop()
2804 ath_beacon_free(sc); /* XXX not needed */ in ath_stop()
2808 ath_power_restore_power_state(sc); in ath_stop()
2821 ath_txrx_stop_locked(struct ath_softc *sc) in ath_txrx_stop_locked() argument
2825 ATH_UNLOCK_ASSERT(sc); in ath_txrx_stop_locked()
2826 ATH_PCU_LOCK_ASSERT(sc); in ath_txrx_stop_locked()
2834 while (sc->sc_rxproc_cnt || sc->sc_txproc_cnt || in ath_txrx_stop_locked()
2835 sc->sc_txstart_cnt || sc->sc_intr_cnt) { in ath_txrx_stop_locked()
2838 msleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", in ath_txrx_stop_locked()
2844 device_printf(sc->sc_dev, in ath_txrx_stop_locked()
2852 ath_txrx_stop(struct ath_softc *sc)
2854 ATH_UNLOCK_ASSERT(sc);
2855 ATH_PCU_UNLOCK_ASSERT(sc);
2857 ATH_PCU_LOCK(sc);
2858 ath_txrx_stop_locked(sc);
2859 ATH_PCU_UNLOCK(sc);
2864 ath_txrx_start(struct ath_softc *sc) in ath_txrx_start() argument
2867 taskqueue_unblock(sc->sc_tq); in ath_txrx_start()
2888 ath_reset_grablock(struct ath_softc *sc, int dowait) in ath_reset_grablock() argument
2893 ATH_PCU_LOCK_ASSERT(sc); in ath_reset_grablock()
2895 if (sc->sc_inreset_cnt == 0) { in ath_reset_grablock()
2903 ATH_PCU_UNLOCK(sc); in ath_reset_grablock()
2910 ATH_PCU_LOCK(sc); in ath_reset_grablock()
2918 sc->sc_inreset_cnt++; in ath_reset_grablock()
2921 device_printf(sc->sc_dev, in ath_reset_grablock()
2926 device_printf(sc->sc_dev, in ath_reset_grablock()
2942 ath_reset(struct ath_softc *sc, ATH_RESET_TYPE reset_type, in ath_reset() argument
2945 struct ieee80211com *ic = &sc->sc_ic; in ath_reset()
2946 struct ath_hal *ah = sc->sc_ah; in ath_reset()
2950 DPRINTF(sc, ATH_DEBUG_RESET, "%s: called\n", __func__); in ath_reset()
2953 ATH_PCU_UNLOCK_ASSERT(sc); in ath_reset()
2954 ATH_UNLOCK_ASSERT(sc); in ath_reset()
2957 taskqueue_block(sc->sc_tq); in ath_reset()
2962 ATH_LOCK(sc); in ath_reset()
2963 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_reset()
2964 ATH_UNLOCK(sc); in ath_reset()
2966 ATH_PCU_LOCK(sc); in ath_reset()
2974 if (ath_reset_grablock(sc, 1) == 0) { in ath_reset()
2975 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_reset()
2986 ath_txrx_stop_locked(sc); in ath_reset()
2988 ATH_PCU_UNLOCK(sc); in ath_reset()
2995 ath_stoprecv(sc, (reset_type != ATH_RESET_NOLOSS)); in ath_reset()
2996 ath_rx_flush(sc); in ath_reset()
3003 ath_draintxq(sc, reset_type); /* stop xmit side */ in ath_reset()
3005 ath_settkipmic(sc); /* configure TKIP MIC handling */ in ath_reset()
3007 ath_update_chainmasks(sc, ic->ic_curchan); in ath_reset()
3008 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_reset()
3009 sc->sc_cur_rxchainmask); in ath_reset()
3010 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, in ath_reset()
3012 device_printf(sc->sc_dev, in ath_reset()
3015 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_reset()
3017 ATH_RX_LOCK(sc); in ath_reset()
3018 sc->sc_rx_stopped = 1; in ath_reset()
3019 sc->sc_rx_resetted = 1; in ath_reset()
3020 ATH_RX_UNLOCK(sc); in ath_reset()
3023 ath_vap_clear_quiet_ie(sc); in ath_reset()
3026 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_reset()
3029 ath_spectral_enable(sc, ic->ic_curchan); in ath_reset()
3034 ath_btcoex_enable(sc, ic->ic_curchan); in ath_reset()
3040 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_reset()
3041 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_reset()
3043 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_reset()
3045 if (ath_startrecv(sc) != 0) /* restart recv */ in ath_reset()
3046 device_printf(sc->sc_dev, in ath_reset()
3053 ath_chan_change(sc, ic->ic_curchan); in ath_reset()
3054 if (sc->sc_beacons) { /* restart beacons */ in ath_reset()
3056 if (sc->sc_tdma) in ath_reset()
3057 ath_tdma_config(sc, NULL); in ath_reset()
3060 ath_beacon_config(sc, NULL); in ath_reset()
3075 ATH_PCU_LOCK(sc); in ath_reset()
3076 sc->sc_inreset_cnt--; in ath_reset()
3077 sc->sc_txstart_cnt++; in ath_reset()
3079 ath_hal_intrset(ah, sc->sc_imask); in ath_reset()
3080 ATH_PCU_UNLOCK(sc); in ath_reset()
3092 ath_txrx_start(sc); in ath_reset()
3099 if (ATH_TXQ_SETUP(sc, i)) { in ath_reset()
3100 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_reset()
3101 ath_txq_restart_dma(sc, &sc->sc_txq[i]); in ath_reset()
3102 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_reset()
3104 ATH_TX_LOCK(sc); in ath_reset()
3105 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_reset()
3106 ATH_TX_UNLOCK(sc); in ath_reset()
3111 ATH_LOCK(sc); in ath_reset()
3112 ath_power_restore_power_state(sc); in ath_reset()
3113 ATH_UNLOCK(sc); in ath_reset()
3115 ATH_PCU_LOCK(sc); in ath_reset()
3116 sc->sc_txstart_cnt--; in ath_reset()
3117 ATH_PCU_UNLOCK(sc); in ath_reset()
3124 ath_tx_kick(sc); /* restart xmit */ in ath_reset()
3132 struct ath_softc *sc = ic->ic_softc; in ath_reset_vap() local
3133 struct ath_hal *ah = sc->sc_ah; in ath_reset_vap()
3147 return ath_reset(sc, ATH_RESET_FULL, HAL_RESET_NORMAL); in ath_reset_vap()
3151 _ath_getbuf_locked(struct ath_softc *sc, ath_buf_type_t btype) in _ath_getbuf_locked() argument
3155 ATH_TXBUF_LOCK_ASSERT(sc); in _ath_getbuf_locked()
3158 bf = TAILQ_FIRST(&sc->sc_txbuf_mgmt); in _ath_getbuf_locked()
3160 bf = TAILQ_FIRST(&sc->sc_txbuf); in _ath_getbuf_locked()
3163 sc->sc_stats.ast_tx_getnobuf++; in _ath_getbuf_locked()
3166 sc->sc_stats.ast_tx_getbusybuf++; in _ath_getbuf_locked()
3173 TAILQ_REMOVE(&sc->sc_txbuf_mgmt, bf, bf_list); in _ath_getbuf_locked()
3175 TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list); in _ath_getbuf_locked()
3176 sc->sc_txbuf_cnt--; in _ath_getbuf_locked()
3183 if (sc->sc_txbuf_cnt < 0) { in _ath_getbuf_locked()
3184 device_printf(sc->sc_dev, in _ath_getbuf_locked()
3187 sc->sc_txbuf_cnt = 0; in _ath_getbuf_locked()
3195 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__, in _ath_getbuf_locked()
3196 TAILQ_FIRST(&sc->sc_txbuf) == NULL ? in _ath_getbuf_locked()
3218 if (sc->sc_isedma) { in _ath_getbuf_locked()
3219 bf->bf_descid = sc->sc_txbuf_descid; in _ath_getbuf_locked()
3220 sc->sc_txbuf_descid++; in _ath_getbuf_locked()
3241 ath_buf_clone(struct ath_softc *sc, struct ath_buf *bf) in ath_buf_clone() argument
3245 tbf = ath_getbuf(sc, in ath_buf_clone()
3278 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_buf_clone()
3280 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_buf_clone()
3293 ath_getbuf(struct ath_softc *sc, ath_buf_type_t btype) in ath_getbuf() argument
3297 ATH_TXBUF_LOCK(sc); in ath_getbuf()
3298 bf = _ath_getbuf_locked(sc, btype); in ath_getbuf()
3304 bf = _ath_getbuf_locked(sc, ATH_BUFTYPE_NORMAL); in ath_getbuf()
3305 ATH_TXBUF_UNLOCK(sc); in ath_getbuf()
3307 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: stop queue\n", __func__); in ath_getbuf()
3308 sc->sc_stats.ast_tx_qstop++; in ath_getbuf()
3322 struct ath_softc *sc = ic->ic_softc; in ath_transmit() local
3332 ATH_PCU_LOCK(sc); in ath_transmit()
3333 if (sc->sc_inreset_cnt > 0) { in ath_transmit()
3334 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3336 ATH_PCU_UNLOCK(sc); in ath_transmit()
3337 sc->sc_stats.ast_tx_qstop++; in ath_transmit()
3338 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_start_task: OACTIVE, finish"); in ath_transmit()
3341 sc->sc_txstart_cnt++; in ath_transmit()
3342 ATH_PCU_UNLOCK(sc); in ath_transmit()
3345 ATH_LOCK(sc); in ath_transmit()
3346 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_transmit()
3347 ATH_UNLOCK(sc); in ath_transmit()
3349 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_transmit: start"); in ath_transmit()
3354 ATH_TX_LOCK(sc); in ath_transmit()
3375 (ATH_NODE(ni)->an_swq_depth > sc->sc_txq_node_maxdepth)) { in ath_transmit()
3376 sc->sc_stats.ast_tx_nodeq_overflow++; in ath_transmit()
3398 (sc->sc_txbuf_cnt <= sc->sc_txq_data_minfree)) { in ath_transmit()
3399 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3415 bf = ath_getbuf(sc, ATH_BUFTYPE_MGMT); in ath_transmit()
3417 bf = ath_getbuf(sc, ATH_BUFTYPE_NORMAL); in ath_transmit()
3426 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3444 !ath_txfrag_setup(sc, &frags, m, ni)) { in ath_transmit()
3445 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3447 sc->sc_stats.ast_tx_nofrag++; in ath_transmit()
3516 if (ath_tx_start(sc, ni, bf, m)) { in ath_transmit()
3522 ATH_TXBUF_LOCK(sc); in ath_transmit()
3523 ath_returnbuf_head(sc, bf); in ath_transmit()
3528 ath_txfrag_cleanup(sc, &frags, ni); in ath_transmit()
3529 ATH_TXBUF_UNLOCK(sc); in ath_transmit()
3544 ath_tx_update_tim(sc, ni, 1); in ath_transmit()
3552 DPRINTF(sc, ATH_DEBUG_XMIT, in ath_transmit()
3570 sc->sc_wd_timer = 5; in ath_transmit()
3573 ATH_TX_UNLOCK(sc); in ath_transmit()
3578 ATH_PCU_LOCK(sc); in ath_transmit()
3579 sc->sc_txstart_cnt--; in ath_transmit()
3580 ATH_PCU_UNLOCK(sc); in ath_transmit()
3583 ATH_LOCK(sc); in ath_transmit()
3584 ath_power_restore_power_state(sc); in ath_transmit()
3585 ATH_UNLOCK(sc); in ath_transmit()
3587 ATH_KTR(sc, ATH_KTR_TX, 0, "ath_transmit: finished"); in ath_transmit()
3601 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_begin() local
3603 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); in ath_key_update_begin()
3604 taskqueue_block(sc->sc_tq); in ath_key_update_begin()
3610 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_end() local
3612 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); in ath_key_update_end()
3613 taskqueue_unblock(sc->sc_tq); in ath_key_update_end()
3619 struct ath_softc *sc = ic->ic_softc; in ath_update_promisc() local
3623 ATH_LOCK(sc); in ath_update_promisc()
3624 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_update_promisc()
3625 rfilt = ath_calcrxfilter(sc); in ath_update_promisc()
3626 ath_hal_setrxfilter(sc->sc_ah, rfilt); in ath_update_promisc()
3627 ath_power_restore_power_state(sc); in ath_update_promisc()
3628 ATH_UNLOCK(sc); in ath_update_promisc()
3630 DPRINTF(sc, ATH_DEBUG_MODE, "%s: RX filter 0x%x\n", __func__, rfilt); in ath_update_promisc()
3658 ath_update_mcast_hw(struct ath_softc *sc) in ath_update_mcast_hw() argument
3660 struct ieee80211com *ic = &sc->sc_ic; in ath_update_mcast_hw()
3676 ath_hal_setmcastfilter(sc->sc_ah, mfilt[0], mfilt[1]); in ath_update_mcast_hw()
3678 DPRINTF(sc, ATH_DEBUG_MODE, "%s: MC filter %08x:%08x\n", in ath_update_mcast_hw()
3689 struct ath_softc *sc = ic->ic_softc; in ath_update_mcast() local
3691 ATH_LOCK(sc); in ath_update_mcast()
3692 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_update_mcast()
3693 ATH_UNLOCK(sc); in ath_update_mcast()
3695 ath_update_mcast_hw(sc); in ath_update_mcast()
3697 ATH_LOCK(sc); in ath_update_mcast()
3698 ath_power_restore_power_state(sc); in ath_update_mcast()
3699 ATH_UNLOCK(sc); in ath_update_mcast()
3703 ath_mode_init(struct ath_softc *sc) in ath_mode_init() argument
3705 struct ieee80211com *ic = &sc->sc_ic; in ath_mode_init()
3706 struct ath_hal *ah = sc->sc_ah; in ath_mode_init()
3712 rfilt = ath_calcrxfilter(sc); in ath_mode_init()
3722 ath_update_mcast_hw(sc); in ath_mode_init()
3729 ath_setslottime(struct ath_softc *sc) in ath_setslottime() argument
3731 struct ieee80211com *ic = &sc->sc_ic; in ath_setslottime()
3732 struct ath_hal *ah = sc->sc_ah; in ath_setslottime()
3749 DPRINTF(sc, ATH_DEBUG_RESET, in ath_setslottime()
3755 ATH_LOCK(sc); in ath_setslottime()
3756 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_setslottime()
3758 ath_power_restore_power_state(sc); in ath_setslottime()
3759 sc->sc_updateslot = OK; in ath_setslottime()
3760 ATH_UNLOCK(sc); in ath_setslottime()
3770 struct ath_softc *sc = ic->ic_softc; in ath_updateslot() local
3781 sc->sc_updateslot = UPDATE; in ath_updateslot()
3783 ath_setslottime(sc); in ath_updateslot()
3814 struct ath_softc *sc = arg; in ath_reset_proc() local
3817 device_printf(sc->sc_dev, "%s: resetting\n", __func__); in ath_reset_proc()
3819 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_FORCE_COLD); in ath_reset_proc()
3828 struct ath_softc *sc = arg; in ath_bstuck_proc() local
3831 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) in ath_bstuck_proc()
3832 device_printf(sc->sc_dev, "bb hang detected (0x%x)\n", hangs); in ath_bstuck_proc()
3835 if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_STUCK_BEACON)) in ath_bstuck_proc()
3836 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_STUCK_BEACON, 0, NULL); in ath_bstuck_proc()
3839 device_printf(sc->sc_dev, "stuck beacon; resetting (bmiss count %u)\n", in ath_bstuck_proc()
3840 sc->sc_bmisscount); in ath_bstuck_proc()
3841 sc->sc_stats.ast_bstuck++; in ath_bstuck_proc()
3846 ath_reset(sc, ATH_RESET_NOLOSS, HAL_RESET_FORCE_COLD); in ath_bstuck_proc()
3850 ath_desc_alloc(struct ath_softc *sc) in ath_desc_alloc() argument
3854 error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf, in ath_desc_alloc()
3855 "tx", sc->sc_tx_desclen, ath_txbuf, ATH_MAX_SCATTER); in ath_desc_alloc()
3859 sc->sc_txbuf_cnt = ath_txbuf; in ath_desc_alloc()
3861 error = ath_descdma_setup(sc, &sc->sc_txdma_mgmt, &sc->sc_txbuf_mgmt, in ath_desc_alloc()
3862 "tx_mgmt", sc->sc_tx_desclen, ath_txbuf_mgmt, in ath_desc_alloc()
3865 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3874 error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf, in ath_desc_alloc()
3875 "beacon", sc->sc_tx_desclen, ATH_BCBUF, 1); in ath_desc_alloc()
3877 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3878 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_alloc()
3879 &sc->sc_txbuf_mgmt); in ath_desc_alloc()
3886 ath_desc_free(struct ath_softc *sc) in ath_desc_free() argument
3889 if (sc->sc_bdma.dd_desc_len != 0) in ath_desc_free()
3890 ath_descdma_cleanup(sc, &sc->sc_bdma, &sc->sc_bbuf); in ath_desc_free()
3891 if (sc->sc_txdma.dd_desc_len != 0) in ath_desc_free()
3892 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_free()
3893 if (sc->sc_txdma_mgmt.dd_desc_len != 0) in ath_desc_free()
3894 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_free()
3895 &sc->sc_txbuf_mgmt); in ath_desc_free()
3902 struct ath_softc *sc = ic->ic_softc; in ath_node_alloc() local
3903 const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; in ath_node_alloc()
3911 ath_rate_node_init(sc, an); in ath_node_alloc()
3915 device_get_nameunit(sc->sc_dev), an); in ath_node_alloc()
3919 ath_tx_tid_init(sc, an); in ath_node_alloc()
3925 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, mac, ":", an); in ath_node_alloc()
3933 struct ath_softc *sc = ic->ic_softc; in ath_node_cleanup() local
3935 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, in ath_node_cleanup()
3939 ath_tx_node_flush(sc, ATH_NODE(ni)); in ath_node_cleanup()
3940 ath_rate_node_cleanup(sc, ATH_NODE(ni)); in ath_node_cleanup()
3941 sc->sc_node_cleanup(ni); in ath_node_cleanup()
3948 struct ath_softc *sc = ic->ic_softc; in ath_node_free() local
3950 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: an %p\n", __func__, in ath_node_free()
3953 sc->sc_node_free(ni); in ath_node_free()
3960 struct ath_softc *sc = ic->ic_softc; in ath_node_getsignal() local
3961 struct ath_hal *ah = sc->sc_ah; in ath_node_getsignal()
3974 ath_setdefantenna(struct ath_softc *sc, u_int antenna) in ath_setdefantenna() argument
3976 struct ath_hal *ah = sc->sc_ah; in ath_setdefantenna()
3980 if (sc->sc_defant != antenna) in ath_setdefantenna()
3981 sc->sc_stats.ast_ant_defswitch++; in ath_setdefantenna()
3982 sc->sc_defant = antenna; in ath_setdefantenna()
3983 sc->sc_rxotherant = 0; in ath_setdefantenna()
3987 ath_txq_init(struct ath_softc *sc, struct ath_txq *txq, int qnum) in ath_txq_init() argument
3995 txq->axq_softc = sc; in ath_txq_init()
3999 ATH_TXQ_LOCK_INIT(sc, txq); in ath_txq_init()
4006 ath_txq_setup(struct ath_softc *sc, int qtype, int subtype) in ath_txq_setup() argument
4008 struct ath_hal *ah = sc->sc_ah; in ath_txq_setup()
4029 if (sc->sc_isedma) in ath_txq_setup()
4044 if (qnum >= nitems(sc->sc_txq)) { in ath_txq_setup()
4045 device_printf(sc->sc_dev, in ath_txq_setup()
4047 qnum, nitems(sc->sc_txq)); in ath_txq_setup()
4051 if (!ATH_TXQ_SETUP(sc, qnum)) { in ath_txq_setup()
4052 ath_txq_init(sc, &sc->sc_txq[qnum], qnum); in ath_txq_setup()
4053 sc->sc_txqsetup |= 1<<qnum; in ath_txq_setup()
4055 return &sc->sc_txq[qnum]; in ath_txq_setup()
4068 ath_tx_setup(struct ath_softc *sc, int ac, int haltype) in ath_tx_setup() argument
4072 if (ac >= nitems(sc->sc_ac2q)) { in ath_tx_setup()
4073 device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", in ath_tx_setup()
4074 ac, nitems(sc->sc_ac2q)); in ath_tx_setup()
4077 txq = ath_txq_setup(sc, HAL_TX_QUEUE_DATA, haltype); in ath_tx_setup()
4080 sc->sc_ac2q[ac] = txq; in ath_tx_setup()
4090 ath_txq_update(struct ath_softc *sc, int ac) in ath_txq_update() argument
4093 struct ieee80211com *ic = &sc->sc_ic; in ath_txq_update()
4094 struct ath_txq *txq = sc->sc_ac2q[ac]; in ath_txq_update()
4097 struct ath_hal *ah = sc->sc_ah; in ath_txq_update()
4105 if (sc->sc_tdma) { in ath_txq_update()
4124 qi.tqi_readyTime = sc->sc_tdmaslotlen; in ath_txq_update()
4147 DPRINTF(sc, ATH_DEBUG_RESET, in ath_txq_update()
4153 device_printf(sc->sc_dev, "unable to update hardware queue " in ath_txq_update()
4169 struct ath_softc *sc = ic->ic_softc; in ath_wme_update() local
4171 return !ath_txq_update(sc, WME_AC_BE) || in ath_wme_update()
4172 !ath_txq_update(sc, WME_AC_BK) || in ath_wme_update()
4173 !ath_txq_update(sc, WME_AC_VI) || in ath_wme_update()
4174 !ath_txq_update(sc, WME_AC_VO) ? EIO : 0; in ath_wme_update()
4181 ath_tx_cleanupq(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_cleanupq() argument
4184 ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum); in ath_tx_cleanupq()
4185 sc->sc_txqsetup &= ~(1<<txq->axq_qnum); in ath_tx_cleanupq()
4193 ath_tx_cleanup(struct ath_softc *sc) in ath_tx_cleanup() argument
4197 ATH_TXBUF_LOCK_DESTROY(sc); in ath_tx_cleanup()
4199 if (ATH_TXQ_SETUP(sc, i)) in ath_tx_cleanup()
4200 ath_tx_cleanupq(sc, &sc->sc_txq[i]); in ath_tx_cleanup()
4208 ath_tx_findrix(const struct ath_softc *sc, uint8_t rate) in ath_tx_findrix() argument
4210 int rix = sc->sc_rixmap[rate]; in ath_tx_findrix()
4216 ath_tx_update_stats(struct ath_softc *sc, struct ath_tx_status *ts, in ath_tx_update_stats() argument
4220 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_update_stats()
4230 sc->sc_stats.ast_ant_tx[txant]++; in ath_tx_update_stats()
4231 sc->sc_ant_tx[txant]++; in ath_tx_update_stats()
4233 sc->sc_stats.ast_tx_altrate++; in ath_tx_update_stats()
4244 sc->sc_stats.ast_tx_xretries++; in ath_tx_update_stats()
4246 sc->sc_stats.ast_tx_fifoerr++; in ath_tx_update_stats()
4248 sc->sc_stats.ast_tx_filtered++; in ath_tx_update_stats()
4250 sc->sc_stats.ast_tx_xtxop++; in ath_tx_update_stats()
4252 sc->sc_stats.ast_tx_timerexpired++; in ath_tx_update_stats()
4255 sc->sc_stats.ast_ff_txerr++; in ath_tx_update_stats()
4259 sc->sc_stats.ast_tx_desccfgerr++; in ath_tx_update_stats()
4269 sc->sc_stats.ast_tx_data_underrun++; in ath_tx_update_stats()
4271 sc->sc_stats.ast_tx_delim_underrun++; in ath_tx_update_stats()
4275 sc->sc_stats.ast_tx_shortretry += sr; in ath_tx_update_stats()
4276 sc->sc_stats.ast_tx_longretry += lr; in ath_tx_update_stats()
4286 ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) in ath_tx_default_comp() argument
4299 device_printf(sc->sc_dev, in ath_tx_default_comp()
4306 device_printf(sc->sc_dev, in ath_tx_default_comp()
4328 ATH_TX_LOCK(sc); in ath_tx_default_comp()
4329 ath_tx_update_tim(sc, bf->bf_node, 0); in ath_tx_default_comp()
4330 ATH_TX_UNLOCK(sc); in ath_tx_default_comp()
4339 ath_tx_freebuf(sc, bf, st); in ath_tx_default_comp()
4346 ath_tx_update_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni, in ath_tx_update_ratectrl() argument
4367 ath_rate_tx_complete(sc, an, rc, ts, frmlen, rc_framelen, in ath_tx_update_ratectrl()
4381 ath_tx_process_buf_completion(struct ath_softc *sc, struct ath_txq *txq, in ath_tx_process_buf_completion() argument
4386 ATH_TX_UNLOCK_ASSERT(sc); in ath_tx_process_buf_completion()
4392 ath_tx_update_stats(sc, ts, bf); in ath_tx_process_buf_completion()
4413 ath_tx_update_ratectrl(sc, ni, in ath_tx_process_buf_completion()
4420 ath_tx_default_comp(sc, bf, 0); in ath_tx_process_buf_completion()
4422 bf->bf_comp(sc, bf, 0); in ath_tx_process_buf_completion()
4431 ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq, int dosched) in ath_tx_processq() argument
4433 struct ath_hal *ah = sc->sc_ah; in ath_tx_processq()
4439 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_processq()
4444 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %u head %p link %p\n", in ath_tx_processq()
4446 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4449 ATH_KTR(sc, ATH_KTR_TXCOMP, 4, in ath_tx_processq()
4452 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4470 if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) in ath_tx_processq()
4471 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4473 else if ((sc->sc_debug & ATH_DEBUG_RESET) && (dosched == 0)) in ath_tx_processq()
4474 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4478 if (if_ath_alq_checkdebug(&sc->sc_alq, in ath_tx_processq()
4480 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS, in ath_tx_processq()
4481 sc->sc_tx_statuslen, in ath_tx_processq()
4487 ATH_KTR(sc, ATH_KTR_TXCOMP, 3, in ath_tx_processq()
4499 device_printf(sc->sc_dev, in ath_tx_processq()
4507 device_printf(sc->sc_dev, in ath_tx_processq()
4537 ATH_KTR(sc, ATH_KTR_TXCOMP, 5, in ath_tx_processq()
4548 sc->sc_stats.ast_tx_rssi = ts->ts_rssi; in ath_tx_processq()
4549 ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, in ath_tx_processq()
4559 ath_tx_process_buf_completion(sc, txq, ts, bf); in ath_tx_processq()
4573 ATH_TX_LOCK(sc); in ath_tx_processq()
4574 ath_txq_sched(sc, txq); in ath_tx_processq()
4575 ATH_TX_UNLOCK(sc); in ath_tx_processq()
4578 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_processq()
4594 struct ath_softc *sc = arg; in ath_tx_proc_q0() local
4597 ATH_PCU_LOCK(sc); in ath_tx_proc_q0()
4598 sc->sc_txproc_cnt++; in ath_tx_proc_q0()
4599 txqs = sc->sc_txq_active; in ath_tx_proc_q0()
4600 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0()
4601 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0()
4603 ATH_LOCK(sc); in ath_tx_proc_q0()
4604 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc_q0()
4605 ATH_UNLOCK(sc); in ath_tx_proc_q0()
4607 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_proc_q0()
4610 if (TXQACTIVE(txqs, 0) && ath_tx_processq(sc, &sc->sc_txq[0], 1)) in ath_tx_proc_q0()
4612 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0()
4613 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0()
4614 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0()
4615 sc->sc_wd_timer = 0; in ath_tx_proc_q0()
4617 if (sc->sc_softled) in ath_tx_proc_q0()
4618 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0()
4620 ATH_PCU_LOCK(sc); in ath_tx_proc_q0()
4621 sc->sc_txproc_cnt--; in ath_tx_proc_q0()
4622 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0()
4624 ATH_LOCK(sc); in ath_tx_proc_q0()
4625 ath_power_restore_power_state(sc); in ath_tx_proc_q0()
4626 ATH_UNLOCK(sc); in ath_tx_proc_q0()
4628 ath_tx_kick(sc); in ath_tx_proc_q0()
4638 struct ath_softc *sc = arg; in ath_tx_proc_q0123() local
4642 ATH_PCU_LOCK(sc); in ath_tx_proc_q0123()
4643 sc->sc_txproc_cnt++; in ath_tx_proc_q0123()
4644 txqs = sc->sc_txq_active; in ath_tx_proc_q0123()
4645 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0123()
4646 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0123()
4648 ATH_LOCK(sc); in ath_tx_proc_q0123()
4649 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc_q0123()
4650 ATH_UNLOCK(sc); in ath_tx_proc_q0123()
4652 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, in ath_tx_proc_q0123()
4660 nacked += ath_tx_processq(sc, &sc->sc_txq[0], 1); in ath_tx_proc_q0123()
4662 nacked += ath_tx_processq(sc, &sc->sc_txq[1], 1); in ath_tx_proc_q0123()
4664 nacked += ath_tx_processq(sc, &sc->sc_txq[2], 1); in ath_tx_proc_q0123()
4666 nacked += ath_tx_processq(sc, &sc->sc_txq[3], 1); in ath_tx_proc_q0123()
4667 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0123()
4668 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0123()
4670 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0123()
4672 sc->sc_wd_timer = 0; in ath_tx_proc_q0123()
4674 if (sc->sc_softled) in ath_tx_proc_q0123()
4675 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0123()
4677 ATH_PCU_LOCK(sc); in ath_tx_proc_q0123()
4678 sc->sc_txproc_cnt--; in ath_tx_proc_q0123()
4679 ATH_PCU_UNLOCK(sc); in ath_tx_proc_q0123()
4681 ATH_LOCK(sc); in ath_tx_proc_q0123()
4682 ath_power_restore_power_state(sc); in ath_tx_proc_q0123()
4683 ATH_UNLOCK(sc); in ath_tx_proc_q0123()
4685 ath_tx_kick(sc); in ath_tx_proc_q0123()
4694 struct ath_softc *sc = arg; in ath_tx_proc() local
4698 ATH_PCU_LOCK(sc); in ath_tx_proc()
4699 sc->sc_txproc_cnt++; in ath_tx_proc()
4700 txqs = sc->sc_txq_active; in ath_tx_proc()
4701 sc->sc_txq_active &= ~txqs; in ath_tx_proc()
4702 ATH_PCU_UNLOCK(sc); in ath_tx_proc()
4704 ATH_LOCK(sc); in ath_tx_proc()
4705 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_tx_proc()
4706 ATH_UNLOCK(sc); in ath_tx_proc()
4708 ATH_KTR(sc, ATH_KTR_TXCOMP, 1, "ath_tx_proc: txqs=0x%08x", txqs); in ath_tx_proc()
4715 if (ATH_TXQ_SETUP(sc, i) && TXQACTIVE(txqs, i)) in ath_tx_proc()
4716 nacked += ath_tx_processq(sc, &sc->sc_txq[i], 1); in ath_tx_proc()
4718 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc()
4720 sc->sc_wd_timer = 0; in ath_tx_proc()
4722 if (sc->sc_softled) in ath_tx_proc()
4723 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc()
4725 ATH_PCU_LOCK(sc); in ath_tx_proc()
4726 sc->sc_txproc_cnt--; in ath_tx_proc()
4727 ATH_PCU_UNLOCK(sc); in ath_tx_proc()
4729 ATH_LOCK(sc); in ath_tx_proc()
4730 ath_power_restore_power_state(sc); in ath_tx_proc()
4731 ATH_UNLOCK(sc); in ath_tx_proc()
4733 ath_tx_kick(sc); in ath_tx_proc()
4743 struct ath_softc *sc = arg; in ath_txq_sched_tasklet() local
4747 ATH_PCU_LOCK(sc); in ath_txq_sched_tasklet()
4749 if (sc->sc_inreset_cnt > 0) { in ath_txq_sched_tasklet()
4750 device_printf(sc->sc_dev, in ath_txq_sched_tasklet()
4752 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4756 sc->sc_txproc_cnt++; in ath_txq_sched_tasklet()
4757 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4759 ATH_LOCK(sc); in ath_txq_sched_tasklet()
4760 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_txq_sched_tasklet()
4761 ATH_UNLOCK(sc); in ath_txq_sched_tasklet()
4763 ATH_TX_LOCK(sc); in ath_txq_sched_tasklet()
4765 if (ATH_TXQ_SETUP(sc, i)) { in ath_txq_sched_tasklet()
4766 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_txq_sched_tasklet()
4769 ATH_TX_UNLOCK(sc); in ath_txq_sched_tasklet()
4771 ATH_LOCK(sc); in ath_txq_sched_tasklet()
4772 ath_power_restore_power_state(sc); in ath_txq_sched_tasklet()
4773 ATH_UNLOCK(sc); in ath_txq_sched_tasklet()
4775 ATH_PCU_LOCK(sc); in ath_txq_sched_tasklet()
4776 sc->sc_txproc_cnt--; in ath_txq_sched_tasklet()
4777 ATH_PCU_UNLOCK(sc); in ath_txq_sched_tasklet()
4781 ath_returnbuf_tail(struct ath_softc *sc, struct ath_buf *bf) in ath_returnbuf_tail() argument
4784 ATH_TXBUF_LOCK_ASSERT(sc); in ath_returnbuf_tail()
4787 TAILQ_INSERT_TAIL(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_tail()
4789 TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_tail()
4790 sc->sc_txbuf_cnt++; in ath_returnbuf_tail()
4791 if (sc->sc_txbuf_cnt > ath_txbuf) { in ath_returnbuf_tail()
4792 device_printf(sc->sc_dev, in ath_returnbuf_tail()
4796 sc->sc_txbuf_cnt = ath_txbuf; in ath_returnbuf_tail()
4802 ath_returnbuf_head(struct ath_softc *sc, struct ath_buf *bf) in ath_returnbuf_head() argument
4805 ATH_TXBUF_LOCK_ASSERT(sc); in ath_returnbuf_head()
4808 TAILQ_INSERT_HEAD(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_head()
4810 TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_head()
4811 sc->sc_txbuf_cnt++; in ath_returnbuf_head()
4812 if (sc->sc_txbuf_cnt > ATH_TXBUF) { in ath_returnbuf_head()
4813 device_printf(sc->sc_dev, in ath_returnbuf_head()
4817 sc->sc_txbuf_cnt = ATH_TXBUF; in ath_returnbuf_head()
4826 ath_txq_freeholdingbuf(struct ath_softc *sc, struct ath_txq *txq) in ath_txq_freeholdingbuf() argument
4828 ATH_TXBUF_UNLOCK_ASSERT(sc); in ath_txq_freeholdingbuf()
4836 ATH_TXBUF_LOCK(sc); in ath_txq_freeholdingbuf()
4837 ath_returnbuf_tail(sc, txq->axq_holdingbf); in ath_txq_freeholdingbuf()
4838 ATH_TXBUF_UNLOCK(sc); in ath_txq_freeholdingbuf()
4848 ath_txq_addholdingbuf(struct ath_softc *sc, struct ath_buf *bf) in ath_txq_addholdingbuf() argument
4852 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_txq_addholdingbuf()
4854 ATH_TXBUF_UNLOCK_ASSERT(sc); in ath_txq_addholdingbuf()
4861 device_printf(sc->sc_dev, "%s: bf=%p: invalid tx queue (%d)\n", in ath_txq_addholdingbuf()
4866 ath_returnbuf_tail(sc, bf); in ath_txq_addholdingbuf()
4869 ath_txq_freeholdingbuf(sc, txq); in ath_txq_addholdingbuf()
4891 ath_freebuf(struct ath_softc *sc, struct ath_buf *bf) in ath_freebuf() argument
4895 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_freebuf()
4905 ath_txq_addholdingbuf(sc, bf); in ath_freebuf()
4913 ATH_TXBUF_LOCK(sc); in ath_freebuf()
4914 ath_returnbuf_tail(sc, bf); in ath_freebuf()
4915 ATH_TXBUF_UNLOCK(sc); in ath_freebuf()
4925 ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status) in ath_tx_freebuf() argument
4936 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_tx_freebuf()
4938 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_tx_freebuf()
4945 ath_freebuf(sc, bf); in ath_tx_freebuf()
4952 ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_draintxq_get_one() argument
4970 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
4986 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
5007 ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_draintxq() argument
5010 struct ath_hal *ah = sc->sc_ah; in ath_tx_draintxq()
5021 bf = ath_tx_draintxq_get_one(sc, txq); in ath_tx_draintxq()
5029 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_tx_draintxq()
5030 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_draintxq()
5039 if (! sc->sc_isedma) { in ath_tx_draintxq()
5044 ath_printtxbuf(sc, bf, txq->axq_qnum, ix, status); in ath_tx_draintxq()
5061 bf->bf_comp(sc, bf, 1); in ath_tx_draintxq()
5063 ath_tx_default_comp(sc, bf, 1); in ath_tx_draintxq()
5070 ath_txq_freeholdingbuf(sc, txq); in ath_tx_draintxq()
5077 ath_tx_txq_drain(sc, txq); in ath_tx_draintxq()
5081 ath_tx_stopdma(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_stopdma() argument
5083 struct ath_hal *ah = sc->sc_ah; in ath_tx_stopdma()
5087 DPRINTF(sc, ATH_DEBUG_RESET, in ath_tx_stopdma()
5104 if ((sc->sc_debug & ATH_DEBUG_RESET) in ath_tx_stopdma()
5106 ath_printtxbuf(sc, txq->axq_holdingbf, txq->axq_qnum, 0, 0); in ath_tx_stopdma()
5112 ath_stoptxdma(struct ath_softc *sc) in ath_stoptxdma() argument
5114 struct ath_hal *ah = sc->sc_ah; in ath_stoptxdma()
5118 if (sc->sc_invalid) in ath_stoptxdma()
5121 if (!sc->sc_invalid) { in ath_stoptxdma()
5123 DPRINTF(sc, ATH_DEBUG_RESET, "%s: tx queue [%u] %p, link %p\n", in ath_stoptxdma()
5124 __func__, sc->sc_bhalq, in ath_stoptxdma()
5125 (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq), in ath_stoptxdma()
5129 (void) ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_stoptxdma()
5133 if (ATH_TXQ_SETUP(sc, i)) { in ath_stoptxdma()
5134 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_stoptxdma()
5135 ath_tx_stopdma(sc, &sc->sc_txq[i]); in ath_stoptxdma()
5136 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_stoptxdma()
5146 ath_tx_dump(struct ath_softc *sc, struct ath_txq *txq) in ath_tx_dump() argument
5148 struct ath_hal *ah = sc->sc_ah; in ath_tx_dump()
5152 if (! (sc->sc_debug & ATH_DEBUG_RESET)) in ath_tx_dump()
5155 device_printf(sc->sc_dev, "%s: Q%d: begin\n", in ath_tx_dump()
5158 ath_printtxbuf(sc, bf, txq->axq_qnum, i, in ath_tx_dump()
5163 device_printf(sc->sc_dev, "%s: Q%d: end\n", in ath_tx_dump()
5172 ath_legacy_tx_drain(struct ath_softc *sc, ATH_RESET_TYPE reset_type) in ath_legacy_tx_drain() argument
5174 struct ath_hal *ah = sc->sc_ah; in ath_legacy_tx_drain()
5178 (void) ath_stoptxdma(sc); in ath_legacy_tx_drain()
5188 if (ATH_TXQ_SETUP(sc, i)) { in ath_legacy_tx_drain()
5190 if (sc->sc_debug & ATH_DEBUG_RESET) in ath_legacy_tx_drain()
5191 ath_tx_dump(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5194 ath_tx_processq(sc, &sc->sc_txq[i], 0); in ath_legacy_tx_drain()
5195 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
5200 ath_txq_freeholdingbuf(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5207 bf_last = ATH_TXQ_LAST(&sc->sc_txq[i], in ath_legacy_tx_drain()
5212 &sc->sc_txq[i].axq_link); in ath_legacy_tx_drain()
5214 sc->sc_txq[i].axq_link = NULL; in ath_legacy_tx_drain()
5216 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
5218 ath_tx_draintxq(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5222 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_legacy_tx_drain()
5223 struct ath_buf *bf = TAILQ_FIRST(&sc->sc_bbuf); in ath_legacy_tx_drain()
5225 ath_printtxbuf(sc, bf, sc->sc_bhalq, 0, in ath_legacy_tx_drain()
5228 ieee80211_dump_pkt(&sc->sc_ic, in ath_legacy_tx_drain()
5234 sc->sc_wd_timer = 0; in ath_legacy_tx_drain()
5241 ath_chan_change(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_chan_change() argument
5250 if (mode != sc->sc_curmode) in ath_chan_change()
5251 ath_setcurmode(sc, mode); in ath_chan_change()
5252 sc->sc_curchan = chan; in ath_chan_change()
5262 ath_chan_set(struct ath_softc *sc, struct ieee80211_channel *chan) in ath_chan_set() argument
5264 struct ieee80211com *ic = &sc->sc_ic; in ath_chan_set()
5265 struct ath_hal *ah = sc->sc_ah; in ath_chan_set()
5269 ATH_PCU_UNLOCK_ASSERT(sc); in ath_chan_set()
5270 ATH_UNLOCK_ASSERT(sc); in ath_chan_set()
5273 taskqueue_block(sc->sc_tq); in ath_chan_set()
5275 ATH_PCU_LOCK(sc); in ath_chan_set()
5281 if (ath_reset_grablock(sc, 1) == 0) { in ath_chan_set()
5282 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_chan_set()
5287 ath_txrx_stop_locked(sc); in ath_chan_set()
5289 ATH_PCU_UNLOCK(sc); in ath_chan_set()
5291 DPRINTF(sc, ATH_DEBUG_RESET, "%s: %u (%u MHz, flags 0x%x)\n", in ath_chan_set()
5294 if (chan != sc->sc_curchan) { in ath_chan_set()
5305 ath_stoprecv(sc, 1); /* turn off frame recv */ in ath_chan_set()
5309 ath_rx_flush(sc); in ath_chan_set()
5310 ath_draintxq(sc, ATH_RESET_NOLOSS); in ath_chan_set()
5314 ath_draintxq(sc, ATH_RESET_FULL); /* clear pending tx frames */ in ath_chan_set()
5316 ath_update_chainmasks(sc, chan); in ath_chan_set()
5317 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_chan_set()
5318 sc->sc_cur_rxchainmask); in ath_chan_set()
5319 if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, in ath_chan_set()
5321 device_printf(sc->sc_dev, "%s: unable to reset " in ath_chan_set()
5328 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_chan_set()
5330 ATH_RX_LOCK(sc); in ath_chan_set()
5331 sc->sc_rx_stopped = 1; in ath_chan_set()
5332 sc->sc_rx_resetted = 1; in ath_chan_set()
5333 ATH_RX_UNLOCK(sc); in ath_chan_set()
5336 ath_vap_clear_quiet_ie(sc); in ath_chan_set()
5339 ath_dfs_radar_enable(sc, chan); in ath_chan_set()
5342 ath_spectral_enable(sc, chan); in ath_chan_set()
5348 ath_btcoex_enable(sc, ic->ic_curchan); in ath_chan_set()
5354 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_chan_set()
5355 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_chan_set()
5357 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_chan_set()
5362 if (ath_startrecv(sc) != 0) { in ath_chan_set()
5363 device_printf(sc->sc_dev, in ath_chan_set()
5373 ath_chan_change(sc, chan); in ath_chan_set()
5379 if (sc->sc_beacons) { /* restart beacons */ in ath_chan_set()
5381 if (sc->sc_tdma) in ath_chan_set()
5382 ath_tdma_config(sc, NULL); in ath_chan_set()
5385 ath_beacon_config(sc, NULL); in ath_chan_set()
5392 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5397 ATH_PCU_LOCK(sc); in ath_chan_set()
5398 sc->sc_inreset_cnt--; in ath_chan_set()
5400 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5401 ATH_PCU_UNLOCK(sc); in ath_chan_set()
5403 ath_txrx_start(sc); in ath_chan_set()
5416 struct ath_softc *sc = arg; in ath_calibrate() local
5417 struct ath_hal *ah = sc->sc_ah; in ath_calibrate()
5418 struct ieee80211com *ic = &sc->sc_ic; in ath_calibrate()
5423 ATH_LOCK_ASSERT(sc); in ath_calibrate()
5428 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_calibrate()
5431 if (sc->sc_inreset_cnt) in ath_calibrate()
5436 longCal = (ticks - sc->sc_lastlongcal >= ath_longcalinterval*hz); in ath_calibrate()
5437 aniCal = (ticks - sc->sc_lastani >= ath_anicalinterval*hz/1000); in ath_calibrate()
5438 if (sc->sc_doresetcal) in ath_calibrate()
5439 shortCal = (ticks - sc->sc_lastshortcal >= ath_shortcalinterval*hz/1000); in ath_calibrate()
5441 …DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: shortCal=%d; longCal=%d; aniCal=%d\n", __func__, shortCal, l… in ath_calibrate()
5443 sc->sc_stats.ast_ani_cal++; in ath_calibrate()
5444 sc->sc_lastani = ticks; in ath_calibrate()
5445 ath_hal_ani_poll(ah, sc->sc_curchan); in ath_calibrate()
5449 sc->sc_stats.ast_per_cal++; in ath_calibrate()
5450 sc->sc_lastlongcal = ticks; in ath_calibrate()
5456 DPRINTF(sc, ATH_DEBUG_CALIBRATE, in ath_calibrate()
5458 sc->sc_stats.ast_per_rfgain++; in ath_calibrate()
5459 sc->sc_resetcal = 0; in ath_calibrate()
5460 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5461 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_calibrate()
5462 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_calibrate()
5463 ath_power_restore_power_state(sc); in ath_calibrate()
5470 if (sc->sc_resetcal) { in ath_calibrate()
5471 (void) ath_hal_calreset(ah, sc->sc_curchan); in ath_calibrate()
5472 sc->sc_lastcalreset = ticks; in ath_calibrate()
5473 sc->sc_lastshortcal = ticks; in ath_calibrate()
5474 sc->sc_resetcal = 0; in ath_calibrate()
5475 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5482 if (ath_hal_calibrateN(ah, sc->sc_curchan, longCal, &isCalDone)) { in ath_calibrate()
5490 DPRINTF(sc, ATH_DEBUG_ANY, in ath_calibrate()
5492 __func__, sc->sc_curchan->ic_freq); in ath_calibrate()
5493 sc->sc_stats.ast_per_calfail++; in ath_calibrate()
5510 sc->sc_lastshortcal = ticks; in ath_calibrate()
5522 sc->sc_lastshortcal = ticks; in ath_calibrate()
5524 if (sc->sc_opmode != HAL_M_HOSTAP) in ath_calibrate()
5526 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5530 if (sc->sc_lastcalreset == 0) in ath_calibrate()
5531 sc->sc_lastcalreset = sc->sc_lastlongcal; in ath_calibrate()
5532 else if (ticks - sc->sc_lastcalreset >= ath_resetcalinterval*hz) in ath_calibrate()
5533 sc->sc_resetcal = 1; /* setup reset next trip */ in ath_calibrate()
5534 sc->sc_doresetcal = AH_FALSE; in ath_calibrate()
5541 DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: next +%u (%sisCalDone)\n", in ath_calibrate()
5543 callout_reset(&sc->sc_cal_ch, nextcal, ath_calibrate, sc); in ath_calibrate()
5545 DPRINTF(sc, ATH_DEBUG_CALIBRATE, "%s: calibration disabled\n", in ath_calibrate()
5552 ath_power_restore_power_state(sc); in ath_calibrate()
5558 struct ath_softc *sc = ic->ic_softc; in ath_scan_start() local
5559 struct ath_hal *ah = sc->sc_ah; in ath_scan_start()
5565 ATH_LOCK(sc); in ath_scan_start()
5566 sc->sc_scanning = 1; in ath_scan_start()
5567 sc->sc_syncbeacon = 0; in ath_scan_start()
5568 rfilt = ath_calcrxfilter(sc); in ath_scan_start()
5569 ATH_UNLOCK(sc); in ath_scan_start()
5571 ATH_PCU_LOCK(sc); in ath_scan_start()
5574 ATH_PCU_UNLOCK(sc); in ath_scan_start()
5576 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0\n", in ath_scan_start()
5583 struct ath_softc *sc = ic->ic_softc; in ath_scan_end() local
5584 struct ath_hal *ah = sc->sc_ah; in ath_scan_end()
5587 ATH_LOCK(sc); in ath_scan_end()
5588 sc->sc_scanning = 0; in ath_scan_end()
5589 rfilt = ath_calcrxfilter(sc); in ath_scan_end()
5590 ATH_UNLOCK(sc); in ath_scan_end()
5592 ATH_PCU_LOCK(sc); in ath_scan_end()
5594 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_scan_end()
5597 ATH_PCU_UNLOCK(sc); in ath_scan_end()
5599 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n", in ath_scan_end()
5600 __func__, rfilt, ether_sprintf(sc->sc_curbssid), in ath_scan_end()
5601 sc->sc_curaid); in ath_scan_end()
5623 struct ath_softc *sc = ic->ic_softc; in ath_update_chw() local
5626 device_printf(sc->sc_dev, "%s: called\n", __func__); in ath_update_chw()
5676 struct ath_softc *sc = ic->ic_softc; in ath_set_quiet_ie() local
5683 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5686 ath_hal_set_quiet(sc->sc_ah, 0, 0, 0, HAL_QUIET_DISABLE); in ath_set_quiet_ie()
5709 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5722 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5732 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5739 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5744 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5754 DPRINTF(sc, ATH_DEBUG_QUIETIE, in ath_set_quiet_ie()
5756 ath_hal_set_quiet(sc->sc_ah, in ath_set_quiet_ie()
5776 struct ath_softc *sc = ic->ic_softc; in ath_set_channel() local
5778 ATH_LOCK(sc); in ath_set_channel()
5779 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_set_channel()
5780 ATH_UNLOCK(sc); in ath_set_channel()
5782 (void) ath_chan_set(sc, ic->ic_curchan); in ath_set_channel()
5789 ATH_LOCK(sc); in ath_set_channel()
5790 if (!sc->sc_scanning && ic->ic_curchan == ic->ic_bsschan) in ath_set_channel()
5791 sc->sc_syncbeacon = 1; in ath_set_channel()
5792 ath_power_restore_power_state(sc); in ath_set_channel()
5793 ATH_UNLOCK(sc); in ath_set_channel()
5818 struct ath_softc *sc = ic->ic_softc; in ath_newstate() local
5820 struct ath_hal *ah = sc->sc_ah; in ath_newstate()
5838 DPRINTF(sc, ATH_DEBUG_STATE, "%s: %s -> %s\n", __func__, in ath_newstate()
5852 ATH_LOCK(sc); in ath_newstate()
5862 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
5867 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_newstate()
5873 callout_stop(&sc->sc_cal_ch); in ath_newstate()
5874 ATH_UNLOCK(sc); in ath_newstate()
5890 ATH_LOCK(sc); in ath_newstate()
5891 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
5892 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_newstate()
5893 ATH_UNLOCK(sc); in ath_newstate()
5896 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS)); in ath_newstate()
5897 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
5898 sc->sc_beacons = 0; in ath_newstate()
5899 taskqueue_unblock(sc->sc_tq); in ath_newstate()
5903 rfilt = ath_calcrxfilter(sc); in ath_newstate()
5913 sc->sc_curaid = ni->ni_associd; in ath_newstate()
5914 IEEE80211_ADDR_COPY(sc->sc_curbssid, ni->ni_bssid); in ath_newstate()
5915 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_newstate()
5917 DPRINTF(sc, ATH_DEBUG_STATE, "%s: RX filter 0x%x bssid %s aid 0x%x\n", in ath_newstate()
5918 __func__, rfilt, ether_sprintf(sc->sc_curbssid), sc->sc_curaid); in ath_newstate()
5997 DPRINTF(sc, ATH_DEBUG_STATE, in ath_newstate()
6030 ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_newstate()
6032 error = ath_beacon_alloc(sc, ni); in ath_newstate()
6045 sc->sc_syncbeacon = 1; in ath_newstate()
6046 } else if (!sc->sc_beacons) { in ath_newstate()
6049 ath_tdma_config(sc, vap); in ath_newstate()
6052 ath_beacon_config(sc, vap); in ath_newstate()
6053 sc->sc_beacons = 1; in ath_newstate()
6080 DPRINTF(sc, ATH_DEBUG_BEACON, in ath_newstate()
6082 sc->sc_syncbeacon = 1; in ath_newstate()
6084 ath_beacon_config(sc, vap); in ath_newstate()
6103 sc->sc_beacons = 1; in ath_newstate()
6113 ath_hal_intrset(ah, sc->sc_imask); in ath_newstate()
6128 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6129 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6130 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6135 ATH_LOCK(sc); in ath_newstate()
6136 ath_power_setselfgen(sc, HAL_PM_AWAKE); in ath_newstate()
6137 ath_power_setpower(sc, HAL_PM_AWAKE, 1); in ath_newstate()
6145 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_newstate()
6147 DPRINTF(sc, ATH_DEBUG_CALIBRATE, in ath_newstate()
6150 ATH_UNLOCK(sc); in ath_newstate()
6152 taskqueue_unblock(sc->sc_tq); in ath_newstate()
6165 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
6167 ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL); in ath_newstate()
6168 taskqueue_block(sc->sc_tq); in ath_newstate()
6169 sc->sc_beacons = 0; in ath_newstate()
6188 if (sc->sc_nvaps == 1 && in ath_newstate()
6190 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=%d\n", __func__, sc->sc_syncbeacon); in ath_newstate()
6191 ATH_LOCK(sc); in ath_newstate()
6196 ath_power_setselfgen(sc, HAL_PM_NETWORK_SLEEP); in ath_newstate()
6206 if (sc->sc_syncbeacon == 0) { in ath_newstate()
6207 ath_power_setpower(sc, HAL_PM_NETWORK_SLEEP, 1); in ath_newstate()
6209 ATH_UNLOCK(sc); in ath_newstate()
6235 ATH_LOCK(sc); in ath_newstate()
6238 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_newstate()
6240 DPRINTF(sc, ATH_DEBUG_CALIBRATE, in ath_newstate()
6243 ATH_UNLOCK(sc); in ath_newstate()
6252 ATH_LOCK(sc); in ath_newstate()
6253 ath_power_restore_power_state(sc); in ath_newstate()
6254 ATH_UNLOCK(sc); in ath_newstate()
6270 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_setup_stationkey() local
6289 ath_keyset(sc, vap, &ni->ni_ucastkey, vap->iv_bss); in ath_setup_stationkey()
6303 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_newassoc() local
6306 an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate); in ath_newassoc()
6307 an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate); in ath_newassoc()
6309 DPRINTF(sc, ATH_DEBUG_NODE, "%s: %6D: reassoc; isnew=%d, is_powersave=%d\n", in ath_newassoc()
6317 ath_rate_newassoc(sc, an, isnew); in ath_newassoc()
6321 (vap->iv_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey && in ath_newassoc()
6335 DPRINTF(sc, ATH_DEBUG_NODE, in ath_newassoc()
6343 ath_tx_node_reassoc(sc, an); in ath_newassoc()
6347 ath_tx_node_wakeup(sc, an); in ath_newassoc()
6355 struct ath_softc *sc = ic->ic_softc; in ath_setregdomain() local
6356 struct ath_hal *ah = sc->sc_ah; in ath_setregdomain()
6359 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, in ath_setregdomain()
6367 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: failed, status %u\n", in ath_setregdomain()
6379 struct ath_softc *sc = ic->ic_softc; in ath_getradiocaps() local
6380 struct ath_hal *ah = sc->sc_ah; in ath_getradiocaps()
6382 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, "%s: use rd %u cc %d\n", in ath_getradiocaps()
6392 ath_getchannels(struct ath_softc *sc) in ath_getchannels() argument
6394 struct ieee80211com *ic = &sc->sc_ic; in ath_getchannels()
6395 struct ath_hal *ah = sc->sc_ah; in ath_getchannels()
6404 device_printf(sc->sc_dev, in ath_getchannels()
6409 (void) ath_hal_getregdomain(ah, &sc->sc_eerd); in ath_getchannels()
6410 ath_hal_getcountrycode(ah, &sc->sc_eecc); /* NB: cannot fail */ in ath_getchannels()
6413 ic->ic_regdomain.regdomain = (uint16_t) sc->sc_eerd; in ath_getchannels()
6414 ic->ic_regdomain.country = (uint16_t) sc->sc_eecc; in ath_getchannels()
6421 DPRINTF(sc, ATH_DEBUG_REGDOMAIN, in ath_getchannels()
6423 __func__, sc->sc_eerd, sc->sc_eecc, in ath_getchannels()
6430 ath_rate_setup(struct ath_softc *sc, u_int mode) in ath_rate_setup() argument
6432 struct ath_hal *ah = sc->sc_ah; in ath_rate_setup()
6467 DPRINTF(sc, ATH_DEBUG_ANY, "%s: invalid mode %u\n", in ath_rate_setup()
6471 sc->sc_rates[mode] = rt; in ath_rate_setup()
6476 ath_setcurmode(struct ath_softc *sc, enum ieee80211_phymode mode) in ath_setcurmode() argument
6503 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); in ath_setcurmode()
6504 rt = sc->sc_rates[mode]; in ath_setcurmode()
6509 sc->sc_rixmap[ieeerate] = i; in ath_setcurmode()
6511 sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; in ath_setcurmode()
6513 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); in ath_setcurmode()
6514 for (i = 0; i < nitems(sc->sc_hwmap); i++) { in ath_setcurmode()
6516 sc->sc_hwmap[i].ledon = (500 * hz) / 1000; in ath_setcurmode()
6517 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; in ath_setcurmode()
6520 sc->sc_hwmap[i].ieeerate = in ath_setcurmode()
6523 sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS; in ath_setcurmode()
6524 sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; in ath_setcurmode()
6527 sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ath_setcurmode()
6528 sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags; in ath_setcurmode()
6530 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) in ath_setcurmode()
6534 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000; in ath_setcurmode()
6535 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000; in ath_setcurmode()
6537 sc->sc_currates = rt; in ath_setcurmode()
6538 sc->sc_curmode = mode; in ath_setcurmode()
6544 sc->sc_protrix = ath_tx_findrix(sc, 2*2); in ath_setcurmode()
6546 sc->sc_protrix = ath_tx_findrix(sc, 2*1); in ath_setcurmode()
6553 struct ath_softc *sc = arg; in ath_watchdog() local
6554 struct ieee80211com *ic = &sc->sc_ic; in ath_watchdog()
6557 ATH_LOCK_ASSERT(sc); in ath_watchdog()
6559 if (sc->sc_wd_timer != 0 && --sc->sc_wd_timer == 0) { in ath_watchdog()
6562 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_watchdog()
6564 if (ath_hal_gethangstate(sc->sc_ah, 0xffff, &hangs) && in ath_watchdog()
6566 device_printf(sc->sc_dev, "%s hang detected (0x%x)\n", in ath_watchdog()
6569 device_printf(sc->sc_dev, "device timeout\n"); in ath_watchdog()
6572 sc->sc_stats.ast_watchdog++; in ath_watchdog()
6574 ath_power_restore_power_state(sc); in ath_watchdog()
6584 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_watchdog()
6587 callout_schedule(&sc->sc_wd_ch, hz); in ath_watchdog()
6593 struct ath_softc *sc = ic->ic_softc; in ath_parent() local
6596 ATH_LOCK(sc); in ath_parent()
6603 if (sc->sc_running) { in ath_parent()
6604 ath_power_set_power_state(sc, HAL_PM_AWAKE); in ath_parent()
6605 ath_mode_init(sc); in ath_parent()
6606 ath_power_restore_power_state(sc); in ath_parent()
6607 } else if (!sc->sc_invalid) { in ath_parent()
6617 error = ath_init(sc); in ath_parent()
6620 ath_stop(sc); in ath_parent()
6621 if (!sc->sc_invalid) in ath_parent()
6622 ath_power_setpower(sc, HAL_PM_FULL_SLEEP, 1); in ath_parent()
6624 ATH_UNLOCK(sc); in ath_parent()
6628 if (sc->sc_tx99 != NULL) in ath_parent()
6629 sc->sc_tx99->start(sc->sc_tx99); in ath_parent()
6640 ath_announce(struct ath_softc *sc) in ath_announce() argument
6642 struct ath_hal *ah = sc->sc_ah; in ath_announce()
6644 device_printf(sc->sc_dev, "%s mac %d.%d RF%s phy %d.%d\n", in ath_announce()
6647 device_printf(sc->sc_dev, "2GHz radio: 0x%.4x; 5GHz radio: 0x%.4x\n", in ath_announce()
6652 struct ath_txq *txq = sc->sc_ac2q[i]; in ath_announce()
6653 device_printf(sc->sc_dev, in ath_announce()
6657 device_printf(sc->sc_dev, "Use hw queue %u for CAB traffic\n", in ath_announce()
6658 sc->sc_cabq->axq_qnum); in ath_announce()
6659 device_printf(sc->sc_dev, "Use hw queue %u for beacons\n", in ath_announce()
6660 sc->sc_bhalq); in ath_announce()
6663 device_printf(sc->sc_dev, "using %u rx buffers\n", ath_rxbuf); in ath_announce()
6665 device_printf(sc->sc_dev, "using %u tx buffers\n", ath_txbuf); in ath_announce()
6666 if (sc->sc_mcastkey && bootverbose) in ath_announce()
6667 device_printf(sc->sc_dev, "using multicast key search\n"); in ath_announce()
6673 struct ath_softc *sc = (struct ath_softc *) p; in ath_dfs_tasklet() local
6674 struct ieee80211com *ic = &sc->sc_ic; in ath_dfs_tasklet()
6681 if (ath_dfs_process_radar_event(sc, sc->sc_curchan)) { in ath_dfs_tasklet()
6698 ieee80211_dfs_notify_radar(ic, sc->sc_curchan); in ath_dfs_tasklet()
6715 struct ath_softc *sc = ic->ic_softc; in ath_node_powersave() local
6720 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, "%s: %6D: enable=%d\n", in ath_node_powersave()
6728 ath_tx_node_sleep(sc, an); in ath_node_powersave()
6730 ath_tx_node_wakeup(sc, an); in ath_node_powersave()
6782 struct ath_softc *sc = ic->ic_softc; in ath_node_set_tim() local
6787 ATH_TX_LOCK(sc); in ath_node_set_tim()
6798 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6817 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6823 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6825 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6832 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6836 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6843 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6849 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6856 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6864 ATH_TX_UNLOCK(sc); in ath_node_set_tim()
6865 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_set_tim()
6911 ath_tx_update_tim(struct ath_softc *sc, struct ieee80211_node *ni, in ath_tx_update_tim() argument
6932 ATH_TX_LOCK_ASSERT(sc); in ath_tx_update_tim()
6938 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_tx_update_tim()
6957 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_tx_update_tim()
6987 struct ath_softc *sc = ic->ic_softc; in ath_node_recv_pspoll() local
7032 ATH_TX_LOCK(sc); in ath_node_recv_pspoll()
7039 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
7044 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
7064 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
7065 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
7085 ath_tx_tid_sched(sc, atid); in ath_node_recv_pspoll()
7091 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
7092 taskqueue_enqueue(sc->sc_tq, &sc->sc_txqtask); in ath_node_recv_pspoll()
7093 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()
7102 ATH_TX_UNLOCK(sc); in ath_node_recv_pspoll()
7107 DPRINTF(sc, ATH_DEBUG_NODE_PWRSAVE, in ath_node_recv_pspoll()