Lines Matching +full:tsc +full:- +full:irq
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
5 * Copyright (c) 2007-2008 Marvell Semiconductor, Inc.
230 ((sc->sc_debug & MWL_DEBUG_RECV) && \
231 ((sc->sc_debug & MWL_DEBUG_RECV_ALL) || !IEEE80211_IS_MGMT_BEACON(wh)))
233 (sc->sc_debug & MWL_DEBUG_XMIT)
236 if (sc->sc_debug & (m)) \
240 if (sc->sc_debug & MWL_DEBUG_KEYCACHE) \
255 * Each packet has fixed front matter: a 2-byte length
256 * of the payload, followed by a 4-address 802.11 header
274 return bus_space_read_4(sc->sc_io0t, sc->sc_io0h, off); in RD4()
281 bus_space_write_4(sc->sc_io0t, sc->sc_io0h, off, val); in WR4()
287 struct ieee80211com *ic = &sc->sc_ic; in mwl_attach()
299 mh = mwl_hal_attach(sc->sc_dev, devid, in mwl_attach()
300 sc->sc_io1h, sc->sc_io1t, sc->sc_dmat); in mwl_attach()
302 device_printf(sc->sc_dev, "unable to attach HAL\n"); in mwl_attach()
306 sc->sc_mh = mh; in mwl_attach()
309 * pick station firmware; we'll re-load firmware as in mwl_attach()
313 device_printf(sc->sc_dev, "unable to setup builtin firmware\n"); in mwl_attach()
317 if (mwl_hal_gethwspecs(mh, &sc->sc_hwspecs) != 0) { in mwl_attach()
318 device_printf(sc->sc_dev, "unable to fetch h/w specs\n"); in mwl_attach()
326 sc->sc_txantenna = 0; /* h/w default */ in mwl_attach()
327 sc->sc_rxantenna = 0; /* h/w default */ in mwl_attach()
328 sc->sc_invalid = 0; /* ready to go, enable int handling */ in mwl_attach()
329 sc->sc_ageinterval = MWL_AGEINTERVAL; in mwl_attach()
338 device_printf(sc->sc_dev, "failed to setup descriptors: %d\n", in mwl_attach()
346 callout_init(&sc->sc_timer, 1); in mwl_attach()
347 callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0); in mwl_attach()
348 mbufq_init(&sc->sc_snd, ifqmaxlen); in mwl_attach()
350 sc->sc_tq = taskqueue_create("mwl_taskq", M_NOWAIT, in mwl_attach()
351 taskqueue_thread_enqueue, &sc->sc_tq); in mwl_attach()
352 taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, in mwl_attach()
353 "%s taskq", device_get_nameunit(sc->sc_dev)); in mwl_attach()
355 NET_TASK_INIT(&sc->sc_rxtask, 0, mwl_rx_proc, sc); in mwl_attach()
356 TASK_INIT(&sc->sc_radartask, 0, mwl_radar_proc, sc); in mwl_attach()
357 TASK_INIT(&sc->sc_chanswitchtask, 0, mwl_chanswitch_proc, sc); in mwl_attach()
358 TASK_INIT(&sc->sc_bawatchdogtask, 0, mwl_bawatchdog_proc, sc); in mwl_attach()
362 device_printf(sc->sc_dev, in mwl_attach()
378 if (sc->sc_ac2q[WME_AC_VI] != NULL) in mwl_attach()
379 mwl_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_VI]); in mwl_attach()
380 if (sc->sc_ac2q[WME_AC_BE] != NULL) in mwl_attach()
381 mwl_tx_cleanupq(sc, sc->sc_ac2q[WME_AC_BE]); in mwl_attach()
382 sc->sc_ac2q[WME_AC_BE] = sc->sc_ac2q[WME_AC_BK]; in mwl_attach()
383 sc->sc_ac2q[WME_AC_VI] = sc->sc_ac2q[WME_AC_BK]; in mwl_attach()
384 sc->sc_ac2q[WME_AC_VO] = sc->sc_ac2q[WME_AC_BK]; in mwl_attach()
386 TASK_INIT(&sc->sc_txtask, 0, mwl_tx_proc, sc); in mwl_attach()
388 ic->ic_softc = sc; in mwl_attach()
389 ic->ic_name = device_get_nameunit(sc->sc_dev); in mwl_attach()
391 ic->ic_phytype = IEEE80211_T_OFDM; in mwl_attach()
392 ic->ic_opmode = IEEE80211_M_STA; in mwl_attach()
393 ic->ic_caps = in mwl_attach()
414 ic->ic_htcaps = in mwl_attach()
419 | IEEE80211_HTCAP_RXSTBC_2STREAM/* 1-2 spatial streams */ in mwl_attach()
421 | IEEE80211_HTCAP_MAXAMSDU_7935 /* max A-MSDU length */ in mwl_attach()
423 | IEEE80211_HTCAP_MAXAMSDU_3839 /* max A-MSDU length */ in mwl_attach()
431 | IEEE80211_HTC_AMPDU /* tx A-MPDU */ in mwl_attach()
432 | IEEE80211_HTC_AMSDU /* tx A-MSDU */ in mwl_attach()
440 ic->ic_cryptocaps |= IEEE80211_CRYPTO_WEP in mwl_attach()
452 ic->ic_headroom = sizeof(struct mwltxrec) - in mwl_attach()
455 IEEE80211_ADDR_COPY(ic->ic_macaddr, sc->sc_hwspecs.macAddr); in mwl_attach()
459 ic->ic_setregdomain = mwl_setregdomain; in mwl_attach()
460 ic->ic_getradiocaps = mwl_getradiocaps; in mwl_attach()
462 ic->ic_raw_xmit = mwl_raw_xmit; in mwl_attach()
463 ic->ic_newassoc = mwl_newassoc; in mwl_attach()
464 ic->ic_updateslot = mwl_updateslot; in mwl_attach()
465 ic->ic_update_mcast = mwl_update_mcast; in mwl_attach()
466 ic->ic_update_promisc = mwl_update_promisc; in mwl_attach()
467 ic->ic_wme.wme_update = mwl_wme_update; in mwl_attach()
468 ic->ic_transmit = mwl_transmit; in mwl_attach()
469 ic->ic_ioctl = mwl_ioctl; in mwl_attach()
470 ic->ic_parent = mwl_parent; in mwl_attach()
472 ic->ic_node_alloc = mwl_node_alloc; in mwl_attach()
473 sc->sc_node_cleanup = ic->ic_node_cleanup; in mwl_attach()
474 ic->ic_node_cleanup = mwl_node_cleanup; in mwl_attach()
475 sc->sc_node_drain = ic->ic_node_drain; in mwl_attach()
476 ic->ic_node_drain = mwl_node_drain; in mwl_attach()
477 ic->ic_node_getsignal = mwl_node_getsignal; in mwl_attach()
478 ic->ic_node_getmimoinfo = mwl_node_getmimoinfo; in mwl_attach()
480 ic->ic_scan_start = mwl_scan_start; in mwl_attach()
481 ic->ic_scan_end = mwl_scan_end; in mwl_attach()
482 ic->ic_set_channel = mwl_set_channel; in mwl_attach()
484 sc->sc_recv_action = ic->ic_recv_action; in mwl_attach()
485 ic->ic_recv_action = mwl_recv_action; in mwl_attach()
486 sc->sc_addba_request = ic->ic_addba_request; in mwl_attach()
487 ic->ic_addba_request = mwl_addba_request; in mwl_attach()
488 sc->sc_addba_response = ic->ic_addba_response; in mwl_attach()
489 ic->ic_addba_response = mwl_addba_response; in mwl_attach()
490 sc->sc_addba_stop = ic->ic_addba_stop; in mwl_attach()
491 ic->ic_addba_stop = mwl_addba_stop; in mwl_attach()
493 ic->ic_vap_create = mwl_vap_create; in mwl_attach()
494 ic->ic_vap_delete = mwl_vap_delete; in mwl_attach()
497 &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), in mwl_attach()
499 &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), in mwl_attach()
517 sc->sc_invalid = 1; in mwl_attach()
524 struct ieee80211com *ic = &sc->sc_ic; in mwl_detach()
542 callout_drain(&sc->sc_watchdog); in mwl_detach()
546 mwl_hal_detach(sc->sc_mh); in mwl_detach()
547 mbufq_drain(&sc->sc_snd); in mwl_detach()
563 if (clone && mwl_hal_ismbsscapable(sc->sc_mh)) { in assign_address()
566 if ((sc->sc_bssidmask & (1<<i)) == 0) in assign_address()
572 sc->sc_bssidmask |= 1<<i; in assign_address()
574 sc->sc_nbssid0++; in assign_address()
581 if (i != 0 || --sc->sc_nbssid0 == 0) in reclaim_address()
582 sc->sc_bssidmask &= ~(1<<i); in reclaim_address()
591 struct mwl_softc *sc = ic->ic_softc; in mwl_vap_create()
592 struct mwl_hal *mh = sc->sc_mh; in mwl_vap_create()
625 if (sc->sc_napvaps == 0) in mwl_vap_create()
638 mvp->mv_hvap = hvap; in mwl_vap_create()
644 TAILQ_FOREACH(apvap, &ic->ic_vaps, iv_next) in mwl_vap_create()
645 if (apvap->iv_opmode == IEEE80211_M_HOSTAP) { in mwl_vap_create()
646 mvp->mv_ap_hvap = MWL_VAP(apvap)->mv_hvap; in mwl_vap_create()
649 KASSERT(mvp->mv_ap_hvap != NULL, ("no ap vap")); in mwl_vap_create()
651 vap = &mvp->mv_vap; in mwl_vap_create()
654 mvp->mv_newstate = vap->iv_newstate; in mwl_vap_create()
655 vap->iv_newstate = mwl_newstate; in mwl_vap_create()
656 vap->iv_max_keyix = 0; /* XXX */ in mwl_vap_create()
657 vap->iv_key_alloc = mwl_key_alloc; in mwl_vap_create()
658 vap->iv_key_delete = mwl_key_delete; in mwl_vap_create()
659 vap->iv_key_set = mwl_key_set; in mwl_vap_create()
662 vap->iv_update_ps = mwl_update_ps; in mwl_vap_create()
663 mvp->mv_set_tim = vap->iv_set_tim; in mwl_vap_create()
664 vap->iv_set_tim = mwl_set_tim; in mwl_vap_create()
667 vap->iv_reset = mwl_reset; in mwl_vap_create()
668 vap->iv_update_beacon = mwl_beacon_update; in mwl_vap_create()
671 vap->iv_max_aid = MWL_MAXSTAID; in mwl_vap_create()
672 /* override default A-MPDU rx parameters */ in mwl_vap_create()
673 vap->iv_ampdu_rxmax = IEEE80211_HTCAP_MAXRXAMPDU_64K; in mwl_vap_create()
674 vap->iv_ampdu_density = IEEE80211_HTCAP_MPDUDENSITY_4; in mwl_vap_create()
680 switch (vap->iv_opmode) { in mwl_vap_create()
688 if (vap->iv_opmode == IEEE80211_M_HOSTAP || in mwl_vap_create()
689 vap->iv_opmode == IEEE80211_M_MBSS) in mwl_vap_create()
690 sc->sc_napvaps++; in mwl_vap_create()
692 sc->sc_nstavaps++; in mwl_vap_create()
695 sc->sc_nwdsvaps++; in mwl_vap_create()
703 if (sc->sc_napvaps) in mwl_vap_create()
704 ic->ic_opmode = IEEE80211_M_HOSTAP; in mwl_vap_create()
705 else if (sc->sc_nstavaps) in mwl_vap_create()
706 ic->ic_opmode = IEEE80211_M_STA; in mwl_vap_create()
708 ic->ic_opmode = opmode; in mwl_vap_create()
717 struct mwl_softc *sc = vap->iv_ic->ic_softc; in mwl_vap_delete()
718 struct mwl_hal *mh = sc->sc_mh; in mwl_vap_delete()
719 struct mwl_hal_vap *hvap = mvp->mv_hvap; in mwl_vap_delete()
720 enum ieee80211_opmode opmode = vap->iv_opmode; in mwl_vap_delete()
723 if (sc->sc_running) { in mwl_vap_delete()
733 (void) mwl_hal_delstation(hvap, vap->iv_myaddr); in mwl_vap_delete()
736 sc->sc_napvaps--; in mwl_vap_delete()
738 sc->sc_nstavaps--; in mwl_vap_delete()
740 reclaim_address(sc, vap->iv_myaddr); in mwl_vap_delete()
743 sc->sc_nwdsvaps--; in mwl_vap_delete()
750 if (sc->sc_running) in mwl_vap_delete()
751 mwl_hal_intrset(mh, sc->sc_imask); in mwl_vap_delete()
769 if (sc->sc_ic.ic_nrunning > 0) in mwl_resume()
774 ieee80211_start_all(&sc->sc_ic); /* start all vap's */ in mwl_resume()
794 struct mwl_hal *mh = sc->sc_mh; in mwl_intr()
797 if (sc->sc_invalid) { in mwl_intr()
800 * Note this can happen early on if the IRQ is shared. in mwl_intr()
809 if (status == 0) /* must be a shared irq */ in mwl_intr()
813 __func__, status, sc->sc_imask); in mwl_intr()
815 taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); in mwl_intr()
817 taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask); in mwl_intr()
819 taskqueue_enqueue(sc->sc_tq, &sc->sc_bawatchdogtask); in mwl_intr()
827 sc->sc_stats.mst_rx_badtkipicv++; in mwl_intr()
830 /* 11n aggregation queue is empty, re-fill */ in mwl_intr()
838 taskqueue_enqueue(sc->sc_tq, &sc->sc_radartask); in mwl_intr()
842 taskqueue_enqueue(sc->sc_tq, &sc->sc_chanswitchtask); in mwl_intr()
850 struct ieee80211com *ic = &sc->sc_ic; in mwl_radar_proc()
855 sc->sc_stats.mst_radardetect++; in mwl_radar_proc()
859 ieee80211_dfs_notify_radar(ic, ic->ic_curchan); in mwl_radar_proc()
867 struct ieee80211com *ic = &sc->sc_ic; in mwl_chanswitch_proc()
873 sc->sc_csapending = 0; in mwl_chanswitch_proc()
881 struct ieee80211_node *ni = sp->data[0]; in mwl_bawatchdog()
884 ieee80211_ampdu_stop(ni, sp->data[1], IEEE80211_REASON_UNSPECIFIED); in mwl_bawatchdog()
891 struct mwl_hal *mh = sc->sc_mh; in mwl_bawatchdog_proc()
895 sc->sc_stats.mst_bawatchdog++; in mwl_bawatchdog_proc()
900 sc->sc_stats.mst_bawatchdog_failed++; in mwl_bawatchdog_proc()
917 sc->sc_stats.mst_bawatchdog_empty++; in mwl_bawatchdog_proc()
927 sc->sc_stats.mst_bawatchdog_notfound++; in mwl_bawatchdog_proc()
938 hc->channel = chan->ic_ieee; in mwl_mapchan()
940 *(uint32_t *)&hc->channelFlags = 0; in mwl_mapchan()
942 hc->channelFlags.FreqBand = MWL_FREQ_BAND_2DOT4GHZ; in mwl_mapchan()
944 hc->channelFlags.FreqBand = MWL_FREQ_BAND_5GHZ; in mwl_mapchan()
946 hc->channelFlags.ChnlWidth = MWL_CH_40_MHz_WIDTH; in mwl_mapchan()
948 hc->channelFlags.ExtChnlOffset = MWL_EXT_CH_ABOVE_CTRL_CH; in mwl_mapchan()
950 hc->channelFlags.ExtChnlOffset = MWL_EXT_CH_BELOW_CTRL_CH; in mwl_mapchan()
952 hc->channelFlags.ChnlWidth = MWL_CH_20_MHz_WIDTH; in mwl_mapchan()
967 sc->sc_hwdma.rxDescRead = sc->sc_rxdma.dd_desc_paddr; in mwl_setupdma()
968 WR4(sc, sc->sc_hwspecs.rxDescRead, sc->sc_hwdma.rxDescRead); in mwl_setupdma()
969 WR4(sc, sc->sc_hwspecs.rxDescWrite, sc->sc_hwdma.rxDescRead); in mwl_setupdma()
971 for (i = 0; i < MWL_NUM_TX_QUEUES-MWL_NUM_ACK_QUEUES; i++) { in mwl_setupdma()
972 struct mwl_txq *txq = &sc->sc_txq[i]; in mwl_setupdma()
973 sc->sc_hwdma.wcbBase[i] = txq->dma.dd_desc_paddr; in mwl_setupdma()
974 WR4(sc, sc->sc_hwspecs.wcbBase[i], sc->sc_hwdma.wcbBase[i]); in mwl_setupdma()
976 sc->sc_hwdma.maxNumTxWcb = mwl_txbuf; in mwl_setupdma()
977 sc->sc_hwdma.maxNumWCB = MWL_NUM_TX_QUEUES-MWL_NUM_ACK_QUEUES; in mwl_setupdma()
979 error = mwl_hal_sethwdma(sc->sc_mh, &sc->sc_hwdma); in mwl_setupdma()
981 device_printf(sc->sc_dev, in mwl_setupdma()
995 struct ieee80211com *ic = &sc->sc_ic; in mwl_setcurchanrates()
1000 rs = ieee80211_get_suprates(ic, ic->ic_curchan); in mwl_setcurchanrates()
1002 rates.MgtRate = rs->rs_rates[0] & IEEE80211_RATE_VAL; in mwl_setcurchanrates()
1006 return mwl_hal_settxrate_auto(sc->sc_mh, &rates); in mwl_setcurchanrates()
1011 * user-settable params change and after a channel change.
1017 struct ieee80211_node *ni = vap->iv_bss; in mwl_setrates()
1018 const struct ieee80211_txparam *tp = ni->ni_txparms; in mwl_setrates()
1021 KASSERT(vap->iv_state == IEEE80211_S_RUN, ("state %d", vap->iv_state)); in mwl_setrates()
1029 rates.MgtRate = tp->mgmtrate; in mwl_setrates()
1031 rates.McastRate = tp->mcastrate; in mwl_setrates()
1034 mvp->mv_eapolformat = htole16(mwl_calcformat(rates.MgtRate, ni)); in mwl_setrates()
1036 return mwl_hal_settxrate(mvp->mv_hvap, in mwl_setrates()
1037 tp->ucastrate != IEEE80211_FIXED_RATE_NONE ? in mwl_setrates()
1048 struct ieee80211_node *ni = vap->iv_bss; in mwl_seteapolformat()
1052 KASSERT(vap->iv_state == IEEE80211_S_RUN, ("state %d", vap->iv_state)); in mwl_seteapolformat()
1054 mode = ieee80211_chan2mode(ni->ni_chan); in mwl_seteapolformat()
1056 * Use legacy rates when operating a mixed HT+non-HT bss. in mwl_seteapolformat()
1060 (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0) in mwl_seteapolformat()
1061 rate = vap->iv_txparms[IEEE80211_MODE_11A].mgmtrate; in mwl_seteapolformat()
1063 (vap->iv_flags_ht & IEEE80211_FHT_PUREN) == 0) in mwl_seteapolformat()
1064 rate = vap->iv_txparms[IEEE80211_MODE_11G].mgmtrate; in mwl_seteapolformat()
1066 rate = vap->iv_txparms[mode].mgmtrate; in mwl_seteapolformat()
1068 mvp->mv_eapolformat = htole16(mwl_calcformat(rate, ni)); in mwl_seteapolformat()
1077 switch (rd->regdomain) { in mwl_map2regioncode()
1086 if (rd->country == CTRY_SPAIN) in mwl_map2regioncode()
1088 if (rd->country == CTRY_FRANCE || rd->country == CTRY_FRANCE2) in mwl_map2regioncode()
1108 struct ieee80211com *ic = &sc->sc_ic; in mwl_hal_reset()
1109 struct mwl_hal *mh = sc->sc_mh; in mwl_hal_reset()
1111 mwl_hal_setantenna(mh, WL_ANTENNATYPE_RX, sc->sc_rxantenna); in mwl_hal_reset()
1112 mwl_hal_setantenna(mh, WL_ANTENNATYPE_TX, sc->sc_txantenna); in mwl_hal_reset()
1114 mwl_hal_setwmm(sc->sc_mh, (ic->ic_flags & IEEE80211_F_WME) != 0); in mwl_hal_reset()
1115 mwl_chan_set(sc, ic->ic_curchan); in mwl_hal_reset()
1119 (ic->ic_flags & IEEE80211_F_BURST) != 0); in mwl_hal_reset()
1121 mwl_hal_setregioncode(mh, mwl_map2regioncode(&ic->ic_regdomain)); in mwl_hal_reset()
1132 struct mwl_hal *mh = sc->sc_mh; in mwl_init()
1144 * Push vap-independent state to the firmware. in mwl_init()
1147 device_printf(sc->sc_dev, "unable to reset hardware\n"); in mwl_init()
1156 device_printf(sc->sc_dev, "unable to start recv logic\n"); in mwl_init()
1163 sc->sc_imask = MACREG_A2HRIC_BIT_RX_RDY in mwl_init()
1179 sc->sc_running = 1; in mwl_init()
1180 mwl_hal_intrset(mh, sc->sc_imask); in mwl_init()
1181 callout_reset(&sc->sc_watchdog, hz, mwl_watchdog, sc); in mwl_init()
1191 if (sc->sc_running) { in mwl_stop()
1195 sc->sc_running = 0; in mwl_stop()
1196 callout_stop(&sc->sc_watchdog); in mwl_stop()
1197 sc->sc_tx_timer = 0; in mwl_stop()
1205 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_reset_vap()
1206 struct ieee80211com *ic = vap->iv_ic; in mwl_reset_vap()
1211 mwl_hal_setrtsthreshold(hvap, vap->iv_rtsthreshold); in mwl_reset_vap()
1213 mwl_hal_sethtgi(hvap, (vap->iv_flags_ht & in mwl_reset_vap()
1215 mwl_hal_setnprot(hvap, ic->ic_htprotmode == IEEE80211_PROT_NONE ? in mwl_reset_vap()
1219 /* re-setup beacons */ in mwl_reset_vap()
1221 (vap->iv_opmode == IEEE80211_M_HOSTAP || in mwl_reset_vap()
1222 vap->iv_opmode == IEEE80211_M_MBSS || in mwl_reset_vap()
1223 vap->iv_opmode == IEEE80211_M_IBSS)) { in mwl_reset_vap()
1224 mwl_setapmode(vap, vap->iv_bss->ni_chan); in mwl_reset_vap()
1226 ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); in mwl_reset_vap()
1239 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_reset()
1243 struct ieee80211com *ic = vap->iv_ic; in mwl_reset()
1244 struct mwl_softc *sc = ic->ic_softc; in mwl_reset()
1245 struct mwl_hal *mh = sc->sc_mh; in mwl_reset()
1250 error = mwl_reset_vap(vap, vap->iv_state); in mwl_reset()
1251 mwl_hal_intrset(mh, sc->sc_imask); in mwl_reset()
1270 bf = STAILQ_FIRST(&txq->free); in mwl_gettxbuf()
1272 STAILQ_REMOVE_HEAD(&txq->free, bf_list); in mwl_gettxbuf()
1273 txq->nfree--; in mwl_gettxbuf()
1278 "%s: out of xmit buffers on q %d\n", __func__, txq->qnum); in mwl_gettxbuf()
1286 * (the firmware pre-fetches descriptors so we cannot reorder).
1291 bf->bf_m = NULL; in mwl_puttxbuf_head()
1292 bf->bf_node = NULL; in mwl_puttxbuf_head()
1294 STAILQ_INSERT_HEAD(&txq->free, bf, bf_list); in mwl_puttxbuf_head()
1295 txq->nfree++; in mwl_puttxbuf_head()
1302 bf->bf_m = NULL; in mwl_puttxbuf_tail()
1303 bf->bf_node = NULL; in mwl_puttxbuf_tail()
1305 STAILQ_INSERT_TAIL(&txq->free, bf, bf_list); in mwl_puttxbuf_tail()
1306 txq->nfree++; in mwl_puttxbuf_tail()
1313 struct mwl_softc *sc = ic->ic_softc; in mwl_transmit()
1317 if (!sc->sc_running) { in mwl_transmit()
1321 error = mbufq_enqueue(&sc->sc_snd, m); in mwl_transmit()
1341 if (!sc->sc_running || sc->sc_invalid) in mwl_start()
1344 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) { in mwl_start()
1348 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; in mwl_start()
1350 m->m_pkthdr.rcvif = NULL; /* committed, clear ref */ in mwl_start()
1355 txq = sc->sc_ac2q[M_WME_GETAC(m)]; in mwl_start()
1361 sc->sc_stats.mst_tx_qstop++; in mwl_start()
1365 "%s: tail drop on q %d\n", __func__, txq->qnum); in mwl_start()
1366 sc->sc_stats.mst_tx_qdrop++; in mwl_start()
1375 if_inc_counter(ni->ni_vap->iv_ifp, in mwl_start()
1388 mwl_hal_txstart(sc->sc_mh, 0/*XXX*/); in mwl_start()
1405 mwl_hal_txstart(sc->sc_mh, 0/*XXX*/); in mwl_start()
1413 struct ieee80211com *ic = ni->ni_ic; in mwl_raw_xmit()
1414 struct mwl_softc *sc = ic->ic_softc; in mwl_raw_xmit()
1418 if (!sc->sc_running || sc->sc_invalid) { in mwl_raw_xmit()
1428 * because we may receive non-mgt frames. in mwl_raw_xmit()
1430 txq = sc->sc_ac2q[M_WME_GETAC(m)]; in mwl_raw_xmit()
1433 sc->sc_stats.mst_tx_qstop++; in mwl_raw_xmit()
1458 mwl_hal_txstart(sc->sc_mh, 0/*XXX*/); in mwl_raw_xmit()
1486 "AES-CCM", in mwl_keyprint()
1490 printf("%s: [%u] %-7s", tag, hk->keyIndex, ciphers[hk->keyTypeId]); in mwl_keyprint()
1491 for (i = 0, n = hk->keyLen; i < n; i++) in mwl_keyprint()
1492 printf(" %02x", hk->key.aes[i]); in mwl_keyprint()
1494 if (hk->keyTypeId == KEY_TYPE_ID_TKIP) { in mwl_keyprint()
1496 for (i = 0; i < sizeof(hk->key.tkip.rxMic); i++) in mwl_keyprint()
1497 printf(" %02x", hk->key.tkip.rxMic[i]); in mwl_keyprint()
1499 for (i = 0; i < sizeof(hk->key.tkip.txMic); i++) in mwl_keyprint()
1500 printf(" %02x", hk->key.tkip.txMic[i]); in mwl_keyprint()
1502 printf(" flags 0x%x\n", hk->keyFlags); in mwl_keyprint()
1515 struct mwl_softc *sc = vap->iv_ic->ic_softc; in mwl_key_alloc()
1517 if (k->wk_keyix != IEEE80211_KEYIX_NONE || in mwl_key_alloc()
1518 (k->wk_flags & IEEE80211_KEY_GROUP)) { in mwl_key_alloc()
1542 struct mwl_softc *sc = vap->iv_ic->ic_softc; in mwl_key_delete()
1543 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_key_delete()
1549 if (vap->iv_opmode != IEEE80211_M_WDS) { in mwl_key_delete()
1553 vap->iv_opmode); in mwl_key_delete()
1556 hvap = MWL_VAP(vap)->mv_ap_hvap; in mwl_key_delete()
1560 __func__, k->wk_keyix); in mwl_key_delete()
1563 hk.keyIndex = k->wk_keyix; in mwl_key_delete()
1564 switch (k->wk_cipher->ic_cipher) { in mwl_key_delete()
1577 __func__, k->wk_cipher->ic_cipher); in mwl_key_delete()
1586 if (k->wk_flags & IEEE80211_KEY_GROUP) { in addgroupflags()
1587 if (k->wk_flags & IEEE80211_KEY_XMIT) in addgroupflags()
1588 hk->keyFlags |= KEY_FLAG_TXGROUPKEY; in addgroupflags()
1589 if (k->wk_flags & IEEE80211_KEY_RECV) in addgroupflags()
1590 hk->keyFlags |= KEY_FLAG_RXGROUPKEY; in addgroupflags()
1603 return (_mwl_key_set(vap, k, k->wk_macaddr)); in mwl_key_set()
1613 (((k)->wk_flags & (GRPXMIT|IEEE80211_KEY_RECV)) == \ in _mwl_key_set()
1615 struct mwl_softc *sc = vap->iv_ic->ic_softc; in _mwl_key_set()
1616 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in _mwl_key_set()
1617 const struct ieee80211_cipher *cip = k->wk_cipher; in _mwl_key_set()
1621 KASSERT((k->wk_flags & IEEE80211_KEY_SWCRYPT) == 0, in _mwl_key_set()
1625 if (vap->iv_opmode != IEEE80211_M_WDS) { in _mwl_key_set()
1629 vap->iv_opmode); in _mwl_key_set()
1632 hvap = MWL_VAP(vap)->mv_ap_hvap; in _mwl_key_set()
1635 hk.keyIndex = k->wk_keyix; in _mwl_key_set()
1636 switch (cip->ic_cipher) { in _mwl_key_set()
1639 hk.keyLen = k->wk_keylen; in _mwl_key_set()
1640 if (k->wk_keyix == vap->iv_def_txkey) in _mwl_key_set()
1649 hk.key.tkip.tsc.high = (uint32_t)(k->wk_keytsc >> 16); in _mwl_key_set()
1650 hk.key.tkip.tsc.low = (uint16_t)k->wk_keytsc; in _mwl_key_set()
1652 hk.keyLen = k->wk_keylen + IEEE80211_MICBUF_SIZE; in _mwl_key_set()
1658 hk.keyLen = k->wk_keylen; in _mwl_key_set()
1665 __func__, k->wk_cipher->ic_cipher); in _mwl_key_set()
1672 memcpy(hk.key.aes, k->wk_key, hk.keyLen); in _mwl_key_set()
1679 if (vap->iv_opmode == IEEE80211_M_STA) { in _mwl_key_set()
1687 macaddr = vap->iv_bss->ni_bssid; in _mwl_key_set()
1688 if ((k->wk_flags & IEEE80211_KEY_GROUP) == 0) { in _mwl_key_set()
1690 mwl_hal_keyset(hvap, &hk, vap->iv_myaddr); in _mwl_key_set()
1692 } else if (vap->iv_opmode == IEEE80211_M_WDS && in _mwl_key_set()
1693 vap->iv_state != IEEE80211_S_RUN) { in _mwl_key_set()
1700 macaddr = vap->iv_des_bssid; in _mwl_key_set()
1701 } else if ((k->wk_flags & GRPXMIT) == GRPXMIT) in _mwl_key_set()
1702 macaddr = vap->iv_myaddr; in _mwl_key_set()
1727 ETHER_FIRST_MULTI(estep, &sc->sc_ec, enm); in mwl_setmcastfilter()
1731 !IEEE80211_ADDR_EQ(enm->enm_addrlo, enm->enm_addrhi)) { in mwl_setmcastfilter()
1735 IEEE80211_ADDR_COPY(mp, enm->enm_addrlo); in mwl_setmcastfilter()
1740 mwl_hal_setmcast(sc->sc_mh, nmc, macs); in mwl_setmcastfilter()
1747 struct ieee80211com *ic = &sc->sc_ic; in mwl_mode_init()
1748 struct mwl_hal *mh = sc->sc_mh; in mwl_mode_init()
1750 mwl_hal_setpromisc(mh, ic->ic_promisc > 0); in mwl_mode_init()
1762 struct mwl_softc *sc = ic->ic_softc; in mwl_update_mcast()
1777 struct mwl_softc *sc = ic->ic_softc; in mwl_update_promisc()
1779 mwl_hal_setpromisc(sc->sc_mh, ic->ic_promisc > 0); in mwl_update_promisc()
1791 struct mwl_softc *sc = ic->ic_softc; in mwl_updateslot()
1792 struct mwl_hal *mh = sc->sc_mh; in mwl_updateslot()
1796 if (!sc->sc_running) in mwl_updateslot()
1804 if (IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) { in mwl_updateslot()
1805 if ((ic->ic_flags & IEEE80211_F_SHSLOT) == 0) in mwl_updateslot()
1807 if (ic->ic_flags & IEEE80211_F_USEPROT) in mwl_updateslot()
1809 if (ic->ic_flags & IEEE80211_F_USEBARKER) in mwl_updateslot()
1815 __func__, ic->ic_curchan->ic_freq, ic->ic_curchan->ic_flags, in mwl_updateslot()
1816 ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long", prot, in mwl_updateslot()
1817 ic->ic_flags); in mwl_updateslot()
1828 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_beacon_setup()
1829 struct ieee80211_node *ni = vap->iv_bss; in mwl_beacon_setup()
1835 mwl_hal_setbeacon(hvap, mtod(m, const void *), m->m_len); in mwl_beacon_setup()
1847 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_beacon_update()
1848 struct ieee80211com *ic = vap->iv_ic; in mwl_beacon_update()
1857 ic->ic_curhtprotmode, IEEE80211_HTINFO_OPMODE)); in mwl_beacon_update()
1877 *paddr = segs->ds_addr; in mwl_load_cb()
1889 if (nsta == 0 || mvp->mv_last_ps_sta == 0) in mwl_update_ps()
1890 mwl_hal_setpowersave_bss(mvp->mv_hvap, nsta); in mwl_update_ps()
1891 mvp->mv_last_ps_sta = nsta; in mwl_update_ps()
1900 struct ieee80211vap *vap = ni->ni_vap; in mwl_set_tim()
1903 if (mvp->mv_set_tim(ni, set)) { /* NB: state change */ in mwl_set_tim()
1904 mwl_hal_setpowersave_sta(mvp->mv_hvap, in mwl_set_tim()
1905 IEEE80211_AID(ni->ni_associd), set); in mwl_set_tim()
1925 dd->dd_name = name; in mwl_desc_setup()
1926 dd->dd_desc_len = nbuf * ndesc * descsize; in mwl_desc_setup()
1931 error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), /* parent */ in mwl_desc_setup()
1936 dd->dd_desc_len, /* maxsize */ in mwl_desc_setup()
1938 dd->dd_desc_len, /* maxsegsize */ in mwl_desc_setup()
1942 &dd->dd_dmat); in mwl_desc_setup()
1944 device_printf(sc->sc_dev, "cannot allocate %s DMA tag\n", dd->dd_name); in mwl_desc_setup()
1949 error = bus_dmamem_alloc(dd->dd_dmat, (void**) &dd->dd_desc, in mwl_desc_setup()
1951 &dd->dd_dmamap); in mwl_desc_setup()
1953 device_printf(sc->sc_dev, "unable to alloc memory for %u %s descriptors, " in mwl_desc_setup()
1954 "error %u\n", nbuf * ndesc, dd->dd_name, error); in mwl_desc_setup()
1958 error = bus_dmamap_load(dd->dd_dmat, dd->dd_dmamap, in mwl_desc_setup()
1959 dd->dd_desc, dd->dd_desc_len, in mwl_desc_setup()
1960 mwl_load_cb, &dd->dd_desc_paddr, in mwl_desc_setup()
1963 device_printf(sc->sc_dev, "unable to map %s descriptors, error %u\n", in mwl_desc_setup()
1964 dd->dd_name, error); in mwl_desc_setup()
1968 ds = dd->dd_desc; in mwl_desc_setup()
1969 memset(ds, 0, dd->dd_desc_len); in mwl_desc_setup()
1971 "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n", in mwl_desc_setup()
1972 __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, in mwl_desc_setup()
1973 (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); in mwl_desc_setup()
1977 bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); in mwl_desc_setup()
1979 bus_dma_tag_destroy(dd->dd_dmat); in mwl_desc_setup()
1988 bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); in mwl_desc_cleanup()
1989 bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); in mwl_desc_cleanup()
1990 bus_dma_tag_destroy(dd->dd_dmat); in mwl_desc_cleanup()
1998 * because the firmware pre-fetches descriptors.
2008 bf = txq->dma.dd_bufptr; in mwl_txq_reset()
2009 STAILQ_INIT(&txq->free); in mwl_txq_reset()
2011 STAILQ_INSERT_TAIL(&txq->free, bf, bf_list); in mwl_txq_reset()
2012 txq->nfree = i; in mwl_txq_reset()
2016 ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
2025 error = mwl_desc_setup(sc, "tx", &txq->dma, in mwl_txdma_setup()
2035 device_printf(sc->sc_dev, "malloc of %u tx buffers failed\n", in mwl_txdma_setup()
2039 txq->dma.dd_bufptr = bf; in mwl_txdma_setup()
2041 ds = txq->dma.dd_desc; in mwl_txdma_setup()
2043 bf->bf_desc = ds; in mwl_txdma_setup()
2044 bf->bf_daddr = DS2PHYS(&txq->dma, ds); in mwl_txdma_setup()
2045 error = bus_dmamap_create(sc->sc_dmat, BUS_DMA_NOWAIT, in mwl_txdma_setup()
2046 &bf->bf_dmamap); in mwl_txdma_setup()
2048 device_printf(sc->sc_dev, "unable to create dmamap for tx " in mwl_txdma_setup()
2063 bf = txq->dma.dd_bufptr; in mwl_txdma_cleanup()
2065 KASSERT(bf->bf_m == NULL, ("mbuf on free list")); in mwl_txdma_cleanup()
2066 KASSERT(bf->bf_node == NULL, ("node on free list")); in mwl_txdma_cleanup()
2067 if (bf->bf_dmamap != NULL) in mwl_txdma_cleanup()
2068 bus_dmamap_destroy(sc->sc_dmat, bf->bf_dmamap); in mwl_txdma_cleanup()
2070 STAILQ_INIT(&txq->free); in mwl_txdma_cleanup()
2071 txq->nfree = 0; in mwl_txdma_cleanup()
2072 if (txq->dma.dd_bufptr != NULL) { in mwl_txdma_cleanup()
2073 free(txq->dma.dd_bufptr, M_MWLDEV); in mwl_txdma_cleanup()
2074 txq->dma.dd_bufptr = NULL; in mwl_txdma_cleanup()
2076 if (txq->dma.dd_desc_len != 0) in mwl_txdma_cleanup()
2077 mwl_desc_cleanup(sc, &txq->dma); in mwl_txdma_cleanup()
2089 error = mwl_desc_setup(sc, "rx", &sc->sc_rxdma, in mwl_rxdma_setup()
2097 * This allows us to attach to mbuf's and avoid re-mapping in mwl_rxdma_setup()
2106 device_printf(sc->sc_dev, in mwl_rxdma_setup()
2112 sc->sc_rxmemsize = mwl_rxbuf*jumbosize; in mwl_rxdma_setup()
2114 error = bus_dma_tag_create(sc->sc_dmat, /* parent */ in mwl_rxdma_setup()
2119 sc->sc_rxmemsize, /* maxsize */ in mwl_rxdma_setup()
2121 sc->sc_rxmemsize, /* maxsegsize */ in mwl_rxdma_setup()
2125 &sc->sc_rxdmat); in mwl_rxdma_setup()
2127 device_printf(sc->sc_dev, "could not create rx DMA tag\n"); in mwl_rxdma_setup()
2131 error = bus_dmamem_alloc(sc->sc_rxdmat, (void**) &sc->sc_rxmem, in mwl_rxdma_setup()
2133 &sc->sc_rxmap); in mwl_rxdma_setup()
2135 device_printf(sc->sc_dev, "could not alloc %ju bytes of rx DMA memory\n", in mwl_rxdma_setup()
2136 (uintmax_t) sc->sc_rxmemsize); in mwl_rxdma_setup()
2140 error = bus_dmamap_load(sc->sc_rxdmat, sc->sc_rxmap, in mwl_rxdma_setup()
2141 sc->sc_rxmem, sc->sc_rxmemsize, in mwl_rxdma_setup()
2142 mwl_load_cb, &sc->sc_rxmem_paddr, in mwl_rxdma_setup()
2145 device_printf(sc->sc_dev, "could not load rx DMA map\n"); in mwl_rxdma_setup()
2155 device_printf(sc->sc_dev, "malloc of %u rx buffers failed\n", bsize); in mwl_rxdma_setup()
2158 sc->sc_rxdma.dd_bufptr = bf; in mwl_rxdma_setup()
2160 STAILQ_INIT(&sc->sc_rxbuf); in mwl_rxdma_setup()
2161 ds = sc->sc_rxdma.dd_desc; in mwl_rxdma_setup()
2163 bf->bf_desc = ds; in mwl_rxdma_setup()
2164 bf->bf_daddr = DS2PHYS(&sc->sc_rxdma, ds); in mwl_rxdma_setup()
2165 /* pre-assign dma buffer */ in mwl_rxdma_setup()
2166 bf->bf_data = ((uint8_t *)sc->sc_rxmem) + (i*jumbosize); in mwl_rxdma_setup()
2168 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); in mwl_rxdma_setup()
2174 SLIST_INIT(&sc->sc_rxfree); in mwl_rxdma_setup()
2176 data = ((uint8_t *)sc->sc_rxmem) + (i*jumbosize); in mwl_rxdma_setup()
2178 SLIST_INSERT_HEAD(&sc->sc_rxfree, rbuf, next); in mwl_rxdma_setup()
2179 sc->sc_nrxfree++; in mwl_rxdma_setup()
2188 if (sc->sc_rxmem_paddr != 0) { in mwl_rxdma_cleanup()
2189 bus_dmamap_unload(sc->sc_rxdmat, sc->sc_rxmap); in mwl_rxdma_cleanup()
2190 sc->sc_rxmem_paddr = 0; in mwl_rxdma_cleanup()
2192 if (sc->sc_rxmem != NULL) { in mwl_rxdma_cleanup()
2193 bus_dmamem_free(sc->sc_rxdmat, sc->sc_rxmem, sc->sc_rxmap); in mwl_rxdma_cleanup()
2194 sc->sc_rxmem = NULL; in mwl_rxdma_cleanup()
2196 if (sc->sc_rxdma.dd_bufptr != NULL) { in mwl_rxdma_cleanup()
2197 free(sc->sc_rxdma.dd_bufptr, M_MWLDEV); in mwl_rxdma_cleanup()
2198 sc->sc_rxdma.dd_bufptr = NULL; in mwl_rxdma_cleanup()
2200 if (sc->sc_rxdma.dd_desc_len != 0) in mwl_rxdma_cleanup()
2201 mwl_desc_cleanup(sc, &sc->sc_rxdma); in mwl_rxdma_cleanup()
2216 error = mwl_txdma_setup(sc, &sc->sc_txq[i]); in mwl_dma_setup()
2231 mwl_txdma_cleanup(sc, &sc->sc_txq[i]); in mwl_dma_cleanup()
2238 struct ieee80211com *ic = vap->iv_ic; in mwl_node_alloc()
2239 struct mwl_softc *sc = ic->ic_softc; in mwl_node_alloc()
2249 return &mn->mn_node; in mwl_node_alloc()
2255 struct ieee80211com *ic = ni->ni_ic; in mwl_node_cleanup()
2256 struct mwl_softc *sc = ic->ic_softc; in mwl_node_cleanup()
2260 __func__, ni, ni->ni_ic, mn->mn_staid); in mwl_node_cleanup()
2262 if (mn->mn_staid != 0) { in mwl_node_cleanup()
2263 struct ieee80211vap *vap = ni->ni_vap; in mwl_node_cleanup()
2265 if (mn->mn_hvap != NULL) { in mwl_node_cleanup()
2266 if (vap->iv_opmode == IEEE80211_M_STA) in mwl_node_cleanup()
2267 mwl_hal_delstation(mn->mn_hvap, vap->iv_myaddr); in mwl_node_cleanup()
2269 mwl_hal_delstation(mn->mn_hvap, ni->ni_macaddr); in mwl_node_cleanup()
2276 else if (vap->iv_opmode == IEEE80211_M_WDS && in mwl_node_cleanup()
2277 MWL_VAP(vap)->mv_ap_hvap != NULL) in mwl_node_cleanup()
2278 mwl_hal_delstation(MWL_VAP(vap)->mv_ap_hvap, in mwl_node_cleanup()
2279 ni->ni_macaddr); in mwl_node_cleanup()
2280 delstaid(sc, mn->mn_staid); in mwl_node_cleanup()
2281 mn->mn_staid = 0; in mwl_node_cleanup()
2283 sc->sc_node_cleanup(ni); in mwl_node_cleanup()
2299 n = rap->rxa_qframes; in mwl_ampdu_rxdma_reclaim()
2300 for (i = 0; i < rap->rxa_wnd && n > 0; i++) { in mwl_ampdu_rxdma_reclaim()
2301 m = rap->rxa_m[i]; in mwl_ampdu_rxdma_reclaim()
2304 n--; in mwl_ampdu_rxdma_reclaim()
2305 /* our dma buffers have a well-known free routine */ in mwl_ampdu_rxdma_reclaim()
2306 if ((m->m_flags & M_EXT) == 0 || in mwl_ampdu_rxdma_reclaim()
2307 m->m_ext.ext_free != mwl_ext_free) in mwl_ampdu_rxdma_reclaim()
2312 off = m->m_data - m->m_ext.ext_buf; in mwl_ampdu_rxdma_reclaim()
2313 if (off + m->m_pkthdr.len > MCLBYTES) { in mwl_ampdu_rxdma_reclaim()
2318 &m->m_ext.ext_paddr); in mwl_ampdu_rxdma_reclaim()
2327 memcpy((caddr_t) cl + off, m->m_data, m->m_pkthdr.len); in mwl_ampdu_rxdma_reclaim()
2331 m->m_flags |= M_CLUSTER | M_EXT_RW; in mwl_ampdu_rxdma_reclaim()
2334 m->m_data += off; in mwl_ampdu_rxdma_reclaim()
2350 struct ieee80211com *ic = ni->ni_ic; in mwl_node_drain()
2351 struct mwl_softc *sc = ic->ic_softc; in mwl_node_drain()
2355 __func__, ni, ni->ni_vap, mn->mn_staid); in mwl_node_drain()
2358 sc->sc_node_drain(ni); in mwl_node_drain()
2361 if (sc->sc_rxblocked && mn->mn_staid != 0 && in mwl_node_drain()
2362 (ni->ni_flags & IEEE80211_NODE_HT)) { in mwl_node_drain()
2371 rap = &ni->ni_rx_ampdu[tid]; in mwl_node_drain()
2372 if ((rap->rxa_flags & IEEE80211_AGGR_XCHGPEND) == 0) in mwl_node_drain()
2374 if (rap->rxa_qframes) in mwl_node_drain()
2383 *rssi = ni->ni_ic->ic_node_getrssi(ni); in mwl_node_getsignal()
2387 *noise = -MWL_NODE_CONST(ni)->mn_ai.nf; in mwl_node_getsignal()
2389 *noise = -95; /* XXX */ in mwl_node_getsignal()
2392 *noise = -95; /* XXX */ in mwl_node_getsignal()
2397 * Convert Hardware per-antenna rssi info to common format:
2401 * Rssi1_dBm = RSSI_dBm + 20*log10(a1) - 20*log10(amax)
2402 * We store a table that is 4*20*log10(idx) - the extra 4 is to store or
2412 (_dst) = rssi + ((logdbtbl[_src] - logdbtbl[rssi_max]) >> 2); \ in mwl_node_getmimoinfo()
2422 uint8_t rssi = mn->mn_ai.rsvd1/2; /* XXX */ in mwl_node_getmimoinfo()
2425 rssi_max = mn->mn_ai.rssi_a; in mwl_node_getmimoinfo()
2426 if (mn->mn_ai.rssi_b > rssi_max) in mwl_node_getmimoinfo()
2427 rssi_max = mn->mn_ai.rssi_b; in mwl_node_getmimoinfo()
2428 if (mn->mn_ai.rssi_c > rssi_max) in mwl_node_getmimoinfo()
2429 rssi_max = mn->mn_ai.rssi_c; in mwl_node_getmimoinfo()
2431 CVT(mi->ch[0].rssi[0], mn->mn_ai.rssi_a); in mwl_node_getmimoinfo()
2432 CVT(mi->ch[1].rssi[0], mn->mn_ai.rssi_b); in mwl_node_getmimoinfo()
2433 CVT(mi->ch[2].rssi[0], mn->mn_ai.rssi_c); in mwl_node_getmimoinfo()
2435 mi->ch[0].noise[0] = mn->mn_ai.nf_a; in mwl_node_getmimoinfo()
2436 mi->ch[1].noise[0] = mn->mn_ai.nf_b; in mwl_node_getmimoinfo()
2437 mi->ch[2].noise[0] = mn->mn_ai.nf_c; in mwl_node_getmimoinfo()
2451 buf = SLIST_FIRST(&sc->sc_rxfree); in mwl_getrxdma()
2455 sc->sc_stats.mst_rx_nodmabuf++; in mwl_getrxdma()
2458 SLIST_REMOVE_HEAD(&sc->sc_rxfree, next); in mwl_getrxdma()
2459 sc->sc_nrxfree--; in mwl_getrxdma()
2474 SLIST_INSERT_HEAD(&sc->sc_rxfree, buf, next); in mwl_putrxdma()
2475 sc->sc_nrxfree++; in mwl_putrxdma()
2484 ds = bf->bf_desc; in mwl_rxbuf_init()
2485 if (bf->bf_data == NULL) { in mwl_rxbuf_init()
2486 bf->bf_data = mwl_getrxdma(sc); in mwl_rxbuf_init()
2487 if (bf->bf_data == NULL) { in mwl_rxbuf_init()
2489 ds->RxControl = EAGLE_RXD_CTRL_OS_OWN; in mwl_rxbuf_init()
2492 sc->sc_stats.mst_rxbuf_failed++; in mwl_rxbuf_init()
2504 ds->QosCtrl = 0; in mwl_rxbuf_init()
2505 ds->RSSI = 0; in mwl_rxbuf_init()
2506 ds->Status = EAGLE_RXD_STATUS_IDLE; in mwl_rxbuf_init()
2507 ds->Channel = 0; in mwl_rxbuf_init()
2508 ds->PktLen = htole16(MWL_AGGR_SIZE); in mwl_rxbuf_init()
2509 ds->SQ2 = 0; in mwl_rxbuf_init()
2510 ds->pPhysBuffData = htole32(MWL_JUMBO_DMA_ADDR(sc, bf->bf_data)); in mwl_rxbuf_init()
2512 ds->RxControl = EAGLE_RXD_CTRL_DRIVER_OWN; in mwl_rxbuf_init()
2521 struct mwl_softc *sc = m->m_ext.ext_arg1; in mwl_ext_free()
2524 mwl_putrxdma(sc, m->m_ext.ext_buf); in mwl_ext_free()
2529 if (sc->sc_rxblocked && sc->sc_nrxfree > mwl_rxdmalow) { in mwl_ext_free()
2530 sc->sc_rxblocked = 0; in mwl_ext_free()
2531 mwl_hal_intrset(sc->sc_mh, sc->sc_imask); in mwl_ext_free()
2554 switch (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) { in mwl_anyhdrsize()
2575 ieee80211_notify_michael_failure(ni->ni_vap, wh, 0); in mwl_handlemicerror()
2588 * will give at least +/- 3dB for 2.4GHz and +/- 5dB for 5GHz.
2595 rssi = 2*(87 - rssi); /* NB: .5 dBm units */ in cvtrssi()
2603 struct ieee80211com *ic = &sc->sc_ic; in mwl_rx_proc()
2616 __func__, npending, RD4(sc, sc->sc_hwspecs.rxDescRead), in mwl_rx_proc()
2617 RD4(sc, sc->sc_hwspecs.rxDescWrite)); in mwl_rx_proc()
2618 nf = -96; /* XXX */ in mwl_rx_proc()
2619 bf = sc->sc_rxnext; in mwl_rx_proc()
2620 for (ntodo = mwl_rxquota; ntodo > 0; ntodo--) { in mwl_rx_proc()
2622 bf = STAILQ_FIRST(&sc->sc_rxbuf); in mwl_rx_proc()
2623 ds = bf->bf_desc; in mwl_rx_proc()
2624 data = bf->bf_data; in mwl_rx_proc()
2628 * will be no buffer; try again to re-populate it. in mwl_rx_proc()
2636 sc->sc_stats.mst_rx_dmabufmissing++; in mwl_rx_proc()
2641 if (ds->RxControl != EAGLE_RXD_CTRL_DMA_OWN) in mwl_rx_proc()
2644 if (sc->sc_debug & MWL_DEBUG_RECV_DESC) in mwl_rx_proc()
2647 status = ds->Status; in mwl_rx_proc()
2649 counter_u64_add(ic->ic_ierrors, 1); in mwl_rx_proc()
2650 sc->sc_stats.mst_rx_crypto++; in mwl_rx_proc()
2660 bus_dmamap_sync(sc->sc_rxdmat, sc->sc_rxmap, in mwl_rx_proc()
2663 sc->sc_stats.mst_rx_tkipmic++; in mwl_rx_proc()
2671 len = le16toh(ds->PktLen); in mwl_rx_proc()
2672 bus_dmamap_sync(sc->sc_rxdmat, sc->sc_rxmap, BUS_DMASYNC_POSTREAD); in mwl_rx_proc()
2682 /* calculate rssi early so we can re-use for each aggregate */ in mwl_rx_proc()
2683 rssi = cvtrssi(ds->RSSI); in mwl_rx_proc()
2685 pktlen = hdrlen + (len - off); in mwl_rx_proc()
2688 * IEEE80211_MIN_LEN because there is a 4-address in mwl_rx_proc()
2706 sc->sc_stats.mst_rx_nombuf++; in mwl_rx_proc()
2719 * A-MPDU as otherwise the host's view of the BA in mwl_rx_proc()
2727 mwl_hal_intrset(sc->sc_mh, in mwl_rx_proc()
2728 sc->sc_imask &~ MACREG_A2HRIC_BIT_RX_RDY); in mwl_rx_proc()
2729 sc->sc_rxblocked = 1; in mwl_rx_proc()
2734 bf->bf_data = newdata; in mwl_rx_proc()
2737 * mwl_rxbuf_init will re-setup the rx in mwl_rx_proc()
2743 m->m_data += off - hdrlen; in mwl_rx_proc()
2744 m->m_pkthdr.len = m->m_len = pktlen; in mwl_rx_proc()
2745 /* NB: dma buffer assumed read-only */ in mwl_rx_proc()
2755 *(uint16_t *)ieee80211_getqos(wh) = ds->QosCtrl; in mwl_rx_proc()
2766 if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) in mwl_rx_proc()
2767 m->m_flags |= M_WEP; in mwl_rx_proc()
2769 wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; in mwl_rx_proc()
2771 wh->i_fc[1] &= ~(IEEE80211_FC1_PROTECTED | in mwl_rx_proc()
2776 struct mwl_rx_radiotap_header *tap = &sc->sc_rx_th; in mwl_rx_proc()
2778 tap->wr_flags = 0; in mwl_rx_proc()
2779 tap->wr_rate = ds->Rate; in mwl_rx_proc()
2780 tap->wr_antsignal = rssi + nf; in mwl_rx_proc()
2781 tap->wr_antnoise = nf; in mwl_rx_proc()
2785 len, ds->Rate, rssi); in mwl_rx_proc()
2793 mn->mn_ai.rssi_a = ds->ai.rssi_a; in mwl_rx_proc()
2794 mn->mn_ai.rssi_b = ds->ai.rssi_b; in mwl_rx_proc()
2795 mn->mn_ai.rssi_c = ds->ai.rssi_c; in mwl_rx_proc()
2796 mn->mn_ai.rsvd1 = rssi; in mwl_rx_proc()
2799 if (ni->ni_flags & IEEE80211_NODE_HT) in mwl_rx_proc()
2800 m->m_flags |= M_AMPDU; in mwl_rx_proc()
2811 sc->sc_rxnext = bf; in mwl_rx_proc()
2813 if (mbufq_first(&sc->sc_snd) != NULL) { in mwl_rx_proc()
2815 mwl_hal_txstart(sc->sc_mh, 0); in mwl_rx_proc()
2827 txq->qnum = qnum; in mwl_txq_init()
2828 txq->txpri = 0; /* XXX */ in mwl_txq_init()
2831 STAILQ_INIT(&txq->free); in mwl_txq_init()
2833 STAILQ_FOREACH(bf, &txq->free, bf_list) { in mwl_txq_init()
2834 bf->bf_txq = txq; in mwl_txq_init()
2836 ds = bf->bf_desc; in mwl_txq_init()
2839 bn = STAILQ_FIRST(&txq->free); in mwl_txq_init()
2840 ds->pPhysNext = htole32(bn->bf_daddr); in mwl_txq_init()
2842 STAILQ_INIT(&txq->active); in mwl_txq_init()
2855 if (ac >= nitems(sc->sc_ac2q)) { in mwl_tx_setup()
2856 device_printf(sc->sc_dev, "AC %u out of range, max %zu!\n", in mwl_tx_setup()
2857 ac, nitems(sc->sc_ac2q)); in mwl_tx_setup()
2861 device_printf(sc->sc_dev, "mvtype %u out of range, max %u!\n", in mwl_tx_setup()
2865 txq = &sc->sc_txq[mvtype]; in mwl_tx_setup()
2867 sc->sc_ac2q[ac] = txq; in mwl_tx_setup()
2877 #define MWL_EXPONENT_TO_VALUE(v) ((1<<v)-1) in mwl_txq_update()
2878 struct ieee80211com *ic = &sc->sc_ic; in mwl_txq_update()
2880 struct mwl_txq *txq = sc->sc_ac2q[ac]; in mwl_txq_update()
2882 struct mwl_hal *mh = sc->sc_mh; in mwl_txq_update()
2888 aifs = wmep->wmep_aifsn; in mwl_txq_update()
2890 cwmin = MWL_EXPONENT_TO_VALUE(wmep->wmep_logcwmin); in mwl_txq_update()
2891 cwmax = MWL_EXPONENT_TO_VALUE(wmep->wmep_logcwmax); in mwl_txq_update()
2892 txoplim = wmep->wmep_txopLimit; /* NB: units of 32us */ in mwl_txq_update()
2894 if (mwl_hal_setedcaparams(mh, txq->qnum, cwmin, cwmax, aifs, txoplim)) { in mwl_txq_update()
2895 device_printf(sc->sc_dev, "unable to update hardware queue " in mwl_txq_update()
2910 struct mwl_softc *sc = ic->ic_softc; in mwl_wme_update()
2937 mwl_tx_cleanupq(sc, &sc->sc_txq[i]); in mwl_tx_cleanup()
2950 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0, in mwl_tx_dmasetup()
2951 bf->bf_segs, &bf->bf_nseg, in mwl_tx_dmasetup()
2955 bf->bf_nseg = MWL_TXDESC+1; in mwl_tx_dmasetup()
2957 sc->sc_stats.mst_tx_busdma++; in mwl_tx_dmasetup()
2967 sc->sc_stats.mst_tx_linear++; in mwl_tx_dmasetup()
2975 sc->sc_stats.mst_tx_nombuf++; in mwl_tx_dmasetup()
2979 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0, in mwl_tx_dmasetup()
2980 bf->bf_segs, &bf->bf_nseg, in mwl_tx_dmasetup()
2983 sc->sc_stats.mst_tx_busdma++; in mwl_tx_dmasetup()
2987 KASSERT(bf->bf_nseg <= MWL_TXDESC, in mwl_tx_dmasetup()
2988 ("too many segments after defrag; nseg %u", bf->bf_nseg)); in mwl_tx_dmasetup()
2989 } else if (bf->bf_nseg == 0) { /* null packet, discard */ in mwl_tx_dmasetup()
2990 sc->sc_stats.mst_tx_nodata++; in mwl_tx_dmasetup()
2995 __func__, m0, m0->m_pkthdr.len); in mwl_tx_dmasetup()
2996 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE); in mwl_tx_dmasetup()
2997 bf->bf_m = m0; in mwl_tx_dmasetup()
3034 | (IEEE80211_IS_CHAN_HT40D(ni->ni_chan) ? in mwl_calcformat()
3040 /* XXX short/long GI may be wrong; re-check */ in mwl_calcformat()
3041 if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) { in mwl_calcformat()
3043 | (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI40 ? in mwl_calcformat()
3047 | (ni->ni_htcap & IEEE80211_HTCAP_SHORTGI20 ? in mwl_calcformat()
3056 | (ni->ni_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE ? in mwl_calcformat()
3066 struct ieee80211com *ic = &sc->sc_ic; in mwl_tx_start()
3067 struct ieee80211vap *vap = ni->ni_vap; in mwl_tx_start()
3081 iswep = wh->i_fc[1] & IEEE80211_FC1_PROTECTED; in mwl_tx_start()
3082 ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1); in mwl_tx_start()
3084 pktlen = m0->m_pkthdr.len; in mwl_tx_start()
3120 cip = k->wk_cipher; in mwl_tx_start()
3121 pktlen += cip->ic_header + cip->ic_miclen + cip->ic_trailer; in mwl_tx_start()
3128 sc->sc_tx_th.wt_flags = 0; /* XXX */ in mwl_tx_start()
3130 sc->sc_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; in mwl_tx_start()
3132 sc->sc_tx_th.wt_rate = ds->DataRate; in mwl_tx_start()
3134 sc->sc_tx_th.wt_txpower = ni->ni_txpower; in mwl_tx_start()
3135 sc->sc_tx_th.wt_antenna = sc->sc_txantenna; in mwl_tx_start()
3141 * we present a 2-byte payload length followed by a in mwl_tx_start()
3142 * 4-address header (w/o QoS), followed (optionally) by in mwl_tx_start()
3145 * prepend in-place by the setup of ic_headroom in in mwl_tx_start()
3149 const int space = sizeof(struct mwltxrec) - hdrlen; in mwl_tx_start()
3152 device_printf(sc->sc_dev, in mwl_tx_start()
3155 space, M_LEADINGSPACE(m0), m0->m_flags, m0->m_len); in mwl_tx_start()
3157 mtod(m0, const uint8_t *), m0->m_len, 0, -1); in mwl_tx_start()
3159 sc->sc_stats.mst_tx_noheadroom++; in mwl_tx_start()
3165 if (wh != (struct ieee80211_frame *) &tr->wh) in mwl_tx_start()
3166 ovbcopy(wh, &tr->wh, hdrlen); in mwl_tx_start()
3173 tr->fwlen = htole16(pktlen - hdrlen); in mwl_tx_start()
3186 bf->bf_node = ni; /* NB: held reference */ in mwl_tx_start()
3187 m0 = bf->bf_m; /* NB: may have changed */ in mwl_tx_start()
3189 wh = (struct ieee80211_frame *)&tr->wh; in mwl_tx_start()
3194 ds = bf->bf_desc; in mwl_tx_start()
3195 txq = bf->bf_txq; in mwl_tx_start()
3197 ds->QosCtrl = qos; /* NB: already little-endian */ in mwl_tx_start()
3203 * using firmware with multi-segment support. in mwl_tx_start()
3205 ds->PktPtr = htole32(bf->bf_segs[0].ds_addr); in mwl_tx_start()
3206 ds->PktLen = htole16(bf->bf_segs[0].ds_len); in mwl_tx_start()
3208 ds->multiframes = htole32(bf->bf_nseg); in mwl_tx_start()
3209 ds->PktLen = htole16(m0->m_pkthdr.len); in mwl_tx_start()
3210 for (i = 0; i < bf->bf_nseg; i++) { in mwl_tx_start()
3211 ds->PktPtrArray[i] = htole32(bf->bf_segs[i].ds_addr); in mwl_tx_start()
3212 ds->PktLenArray[i] = htole16(bf->bf_segs[i].ds_len); in mwl_tx_start()
3216 ds->Format = 0; in mwl_tx_start()
3217 ds->pad = 0; in mwl_tx_start()
3218 ds->ack_wcb_addr = 0; in mwl_tx_start()
3224 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { in mwl_tx_start()
3226 sc->sc_stats.mst_tx_mgmt++; in mwl_tx_start()
3230 ds->TxPriority = MWL_WME_AC_BE; in mwl_tx_start()
3234 const struct ieee80211_txparam *tp = ni->ni_txparms; in mwl_tx_start()
3240 if (m0->m_flags & M_EAPOL) { in mwl_tx_start()
3242 ds->Format = mvp->mv_eapolformat; in mwl_tx_start()
3243 ds->pad = htole16( in mwl_tx_start()
3245 } else if (tp->ucastrate != IEEE80211_FIXED_RATE_NONE) { in mwl_tx_start()
3246 /* XXX pre-calculate per node */ in mwl_tx_start()
3247 ds->Format = htole16( in mwl_tx_start()
3248 mwl_calcformat(tp->ucastrate, ni)); in mwl_tx_start()
3249 ds->pad = htole16(EAGLE_TXD_FIXED_RATE); in mwl_tx_start()
3253 ds->TxPriority = txq->qnum; in mwl_tx_start()
3255 else if (mwl_bastream_match(&mn->mn_ba[3], qos)) in mwl_tx_start()
3256 ds->TxPriority = mn->mn_ba[3].txq; in mwl_tx_start()
3259 else if (mwl_bastream_match(&mn->mn_ba[2], qos)) in mwl_tx_start()
3260 ds->TxPriority = mn->mn_ba[2].txq; in mwl_tx_start()
3263 else if (mwl_bastream_match(&mn->mn_ba[1], qos)) in mwl_tx_start()
3264 ds->TxPriority = mn->mn_ba[1].txq; in mwl_tx_start()
3267 else if (mwl_bastream_match(&mn->mn_ba[0], qos)) in mwl_tx_start()
3268 ds->TxPriority = mn->mn_ba[0].txq; in mwl_tx_start()
3271 ds->TxPriority = txq->qnum; in mwl_tx_start()
3273 ds->TxPriority = txq->qnum; in mwl_tx_start()
3276 device_printf(sc->sc_dev, "bogus frame type 0x%x (%s)\n", in mwl_tx_start()
3277 wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); in mwl_tx_start()
3278 sc->sc_stats.mst_tx_badframetype++; in mwl_tx_start()
3286 m0->m_len - sizeof(uint16_t), ds->DataRate, -1); in mwl_tx_start()
3289 ds->Status = htole32(EAGLE_TXD_STATUS_FW_OWNED); in mwl_tx_start()
3290 STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); in mwl_tx_start()
3293 sc->sc_tx_timer = 5; in mwl_tx_start()
3315 struct ieee80211com *ic = &sc->sc_ic; in mwl_tx_processq()
3322 DPRINTF(sc, MWL_DEBUG_TX_PROC, "%s: tx queue %u\n", __func__, txq->qnum); in mwl_tx_processq()
3325 bf = STAILQ_FIRST(&txq->active); in mwl_tx_processq()
3330 ds = bf->bf_desc; in mwl_tx_processq()
3333 if (ds->Status & htole32(EAGLE_TXD_STATUS_FW_OWNED)) { in mwl_tx_processq()
3337 STAILQ_REMOVE_HEAD(&txq->active, bf_list); in mwl_tx_processq()
3341 if (sc->sc_debug & MWL_DEBUG_XMIT_DESC) in mwl_tx_processq()
3342 mwl_printtxbuf(bf, txq->qnum, nreaped); in mwl_tx_processq()
3344 ni = bf->bf_node; in mwl_tx_processq()
3346 status = le32toh(ds->Status); in mwl_tx_processq()
3348 uint16_t Format = le16toh(ds->Format); in mwl_tx_processq()
3352 sc->sc_stats.mst_ant_tx[txant]++; in mwl_tx_processq()
3354 sc->sc_stats.mst_tx_retries++; in mwl_tx_processq()
3356 sc->sc_stats.mst_tx_mretries++; in mwl_tx_processq()
3357 if (txq->qnum >= MWL_WME_AC_VO) in mwl_tx_processq()
3358 ic->ic_wme.wme_hipri_traffic++; in mwl_tx_processq()
3359 ni->ni_txrate = _IEEE80211_MASKSHIFT(Format, in mwl_tx_processq()
3362 ni->ni_txrate = mwl_cvtlegacyrix( in mwl_tx_processq()
3363 ni->ni_txrate); in mwl_tx_processq()
3365 ni->ni_txrate |= IEEE80211_RATE_MCS; in mwl_tx_processq()
3366 sc->sc_stats.mst_tx_rate = ni->ni_txrate; in mwl_tx_processq()
3369 sc->sc_stats.mst_tx_linkerror++; in mwl_tx_processq()
3371 sc->sc_stats.mst_tx_xretries++; in mwl_tx_processq()
3373 sc->sc_stats.mst_tx_aging++; in mwl_tx_processq()
3374 if (bf->bf_m->m_flags & M_FF) in mwl_tx_processq()
3375 sc->sc_stats.mst_ff_txerr++; in mwl_tx_processq()
3377 if (bf->bf_m->m_flags & M_TXCB) in mwl_tx_processq()
3379 m_adj(bf->bf_m, sizeof(uint16_t)); in mwl_tx_processq()
3380 ieee80211_tx_complete(ni, bf->bf_m, in mwl_tx_processq()
3383 m_freem(bf->bf_m); in mwl_tx_processq()
3384 ds->Status = htole32(EAGLE_TXD_STATUS_IDLE); in mwl_tx_processq()
3386 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, in mwl_tx_processq()
3388 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in mwl_tx_processq()
3397 * Deferred processing of transmit interrupt; special-cased
3398 * for four hardware queues, 0-3.
3410 if (!STAILQ_EMPTY(&sc->sc_txq[0].active)) in mwl_tx_proc()
3411 nreaped += mwl_tx_processq(sc, &sc->sc_txq[0]); in mwl_tx_proc()
3412 if (!STAILQ_EMPTY(&sc->sc_txq[1].active)) in mwl_tx_proc()
3413 nreaped += mwl_tx_processq(sc, &sc->sc_txq[1]); in mwl_tx_proc()
3414 if (!STAILQ_EMPTY(&sc->sc_txq[2].active)) in mwl_tx_proc()
3415 nreaped += mwl_tx_processq(sc, &sc->sc_txq[2]); in mwl_tx_proc()
3416 if (!STAILQ_EMPTY(&sc->sc_txq[3].active)) in mwl_tx_proc()
3417 nreaped += mwl_tx_processq(sc, &sc->sc_txq[3]); in mwl_tx_proc()
3420 sc->sc_tx_timer = 0; in mwl_tx_proc()
3421 if (mbufq_first(&sc->sc_snd) != NULL) { in mwl_tx_proc()
3423 mwl_hal_txstart(sc->sc_mh, 0); in mwl_tx_proc()
3442 bf = STAILQ_FIRST(&txq->active); in mwl_tx_draintxq()
3447 STAILQ_REMOVE_HEAD(&txq->active, bf_list); in mwl_tx_draintxq()
3450 if (sc->sc_debug & MWL_DEBUG_RESET) { in mwl_tx_draintxq()
3451 struct ieee80211com *ic = &sc->sc_ic; in mwl_tx_draintxq()
3453 mtod(bf->bf_m, const struct mwltxrec *); in mwl_tx_draintxq()
3454 mwl_printtxbuf(bf, txq->qnum, ix); in mwl_tx_draintxq()
3455 ieee80211_dump_pkt(ic, (const uint8_t *)&tr->wh, in mwl_tx_draintxq()
3456 bf->bf_m->m_len - sizeof(tr->fwlen), 0, -1); in mwl_tx_draintxq()
3459 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); in mwl_tx_draintxq()
3460 ni = bf->bf_node; in mwl_tx_draintxq()
3467 m_freem(bf->bf_m); in mwl_tx_draintxq()
3482 mwl_tx_draintxq(sc, &sc->sc_txq[i]); in mwl_draintxq()
3483 sc->sc_tx_timer = 0; in mwl_draintxq()
3496 mwl_txq_reset(sc, &sc->sc_txq[i]); in mwl_resettxq()
3515 txq = &sc->sc_txq[i]; in mwl_cleartxq()
3517 STAILQ_FOREACH(bf, &txq->active, bf_list) { in mwl_cleartxq()
3518 struct ieee80211_node *ni = bf->bf_node; in mwl_cleartxq()
3519 if (ni != NULL && ni->ni_vap == vap) { in mwl_cleartxq()
3520 bf->bf_node = NULL; in mwl_cleartxq()
3532 struct mwl_softc *sc = ni->ni_ic->ic_softc; in mwl_recv_action()
3536 if (ia->ia_category == IEEE80211_ACTION_CAT_HT && in mwl_recv_action()
3537 ia->ia_action == IEEE80211_ACTION_HT_MIMOPWRSAVE) { in mwl_recv_action()
3541 mwl_hal_setmimops(sc->sc_mh, ni->ni_macaddr, in mwl_recv_action()
3542 mps->am_control & IEEE80211_A_HT_MIMOPWRSAVE_ENA, in mwl_recv_action()
3543 _IEEE80211_MASKSHIFT(mps->am_control, in mwl_recv_action()
3547 return sc->sc_recv_action(ni, wh, frm, efrm); in mwl_recv_action()
3554 struct mwl_softc *sc = ni->ni_ic->ic_softc; in mwl_addba_request()
3555 struct ieee80211vap *vap = ni->ni_vap; in mwl_addba_request()
3559 bas = tap->txa_private; in mwl_addba_request()
3566 if (mn->mn_ba[3].bastream == NULL) in mwl_addba_request()
3567 bas = &mn->mn_ba[3]; in mwl_addba_request()
3571 if (mn->mn_ba[2].bastream == NULL) in mwl_addba_request()
3572 bas = &mn->mn_ba[2]; in mwl_addba_request()
3576 if (mn->mn_ba[1].bastream == NULL) in mwl_addba_request()
3577 bas = &mn->mn_ba[1]; in mwl_addba_request()
3581 if (mn->mn_ba[0].bastream == NULL) in mwl_addba_request()
3582 bas = &mn->mn_ba[0]; in mwl_addba_request()
3590 sc->sc_stats.mst_ampdu_reject++; in mwl_addba_request()
3594 sp = mwl_hal_bastream_alloc(MWL_VAP(vap)->mv_hvap, in mwl_addba_request()
3596 ni->ni_macaddr, tap->txa_tid, ni->ni_htparam, in mwl_addba_request()
3601 * a-mpdu aggregation will be done. in mwl_addba_request()
3605 sc->sc_stats.mst_ampdu_nostream++; in mwl_addba_request()
3611 bas->bastream = sp; in mwl_addba_request()
3612 tap->txa_private = bas; in mwl_addba_request()
3615 if (mwl_hal_bastream_get_seqno(sc->sc_mh, bas->bastream, in mwl_addba_request()
3616 vap->iv_opmode == IEEE80211_M_STA ? vap->iv_myaddr : ni->ni_macaddr, in mwl_addba_request()
3617 &tap->txa_start) != 0) in mwl_addba_request()
3618 tap->txa_start = 0; in mwl_addba_request()
3619 return sc->sc_addba_request(ni, tap, dialogtoken, baparamset, batimeout); in mwl_addba_request()
3626 struct mwl_softc *sc = ni->ni_ic->ic_softc; in mwl_addba_response()
3629 bas = tap->txa_private; in mwl_addba_response()
3634 __func__, tap->txa_tid); in mwl_addba_response()
3635 sc->sc_stats.mst_addba_nostream++; in mwl_addba_response()
3639 struct ieee80211vap *vap = ni->ni_vap; in mwl_addba_response()
3645 * pre-allocated one before forming the request. in mwl_addba_response()
3650 error = mwl_hal_bastream_create(MWL_VAP(vap)->mv_hvap, in mwl_addba_response()
3651 bas->bastream, bufsiz, bufsiz, tap->txa_start); in mwl_addba_response()
3654 * Setup failed, return immediately so no a-mpdu in mwl_addba_response()
3657 mwl_hal_bastream_destroy(sc->sc_mh, bas->bastream); in mwl_addba_response()
3659 tap->txa_private = NULL; in mwl_addba_response()
3664 tap->txa_tid, ni->ni_htparam); in mwl_addba_response()
3665 sc->sc_stats.mst_bacreate_failed++; in mwl_addba_response()
3669 mwl_bastream_setup(bas, tap->txa_tid, bas->bastream->txq); in mwl_addba_response()
3672 "htparam 0x%x\n", __func__, bas->bastream, in mwl_addba_response()
3673 bas->txq, tap->txa_tid, bufsiz, ni->ni_htparam); in mwl_addba_response()
3680 __func__, code, bas->bastream); in mwl_addba_response()
3681 mwl_hal_bastream_destroy(sc->sc_mh, bas->bastream); in mwl_addba_response()
3683 tap->txa_private = NULL; in mwl_addba_response()
3686 return sc->sc_addba_response(ni, tap, code, baparamset, batimeout); in mwl_addba_response()
3692 struct mwl_softc *sc = ni->ni_ic->ic_softc; in mwl_addba_stop()
3695 bas = tap->txa_private; in mwl_addba_stop()
3698 __func__, bas->bastream); in mwl_addba_stop()
3699 mwl_hal_bastream_destroy(sc->sc_mh, bas->bastream); in mwl_addba_stop()
3701 tap->txa_private = NULL; in mwl_addba_stop()
3703 sc->sc_addba_stop(ni, tap); in mwl_addba_stop()
3713 if (!sc->sc_recvsetup) { in mwl_startrecv()
3718 STAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { in mwl_startrecv()
3727 ds = prev->bf_desc; in mwl_startrecv()
3728 ds->pPhysNext = htole32(bf->bf_daddr); in mwl_startrecv()
3733 ds = prev->bf_desc; in mwl_startrecv()
3734 ds->pPhysNext = in mwl_startrecv()
3735 htole32(STAILQ_FIRST(&sc->sc_rxbuf)->bf_daddr); in mwl_startrecv()
3737 sc->sc_recvsetup = 1; in mwl_startrecv()
3749 if (vap->iv_flags_ht & IEEE80211_FHT_PUREN) in mwl_getapmode()
3753 else if (vap->iv_flags & IEEE80211_F_PUREG) in mwl_getapmode()
3758 if (vap->iv_flags & IEEE80211_F_PUREG) in mwl_getapmode()
3774 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_setapmode()
3784 struct mwl_hal *mh = sc->sc_mh; in mwl_chan_set()
3785 struct ieee80211com *ic = &sc->sc_ic; in mwl_chan_set()
3790 __func__, chan->ic_freq, chan->ic_flags); in mwl_chan_set()
3805 * possibly a user-set limit. We pass the min of in mwl_chan_set()
3810 maxtxpow = 2*chan->ic_maxregpower; in mwl_chan_set()
3811 if (maxtxpow > ic->ic_txpowlimit) in mwl_chan_set()
3812 maxtxpow = ic->ic_txpowlimit; in mwl_chan_set()
3820 sc->sc_tx_th.wt_chan_freq = htole16(chan->ic_freq); in mwl_chan_set()
3821 sc->sc_rx_th.wr_chan_freq = htole16(chan->ic_freq); in mwl_chan_set()
3823 sc->sc_tx_th.wt_chan_flags = htole16(IEEE80211_CHAN_A); in mwl_chan_set()
3824 sc->sc_rx_th.wr_chan_flags = htole16(IEEE80211_CHAN_A); in mwl_chan_set()
3826 sc->sc_tx_th.wt_chan_flags = htole16(IEEE80211_CHAN_G); in mwl_chan_set()
3827 sc->sc_rx_th.wr_chan_flags = htole16(IEEE80211_CHAN_G); in mwl_chan_set()
3829 sc->sc_tx_th.wt_chan_flags = htole16(IEEE80211_CHAN_B); in mwl_chan_set()
3830 sc->sc_rx_th.wr_chan_flags = htole16(IEEE80211_CHAN_B); in mwl_chan_set()
3832 sc->sc_curchan = hchan; in mwl_chan_set()
3833 mwl_hal_intrset(mh, sc->sc_imask); in mwl_chan_set()
3841 struct mwl_softc *sc = ic->ic_softc; in mwl_scan_start()
3849 struct mwl_softc *sc = ic->ic_softc; in mwl_scan_end()
3857 struct mwl_softc *sc = ic->ic_softc; in mwl_set_channel()
3859 (void) mwl_chan_set(sc, ic->ic_curchan); in mwl_set_channel()
3871 struct ieee80211com *ic = vap->iv_ic; in mwl_startcsa()
3872 struct mwl_softc *sc = ic->ic_softc; in mwl_startcsa()
3875 if (sc->sc_csapending) in mwl_startcsa()
3878 mwl_mapchan(&hchan, ic->ic_csa_newchan); in mwl_startcsa()
3880 mwl_hal_setchannelswitchie(sc->sc_mh, &hchan, 1, ic->ic_csa_count); in mwl_startcsa()
3881 sc->sc_csapending = 1; in mwl_startcsa()
3892 if ((vap->iv_flags & (IEEE80211_F_PRIVACY|IEEE80211_F_WPA)) == in mwl_setanywepkey()
3894 vap->iv_def_txkey != IEEE80211_KEYIX_NONE && in mwl_setanywepkey()
3895 vap->iv_nw_keys[vap->iv_def_txkey].wk_keyix != IEEE80211_KEYIX_NONE) in mwl_setanywepkey()
3896 (void) _mwl_key_set(vap, &vap->iv_nw_keys[vap->iv_def_txkey], in mwl_setanywepkey()
3904 struct ieee80211vap *vap = ni->ni_vap; in mwl_peerstadb()
3908 if (vap->iv_opmode == IEEE80211_M_WDS) { in mwl_peerstadb()
3914 hvap = MWL_VAP(vap)->mv_ap_hvap; in mwl_peerstadb()
3916 hvap = MWL_VAP(vap)->mv_hvap; in mwl_peerstadb()
3917 error = mwl_hal_newstation(hvap, ni->ni_macaddr, in mwl_peerstadb()
3919 ni->ni_flags & (IEEE80211_NODE_QOS | IEEE80211_NODE_HT), in mwl_peerstadb()
3920 ni->ni_ies.wme_ie != NULL ? WME(ni->ni_ies.wme_ie)->wme_info : 0); in mwl_peerstadb()
3928 mwl_setanywepkey(vap, ni->ni_macaddr); in mwl_peerstadb()
3939 wk = &vap->iv_nw_keys[0]; in mwl_setglobalkeys()
3940 for (; wk < &vap->iv_nw_keys[IEEE80211_WEP_NKID]; wk++) in mwl_setglobalkeys()
3941 if (wk->wk_keyix != IEEE80211_KEYIX_NONE) in mwl_setglobalkeys()
3942 (void) _mwl_key_set(vap, wk, vap->iv_myaddr); in mwl_setglobalkeys()
3955 for (i = 0; i < rs->rs_nrates; i++) in get_rate_bitmap()
3956 switch (rs->rs_rates[i] & IEEE80211_RATE_VAL) { in get_rate_bitmap()
3984 for (i = 0; i < rs->rs_nrates; i++) { in get_htrate_bitmap()
3985 if (rs->rs_rates[i] < 16) in get_htrate_bitmap()
3986 rates |= 1<<rs->rs_rates[i]; in get_htrate_bitmap()
3998 const struct ieee80211vap *vap = ni->ni_vap; in mkpeerinfo()
4001 pi->LegacyRateBitMap = get_rate_bitmap(&ni->ni_rates); in mkpeerinfo()
4002 pi->CapInfo = ni->ni_capinfo; in mkpeerinfo()
4003 if (ni->ni_flags & IEEE80211_NODE_HT) { in mkpeerinfo()
4005 pi->HTCapabilitiesInfo = ni->ni_htcap; in mkpeerinfo()
4007 pi->MacHTParamInfo = ni->ni_htparam; in mkpeerinfo()
4008 pi->HTRateBitMap = get_htrate_bitmap(&ni->ni_htrates); in mkpeerinfo()
4009 pi->AddHtInfo.ControlChan = ni->ni_htctlchan; in mkpeerinfo()
4010 pi->AddHtInfo.AddChan = ni->ni_ht2ndchan; in mkpeerinfo()
4011 pi->AddHtInfo.OpMode = ni->ni_htopmode; in mkpeerinfo()
4012 pi->AddHtInfo.stbc = ni->ni_htstbc; in mkpeerinfo()
4015 if ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI40) == 0) in mkpeerinfo()
4016 pi->HTCapabilitiesInfo &= ~IEEE80211_HTCAP_SHORTGI40; in mkpeerinfo()
4017 if ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) == 0) in mkpeerinfo()
4018 pi->HTCapabilitiesInfo &= ~IEEE80211_HTCAP_SHORTGI20; in mkpeerinfo()
4019 if (ni->ni_chw != IEEE80211_STA_RX_BW_40) in mkpeerinfo()
4020 pi->HTCapabilitiesInfo &= ~IEEE80211_HTCAP_CHWIDTH40; in mkpeerinfo()
4026 * Re-create the local sta db entry for a vap to ensure
4035 struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap; in mwl_localstadb()
4040 switch (vap->iv_opmode) { in mwl_localstadb()
4042 bss = vap->iv_bss; in mwl_localstadb()
4043 error = mwl_hal_newstation(hvap, vap->iv_myaddr, 0, 0, in mwl_localstadb()
4044 vap->iv_state == IEEE80211_S_RUN ? in mwl_localstadb()
4046 (bss->ni_flags & (IEEE80211_NODE_QOS | IEEE80211_NODE_HT)), in mwl_localstadb()
4047 bss->ni_ies.wme_ie != NULL ? in mwl_localstadb()
4048 WME(bss->ni_ies.wme_ie)->wme_info : 0); in mwl_localstadb()
4054 error = mwl_hal_newstation(hvap, vap->iv_myaddr, in mwl_localstadb()
4055 0, 0, NULL, vap->iv_flags & IEEE80211_F_WME, 0); in mwl_localstadb()
4071 struct mwl_hal_vap *hvap = mvp->mv_hvap; in mwl_newstate()
4072 struct ieee80211com *ic = vap->iv_ic; in mwl_newstate()
4074 struct mwl_softc *sc = ic->ic_softc; in mwl_newstate()
4075 struct mwl_hal *mh = sc->sc_mh; in mwl_newstate()
4076 enum ieee80211_state ostate = vap->iv_state; in mwl_newstate()
4079 DPRINTF(sc, MWL_DEBUG_STATE, "%s: %s: %s -> %s\n", in mwl_newstate()
4080 if_name(vap->iv_ifp), __func__, in mwl_newstate()
4083 callout_stop(&sc->sc_timer); in mwl_newstate()
4090 } else if (sc->sc_radarena) { in mwl_newstate()
4091 /* stop in-service radar detection */ in mwl_newstate()
4093 sc->sc_radarena = 0; in mwl_newstate()
4096 * Carry out per-state actions before doing net80211 work. in mwl_newstate()
4112 ni = vap->iv_bss; in mwl_newstate()
4113 MWL_NODE(ni)->mn_hvap = hvap; in mwl_newstate()
4117 if (vap->iv_opmode == IEEE80211_M_HOSTAP || in mwl_newstate()
4118 vap->iv_opmode == IEEE80211_M_MBSS) in mwl_newstate()
4129 error = mvp->mv_newstate(vap, nstate, arg); in mwl_newstate()
4137 ni = vap->iv_bss; in mwl_newstate()
4142 if_name(vap->iv_ifp), __func__, vap->iv_flags, in mwl_newstate()
4143 ni->ni_intval, ether_sprintf(ni->ni_bssid), ni->ni_capinfo, in mwl_newstate()
4144 ieee80211_chan2ieee(ic, ic->ic_curchan)); in mwl_newstate()
4150 switch (vap->iv_opmode) { in mwl_newstate()
4154 /* enable in-service radar detection */ in mwl_newstate()
4157 sc->sc_radarena = 1; in mwl_newstate()
4175 if_name(vap->iv_ifp), __func__, ni->ni_associd); in mwl_newstate()
4179 mwl_hal_setassocid(hvap, ni->ni_bssid, ni->ni_associd); in mwl_newstate()
4181 mwl_hal_setrtsthreshold(hvap, vap->iv_rtsthreshold); in mwl_newstate()
4182 if ((vap->iv_flags & IEEE80211_F_DWDS) && in mwl_newstate()
4183 sc->sc_ndwdsvaps++ == 0) in mwl_newstate()
4188 if_name(vap->iv_ifp), __func__, in mwl_newstate()
4189 ether_sprintf(ni->ni_bssid)); in mwl_newstate()
4201 if (IEEE80211_IS_CHAN_5GHZ(ic->ic_bsschan)) in mwl_newstate()
4208 if (sc->sc_ageinterval != 0) in mwl_newstate()
4209 callout_reset(&sc->sc_timer, sc->sc_ageinterval*hz, in mwl_newstate()
4213 } else if ((vap->iv_flags & IEEE80211_F_DWDS) && in mwl_newstate()
4214 --sc->sc_ndwdsvaps == 0) in mwl_newstate()
4230 if (!(0 < aid && aid < MWL_MAXSTAID) || isset(sc->sc_staid, aid)) { in allocstaid()
4233 if (isclr(sc->sc_staid, staid)) in allocstaid()
4237 setbit(sc->sc_staid, staid); in allocstaid()
4244 clrbit(sc->sc_staid, staid); in delstaid()
4248 * Setup driver-specific state for a newly associated node.
4249 * Note that we're called also on a re-associate, the isnew
4255 struct ieee80211vap *vap = ni->ni_vap; in mwl_newassoc()
4256 struct mwl_softc *sc = vap->iv_ic->ic_softc; in mwl_newassoc()
4262 aid = IEEE80211_AID(ni->ni_associd); in mwl_newassoc()
4264 mn->mn_staid = allocstaid(sc, aid); in mwl_newassoc()
4265 mn->mn_hvap = MWL_VAP(vap)->mv_hvap; in mwl_newassoc()
4271 __func__, ether_sprintf(ni->ni_macaddr), isnew, aid, mn->mn_staid); in mwl_newassoc()
4272 error = mwl_peerstadb(ni, aid, mn->mn_staid, mkpeerinfo(&pi, ni)); in mwl_newassoc()
4290 mwl_hal_setkeepalive(sc->sc_mh); in mwl_agestations()
4291 if (sc->sc_ageinterval != 0) /* NB: catch dynamic changes */ in mwl_agestations()
4292 callout_schedule(&sc->sc_timer, sc->sc_ageinterval*hz); in mwl_agestations()
4300 for (i = 0; i < ci->nchannels; i++) { in findhalchannel()
4301 const struct mwl_hal_channel *hc = &ci->channels[i]; in findhalchannel()
4302 if (hc->ieee == ieee) in findhalchannel()
4312 struct mwl_softc *sc = ic->ic_softc; in mwl_setregdomain()
4313 struct mwl_hal *mh = sc->sc_mh; in mwl_setregdomain()
4330 device_printf(sc->sc_dev, in mwl_setregdomain()
4332 __func__, c->ic_ieee, c->ic_freq, c->ic_flags); in mwl_setregdomain()
4338 hc = findhalchannel(ci, c->ic_ieee); in mwl_setregdomain()
4340 if (c->ic_maxpower > 2*hc->maxTxPow) in mwl_setregdomain()
4341 c->ic_maxpower = 2*hc->maxTxPow; in mwl_setregdomain()
4349 hc = findhalchannel(ci, c->ic_extieee); in mwl_setregdomain()
4351 if (c->ic_maxpower > 2*hc->maxTxPow) in mwl_setregdomain()
4352 c->ic_maxpower = 2*hc->maxTxPow; in mwl_setregdomain()
4356 device_printf(sc->sc_dev, in mwl_setregdomain()
4358 __func__, c->ic_ieee, c->ic_extieee, in mwl_setregdomain()
4359 c->ic_freq, c->ic_flags); in mwl_setregdomain()
4376 for (i = 0; i < ci->nchannels; i++) { in addht40channels()
4377 const struct mwl_hal_channel *hc = &ci->channels[i]; in addht40channels()
4380 hc->ieee, hc->maxTxPow, flags); in addht40channels()
4393 for (i = 0; i < ci->nchannels && error == 0; i++) { in addchannels()
4394 const struct mwl_hal_channel *hc = &ci->channels[i]; in addchannels()
4397 hc->ieee, hc->freq, hc->maxTxPow, 0, bands); in addchannels()
4415 if (mwl_hal_getchannelinfo(sc->sc_mh, in getchannels()
4423 if (mwl_hal_getchannelinfo(sc->sc_mh, in getchannels()
4430 if (mwl_hal_getchannelinfo(sc->sc_mh, in getchannels()
4433 if (mwl_hal_getchannelinfo(sc->sc_mh, in getchannels()
4442 struct mwl_softc *sc = ic->ic_softc; in mwl_getradiocaps()
4450 struct ieee80211com *ic = &sc->sc_ic; in mwl_getchannels()
4457 memset(ic->ic_channels, 0, sizeof(ic->ic_channels)); in mwl_getchannels()
4458 ic->ic_nchans = 0; in mwl_getchannels()
4459 getchannels(sc, IEEE80211_CHAN_MAX, &ic->ic_nchans, ic->ic_channels); in mwl_getchannels()
4461 ic->ic_regdomain.regdomain = SKU_DEBUG; in mwl_getchannels()
4462 ic->ic_regdomain.country = CTRY_DEFAULT; in mwl_getchannels()
4463 ic->ic_regdomain.location = 'I'; in mwl_getchannels()
4464 ic->ic_regdomain.isocc[0] = ' '; /* XXX? */ in mwl_getchannels()
4465 ic->ic_regdomain.isocc[1] = ' '; in mwl_getchannels()
4466 return (ic->ic_nchans == 0 ? EIO : 0); in mwl_getchannels()
4475 const struct mwl_rxdesc *ds = bf->bf_desc; in mwl_printrxbuf()
4476 uint32_t status = le32toh(ds->Status); in mwl_printrxbuf()
4480 ix, ds, (uintmax_t)bf->bf_daddr, le32toh(ds->pPhysNext), in mwl_printrxbuf()
4481 le32toh(ds->pPhysBuffData), ds->RxControl, in mwl_printrxbuf()
4482 ds->RxControl != EAGLE_RXD_CTRL_DRIVER_OWN ? in mwl_printrxbuf()
4484 ds->Status, le16toh(ds->PktLen), ds->RSSI, ds->Channel, in mwl_printrxbuf()
4485 ds->Rate, le16toh(ds->QosCtrl), le16toh(ds->HtSig2)); in mwl_printrxbuf()
4491 const struct mwl_txdesc *ds = bf->bf_desc; in mwl_printtxbuf()
4492 uint32_t status = le32toh(ds->Status); in mwl_printtxbuf()
4495 printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr); in mwl_printtxbuf()
4497 le32toh(ds->pPhysNext), in mwl_printtxbuf()
4498 le32toh(ds->PktPtr), le16toh(ds->PktLen), status, in mwl_printtxbuf()
4502 ds->DataRate, ds->TxPriority, le16toh(ds->QosCtrl), in mwl_printtxbuf()
4503 le32toh(ds->SapPktInfo), le16toh(ds->Format)); in mwl_printtxbuf()
4506 , le32toh(ds->multiframes) in mwl_printtxbuf()
4507 , le16toh(ds->PktLenArray[0]), le16toh(ds->PktLenArray[1]) in mwl_printtxbuf()
4508 , le16toh(ds->PktLenArray[2]), le16toh(ds->PktLenArray[3]) in mwl_printtxbuf()
4509 , le16toh(ds->PktLenArray[4]), le16toh(ds->PktLenArray[5]) in mwl_printtxbuf()
4512 , le32toh(ds->PktPtrArray[0]), le32toh(ds->PktPtrArray[1]) in mwl_printtxbuf()
4513 , le32toh(ds->PktPtrArray[2]), le32toh(ds->PktPtrArray[3]) in mwl_printtxbuf()
4514 , le32toh(ds->PktPtrArray[4]), le32toh(ds->PktPtrArray[5]) in mwl_printtxbuf()
4539 STAILQ_FOREACH(bf, &txq->active, bf_list) {
4540 struct mwl_txdesc *ds = bf->bf_desc;
4544 mwl_printtxbuf(bf, txq->qnum, i);
4557 callout_reset(&sc->sc_watchdog, hz, mwl_watchdog, sc); in mwl_watchdog()
4558 if (sc->sc_tx_timer == 0 || --sc->sc_tx_timer > 0) in mwl_watchdog()
4561 if (sc->sc_running && !sc->sc_invalid) { in mwl_watchdog()
4562 if (mwl_hal_setkeepalive(sc->sc_mh)) in mwl_watchdog()
4563 device_printf(sc->sc_dev, in mwl_watchdog()
4566 device_printf(sc->sc_dev, in mwl_watchdog()
4570 mwl_txq_dump(&sc->sc_txq[0]);/*XXX*/ in mwl_watchdog()
4572 counter_u64_add(sc->sc_ic.ic_oerrors, 1); in mwl_watchdog()
4573 sc->sc_stats.mst_watchdog++; in mwl_watchdog()
4587 struct mwl_hal *mh = sc->sc_mh; in mwl_ioctl_diag()
4588 u_int id = md->md_id & MWL_DIAG_ID; in mwl_ioctl_diag()
4591 u_int32_t insize = md->md_in_size; in mwl_ioctl_diag()
4592 u_int32_t outsize = md->md_out_size; in mwl_ioctl_diag()
4595 if (md->md_id & MWL_DIAG_IN) { in mwl_ioctl_diag()
4604 error = copyin(md->md_in_data, indata, insize); in mwl_ioctl_diag()
4608 if (md->md_id & MWL_DIAG_DYN) { in mwl_ioctl_diag()
4623 if (outsize < md->md_out_size) in mwl_ioctl_diag()
4624 md->md_out_size = outsize; in mwl_ioctl_diag()
4626 error = copyout(outdata, md->md_out_data, in mwl_ioctl_diag()
4627 md->md_out_size); in mwl_ioctl_diag()
4632 if ((md->md_id & MWL_DIAG_IN) && indata != NULL) in mwl_ioctl_diag()
4634 if ((md->md_id & MWL_DIAG_DYN) && outdata != NULL) in mwl_ioctl_diag()
4642 struct mwl_hal *mh = sc->sc_mh; in mwl_ioctl_reset()
4647 if (md->md_id == 0 && mwl_hal_fwload(mh, NULL) != 0) { in mwl_ioctl_reset()
4648 device_printf(sc->sc_dev, "unable to load firmware\n"); in mwl_ioctl_reset()
4651 if (mwl_hal_gethwspecs(mh, &sc->sc_hwspecs) != 0) { in mwl_ioctl_reset()
4652 device_printf(sc->sc_dev, "unable to fetch h/w specs\n"); in mwl_ioctl_reset()
4662 * re-start the driver's notion of the next xmit/recv. in mwl_ioctl_reset()
4666 sc->sc_rxnext = NULL; /* force rx to start at the list head */ in mwl_ioctl_reset()
4674 struct mwl_softc *sc = ic->ic_softc; in mwl_parent()
4678 if (ic->ic_nrunning > 0) { in mwl_parent()
4679 if (sc->sc_running) { in mwl_parent()
4691 * However trying to re-init the interface in mwl_parent()
4696 if (!sc->sc_invalid) { in mwl_parent()
4711 struct mwl_softc *sc = ic->ic_softc; in mwl_ioctl()
4717 mwl_hal_gethwstats(sc->sc_mh, &sc->sc_stats.hw_stats); in mwl_ioctl()
4720 sc->sc_stats.mst_tx_packets = in mwl_ioctl()
4722 sc->sc_stats.mst_rx_packets = in mwl_ioctl()
4731 return (copyout(&sc->sc_stats, ifr_data_get_ptr(ifr), in mwl_ioctl()
4732 sizeof (sc->sc_stats))); in mwl_ioctl()
4758 debug = sc->sc_debug | (mwl_hal_getdebug(sc->sc_mh) << 24); in mwl_sysctl_debug()
4760 if (error || !req->newptr) in mwl_sysctl_debug()
4762 mwl_hal_setdebug(sc->sc_mh, debug >> 24); in mwl_sysctl_debug()
4763 sc->sc_debug = debug & 0x00ffffff; in mwl_sysctl_debug()
4772 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); in mwl_sysctlattach()
4773 struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); in mwl_sysctlattach()
4775 sc->sc_debug = mwl_debug; in mwl_sysctlattach()
4789 device_printf(sc->sc_dev, "Rev A%d hardware, v%d.%d.%d.%d firmware (regioncode %d)\n", in mwl_announce()
4790 sc->sc_hwspecs.hwVersion, in mwl_announce()
4791 (sc->sc_hwspecs.fwReleaseNumber>>24) & 0xff, in mwl_announce()
4792 (sc->sc_hwspecs.fwReleaseNumber>>16) & 0xff, in mwl_announce()
4793 (sc->sc_hwspecs.fwReleaseNumber>>8) & 0xff, in mwl_announce()
4794 (sc->sc_hwspecs.fwReleaseNumber>>0) & 0xff, in mwl_announce()
4795 sc->sc_hwspecs.regionCode); in mwl_announce()
4796 sc->sc_fwrelease = sc->sc_hwspecs.fwReleaseNumber; in mwl_announce()
4801 struct mwl_txq *txq = sc->sc_ac2q[i]; in mwl_announce()
4802 device_printf(sc->sc_dev, "Use hw queue %u for %s traffic\n", in mwl_announce()
4803 txq->qnum, ieee80211_wme_acnames[i]); in mwl_announce()
4807 device_printf(sc->sc_dev, "using %u rx descriptors\n", mwl_rxdesc); in mwl_announce()
4809 device_printf(sc->sc_dev, "using %u rx buffers\n", mwl_rxbuf); in mwl_announce()
4811 device_printf(sc->sc_dev, "using %u tx buffers\n", mwl_txbuf); in mwl_announce()
4812 if (bootverbose && mwl_hal_ismbsscapable(sc->sc_mh)) in mwl_announce()
4813 device_printf(sc->sc_dev, "multi-bss support\n"); in mwl_announce()
4816 device_printf(sc->sc_dev, "no tx drop\n"); in mwl_announce()