Lines Matching +full:no +full:- +full:bf
3 /*-
4 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
17 * 3. Neither the names of the above-listed copyright holders nor the names
25 * NO WARRANTY
29 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
255 ((sc->sc_debug & (m)) || \
256 (sc->sc_if.if_flags & (IFF_DEBUG | IFF_LINK2)) \
259 if (sc->sc_debug & (m)) \
263 if (sc->sc_debug & ATH_DEBUG_KEYCACHE) \
266 static void ath_printrxbuf(struct ath_buf *bf, int);
267 static void ath_printtxbuf(struct ath_buf *bf, int);
270 ((sc->sc_if.if_flags & (IFF_DEBUG | IFF_LINK2)) \
281 struct ifnet *ifp = &sc->sc_if; in ath_attach()
282 struct ieee80211com *ic = &sc->sc_ic; in ath_attach()
289 pmf_self_suspensor_init(sc->sc_dev, &sc->sc_suspensor, &sc->sc_qual); in ath_attach()
291 memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); in ath_attach()
293 ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status); in ath_attach()
300 if (ah->ah_abi != HAL_ABI_VERSION) { in ath_attach()
303 ah->ah_abi, HAL_ABI_VERSION); in ath_attach()
307 sc->sc_ah = ah; in ath_attach()
309 if (!prop_dictionary_set_bool(device_properties(sc->sc_dev), in ath_attach()
310 "pmf-no-powerdown", true)) in ath_attach()
314 * Check if the MAC has multi-rate retry support. in ath_attach()
320 sc->sc_mrretry = ath_hal_setupxtxdesc(ah, NULL, 0,0, 0,0, 0,0); in ath_attach()
328 sc->sc_needmib = 1; in ath_attach()
333 sc->sc_keymax = ath_hal_keycachesize(ah); in ath_attach()
334 if (sc->sc_keymax > ATH_KEYMAX) { in ath_attach()
336 ATH_KEYMAX, sc->sc_keymax); in ath_attach()
337 sc->sc_keymax = ATH_KEYMAX; in ath_attach()
343 for (i = 0; i < sc->sc_keymax; i++) in ath_attach()
352 setbit(sc->sc_keymap, i); in ath_attach()
353 setbit(sc->sc_keymap, i+32); in ath_attach()
354 setbit(sc->sc_keymap, i+64); in ath_attach()
355 setbit(sc->sc_keymap, i+32+64); in ath_attach()
388 ATH_CALLOUT_INIT(&sc->sc_scan_ch, debug_mpsafenet ? CALLOUT_MPSAFE : 0); in ath_attach()
389 ATH_CALLOUT_INIT(&sc->sc_cal_ch, CALLOUT_MPSAFE); in ath_attach()
391 ATH_CALLOUT_INIT(&sc->sc_dfs_ch, CALLOUT_MPSAFE); in ath_attach()
396 TASK_INIT(&sc->sc_rxtask, 0, ath_rx_proc, sc); in ath_attach()
397 TASK_INIT(&sc->sc_rxorntask, 0, ath_rxorn_proc, sc); in ath_attach()
398 TASK_INIT(&sc->sc_fataltask, 0, ath_fatal_proc, sc); in ath_attach()
399 TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); in ath_attach()
400 TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); in ath_attach()
401 TASK_INIT(&sc->sc_radartask, 0, ath_radar_proc, sc); in ath_attach()
409 * XXX PS-Poll in ath_attach()
411 sc->sc_bhalq = ath_beaconq_setup(ah); in ath_attach()
412 if (sc->sc_bhalq == (u_int) -1) { in ath_attach()
417 sc->sc_cabq = ath_txq_setup(sc, HAL_TX_QUEUE_CAB, 0); in ath_attach()
418 if (sc->sc_cabq == NULL) { in ath_attach()
440 if (sc->sc_ac2q[WME_AC_VI] != NULL) in ath_attach()
441 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]); in ath_attach()
442 if (sc->sc_ac2q[WME_AC_BE] != NULL) in ath_attach()
443 ath_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]); in ath_attach()
444 sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
445 sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
446 sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK]; in ath_attach()
454 switch (sc->sc_txqsetup &~ (1<<sc->sc_cabq->axq_qnum)) { in ath_attach()
456 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0, sc); in ath_attach()
459 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc_q0123, sc); in ath_attach()
462 TASK_INIT(&sc->sc_txtask, 0, ath_tx_proc, sc); in ath_attach()
472 sc->sc_setdefantenna = ath_setdefantenna; in ath_attach()
473 sc->sc_rc = ath_rate_attach(sc); in ath_attach()
474 if (sc->sc_rc == NULL) { in ath_attach()
479 sc->sc_blinking = 0; in ath_attach()
480 sc->sc_ledstate = 1; in ath_attach()
481 sc->sc_ledon = 0; /* low true */ in ath_attach()
482 sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */ in ath_attach()
483 ATH_CALLOUT_INIT(&sc->sc_ledtimer, CALLOUT_MPSAFE); in ath_attach()
485 * Auto-enable soft led processing for IBM cards and for in ath_attach()
489 sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID); in ath_attach()
490 if (sc->sc_softled) { in ath_attach()
491 ath_hal_gpioCfgOutput(ah, sc->sc_ledpin, in ath_attach()
493 ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon); in ath_attach()
496 ifp->if_softc = sc; in ath_attach()
497 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; in ath_attach()
498 ifp->if_start = ath_start; in ath_attach()
499 ifp->if_stop = ath_stop; in ath_attach()
500 ifp->if_watchdog = ath_watchdog; in ath_attach()
501 ifp->if_ioctl = ath_ioctl; in ath_attach()
502 ifp->if_init = ath_ifinit; in ath_attach()
503 IFQ_SET_READY(&ifp->if_snd); in ath_attach()
505 ic->ic_ifp = ifp; in ath_attach()
506 ic->ic_reset = ath_reset; in ath_attach()
507 ic->ic_newassoc = ath_newassoc; in ath_attach()
508 ic->ic_updateslot = ath_updateslot; in ath_attach()
509 ic->ic_wme.wme_update = ath_wme_update; in ath_attach()
511 ic->ic_phytype = IEEE80211_T_OFDM; in ath_attach()
512 ic->ic_opmode = IEEE80211_M_STA; in ath_attach()
513 ic->ic_caps = in ath_attach()
526 ic->ic_caps |= IEEE80211_C_WEP; in ath_attach()
528 ic->ic_caps |= IEEE80211_C_AES; in ath_attach()
530 ic->ic_caps |= IEEE80211_C_AES_CCM; in ath_attach()
532 ic->ic_caps |= IEEE80211_C_CKIP; in ath_attach()
534 ic->ic_caps |= IEEE80211_C_TKIP; in ath_attach()
541 ic->ic_caps |= IEEE80211_C_TKIPMIC; in ath_attach()
549 sc->sc_splitmic = 1; in ath_attach()
557 ic->ic_caps |= IEEE80211_C_WME_TKIPMIC; in ath_attach()
559 sc->sc_hasclrkey = ath_hal_ciphersupported(ah, HAL_CIPHER_CLR); in ath_attach()
560 sc->sc_mcastkey = ath_hal_getmcastkeysearch(ah); in ath_attach()
567 setbit(sc->sc_keymap, i); in ath_attach()
568 setbit(sc->sc_keymap, i+64); in ath_attach()
569 if (sc->sc_splitmic) { in ath_attach()
570 setbit(sc->sc_keymap, i+32); in ath_attach()
571 setbit(sc->sc_keymap, i+32+64); in ath_attach()
576 * per-packet support. The latter is not available on in ath_attach()
581 ic->ic_caps |= IEEE80211_C_TXPMGT; in ath_attach()
587 if (sc->sc_ac2q[WME_AC_BE] != sc->sc_ac2q[WME_AC_BK]) in ath_attach()
588 ic->ic_caps |= IEEE80211_C_WME; in ath_attach()
593 ic->ic_caps |= IEEE80211_C_BURST; in ath_attach()
597 * 32-bit boundary for 4-address and QoS frames. in ath_attach()
599 ic->ic_flags |= IEEE80211_F_DATAPAD; in ath_attach()
604 sc->sc_defant = ath_hal_getdefantenna(ah); in ath_attach()
610 sc->sc_hasveol = ath_hal_hasveol(ah); in ath_attach()
613 ath_hal_getmac(ah, ic->ic_myaddr); in ath_attach()
619 ic->ic_node_alloc = ath_node_alloc; in ath_attach()
620 sc->sc_node_free = ic->ic_node_free; in ath_attach()
621 ic->ic_node_free = ath_node_free; in ath_attach()
622 ic->ic_node_getrssi = ath_node_getrssi; in ath_attach()
623 sc->sc_recv_mgmt = ic->ic_recv_mgmt; in ath_attach()
624 ic->ic_recv_mgmt = ath_recv_mgmt; in ath_attach()
625 sc->sc_newstate = ic->ic_newstate; in ath_attach()
626 ic->ic_newstate = ath_newstate; in ath_attach()
627 ic->ic_crypto.cs_max_keyix = sc->sc_keymax; in ath_attach()
628 ic->ic_crypto.cs_key_alloc = ath_key_alloc; in ath_attach()
629 ic->ic_crypto.cs_key_delete = ath_key_delete; in ath_attach()
630 ic->ic_crypto.cs_key_set = ath_key_set; in ath_attach()
631 ic->ic_crypto.cs_key_update_begin = ath_key_update_begin; in ath_attach()
632 ic->ic_crypto.cs_key_update_end = ath_key_update_end; in ath_attach()
638 sc->sc_flags |= ATH_ATTACHED; in ath_attach()
655 (void)config_deactivate(sc->sc_dev); in ath_attach()
662 struct ifnet *ifp = &sc->sc_if; in ath_detach()
665 if ((sc->sc_flags & ATH_ATTACHED) == 0) in ath_detach()
669 __func__, ifp->if_flags); in ath_detach()
686 ieee80211_ifdetach(&sc->sc_ic); in ath_detach()
688 if (sc->sc_tx99 != NULL) in ath_detach()
689 sc->sc_tx99->detach(sc->sc_tx99); in ath_detach()
691 ath_rate_detach(sc->sc_rc); in ath_detach()
694 sysctl_teardown(&sc->sc_sysctllog); in ath_detach()
695 ath_hal_detach(sc->sc_ah); in ath_detach()
715 ath_hal_setpower(sc->sc_ah, HAL_PM_FULL_SLEEP); in ath_suspend()
722 struct ath_hal *ah = sc->sc_ah; in ath_resume()
723 struct ieee80211com *ic = &sc->sc_ic; in ath_resume()
730 ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, HAL_M_IBSS, &status); in ath_resume()
737 for (i = 0; i < sc->sc_keymax; i++) in ath_resume()
740 ath_hal_resettxqueue(ah, sc->sc_bhalq); in ath_resume()
745 if (sc->sc_softled) { in ath_resume()
746 ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin, in ath_resume()
748 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); in ath_resume()
760 struct ifnet *ifp = &sc->sc_if; in ath_intr()
761 struct ath_hal *ah = sc->sc_ah; in ath_intr()
764 if (!device_activation(sc->sc_dev, DEVACT_LEVEL_DRIVER)) { in ath_intr()
776 if ((ifp->if_flags & (IFF_RUNNING |IFF_UP)) != (IFF_RUNNING |IFF_UP)) { in ath_intr()
778 __func__, ifp->if_flags); in ath_intr()
785 * that the hal returns a pseudo-ISR that may include in ath_intr()
791 status &= sc->sc_imask; /* discard unasked for bits */ in ath_intr()
799 sc->sc_stats.ast_hardware++; in ath_intr()
801 TASK_RUN_OR_ENQUEUE(&sc->sc_fataltask); in ath_intr()
803 sc->sc_stats.ast_rxorn++; in ath_intr()
805 TASK_RUN_OR_ENQUEUE(&sc->sc_rxorntask); in ath_intr()
809 * Software beacon alert--time to send a beacon. in ath_intr()
818 * NB: the hardware should re-read the link when in ath_intr()
822 sc->sc_stats.ast_rxeol++; in ath_intr()
823 sc->sc_rxlink = NULL; in ath_intr()
826 sc->sc_stats.ast_txurn++; in ath_intr()
831 TASK_RUN_OR_ENQUEUE(&sc->sc_rxtask); in ath_intr()
833 TASK_RUN_OR_ENQUEUE(&sc->sc_txtask); in ath_intr()
835 sc->sc_stats.ast_bmiss++; in ath_intr()
836 TASK_RUN_OR_ENQUEUE(&sc->sc_bmisstask); in ath_intr()
839 sc->sc_stats.ast_mib++; in ath_intr()
849 ath_hal_mibevent(ah, &sc->sc_halstats); in ath_intr()
850 ath_hal_intrset(ah, sc->sc_imask); in ath_intr()
864 ds->ds_link = htole32(ds->ds_link); in ath_desc_swap()
865 ds->ds_data = htole32(ds->ds_data); in ath_desc_swap()
866 ds->ds_ctl0 = htole32(ds->ds_ctl0); in ath_desc_swap()
867 ds->ds_ctl1 = htole32(ds->ds_ctl1); in ath_desc_swap()
868 ds->ds_hw[0] = htole32(ds->ds_hw[0]); in ath_desc_swap()
869 ds->ds_hw[1] = htole32(ds->ds_hw[1]); in ath_desc_swap()
877 struct ifnet *ifp = &sc->sc_if; in ath_fatal_proc()
896 struct ifnet *ifp = &sc->sc_if; in ath_rxorn_proc()
915 struct ieee80211com *ic = &sc->sc_ic; in ath_bmiss_proc()
919 KASSERTMSG(ic->ic_opmode == IEEE80211_M_STA, in ath_bmiss_proc()
920 "unexpect operating mode %u", ic->ic_opmode); in ath_bmiss_proc()
921 if (ic->ic_state == IEEE80211_S_RUN) { in ath_bmiss_proc()
922 u_int64_t lastrx = sc->sc_lastrx; in ath_bmiss_proc()
923 u_int64_t tsf = ath_hal_gettsf64(sc->sc_ah); in ath_bmiss_proc()
928 __func__, tsf, tsf - lastrx, lastrx, in ath_bmiss_proc()
929 ic->ic_bmisstimeout*1024); in ath_bmiss_proc()
931 * Workaround phantom bmiss interrupts by sanity-checking in ath_bmiss_proc()
937 if (tsf - lastrx > ic->ic_bmisstimeout*1024) { in ath_bmiss_proc()
942 sc->sc_stats.ast_bmiss_phantom++; in ath_bmiss_proc()
951 struct ifnet *ifp = &sc->sc_if; in ath_radar_proc()
952 struct ath_hal *ah = sc->sc_ah; in ath_radar_proc()
990 struct ath_softc *sc = (struct ath_softc *)ifp->if_softc; in ath_ifinit()
998 struct ieee80211com *ic = &sc->sc_ic; in ath_settkipmic()
999 struct ath_hal *ah = sc->sc_ah; in ath_settkipmic()
1001 if ((ic->ic_caps & IEEE80211_C_TKIP) && in ath_settkipmic()
1002 !(ic->ic_caps & IEEE80211_C_WME_TKIPMIC)) { in ath_settkipmic()
1003 if (ic->ic_flags & IEEE80211_F_WME) { in ath_settkipmic()
1005 ic->ic_caps &= ~IEEE80211_C_TKIPMIC; in ath_settkipmic()
1008 ic->ic_caps |= IEEE80211_C_TKIPMIC; in ath_settkipmic()
1016 struct ifnet *ifp = &sc->sc_if; in ath_init()
1017 struct ieee80211com *ic = &sc->sc_ic; in ath_init()
1018 struct ath_hal *ah = sc->sc_ah; in ath_init()
1023 __func__, ifp->if_flags); in ath_init()
1025 if (device_is_active(sc->sc_dev)) { in ath_init()
1027 } else if (!pmf_device_subtree_resume(sc->sc_dev, &sc->sc_qual) || in ath_init()
1028 !device_is_active(sc->sc_dev)) in ath_init()
1047 sc->sc_curchan.channel = ic->ic_curchan->ic_freq; in ath_init()
1048 sc->sc_curchan.channelFlags = ath_chan2flags(ic, ic->ic_curchan); in ath_init()
1049 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_FALSE, &status)) { in ath_init()
1066 sc->sc_calinterval = 1; in ath_init()
1067 sc->sc_caltries = 0; in ath_init()
1084 sc->sc_imask = HAL_INT_RX | HAL_INT_TX in ath_init()
1091 if (sc->sc_needmib && ic->ic_opmode == IEEE80211_M_STA) in ath_init()
1092 sc->sc_imask |= HAL_INT_MIB; in ath_init()
1093 ath_hal_intrset(ah, sc->sc_imask); in ath_init()
1095 ifp->if_flags |= IFF_RUNNING; in ath_init()
1096 ic->ic_state = IEEE80211_S_INIT; in ath_init()
1103 ath_chan_change(sc, ic->ic_curchan); in ath_init()
1105 if (sc->sc_tx99 != NULL) in ath_init()
1106 sc->sc_tx99->start(sc->sc_tx99); in ath_init()
1109 if (ic->ic_opmode != IEEE80211_M_MONITOR) { in ath_init()
1110 if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) in ath_init()
1111 ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); in ath_init()
1113 ieee80211_new_state(ic, IEEE80211_S_RUN, -1); in ath_init()
1122 struct ath_softc *sc = ifp->if_softc; in ath_stop_locked()
1123 struct ieee80211com *ic = &sc->sc_ic; in ath_stop_locked()
1124 struct ath_hal *ah = sc->sc_ah; in ath_stop_locked()
1127 __func__, !device_is_enabled(sc->sc_dev), ifp->if_flags); in ath_stop_locked()
1130 if (ifp->if_flags & IFF_RUNNING) { in ath_stop_locked()
1147 if (sc->sc_tx99 != NULL) in ath_stop_locked()
1148 sc->sc_tx99->stop(sc->sc_tx99); in ath_stop_locked()
1150 ieee80211_new_state(ic, IEEE80211_S_INIT, -1); in ath_stop_locked()
1151 ifp->if_flags &= ~IFF_RUNNING; in ath_stop_locked()
1152 ifp->if_timer = 0; in ath_stop_locked()
1153 if (device_is_enabled(sc->sc_dev)) { in ath_stop_locked()
1154 if (sc->sc_softled) { in ath_stop_locked()
1155 callout_stop(&sc->sc_ledtimer); in ath_stop_locked()
1156 ath_hal_gpioset(ah, sc->sc_ledpin, in ath_stop_locked()
1157 !sc->sc_ledon); in ath_stop_locked()
1158 sc->sc_blinking = 0; in ath_stop_locked()
1163 if (device_is_enabled(sc->sc_dev)) { in ath_stop_locked()
1167 sc->sc_rxlink = NULL; in ath_stop_locked()
1168 IF_PURGE(&ifp->if_snd); in ath_stop_locked()
1172 pmf_device_suspend(sc->sc_dev, &sc->sc_qual); in ath_stop_locked()
1188 struct ifnet *ifp = &sc->sc_if; in ath_restore_diversity()
1189 struct ath_hal *ah = sc->sc_ah; in ath_restore_diversity()
1191 if (!ath_hal_setdiversity(sc->sc_ah, sc->sc_diversity) || in ath_restore_diversity()
1192 sc->sc_diversity != ath_hal_getdiversity(ah)) { in ath_restore_diversity()
1194 sc->sc_diversity); in ath_restore_diversity()
1195 sc->sc_diversity = ath_hal_getdiversity(ah); in ath_restore_diversity()
1209 struct ath_softc *sc = ifp->if_softc; in ath_reset()
1210 struct ieee80211com *ic = &sc->sc_ic; in ath_reset()
1211 struct ath_hal *ah = sc->sc_ah; in ath_reset()
1219 c = ic->ic_curchan; in ath_reset()
1220 sc->sc_curchan.channel = c->ic_freq; in ath_reset()
1221 sc->sc_curchan.channelFlags = ath_chan2flags(ic, c); in ath_reset()
1228 if (!ath_hal_reset(ah, ic->ic_opmode, &sc->sc_curchan, AH_TRUE, &status)) in ath_reset()
1233 sc->sc_calinterval = 1; in ath_reset()
1234 sc->sc_caltries = 0; in ath_reset()
1243 if (ic->ic_state == IEEE80211_S_RUN) in ath_reset()
1245 ath_hal_intrset(ah, sc->sc_imask); in ath_reset()
1260 struct ath_buf *bf; in ath_txfrag_cleanup() local
1264 while ((bf = STAILQ_FIRST(frags)) != NULL) { in ath_txfrag_cleanup()
1266 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_txfrag_cleanup()
1267 sc->sc_if.if_flags &= ~IFF_OACTIVE; in ath_txfrag_cleanup()
1282 struct ath_buf *bf; in ath_txfrag_setup() local
1285 for (m = m0->m_nextpkt; m != NULL; m = m->m_nextpkt) { in ath_txfrag_setup()
1286 bf = STAILQ_FIRST(&sc->sc_txbuf); in ath_txfrag_setup()
1287 if (bf == NULL) { /* out of buffers, cleanup */ in ath_txfrag_setup()
1290 sc->sc_if.if_flags |= IFF_OACTIVE; in ath_txfrag_setup()
1294 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); in ath_txfrag_setup()
1296 STAILQ_INSERT_TAIL(frags, bf, bf_list); in ath_txfrag_setup()
1306 struct ath_softc *sc = ifp->if_softc; in ath_start()
1307 struct ath_hal *ah = sc->sc_ah; in ath_start()
1308 struct ieee80211com *ic = &sc->sc_ic; in ath_start()
1310 struct ath_buf *bf; in ath_start() local
1316 if ((ifp->if_flags & IFF_RUNNING) == 0 || in ath_start()
1317 !device_is_active(sc->sc_dev)) in ath_start()
1320 if (sc->sc_flags & ATH_KEY_UPDATING) in ath_start()
1328 bf = STAILQ_FIRST(&sc->sc_txbuf); in ath_start()
1329 if (bf != NULL) in ath_start()
1330 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); in ath_start()
1332 if (bf == NULL) { in ath_start()
1335 sc->sc_stats.ast_tx_qstop++; in ath_start()
1336 ifp->if_flags |= IFF_OACTIVE; in ath_start()
1343 IF_DEQUEUE(&ic->ic_mgtq, m); in ath_start()
1346 * No data frames go out unless we're associated. in ath_start()
1348 if (ic->ic_state != IEEE80211_S_RUN) { in ath_start()
1352 ieee80211_state_name[ic->ic_state]); in ath_start()
1353 sc->sc_stats.ast_tx_discard++; in ath_start()
1355 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_start()
1359 IFQ_DEQUEUE(&ifp->if_snd, m); /* XXX: LOCK */ in ath_start()
1362 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_start()
1371 if (m->m_len < sizeof(struct ether_header) && in ath_start()
1373 ic->ic_stats.is_tx_nobuf++; /* XXX */ in ath_start()
1378 ni = ieee80211_find_txnode(ic, eh->ether_dhost); in ath_start()
1384 if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) && in ath_start()
1385 (m->m_flags & M_PWR_SAV) == 0) { in ath_start()
1413 sc->sc_stats.ast_tx_encap++; in ath_start()
1422 if ((m->m_flags & M_FRAG) && in ath_start()
1426 ic->ic_stats.is_tx_nobuf++; /* XXX */ in ath_start()
1436 * and there's no other way (other than packet in ath_start()
1444 if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == in ath_start()
1457 sc->sc_stats.ast_tx_mgmt++; in ath_start()
1461 next = m->m_nextpkt; in ath_start()
1462 if (ath_tx_start(sc, ni, bf, m)) { in ath_start()
1467 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_start()
1476 bf = STAILQ_FIRST(&frags); in ath_start()
1477 KASSERTMSG(bf != NULL, "no buf for txfrag"); in ath_start()
1482 ifp->if_timer = 1; in ath_start()
1490 ((ifp->if_flags & IFF_UP) && (ifp->if_flags & IFF_RUNNING)) in ath_media_change()
1496 ath_init(ifp->if_softc); /* XXX lose error */ in ath_media_change()
1510 "AES-OCB", in ath_keyprint()
1511 "AES-CCM", in ath_keyprint()
1518 printf("%s: [%02u] %-7s ", tag, ix, ciphers[hk->kv_type]); in ath_keyprint()
1519 for (i = 0, n = hk->kv_len; i < n; i++) in ath_keyprint()
1520 printf("%02x", hk->kv_val[i]); in ath_keyprint()
1522 if (hk->kv_type == HAL_CIPHER_TKIP) { in ath_keyprint()
1524 for (i = 0; i < sizeof(hk->kv_mic); i++) in ath_keyprint()
1525 printf("%02x", hk->kv_mic[i]); in ath_keyprint()
1542 struct ath_hal *ah = sc->sc_ah; in ath_keyset_tkip()
1544 KASSERTMSG(k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP, in ath_keyset_tkip()
1545 "got a non-TKIP key, cipher %u", k->wk_cipher->ic_cipher); in ath_keyset_tkip()
1546 if ((k->wk_flags & IEEE80211_KEY_XR) == IEEE80211_KEY_XR) { in ath_keyset_tkip()
1547 if (sc->sc_splitmic) { in ath_keyset_tkip()
1552 memcpy(hk->kv_mic, k->wk_txmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
1553 KEYPRINTF(sc, k->wk_keyix, hk, zerobssid); in ath_keyset_tkip()
1554 if (!ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, in ath_keyset_tkip()
1558 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
1559 KEYPRINTF(sc, k->wk_keyix+32, hk, mac); in ath_keyset_tkip()
1561 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix+32), in ath_keyset_tkip()
1569 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
1570 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
1571 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
1572 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac); in ath_keyset_tkip()
1574 } else if (k->wk_flags & IEEE80211_KEY_XMIT) { in ath_keyset_tkip()
1575 if (sc->sc_splitmic) { in ath_keyset_tkip()
1580 memcpy(hk->kv_mic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
1582 memcpy(hk->kv_txmic, k->wk_txmic, sizeof(hk->kv_txmic)); in ath_keyset_tkip()
1583 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
1584 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), hk, mac); in ath_keyset_tkip()
1585 } else if (k->wk_flags & IEEE80211_KEY_RECV) { in ath_keyset_tkip()
1586 memcpy(hk->kv_mic, k->wk_rxmic, sizeof(hk->kv_mic)); in ath_keyset_tkip()
1587 KEYPRINTF(sc, k->wk_keyix, hk, mac); in ath_keyset_tkip()
1588 return ath_hal_keyset(ah, k->wk_keyix, hk, mac); in ath_keyset_tkip()
1610 (u_int8_t) -1, /* 4 is not allocated */ in ath_keyset()
1614 struct ath_hal *ah = sc->sc_ah; in ath_keyset()
1615 const struct ieee80211_cipher *cip = k->wk_cipher; in ath_keyset()
1622 * Software crypto uses a "clear key" so non-crypto in ath_keyset()
1626 if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0) { in ath_keyset()
1627 KASSERTMSG(cip->ic_cipher < N(ciphermap), in ath_keyset()
1628 "invalid cipher type %u", cip->ic_cipher); in ath_keyset()
1629 hk.kv_type = ciphermap[cip->ic_cipher]; in ath_keyset()
1630 hk.kv_len = k->wk_keylen; in ath_keyset()
1631 memcpy(hk.kv_val, k->wk_key, k->wk_keylen); in ath_keyset()
1635 if ((k->wk_flags & IEEE80211_KEY_GROUP) && sc->sc_mcastkey) { in ath_keyset()
1639 * the high bit set instead of the app-specified address. in ath_keyset()
1641 IEEE80211_ADDR_COPY(gmac, bss->ni_macaddr); in ath_keyset()
1648 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0)) { in ath_keyset()
1651 KEYPRINTF(sc, k->wk_keyix, &hk, mac); in ath_keyset()
1652 return ath_hal_keyset(ah, ATH_KEY(k->wk_keyix), &hk, mac); in ath_keyset()
1668 KASSERTMSG(sc->sc_splitmic, "key cache !split"); in key_alloc_2pair()
1670 for (i = 0; i < N(sc->sc_keymap)/4; i++) { in key_alloc_2pair()
1671 u_int8_t b = sc->sc_keymap[i]; in key_alloc_2pair()
1683 if (isset(sc->sc_keymap, keyix+32) || in key_alloc_2pair()
1684 isset(sc->sc_keymap, keyix+64) || in key_alloc_2pair()
1685 isset(sc->sc_keymap, keyix+32+64)) { in key_alloc_2pair()
1689 /* no slots were appropriate, advance */ in key_alloc_2pair()
1694 setbit(sc->sc_keymap, keyix); in key_alloc_2pair()
1695 setbit(sc->sc_keymap, keyix+64); in key_alloc_2pair()
1696 setbit(sc->sc_keymap, keyix+32); in key_alloc_2pair()
1697 setbit(sc->sc_keymap, keyix+32+64); in key_alloc_2pair()
1723 KASSERTMSG(!sc->sc_splitmic, "key cache split"); in key_alloc_pair()
1725 for (i = 0; i < N(sc->sc_keymap)/4; i++) { in key_alloc_pair()
1726 uint8_t b = sc->sc_keymap[i]; in key_alloc_pair()
1737 if (isset(sc->sc_keymap, keyix+64)) { in key_alloc_pair()
1741 /* no slots were appropriate, advance */ in key_alloc_pair()
1746 setbit(sc->sc_keymap, keyix); in key_alloc_pair()
1747 setbit(sc->sc_keymap, keyix+64); in key_alloc_pair()
1771 for (i = 0; i < N(sc->sc_keymap); i++) { in key_alloc_single()
1772 u_int8_t b = sc->sc_keymap[i]; in key_alloc_single()
1780 setbit(sc->sc_keymap, keyix); in key_alloc_single()
1805 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_key_alloc()
1816 * multi-station operation. in ath_key_alloc()
1818 if ((k->wk_flags & IEEE80211_KEY_GROUP) && !sc->sc_mcastkey) { in ath_key_alloc()
1819 if (!(&ic->ic_nw_keys[0] <= k && in ath_key_alloc()
1820 k < &ic->ic_nw_keys[IEEE80211_WEP_NKID])) { in ath_key_alloc()
1827 * XXX we pre-allocate the global keys so in ath_key_alloc()
1828 * have no way to check if they've already been allocated. in ath_key_alloc()
1830 *keyix = *rxkeyix = k - ic->ic_nw_keys; in ath_key_alloc()
1838 * a pass-through slot on the 5211 and 5212. The 5210 does in ath_key_alloc()
1839 * not support pass-through cache entries and we map all in ath_key_alloc()
1842 if (k->wk_flags & IEEE80211_KEY_SWCRYPT) { in ath_key_alloc()
1844 } else if (k->wk_cipher->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_alloc()
1845 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) { in ath_key_alloc()
1846 if (sc->sc_splitmic) in ath_key_alloc()
1861 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_key_delete()
1862 struct ath_hal *ah = sc->sc_ah; in ath_key_delete()
1863 const struct ieee80211_cipher *cip = k->wk_cipher; in ath_key_delete()
1864 u_int keyix = k->wk_keyix; in ath_key_delete()
1868 if (!device_has_power(sc->sc_dev)) { in ath_key_delete()
1869 aprint_error_dev(sc->sc_dev, "deleting keyix %d w/o power\n", in ath_key_delete()
1870 k->wk_keyix); in ath_key_delete()
1877 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_delete()
1878 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && sc->sc_splitmic) in ath_key_delete()
1885 clrbit(sc->sc_keymap, keyix); in ath_key_delete()
1886 if (cip->ic_cipher == IEEE80211_CIPHER_TKIP && in ath_key_delete()
1887 (k->wk_flags & IEEE80211_KEY_SWMIC) == 0) { in ath_key_delete()
1888 clrbit(sc->sc_keymap, keyix+64); /* TX key MIC */ in ath_key_delete()
1889 if (sc->sc_splitmic) { in ath_key_delete()
1891 clrbit(sc->sc_keymap, keyix+32); in ath_key_delete()
1892 clrbit(sc->sc_keymap, keyix+32+64); in ath_key_delete()
1907 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_key_set()
1909 if (!device_has_power(sc->sc_dev)) { in ath_key_set()
1910 aprint_error_dev(sc->sc_dev, "setting keyix %d w/o power\n", in ath_key_set()
1911 k->wk_keyix); in ath_key_set()
1913 return ath_keyset(sc, k, mac, ic->ic_bss); in ath_key_set()
1925 struct ifnet *ifp = ic->ic_ifp; in ath_key_update_begin()
1926 struct ath_softc *sc = ifp->if_softc; in ath_key_update_begin()
1930 tasklet_disable(&sc->sc_rxtq); in ath_key_update_begin()
1932 sc->sc_flags |= ATH_KEY_UPDATING; in ath_key_update_begin()
1938 struct ifnet *ifp = ic->ic_ifp; in ath_key_update_end()
1939 struct ath_softc *sc = ifp->if_softc; in ath_key_update_end()
1942 sc->sc_flags &= ~ATH_KEY_UPDATING; in ath_key_update_end()
1944 tasklet_enable(&sc->sc_rxtq); in ath_key_update_end()
1959 * - when operating in adhoc mode so the 802.11 layer creates
1961 * - when operating in station mode for collecting rssi data when
1963 * - when scanning
1968 struct ieee80211com *ic = &sc->sc_ic; in ath_calcrxfilter()
1969 struct ath_hal *ah = sc->sc_ah; in ath_calcrxfilter()
1970 struct ifnet *ifp = &sc->sc_if; in ath_calcrxfilter()
1975 if (ic->ic_opmode != IEEE80211_M_STA) in ath_calcrxfilter()
1977 if (ic->ic_opmode != IEEE80211_M_HOSTAP && in ath_calcrxfilter()
1978 (ifp->if_flags & IFF_PROMISC)) in ath_calcrxfilter()
1980 if (ifp->if_flags & IFF_PROMISC) in ath_calcrxfilter()
1982 if (ic->ic_opmode == IEEE80211_M_STA || in ath_calcrxfilter()
1983 ic->ic_opmode == IEEE80211_M_IBSS || in ath_calcrxfilter()
1992 struct ethercom *ec = &sc->sc_ec; in ath_mode_init()
1993 struct ifnet *ifp = &sc->sc_if; in ath_mode_init()
1994 struct ieee80211com *ic = &sc->sc_ic; in ath_mode_init()
1995 struct ath_hal *ah = sc->sc_ah; in ath_mode_init()
2003 rfilt = ath_calcrxfilter(sc, ic->ic_state); in ath_mode_init()
2013 &ic->ic_crypto.cs_nw_keys[i], in ath_mode_init()
2014 ic->ic_myaddr); in ath_mode_init()
2019 * Handle any link-level address change. Note that we only in ath_mode_init()
2026 IEEE80211_ADDR_COPY(ic->ic_myaddr, CLLADDR(sc->sc_if.if_sadl)); in ath_mode_init()
2027 ath_hal_setmac(ah, ic->ic_myaddr); in ath_mode_init()
2030 ifp->if_flags &= ~IFF_ALLMULTI; in ath_mode_init()
2037 if (!IEEE80211_ADDR_EQ(enm->enm_addrlo, enm->enm_addrhi)) { in ath_mode_init()
2039 ifp->if_flags |= IFF_ALLMULTI; in ath_mode_init()
2042 dl = enm->enm_addrlo; in ath_mode_init()
2065 struct ieee80211com *ic = &sc->sc_ic; in ath_setslottime()
2066 struct ath_hal *ah = sc->sc_ah; in ath_setslottime()
2068 if (ic->ic_flags & IEEE80211_F_SHSLOT) in ath_setslottime()
2072 sc->sc_updateslot = OK; in ath_setslottime()
2082 struct ath_softc *sc = ifp->if_softc; in ath_updateslot()
2083 struct ieee80211com *ic = &sc->sc_ic; in ath_updateslot()
2090 if (ic->ic_opmode == IEEE80211_M_HOSTAP) in ath_updateslot()
2091 sc->sc_updateslot = UPDATE; in ath_updateslot()
2119 #define ATH_EXPONENT_TO_VALUE(v) ((1<<(v))-1) in ath_beaconq_config()
2120 struct ieee80211com *ic = &sc->sc_ic; in ath_beaconq_config()
2121 struct ath_hal *ah = sc->sc_ah; in ath_beaconq_config()
2124 ath_hal_gettxqueueprops(ah, sc->sc_bhalq, &qi); in ath_beaconq_config()
2125 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { in ath_beaconq_config()
2134 &ic->ic_wme.wme_chanParams.cap_wmeParams[WME_AC_BE]; in ath_beaconq_config()
2138 qi.tqi_aifs = wmep->wmep_aifsn; in ath_beaconq_config()
2139 qi.tqi_cwmin = 2*ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin); in ath_beaconq_config()
2140 qi.tqi_cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax); in ath_beaconq_config()
2143 if (!ath_hal_settxqueueprops(ah, sc->sc_bhalq, &qi)) { in ath_beaconq_config()
2144 device_printf(sc->sc_dev, "unable to update parameters for " in ath_beaconq_config()
2148 ath_hal_resettxqueue(ah, sc->sc_bhalq); /* push to h/w */ in ath_beaconq_config()
2160 struct ieee80211com *ic = ni->ni_ic; in ath_beacon_alloc()
2161 struct ath_buf *bf; in ath_beacon_alloc() local
2165 bf = STAILQ_FIRST(&sc->sc_bbuf); in ath_beacon_alloc()
2166 if (bf == NULL) { in ath_beacon_alloc()
2167 DPRINTF(sc, ATH_DEBUG_BEACON, "%s: no dma buffers\n", __func__); in ath_beacon_alloc()
2168 sc->sc_stats.ast_be_nombuf++; /* XXX */ in ath_beacon_alloc()
2172 * NB: the beacon data buffer must be 32-bit aligned; in ath_beacon_alloc()
2176 m = ieee80211_beacon_alloc(ic, ni, &sc->sc_boff); in ath_beacon_alloc()
2180 sc->sc_stats.ast_be_nombuf++; in ath_beacon_alloc()
2183 error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m, in ath_beacon_alloc()
2186 bf->bf_m = m; in ath_beacon_alloc()
2187 bf->bf_node = ieee80211_ref_node(ni); in ath_beacon_alloc()
2198 ath_beacon_setup(struct ath_softc *sc, struct ath_buf *bf) in ath_beacon_setup() argument
2201 (((_ic)->ic_flags & (IEEE80211_F_SHPREAMBLE | IEEE80211_F_USEBARKER))\ in ath_beacon_setup()
2203 struct ieee80211_node *ni = bf->bf_node; in ath_beacon_setup()
2204 struct ieee80211com *ic = ni->ni_ic; in ath_beacon_setup()
2205 struct mbuf *m = bf->bf_m; in ath_beacon_setup()
2206 struct ath_hal *ah = sc->sc_ah; in ath_beacon_setup()
2213 __func__, m, m->m_len); in ath_beacon_setup()
2216 ds = bf->bf_desc; in ath_beacon_setup()
2219 if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) { in ath_beacon_setup()
2220 ds->ds_link = HTOAH32(bf->bf_daddr); /* self-linked */ in ath_beacon_setup()
2227 antenna = sc->sc_txantenna; in ath_beacon_setup()
2229 ds->ds_link = 0; in ath_beacon_setup()
2237 if (sc->sc_txantenna == 0) in ath_beacon_setup()
2238 antenna = (sc->sc_stats.ast_be_xmit & 4 ? 2 : 1); in ath_beacon_setup()
2240 antenna = sc->sc_txantenna; in ath_beacon_setup()
2243 KASSERTMSG(bf->bf_nseg == 1, in ath_beacon_setup()
2244 "multi-segment beacon frame; nseg %u", bf->bf_nseg); in ath_beacon_setup()
2245 ds->ds_data = bf->bf_segs[0].ds_addr; in ath_beacon_setup()
2250 rix = sc->sc_minrateix; in ath_beacon_setup()
2251 rt = sc->sc_currates; in ath_beacon_setup()
2252 rate = rt->info[rix].rateCode; in ath_beacon_setup()
2254 rate |= rt->info[rix].shortPreamble; in ath_beacon_setup()
2256 , m->m_len + IEEE80211_CRC_LEN /* frame length */ in ath_beacon_setup()
2259 , ni->ni_txpower /* txpower XXX */ in ath_beacon_setup()
2261 , HAL_TXKEYIX_INVALID /* no encryption */ in ath_beacon_setup()
2263 , flags /* no ack, veol for beacons */ in ath_beacon_setup()
2269 , roundup(m->m_len, 4) /* buffer length */ in ath_beacon_setup()
2292 struct ath_buf *bf = STAILQ_FIRST(&sc->sc_bbuf); in ath_beacon_proc() local
2293 struct ieee80211_node *ni = bf->bf_node; in ath_beacon_proc()
2294 struct ieee80211com *ic = ni->ni_ic; in ath_beacon_proc()
2295 struct ath_hal *ah = sc->sc_ah; in ath_beacon_proc()
2302 if (ic->ic_opmode == IEEE80211_M_STA || in ath_beacon_proc()
2303 ic->ic_opmode == IEEE80211_M_MONITOR || in ath_beacon_proc()
2304 bf == NULL || bf->bf_m == NULL) { in ath_beacon_proc()
2305 DPRINTF(sc, ATH_DEBUG_ANY, "%s: ic_flags=%x bf=%p bf_m=%p\n", in ath_beacon_proc()
2306 __func__, ic->ic_flags, bf, bf ? bf->bf_m : NULL); in ath_beacon_proc()
2316 if (ath_hal_numtxpending(ah, sc->sc_bhalq) != 0) { in ath_beacon_proc()
2317 sc->sc_bmisscount++; in ath_beacon_proc()
2320 __func__, sc->sc_bmisscount); in ath_beacon_proc()
2321 if (sc->sc_bmisscount > 3) /* NB: 3 is a guess */ in ath_beacon_proc()
2322 TASK_RUN_OR_ENQUEUE(&sc->sc_bstucktask); in ath_beacon_proc()
2325 if (sc->sc_bmisscount != 0) { in ath_beacon_proc()
2328 __func__, sc->sc_bmisscount); in ath_beacon_proc()
2329 sc->sc_bmisscount = 0; in ath_beacon_proc()
2334 * non-zero then we need to remap the memory because in ath_beacon_proc()
2338 m = bf->bf_m; in ath_beacon_proc()
2339 ncabq = ath_hal_numtxpending(ah, sc->sc_cabq->axq_qnum); in ath_beacon_proc()
2340 if (ieee80211_beacon_update(ic, bf->bf_node, &sc->sc_boff, m, ncabq)) { in ath_beacon_proc()
2342 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_beacon_proc()
2343 error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m, in ath_beacon_proc()
2346 if_printf(&sc->sc_if, in ath_beacon_proc()
2354 * Handle slot time change when a non-ERP station joins/leaves in ath_beacon_proc()
2361 if (sc->sc_updateslot == UPDATE) in ath_beacon_proc()
2362 sc->sc_updateslot = COMMIT; /* commit next beacon */ in ath_beacon_proc()
2363 else if (sc->sc_updateslot == COMMIT) in ath_beacon_proc()
2367 * Check recent per-antenna transmit statistics and flip in ath_beacon_proc()
2369 * on the non-default antenna. in ath_beacon_proc()
2372 otherant = sc->sc_defant & 1 ? 2 : 1; in ath_beacon_proc()
2373 if (sc->sc_ant_tx[otherant] > sc->sc_ant_tx[sc->sc_defant] + 2) in ath_beacon_proc()
2375 sc->sc_ant_tx[1] = sc->sc_ant_tx[2] = 0; in ath_beacon_proc()
2380 ath_beacon_setup(sc, bf); in ath_beacon_proc()
2384 * This should never fail since we check above that no frames in ath_beacon_proc()
2387 if (!ath_hal_stoptxdma(ah, sc->sc_bhalq)) { in ath_beacon_proc()
2390 __func__, sc->sc_bhalq); in ath_beacon_proc()
2392 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, 0, in ath_beacon_proc()
2393 bf->bf_dmamap->dm_mapsize, BUS_DMASYNC_PREWRITE); in ath_beacon_proc()
2399 if (ncabq != 0 && (sc->sc_boff.bo_tim[4] & 1)) /* NB: only at DTIM */ in ath_beacon_proc()
2400 ath_hal_txstart(ah, sc->sc_cabq->axq_qnum); in ath_beacon_proc()
2401 ath_hal_puttxbuf(ah, sc->sc_bhalq, bf->bf_daddr); in ath_beacon_proc()
2402 ath_hal_txstart(ah, sc->sc_bhalq); in ath_beacon_proc()
2405 sc->sc_bhalq, (uint64_t)bf->bf_daddr, bf->bf_desc); in ath_beacon_proc()
2407 sc->sc_stats.ast_be_xmit++; in ath_beacon_proc()
2417 struct ifnet *ifp = &sc->sc_if; in ath_bstuck_proc()
2423 sc->sc_bmisscount); in ath_bstuck_proc()
2439 struct ath_buf *bf; in ath_beacon_free() local
2441 STAILQ_FOREACH(bf, &sc->sc_bbuf, bf_list) { in ath_beacon_free()
2442 if (bf->bf_m != NULL) { in ath_beacon_free()
2443 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_beacon_free()
2444 m_freem(bf->bf_m); in ath_beacon_free()
2445 bf->bf_m = NULL; in ath_beacon_free()
2447 if (bf->bf_node != NULL) { in ath_beacon_free()
2448 ieee80211_free_node(bf->bf_node); in ath_beacon_free()
2449 bf->bf_node = NULL; in ath_beacon_free()
2475 struct ath_hal *ah = sc->sc_ah; in ath_beacon_config()
2476 struct ieee80211com *ic = &sc->sc_ic; in ath_beacon_config()
2477 struct ieee80211_node *ni = ic->ic_bss; in ath_beacon_config()
2482 nexttbtt = TSF_TO_TU(LE_READ_4(ni->ni_tstamp.data + 4), in ath_beacon_config()
2483 LE_READ_4(ni->ni_tstamp.data)); in ath_beacon_config()
2485 intval = ni->ni_intval & HAL_BEACON_PERIOD; in ath_beacon_config()
2491 __func__, nexttbtt, intval, ni->ni_intval); in ath_beacon_config()
2492 if (ic->ic_opmode == IEEE80211_M_STA) { in ath_beacon_config()
2501 dtimperiod = ni->ni_dtim_period; in ath_beacon_config()
2504 dtimcount = ni->ni_dtim_count; in ath_beacon_config()
2507 cfpperiod = 1; /* NB: no PCF support yet */ in ath_beacon_config()
2517 if (--dtimcount < 0) { in ath_beacon_config()
2518 dtimcount = dtimperiod - 1; in ath_beacon_config()
2519 if (--cfpcount < 0) in ath_beacon_config()
2520 cfpcount = cfpperiod - 1; in ath_beacon_config()
2541 bs.bs_timoffset = ni->ni_timoff; in ath_beacon_config()
2550 bs.bs_bmissthreshold = howmany(ic->ic_bmisstimeout, intval); in ath_beacon_config()
2587 sc->sc_imask |= HAL_INT_BMISS; in ath_beacon_config()
2588 ath_hal_intrset(ah, sc->sc_imask); in ath_beacon_config()
2593 if (ic->ic_opmode == IEEE80211_M_IBSS) { in ath_beacon_config()
2598 * self-linked tx descriptor and let the hardware in ath_beacon_config()
2602 if (!sc->sc_hasveol) in ath_beacon_config()
2603 sc->sc_imask |= HAL_INT_SWBA; in ath_beacon_config()
2616 } else if (ic->ic_opmode == IEEE80211_M_HOSTAP) { in ath_beacon_config()
2622 sc->sc_imask |= HAL_INT_SWBA; /* beacon prepare */ in ath_beacon_config()
2626 sc->sc_bmisscount = 0; in ath_beacon_config()
2627 ath_hal_intrset(ah, sc->sc_imask); in ath_beacon_config()
2629 * When using a self-linked beacon descriptor in in ath_beacon_config()
2632 if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) in ath_beacon_config()
2635 sc->sc_syncbeacon = 0; in ath_beacon_config()
2646 ((_dd)->dd_desc_paddr + ((char *)(_ds) - (char *)(_dd)->dd_desc)) in ath_descdma_setup()
2647 struct ifnet *ifp = &sc->sc_if; in ath_descdma_setup()
2649 struct ath_buf *bf; in ath_descdma_setup() local
2655 dd->dd_name = name; in ath_descdma_setup()
2656 dd->dd_desc_len = sizeof(struct ath_desc) * nbuf * ndesc; in ath_descdma_setup()
2661 dd->dd_dmat = sc->sc_dmat; in ath_descdma_setup()
2663 error = bus_dmamem_alloc(dd->dd_dmat, dd->dd_desc_len, PAGE_SIZE, in ath_descdma_setup()
2664 0, &dd->dd_dseg, 1, &dd->dd_dnseg, 0); in ath_descdma_setup()
2668 "error %u\n", nbuf * ndesc, dd->dd_name, error); in ath_descdma_setup()
2672 error = bus_dmamem_map(dd->dd_dmat, &dd->dd_dseg, dd->dd_dnseg, in ath_descdma_setup()
2673 dd->dd_desc_len, (void **)&dd->dd_desc, BUS_DMA_COHERENT); in ath_descdma_setup()
2676 nbuf * ndesc, dd->dd_name, error); in ath_descdma_setup()
2681 error = bus_dmamap_create(dd->dd_dmat, dd->dd_desc_len, 1, in ath_descdma_setup()
2682 dd->dd_desc_len, 0, BUS_DMA_NOWAIT, &dd->dd_dmamap); in ath_descdma_setup()
2685 "error %u\n", dd->dd_name, error); in ath_descdma_setup()
2689 error = bus_dmamap_load(dd->dd_dmat, dd->dd_dmamap, dd->dd_desc, in ath_descdma_setup()
2690 dd->dd_desc_len, NULL, BUS_DMA_NOWAIT); in ath_descdma_setup()
2693 dd->dd_name, error); in ath_descdma_setup()
2697 ds = dd->dd_desc; in ath_descdma_setup()
2698 dd->dd_desc_paddr = dd->dd_dmamap->dm_segs[0].ds_addr; in ath_descdma_setup()
2700 "%s: %s DMA map: %p (%lu) -> %" PRIx64 " (%lu)\n", in ath_descdma_setup()
2701 __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, in ath_descdma_setup()
2702 (uint64_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); in ath_descdma_setup()
2706 bf = malloc(bsize, M_ATHDEV, M_WAITOK | M_ZERO); in ath_descdma_setup()
2707 dd->dd_bufptr = bf; in ath_descdma_setup()
2710 for (i = 0; i < nbuf; i++, bf++, ds += ndesc) { in ath_descdma_setup()
2711 bf->bf_desc = ds; in ath_descdma_setup()
2712 bf->bf_daddr = DS2PHYS(dd, ds); in ath_descdma_setup()
2713 error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, ndesc, in ath_descdma_setup()
2714 MCLBYTES, 0, BUS_DMA_NOWAIT, &bf->bf_dmamap); in ath_descdma_setup()
2717 "buffer %u, error %u\n", dd->dd_name, i, error); in ath_descdma_setup()
2721 STAILQ_INSERT_TAIL(head, bf, bf_list); in ath_descdma_setup()
2725 bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); in ath_descdma_setup()
2727 bus_dmamem_unmap(dd->dd_dmat, (void *)dd->dd_desc, dd->dd_desc_len); in ath_descdma_setup()
2729 bus_dmamem_free(dd->dd_dmat, &dd->dd_dseg, dd->dd_dnseg); in ath_descdma_setup()
2740 struct ath_buf *bf; in ath_descdma_cleanup() local
2743 bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); in ath_descdma_cleanup()
2744 bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); in ath_descdma_cleanup()
2745 bus_dmamem_unmap(dd->dd_dmat, (void *)dd->dd_desc, dd->dd_desc_len); in ath_descdma_cleanup()
2746 bus_dmamem_free(dd->dd_dmat, &dd->dd_dseg, dd->dd_dnseg); in ath_descdma_cleanup()
2748 STAILQ_FOREACH(bf, head, bf_list) { in ath_descdma_cleanup()
2749 m_freem(bf->bf_m); in ath_descdma_cleanup()
2750 bf->bf_m = NULL; in ath_descdma_cleanup()
2751 if (bf->bf_dmamap != NULL) { in ath_descdma_cleanup()
2752 bus_dmamap_destroy(sc->sc_dmat, bf->bf_dmamap); in ath_descdma_cleanup()
2753 bf->bf_dmamap = NULL; in ath_descdma_cleanup()
2755 ni = bf->bf_node; in ath_descdma_cleanup()
2756 bf->bf_node = NULL; in ath_descdma_cleanup()
2766 free(dd->dd_bufptr, M_ATHDEV); in ath_descdma_cleanup()
2775 error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf, in ath_desc_alloc()
2780 error = ath_descdma_setup(sc, &sc->sc_txdma, &sc->sc_txbuf, in ath_desc_alloc()
2783 ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf); in ath_desc_alloc()
2787 error = ath_descdma_setup(sc, &sc->sc_bdma, &sc->sc_bbuf, in ath_desc_alloc()
2790 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_alloc()
2791 ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf); in ath_desc_alloc()
2801 if (sc->sc_bdma.dd_desc_len != 0) in ath_desc_free()
2802 ath_descdma_cleanup(sc, &sc->sc_bdma, &sc->sc_bbuf); in ath_desc_free()
2803 if (sc->sc_txdma.dd_desc_len != 0) in ath_desc_free()
2804 ath_descdma_cleanup(sc, &sc->sc_txdma, &sc->sc_txbuf); in ath_desc_free()
2805 if (sc->sc_rxdma.dd_desc_len != 0) in ath_desc_free()
2806 ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf); in ath_desc_free()
2812 struct ieee80211com *ic = nt->nt_ic; in ath_node_alloc()
2813 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_node_alloc()
2814 const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; in ath_node_alloc()
2822 an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_node_alloc()
2826 return &an->an_node; in ath_node_alloc()
2832 struct ieee80211com *ic = ni->ni_ic; in ath_node_free()
2833 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_node_free()
2838 sc->sc_node_free(ni); in ath_node_free()
2845 ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) in ath_node_getrssi()
2846 u_int32_t avgrssi = ATH_NODE_CONST(ni)->an_avgrssi; in ath_node_getrssi()
2850 * When only one frame is received there will be no state in in ath_node_getrssi()
2856 rssi = ni->ni_rssi; in ath_node_getrssi()
2862 ath_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) in ath_rxbuf_init() argument
2864 struct ath_hal *ah = sc->sc_ah; in ath_rxbuf_init()
2869 m = bf->bf_m; in ath_rxbuf_init()
2874 * this buffer be cache-line-aligned and sized to be in ath_rxbuf_init()
2881 "%s: no mbuf/cluster\n", __func__); in ath_rxbuf_init()
2882 sc->sc_stats.ast_rx_nombuf++; in ath_rxbuf_init()
2885 bf->bf_m = m; in ath_rxbuf_init()
2886 m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; in ath_rxbuf_init()
2888 error = bus_dmamap_load_mbuf(sc->sc_dmat, in ath_rxbuf_init()
2889 bf->bf_dmamap, m, in ath_rxbuf_init()
2895 sc->sc_stats.ast_rx_busdma++; in ath_rxbuf_init()
2898 KASSERTMSG(bf->bf_nseg == 1, in ath_rxbuf_init()
2899 "multi-segment packet; nseg %u", bf->bf_nseg); in ath_rxbuf_init()
2901 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, 0, in ath_rxbuf_init()
2902 bf->bf_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); in ath_rxbuf_init()
2906 * the descriptor list with a self-linked entry so we'll in ath_rxbuf_init()
2910 * To insure the last descriptor is self-linked we create in ath_rxbuf_init()
2911 * each descriptor as self-linked and add it to the end. As in ath_rxbuf_init()
2912 * each additional descriptor is added the previous self-linked in ath_rxbuf_init()
2915 * never remove/process the last, self-linked, entry on the in ath_rxbuf_init()
2919 ds = bf->bf_desc; in ath_rxbuf_init()
2920 ds->ds_link = HTOAH32(bf->bf_daddr); /* link to self */ in ath_rxbuf_init()
2921 ds->ds_data = bf->bf_segs[0].ds_addr; in ath_rxbuf_init()
2922 /* ds->ds_vdata = mtod(m, void *); for radar */ in ath_rxbuf_init()
2924 , m->m_len /* buffer size */ in ath_rxbuf_init()
2928 if (sc->sc_rxlink != NULL) in ath_rxbuf_init()
2929 *sc->sc_rxlink = bf->bf_daddr; in ath_rxbuf_init()
2930 sc->sc_rxlink = &ds->ds_link; in ath_rxbuf_init()
2935 * Extend 15-bit time stamp from rx descriptor to
2936 * a full 64-bit TSF using the specified TSF.
2942 tsf -= 0x8000; in ath_extend_tsf()
2955 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_recv_mgmt()
2961 sc->sc_recv_mgmt(ic, m, ni, subtype, rssi, rstamp); in ath_recv_mgmt()
2965 ATH_RSSI_LPF(sc->sc_halstats.ns_avgbrssi, rssi); in ath_recv_mgmt()
2966 if (sc->sc_syncbeacon && in ath_recv_mgmt()
2967 ni == ic->ic_bss && ic->ic_state == IEEE80211_S_RUN) { in ath_recv_mgmt()
2976 if (ic->ic_opmode == IEEE80211_M_IBSS && in ath_recv_mgmt()
2977 ic->ic_state == IEEE80211_S_RUN) { in ath_recv_mgmt()
2979 ath_hal_gettsf64(sc->sc_ah)); in ath_recv_mgmt()
2989 * RUN -> RUN when this happens. in ath_recv_mgmt()
2991 if (le64toh(ni->ni_tstamp.tsf) >= tsf) { in ath_recv_mgmt()
2995 (uintmax_t)ni->ni_tstamp.tsf); in ath_recv_mgmt()
3009 struct ath_hal *ah = sc->sc_ah; in ath_setdefantenna()
3013 if (sc->sc_defant != antenna) in ath_setdefantenna()
3014 sc->sc_stats.ast_ant_defswitch++; in ath_setdefantenna()
3015 sc->sc_defant = antenna; in ath_setdefantenna()
3016 sc->sc_rxotherant = 0; in ath_setdefantenna()
3038 ((struct ath_desc *)((char *)(_sc)->sc_rxdma.dd_desc + \ in ath_rx_proc()
3039 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr))) in ath_rx_proc()
3041 struct ath_buf *bf; in ath_rx_proc() local
3042 struct ieee80211com *ic = &sc->sc_ic; in ath_rx_proc()
3043 struct ifnet *ifp = &sc->sc_if; in ath_rx_proc()
3044 struct ath_hal *ah = sc->sc_ah; in ath_rx_proc()
3060 (ifp->if_flags & IFF_PROMISC) ? HAL_RXERR_CRC|HAL_RXERR_PHY : 0; in ath_rx_proc()
3062 if (sc->sc_ic.ic_opmode == IEEE80211_M_MONITOR) in ath_rx_proc()
3064 else if (ifp->if_flags & IFF_PROMISC) in ath_rx_proc()
3069 nf = ath_hal_getchannoise(ah, &sc->sc_curchan); in ath_rx_proc()
3072 bf = STAILQ_FIRST(&sc->sc_rxbuf); in ath_rx_proc()
3073 if (bf == NULL) { /* NB: shouldn't happen */ in ath_rx_proc()
3074 if_printf(ifp, "%s: no buffer!\n", __func__); in ath_rx_proc()
3077 ds = bf->bf_desc; in ath_rx_proc()
3078 if (ds->ds_link == bf->bf_daddr) { in ath_rx_proc()
3079 /* NB: never process the self-linked entry at the end */ in ath_rx_proc()
3082 m = bf->bf_m; in ath_rx_proc()
3084 if_printf(ifp, "%s: no mbuf!\n", __func__); in ath_rx_proc()
3097 * a self-linked list to avoid rx overruns. in ath_rx_proc()
3100 bf->bf_daddr, PA2DESC(sc, ds->ds_link), in ath_rx_proc()
3101 &ds->ds_rxstat); in ath_rx_proc()
3103 if (sc->sc_debug & ATH_DEBUG_RECV_DESC) in ath_rx_proc()
3104 ath_printrxbuf(bf, status == HAL_OK); in ath_rx_proc()
3108 STAILQ_REMOVE_HEAD(&sc->sc_rxbuf, bf_list); in ath_rx_proc()
3109 if (ds->ds_rxstat.rs_more) { in ath_rx_proc()
3116 if (ic->ic_opmode != IEEE80211_M_MONITOR) { in ath_rx_proc()
3117 sc->sc_stats.ast_rx_toobig++; in ath_rx_proc()
3121 } else if (ds->ds_rxstat.rs_status != 0) { in ath_rx_proc()
3122 if (ds->ds_rxstat.rs_status & HAL_RXERR_CRC) in ath_rx_proc()
3123 sc->sc_stats.ast_rx_crcerr++; in ath_rx_proc()
3124 if (ds->ds_rxstat.rs_status & HAL_RXERR_FIFO) in ath_rx_proc()
3125 sc->sc_stats.ast_rx_fifoerr++; in ath_rx_proc()
3126 if (ds->ds_rxstat.rs_status & HAL_RXERR_PHY) { in ath_rx_proc()
3127 sc->sc_stats.ast_rx_phyerr++; in ath_rx_proc()
3128 phyerr = ds->ds_rxstat.rs_phyerr & 0x1f; in ath_rx_proc()
3129 sc->sc_stats.ast_rx_phy[phyerr]++; in ath_rx_proc()
3132 if (ds->ds_rxstat.rs_status & HAL_RXERR_DECRYPT) { in ath_rx_proc()
3135 * because there was no hardware key, then in ath_rx_proc()
3138 * parts which have no way to setup a ``clear'' in ath_rx_proc()
3143 if (ds->ds_rxstat.rs_keyix == HAL_RXKEYIX_INVALID) in ath_rx_proc()
3145 sc->sc_stats.ast_rx_badcrypt++; in ath_rx_proc()
3147 if (ds->ds_rxstat.rs_status & HAL_RXERR_MIC) { in ath_rx_proc()
3148 sc->sc_stats.ast_rx_badmic++; in ath_rx_proc()
3154 len = ds->ds_rxstat.rs_datalen; in ath_rx_proc()
3156 bus_dmamap_sync(sc->sc_dmat, in ath_rx_proc()
3157 bf->bf_dmamap, in ath_rx_proc()
3158 0, bf->bf_dmamap->dm_mapsize, in ath_rx_proc()
3162 sc->sc_splitmic ? in ath_rx_proc()
3163 ds->ds_rxstat.rs_keyix-32 : ds->ds_rxstat.rs_keyix); in ath_rx_proc()
3173 if (ds->ds_rxstat.rs_status &~ (rxerr_tap|rxerr_mon)) in ath_rx_proc()
3184 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in ath_rx_proc()
3185 0, bf->bf_dmamap->dm_mapsize, in ath_rx_proc()
3187 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_rx_proc()
3188 bf->bf_m = NULL; in ath_rx_proc()
3191 len = ds->ds_rxstat.rs_datalen; in ath_rx_proc()
3192 m->m_pkthdr.len = m->m_len = len; in ath_rx_proc()
3194 sc->sc_stats.ast_ant_rx[ds->ds_rxstat.rs_antenna]++; in ath_rx_proc()
3196 if (sc->sc_drvbpf) { in ath_rx_proc()
3206 sc->sc_stats.ast_rx_tooshort++; in ath_rx_proc()
3210 rix = ds->ds_rxstat.rs_rate; in ath_rx_proc()
3211 sc->sc_rx_th.wr_tsf = htole64( in ath_rx_proc()
3212 ath_extend_tsf(ds->ds_rxstat.rs_tstamp, tsf)); in ath_rx_proc()
3213 sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].rxflags; in ath_rx_proc()
3214 if (ds->ds_rxstat.rs_status & in ath_rx_proc()
3216 sc->sc_rx_th.wr_flags |= in ath_rx_proc()
3219 sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate; in ath_rx_proc()
3220 sc->sc_rx_th.wr_antsignal = ds->ds_rxstat.rs_rssi + nf; in ath_rx_proc()
3221 sc->sc_rx_th.wr_antnoise = nf; in ath_rx_proc()
3222 sc->sc_rx_th.wr_antenna = ds->ds_rxstat.rs_antenna; in ath_rx_proc()
3224 bpf_mtap2(sc->sc_drvbpf, &sc->sc_rx_th, in ath_rx_proc()
3225 sc->sc_rx_th_len, m, BPF_D_IN); in ath_rx_proc()
3228 if (ds->ds_rxstat.rs_status & rxerr_tap) { in ath_rx_proc()
3239 sc->sc_stats.ast_rx_tooshort++; in ath_rx_proc()
3246 sc->sc_hwmap[ds->ds_rxstat.rs_rate].ieeerate, in ath_rx_proc()
3247 ds->ds_rxstat.rs_rssi); in ath_rx_proc()
3250 m_adj(m, -IEEE80211_CRC_LEN); in ath_rx_proc()
3259 ds->ds_rxstat.rs_keyix == HAL_RXKEYIX_INVALID ? in ath_rx_proc()
3260 IEEE80211_KEYIX_NONE : ds->ds_rxstat.rs_keyix); in ath_rx_proc()
3265 ATH_RSSI_LPF(an->an_avgrssi, ds->ds_rxstat.rs_rssi); in ath_rx_proc()
3266 ATH_RSSI_LPF(sc->sc_halstats.ns_avgrssi, ds->ds_rxstat.rs_rssi); in ath_rx_proc()
3271 ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); in ath_rx_proc()
3273 if (sc->sc_diversity) { in ath_rx_proc()
3279 if (sc->sc_defant != ds->ds_rxstat.rs_antenna) { in ath_rx_proc()
3280 if (++sc->sc_rxotherant >= 3) in ath_rx_proc()
3282 ds->ds_rxstat.rs_antenna); in ath_rx_proc()
3284 sc->sc_rxotherant = 0; in ath_rx_proc()
3286 if (sc->sc_softled) { in ath_rx_proc()
3289 * heartbeat-style blink when idle. The latter in ath_rx_proc()
3294 sc->sc_rxrate = ds->ds_rxstat.rs_rate; in ath_rx_proc()
3296 } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle) in ath_rx_proc()
3304 if (ic->ic_opmode == IEEE80211_M_STA && in ath_rx_proc()
3305 ds->ds_rxstat.rs_keyix != HAL_RXKEYIX_INVALID) in ath_rx_proc()
3308 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); in ath_rx_proc()
3309 } while (ath_rxbuf_init(sc, bf) == 0); in ath_rx_proc()
3312 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan); in ath_rx_proc()
3315 TASK_RUN_OR_ENQUEUE(&sc->sc_radartask); in ath_rx_proc()
3318 sc->sc_lastrx = tsf; in ath_rx_proc()
3322 if ((ifp->if_flags & IFF_OACTIVE) == 0 && !IFQ_IS_EMPTY(&ifp->if_snd)) in ath_rx_proc()
3337 struct ath_hal *ah = sc->sc_ah; in ath_txq_setup()
3360 if (qnum == -1) { in ath_txq_setup()
3367 if (qnum >= N(sc->sc_txq)) { in ath_txq_setup()
3368 device_printf(sc->sc_dev, in ath_txq_setup()
3370 qnum, N(sc->sc_txq)); in ath_txq_setup()
3375 struct ath_txq *txq = &sc->sc_txq[qnum]; in ath_txq_setup()
3377 txq->axq_qnum = qnum; in ath_txq_setup()
3378 txq->axq_depth = 0; in ath_txq_setup()
3379 txq->axq_intrcnt = 0; in ath_txq_setup()
3380 txq->axq_link = NULL; in ath_txq_setup()
3381 STAILQ_INIT(&txq->axq_q); in ath_txq_setup()
3383 sc->sc_txqsetup |= 1<<qnum; in ath_txq_setup()
3385 return &sc->sc_txq[qnum]; in ath_txq_setup()
3404 if (ac >= N(sc->sc_ac2q)) { in ath_tx_setup()
3405 device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", in ath_tx_setup()
3406 ac, N(sc->sc_ac2q)); in ath_tx_setup()
3411 sc->sc_ac2q[ac] = txq; in ath_tx_setup()
3424 #define ATH_EXPONENT_TO_VALUE(v) ((1<<v)-1) in ath_txq_update()
3426 struct ieee80211com *ic = &sc->sc_ic; in ath_txq_update()
3427 struct ath_txq *txq = sc->sc_ac2q[ac]; in ath_txq_update()
3428 struct wmeParams *wmep = &ic->ic_wme.wme_chanParams.cap_wmeParams[ac]; in ath_txq_update()
3429 struct ath_hal *ah = sc->sc_ah; in ath_txq_update()
3432 ath_hal_gettxqueueprops(ah, txq->axq_qnum, &qi); in ath_txq_update()
3433 qi.tqi_aifs = wmep->wmep_aifsn; in ath_txq_update()
3434 qi.tqi_cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin); in ath_txq_update()
3435 qi.tqi_cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax); in ath_txq_update()
3436 qi.tqi_burstTime = ATH_TXOP_TO_US(wmep->wmep_txopLimit); in ath_txq_update()
3438 if (!ath_hal_settxqueueprops(ah, txq->axq_qnum, &qi)) { in ath_txq_update()
3439 device_printf(sc->sc_dev, "unable to update hardware queue " in ath_txq_update()
3444 ath_hal_resettxqueue(ah, txq->axq_qnum); /* push to h/w */ in ath_txq_update()
3457 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_wme_update()
3472 ath_hal_releasetxqueue(sc->sc_ah, txq->axq_qnum); in ath_tx_cleanupq()
3474 sc->sc_txqsetup &= ~(1<<txq->axq_qnum); in ath_tx_cleanupq()
3488 ath_tx_cleanupq(sc, &sc->sc_txq[i]); in ath_tx_cleanup()
3508 for (m = m0; m != NULL; m = m->m_next) in ath_defrag()
3519 n = m->m_next; in ath_defrag()
3522 if (n->m_len < M_TRAILINGSPACE(m)) { in ath_defrag()
3523 memcpy(mtod(m, char *) + m->m_len, mtod(n, void *), in ath_defrag()
3524 n->m_len); in ath_defrag()
3525 m->m_len += n->m_len; in ath_defrag()
3526 m->m_next = n->m_next; in ath_defrag()
3528 if (--curfrags <= maxfrags) in ath_defrag()
3538 prev = &m0->m_next; /* NB: not the first mbuf */ in ath_defrag()
3540 if ((n2 = n->m_next) != NULL && in ath_defrag()
3541 n->m_len + n2->m_len < MCLBYTES) { in ath_defrag()
3545 bcopy(mtod(n, void *), mtod(m, void *), n->m_len); in ath_defrag()
3546 bcopy(mtod(n2, void *), mtod(m, char *) + n->m_len, in ath_defrag()
3547 n2->m_len); in ath_defrag()
3548 m->m_len = n->m_len + n2->m_len; in ath_defrag()
3549 m->m_next = n2->m_next; in ath_defrag()
3553 if (--curfrags <= maxfrags) /* +1 cl -2 mbufs */ in ath_defrag()
3561 prev = &n->m_next; in ath_defrag()
3564 * No place where we can collapse to a cluster; punt. in ath_defrag()
3582 for (i = 0; i < rt->rateCount; i++) in ath_tx_findrix()
3583 if ((rt->info[i].dot11Rate & IEEE80211_RATE_VAL) == rate) in ath_tx_findrix()
3594 next = m->m_nextpkt; in ath_freetx()
3595 m->m_nextpkt = NULL; in ath_freetx()
3606 return len - (hdrlen & 3); in deduct_pad_bytes()
3610 ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, in ath_tx_start() argument
3613 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_start()
3614 struct ath_hal *ah = sc->sc_ah; in ath_tx_start()
3615 struct ifnet *ifp = &sc->sc_if; in ath_tx_start()
3616 const struct chanAccParams *cap = &ic->ic_wme.wme_chanParams; in ath_tx_start()
3633 iswep = wh->i_fc[1] & IEEE80211_FC1_WEP; in ath_tx_start()
3634 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in ath_tx_start()
3635 isfrag = m0->m_flags & M_FRAG; in ath_tx_start()
3641 pktlen = deduct_pad_bytes(m0->m_pkthdr.len, hdrlen); in ath_tx_start()
3667 * added to it prior to entry so m0->m_pkthdr.len above will in ath_tx_start()
3671 cip = k->wk_cipher; in ath_tx_start()
3672 hdrlen += cip->ic_header; in ath_tx_start()
3673 pktlen += cip->ic_header + cip->ic_trailer; in ath_tx_start()
3675 if ((k->wk_flags & IEEE80211_KEY_SWMIC) == 0 && !isfrag) in ath_tx_start()
3676 pktlen += cip->ic_miclen; in ath_tx_start()
3677 keyix = k->wk_keyix; in ath_tx_start()
3681 } else if (ni->ni_ucastkey.wk_cipher == &ieee80211_cipher_none) { in ath_tx_start()
3685 keyix = ni->ni_ucastkey.wk_keyix; in ath_tx_start()
3697 error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m0, in ath_tx_start()
3701 bf->bf_nseg = ATH_TXDESC+1; in ath_tx_start()
3703 sc->sc_stats.ast_tx_busdma++; in ath_tx_start()
3713 sc->sc_stats.ast_tx_linear++; in ath_tx_start()
3717 sc->sc_stats.ast_tx_nombuf++; in ath_tx_start()
3721 error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m0, in ath_tx_start()
3724 sc->sc_stats.ast_tx_busdma++; in ath_tx_start()
3728 KASSERTMSG(bf->bf_nseg <= ATH_TXDESC, in ath_tx_start()
3729 "too many segments after defrag; nseg %u", bf->bf_nseg); in ath_tx_start()
3730 } else if (bf->bf_nseg == 0) { /* null packet, discard */ in ath_tx_start()
3731 sc->sc_stats.ast_tx_nodata++; in ath_tx_start()
3736 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, 0, in ath_tx_start()
3737 bf->bf_dmamap->dm_mapsize, BUS_DMASYNC_PREWRITE); in ath_tx_start()
3738 bf->bf_m = m0; in ath_tx_start()
3739 bf->bf_node = ni; /* NB: held reference */ in ath_tx_start()
3742 ds = bf->bf_desc; in ath_tx_start()
3743 rt = sc->sc_currates; in ath_tx_start()
3744 KASSERTMSG(rt != NULL, "no rate table, mode %u", sc->sc_curmode); in ath_tx_start()
3751 if ((ic->ic_flags & IEEE80211_F_SHPREAMBLE) && in ath_tx_start()
3752 (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) && !ismcast) { in ath_tx_start()
3754 sc->sc_stats.ast_tx_shortpre++; in ath_tx_start()
3761 ismrr = 0; /* default no multi-rate retry*/ in ath_tx_start()
3766 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { in ath_tx_start()
3768 subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; in ath_tx_start()
3777 rix = sc->sc_minrateix; in ath_tx_start()
3778 txrate = rt->info[rix].rateCode; in ath_tx_start()
3780 txrate |= rt->info[rix].shortPreamble; in ath_tx_start()
3783 if (ni->ni_flags & IEEE80211_NODE_QOS) { in ath_tx_start()
3792 rix = sc->sc_minrateix; in ath_tx_start()
3793 txrate = rt->info[rix].rateCode; in ath_tx_start()
3795 txrate |= rt->info[rix].shortPreamble; in ath_tx_start()
3798 if (ni->ni_flags & IEEE80211_NODE_QOS) { in ath_tx_start()
3817 if (ic->ic_mcast_rate != sc->sc_mcastrate) { in ath_tx_start()
3818 sc->sc_mcastrix = in ath_tx_start()
3819 ath_tx_findrix(rt, ic->ic_mcast_rate); in ath_tx_start()
3820 sc->sc_mcastrate = ic->ic_mcast_rate; in ath_tx_start()
3822 rix = sc->sc_mcastrix; in ath_tx_start()
3823 txrate = rt->info[rix].rateCode; in ath_tx_start()
3828 sc->sc_txrate = txrate; /* for LED blinking */ in ath_tx_start()
3833 if (cap->cap_wmeParams[pri].wmep_noackPolicy) in ath_tx_start()
3838 wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); in ath_tx_start()
3843 txq = sc->sc_ac2q[pri]; in ath_tx_start()
3846 * When servicing one or more stations in power-save mode in ath_tx_start()
3850 if (ismcast && ic->ic_ps_sta) { in ath_tx_start()
3851 txq = sc->sc_cabq; in ath_tx_start()
3859 flags |= HAL_TXDESC_NOACK; /* no ack on broad/multicast */ in ath_tx_start()
3860 } else if (pktlen > ic->ic_rtsthreshold) { in ath_tx_start()
3862 cix = rt->info[rix].controlRate; in ath_tx_start()
3863 sc->sc_stats.ast_tx_rts++; in ath_tx_start()
3866 sc->sc_stats.ast_tx_noack++; in ath_tx_start()
3873 if ((ic->ic_flags & IEEE80211_F_USEPROT) && in ath_tx_start()
3874 rt->info[rix].phy == IEEE80211_T_OFDM && in ath_tx_start()
3877 if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) in ath_tx_start()
3879 else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) in ath_tx_start()
3889 cix = rt->info[sc->sc_protrix].controlRate; in ath_tx_start()
3891 cix = rt->info[sc->sc_protrix].controlRate; in ath_tx_start()
3892 sc->sc_stats.ast_tx_protect++; in ath_tx_start()
3900 (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL) { in ath_tx_start()
3906 dur = rt->info[rix].spAckDuration; in ath_tx_start()
3908 dur = rt->info[rix].lpAckDuration; in ath_tx_start()
3909 if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG) { in ath_tx_start()
3911 KASSERTMSG(m0->m_nextpkt != NULL, "no fragment"); in ath_tx_start()
3918 deduct_pad_bytes(m0->m_nextpkt->m_pkthdr.len, in ath_tx_start()
3919 hdrlen) - in ath_tx_start()
3920 deduct_pad_bytes(m0->m_pkthdr.len, hdrlen) + pktlen, in ath_tx_start()
3926 * fragment by disabling multi-rate retry which updates in ath_tx_start()
3927 * duration based on the multi-rate duration table. in ath_tx_start()
3931 *(u_int16_t *)wh->i_dur = htole16(dur); in ath_tx_start()
3946 ctsrate = rt->info[cix].rateCode; in ath_tx_start()
3957 ctsrate |= rt->info[cix].shortPreamble; in ath_tx_start()
3959 ctsduration += rt->info[cix].spAckDuration; in ath_tx_start()
3963 ctsduration += rt->info[rix].spAckDuration; in ath_tx_start()
3966 ctsduration += rt->info[cix].lpAckDuration; in ath_tx_start()
3970 ctsduration += rt->info[rix].lpAckDuration; in ath_tx_start()
3973 * Must disable multi-rate retry when using RTS/CTS. in ath_tx_start()
3981 ieee80211_dump_pkt(mtod(m0, void *), m0->m_len, in ath_tx_start()
3982 sc->sc_hwmap[txrate].ieeerate, -1); in ath_tx_start()
3983 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); in ath_tx_start()
3984 if (sc->sc_drvbpf) { in ath_tx_start()
3987 sc->sc_tx_th.wt_tsf = htole64(tsf); in ath_tx_start()
3988 sc->sc_tx_th.wt_flags = sc->sc_hwmap[txrate].txflags; in ath_tx_start()
3990 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; in ath_tx_start()
3992 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_FRAG; in ath_tx_start()
3993 sc->sc_tx_th.wt_rate = sc->sc_hwmap[txrate].ieeerate; in ath_tx_start()
3994 sc->sc_tx_th.wt_txpower = ni->ni_txpower; in ath_tx_start()
3995 sc->sc_tx_th.wt_antenna = sc->sc_txantenna; in ath_tx_start()
3997 bpf_mtap2(sc->sc_drvbpf, &sc->sc_tx_th, sc->sc_tx_th_len, m0, in ath_tx_start()
4017 txq->axq_intrcnt = 0; in ath_tx_start()
4018 } else if (++txq->axq_intrcnt >= sc->sc_txintrperiod) { in ath_tx_start()
4020 txq->axq_intrcnt = 0; in ath_tx_start()
4031 , ni->ni_txpower /* txpower */ in ath_tx_start()
4034 , sc->sc_txantenna /* antenna mode */ in ath_tx_start()
4039 bf->bf_flags = flags; in ath_tx_start()
4041 * Setup the multi-rate retry state only when we're in ath_tx_start()
4044 * when the hardware supports multi-rate retry and in ath_tx_start()
4054 for (i = 0; i < bf->bf_nseg; i++, ds++) { in ath_tx_start()
4055 ds->ds_data = bf->bf_segs[i].ds_addr; in ath_tx_start()
4056 if (i == bf->bf_nseg - 1) in ath_tx_start()
4057 ds->ds_link = 0; in ath_tx_start()
4059 ds->ds_link = bf->bf_daddr + sizeof(*ds) * (i + 1); in ath_tx_start()
4061 , bf->bf_segs[i].ds_len /* segment length */ in ath_tx_start()
4063 , i == bf->bf_nseg - 1 /* last segment */ in ath_tx_start()
4074 __func__, i, ds->ds_link, ds->ds_data, in ath_tx_start()
4075 ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1]); in ath_tx_start()
4082 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list); in ath_tx_start()
4083 if (txq->axq_link == NULL) { in ath_tx_start()
4084 ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); in ath_tx_start()
4087 txq->axq_qnum, (uint64_t)bf->bf_daddr, bf->bf_desc, in ath_tx_start()
4088 txq->axq_depth); in ath_tx_start()
4090 *txq->axq_link = HTOAH32(bf->bf_daddr); in ath_tx_start()
4093 __func__, txq->axq_qnum, txq->axq_link, in ath_tx_start()
4094 (uint64_t)bf->bf_daddr, bf->bf_desc, txq->axq_depth); in ath_tx_start()
4096 txq->axq_link = &bf->bf_desc[bf->bf_nseg - 1].ds_link; in ath_tx_start()
4101 if (txq != sc->sc_cabq) in ath_tx_start()
4102 ath_hal_txstart(ah, txq->axq_qnum); in ath_tx_start()
4114 struct ath_hal *ah = sc->sc_ah; in ath_tx_processq()
4115 struct ieee80211com *ic = &sc->sc_ic; in ath_tx_processq()
4116 struct ath_buf *bf; in ath_tx_processq() local
4124 __func__, txq->axq_qnum, in ath_tx_processq()
4125 (void *)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), in ath_tx_processq()
4126 txq->axq_link); in ath_tx_processq()
4130 txq->axq_intrcnt = 0; /* reset periodic desc intr count */ in ath_tx_processq()
4131 bf = STAILQ_FIRST(&txq->axq_q); in ath_tx_processq()
4132 if (bf == NULL) { in ath_tx_processq()
4133 txq->axq_link = NULL; in ath_tx_processq()
4137 ds0 = &bf->bf_desc[0]; in ath_tx_processq()
4138 ds = &bf->bf_desc[bf->bf_nseg - 1]; in ath_tx_processq()
4139 status = ath_hal_txprocdesc(ah, ds, &ds->ds_txstat); in ath_tx_processq()
4140 if (sc->sc_debug & ATH_DEBUG_XMIT_DESC) in ath_tx_processq()
4141 ath_printtxbuf(bf, status == HAL_OK); in ath_tx_processq()
4149 ni = bf->bf_node; in ath_tx_processq()
4152 if (ds->ds_txstat.ts_status == 0) { in ath_tx_processq()
4153 u_int8_t txant = ds->ds_txstat.ts_antenna; in ath_tx_processq()
4154 sc->sc_stats.ast_ant_tx[txant]++; in ath_tx_processq()
4155 sc->sc_ant_tx[txant]++; in ath_tx_processq()
4156 if (ds->ds_txstat.ts_rate & HAL_TXSTAT_ALTRATE) in ath_tx_processq()
4157 sc->sc_stats.ast_tx_altrate++; in ath_tx_processq()
4158 sc->sc_stats.ast_tx_rssi = in ath_tx_processq()
4159 ds->ds_txstat.ts_rssi; in ath_tx_processq()
4160 ATH_RSSI_LPF(sc->sc_halstats.ns_avgtxrssi, in ath_tx_processq()
4161 ds->ds_txstat.ts_rssi); in ath_tx_processq()
4162 pri = M_WME_GETAC(bf->bf_m); in ath_tx_processq()
4164 ic->ic_wme.wme_hipri_traffic++; in ath_tx_processq()
4165 ni->ni_inact = ni->ni_inact_reload; in ath_tx_processq()
4167 if (ds->ds_txstat.ts_status & HAL_TXERR_XRETRY) in ath_tx_processq()
4168 sc->sc_stats.ast_tx_xretries++; in ath_tx_processq()
4169 if (ds->ds_txstat.ts_status & HAL_TXERR_FIFO) in ath_tx_processq()
4170 sc->sc_stats.ast_tx_fifoerr++; in ath_tx_processq()
4171 if (ds->ds_txstat.ts_status & HAL_TXERR_FILT) in ath_tx_processq()
4172 sc->sc_stats.ast_tx_filtered++; in ath_tx_processq()
4174 sr = ds->ds_txstat.ts_shortretry; in ath_tx_processq()
4175 lr = ds->ds_txstat.ts_longretry; in ath_tx_processq()
4176 sc->sc_stats.ast_tx_shortretry += sr; in ath_tx_processq()
4177 sc->sc_stats.ast_tx_longretry += lr; in ath_tx_processq()
4181 if ((ds->ds_txstat.ts_status & HAL_TXERR_FILT) == 0 && in ath_tx_processq()
4182 (bf->bf_flags & HAL_TXDESC_NOACK) == 0) { in ath_tx_processq()
4187 if (ds->ds_txstat.ts_status == 0) in ath_tx_processq()
4200 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, 0, in ath_tx_processq()
4201 bf->bf_dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); in ath_tx_processq()
4202 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_tx_processq()
4203 m_freem(bf->bf_m); in ath_tx_processq()
4204 bf->bf_m = NULL; in ath_tx_processq()
4205 bf->bf_node = NULL; in ath_tx_processq()
4208 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_tx_processq()
4209 sc->sc_if.if_flags &= ~IFF_OACTIVE; in ath_tx_processq()
4224 * Deferred processing of transmit interrupt; special-cased
4231 struct ifnet *ifp = &sc->sc_if; in ath_tx_proc_q0()
4236 if (txqactive(sc->sc_ah, 0) && ath_tx_processq(sc, &sc->sc_txq[0]) > 0) in ath_tx_proc_q0()
4237 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0()
4239 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0()
4240 ath_tx_processq(sc, sc->sc_cabq); in ath_tx_proc_q0()
4242 if (sc->sc_softled) in ath_tx_proc_q0()
4255 * Deferred processing of transmit interrupt; special-cased
4256 * for four hardware queues, 0-3 (e.g. 5212 w/ WME support).
4262 struct ifnet *ifp = &sc->sc_if; in ath_tx_proc_q0123()
4272 if (txqactive(sc->sc_ah, 0)) in ath_tx_proc_q0123()
4273 nacked += ath_tx_processq(sc, &sc->sc_txq[0]); in ath_tx_proc_q0123()
4274 if (txqactive(sc->sc_ah, 1)) in ath_tx_proc_q0123()
4275 nacked += ath_tx_processq(sc, &sc->sc_txq[1]); in ath_tx_proc_q0123()
4276 if (txqactive(sc->sc_ah, 2)) in ath_tx_proc_q0123()
4277 nacked += ath_tx_processq(sc, &sc->sc_txq[2]); in ath_tx_proc_q0123()
4278 if (txqactive(sc->sc_ah, 3)) in ath_tx_proc_q0123()
4279 nacked += ath_tx_processq(sc, &sc->sc_txq[3]); in ath_tx_proc_q0123()
4280 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum)) in ath_tx_proc_q0123()
4281 ath_tx_processq(sc, sc->sc_cabq); in ath_tx_proc_q0123()
4283 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc_q0123()
4286 if (sc->sc_softled) in ath_tx_proc_q0123()
4305 struct ifnet *ifp = &sc->sc_if; in ath_tx_proc()
4316 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i)) in ath_tx_proc()
4317 nacked += ath_tx_processq(sc, &sc->sc_txq[i]); in ath_tx_proc()
4319 sc->sc_lastrx = ath_hal_gettsf64(sc->sc_ah); in ath_tx_proc()
4322 if (sc->sc_softled) in ath_tx_proc()
4337 struct ath_hal *ah = sc->sc_ah; in ath_tx_draintxq()
4339 struct ath_buf *bf; in ath_tx_draintxq() local
4348 bf = STAILQ_FIRST(&txq->axq_q); in ath_tx_draintxq()
4349 if (bf == NULL) { in ath_tx_draintxq()
4350 txq->axq_link = NULL; in ath_tx_draintxq()
4356 ds = &bf->bf_desc[bf->bf_nseg - 1]; in ath_tx_draintxq()
4357 if (sc->sc_debug & ATH_DEBUG_RESET) in ath_tx_draintxq()
4358 ath_printtxbuf(bf, in ath_tx_draintxq()
4359 ath_hal_txprocdesc(ah, bf->bf_desc, in ath_tx_draintxq()
4360 &ds->ds_txstat) == HAL_OK); in ath_tx_draintxq()
4361 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in ath_tx_draintxq()
4362 m_freem(bf->bf_m); in ath_tx_draintxq()
4363 bf->bf_m = NULL; in ath_tx_draintxq()
4364 ni = bf->bf_node; in ath_tx_draintxq()
4365 bf->bf_node = NULL; in ath_tx_draintxq()
4373 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); in ath_tx_draintxq()
4374 sc->sc_if.if_flags &= ~IFF_OACTIVE; in ath_tx_draintxq()
4382 struct ath_hal *ah = sc->sc_ah; in ath_tx_stopdma()
4384 (void) ath_hal_stoptxdma(ah, txq->axq_qnum); in ath_tx_stopdma()
4386 __func__, txq->axq_qnum, in ath_tx_stopdma()
4387 (void *)(uintptr_t) ath_hal_gettxbuf(ah, txq->axq_qnum), in ath_tx_stopdma()
4388 txq->axq_link); in ath_tx_stopdma()
4397 struct ath_hal *ah = sc->sc_ah; in ath_draintxq()
4401 if (device_is_active(sc->sc_dev)) { in ath_draintxq()
4403 (void) ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_draintxq()
4406 (void *)(uintptr_t) ath_hal_gettxbuf(ah, sc->sc_bhalq)); in ath_draintxq()
4409 ath_tx_stopdma(sc, &sc->sc_txq[i]); in ath_draintxq()
4413 ath_tx_draintxq(sc, &sc->sc_txq[i]); in ath_draintxq()
4423 ((struct ath_desc *)((char *)(_sc)->sc_rxdma.dd_desc + \ in ath_stoprecv()
4424 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr))) in ath_stoprecv()
4425 struct ath_hal *ah = sc->sc_ah; in ath_stoprecv()
4431 if (sc->sc_debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) { in ath_stoprecv()
4432 struct ath_buf *bf; in ath_stoprecv() local
4435 (void *)(uintptr_t) ath_hal_getrxbuf(ah), sc->sc_rxlink); in ath_stoprecv()
4436 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { in ath_stoprecv()
4437 struct ath_desc *ds = bf->bf_desc; in ath_stoprecv()
4439 bf->bf_daddr, PA2DESC(sc, ds->ds_link), in ath_stoprecv()
4440 &ds->ds_rxstat); in ath_stoprecv()
4441 if (status == HAL_OK || (sc->sc_debug & ATH_DEBUG_FATAL)) in ath_stoprecv()
4442 ath_printrxbuf(bf, status == HAL_OK); in ath_stoprecv()
4445 sc->sc_rxlink = NULL; /* just in case */ in ath_stoprecv()
4455 struct ath_hal *ah = sc->sc_ah; in ath_startrecv()
4456 struct ath_buf *bf; in ath_startrecv() local
4458 sc->sc_rxlink = NULL; in ath_startrecv()
4459 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { in ath_startrecv()
4460 int error = ath_rxbuf_init(sc, bf); in ath_startrecv()
4469 bf = STAILQ_FIRST(&sc->sc_rxbuf); in ath_startrecv()
4470 ath_hal_putrxbuf(ah, bf->bf_daddr); in ath_startrecv()
4473 ath_hal_startpcurecv(ah); /* re-enable PCU/DMA engine */ in ath_startrecv()
4483 struct ieee80211com *ic = &sc->sc_ic; in ath_chan_change()
4492 if (mode != sc->sc_curmode) in ath_chan_change()
4508 sc->sc_tx_th.wt_chan_freq = sc->sc_rx_th.wr_chan_freq = in ath_chan_change()
4509 htole16(chan->ic_freq); in ath_chan_change()
4510 sc->sc_tx_th.wt_chan_flags = sc->sc_rx_th.wr_chan_flags = in ath_chan_change()
4524 struct ath_hal *ah = sc->sc_ah;
4529 if_printf(&sc->sc_if,
4539 sc->sc_curchan.privFlags |= CHANNEL_DFS_CLEAR;
4540 sc->sc_if.if_flags &= ~IFF_OACTIVE;
4541 if_printf(&sc->sc_if,
4545 callout_reset(&sc->sc_dfs_ch, 2 * hz, ath_dfswait, sc);
4558 struct ath_hal *ah = sc->sc_ah; in ath_chan_set()
4559 struct ieee80211com *ic = &sc->sc_ic; in ath_chan_set()
4567 hchan.channel = chan->ic_freq; in ath_chan_set()
4571 "%s: %u (%u MHz, hal flags 0x%x) -> %u (%u MHz, hal flags 0x%x)\n", in ath_chan_set()
4573 ath_hal_mhz2ieee(ah, sc->sc_curchan.channel, in ath_chan_set()
4574 sc->sc_curchan.channelFlags), in ath_chan_set()
4575 sc->sc_curchan.channel, sc->sc_curchan.channelFlags, in ath_chan_set()
4578 if (hchan.channel != sc->sc_curchan.channel || in ath_chan_set()
4579 hchan.channelFlags != sc->sc_curchan.channelFlags) { in ath_chan_set()
4585 * hardware at the new frequency, and then re-enable in ath_chan_set()
4591 if (!ath_hal_reset(ah, ic->ic_opmode, &hchan, AH_TRUE, &status)) { in ath_chan_set()
4592 if_printf(ic->ic_ifp, "%s: unable to reset " in ath_chan_set()
4595 chan->ic_freq, chan->ic_flags, hchan.channelFlags); in ath_chan_set()
4598 sc->sc_curchan = hchan; in ath_chan_set()
4601 sc->sc_calinterval = 1; in ath_chan_set()
4602 sc->sc_caltries = 0; in ath_chan_set()
4605 * Re-enable rx framework. in ath_chan_set()
4608 if_printf(&sc->sc_if, in ath_chan_set()
4617 ic->ic_ibss_chan = chan; in ath_chan_set()
4625 if (ic->ic_opmode == IEEE80211_M_HOSTAP) { in ath_chan_set()
4627 (((_c)->privFlags & (CHANNEL_DFS | CHANNEL_DFS_CLEAR)) == CHANNEL_DFS) in ath_chan_set()
4628 if (DFS_AND_NOT_CLEAR(&sc->sc_curchan)) { in ath_chan_set()
4629 if_printf(&sc->sc_if, in ath_chan_set()
4632 sc->sc_if.if_flags |= IFF_OACTIVE; in ath_chan_set()
4633 callout_reset(&sc->sc_dfs_ch, in ath_chan_set()
4636 callout_stop(&sc->sc_dfs_ch); in ath_chan_set()
4642 * Re-enable interrupts. in ath_chan_set()
4644 ath_hal_intrset(ah, sc->sc_imask); in ath_chan_set()
4653 struct ieee80211com *ic = &sc->sc_ic; in ath_next_scan()
4659 if (ic->ic_state == IEEE80211_S_SCAN) in ath_next_scan()
4672 struct ath_hal *ah = sc->sc_ah; in ath_calibrate()
4676 sc->sc_stats.ast_per_cal++; in ath_calibrate()
4687 sc->sc_stats.ast_per_rfgain++; in ath_calibrate()
4688 ath_reset(&sc->sc_if); in ath_calibrate()
4690 if (!ath_hal_calibrate(ah, &sc->sc_curchan, &iqCalDone)) { in ath_calibrate()
4693 __func__, sc->sc_curchan.channel); in ath_calibrate()
4694 sc->sc_stats.ast_per_calfail++; in ath_calibrate()
4706 if (iqCalDone || sc->sc_calinterval >= ath_calinterval) { in ath_calibrate()
4707 sc->sc_caltries = 0; in ath_calibrate()
4708 sc->sc_calinterval = ath_calinterval; in ath_calibrate()
4709 } else if (sc->sc_caltries > 4) { in ath_calibrate()
4710 sc->sc_caltries = 0; in ath_calibrate()
4711 sc->sc_calinterval <<= 1; in ath_calibrate()
4712 if (sc->sc_calinterval > ath_calinterval) in ath_calibrate()
4713 sc->sc_calinterval = ath_calinterval; in ath_calibrate()
4715 KASSERTMSG(0 < sc->sc_calinterval && in ath_calibrate()
4716 sc->sc_calinterval <= ath_calinterval, in ath_calibrate()
4717 "bad calibration interval %u", sc->sc_calinterval); in ath_calibrate()
4721 sc->sc_calinterval, iqCalDone ? "" : "!", sc->sc_caltries); in ath_calibrate()
4722 sc->sc_caltries++; in ath_calibrate()
4723 callout_reset(&sc->sc_cal_ch, sc->sc_calinterval * hz, in ath_calibrate()
4731 struct ifnet *ifp = ic->ic_ifp; in ath_newstate()
4732 struct ath_softc *sc = ifp->if_softc; in ath_newstate()
4733 struct ath_hal *ah = sc->sc_ah; in ath_newstate()
4746 DPRINTF(sc, ATH_DEBUG_STATE, "%s: %s -> %s\n", __func__, in ath_newstate()
4747 ieee80211_state_name[ic->ic_state], in ath_newstate()
4750 callout_stop(&sc->sc_scan_ch); in ath_newstate()
4751 callout_stop(&sc->sc_cal_ch); in ath_newstate()
4753 callout_stop(&sc->sc_dfs_ch); in ath_newstate()
4758 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
4762 ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL); in ath_newstate()
4769 ni = ic->ic_bss; in ath_newstate()
4770 error = ath_chan_set(sc, ic->ic_curchan); in ath_newstate()
4775 bssid = ifp->if_broadcastaddr; in ath_newstate()
4777 bssid = ni->ni_bssid; in ath_newstate()
4782 if (nstate == IEEE80211_S_RUN && ic->ic_opmode == IEEE80211_M_STA) in ath_newstate()
4783 ath_hal_setassocid(ah, bssid, ni->ni_associd); in ath_newstate()
4786 if (ic->ic_flags & IEEE80211_F_PRIVACY) { in ath_newstate()
4798 if (ic->ic_opmode == IEEE80211_M_MONITOR) { in ath_newstate()
4805 , ic->ic_flags in ath_newstate()
4806 , ni->ni_intval in ath_newstate()
4807 , ether_sprintf(ni->ni_bssid) in ath_newstate()
4808 , ni->ni_capinfo in ath_newstate()
4809 , ieee80211_chan2ieee(ic, ic->ic_curchan)); in ath_newstate()
4811 switch (ic->ic_opmode) { in ath_newstate()
4820 * transition from RUN->RUN that means we may in ath_newstate()
4823 ath_hal_stoptxdma(ah, sc->sc_bhalq); in ath_newstate()
4832 * starting an ibss/bss so there's no need to delay. in ath_newstate()
4834 if (ic->ic_opmode == IEEE80211_M_IBSS && in ath_newstate()
4835 ic->ic_bss->ni_tstamp.tsf != 0) in ath_newstate()
4836 sc->sc_syncbeacon = 1; in ath_newstate()
4844 if ((ic->ic_flags & IEEE80211_F_PRIVACY) == 0 && in ath_newstate()
4845 sc->sc_hasclrkey && in ath_newstate()
4846 ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE) in ath_newstate()
4853 sc->sc_syncbeacon = 1; in ath_newstate()
4866 sc->sc_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
4867 sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
4868 sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; in ath_newstate()
4871 sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS)); in ath_newstate()
4872 sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); in ath_newstate()
4878 error = sc->sc_newstate(ic, nstate, arg); in ath_newstate()
4884 callout_reset(&sc->sc_cal_ch, sc->sc_calinterval * hz, in ath_newstate()
4888 callout_reset(&sc->sc_scan_ch, (ath_dwelltime * hz) / 1000, in ath_newstate()
4906 struct ieee80211com *ic = ni->ni_ic; in ath_setup_stationkey()
4907 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_setup_stationkey()
4910 if (!ath_key_alloc(ic, &ni->ni_ucastkey, &keyix, &rxkeyix)) { in ath_setup_stationkey()
4914 * this also means no h/w compression. in ath_setup_stationkey()
4919 ni->ni_ucastkey.wk_keyix = keyix; in ath_setup_stationkey()
4920 ni->ni_ucastkey.wk_rxkeyix = rxkeyix; in ath_setup_stationkey()
4921 /* NB: this will create a pass-thru key entry */ in ath_setup_stationkey()
4922 ath_keyset(sc, &ni->ni_ucastkey, ni->ni_macaddr, ic->ic_bss); in ath_setup_stationkey()
4927 * Setup driver-specific state for a newly associated node.
4928 * Note that we're called also on a re-associate, the isnew
4934 struct ieee80211com *ic = ni->ni_ic; in ath_newassoc()
4935 struct ath_softc *sc = ic->ic_ifp->if_softc; in ath_newassoc()
4939 (ic->ic_flags & IEEE80211_F_PRIVACY) == 0 && sc->sc_hasclrkey) { in ath_newassoc()
4940 KASSERTMSG(ni->ni_ucastkey.wk_keyix == IEEE80211_KEYIX_NONE, in ath_newassoc()
4942 ni->ni_ucastkey.wk_keyix); in ath_newassoc()
4952 struct ieee80211com *ic = &sc->sc_ic; in ath_getchannels()
4953 struct ifnet *ifp = &sc->sc_if; in ath_getchannels()
4954 struct ath_hal *ah = sc->sc_ah; in ath_getchannels()
4980 ix = ath_hal_mhz2ieee(ah, c->channel, c->channelFlags); in ath_getchannels()
4983 ix, c->channel, c->channelFlags); in ath_getchannels()
4991 ix, c->channel, c->channelFlags); in ath_getchannels()
5000 flags = c->channelFlags & COMPAT; in ath_getchannels()
5001 if (c->channelFlags & CHANNEL_STURBO) in ath_getchannels()
5003 if (ic->ic_channels[ix].ic_freq == 0) { in ath_getchannels()
5004 ic->ic_channels[ix].ic_freq = c->channel; in ath_getchannels()
5005 ic->ic_channels[ix].ic_flags = flags; in ath_getchannels()
5008 ic->ic_channels[ix].ic_flags |= flags; in ath_getchannels()
5021 sc->sc_blinking = 0; in ath_led_done()
5025 * Turn the LED off: flip the pin and then set a timer so no
5033 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon); in ath_led_off()
5034 callout_reset(&sc->sc_ledtimer, sc->sc_ledoff, ath_led_done, sc); in ath_led_off()
5044 ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, sc->sc_ledon); in ath_led_blink()
5045 sc->sc_blinking = 1; in ath_led_blink()
5046 sc->sc_ledoff = off; in ath_led_blink()
5047 callout_reset(&sc->sc_ledtimer, on, ath_led_off, sc); in ath_led_blink()
5054 sc->sc_ledevent = ticks; /* time of last event */ in ath_led_event()
5055 if (sc->sc_blinking) /* don't interrupt active blink */ in ath_led_event()
5059 ath_led_blink(sc, sc->sc_hwmap[0].ledon, in ath_led_event()
5060 sc->sc_hwmap[0].ledoff); in ath_led_event()
5063 ath_led_blink(sc, sc->sc_hwmap[sc->sc_txrate].ledon, in ath_led_event()
5064 sc->sc_hwmap[sc->sc_txrate].ledoff); in ath_led_event()
5067 ath_led_blink(sc, sc->sc_hwmap[sc->sc_rxrate].ledon, in ath_led_event()
5068 sc->sc_hwmap[sc->sc_rxrate].ledoff); in ath_led_event()
5077 struct ieee80211com *ic = &sc->sc_ic; in ath_update_txpow()
5078 struct ath_hal *ah = sc->sc_ah; in ath_update_txpow()
5081 if (sc->sc_curtxpow != ic->ic_txpowlimit) { in ath_update_txpow()
5082 ath_hal_settxpowlimit(ah, ic->ic_txpowlimit); in ath_update_txpow()
5085 ic->ic_txpowlimit = sc->sc_curtxpow = txpow; in ath_update_txpow()
5090 (void)ath_hal_getmaxtxpow(sc->sc_ah, &txpow); in ath_update_txpow()
5091 ic->ic_bss->ni_txpower = txpow; in ath_update_txpow()
5100 if (rt->rateCount > IEEE80211_RATE_MAXSIZE) { in rate_setup()
5103 __func__, rt->rateCount, IEEE80211_RATE_MAXSIZE); in rate_setup()
5106 maxrates = rt->rateCount; in rate_setup()
5108 rs->rs_rates[i] = rt->info[i].dot11Rate; in rate_setup()
5109 rs->rs_nrates = maxrates; in rate_setup()
5115 struct ath_hal *ah = sc->sc_ah; in ath_rate_setup()
5116 struct ieee80211com *ic = &sc->sc_ic; in ath_rate_setup()
5141 sc->sc_rates[mode] = rt; in ath_rate_setup()
5143 rate_setup(sc, rt, &ic->ic_sup_rates[mode]); in ath_rate_setup()
5177 memset(sc->sc_rixmap, 0xff, sizeof(sc->sc_rixmap)); in ath_setcurmode()
5178 rt = sc->sc_rates[mode]; in ath_setcurmode()
5179 KASSERTMSG(rt != NULL, "no h/w rate set for phy mode %u", mode); in ath_setcurmode()
5180 for (i = 0; i < rt->rateCount; i++) in ath_setcurmode()
5181 sc->sc_rixmap[rt->info[i].dot11Rate & IEEE80211_RATE_VAL] = i; in ath_setcurmode()
5182 memset(sc->sc_hwmap, 0, sizeof(sc->sc_hwmap)); in ath_setcurmode()
5184 u_int8_t ix = rt->rateCodeToIndex[i]; in ath_setcurmode()
5186 sc->sc_hwmap[i].ledon = (500 * hz) / 1000; in ath_setcurmode()
5187 sc->sc_hwmap[i].ledoff = (130 * hz) / 1000; in ath_setcurmode()
5190 sc->sc_hwmap[i].ieeerate = in ath_setcurmode()
5191 rt->info[ix].dot11Rate & IEEE80211_RATE_VAL; in ath_setcurmode()
5192 sc->sc_hwmap[i].txflags = IEEE80211_RADIOTAP_F_DATAPAD; in ath_setcurmode()
5193 if (rt->info[ix].shortPreamble || in ath_setcurmode()
5194 rt->info[ix].phy == IEEE80211_T_OFDM) in ath_setcurmode()
5195 sc->sc_hwmap[i].txflags |= IEEE80211_RADIOTAP_F_SHORTPRE; in ath_setcurmode()
5197 sc->sc_hwmap[i].rxflags = sc->sc_hwmap[i].txflags | in ath_setcurmode()
5199 /* setup blink rate table to avoid per-packet lookup */ in ath_setcurmode()
5200 for (j = 0; j < N(blinkrates)-1; j++) in ath_setcurmode()
5201 if (blinkrates[j].rate == sc->sc_hwmap[i].ieeerate) in ath_setcurmode()
5205 sc->sc_hwmap[i].ledon = (blinkrates[j].timeOn * hz) / 1000; in ath_setcurmode()
5206 sc->sc_hwmap[i].ledoff = (blinkrates[j].timeOff * hz) / 1000; in ath_setcurmode()
5208 sc->sc_currates = rt; in ath_setcurmode()
5209 sc->sc_curmode = mode; in ath_setcurmode()
5215 sc->sc_protrix = ath_tx_findrix(rt, 2*2); in ath_setcurmode()
5217 sc->sc_protrix = ath_tx_findrix(rt, 2*1); in ath_setcurmode()
5219 sc->sc_minrateix = 0; in ath_setcurmode()
5224 sc->sc_mcastrix = ath_tx_findrix(rt, sc->sc_ic.ic_mcast_rate); in ath_setcurmode()
5225 sc->sc_mcastrate = sc->sc_ic.ic_mcast_rate; in ath_setcurmode()
5232 ath_printrxbuf(struct ath_buf *bf, int done) in ath_printrxbuf() argument
5237 for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) { in ath_printrxbuf()
5240 (uint64_t)bf->bf_daddr + sizeof (struct ath_desc) * i, in ath_printrxbuf()
5241 ds->ds_link, ds->ds_data, in ath_printrxbuf()
5242 ds->ds_ctl0, ds->ds_ctl1, in ath_printrxbuf()
5243 ds->ds_hw[0], ds->ds_hw[1], in ath_printrxbuf()
5244 ds->ds_rxstat.rs_status, ds->ds_rxstat.rs_keyix, in ath_printrxbuf()
5245 !done ? ' ' : (ds->ds_rxstat.rs_status == 0) ? '*' : '!'); in ath_printrxbuf()
5250 ath_printtxbuf(struct ath_buf *bf, int done) in ath_printtxbuf() argument
5255 for (i = 0, ds = bf->bf_desc; i < bf->bf_nseg; i++, ds++) { in ath_printtxbuf()
5259 (uint64_t)bf->bf_daddr + sizeof (struct ath_desc) * i, in ath_printtxbuf()
5260 ds->ds_link, ds->ds_data, in ath_printtxbuf()
5261 ds->ds_ctl0, ds->ds_ctl1, in ath_printtxbuf()
5262 ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3], in ath_printtxbuf()
5263 !done ? ' ' : (ds->ds_txstat.ts_status == 0) ? '*' : '!'); in ath_printtxbuf()
5271 struct ath_softc *sc = ifp->if_softc; in ath_watchdog()
5272 struct ieee80211com *ic = &sc->sc_ic; in ath_watchdog()
5276 ifp->if_timer = 0; in ath_watchdog()
5277 if ((ifp->if_flags & IFF_RUNNING) == 0 || in ath_watchdog()
5278 !device_is_active(sc->sc_dev)) in ath_watchdog()
5283 axq = &sc->sc_txq[i]; in ath_watchdog()
5285 if (axq->axq_timer == 0) in ath_watchdog()
5287 else if (--axq->axq_timer == 0) { in ath_watchdog()
5290 "txintrperiod %d)\n", i, sc->sc_txintrperiod); in ath_watchdog()
5291 if (sc->sc_txintrperiod > 1) in ath_watchdog()
5292 sc->sc_txintrperiod--; in ath_watchdog()
5295 sc->sc_stats.ast_watchdog++; in ath_watchdog()
5298 ifp->if_timer = 1; in ath_watchdog()
5313 struct ath_hal *ah = sc->sc_ah; in ath_ioctl_diag()
5314 u_int id = ad->ad_id & ATH_DIAG_ID; in ath_ioctl_diag()
5317 u_int32_t insize = ad->ad_in_size; in ath_ioctl_diag()
5318 u_int32_t outsize = ad->ad_out_size; in ath_ioctl_diag()
5321 if (ad->ad_id & ATH_DIAG_IN) { in ath_ioctl_diag()
5326 error = copyin(ad->ad_in_data, indata, insize); in ath_ioctl_diag()
5330 if (ad->ad_id & ATH_DIAG_DYN) { in ath_ioctl_diag()
5341 if (outsize < ad->ad_out_size) in ath_ioctl_diag()
5342 ad->ad_out_size = outsize; in ath_ioctl_diag()
5344 error = copyout(outdata, ad->ad_out_data, in ath_ioctl_diag()
5345 ad->ad_out_size); in ath_ioctl_diag()
5350 if ((ad->ad_id & ATH_DIAG_IN) && indata != NULL) in ath_ioctl_diag()
5352 if ((ad->ad_id & ATH_DIAG_DYN) && outdata != NULL) in ath_ioctl_diag()
5361 ((ifp->if_flags & IFF_UP) && (ifp->if_flags & IFF_RUNNING)) in ath_ioctl()
5362 struct ath_softc *sc = ifp->if_softc; in ath_ioctl()
5363 struct ieee80211com *ic = &sc->sc_ic; in ath_ioctl()
5372 switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) { in ath_ioctl()
5386 * However trying to re-init the interface in ath_ioctl()
5403 if (ifp->if_flags & IFF_RUNNING) in ath_ioctl()
5414 stats_out = sc->sc_stats; in ath_ioctl()
5423 ifr->ifr_data, sizeof (stats_out)); in ath_ioctl()
5440 ic->ic_roaming != IEEE80211_ROAMING_MANUAL) in ath_ioctl()
5454 struct ifnet *ifp = &sc->sc_if; in ath_bpfattach()
5457 sizeof(struct ieee80211_frame) + sizeof(sc->sc_tx_th), in ath_bpfattach()
5458 &sc->sc_drvbpf); in ath_bpfattach()
5462 * XXX make header lengths a multiple of 32-bits so subsequent in ath_bpfattach()
5469 sc->sc_tx_th_len = roundup(sizeof(sc->sc_tx_th), sizeof(u_int32_t)); in ath_bpfattach()
5470 sc->sc_tx_th.wt_ihdr.it_len = htole16(sc->sc_tx_th_len); in ath_bpfattach()
5471 sc->sc_tx_th.wt_ihdr.it_present = htole32(ATH_TX_RADIOTAP_PRESENT); in ath_bpfattach()
5473 sc->sc_rx_th_len = roundup(sizeof(sc->sc_rx_th), sizeof(u_int32_t)); in ath_bpfattach()
5474 sc->sc_rx_th.wr_ihdr.it_len = htole16(sc->sc_rx_th_len); in ath_bpfattach()
5475 sc->sc_rx_th.wr_ihdr.it_present = htole32(ATH_RX_RADIOTAP_PRESENT); in ath_bpfattach()
5485 struct ifnet *ifp = &sc->sc_if; in ath_announce()
5486 struct ath_hal *ah = sc->sc_ah; in ath_announce()
5490 ah->ah_macVersion, ah->ah_macRev, in ath_announce()
5491 ah->ah_phyRev >> 4, ah->ah_phyRev & 0xf); in ath_announce()
5495 * Dual-band radio revs are returned in the 5 GHz rev number. in ath_announce()
5500 if (ah->ah_analog5GhzRev && ah->ah_analog2GhzRev) in ath_announce()
5502 ah->ah_analog5GhzRev >> 4, in ath_announce()
5503 ah->ah_analog5GhzRev & 0xf, in ath_announce()
5504 ah->ah_analog2GhzRev >> 4, in ath_announce()
5505 ah->ah_analog2GhzRev & 0xf); in ath_announce()
5507 printf(" radio %d.%d", ah->ah_analog5GhzRev >> 4, in ath_announce()
5508 ah->ah_analog5GhzRev & 0xf); in ath_announce()
5510 printf(" radio %d.%d", ah->ah_analog5GhzRev >> 4, in ath_announce()
5511 ah->ah_analog5GhzRev & 0xf); in ath_announce()
5516 struct ath_txq *txq = sc->sc_ac2q[i]; in ath_announce()
5518 txq->axq_qnum, ieee80211_wme_acnames[i]); in ath_announce()
5521 sc->sc_cabq->axq_qnum); in ath_announce()
5522 if_printf(ifp, "Use hw queue %u for beacons\n", sc->sc_bhalq); in ath_announce()