Lines Matching +full:un +full:- +full:padded

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
44 * by the driver - eg, calls to ath_hal_gettsf32().
132 * Only enable this if you're working on PS-POLL support.
240 static int ath_anicalinterval = 100; /* ANI calibration - 100 msec */
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()
294 * If the chip is being programmed full-awake, then immediately
295 * program it full-awake so we can actually stay awake rather than
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()
328 * If the NIC is force-awake, then set the in _ath_power_setpower()
329 * self-gen frame state appropriately. in _ath_power_setpower()
331 * If the nic is in network sleep or full-sleep, in _ath_power_setpower()
332 * we let the above call leave the self-gen 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()
345 * Set the current self-generated frames state.
350 * needs to know to set PWRMGT=1 in self-generated frames.
363 sc->sc_target_selfgen_state); in _ath_power_set_selfgen()
365 sc->sc_target_selfgen_state = power_state; in _ath_power_set_selfgen()
368 * If the NIC is force-awake, then set the power state. in _ath_power_set_selfgen()
369 * Network-state and full-sleep will already transition it to in _ath_power_set_selfgen()
370 * mark self-gen frames as sleeping - and we can't in _ath_power_set_selfgen()
371 * guarantee the NIC is awake to program the self-gen frame 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()
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()
410 * Adjust the self-gen powerstate if appropriate. 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()
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()
451 * Adjust the self-gen powerstate if appropriate. 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()
477 if (sc->sc_pci_devinfo & (ATH_PCI_CUS198 | ATH_PCI_CUS230)) { in ath_setup_hal_config()
478 ah_config->ath_hal_ext_lna_ctl_gpio = 0x200; /* bit 9 */ in ath_setup_hal_config()
479 ah_config->ath_hal_ext_atten_margin_cfg = AH_TRUE; in ath_setup_hal_config()
480 ah_config->ath_hal_min_gainidx = AH_TRUE; in ath_setup_hal_config()
481 ah_config->ath_hal_ant_ctrl_comm2g_switch_enable = 0x000bbb88; 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()
517 pCap->hw_caps &= ~ATH9K_HW_CAP_ANT_DIV_COMB; in ath_setup_hal_config()
520 if (sc->sc_pci_devinfo & ATH9K_PCI_BT_ANT_DIV) { in ath_setup_hal_config()
521 pCap->hw_caps |= ATH9K_HW_CAP_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()
527 ah_config->ath_hal_pcie_waen = 0x0040473b; 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()
533 ah->config.no_pll_pwrsave = true; in ath_setup_hal_config()
534 device_printf(sc->sc_dev, "Disable PLL PowerSave\n"); in ath_setup_hal_config()
543 * Returns 0, macaddr in macaddr if successful; -1 otherwise.
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()
591 return (-1); in ath_fetch_mac_kenv()
601 struct ieee80211com *ic = &sc->sc_ic; in ath_attach()
611 ic->ic_softc = sc; in ath_attach()
612 ic->ic_name = device_get_nameunit(sc->sc_dev); 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()
654 if (ath_hal_hasedma(sc->sc_ah)) { in ath_attach()
655 sc->sc_isedma = 1; in ath_attach()
663 if (ath_hal_hasmybeacon(sc->sc_ah)) { in ath_attach()
664 sc->sc_do_mybeacon = 1; in ath_attach()
668 * Check if the MAC has multi-rate retry support. 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()
730 device_printf(sc->sc_dev, in ath_attach()
736 device_printf(sc->sc_dev, 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()
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()
775 * XXX PS-Poll 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()
792 device_printf(sc->sc_dev, 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()
820 * The non-EDMA chips may have some special case optimisations; 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()
840 device_printf(sc->sc_dev, in ath_attach()
848 device_printf(sc->sc_dev, in ath_attach()
856 device_printf(sc->sc_dev, 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()
881 * Don't setup hardware-based blinking. in ath_attach()
888 * the MAC power LED to GPIO2. However, the DWA-552 cardbus 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()
895 * Auto-enable soft led processing for IBM cards and for in ath_attach()
899 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); in ath_attach()
904 ic->ic_phytype = IEEE80211_T_OFDM; in ath_attach()
905 ic->ic_opmode = IEEE80211_M_STA; in ath_attach()
906 ic->ic_caps = in ath_attach()
912 | IEEE80211_C_WDS /* 4-address traffic works */ in ath_attach()
928 ic->ic_flags_ext |= IEEE80211_FEXT_SEQNO_OFFLOAD; in ath_attach()
934 ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP; in ath_attach()
936 ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_OCB; in ath_attach()
938 ic->ic_cryptocaps |= IEEE80211_CRYPTO_AES_CCM; in ath_attach()
940 ic->ic_cryptocaps |= IEEE80211_CRYPTO_CKIP; in ath_attach()
942 ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIP; in ath_attach()
949 ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC; in ath_attach()
956 sc->sc_splitmic = 1; in ath_attach()
963 sc->sc_wmetkipmic = 1; in ath_attach()
965 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR); in ath_attach()
969 if (ath_hal_hasmcastkeysearch(sc->sc_ah) && in ath_attach()
970 !ath_hal_getmcastkeysearch(sc->sc_ah)) { in ath_attach()
971 ath_hal_setmcastkeysearch(sc->sc_ah, 1); in ath_attach()
973 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); in ath_attach()
980 setbit(sc->sc_keymap, i); in ath_attach()
981 setbit(sc->sc_keymap, i+64); in ath_attach()
982 if (sc->sc_splitmic) { in ath_attach()
983 setbit(sc->sc_keymap, i+32); in ath_attach()
984 setbit(sc->sc_keymap, i+32+64); in ath_attach()
989 * per-packet support. The latter is not available on in ath_attach()
994 ic->ic_caps |= IEEE80211_C_TXPMGT; in ath_attach()
1000 if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK]) in ath_attach()
1001 ic->ic_caps |= IEEE80211_C_WME; in ath_attach()
1006 ic->ic_caps |= IEEE80211_C_BURST; in ath_attach()
1007 sc->sc_hasbmask = ath_hal_hasbssidmask(ah); in ath_attach()
1008 sc->sc_hasbmatch = ath_hal_hasbssidmatch(ah); in ath_attach()
1009 sc->sc_hastsfadd = ath_hal_hastsfadjust(ah); in ath_attach()
1010 sc->sc_rxslink = ath_hal_self_linked_final_rxdesc(ah); in ath_attach()
1015 sc->sc_rxtsf32 = 1; in ath_attach()
1018 device_printf(sc->sc_dev, "RX timestamp: %d bits\n", i); in ath_attach()
1022 device_printf(sc->sc_dev, "TX timestamp: %d bits\n", i); in ath_attach()
1025 sc->sc_hasenforcetxop = ath_hal_hasenforcetxop(ah); in ath_attach()
1026 sc->sc_rx_lnamixer = ath_hal_hasrxlnamixer(ah); in ath_attach()
1027 sc->sc_hasdivcomb = ath_hal_hasdivantcomb(ah); in ath_attach()
1044 if (sc->sc_pci_devinfo & (ATH9K_PCI_AR9565_1ANT | ATH9K_PCI_AR9565_2ANT)) { in ath_attach()
1045 device_printf(sc->sc_dev, "%s: WB335: disabling LNA mixer diversity\n", in ath_attach()
1047 sc->sc_dolnadiv = 0; in ath_attach()
1052 ic->ic_caps |= IEEE80211_C_FF; in ath_attach()
1055 ic->ic_caps |= IEEE80211_C_TURBOP; in ath_attach()
1058 ic->ic_caps |= IEEE80211_C_TDMA; /* capable of TDMA */ in ath_attach()
1059 ic->ic_tdma_update = ath_tdma_update; in ath_attach()
1068 sc->sc_txq_data_minfree = 10; in ath_attach()
1078 sc->sc_txq_mcastq_maxdepth = MIN(64, ath_txbuf / 4); in ath_attach()
1083 sc->sc_txq_node_psq_maxdepth = 16; in ath_attach()
1090 * at 64, two full A-MPDU subframes of 32 frames each is in ath_attach()
1094 * to begin making A-MPDU frames out of. in ath_attach()
1096 sc->sc_txq_node_maxdepth = MIN(128, ath_txbuf / 4); in ath_attach()
1099 sc->sc_cabq_enable = 1; in ath_attach()
1105 * This must be done early - before the hardware is in ath_attach()
1109 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1110 device_get_unit(sc->sc_dev), "rx_chainmask", in ath_attach()
1112 device_printf(sc->sc_dev, "Setting RX chainmask to 0x%x\n", in ath_attach()
1114 (void) ath_hal_setrxchainmask(sc->sc_ah, rx_chainmask); in ath_attach()
1116 if (resource_int_value(device_get_name(sc->sc_dev), in ath_attach()
1117 device_get_unit(sc->sc_dev), "tx_chainmask", in ath_attach()
1119 device_printf(sc->sc_dev, "Setting TX chainmask to 0x%x\n", in ath_attach()
1121 (void) ath_hal_settxchainmask(sc->sc_ah, tx_chainmask); in ath_attach()
1129 ath_hal_getrxchainmask(ah, &sc->sc_rxchainmask); in ath_attach()
1130 ath_hal_gettxchainmask(ah, &sc->sc_txchainmask); in ath_attach()
1136 sc->sc_mrrprot = 0; /* XXX should be a capability */ in ath_attach()
1142 &sc->sc_ent_cfg) == HAL_OK) in ath_attach()
1143 sc->sc_use_ent = 1; in ath_attach()
1154 device_printf(sc->sc_dev, "[HT] enabling HT modes\n"); in ath_attach()
1156 sc->sc_mrrprot = 1; /* XXX should be a capability */ in ath_attach()
1158 ic->ic_htcaps = IEEE80211_HTC_HT /* HT operation */ in ath_attach()
1159 | IEEE80211_HTC_AMPDU /* A-MPDU tx/rx */ in ath_attach()
1160 | IEEE80211_HTC_AMSDU /* A-MSDU tx/rx */ in ath_attach()
1162 /* max A-MSDU length */ in ath_attach()
1166 * Enable short-GI for HT20 only if the hardware in ath_attach()
1173 device_printf(sc->sc_dev, in ath_attach()
1174 "[HT] enabling short-GI in 20MHz mode\n"); in ath_attach()
1175 ic->ic_htcaps |= IEEE80211_HTCAP_SHORTGI20; in ath_attach()
1179 ic->ic_htcaps |= IEEE80211_HTCAP_CHWIDTH40 in ath_attach()
1189 ic->ic_txstream = txs; in ath_attach()
1190 ic->ic_rxstream = rxs; in ath_attach()
1195 * Ie - don't enable STBC TX if only one chain is enabled. in ath_attach()
1201 sc->sc_rx_stbc = 1; in ath_attach()
1202 device_printf(sc->sc_dev, in ath_attach()
1204 ic->ic_htcaps |= IEEE80211_HTCAP_RXSTBC_1STREAM; in ath_attach()
1208 sc->sc_tx_stbc = 1; in ath_attach()
1209 device_printf(sc->sc_dev, in ath_attach()
1211 ic->ic_htcaps |= IEEE80211_HTCAP_TXSTBC; in ath_attach()
1215 &sc->sc_rts_aggr_limit); in ath_attach()
1216 if (sc->sc_rts_aggr_limit != (64 * 1024)) in ath_attach()
1217 device_printf(sc->sc_dev, in ath_attach()
1219 sc->sc_rts_aggr_limit / 1024); in ath_attach()
1226 sc->sc_has_ldpc = 1; in ath_attach()
1227 device_printf(sc->sc_dev, in ath_attach()
1229 ic->ic_htcaps |= IEEE80211_HTCAP_LDPC | in ath_attach()
1233 device_printf(sc->sc_dev, in ath_attach()
1241 sc->sc_hwq_limit_aggr = ATH_AGGR_MIN_QDEPTH; in ath_attach()
1242 sc->sc_hwq_limit_nonaggr = ATH_NONAGGR_MIN_QDEPTH; in ath_attach()
1243 sc->sc_tid_hwq_lo = ATH_AGGR_SCHED_LOW; in ath_attach()
1244 sc->sc_tid_hwq_hi = ATH_AGGR_SCHED_HIGH; in ath_attach()
1245 sc->sc_aggr_limit = ATH_AGGR_MAXSIZE; in ath_attach()
1246 sc->sc_delim_min_pad = 0; in ath_attach()
1255 sc->sc_ah->ah_config.ah_serialise_reg_war = 1; in ath_attach()
1256 device_printf(sc->sc_dev, in ath_attach()
1263 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_HP]); in ath_attach()
1264 TAILQ_INIT(&sc->sc_rx_rxlist[HAL_RX_QUEUE_LP]); in ath_attach()
1267 * Indicate we need the 802.11 header padded to a in ath_attach()
1268 * 32-bit boundary for 4-address and QoS frames. in ath_attach()
1270 ic->ic_flags |= IEEE80211_F_DATAPAD; in ath_attach()
1275 sc->sc_defant = ath_hal_getdefantenna(ah); in ath_attach()
1281 sc->sc_hasveol = ath_hal_hasveol(ah); in ath_attach()
1284 if (ath_fetch_mac_kenv(sc, ic->ic_macaddr) == 0) { in ath_attach()
1286 ath_hal_setmac(ah, ic->ic_macaddr); in ath_attach()
1288 ath_hal_getmac(ah, ic->ic_macaddr); in ath_attach()
1291 if (sc->sc_hasbmask) in ath_attach()
1292 ath_hal_getbssidmask(ah, sc->sc_hwbssidmask); in ath_attach()
1295 ic->ic_max_keyix = sc->sc_keymax; in ath_attach()
1298 ic->ic_setregdomain = ath_setregdomain; in ath_attach()
1299 ic->ic_getradiocaps = ath_getradiocaps; in ath_attach()
1300 sc->sc_opmode = HAL_M_STA; in ath_attach()
1303 ic->ic_ioctl = ath_ioctl; in ath_attach()
1304 ic->ic_parent = ath_parent; in ath_attach()
1305 ic->ic_transmit = ath_transmit; in ath_attach()
1306 ic->ic_newassoc = ath_newassoc; in ath_attach()
1307 ic->ic_updateslot = ath_updateslot; in ath_attach()
1308 ic->ic_wme.wme_update = ath_wme_update; in ath_attach()
1309 ic->ic_vap_create = ath_vap_create; in ath_attach()
1310 ic->ic_vap_delete = ath_vap_delete; in ath_attach()
1311 ic->ic_raw_xmit = ath_raw_xmit; in ath_attach()
1312 ic->ic_update_mcast = ath_update_mcast; in ath_attach()
1313 ic->ic_update_promisc = ath_update_promisc; in ath_attach()
1314 ic->ic_node_alloc = ath_node_alloc; in ath_attach()
1315 sc->sc_node_free = ic->ic_node_free; in ath_attach()
1316 ic->ic_node_free = ath_node_free; in ath_attach()
1317 sc->sc_node_cleanup = ic->ic_node_cleanup; in ath_attach()
1318 ic->ic_node_cleanup = ath_node_cleanup; in ath_attach()
1319 ic->ic_node_getsignal = ath_node_getsignal; in ath_attach()
1320 ic->ic_scan_start = ath_scan_start; in ath_attach()
1321 ic->ic_scan_end = ath_scan_end; in ath_attach()
1322 ic->ic_set_channel = ath_set_channel; in ath_attach()
1324 /* 802.11n specific - but just override anyway */ in ath_attach()
1325 sc->sc_addba_request = ic->ic_addba_request; in ath_attach()
1326 sc->sc_addba_response = ic->ic_addba_response; in ath_attach()
1327 sc->sc_addba_stop = ic->ic_addba_stop; in ath_attach()
1328 sc->sc_bar_response = ic->ic_bar_response; in ath_attach()
1329 sc->sc_addba_response_timeout = ic->ic_addba_response_timeout; in ath_attach()
1331 ic->ic_addba_request = ath_addba_request; in ath_attach()
1332 ic->ic_addba_response = ath_addba_response; in ath_attach()
1333 ic->ic_addba_response_timeout = ath_addba_response_timeout; in ath_attach()
1334 ic->ic_addba_stop = ath_addba_stop; in ath_attach()
1335 ic->ic_bar_response = ath_bar_response; in ath_attach()
1337 ic->ic_update_chw = ath_update_chw; in ath_attach()
1339 ic->ic_set_quiet = ath_set_quiet_ie; in ath_attach()
1347 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), 0, in ath_attach()
1349 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), 1, in ath_attach()
1356 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), in ath_attach()
1358 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), in ath_attach()
1366 if_ath_alq_init(&sc->sc_alq, device_get_nameunit(sc->sc_dev)); in ath_attach()
1367 if_ath_alq_setcfg(&sc->sc_alq, in ath_attach()
1368 sc->sc_ah->ah_macVersion, in ath_attach()
1369 sc->sc_ah->ah_macRev, in ath_attach()
1370 sc->sc_ah->ah_phyRev, in ath_attach()
1371 sc->sc_ah->ah_magic); in ath_attach()
1403 sc->sc_invalid = 1; in ath_attach()
1441 ieee80211_ifdetach(&sc->sc_ic); in ath_detach()
1442 taskqueue_free(sc->sc_tq); in ath_detach()
1444 if (sc->sc_tx99 != NULL) in ath_detach()
1445 sc->sc_tx99->detach(sc->sc_tx99); in ath_detach()
1447 ath_rate_detach(sc->sc_rc); in ath_detach()
1449 if_ath_alq_tidyup(&sc->sc_alq); in ath_detach()
1459 ath_hal_detach(sc->sc_ah); /* NB: sets chip in full sleep */ in ath_detach()
1475 if (clone && sc->sc_hasbmask) { in assign_address()
1478 if ((sc->sc_bssidmask & (1<<i)) == 0) in assign_address()
1484 sc->sc_bssidmask |= 1<<i; in assign_address()
1485 sc->sc_hwbssidmask[0] &= ~mac[0]; in assign_address()
1487 sc->sc_nbssid0++; in assign_address()
1496 if (i != 0 || --sc->sc_nbssid0 == 0) { in reclaim_address()
1497 sc->sc_bssidmask &= ~(1<<i); in reclaim_address()
1501 if (sc->sc_bssidmask & (1<<i)) in reclaim_address()
1503 sc->sc_hwbssidmask[0] |= mask; in reclaim_address()
1520 if (sc->sc_bslot[slot] == NULL) { in assign_bslot()
1521 if (sc->sc_bslot[(slot+1)%ATH_BCBUF] == NULL && in assign_bslot()
1522 sc->sc_bslot[(slot-1)%ATH_BCBUF] == NULL) in assign_bslot()
1536 struct ath_softc *sc = ic->ic_softc; in ath_vap_create()
1551 if (sc->sc_nstavaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1552 device_printf(sc->sc_dev, "only 1 sta vap supported\n"); in ath_vap_create()
1555 if (sc->sc_nvaps) { in ath_vap_create()
1570 if (sc->sc_nvaps != 0) { /* XXX only 1 for now */ in ath_vap_create()
1571 device_printf(sc->sc_dev, in ath_vap_create()
1580 if (sc->sc_nvaps != 0) { in ath_vap_create()
1581 device_printf(sc->sc_dev, in ath_vap_create()
1591 if (sc->sc_nvaps != 0 && ic->ic_opmode != opmode) { in ath_vap_create()
1598 ic_opmode = ic->ic_opmode; in ath_vap_create()
1606 if (sc->sc_nvaps != 0 && ic->ic_opmode == IEEE80211_M_STA) { in ath_vap_create()
1607 device_printf(sc->sc_dev, in ath_vap_create()
1617 if (sc->sc_nvaps == 0) in ath_vap_create()
1620 ic_opmode = ic->ic_opmode; in ath_vap_create()
1623 device_printf(sc->sc_dev, "unknown opmode %d\n", opmode); in ath_vap_create()
1629 if (needbeacon & TAILQ_EMPTY(&sc->sc_bbuf)) { in ath_vap_create()
1630 device_printf(sc->sc_dev, "no beacon buffer available\n"); in ath_vap_create()
1637 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1640 vap = &avp->av_vap; in ath_vap_create()
1646 device_printf(sc->sc_dev, "%s: error %d creating vap\n", in ath_vap_create()
1652 vap->iv_key_alloc = ath_key_alloc; in ath_vap_create()
1653 vap->iv_key_delete = ath_key_delete; in ath_vap_create()
1654 vap->iv_key_set = ath_key_set; in ath_vap_create()
1655 vap->iv_key_update_begin = ath_key_update_begin; in ath_vap_create()
1656 vap->iv_key_update_end = ath_key_update_end; in ath_vap_create()
1659 avp->av_recv_mgmt = vap->iv_recv_mgmt; in ath_vap_create()
1660 vap->iv_recv_mgmt = ath_recv_mgmt; in ath_vap_create()
1661 vap->iv_reset = ath_reset_vap; in ath_vap_create()
1662 vap->iv_update_beacon = ath_beacon_update; in ath_vap_create()
1663 avp->av_newstate = vap->iv_newstate; in ath_vap_create()
1664 vap->iv_newstate = ath_newstate; in ath_vap_create()
1665 avp->av_bmiss = vap->iv_bmiss; in ath_vap_create()
1666 vap->iv_bmiss = ath_bmiss_vap; in ath_vap_create()
1668 avp->av_node_ps = vap->iv_node_ps; in ath_vap_create()
1669 vap->iv_node_ps = ath_node_powersave; in ath_vap_create()
1671 avp->av_set_tim = vap->iv_set_tim; in ath_vap_create()
1672 vap->iv_set_tim = ath_node_set_tim; in ath_vap_create()
1674 avp->av_recv_pspoll = vap->iv_recv_pspoll; in ath_vap_create()
1675 vap->iv_recv_pspoll = ath_node_recv_pspoll; in ath_vap_create()
1683 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_8; in ath_vap_create()
1690 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in ath_vap_create()
1691 vap->iv_ampdu_limit = IEEE80211_HTCAP_MAXRXAMPDU_64K; in ath_vap_create()
1693 avp->av_bslot = -1; in ath_vap_create()
1700 avp->av_bcbuf = TAILQ_FIRST(&sc->sc_bbuf); in ath_vap_create()
1701 TAILQ_REMOVE(&sc->sc_bbuf, avp->av_bcbuf, bf_list); in ath_vap_create()
1702 if (opmode != IEEE80211_M_IBSS || !sc->sc_hasveol) { in ath_vap_create()
1707 avp->av_bslot = assign_bslot(sc); in ath_vap_create()
1708 KASSERT(sc->sc_bslot[avp->av_bslot] == NULL, in ath_vap_create()
1709 ("beacon slot %u not empty", avp->av_bslot)); in ath_vap_create()
1710 sc->sc_bslot[avp->av_bslot] = vap; in ath_vap_create()
1711 sc->sc_nbcnvaps++; in ath_vap_create()
1713 if (sc->sc_hastsfadd && sc->sc_nbcnvaps > 0) { in ath_vap_create()
1719 sc->sc_stagbeacons = 1; in ath_vap_create()
1721 ath_txq_init(sc, &avp->av_mcastq, ATH_TXQ_SWQ); in ath_vap_create()
1724 ic->ic_opmode = ic_opmode; in ath_vap_create()
1726 sc->sc_nvaps++; in ath_vap_create()
1728 sc->sc_nstavaps++; in ath_vap_create()
1730 sc->sc_nmeshvaps++; in ath_vap_create()
1734 sc->sc_opmode = HAL_M_IBSS; in ath_vap_create()
1737 sc->sc_opmode = HAL_M_STA; in ath_vap_create()
1741 if (vap->iv_caps & IEEE80211_C_TDMA) { in ath_vap_create()
1742 sc->sc_tdma = 1; in ath_vap_create()
1744 sc->sc_stagbeacons = 0; in ath_vap_create()
1754 sc->sc_opmode = HAL_M_HOSTAP; in ath_vap_create()
1757 sc->sc_opmode = HAL_M_MONITOR; in ath_vap_create()
1763 if (sc->sc_hastsfadd) { in ath_vap_create()
1767 ath_hal_settsfadjust(sc->sc_ah, sc->sc_stagbeacons); in ath_vap_create()
1773 sc->sc_swbmiss = 1; in ath_vap_create()
1783 ath_hal_setbssidmask(sc->sc_ah, sc->sc_hwbssidmask); in ath_vap_create()
1793 struct ieee80211com *ic = vap->iv_ic; in ath_vap_delete()
1794 struct ath_softc *sc = ic->ic_softc; in ath_vap_delete()
1795 struct ath_hal *ah = sc->sc_ah; in ath_vap_delete()
1803 if (sc->sc_running) { in ath_vap_delete()
1829 * This may be racy - the ath task may be running and the packet in ath_vap_delete()
1830 * may be being scheduled between sw->hw txq. Tsk. in ath_vap_delete()
1845 if (avp->av_bcbuf != NULL) { in ath_vap_delete()
1846 if (avp->av_bslot != -1) { in ath_vap_delete()
1847 sc->sc_bslot[avp->av_bslot] = NULL; in ath_vap_delete()
1848 sc->sc_nbcnvaps--; in ath_vap_delete()
1850 ath_beacon_return(sc, avp->av_bcbuf); in ath_vap_delete()
1851 avp->av_bcbuf = NULL; in ath_vap_delete()
1852 if (sc->sc_nbcnvaps == 0) { in ath_vap_delete()
1853 sc->sc_stagbeacons = 0; in ath_vap_delete()
1854 if (sc->sc_hastsfadd) in ath_vap_delete()
1855 ath_hal_settsfadjust(sc->sc_ah, 0); in ath_vap_delete()
1860 ath_tx_draintxq(sc, &avp->av_mcastq); in ath_vap_delete()
1865 if (vap->iv_opmode == IEEE80211_M_STA) { in ath_vap_delete()
1866 sc->sc_nstavaps--; in ath_vap_delete()
1867 if (sc->sc_nstavaps == 0 && sc->sc_swbmiss) in ath_vap_delete()
1868 sc->sc_swbmiss = 0; in ath_vap_delete()
1869 } else if (vap->iv_opmode == IEEE80211_M_HOSTAP || in ath_vap_delete()
1870 vap->iv_opmode == IEEE80211_M_STA || in ath_vap_delete()
1871 vap->iv_opmode == IEEE80211_M_MBSS) { in ath_vap_delete()
1872 reclaim_address(sc, vap->iv_myaddr); in ath_vap_delete()
1873 ath_hal_setbssidmask(ah, sc->sc_hwbssidmask); in ath_vap_delete()
1874 if (vap->iv_opmode == IEEE80211_M_MBSS) in ath_vap_delete()
1875 sc->sc_nmeshvaps--; in ath_vap_delete()
1877 if (vap->iv_opmode != IEEE80211_M_WDS) in ath_vap_delete()
1878 sc->sc_nvaps--; in ath_vap_delete()
1881 if (sc->sc_tdma && sc->sc_nvaps == 0) { in ath_vap_delete()
1882 sc->sc_tdma = 0; in ath_vap_delete()
1883 sc->sc_swbmiss = 0; in ath_vap_delete()
1888 if (sc->sc_running) { in ath_vap_delete()
1894 device_printf(sc->sc_dev, in ath_vap_delete()
1896 if (sc->sc_beacons) { /* restart beacons */ in ath_vap_delete()
1898 if (sc->sc_tdma) in ath_vap_delete()
1904 ath_hal_intrset(ah, sc->sc_imask); in ath_vap_delete()
1915 struct ieee80211com *ic = &sc->sc_ic; in ath_suspend()
1917 sc->sc_resume_up = ic->ic_nrunning != 0; in ath_suspend()
1925 * XXX TODO: well, that's great, except for non-cardbus in ath_suspend()
1934 ath_hal_intrset(sc->sc_ah, 0); in ath_suspend()
1935 taskqueue_block(sc->sc_tq); in ath_suspend()
1938 callout_stop(&sc->sc_cal_ch); in ath_suspend()
1946 ath_hal_enablepcie(sc->sc_ah, 1, 1); in ath_suspend()
1952 * re-load keys that the 802.11 layer assumes are setup
1958 struct ieee80211com *ic = &sc->sc_ic; in ath_reset_keycache()
1959 struct ath_hal *ah = sc->sc_ah; in ath_reset_keycache()
1964 for (i = 0; i < sc->sc_keymax; i++) in ath_reset_keycache()
1983 sc->sc_cur_rxchainmask = sc->sc_rxchainmask; in ath_update_chainmasks()
1985 sc->sc_cur_txchainmask = sc->sc_txchainmask; in ath_update_chainmasks()
1987 sc->sc_cur_txchainmask = 1; in ath_update_chainmasks()
1993 sc->sc_cur_txchainmask, in ath_update_chainmasks()
1994 sc->sc_cur_rxchainmask); in ath_update_chainmasks()
2000 struct ieee80211com *ic = &sc->sc_ic; in ath_resume()
2001 struct ath_hal *ah = sc->sc_ah; in ath_resume()
2011 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan); in ath_resume()
2012 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_resume()
2013 sc->sc_cur_rxchainmask); in ath_resume()
2022 ath_hal_reset(ah, sc->sc_opmode, in ath_resume()
2023 sc->sc_curchan != NULL ? sc->sc_curchan : ic->ic_curchan, in ath_resume()
2028 sc->sc_rx_stopped = 1; in ath_resume()
2029 sc->sc_rx_resetted = 1; in ath_resume()
2033 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_resume()
2036 ath_spectral_enable(sc, ic->ic_curchan); in ath_resume()
2041 ath_btcoex_enable(sc, ic->ic_curchan); in ath_resume()
2047 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_resume()
2048 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_resume()
2050 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_resume()
2056 if (sc->sc_resume_up) in ath_resume()
2083 struct ath_hal *ah = sc->sc_ah; in ath_intr()
2092 if (sc->sc_inreset_cnt) { in ath_intr()
2103 if (sc->sc_invalid) { in ath_intr()
2121 if (sc->sc_ic.ic_nrunning == 0 && sc->sc_running == 0) { in ath_intr()
2125 __func__, sc->sc_ic.ic_nrunning, sc->sc_running); in ath_intr()
2138 * that the hal returns a pseudo-ISR that may include in ath_intr()
2146 if_ath_alq_post_intr(&sc->sc_alq, status, ah->ah_intrstate, in ath_intr()
2147 ah->ah_syncstate); in ath_intr()
2152 ah->ah_intrstate[0], in ath_intr()
2153 ah->ah_intrstate[1], in ath_intr()
2154 ah->ah_intrstate[2], in ath_intr()
2155 ah->ah_intrstate[3], in ath_intr()
2156 ah->ah_intrstate[6]); in ath_intr()
2160 if (ah->ah_syncstate != 0) { in ath_intr()
2163 if (ah->ah_syncstate & (1 << i)) in ath_intr()
2164 sc->sc_intr_stats.sync_intr[i]++; in ath_intr()
2167 status &= sc->sc_imask; /* discard unasked for bits */ in ath_intr()
2169 /* Short-circuit un-handled interrupts */ in ath_intr()
2184 sc->sc_intr_cnt++; in ath_intr()
2193 sc->sc_stats.ast_hardware++; in ath_intr()
2195 taskqueue_enqueue(sc->sc_tq, &sc->sc_fataltask); in ath_intr()
2199 * Software beacon alert--time to send a beacon. in ath_intr()
2205 if (sc->sc_tdma) { in ath_intr()
2206 if (sc->sc_tdmaswba == 0) { in ath_intr()
2207 struct ieee80211com *ic = &sc->sc_ic; in ath_intr()
2209 TAILQ_FIRST(&ic->ic_vaps); in ath_intr()
2211 sc->sc_tdmaswba = in ath_intr()
2212 vap->iv_tdma->tdma_bintval; in ath_intr()
2214 sc->sc_tdmaswba--; in ath_intr()
2225 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2232 if (! sc->sc_isedma) { in ath_intr()
2235 * NB: the hardware should re-read the link when in ath_intr()
2239 sc->sc_stats.ast_rxeol++; in ath_intr()
2241 * Disable RXEOL/RXORN - prevent an interrupt in ath_intr()
2245 * modify sc_imask - that way if it is reset in ath_intr()
2249 imask = sc->sc_imask; in ath_intr()
2256 * This isn't entirely correct - the correct solution in ath_intr()
2263 if (! sc->sc_kickpcu) in ath_intr()
2264 sc->sc_rxlink = NULL; in ath_intr()
2265 sc->sc_kickpcu = 1; in ath_intr()
2273 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2276 sc->sc_stats.ast_txurn++; in ath_intr()
2285 sc->sc_stats.ast_rx_intr++; in ath_intr()
2286 sc->sc_rx.recv_sched(sc, 1); in ath_intr()
2289 sc->sc_stats.ast_tx_intr++; in ath_intr()
2295 if (! sc->sc_isedma) { in ath_intr()
2298 ath_hal_gettxintrtxqs(sc->sc_ah, &txqs); in ath_intr()
2302 sc->sc_txq_active, in ath_intr()
2303 sc->sc_txq_active | txqs); in ath_intr()
2304 sc->sc_txq_active |= txqs; in ath_intr()
2307 taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask); in ath_intr()
2310 sc->sc_stats.ast_bmiss++; in ath_intr()
2311 taskqueue_enqueue(sc->sc_tq, &sc->sc_bmisstask); in ath_intr()
2314 sc->sc_stats.ast_tx_timeout++; in ath_intr()
2316 sc->sc_stats.ast_tx_cst++; in ath_intr()
2318 sc->sc_stats.ast_mib++; in ath_intr()
2329 ath_hal_mibevent(ah, &sc->sc_halstats); in ath_intr()
2336 if (sc->sc_kickpcu == 0) in ath_intr()
2337 ath_hal_intrset(ah, sc->sc_imask); in ath_intr()
2343 sc->sc_stats.ast_rxorn++; in ath_intr()
2347 * out of range beacon - wake the chip up, in ath_intr()
2348 * but don't modify self-gen frame config. in ath_intr()
2352 sc->sc_stats.ast_tsfoor++; in ath_intr()
2356 taskqueue_enqueue(sc->sc_tq, &sc->sc_tsfoortask); in ath_intr()
2357 device_printf(sc->sc_dev, "%s: TSFOOR\n", __func__); in ath_intr()
2364 sc->sc_intr_cnt--; in ath_intr()
2380 if (sc->sc_invalid) in ath_fatal_proc()
2383 device_printf(sc->sc_dev, "hardware error; resetting\n"); in ath_fatal_proc()
2389 if (ath_hal_getfatalstate(sc->sc_ah, &sp, &len)) { in ath_fatal_proc()
2392 device_printf(sc->sc_dev, in ath_fatal_proc()
2402 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_bmiss_vap()
2405 * Workaround phantom bmiss interrupts by sanity-checking in ath_bmiss_vap()
2422 if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { in ath_bmiss_vap()
2423 u_int64_t lastrx = sc->sc_lastrx; in ath_bmiss_vap()
2424 u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah); in ath_bmiss_vap()
2427 vap->iv_bmissthreshold * vap->iv_bss->ni_intval * 1024; in ath_bmiss_vap()
2432 (unsigned long long)(tsf - lastrx), in ath_bmiss_vap()
2435 if (tsf - lastrx <= bmisstimeout) { in ath_bmiss_vap()
2436 sc->sc_stats.ast_bmiss_phantom++; in ath_bmiss_vap()
2447 * Keep the hardware awake if it's asleep (and leave self-gen in ath_bmiss_vap()
2451 * This handles three common beacon miss cases in STA powersave mode - in ath_bmiss_vap()
2464 if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { in ath_bmiss_vap()
2468 sc->sc_syncbeacon = 1; in ath_bmiss_vap()
2471 ATH_VAP(vap)->av_bmiss(vap); in ath_bmiss_vap()
2505 * It may be a non-recognised RX clear hang which needs a reset in ath_bmiss_proc()
2508 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) { in ath_bmiss_proc()
2510 device_printf(sc->sc_dev, in ath_bmiss_proc()
2514 ieee80211_beacon_miss(&sc->sc_ic); in ath_bmiss_proc()
2518 sc->sc_syncbeacon = 1; in ath_bmiss_proc()
2551 sc->sc_syncbeacon = 1; in ath_tsfoor_proc()
2567 struct ieee80211com *ic = &sc->sc_ic; in ath_settkipmic()
2569 if ((ic->ic_cryptocaps & IEEE80211_CRYPTO_TKIP) && !sc->sc_wmetkipmic) { in ath_settkipmic()
2570 if (ic->ic_flags & IEEE80211_F_WME) { in ath_settkipmic()
2571 ath_hal_settkipmic(sc->sc_ah, AH_FALSE); in ath_settkipmic()
2572 ic->ic_cryptocaps &= ~IEEE80211_CRYPTO_TKIPMIC; in ath_settkipmic()
2574 ath_hal_settkipmic(sc->sc_ah, AH_TRUE); in ath_settkipmic()
2575 ic->ic_cryptocaps |= IEEE80211_CRYPTO_TKIPMIC; in ath_settkipmic()
2583 struct ieee80211com *ic = &sc->sc_ic; in ath_vap_clear_quiet_ie()
2587 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { in ath_vap_clear_quiet_ie()
2589 /* Quiet time handling - ensure we resync */ in ath_vap_clear_quiet_ie()
2590 memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); in ath_vap_clear_quiet_ie()
2597 struct ieee80211com *ic = &sc->sc_ic; in ath_init()
2598 struct ath_hal *ah = sc->sc_ah; in ath_init()
2624 ath_update_chainmasks(sc, ic->ic_curchan); in ath_init()
2625 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_init()
2626 sc->sc_cur_rxchainmask); in ath_init()
2628 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_FALSE, in ath_init()
2630 device_printf(sc->sc_dev, in ath_init()
2636 sc->sc_rx_stopped = 1; in ath_init()
2637 sc->sc_rx_resetted = 1; in ath_init()
2643 ath_chan_change(sc, ic->ic_curchan); in ath_init()
2646 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_init()
2649 ath_spectral_enable(sc, ic->ic_curchan); in ath_init()
2654 ath_btcoex_enable(sc, ic->ic_curchan); in ath_init()
2660 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_init()
2661 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_init()
2663 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_init()
2669 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_init()
2670 sc->sc_lastlongcal = ticks; in ath_init()
2671 sc->sc_resetcal = 1; in ath_init()
2672 sc->sc_lastcalreset = 0; in ath_init()
2673 sc->sc_lastani = ticks; in ath_init()
2674 sc->sc_lastshortcal = ticks; in ath_init()
2675 sc->sc_doresetcal = AH_FALSE; in ath_init()
2681 sc->sc_beacons = 0; in ath_init()
2691 device_printf(sc->sc_dev, "unable to start recv logic\n"); in ath_init()
2699 sc->sc_imask = HAL_INT_RX | HAL_INT_TX in ath_init()
2707 if (sc->sc_isedma) in ath_init()
2708 sc->sc_imask |= (HAL_INT_RXHP | HAL_INT_RXLP); in ath_init()
2715 if (! sc->sc_isedma) in ath_init()
2716 sc->sc_imask |= HAL_INT_RXEOL; in ath_init()
2721 if (sc->sc_btcoex_mci) in ath_init()
2722 sc->sc_imask |= HAL_INT_MCI; in ath_init()
2728 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) in ath_init()
2729 sc->sc_imask |= HAL_INT_MIB; in ath_init()
2737 if (ic->ic_opmode == IEEE80211_M_STA) in ath_init()
2738 sc->sc_imask |= HAL_INT_TSFOOR; in ath_init()
2742 sc->sc_imask |= HAL_INT_GTT; in ath_init()
2745 __func__, sc->sc_imask); in ath_init()
2747 sc->sc_running = 1; in ath_init()
2748 callout_reset(&sc->sc_wd_ch, hz, ath_watchdog, sc); in ath_init()
2749 ath_hal_intrset(ah, sc->sc_imask); in ath_init()
2759 struct ath_hal *ah = sc->sc_ah; in ath_stop()
2768 if (sc->sc_running) { in ath_stop()
2785 if (sc->sc_tx99 != NULL) in ath_stop()
2786 sc->sc_tx99->stop(sc->sc_tx99); in ath_stop()
2788 callout_stop(&sc->sc_wd_ch); in ath_stop()
2789 sc->sc_wd_timer = 0; in ath_stop()
2790 sc->sc_running = 0; in ath_stop()
2791 if (!sc->sc_invalid) { in ath_stop()
2792 if (sc->sc_softled) { in ath_stop()
2793 callout_stop(&sc->sc_ledtimer); in ath_stop()
2794 ath_hal_gpioset(ah, sc->sc_ledpin, in ath_stop()
2795 !sc->sc_ledon); in ath_stop()
2796 sc->sc_blinking = 0; in ath_stop()
2801 if (!sc->sc_invalid) { in ath_stop()
2805 sc->sc_rxlink = NULL; in ath_stop()
2837 while (sc->sc_rxproc_cnt || sc->sc_txproc_cnt || in ath_txrx_stop_locked()
2838 sc->sc_txstart_cnt || sc->sc_intr_cnt) { in ath_txrx_stop_locked()
2841 msleep(sc, &sc->sc_pcu_mtx, 0, "ath_txrx_stop", in ath_txrx_stop_locked()
2843 i--; in ath_txrx_stop_locked()
2847 device_printf(sc->sc_dev, in ath_txrx_stop_locked()
2870 taskqueue_unblock(sc->sc_tq); in ath_txrx_start()
2884 * be locking-reentrant enough to behave correctly.
2898 if (sc->sc_inreset_cnt == 0) { in ath_reset_grablock()
2912 i--; in ath_reset_grablock()
2921 sc->sc_inreset_cnt++; in ath_reset_grablock()
2924 device_printf(sc->sc_dev, in ath_reset_grablock()
2929 device_printf(sc->sc_dev, in ath_reset_grablock()
2948 struct ieee80211com *ic = &sc->sc_ic; in ath_reset()
2949 struct ath_hal *ah = sc->sc_ah; in ath_reset()
2960 taskqueue_block(sc->sc_tq); in ath_reset()
2978 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_reset()
2994 * Regardless of whether we're doing a no-loss flush or in ath_reset()
3010 ath_update_chainmasks(sc, ic->ic_curchan); in ath_reset()
3011 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_reset()
3012 sc->sc_cur_rxchainmask); in ath_reset()
3013 if (!ath_hal_reset(ah, sc->sc_opmode, ic->ic_curchan, AH_TRUE, in ath_reset()
3015 device_printf(sc->sc_dev, in ath_reset()
3018 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_reset()
3021 sc->sc_rx_stopped = 1; in ath_reset()
3022 sc->sc_rx_resetted = 1; in ath_reset()
3025 /* Quiet time handling - ensure we resync */ in ath_reset()
3029 ath_dfs_radar_enable(sc, ic->ic_curchan); in ath_reset()
3032 ath_spectral_enable(sc, ic->ic_curchan); in ath_reset()
3037 ath_btcoex_enable(sc, ic->ic_curchan); in ath_reset()
3043 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_reset()
3044 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_reset()
3046 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_reset()
3049 device_printf(sc->sc_dev, in ath_reset()
3056 ath_chan_change(sc, ic->ic_curchan); in ath_reset()
3057 if (sc->sc_beacons) { /* restart beacons */ in ath_reset()
3059 if (sc->sc_tdma) in ath_reset()
3067 * Release the reset lock and re-enable interrupts here. in ath_reset()
3071 * reset counter - this way ath_intr() doesn't end up in ath_reset()
3079 sc->sc_inreset_cnt--; in ath_reset()
3080 sc->sc_txstart_cnt++; in ath_reset()
3082 ath_hal_intrset(ah, sc->sc_imask); in ath_reset()
3103 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_reset()
3104 ath_txq_restart_dma(sc, &sc->sc_txq[i]); in ath_reset()
3105 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_reset()
3108 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_reset()
3119 sc->sc_txstart_cnt--; in ath_reset()
3134 struct ieee80211com *ic = vap->iv_ic; in ath_reset_vap()
3135 struct ath_softc *sc = ic->ic_softc; in ath_reset_vap()
3136 struct ath_hal *ah = sc->sc_ah; in ath_reset_vap()
3141 * If per-packet TPC is enabled, then we have nothing in ath_reset_vap()
3146 ath_hal_settxpowlimit(ah, ic->ic_txpowlimit); in ath_reset_vap()
3161 bf = TAILQ_FIRST(&sc->sc_txbuf_mgmt); in _ath_getbuf_locked()
3163 bf = TAILQ_FIRST(&sc->sc_txbuf); in _ath_getbuf_locked()
3166 sc->sc_stats.ast_tx_getnobuf++; in _ath_getbuf_locked()
3168 if (bf->bf_flags & ATH_BUF_BUSY) { in _ath_getbuf_locked()
3169 sc->sc_stats.ast_tx_getbusybuf++; in _ath_getbuf_locked()
3174 if (bf != NULL && (bf->bf_flags & ATH_BUF_BUSY) == 0) { in _ath_getbuf_locked()
3176 TAILQ_REMOVE(&sc->sc_txbuf_mgmt, bf, bf_list); in _ath_getbuf_locked()
3178 TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list); in _ath_getbuf_locked()
3179 sc->sc_txbuf_cnt--; in _ath_getbuf_locked()
3186 if (sc->sc_txbuf_cnt < 0) { in _ath_getbuf_locked()
3187 device_printf(sc->sc_dev, in _ath_getbuf_locked()
3190 sc->sc_txbuf_cnt = 0; in _ath_getbuf_locked()
3199 TAILQ_FIRST(&sc->sc_txbuf) == NULL ? in _ath_getbuf_locked()
3206 bf->bf_flags = 0; in _ath_getbuf_locked()
3208 bf->bf_flags |= ATH_BUF_MGMT; in _ath_getbuf_locked()
3210 bf->bf_flags &= (~ATH_BUF_MGMT); in _ath_getbuf_locked()
3213 bf->bf_next = NULL; /* XXX just to be sure */ in _ath_getbuf_locked()
3214 bf->bf_last = NULL; /* XXX again, just to be sure */ in _ath_getbuf_locked()
3215 bf->bf_comp = NULL; /* XXX again, just to be sure */ in _ath_getbuf_locked()
3216 bzero(&bf->bf_state, sizeof(bf->bf_state)); in _ath_getbuf_locked()
3221 if (sc->sc_isedma) { in _ath_getbuf_locked()
3222 bf->bf_descid = sc->sc_txbuf_descid; in _ath_getbuf_locked()
3223 sc->sc_txbuf_descid++; in _ath_getbuf_locked()
3249 (bf->bf_flags & ATH_BUF_MGMT) ? in ath_buf_clone()
3255 tbf->bf_next = NULL; in ath_buf_clone()
3256 tbf->bf_nseg = bf->bf_nseg; in ath_buf_clone()
3257 tbf->bf_flags = bf->bf_flags & ATH_BUF_FLAGS_CLONE; in ath_buf_clone()
3258 tbf->bf_status = bf->bf_status; in ath_buf_clone()
3259 tbf->bf_m = bf->bf_m; in ath_buf_clone()
3260 tbf->bf_node = bf->bf_node; in ath_buf_clone()
3261 KASSERT((bf->bf_node != NULL), ("%s: bf_node=NULL!", __func__)); in ath_buf_clone()
3263 tbf->bf_lastds = NULL; in ath_buf_clone()
3265 tbf->bf_last = tbf; in ath_buf_clone()
3266 tbf->bf_comp = bf->bf_comp; in ath_buf_clone()
3270 /* The caller has to re-init the descriptor + links */ in ath_buf_clone()
3277 if (bf->bf_m != NULL) { in ath_buf_clone()
3281 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_buf_clone()
3283 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_buf_clone()
3286 bf->bf_m = NULL; in ath_buf_clone()
3287 bf->bf_node = NULL; in ath_buf_clone()
3290 memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state)); in ath_buf_clone()
3311 sc->sc_stats.ast_tx_qstop++; in ath_getbuf()
3325 struct ath_softc *sc = ic->ic_softc; in ath_transmit()
3336 if (sc->sc_inreset_cnt > 0) { in ath_transmit()
3340 sc->sc_stats.ast_tx_qstop++; in ath_transmit()
3344 sc->sc_txstart_cnt++; in ath_transmit()
3354 * Grab the TX lock - it's ok to do this here; we haven't in ath_transmit()
3362 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; in ath_transmit()
3372 * XXX we should also track the per-node hardware queue in ath_transmit()
3377 if ((!(m->m_flags & M_EAPOL)) && in ath_transmit()
3378 (ATH_NODE(ni)->an_swq_depth > sc->sc_txq_node_maxdepth)) { in ath_transmit()
3379 sc->sc_stats.ast_tx_nodeq_overflow++; in ath_transmit()
3387 * If this is for non-EAPOL traffic, just leave some in ath_transmit()
3400 if ((!(m->m_flags & M_EAPOL)) && in ath_transmit()
3401 (sc->sc_txbuf_cnt <= sc->sc_txq_data_minfree)) { in ath_transmit()
3402 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3417 if (m->m_flags & M_EAPOL) in ath_transmit()
3429 sc->sc_stats.ast_tx_nobuf++; in ath_transmit()
3446 if ((m->m_flags & M_FRAG) && in ath_transmit()
3450 sc->sc_stats.ast_tx_nofrag++; in ath_transmit()
3451 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); in ath_transmit()
3481 if (m->m_flags & M_FRAG) { in ath_transmit()
3484 struct mbuf *fm = m->m_nextpkt; in ath_transmit()
3493 fbf->bf_nextfraglen = fm->m_pkthdr.len; in ath_transmit()
3495 fm = fm->m_nextpkt; in ath_transmit()
3518 next = m->m_nextpkt; in ath_transmit()
3521 if_inc_counter(ni->ni_vap->iv_ifp, IFCOUNTER_OERRORS, 1); in ath_transmit()
3523 bf->bf_m = NULL; in ath_transmit()
3524 bf->bf_node = NULL; in ath_transmit()
3552 * XXX check sta power-save state? in ath_transmit()
3554 if (ni->ni_vap->iv_state != IEEE80211_S_RUN) { in ath_transmit()
3558 ieee80211_state_name[ni->ni_vap->iv_state]); in ath_transmit()
3573 sc->sc_wd_timer = 5; in ath_transmit()
3582 sc->sc_txstart_cnt--; in ath_transmit()
3604 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_begin()
3607 taskqueue_block(sc->sc_tq); in ath_key_update_begin()
3613 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_key_update_end()
3616 taskqueue_unblock(sc->sc_tq); in ath_key_update_end()
3622 struct ath_softc *sc = ic->ic_softc; in ath_update_promisc()
3629 ath_hal_setrxfilter(sc->sc_ah, rfilt); in ath_update_promisc()
3656 * Driver-internal mcast update call.
3663 struct ieee80211com *ic = &sc->sc_ic; in ath_update_mcast_hw()
3667 if (ic->ic_allmulti == 0) { in ath_update_mcast_hw()
3674 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in ath_update_mcast_hw()
3675 if_foreach_llmaddr(vap->iv_ifp, ath_hash_maddr, &mfilt); in ath_update_mcast_hw()
3679 ath_hal_setmcastfilter(sc->sc_ah, mfilt[0], mfilt[1]); in ath_update_mcast_hw()
3686 * Called from the net80211 layer - force the hardware
3692 struct ath_softc *sc = ic->ic_softc; in ath_update_mcast()
3708 struct ieee80211com *ic = &sc->sc_ic; in ath_mode_init()
3709 struct ath_hal *ah = sc->sc_ah; in ath_mode_init()
3721 /* handle any link-level address change */ in ath_mode_init()
3722 ath_hal_setmac(ah, ic->ic_macaddr); in ath_mode_init()
3734 struct ieee80211com *ic = &sc->sc_ic; in ath_setslottime()
3735 struct ath_hal *ah = sc->sc_ah; in ath_setslottime()
3738 if (IEEE80211_IS_CHAN_HALF(ic->ic_curchan)) in ath_setslottime()
3740 else if (IEEE80211_IS_CHAN_QUARTER(ic->ic_curchan)) in ath_setslottime()
3742 else if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) { in ath_setslottime()
3745 if (ic->ic_flags & IEEE80211_F_SHSLOT) in ath_setslottime()
3754 __func__, ic->ic_curchan->ic_freq, ic->ic_curchan->ic_flags, in ath_setslottime()
3755 ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long", usec); in ath_setslottime()
3762 sc->sc_updateslot = OK; in ath_setslottime()
3773 struct ath_softc *sc = ic->ic_softc; in ath_updateslot()
3782 if (ic->ic_opmode == IEEE80211_M_HOSTAP || in ath_updateslot()
3783 ic->ic_opmode == IEEE80211_M_MBSS) in ath_updateslot()
3784 sc->sc_updateslot = UPDATE; in ath_updateslot()
3800 TAILQ_CONCAT(&dst->axq_q, &src->axq_q, bf_list); in ath_txqmove()
3801 dst->axq_link = src->axq_link; in ath_txqmove()
3802 src->axq_link = NULL; in ath_txqmove()
3803 dst->axq_depth += src->axq_depth; in ath_txqmove()
3804 dst->axq_aggr_depth += src->axq_aggr_depth; in ath_txqmove()
3805 src->axq_depth = 0; in ath_txqmove()
3806 src->axq_aggr_depth = 0; in ath_txqmove()
3820 device_printf(sc->sc_dev, "%s: resetting\n", __func__); in ath_reset_proc()
3834 if (ath_hal_gethangstate(sc->sc_ah, 0xff, &hangs) && hangs != 0) in ath_bstuck_proc()
3835 device_printf(sc->sc_dev, "bb hang detected (0x%x)\n", hangs); in ath_bstuck_proc()
3838 if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_STUCK_BEACON)) in ath_bstuck_proc()
3839 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_STUCK_BEACON, 0, NULL); in ath_bstuck_proc()
3842 device_printf(sc->sc_dev, "stuck beacon; resetting (bmiss count %u)\n", in ath_bstuck_proc()
3843 sc->sc_bmisscount); in ath_bstuck_proc()
3844 sc->sc_stats.ast_bstuck++; in ath_bstuck_proc()
3857 error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf, in ath_desc_alloc()
3858 "tx", sc->sc_tx_desclen, ath_txbuf, ATH_MAX_SCATTER); in ath_desc_alloc()
3862 sc->sc_txbuf_cnt = ath_txbuf; in ath_desc_alloc()
3864 error = ath_descdma_setup(sc, &sc->sc_txdma_mgmt, &sc->sc_txbuf_mgmt, in ath_desc_alloc()
3865 "tx_mgmt", sc->sc_tx_desclen, ath_txbuf_mgmt, in ath_desc_alloc()
3868 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3877 error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf, in ath_desc_alloc()
3878 "beacon", sc->sc_tx_desclen, ATH_BCBUF, 1); in ath_desc_alloc()
3880 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
3881 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_alloc()
3882 &sc->sc_txbuf_mgmt); in ath_desc_alloc()
3892 if (sc->sc_bdma.dd_desc_len != 0) in ath_desc_free()
3893 ath_descdma_cleanup(sc, &sc->sc_bdma, &sc->sc_bbuf); in ath_desc_free()
3894 if (sc->sc_txdma.dd_desc_len != 0) in ath_desc_free()
3895 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_free()
3896 if (sc->sc_txdma_mgmt.dd_desc_len != 0) in ath_desc_free()
3897 ath_descdma_cleanup(sc, &sc->sc_txdma_mgmt, in ath_desc_free()
3898 &sc->sc_txbuf_mgmt); in ath_desc_free()
3904 struct ieee80211com *ic = vap->iv_ic; in ath_node_alloc()
3905 struct ath_softc *sc = ic->ic_softc; in ath_node_alloc()
3906 const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; in ath_node_alloc()
3916 /* Setup the mutex - there's no associd yet so set the name to NULL */ in ath_node_alloc()
3917 snprintf(an->an_name, sizeof(an->an_name), "%s: node %p", in ath_node_alloc()
3918 device_get_nameunit(sc->sc_dev), an); in ath_node_alloc()
3919 mtx_init(&an->an_mtx, an->an_name, NULL, MTX_DEF); in ath_node_alloc()
3924 an->an_node_stats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; in ath_node_alloc()
3925 an->an_node_stats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_node_alloc()
3926 an->an_node_stats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; in ath_node_alloc()
3929 return &an->an_node; in ath_node_alloc()
3935 struct ieee80211com *ic = ni->ni_ic; in ath_node_cleanup()
3936 struct ath_softc *sc = ic->ic_softc; in ath_node_cleanup()
3939 ni->ni_macaddr, ":", ATH_NODE(ni)); in ath_node_cleanup()
3944 sc->sc_node_cleanup(ni); in ath_node_cleanup()
3950 struct ieee80211com *ic = ni->ni_ic; in ath_node_free()
3951 struct ath_softc *sc = ic->ic_softc; in ath_node_free()
3954 ni->ni_macaddr, ":", ATH_NODE(ni)); in ath_node_free()
3955 mtx_destroy(&ATH_NODE(ni)->an_mtx); in ath_node_free()
3956 sc->sc_node_free(ni); in ath_node_free()
3962 struct ieee80211com *ic = ni->ni_ic; in ath_node_getsignal()
3963 struct ath_softc *sc = ic->ic_softc; in ath_node_getsignal()
3964 struct ath_hal *ah = sc->sc_ah; in ath_node_getsignal()
3966 *rssi = ic->ic_node_getrssi(ni); in ath_node_getsignal()
3967 if (ni->ni_chan != IEEE80211_CHAN_ANYC) in ath_node_getsignal()
3968 *noise = ath_hal_getchannoise(ah, ni->ni_chan); in ath_node_getsignal()
3970 *noise = -95; /* nominally correct */ in ath_node_getsignal()
3979 struct ath_hal *ah = sc->sc_ah; in ath_setdefantenna()
3983 if (sc->sc_defant != antenna) in ath_setdefantenna()
3984 sc->sc_stats.ast_ant_defswitch++; in ath_setdefantenna()
3985 sc->sc_defant = antenna; in ath_setdefantenna()
3986 sc->sc_rxotherant = 0; in ath_setdefantenna()
3992 txq->axq_qnum = qnum; in ath_txq_init()
3993 txq->axq_ac = 0; in ath_txq_init()
3994 txq->axq_depth = 0; in ath_txq_init()
3995 txq->axq_aggr_depth = 0; in ath_txq_init()
3996 txq->axq_intrcnt = 0; in ath_txq_init()
3997 txq->axq_link = NULL; in ath_txq_init()
3998 txq->axq_softc = sc; in ath_txq_init()
3999 TAILQ_INIT(&txq->axq_q); in ath_txq_init()
4000 TAILQ_INIT(&txq->axq_tidq); in ath_txq_init()
4001 TAILQ_INIT(&txq->fifo.axq_q); in ath_txq_init()
4011 struct ath_hal *ah = sc->sc_ah; in ath_txq_setup()
4032 if (sc->sc_isedma) in ath_txq_setup()
4040 if (qnum == -1) { in ath_txq_setup()
4047 if (qnum >= nitems(sc->sc_txq)) { in ath_txq_setup()
4048 device_printf(sc->sc_dev, in ath_txq_setup()
4050 qnum, nitems(sc->sc_txq)); in ath_txq_setup()
4055 ath_txq_init(sc, &sc->sc_txq[qnum], qnum); in ath_txq_setup()
4056 sc->sc_txqsetup |= 1<<qnum; in ath_txq_setup()
4058 return &sc->sc_txq[qnum]; in ath_txq_setup()
4075 if (ac >= nitems(sc->sc_ac2q)) { in ath_tx_setup()
4076 device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", in ath_tx_setup()
4077 ac, nitems(sc->sc_ac2q)); in ath_tx_setup()
4082 txq->axq_ac = ac; in ath_tx_setup()
4083 sc->sc_ac2q[ac] = txq; in ath_tx_setup()
4095 #define ATH_EXPONENT_TO_VALUE(v) ((1<<v)-1) in ath_txq_update()
4096 struct ieee80211com *ic = &sc->sc_ic; in ath_txq_update()
4097 struct ath_txq *txq = sc->sc_ac2q[ac]; in ath_txq_update()
4100 struct ath_hal *ah = sc->sc_ah; in ath_txq_update()
4106 ath_hal_gettxqueueprops(ah, txq->axq_qnum, &qi); in ath_txq_update()
4108 if (sc->sc_tdma) { in ath_txq_update()
4110 * AIFS is zero so there's no pre-transmit wait. The in ath_txq_update()
4112 * through net80211. The QCU is setup to not do post-xmit in ath_txq_update()
4113 * back off, lockout all lower-priority QCU's, and fire in ath_txq_update()
4127 qi.tqi_readyTime = sc->sc_tdmaslotlen; in ath_txq_update()
4141 qi.tqi_aifs = wmep->wmep_aifsn; in ath_txq_update()
4142 qi.tqi_cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin); in ath_txq_update()
4143 qi.tqi_cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax); in ath_txq_update()
4145 qi.tqi_burstTime = IEEE80211_TXOP_TO_US(wmep->wmep_txopLimit); in ath_txq_update()
4152 __func__, txq->axq_qnum, qi.tqi_qflags, in ath_txq_update()
4155 if (!ath_hal_settxqueueprops(ah, txq->axq_qnum, &qi)) { in ath_txq_update()
4156 device_printf(sc->sc_dev, "unable to update hardware queue " in ath_txq_update()
4160 ath_hal_resettxqueue(ah, txq->axq_qnum); /* push to h/w */ in ath_txq_update()
4172 struct ath_softc *sc = ic->ic_softc; in ath_wme_update()
4187 ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum); in ath_tx_cleanupq()
4188 sc->sc_txqsetup &= ~(1<<txq->axq_qnum); in ath_tx_cleanupq()
4203 ath_tx_cleanupq(sc, &sc->sc_txq[i]); in ath_tx_cleanup()
4213 int rix = sc->sc_rixmap[rate]; in ath_tx_findrix()
4222 struct ieee80211_node *ni = bf->bf_node; in ath_tx_update_stats()
4223 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_update_stats()
4226 if (ts->ts_status == 0) { in ath_tx_update_stats()
4227 u_int8_t txant = ts->ts_antenna; in ath_tx_update_stats()
4233 sc->sc_stats.ast_ant_tx[txant]++; in ath_tx_update_stats()
4234 sc->sc_ant_tx[txant]++; in ath_tx_update_stats()
4235 if (ts->ts_finaltsi != 0) in ath_tx_update_stats()
4236 sc->sc_stats.ast_tx_altrate++; in ath_tx_update_stats()
4238 /* XXX TODO: should do per-pri conuters */ in ath_tx_update_stats()
4239 pri = M_WME_GETAC(bf->bf_m); in ath_tx_update_stats()
4241 ic->ic_wme.wme_hipri_traffic++; in ath_tx_update_stats()
4243 if ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0) in ath_tx_update_stats()
4244 ni->ni_inact = ni->ni_inact_reload; in ath_tx_update_stats()
4246 if (ts->ts_status & HAL_TXERR_XRETRY) in ath_tx_update_stats()
4247 sc->sc_stats.ast_tx_xretries++; in ath_tx_update_stats()
4248 if (ts->ts_status & HAL_TXERR_FIFO) in ath_tx_update_stats()
4249 sc->sc_stats.ast_tx_fifoerr++; in ath_tx_update_stats()
4250 if (ts->ts_status & HAL_TXERR_FILT) in ath_tx_update_stats()
4251 sc->sc_stats.ast_tx_filtered++; in ath_tx_update_stats()
4252 if (ts->ts_status & HAL_TXERR_XTXOP) in ath_tx_update_stats()
4253 sc->sc_stats.ast_tx_xtxop++; in ath_tx_update_stats()
4254 if (ts->ts_status & HAL_TXERR_TIMER_EXPIRED) in ath_tx_update_stats()
4255 sc->sc_stats.ast_tx_timerexpired++; in ath_tx_update_stats()
4257 if (bf->bf_m->m_flags & M_FF) in ath_tx_update_stats()
4258 sc->sc_stats.ast_ff_txerr++; in ath_tx_update_stats()
4261 if (ts->ts_flags & HAL_TX_DESC_CFG_ERR) in ath_tx_update_stats()
4262 sc->sc_stats.ast_tx_desccfgerr++; in ath_tx_update_stats()
4271 if (ts->ts_flags & HAL_TX_DATA_UNDERRUN) in ath_tx_update_stats()
4272 sc->sc_stats.ast_tx_data_underrun++; in ath_tx_update_stats()
4273 if (ts->ts_flags & HAL_TX_DELIM_UNDERRUN) in ath_tx_update_stats()
4274 sc->sc_stats.ast_tx_delim_underrun++; in ath_tx_update_stats()
4276 sr = ts->ts_shortretry; in ath_tx_update_stats()
4277 lr = ts->ts_longretry; in ath_tx_update_stats()
4278 sc->sc_stats.ast_tx_shortretry += sr; in ath_tx_update_stats()
4279 sc->sc_stats.ast_tx_longretry += lr; in ath_tx_update_stats()
4285 * "please don't retry the frame, and just return -1 status
4291 struct ath_tx_status *ts = &bf->bf_status.ds_txstat; in ath_tx_default_comp()
4295 st = -1; in ath_tx_default_comp()
4297 st = ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0) ? in ath_tx_default_comp()
4298 ts->ts_status : HAL_TXERR_XRETRY; in ath_tx_default_comp()
4301 if (bf->bf_state.bfs_dobaw) in ath_tx_default_comp()
4302 device_printf(sc->sc_dev, in ath_tx_default_comp()
4306 SEQNO(bf->bf_state.bfs_seqno)); in ath_tx_default_comp()
4308 if (bf->bf_next != NULL) in ath_tx_default_comp()
4309 device_printf(sc->sc_dev, in ath_tx_default_comp()
4313 SEQNO(bf->bf_state.bfs_seqno)); in ath_tx_default_comp()
4330 if (bf->bf_node) { in ath_tx_default_comp()
4332 ath_tx_update_tim(sc, bf->bf_node, 0); in ath_tx_default_comp()
4368 if ((ts->ts_status & HAL_TXERR_FILT) == 0) { in ath_tx_update_ratectrl()
4387 struct ieee80211_node *ni = bf->bf_node; in ath_tx_process_buf_completion()
4406 if (bf->bf_comp == NULL) { in ath_tx_process_buf_completion()
4407 if ((ts->ts_status & HAL_TXERR_FILT) == 0 && in ath_tx_process_buf_completion()
4408 (bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0) { in ath_tx_process_buf_completion()
4417 bf->bf_state.bfs_rc, ts, in ath_tx_process_buf_completion()
4418 bf->bf_state.bfs_pktlen, in ath_tx_process_buf_completion()
4419 bf->bf_state.bfs_pktlen, in ath_tx_process_buf_completion()
4421 (ts->ts_status == 0 ? 0 : 1)); in ath_tx_process_buf_completion()
4425 bf->bf_comp(sc, bf, 0); in ath_tx_process_buf_completion()
4436 struct ath_hal *ah = sc->sc_ah; in ath_tx_processq()
4442 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_processq()
4448 __func__, txq->axq_qnum, in ath_tx_processq()
4449 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4450 txq->axq_link); in ath_tx_processq()
4454 txq->axq_qnum, in ath_tx_processq()
4455 (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4456 txq->axq_link, in ath_tx_processq()
4457 txq->axq_depth); in ath_tx_processq()
4462 txq->axq_intrcnt = 0; /* reset periodic desc intr count */ in ath_tx_processq()
4463 bf = TAILQ_FIRST(&txq->axq_q); in ath_tx_processq()
4468 ds = bf->bf_lastds; /* XXX must be setup correctly! */ in ath_tx_processq()
4469 ts = &bf->bf_status.ds_txstat; in ath_tx_processq()
4473 if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) in ath_tx_processq()
4474 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4476 else if ((sc->sc_debug & ATH_DEBUG_RESET) && (dosched == 0)) in ath_tx_processq()
4477 ath_printtxbuf(sc, bf, txq->axq_qnum, 0, in ath_tx_processq()
4481 if (if_ath_alq_checkdebug(&sc->sc_alq, in ath_tx_processq()
4483 if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_TXSTATUS, in ath_tx_processq()
4484 sc->sc_tx_statuslen, in ath_tx_processq()
4492 txq->axq_qnum, bf, ds); in ath_tx_processq()
4501 if (txq->axq_qnum != bf->bf_state.bfs_tx_queue) { in ath_tx_processq()
4502 device_printf(sc->sc_dev, in ath_tx_processq()
4505 txq->axq_qnum, in ath_tx_processq()
4507 bf->bf_state.bfs_tx_queue); in ath_tx_processq()
4509 if (txq->axq_qnum != bf->bf_last->bf_state.bfs_tx_queue) { in ath_tx_processq()
4510 device_printf(sc->sc_dev, in ath_tx_processq()
4513 txq->axq_qnum, in ath_tx_processq()
4514 bf->bf_last, in ath_tx_processq()
4515 bf->bf_last->bf_state.bfs_tx_queue); in ath_tx_processq()
4519 if (txq->axq_depth > 0) { in ath_tx_processq()
4522 * so it's not re-used while the hardware may in ath_tx_processq()
4523 * still re-read the link field in the descriptor. in ath_tx_processq()
4526 * is where the hardware may be - intermediate in ath_tx_processq()
4529 bf->bf_last->bf_flags |= ATH_BUF_BUSY; in ath_tx_processq()
4531 txq->axq_link = NULL; in ath_tx_processq()
4533 bf->bf_last->bf_flags |= ATH_BUF_BUSY; in ath_tx_processq()
4535 if (bf->bf_state.bfs_aggr) in ath_tx_processq()
4536 txq->axq_aggr_depth--; in ath_tx_processq()
4538 ni = bf->bf_node; in ath_tx_processq()
4542 txq->axq_qnum, bf, ds, ni, ts->ts_status); in ath_tx_processq()
4548 if (ni != NULL && ts->ts_status == 0 && in ath_tx_processq()
4549 ((bf->bf_state.bfs_txflags & HAL_TXDESC_NOACK) == 0)) { in ath_tx_processq()
4551 sc->sc_stats.ast_tx_rssi = ts->ts_rssi; in ath_tx_processq()
4552 ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, in ath_tx_processq()
4553 ts->ts_rssi); in ath_tx_processq()
4554 ATH_RSSI_LPF(ATH_NODE(ni)->an_node_stats.ns_avgtxrssi, in ath_tx_processq()
4555 ts->ts_rssi); in ath_tx_processq()
4568 * Flush fast-frame staging queue when traffic slows. in ath_tx_processq()
4570 if (txq->axq_depth <= 1) in ath_tx_processq()
4571 ieee80211_ff_flush(ic, txq->axq_ac); in ath_tx_processq()
4583 txq->axq_qnum); in ath_tx_processq()
4591 * Deferred processing of transmit interrupt; special-cased
4601 sc->sc_txproc_cnt++; in ath_tx_proc_q0()
4602 txqs = sc->sc_txq_active; in ath_tx_proc_q0()
4603 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0()
4613 if (TXQACTIVE(txqs, 0) && ath_tx_processq(sc, &sc->sc_txq[0], 1)) in ath_tx_proc_q0()
4615 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0()
4616 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0()
4617 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0()
4618 sc->sc_wd_timer = 0; in ath_tx_proc_q0()
4620 if (sc->sc_softled) in ath_tx_proc_q0()
4621 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0()
4624 sc->sc_txproc_cnt--; in ath_tx_proc_q0()
4635 * Deferred processing of transmit interrupt; special-cased
4636 * for four hardware queues, 0-3 (e.g. 5212 w/ WME support).
4646 sc->sc_txproc_cnt++; in ath_tx_proc_q0123()
4647 txqs = sc->sc_txq_active; in ath_tx_proc_q0123()
4648 sc->sc_txq_active &= ~txqs; in ath_tx_proc_q0123()
4663 nacked += ath_tx_processq(sc, &sc->sc_txq[0], 1); in ath_tx_proc_q0123()
4665 nacked += ath_tx_processq(sc, &sc->sc_txq[1], 1); in ath_tx_proc_q0123()
4667 nacked += ath_tx_processq(sc, &sc->sc_txq[2], 1); in ath_tx_proc_q0123()
4669 nacked += ath_tx_processq(sc, &sc->sc_txq[3], 1); in ath_tx_proc_q0123()
4670 if (TXQACTIVE(txqs, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0123()
4671 ath_tx_processq(sc, sc->sc_cabq, 1); in ath_tx_proc_q0123()
4673 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0123()
4675 sc->sc_wd_timer = 0; in ath_tx_proc_q0123()
4677 if (sc->sc_softled) in ath_tx_proc_q0123()
4678 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc_q0123()
4681 sc->sc_txproc_cnt--; in ath_tx_proc_q0123()
4702 sc->sc_txproc_cnt++; in ath_tx_proc()
4703 txqs = sc->sc_txq_active; in ath_tx_proc()
4704 sc->sc_txq_active &= ~txqs; in ath_tx_proc()
4719 nacked += ath_tx_processq(sc, &sc->sc_txq[i], 1); in ath_tx_proc()
4721 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc()
4723 sc->sc_wd_timer = 0; in ath_tx_proc()
4725 if (sc->sc_softled) in ath_tx_proc()
4726 ath_led_event(sc, sc->sc_txrix); in ath_tx_proc()
4729 sc->sc_txproc_cnt--; in ath_tx_proc()
4752 if (sc->sc_inreset_cnt > 0) { in ath_txq_sched_tasklet()
4753 device_printf(sc->sc_dev, in ath_txq_sched_tasklet()
4759 sc->sc_txproc_cnt++; in ath_txq_sched_tasklet()
4769 ath_txq_sched(sc, &sc->sc_txq[i]); in ath_txq_sched_tasklet()
4779 sc->sc_txproc_cnt--; in ath_txq_sched_tasklet()
4789 if (bf->bf_flags & ATH_BUF_MGMT) in ath_returnbuf_tail()
4790 TAILQ_INSERT_TAIL(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_tail()
4792 TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_tail()
4793 sc->sc_txbuf_cnt++; in ath_returnbuf_tail()
4794 if (sc->sc_txbuf_cnt > ath_txbuf) { in ath_returnbuf_tail()
4795 device_printf(sc->sc_dev, in ath_returnbuf_tail()
4799 sc->sc_txbuf_cnt = ath_txbuf; in ath_returnbuf_tail()
4810 if (bf->bf_flags & ATH_BUF_MGMT) in ath_returnbuf_head()
4811 TAILQ_INSERT_HEAD(&sc->sc_txbuf_mgmt, bf, bf_list); in ath_returnbuf_head()
4813 TAILQ_INSERT_HEAD(&sc->sc_txbuf, bf, bf_list); in ath_returnbuf_head()
4814 sc->sc_txbuf_cnt++; in ath_returnbuf_head()
4815 if (sc->sc_txbuf_cnt > ATH_TXBUF) { in ath_returnbuf_head()
4816 device_printf(sc->sc_dev, in ath_returnbuf_head()
4820 sc->sc_txbuf_cnt = ATH_TXBUF; in ath_returnbuf_head()
4834 if (txq->axq_holdingbf == NULL) in ath_txq_freeholdingbuf()
4837 txq->axq_holdingbf->bf_flags &= ~ATH_BUF_BUSY; in ath_txq_freeholdingbuf()
4840 ath_returnbuf_tail(sc, txq->axq_holdingbf); in ath_txq_freeholdingbuf()
4843 txq->axq_holdingbf = NULL; in ath_txq_freeholdingbuf()
4855 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_txq_addholdingbuf()
4863 if (bf->bf_state.bfs_tx_queue > HAL_NUM_TX_QUEUES) { in ath_txq_addholdingbuf()
4864 device_printf(sc->sc_dev, "%s: bf=%p: invalid tx queue (%d)\n", in ath_txq_addholdingbuf()
4867 bf->bf_state.bfs_tx_queue); in ath_txq_addholdingbuf()
4868 bf->bf_flags &= ~ATH_BUF_BUSY; in ath_txq_addholdingbuf()
4873 txq->axq_holdingbf = bf; in ath_txq_addholdingbuf()
4898 txq = &sc->sc_txq[bf->bf_state.bfs_tx_queue]; in ath_freebuf()
4900 KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__)); in ath_freebuf()
4901 KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__)); in ath_freebuf()
4906 if (bf->bf_flags & ATH_BUF_BUSY) { in ath_freebuf()
4930 struct ieee80211_node *ni = bf->bf_node; in ath_tx_freebuf()
4931 struct mbuf *m0 = bf->bf_m; in ath_tx_freebuf()
4938 if (bf->bf_m != NULL) { in ath_tx_freebuf()
4939 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_tx_freebuf()
4941 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_tx_freebuf()
4944 bf->bf_node = NULL; in ath_tx_freebuf()
4945 bf->bf_m = NULL; in ath_tx_freebuf()
4950 /* Pass the buffer back to net80211 - completing it */ in ath_tx_freebuf()
4965 bf = TAILQ_FIRST(&txq->fifo.axq_q); in ath_tx_draintxq_get_one()
4971 if (bf->bf_flags & ATH_BUF_FIFOEND) { in ath_tx_draintxq_get_one()
4972 if (txq->axq_fifo_depth == 0) { in ath_tx_draintxq_get_one()
4973 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
4976 txq->axq_qnum, in ath_tx_draintxq_get_one()
4977 txq->fifo.axq_depth); in ath_tx_draintxq_get_one()
4979 txq->axq_fifo_depth--; in ath_tx_draintxq_get_one()
4981 ATH_TXQ_REMOVE(&txq->fifo, bf, bf_list); in ath_tx_draintxq_get_one()
4988 if (txq->axq_fifo_depth != 0 || txq->fifo.axq_depth != 0) { in ath_tx_draintxq_get_one()
4989 device_printf(sc->sc_dev, in ath_tx_draintxq_get_one()
4992 txq->axq_qnum, in ath_tx_draintxq_get_one()
4993 txq->axq_fifo_depth, in ath_tx_draintxq_get_one()
4994 txq->fifo.axq_depth); in ath_tx_draintxq_get_one()
5000 bf = TAILQ_FIRST(&txq->axq_q); in ath_tx_draintxq_get_one()
5002 txq->axq_link = NULL; in ath_tx_draintxq_get_one()
5013 struct ath_hal *ah = sc->sc_ah; in ath_tx_draintxq()
5029 if (bf->bf_state.bfs_aggr) in ath_tx_draintxq()
5030 txq->axq_aggr_depth--; in ath_tx_draintxq()
5032 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_tx_draintxq()
5033 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_draintxq()
5042 if (! sc->sc_isedma) { in ath_tx_draintxq()
5044 bf->bf_lastds, in ath_tx_draintxq()
5045 &bf->bf_status.ds_txstat) == HAL_OK); in ath_tx_draintxq()
5047 ath_printtxbuf(sc, bf, txq->axq_qnum, ix, status); in ath_tx_draintxq()
5048 ieee80211_dump_pkt(ic, mtod(bf->bf_m, const uint8_t *), in ath_tx_draintxq()
5049 bf->bf_m->m_len, 0, -1); in ath_tx_draintxq()
5054 * functions, we -must- call it for aggregation in ath_tx_draintxq()
5062 bf->bf_flags &= ~ATH_BUF_BUSY; in ath_tx_draintxq()
5063 if (bf->bf_comp) in ath_tx_draintxq()
5064 bf->bf_comp(sc, bf, 1); in ath_tx_draintxq()
5086 struct ath_hal *ah = sc->sc_ah; in ath_tx_stopdma()
5094 txq->axq_qnum, in ath_tx_stopdma()
5095 (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, txq->axq_qnum), in ath_tx_stopdma()
5096 (int) (!! ath_hal_txqenabled(ah, txq->axq_qnum)), in ath_tx_stopdma()
5097 (int) ath_hal_numtxpending(ah, txq->axq_qnum), in ath_tx_stopdma()
5098 txq->axq_flags, in ath_tx_stopdma()
5099 txq->axq_link, in ath_tx_stopdma()
5100 txq->axq_holdingbf); in ath_tx_stopdma()
5102 (void) ath_hal_stoptxdma(ah, txq->axq_qnum); in ath_tx_stopdma()
5104 txq->axq_flags &= ~ATH_TXQ_PUTRUNNING; in ath_tx_stopdma()
5107 if ((sc->sc_debug & ATH_DEBUG_RESET) in ath_tx_stopdma()
5108 && (txq->axq_holdingbf != NULL)) { in ath_tx_stopdma()
5109 ath_printtxbuf(sc, txq->axq_holdingbf, txq->axq_qnum, 0, 0); in ath_tx_stopdma()
5117 struct ath_hal *ah = sc->sc_ah; in ath_stoptxdma()
5121 if (sc->sc_invalid) in ath_stoptxdma()
5124 if (!sc->sc_invalid) { in ath_stoptxdma()
5127 __func__, sc->sc_bhalq, in ath_stoptxdma()
5128 (caddr_t)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq), in ath_stoptxdma()
5132 (void) ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_stoptxdma()
5137 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_stoptxdma()
5138 ath_tx_stopdma(sc, &sc->sc_txq[i]); in ath_stoptxdma()
5139 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_stoptxdma()
5151 struct ath_hal *ah = sc->sc_ah; in ath_tx_dump()
5155 if (! (sc->sc_debug & ATH_DEBUG_RESET)) in ath_tx_dump()
5158 device_printf(sc->sc_dev, "%s: Q%d: begin\n", in ath_tx_dump()
5159 __func__, txq->axq_qnum); in ath_tx_dump()
5160 TAILQ_FOREACH(bf, &txq->axq_q, bf_list) { in ath_tx_dump()
5161 ath_printtxbuf(sc, bf, txq->axq_qnum, i, in ath_tx_dump()
5162 ath_hal_txprocdesc(ah, bf->bf_lastds, in ath_tx_dump()
5163 &bf->bf_status.ds_txstat) == HAL_OK); in ath_tx_dump()
5166 device_printf(sc->sc_dev, "%s: Q%d: end\n", in ath_tx_dump()
5167 __func__, txq->axq_qnum); in ath_tx_dump()
5177 struct ath_hal *ah = sc->sc_ah; in ath_legacy_tx_drain()
5193 if (sc->sc_debug & ATH_DEBUG_RESET) in ath_legacy_tx_drain()
5194 ath_tx_dump(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5197 ath_tx_processq(sc, &sc->sc_txq[i], 0); in ath_legacy_tx_drain()
5198 ATH_TXQ_LOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
5203 ath_txq_freeholdingbuf(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5210 bf_last = ATH_TXQ_LAST(&sc->sc_txq[i], in ath_legacy_tx_drain()
5214 bf_last->bf_lastds, in ath_legacy_tx_drain()
5215 &sc->sc_txq[i].axq_link); in ath_legacy_tx_drain()
5217 sc->sc_txq[i].axq_link = NULL; in ath_legacy_tx_drain()
5219 ATH_TXQ_UNLOCK(&sc->sc_txq[i]); in ath_legacy_tx_drain()
5221 ath_tx_draintxq(sc, &sc->sc_txq[i]); in ath_legacy_tx_drain()
5225 if (sc->sc_debug & ATH_DEBUG_RESET) { in ath_legacy_tx_drain()
5226 struct ath_buf *bf = TAILQ_FIRST(&sc->sc_bbuf); in ath_legacy_tx_drain()
5227 if (bf != NULL && bf->bf_m != NULL) { in ath_legacy_tx_drain()
5228 ath_printtxbuf(sc, bf, sc->sc_bhalq, 0, in ath_legacy_tx_drain()
5229 ath_hal_txprocdesc(ah, bf->bf_lastds, in ath_legacy_tx_drain()
5230 &bf->bf_status.ds_txstat) == HAL_OK); in ath_legacy_tx_drain()
5231 ieee80211_dump_pkt(&sc->sc_ic, in ath_legacy_tx_drain()
5232 mtod(bf->bf_m, const uint8_t *), bf->bf_m->m_len, in ath_legacy_tx_drain()
5233 0, -1); in ath_legacy_tx_drain()
5237 sc->sc_wd_timer = 0; in ath_legacy_tx_drain()
5253 if (mode != sc->sc_curmode) in ath_chan_change()
5255 sc->sc_curchan = chan; in ath_chan_change()
5267 struct ieee80211com *ic = &sc->sc_ic; in ath_chan_set()
5268 struct ath_hal *ah = sc->sc_ah; in ath_chan_set()
5276 taskqueue_block(sc->sc_tq); in ath_chan_set()
5285 device_printf(sc->sc_dev, "%s: concurrent reset! Danger!\n", in ath_chan_set()
5296 chan->ic_freq, chan->ic_flags); in ath_chan_set()
5297 if (chan != sc->sc_curchan) { in ath_chan_set()
5302 * hardware at the new frequency, and then re-enable in ath_chan_set()
5315 * Next, flush the non-scheduled frames. in ath_chan_set()
5320 ath_hal_setchainmasks(sc->sc_ah, sc->sc_cur_txchainmask, in ath_chan_set()
5321 sc->sc_cur_rxchainmask); in ath_chan_set()
5322 if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, in ath_chan_set()
5324 device_printf(sc->sc_dev, "%s: unable to reset " in ath_chan_set()
5327 chan->ic_freq, chan->ic_flags, status); in ath_chan_set()
5331 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_chan_set()
5334 sc->sc_rx_stopped = 1; in ath_chan_set()
5335 sc->sc_rx_resetted = 1; in ath_chan_set()
5338 /* Quiet time handling - ensure we resync */ in ath_chan_set()
5351 ath_btcoex_enable(sc, ic->ic_curchan); in ath_chan_set()
5357 if (sc->sc_hasenforcetxop && sc->sc_tdma) in ath_chan_set()
5358 ath_hal_setenforcetxop(sc->sc_ah, 1); in ath_chan_set()
5360 ath_hal_setenforcetxop(sc->sc_ah, 0); in ath_chan_set()
5363 * Re-enable rx framework. in ath_chan_set()
5366 device_printf(sc->sc_dev, in ath_chan_set()
5382 if (sc->sc_beacons) { /* restart beacons */ in ath_chan_set()
5384 if (sc->sc_tdma) in ath_chan_set()
5392 * Re-enable interrupts. in ath_chan_set()
5395 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5401 sc->sc_inreset_cnt--; in ath_chan_set()
5403 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
5420 struct ath_hal *ah = sc->sc_ah; in ath_calibrate()
5421 struct ieee80211com *ic = &sc->sc_ic; in ath_calibrate()
5434 if (sc->sc_inreset_cnt) in ath_calibrate()
5437 if (ic->ic_flags & IEEE80211_F_SCAN) /* defer, off channel */ in ath_calibrate()
5439 longCal = (ticks - sc->sc_lastlongcal >= ath_longcalinterval*hz); in ath_calibrate()
5440 aniCal = (ticks - sc->sc_lastani >= ath_anicalinterval*hz/1000); in ath_calibrate()
5441 if (sc->sc_doresetcal) in ath_calibrate()
5442 shortCal = (ticks - sc->sc_lastshortcal >= ath_shortcalinterval*hz/1000); in ath_calibrate()
5446 sc->sc_stats.ast_ani_cal++; in ath_calibrate()
5447 sc->sc_lastani = ticks; in ath_calibrate()
5448 ath_hal_ani_poll(ah, sc->sc_curchan); in ath_calibrate()
5452 sc->sc_stats.ast_per_cal++; in ath_calibrate()
5453 sc->sc_lastlongcal = ticks; in ath_calibrate()
5461 sc->sc_stats.ast_per_rfgain++; in ath_calibrate()
5462 sc->sc_resetcal = 0; in ath_calibrate()
5463 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5464 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_calibrate()
5465 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_calibrate()
5473 if (sc->sc_resetcal) { in ath_calibrate()
5474 (void) ath_hal_calreset(ah, sc->sc_curchan); in ath_calibrate()
5475 sc->sc_lastcalreset = ticks; in ath_calibrate()
5476 sc->sc_lastshortcal = ticks; in ath_calibrate()
5477 sc->sc_resetcal = 0; in ath_calibrate()
5478 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5485 if (ath_hal_calibrateN(ah, sc->sc_curchan, longCal, &isCalDone)) { in ath_calibrate()
5495 __func__, sc->sc_curchan->ic_freq); in ath_calibrate()
5496 sc->sc_stats.ast_per_calfail++; in ath_calibrate()
5501 * un-freeze the PHY. in ath_calibrate()
5505 * failed the first NF cal - that /can/ fail sometimes in in ath_calibrate()
5513 sc->sc_lastshortcal = ticks; in ath_calibrate()
5525 sc->sc_lastshortcal = ticks; in ath_calibrate()
5527 if (sc->sc_opmode != HAL_M_HOSTAP) in ath_calibrate()
5529 sc->sc_doresetcal = AH_TRUE; in ath_calibrate()
5533 if (sc->sc_lastcalreset == 0) in ath_calibrate()
5534 sc->sc_lastcalreset = sc->sc_lastlongcal; in ath_calibrate()
5535 else if (ticks - sc->sc_lastcalreset >= ath_resetcalinterval*hz) in ath_calibrate()
5536 sc->sc_resetcal = 1; /* setup reset next trip */ in ath_calibrate()
5537 sc->sc_doresetcal = AH_FALSE; in ath_calibrate()
5546 callout_reset(&sc->sc_cal_ch, nextcal, ath_calibrate, sc); in ath_calibrate()
5561 struct ath_softc *sc = ic->ic_softc; in ath_scan_start()
5562 struct ath_hal *ah = sc->sc_ah; in ath_scan_start()
5569 sc->sc_scanning = 1; in ath_scan_start()
5570 sc->sc_syncbeacon = 0; in ath_scan_start()
5586 struct ath_softc *sc = ic->ic_softc; in ath_scan_end()
5587 struct ath_hal *ah = sc->sc_ah; in ath_scan_end()
5591 sc->sc_scanning = 0; in ath_scan_end()
5597 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_scan_end()
5603 __func__, rfilt, ether_sprintf(sc->sc_curbssid), in ath_scan_end()
5604 sc->sc_curaid); in ath_scan_end()
5626 struct ath_softc *sc = ic->ic_softc; in ath_update_chw()
5629 device_printf(sc->sc_dev, "%s: called\n", __func__); in ath_update_chw()
5634 * as if we TX filtered them (whch may mean dropping non-ampdu frames!) in ath_update_chw()
5650 * The quiet IE doesn't control the /now/ beacon interval - it
5659 * each TBTT - so if we just program it in upon each beacon received,
5676 struct ieee80211vap *vap = ni->ni_vap; in ath_set_quiet_ie()
5678 struct ieee80211com *ic = vap->iv_ic; in ath_set_quiet_ie()
5679 struct ath_softc *sc = ic->ic_softc; in ath_set_quiet_ie()
5681 if (vap->iv_opmode != IEEE80211_M_STA) in ath_set_quiet_ie()
5689 ath_hal_set_quiet(sc->sc_ah, 0, 0, 0, HAL_QUIET_DISABLE); in ath_set_quiet_ie()
5690 memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); in ath_set_quiet_ie()
5707 if ((q->period == avp->quiet_ie.period) && in ath_set_quiet_ie()
5708 (le16dec(&q->duration) == le16dec(&avp->quiet_ie.duration)) && in ath_set_quiet_ie()
5709 (le16dec(&q->offset) == le16dec(&avp->quiet_ie.offset))) in ath_set_quiet_ie()
5715 (int) q->tbttcount, in ath_set_quiet_ie()
5716 (int) q->period, in ath_set_quiet_ie()
5717 (int) le16dec(&q->duration), in ath_set_quiet_ie()
5718 (int) le16dec(&q->offset)); in ath_set_quiet_ie()
5723 if ((le16dec(&q->duration) == 0) || in ath_set_quiet_ie()
5724 (le16dec(&q->duration) >= ni->ni_intval)) { in ath_set_quiet_ie()
5727 le16dec(&q->duration)); in ath_set_quiet_ie()
5731 * Can have a 0 offset, but not a duration - so just check in ath_set_quiet_ie()
5734 if (le16dec(&q->duration) + le16dec(&q->offset) >= ni->ni_intval) { in ath_set_quiet_ie()
5737 le16dec(&q->duration), in ath_set_quiet_ie()
5738 le16dec(&q->offset)); in ath_set_quiet_ie()
5741 if (q->tbttcount == 0) { in ath_set_quiet_ie()
5746 if (q->period == 0) { in ath_set_quiet_ie()
5756 if (q->tbttcount == 1) { in ath_set_quiet_ie()
5759 ath_hal_set_quiet(sc->sc_ah, in ath_set_quiet_ie()
5760 q->period * ni->ni_intval, /* convert to TU */ in ath_set_quiet_ie()
5761 le16dec(&q->duration), /* already in TU */ in ath_set_quiet_ie()
5762 le16dec(&q->offset) + ni->ni_intval, in ath_set_quiet_ie()
5770 memcpy(&avp->quiet_ie, ie, sizeof(struct ieee80211_quiet_ie)); in ath_set_quiet_ie()
5779 struct ath_softc *sc = ic->ic_softc; in ath_set_channel()
5785 (void) ath_chan_set(sc, ic->ic_curchan); in ath_set_channel()
5793 if (!sc->sc_scanning && ic->ic_curchan == ic->ic_bsschan) in ath_set_channel()
5794 sc->sc_syncbeacon = 1; in ath_set_channel()
5805 struct ieee80211com *ic = this->iv_ic; in ath_isanyrunningvaps()
5810 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { in ath_isanyrunningvaps()
5811 if (vap != this && vap->iv_state >= IEEE80211_S_RUN) in ath_isanyrunningvaps()
5820 struct ieee80211com *ic = vap->iv_ic; in ath_newstate()
5821 struct ath_softc *sc = ic->ic_softc; in ath_newstate()
5823 struct ath_hal *ah = sc->sc_ah; in ath_newstate()
5828 enum ieee80211_state ostate = vap->iv_state; in ath_newstate()
5841 DPRINTF(sc, ATH_DEBUG_STATE, "%s: %s -> %s\n", __func__, in ath_newstate()
5847 * There are some comments around the calls to vap->iv_newstate in ath_newstate()
5854 /* Before we touch the hardware - wake it up */ in ath_newstate()
5858 * we need to ensure that self-generated frames are in ath_newstate()
5862 * XXX TODO: is this actually the case? :-) in ath_newstate()
5876 callout_stop(&sc->sc_cal_ch); in ath_newstate()
5899 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS)); in ath_newstate()
5900 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
5901 sc->sc_beacons = 0; in ath_newstate()
5902 taskqueue_unblock(sc->sc_tq); in ath_newstate()
5905 ni = ieee80211_ref_node(vap->iv_bss); in ath_newstate()
5907 stamode = (vap->iv_opmode == IEEE80211_M_STA || in ath_newstate()
5908 vap->iv_opmode == IEEE80211_M_AHDEMO || in ath_newstate()
5909 vap->iv_opmode == IEEE80211_M_IBSS); in ath_newstate()
5913 * from SLEEP->RUN. in ath_newstate()
5916 sc->sc_curaid = ni->ni_associd; in ath_newstate()
5917 IEEE80211_ADDR_COPY(sc->sc_curbssid, ni->ni_bssid); in ath_newstate()
5918 ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid); in ath_newstate()
5921 __func__, rfilt, ether_sprintf(sc->sc_curbssid), sc->sc_curaid); in ath_newstate()
5925 if (vap->iv_opmode != IEEE80211_M_STA && in ath_newstate()
5926 (vap->iv_flags & IEEE80211_F_PRIVACY)) { in ath_newstate()
5929 ath_hal_keysetmac(ah, i, ni->ni_bssid); in ath_newstate()
5935 error = avp->av_newstate(vap, nstate, arg); in ath_newstate()
5952 * not allow any ACKs or self-generated frames until we hear in ath_newstate()
5963 * transmitting - and then inform the driver about this in ath_newstate()
5977 * not allow any ACKs or self-generated frames until we hear in ath_newstate()
5988 * transmitting - and then inform the driver about this in ath_newstate()
5998 ni = ieee80211_ref_node(vap->iv_bss); in ath_newstate()
6003 vap->iv_flags, ni->ni_intval, ether_sprintf(ni->ni_bssid), in ath_newstate()
6004 ni->ni_capinfo, ieee80211_chan2ieee(ic, ic->ic_curchan)); in ath_newstate()
6006 switch (vap->iv_opmode) { in ath_newstate()
6009 if ((vap->iv_caps & IEEE80211_C_TDMA) == 0) in ath_newstate()
6030 * transition from RUN->RUN that means we may in ath_newstate()
6033 ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_newstate()
6046 if (vap->iv_opmode == IEEE80211_M_IBSS && in ath_newstate()
6047 ni->ni_tstamp.tsf != 0) { in ath_newstate()
6048 sc->sc_syncbeacon = 1; in ath_newstate()
6049 } else if (!sc->sc_beacons) { in ath_newstate()
6051 if (vap->iv_caps & IEEE80211_C_TDMA) in ath_newstate()
6056 sc->sc_beacons = 1; in ath_newstate()
6064 * However if it's due to a CSA -> RUN transition, in ath_newstate()
6082 if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { in ath_newstate()
6085 sc->sc_syncbeacon = 1; in ath_newstate()
6090 /* Quiet time handling - ensure we resync */ in ath_newstate()
6091 memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); in ath_newstate()
6105 if ((vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) == 0) { in ath_newstate()
6106 sc->sc_beacons = 1; in ath_newstate()
6112 * Monitor mode vaps have only INIT->RUN and RUN->RUN in ath_newstate()
6113 * transitions so we must re-enable interrupts here to in ath_newstate()
6116 ath_hal_intrset(ah, sc->sc_imask); in ath_newstate()
6131 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6132 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6133 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
6148 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_newstate()
6155 taskqueue_unblock(sc->sc_tq); in ath_newstate()
6157 /* Quiet time handling - ensure we resync */ in ath_newstate()
6158 memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); in ath_newstate()
6168 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
6170 ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL); in ath_newstate()
6171 taskqueue_block(sc->sc_tq); in ath_newstate()
6172 sc->sc_beacons = 0; in ath_newstate()
6191 if (sc->sc_nvaps == 1 && in ath_newstate()
6192 vap->iv_opmode == IEEE80211_M_STA) { in ath_newstate()
6193 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: syncbeacon=%d\n", __func__, sc->sc_syncbeacon); in ath_newstate()
6196 * Always at least set the self-generated in ath_newstate()
6209 if (sc->sc_syncbeacon == 0) { in ath_newstate()
6216 * Note - the ANI/calibration timer isn't re-enabled during in ath_newstate()
6217 * network sleep for now. One unfortunate side-effect is that in ath_newstate()
6226 /* Quiet time handling - ensure we resync */ in ath_newstate()
6227 memset(&avp->quiet_ie, 0, sizeof(avp->quiet_ie)); in ath_newstate()
6241 callout_reset(&sc->sc_cal_ch, 1, ath_calibrate, sc); in ath_newstate()
6252 * Restore the power state - either to what it was, or in ath_newstate()
6272 struct ieee80211vap *vap = ni->ni_vap; in ath_setup_stationkey()
6273 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_setup_stationkey()
6276 /* XXX should take a locked ref to vap->iv_bss */ in ath_setup_stationkey()
6277 if (!ath_key_alloc(vap, &ni->ni_ucastkey, &keyix, &rxkeyix)) { in ath_setup_stationkey()
6286 ni->ni_ucastkey.wk_keyix = keyix; in ath_setup_stationkey()
6287 ni->ni_ucastkey.wk_rxkeyix = rxkeyix; in ath_setup_stationkey()
6289 ni->ni_ucastkey.wk_flags |= IEEE80211_KEY_DEVKEY; in ath_setup_stationkey()
6290 IEEE80211_ADDR_COPY(ni->ni_ucastkey.wk_macaddr, ni->ni_macaddr); in ath_setup_stationkey()
6291 /* NB: this will create a pass-thru key entry */ in ath_setup_stationkey()
6292 ath_keyset(sc, vap, &ni->ni_ucastkey, vap->iv_bss); in ath_setup_stationkey()
6297 * Setup driver-specific state for a newly associated node.
6298 * Note that we're called also on a re-associate, the isnew
6305 struct ieee80211vap *vap = ni->ni_vap; in ath_newassoc()
6306 struct ath_softc *sc = vap->iv_ic->ic_softc; in ath_newassoc()
6307 const struct ieee80211_txparam *tp = ni->ni_txparms; in ath_newassoc()
6309 an->an_mcastrix = ath_tx_findrix(sc, tp->mcastrate); in ath_newassoc()
6310 an->an_mgmtrix = ath_tx_findrix(sc, tp->mgmtrate); in ath_newassoc()
6314 ni->ni_macaddr, in ath_newassoc()
6317 an->an_is_powersave); in ath_newassoc()
6324 (vap->iv_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey && in ath_newassoc()
6325 ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE) in ath_newassoc()
6335 * marked as non-aggregate. in ath_newassoc()
6341 ni->ni_macaddr, in ath_newassoc()
6343 an->an_is_powersave); in ath_newassoc()
6349 if (an->an_is_powersave) in ath_newassoc()
6358 struct ath_softc *sc = ic->ic_softc; in ath_setregdomain()
6359 struct ath_hal *ah = sc->sc_ah; in ath_setregdomain()
6364 __func__, reg->regdomain, reg->country, reg->location, in ath_setregdomain()
6365 reg->ecm ? " ecm" : ""); in ath_setregdomain()
6368 reg->country, reg->regdomain); in ath_setregdomain()
6382 struct ath_softc *sc = ic->ic_softc; in ath_getradiocaps()
6383 struct ath_hal *ah = sc->sc_ah; in ath_getradiocaps()
6397 struct ieee80211com *ic = &sc->sc_ic; in ath_getchannels()
6398 struct ath_hal *ah = sc->sc_ah; in ath_getchannels()
6404 status = ath_hal_init_channels(ah, ic->ic_channels, IEEE80211_CHAN_MAX, in ath_getchannels()
6405 &ic->ic_nchans, HAL_MODE_ALL, CTRY_DEFAULT, SKU_NONE, AH_TRUE); in ath_getchannels()
6407 device_printf(sc->sc_dev, in ath_getchannels()
6412 (void) ath_hal_getregdomain(ah, &sc->sc_eerd); in ath_getchannels()
6413 ath_hal_getcountrycode(ah, &sc->sc_eecc); /* NB: cannot fail */ in ath_getchannels()
6416 ic->ic_regdomain.regdomain = (uint16_t) sc->sc_eerd; in ath_getchannels()
6417 ic->ic_regdomain.country = (uint16_t) sc->sc_eecc; in ath_getchannels()
6418 ic->ic_regdomain.isocc[0] = ' '; /* XXX don't know */ in ath_getchannels()
6419 ic->ic_regdomain.isocc[1] = ' '; in ath_getchannels()
6421 ic->ic_regdomain.ecm = 1; in ath_getchannels()
6422 ic->ic_regdomain.location = 'I'; in ath_getchannels()
6426 __func__, sc->sc_eerd, sc->sc_eecc, in ath_getchannels()
6427 ic->ic_regdomain.regdomain, ic->ic_regdomain.country, in ath_getchannels()
6428 ic->ic_regdomain.location, ic->ic_regdomain.ecm ? " ecm" : ""); in ath_getchannels()
6435 struct ath_hal *ah = sc->sc_ah; in ath_rate_setup()
6474 sc->sc_rates[mode] = rt; in ath_rate_setup()
6506 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); in ath_setcurmode()
6507 rt = sc->sc_rates[mode]; in ath_setcurmode()
6509 for (i = 0; i < rt->rateCount; i++) { in ath_setcurmode()
6510 uint8_t ieeerate = rt->info[i].dot11Rate & IEEE80211_RATE_VAL; in ath_setcurmode()
6511 if (rt->info[i].phy != IEEE80211_T_HT) in ath_setcurmode()
6512 sc->sc_rixmap[ieeerate] = i; in ath_setcurmode()
6514 sc->sc_rixmap[ieeerate | IEEE80211_RATE_MCS] = i; in ath_setcurmode()
6516 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); in ath_setcurmode()
6517 for (i = 0; i < nitems(sc->sc_hwmap); i++) { in ath_setcurmode()
6518 if (i >= rt->rateCount) { in ath_setcurmode()
6519 sc->sc_hwmap[i].ledon = (500 * hz) / 1000; in ath_setcurmode()
6520 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; in ath_setcurmode()
6523 sc->sc_hwmap[i].ieeerate = in ath_setcurmode()
6524 rt->info[i].dot11Rate & IEEE80211_RATE_VAL; in ath_setcurmode()
6525 if (rt->info[i].phy == IEEE80211_T_HT) in ath_setcurmode()
6526 sc->sc_hwmap[i].ieeerate |= IEEE80211_RATE_MCS; in ath_setcurmode()
6527 sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; in ath_setcurmode()
6528 if (rt->info[i].shortPreamble || in ath_setcurmode()
6529 rt->info[i].phy == IEEE80211_T_OFDM) in ath_setcurmode()
6530 sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ath_setcurmode()
6531 sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags; in ath_setcurmode()
6532 for (j = 0; j < nitems(blinkrates)-1; j++) in ath_setcurmode()
6533 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) in ath_setcurmode()
6537 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000; in ath_setcurmode()
6538 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000; in ath_setcurmode()
6540 sc->sc_currates = rt; in ath_setcurmode()
6541 sc->sc_curmode = mode; in ath_setcurmode()
6547 sc->sc_protrix = ath_tx_findrix(sc, 2*2); in ath_setcurmode()
6549 sc->sc_protrix = ath_tx_findrix(sc, 2*1); in ath_setcurmode()
6557 struct ieee80211com *ic = &sc->sc_ic; in ath_watchdog()
6562 if (sc->sc_wd_timer != 0 && --sc->sc_wd_timer == 0) { in ath_watchdog()
6567 if (ath_hal_gethangstate(sc->sc_ah, 0xffff, &hangs) && in ath_watchdog()
6569 device_printf(sc->sc_dev, "%s hang detected (0x%x)\n", in ath_watchdog()
6572 device_printf(sc->sc_dev, "device timeout\n"); in ath_watchdog()
6574 counter_u64_add(ic->ic_oerrors, 1); in ath_watchdog()
6575 sc->sc_stats.ast_watchdog++; in ath_watchdog()
6587 taskqueue_enqueue(sc->sc_tq, &sc->sc_resettask); in ath_watchdog()
6590 callout_schedule(&sc->sc_wd_ch, hz); in ath_watchdog()
6596 struct ath_softc *sc = ic->ic_softc; in ath_parent()
6600 if (ic->ic_nrunning > 0) { in ath_parent()
6606 if (sc->sc_running) { in ath_parent()
6610 } else if (!sc->sc_invalid) { in ath_parent()
6615 * However trying to re-init the interface in ath_parent()
6624 if (!sc->sc_invalid) in ath_parent()
6631 if (sc->sc_tx99 != NULL) in ath_parent()
6632 sc->sc_tx99->start(sc->sc_tx99); in ath_parent()
6645 struct ath_hal *ah = sc->sc_ah; in ath_announce()
6647 device_printf(sc->sc_dev, "%s mac %d.%d RF%s phy %d.%d\n", in ath_announce()
6648 ath_hal_mac_name(ah), ah->ah_macVersion, ah->ah_macRev, in ath_announce()
6649 ath_hal_rf_name(ah), ah->ah_phyRev >> 4, ah->ah_phyRev & 0xf); in ath_announce()
6650 device_printf(sc->sc_dev, "2GHz radio: 0x%.4x; 5GHz radio: 0x%.4x\n", in ath_announce()
6651 ah->ah_analog2GhzRev, ah->ah_analog5GhzRev); in ath_announce()
6655 struct ath_txq *txq = sc->sc_ac2q[i]; in ath_announce()
6656 device_printf(sc->sc_dev, in ath_announce()
6658 txq->axq_qnum, ieee80211_wme_acnames[i]); in ath_announce()
6660 device_printf(sc->sc_dev, "Use hw queue %u for CAB traffic\n", in ath_announce()
6661 sc->sc_cabq->axq_qnum); in ath_announce()
6662 device_printf(sc->sc_dev, "Use hw queue %u for beacons\n", in ath_announce()
6663 sc->sc_bhalq); in ath_announce()
6666 device_printf(sc->sc_dev, "using %u rx buffers\n", ath_rxbuf); in ath_announce()
6668 device_printf(sc->sc_dev, "using %u tx buffers\n", ath_txbuf); in ath_announce()
6669 if (sc->sc_mcastkey && bootverbose) in ath_announce()
6670 device_printf(sc->sc_dev, "using multicast key search\n"); in ath_announce()
6677 struct ieee80211com *ic = &sc->sc_ic; in ath_dfs_tasklet()
6684 if (ath_dfs_process_radar_event(sc, sc->sc_curchan)) { in ath_dfs_tasklet()
6701 ieee80211_dfs_notify_radar(ic, sc->sc_curchan); in ath_dfs_tasklet()
6717 struct ieee80211com *ic = ni->ni_ic; in ath_node_powersave()
6718 struct ath_softc *sc = ic->ic_softc; in ath_node_powersave()
6719 struct ath_vap *avp = ATH_VAP(ni->ni_vap); in ath_node_powersave()
6725 ni->ni_macaddr, in ath_node_powersave()
6736 avp->av_node_ps(ni, enable); in ath_node_powersave()
6738 struct ath_vap *avp = ATH_VAP(ni->ni_vap); in ath_node_powersave()
6741 avp->av_node_ps(ni, enable); in ath_node_powersave()
6771 * just wraps the driver state change and this call to avp->av_set_tim().
6775 * into the driver, as well as ps-poll and the driver transmitting
6777 * a packet entering the PSQ and a ps-poll being handled will
6778 * race, causing the TIM to be cleared and not re-set.
6784 struct ieee80211com *ic = ni->ni_ic; in ath_node_set_tim()
6785 struct ath_softc *sc = ic->ic_softc; in ath_node_set_tim()
6787 struct ath_vap *avp = ATH_VAP(ni->ni_vap); in ath_node_set_tim()
6791 an->an_stack_psq = enable; in ath_node_set_tim()
6795 * even if avp->av_set_tim is unset. in ath_node_set_tim()
6800 if (avp->av_set_tim == NULL) { in ath_node_set_tim()
6819 if (enable && an->an_tim_set == 1) { in ath_node_set_tim()
6823 ni->ni_macaddr, in ath_node_set_tim()
6831 ni->ni_macaddr, in ath_node_set_tim()
6834 an->an_tim_set = 1; in ath_node_set_tim()
6836 changed = avp->av_set_tim(ni, enable); in ath_node_set_tim()
6837 } else if (an->an_swq_depth == 0) { in ath_node_set_tim()
6842 ni->ni_macaddr, in ath_node_set_tim()
6845 an->an_tim_set = 0; in ath_node_set_tim()
6847 changed = avp->av_set_tim(ni, enable); in ath_node_set_tim()
6848 } else if (! an->an_is_powersave) { in ath_node_set_tim()
6855 ni->ni_macaddr, in ath_node_set_tim()
6858 an->an_tim_set = 0; in ath_node_set_tim()
6860 changed = avp->av_set_tim(ni, enable); in ath_node_set_tim()
6871 ni->ni_macaddr, in ath_node_set_tim()
6879 struct ath_vap *avp = ATH_VAP(ni->ni_vap); in ath_node_set_tim()
6885 if (avp->av_set_tim == NULL) in ath_node_set_tim()
6888 return (avp->av_set_tim(ni, enable)); in ath_node_set_tim()
6897 * re-check afterwards to ensure nothing has changed in the
6926 avp = ATH_VAP(ni->ni_vap); in ath_tx_update_tim()
6932 if (avp->av_set_tim == NULL) in ath_tx_update_tim()
6938 if (an->an_is_powersave && in ath_tx_update_tim()
6939 an->an_tim_set == 0 && in ath_tx_update_tim()
6940 an->an_swq_depth != 0) { in ath_tx_update_tim()
6944 ni->ni_macaddr, in ath_tx_update_tim()
6946 an->an_tim_set = 1; in ath_tx_update_tim()
6947 (void) avp->av_set_tim(ni, 1); in ath_tx_update_tim()
6953 if (an->an_swq_depth != 0) in ath_tx_update_tim()
6956 if (an->an_is_powersave && in ath_tx_update_tim()
6957 an->an_stack_psq == 0 && in ath_tx_update_tim()
6958 an->an_tim_set == 1 && in ath_tx_update_tim()
6959 an->an_swq_depth == 0) { in ath_tx_update_tim()
6964 ni->ni_macaddr, in ath_tx_update_tim()
6966 an->an_tim_set = 0; in ath_tx_update_tim()
6967 (void) avp->av_set_tim(ni, 0); in ath_tx_update_tim()
6976 * Received a ps-poll frame from net80211.
6978 * Here we get a chance to serve out a software-queued frame ourselves
6979 * before we punt it to net80211 to transmit us one itself - either
6989 struct ieee80211com *ic = ni->ni_ic; in ath_node_recv_pspoll()
6990 struct ath_softc *sc = ic->ic_softc; in ath_node_recv_pspoll()
7000 if (ni->ni_associd == 0) in ath_node_recv_pspoll()
7007 avp = ATH_VAP(ni->ni_vap); in ath_node_recv_pspoll()
7010 * For now, we just call the original ps-poll method. in ath_node_recv_pspoll()
7024 * TIDs worth of traffic - but let's get it working first in ath_node_recv_pspoll()
7027 * Also yes, there's definitely latency here - we're not in ath_node_recv_pspoll()
7032 * turn-around time. in ath_node_recv_pspoll()
7038 * Legacy - we're called and the node isn't asleep. in ath_node_recv_pspoll()
7041 if (! an->an_is_powersave) { in ath_node_recv_pspoll()
7045 ni->ni_macaddr, in ath_node_recv_pspoll()
7048 avp->av_recv_pspoll(ni, m); in ath_node_recv_pspoll()
7057 an->an_leak_count = 1; in ath_node_recv_pspoll()
7066 if (an->an_swq_depth == 0) { in ath_node_recv_pspoll()
7071 ni->ni_macaddr, in ath_node_recv_pspoll()
7073 avp->av_recv_pspoll(ni, m); in ath_node_recv_pspoll()
7081 for (tid = IEEE80211_TID_SIZE - 1; tid >= 0; tid--) { in ath_node_recv_pspoll()
7082 struct ath_tid *atid = &an->an_tid[tid]; in ath_node_recv_pspoll()
7086 if (atid->axq_depth == 0) in ath_node_recv_pspoll()
7095 taskqueue_enqueue(sc->sc_tq, &sc->sc_txqtask); in ath_node_recv_pspoll()
7099 ni->ni_macaddr, in ath_node_recv_pspoll()
7113 ni->ni_macaddr, in ath_node_recv_pspoll()
7115 avp->av_recv_pspoll(ni, m); in ath_node_recv_pspoll()
7117 avp->av_recv_pspoll(ni, m); in ath_node_recv_pspoll()