1e60c4fc2SAdrian Chadd /*- 2e60c4fc2SAdrian Chadd * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3e60c4fc2SAdrian Chadd * All rights reserved. 4e60c4fc2SAdrian Chadd * 5e60c4fc2SAdrian Chadd * Redistribution and use in source and binary forms, with or without 6e60c4fc2SAdrian Chadd * modification, are permitted provided that the following conditions 7e60c4fc2SAdrian Chadd * are met: 8e60c4fc2SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 9e60c4fc2SAdrian Chadd * notice, this list of conditions and the following disclaimer, 10e60c4fc2SAdrian Chadd * without modification. 11e60c4fc2SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12e60c4fc2SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 13e60c4fc2SAdrian Chadd * redistribution must be conditioned upon including a substantially 14e60c4fc2SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 15e60c4fc2SAdrian Chadd * 16e60c4fc2SAdrian Chadd * NO WARRANTY 17e60c4fc2SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18e60c4fc2SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19e60c4fc2SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 20e60c4fc2SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21e60c4fc2SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22e60c4fc2SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23e60c4fc2SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24e60c4fc2SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25e60c4fc2SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26e60c4fc2SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27e60c4fc2SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 28e60c4fc2SAdrian Chadd */ 29e60c4fc2SAdrian Chadd 30e60c4fc2SAdrian Chadd #include <sys/cdefs.h> 31e60c4fc2SAdrian Chadd __FBSDID("$FreeBSD$"); 32e60c4fc2SAdrian Chadd 33e60c4fc2SAdrian Chadd /* 34e60c4fc2SAdrian Chadd * Driver for the Atheros Wireless LAN controller. 35e60c4fc2SAdrian Chadd * 36e60c4fc2SAdrian Chadd * This software is derived from work of Atsushi Onoe; his contribution 37e60c4fc2SAdrian Chadd * is greatly appreciated. 38e60c4fc2SAdrian Chadd */ 39e60c4fc2SAdrian Chadd 40e60c4fc2SAdrian Chadd #include "opt_inet.h" 41e60c4fc2SAdrian Chadd #include "opt_ath.h" 42e60c4fc2SAdrian Chadd /* 43e60c4fc2SAdrian Chadd * This is needed for register operations which are performed 44e60c4fc2SAdrian Chadd * by the driver - eg, calls to ath_hal_gettsf32(). 45e60c4fc2SAdrian Chadd * 46e60c4fc2SAdrian Chadd * It's also required for any AH_DEBUG checks in here, eg the 47e60c4fc2SAdrian Chadd * module dependencies. 48e60c4fc2SAdrian Chadd */ 49e60c4fc2SAdrian Chadd #include "opt_ah.h" 50e60c4fc2SAdrian Chadd #include "opt_wlan.h" 51e60c4fc2SAdrian Chadd 52e60c4fc2SAdrian Chadd #include <sys/param.h> 53e60c4fc2SAdrian Chadd #include <sys/systm.h> 54e60c4fc2SAdrian Chadd #include <sys/sysctl.h> 55e60c4fc2SAdrian Chadd #include <sys/mbuf.h> 56e60c4fc2SAdrian Chadd #include <sys/malloc.h> 57e60c4fc2SAdrian Chadd #include <sys/lock.h> 58e60c4fc2SAdrian Chadd #include <sys/mutex.h> 59e60c4fc2SAdrian Chadd #include <sys/kernel.h> 60e60c4fc2SAdrian Chadd #include <sys/socket.h> 61e60c4fc2SAdrian Chadd #include <sys/sockio.h> 62e60c4fc2SAdrian Chadd #include <sys/errno.h> 63e60c4fc2SAdrian Chadd #include <sys/callout.h> 64e60c4fc2SAdrian Chadd #include <sys/bus.h> 65e60c4fc2SAdrian Chadd #include <sys/endian.h> 66e60c4fc2SAdrian Chadd #include <sys/kthread.h> 67e60c4fc2SAdrian Chadd #include <sys/taskqueue.h> 68e60c4fc2SAdrian Chadd #include <sys/priv.h> 69e60c4fc2SAdrian Chadd #include <sys/module.h> 70e60c4fc2SAdrian Chadd #include <sys/ktr.h> 71e60c4fc2SAdrian Chadd #include <sys/smp.h> /* for mp_ncpus */ 72e60c4fc2SAdrian Chadd 73e60c4fc2SAdrian Chadd #include <machine/bus.h> 74e60c4fc2SAdrian Chadd 75e60c4fc2SAdrian Chadd #include <net/if.h> 76e60c4fc2SAdrian Chadd #include <net/if_dl.h> 77e60c4fc2SAdrian Chadd #include <net/if_media.h> 78e60c4fc2SAdrian Chadd #include <net/if_types.h> 79e60c4fc2SAdrian Chadd #include <net/if_arp.h> 80e60c4fc2SAdrian Chadd #include <net/ethernet.h> 81e60c4fc2SAdrian Chadd #include <net/if_llc.h> 82e60c4fc2SAdrian Chadd 83e60c4fc2SAdrian Chadd #include <net80211/ieee80211_var.h> 84e60c4fc2SAdrian Chadd #include <net80211/ieee80211_regdomain.h> 85e60c4fc2SAdrian Chadd #ifdef IEEE80211_SUPPORT_SUPERG 86e60c4fc2SAdrian Chadd #include <net80211/ieee80211_superg.h> 87e60c4fc2SAdrian Chadd #endif 88e60c4fc2SAdrian Chadd #ifdef IEEE80211_SUPPORT_TDMA 89e60c4fc2SAdrian Chadd #include <net80211/ieee80211_tdma.h> 90e60c4fc2SAdrian Chadd #endif 91e60c4fc2SAdrian Chadd 92e60c4fc2SAdrian Chadd #include <net/bpf.h> 93e60c4fc2SAdrian Chadd 94e60c4fc2SAdrian Chadd #ifdef INET 95e60c4fc2SAdrian Chadd #include <netinet/in.h> 96e60c4fc2SAdrian Chadd #include <netinet/if_ether.h> 97e60c4fc2SAdrian Chadd #endif 98e60c4fc2SAdrian Chadd 99e60c4fc2SAdrian Chadd #include <dev/ath/if_athvar.h> 100e60c4fc2SAdrian Chadd #include <dev/ath/ath_hal/ah_devid.h> /* XXX for softled */ 101e60c4fc2SAdrian Chadd #include <dev/ath/ath_hal/ah_diagcodes.h> 102e60c4fc2SAdrian Chadd 103e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_debug.h> 104e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_misc.h> 105e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_tsf.h> 106e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_tx.h> 107e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_sysctl.h> 108e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_led.h> 109e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_keycache.h> 110e60c4fc2SAdrian Chadd #include <dev/ath/if_ath_rx.h> 111a35dae8dSAdrian Chadd #include <dev/ath/if_ath_beacon.h> 112e60c4fc2SAdrian Chadd #include <dev/ath/if_athdfs.h> 113e60c4fc2SAdrian Chadd 114e60c4fc2SAdrian Chadd #ifdef ATH_TX99_DIAG 115e60c4fc2SAdrian Chadd #include <dev/ath/ath_tx99/ath_tx99.h> 116e60c4fc2SAdrian Chadd #endif 117e60c4fc2SAdrian Chadd 118b69b0dccSAdrian Chadd #ifdef ATH_DEBUG_ALQ 119b69b0dccSAdrian Chadd #include <dev/ath/if_ath_alq.h> 120b69b0dccSAdrian Chadd #endif 121b69b0dccSAdrian Chadd 122e60c4fc2SAdrian Chadd /* 123e60c4fc2SAdrian Chadd * Calculate the receive filter according to the 124e60c4fc2SAdrian Chadd * operating mode and state: 125e60c4fc2SAdrian Chadd * 126e60c4fc2SAdrian Chadd * o always accept unicast, broadcast, and multicast traffic 127e60c4fc2SAdrian Chadd * o accept PHY error frames when hardware doesn't have MIB support 128e60c4fc2SAdrian Chadd * to count and we need them for ANI (sta mode only until recently) 129e60c4fc2SAdrian Chadd * and we are not scanning (ANI is disabled) 130e60c4fc2SAdrian Chadd * NB: older hal's add rx filter bits out of sight and we need to 131e60c4fc2SAdrian Chadd * blindly preserve them 132e60c4fc2SAdrian Chadd * o probe request frames are accepted only when operating in 133e60c4fc2SAdrian Chadd * hostap, adhoc, mesh, or monitor modes 134e60c4fc2SAdrian Chadd * o enable promiscuous mode 135e60c4fc2SAdrian Chadd * - when in monitor mode 136e60c4fc2SAdrian Chadd * - if interface marked PROMISC (assumes bridge setting is filtered) 137e60c4fc2SAdrian Chadd * o accept beacons: 138e60c4fc2SAdrian Chadd * - when operating in station mode for collecting rssi data when 139e60c4fc2SAdrian Chadd * the station is otherwise quiet, or 140e60c4fc2SAdrian Chadd * - when operating in adhoc mode so the 802.11 layer creates 141e60c4fc2SAdrian Chadd * node table entries for peers, 142e60c4fc2SAdrian Chadd * - when scanning 143e60c4fc2SAdrian Chadd * - when doing s/w beacon miss (e.g. for ap+sta) 144e60c4fc2SAdrian Chadd * - when operating in ap mode in 11g to detect overlapping bss that 145e60c4fc2SAdrian Chadd * require protection 146e60c4fc2SAdrian Chadd * - when operating in mesh mode to detect neighbors 147e60c4fc2SAdrian Chadd * o accept control frames: 148e60c4fc2SAdrian Chadd * - when in monitor mode 149e60c4fc2SAdrian Chadd * XXX HT protection for 11n 150e60c4fc2SAdrian Chadd */ 151e60c4fc2SAdrian Chadd u_int32_t 152e60c4fc2SAdrian Chadd ath_calcrxfilter(struct ath_softc *sc) 153e60c4fc2SAdrian Chadd { 154e60c4fc2SAdrian Chadd struct ifnet *ifp = sc->sc_ifp; 155e60c4fc2SAdrian Chadd struct ieee80211com *ic = ifp->if_l2com; 156e60c4fc2SAdrian Chadd u_int32_t rfilt; 157e60c4fc2SAdrian Chadd 158e60c4fc2SAdrian Chadd rfilt = HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; 159e60c4fc2SAdrian Chadd if (!sc->sc_needmib && !sc->sc_scanning) 160e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PHYERR; 161e60c4fc2SAdrian Chadd if (ic->ic_opmode != IEEE80211_M_STA) 162e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PROBEREQ; 163e60c4fc2SAdrian Chadd /* XXX ic->ic_monvaps != 0? */ 164e60c4fc2SAdrian Chadd if (ic->ic_opmode == IEEE80211_M_MONITOR || (ifp->if_flags & IFF_PROMISC)) 165e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PROM; 166e60c4fc2SAdrian Chadd if (ic->ic_opmode == IEEE80211_M_STA || 167e60c4fc2SAdrian Chadd ic->ic_opmode == IEEE80211_M_IBSS || 168e60c4fc2SAdrian Chadd sc->sc_swbmiss || sc->sc_scanning) 169e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_BEACON; 170e60c4fc2SAdrian Chadd /* 171e60c4fc2SAdrian Chadd * NB: We don't recalculate the rx filter when 172e60c4fc2SAdrian Chadd * ic_protmode changes; otherwise we could do 173e60c4fc2SAdrian Chadd * this only when ic_protmode != NONE. 174e60c4fc2SAdrian Chadd */ 175e60c4fc2SAdrian Chadd if (ic->ic_opmode == IEEE80211_M_HOSTAP && 176e60c4fc2SAdrian Chadd IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) 177e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_BEACON; 178e60c4fc2SAdrian Chadd 179e60c4fc2SAdrian Chadd /* 180e60c4fc2SAdrian Chadd * Enable hardware PS-POLL RX only for hostap mode; 181e60c4fc2SAdrian Chadd * STA mode sends PS-POLL frames but never 182e60c4fc2SAdrian Chadd * receives them. 183e60c4fc2SAdrian Chadd */ 184e60c4fc2SAdrian Chadd if (ath_hal_getcapability(sc->sc_ah, HAL_CAP_PSPOLL, 185e60c4fc2SAdrian Chadd 0, NULL) == HAL_OK && 186e60c4fc2SAdrian Chadd ic->ic_opmode == IEEE80211_M_HOSTAP) 187e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PSPOLL; 188e60c4fc2SAdrian Chadd 189e60c4fc2SAdrian Chadd if (sc->sc_nmeshvaps) { 190e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_BEACON; 191e60c4fc2SAdrian Chadd if (sc->sc_hasbmatch) 192e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_BSSID; 193e60c4fc2SAdrian Chadd else 194e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PROM; 195e60c4fc2SAdrian Chadd } 196e60c4fc2SAdrian Chadd if (ic->ic_opmode == IEEE80211_M_MONITOR) 197e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_CONTROL; 198e60c4fc2SAdrian Chadd 199e60c4fc2SAdrian Chadd /* 200e60c4fc2SAdrian Chadd * Enable RX of compressed BAR frames only when doing 201e60c4fc2SAdrian Chadd * 802.11n. Required for A-MPDU. 202e60c4fc2SAdrian Chadd */ 203e60c4fc2SAdrian Chadd if (IEEE80211_IS_CHAN_HT(ic->ic_curchan)) 204e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_COMPBAR; 205e60c4fc2SAdrian Chadd 206e60c4fc2SAdrian Chadd /* 207e60c4fc2SAdrian Chadd * Enable radar PHY errors if requested by the 208e60c4fc2SAdrian Chadd * DFS module. 209e60c4fc2SAdrian Chadd */ 210e60c4fc2SAdrian Chadd if (sc->sc_dodfs) 211e60c4fc2SAdrian Chadd rfilt |= HAL_RX_FILTER_PHYRADAR; 212e60c4fc2SAdrian Chadd 213f29c6bdeSAdrian Chadd /* 214f29c6bdeSAdrian Chadd * Enable spectral PHY errors if requested by the 215f29c6bdeSAdrian Chadd * spectral module. 216f29c6bdeSAdrian Chadd */ 217f29c6bdeSAdrian Chadd if (sc->sc_dospectral) 218f29c6bdeSAdrian Chadd rfilt |= HAL_RX_FILTER_PHYRADAR; 219f29c6bdeSAdrian Chadd 220e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_MODE, "%s: RX filter 0x%x, %s if_flags 0x%x\n", 221e60c4fc2SAdrian Chadd __func__, rfilt, ieee80211_opmode_name[ic->ic_opmode], ifp->if_flags); 222e60c4fc2SAdrian Chadd return rfilt; 223e60c4fc2SAdrian Chadd } 224e60c4fc2SAdrian Chadd 225f8cc9b09SAdrian Chadd static int 226f8cc9b09SAdrian Chadd ath_legacy_rxbuf_init(struct ath_softc *sc, struct ath_buf *bf) 227e60c4fc2SAdrian Chadd { 228e60c4fc2SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 229e60c4fc2SAdrian Chadd int error; 230e60c4fc2SAdrian Chadd struct mbuf *m; 231e60c4fc2SAdrian Chadd struct ath_desc *ds; 232e60c4fc2SAdrian Chadd 233e60c4fc2SAdrian Chadd m = bf->bf_m; 234e60c4fc2SAdrian Chadd if (m == NULL) { 235e60c4fc2SAdrian Chadd /* 236e60c4fc2SAdrian Chadd * NB: by assigning a page to the rx dma buffer we 237e60c4fc2SAdrian Chadd * implicitly satisfy the Atheros requirement that 238e60c4fc2SAdrian Chadd * this buffer be cache-line-aligned and sized to be 239e60c4fc2SAdrian Chadd * multiple of the cache line size. Not doing this 240e60c4fc2SAdrian Chadd * causes weird stuff to happen (for the 5210 at least). 241e60c4fc2SAdrian Chadd */ 242c6499eccSGleb Smirnoff m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); 243e60c4fc2SAdrian Chadd if (m == NULL) { 244e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_ANY, 245e60c4fc2SAdrian Chadd "%s: no mbuf/cluster\n", __func__); 246e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_nombuf++; 247e60c4fc2SAdrian Chadd return ENOMEM; 248e60c4fc2SAdrian Chadd } 249e60c4fc2SAdrian Chadd m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; 250e60c4fc2SAdrian Chadd 251e60c4fc2SAdrian Chadd error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, 252e60c4fc2SAdrian Chadd bf->bf_dmamap, m, 253e60c4fc2SAdrian Chadd bf->bf_segs, &bf->bf_nseg, 254e60c4fc2SAdrian Chadd BUS_DMA_NOWAIT); 255e60c4fc2SAdrian Chadd if (error != 0) { 256e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_ANY, 257e60c4fc2SAdrian Chadd "%s: bus_dmamap_load_mbuf_sg failed; error %d\n", 258e60c4fc2SAdrian Chadd __func__, error); 259e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_busdma++; 260e60c4fc2SAdrian Chadd m_freem(m); 261e60c4fc2SAdrian Chadd return error; 262e60c4fc2SAdrian Chadd } 263e60c4fc2SAdrian Chadd KASSERT(bf->bf_nseg == 1, 264e60c4fc2SAdrian Chadd ("multi-segment packet; nseg %u", bf->bf_nseg)); 265e60c4fc2SAdrian Chadd bf->bf_m = m; 266e60c4fc2SAdrian Chadd } 267e60c4fc2SAdrian Chadd bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_PREREAD); 268e60c4fc2SAdrian Chadd 269e60c4fc2SAdrian Chadd /* 270e60c4fc2SAdrian Chadd * Setup descriptors. For receive we always terminate 271e60c4fc2SAdrian Chadd * the descriptor list with a self-linked entry so we'll 272e60c4fc2SAdrian Chadd * not get overrun under high load (as can happen with a 273e60c4fc2SAdrian Chadd * 5212 when ANI processing enables PHY error frames). 274e60c4fc2SAdrian Chadd * 275e60c4fc2SAdrian Chadd * To insure the last descriptor is self-linked we create 276e60c4fc2SAdrian Chadd * each descriptor as self-linked and add it to the end. As 277e60c4fc2SAdrian Chadd * each additional descriptor is added the previous self-linked 278e60c4fc2SAdrian Chadd * entry is ``fixed'' naturally. This should be safe even 279e60c4fc2SAdrian Chadd * if DMA is happening. When processing RX interrupts we 280e60c4fc2SAdrian Chadd * never remove/process the last, self-linked, entry on the 281e60c4fc2SAdrian Chadd * descriptor list. This insures the hardware always has 282e60c4fc2SAdrian Chadd * someplace to write a new frame. 283e60c4fc2SAdrian Chadd */ 284e60c4fc2SAdrian Chadd /* 285e60c4fc2SAdrian Chadd * 11N: we can no longer afford to self link the last descriptor. 286e60c4fc2SAdrian Chadd * MAC acknowledges BA status as long as it copies frames to host 287e60c4fc2SAdrian Chadd * buffer (or rx fifo). This can incorrectly acknowledge packets 288e60c4fc2SAdrian Chadd * to a sender if last desc is self-linked. 289e60c4fc2SAdrian Chadd */ 290e60c4fc2SAdrian Chadd ds = bf->bf_desc; 291e60c4fc2SAdrian Chadd if (sc->sc_rxslink) 292e60c4fc2SAdrian Chadd ds->ds_link = bf->bf_daddr; /* link to self */ 293e60c4fc2SAdrian Chadd else 294e60c4fc2SAdrian Chadd ds->ds_link = 0; /* terminate the list */ 295e60c4fc2SAdrian Chadd ds->ds_data = bf->bf_segs[0].ds_addr; 296e60c4fc2SAdrian Chadd ath_hal_setuprxdesc(ah, ds 297e60c4fc2SAdrian Chadd , m->m_len /* buffer size */ 298e60c4fc2SAdrian Chadd , 0 299e60c4fc2SAdrian Chadd ); 300e60c4fc2SAdrian Chadd 301e60c4fc2SAdrian Chadd if (sc->sc_rxlink != NULL) 302e60c4fc2SAdrian Chadd *sc->sc_rxlink = bf->bf_daddr; 303e60c4fc2SAdrian Chadd sc->sc_rxlink = &ds->ds_link; 304e60c4fc2SAdrian Chadd return 0; 305e60c4fc2SAdrian Chadd } 306e60c4fc2SAdrian Chadd 307e60c4fc2SAdrian Chadd /* 308e60c4fc2SAdrian Chadd * Intercept management frames to collect beacon rssi data 309e60c4fc2SAdrian Chadd * and to do ibss merges. 310e60c4fc2SAdrian Chadd */ 311e60c4fc2SAdrian Chadd void 312e60c4fc2SAdrian Chadd ath_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, 313e60c4fc2SAdrian Chadd int subtype, int rssi, int nf) 314e60c4fc2SAdrian Chadd { 315e60c4fc2SAdrian Chadd struct ieee80211vap *vap = ni->ni_vap; 316e60c4fc2SAdrian Chadd struct ath_softc *sc = vap->iv_ic->ic_ifp->if_softc; 317e60c4fc2SAdrian Chadd 318e60c4fc2SAdrian Chadd /* 319e60c4fc2SAdrian Chadd * Call up first so subsequent work can use information 320e60c4fc2SAdrian Chadd * potentially stored in the node (e.g. for ibss merge). 321e60c4fc2SAdrian Chadd */ 322e60c4fc2SAdrian Chadd ATH_VAP(vap)->av_recv_mgmt(ni, m, subtype, rssi, nf); 323e60c4fc2SAdrian Chadd switch (subtype) { 324e60c4fc2SAdrian Chadd case IEEE80211_FC0_SUBTYPE_BEACON: 325e60c4fc2SAdrian Chadd /* update rssi statistics for use by the hal */ 326e60c4fc2SAdrian Chadd /* XXX unlocked check against vap->iv_bss? */ 327e60c4fc2SAdrian Chadd ATH_RSSI_LPF(sc->sc_halstats.ns_avgbrssi, rssi); 328e60c4fc2SAdrian Chadd if (sc->sc_syncbeacon && 329e60c4fc2SAdrian Chadd ni == vap->iv_bss && vap->iv_state == IEEE80211_S_RUN) { 330e60c4fc2SAdrian Chadd /* 331e60c4fc2SAdrian Chadd * Resync beacon timers using the tsf of the beacon 332e60c4fc2SAdrian Chadd * frame we just received. 333e60c4fc2SAdrian Chadd */ 334e60c4fc2SAdrian Chadd ath_beacon_config(sc, vap); 335e60c4fc2SAdrian Chadd } 336e60c4fc2SAdrian Chadd /* fall thru... */ 337e60c4fc2SAdrian Chadd case IEEE80211_FC0_SUBTYPE_PROBE_RESP: 338e60c4fc2SAdrian Chadd if (vap->iv_opmode == IEEE80211_M_IBSS && 339e60c4fc2SAdrian Chadd vap->iv_state == IEEE80211_S_RUN) { 340e60c4fc2SAdrian Chadd uint32_t rstamp = sc->sc_lastrs->rs_tstamp; 341e60c4fc2SAdrian Chadd uint64_t tsf = ath_extend_tsf(sc, rstamp, 342e60c4fc2SAdrian Chadd ath_hal_gettsf64(sc->sc_ah)); 343e60c4fc2SAdrian Chadd /* 344e60c4fc2SAdrian Chadd * Handle ibss merge as needed; check the tsf on the 345e60c4fc2SAdrian Chadd * frame before attempting the merge. The 802.11 spec 346e60c4fc2SAdrian Chadd * says the station should change it's bssid to match 347e60c4fc2SAdrian Chadd * the oldest station with the same ssid, where oldest 348e60c4fc2SAdrian Chadd * is determined by the tsf. Note that hardware 349e60c4fc2SAdrian Chadd * reconfiguration happens through callback to 350e60c4fc2SAdrian Chadd * ath_newstate as the state machine will go from 351e60c4fc2SAdrian Chadd * RUN -> RUN when this happens. 352e60c4fc2SAdrian Chadd */ 353e60c4fc2SAdrian Chadd if (le64toh(ni->ni_tstamp.tsf) >= tsf) { 354e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_STATE, 355e60c4fc2SAdrian Chadd "ibss merge, rstamp %u tsf %ju " 356e60c4fc2SAdrian Chadd "tstamp %ju\n", rstamp, (uintmax_t)tsf, 357e60c4fc2SAdrian Chadd (uintmax_t)ni->ni_tstamp.tsf); 358e60c4fc2SAdrian Chadd (void) ieee80211_ibss_merge(ni); 359e60c4fc2SAdrian Chadd } 360e60c4fc2SAdrian Chadd } 361e60c4fc2SAdrian Chadd break; 362e60c4fc2SAdrian Chadd } 363e60c4fc2SAdrian Chadd } 364e60c4fc2SAdrian Chadd 365e1b5ab97SAdrian Chadd #ifdef ATH_ENABLE_RADIOTAP_VENDOR_EXT 366e1b5ab97SAdrian Chadd static void 367e1b5ab97SAdrian Chadd ath_rx_tap_vendor(struct ifnet *ifp, struct mbuf *m, 368e1b5ab97SAdrian Chadd const struct ath_rx_status *rs, u_int64_t tsf, int16_t nf) 369e1b5ab97SAdrian Chadd { 370e1b5ab97SAdrian Chadd struct ath_softc *sc = ifp->if_softc; 371e1b5ab97SAdrian Chadd 372e1b5ab97SAdrian Chadd /* Fill in the extension bitmap */ 373e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_ext_bitmap = htole32(1 << ATH_RADIOTAP_VENDOR_HEADER); 374e1b5ab97SAdrian Chadd 375e1b5ab97SAdrian Chadd /* Fill in the vendor header */ 376e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_vh.vh_oui[0] = 0x7f; 377e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_vh.vh_oui[1] = 0x03; 378e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_vh.vh_oui[2] = 0x00; 379e1b5ab97SAdrian Chadd 380e1b5ab97SAdrian Chadd /* XXX what should this be? */ 381e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_vh.vh_sub_ns = 0; 382e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_vh.vh_skip_len = 383e1b5ab97SAdrian Chadd htole16(sizeof(struct ath_radiotap_vendor_hdr)); 384e1b5ab97SAdrian Chadd 385e1b5ab97SAdrian Chadd /* General version info */ 386e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_version = 1; 387e1b5ab97SAdrian Chadd 388e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_rx_chainmask = sc->sc_rxchainmask; 389e1b5ab97SAdrian Chadd 390e1b5ab97SAdrian Chadd /* rssi */ 391e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ctl[0] = rs->rs_rssi_ctl[0]; 392e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ctl[1] = rs->rs_rssi_ctl[1]; 393e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ctl[2] = rs->rs_rssi_ctl[2]; 394e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ext[0] = rs->rs_rssi_ext[0]; 395e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ext[1] = rs->rs_rssi_ext[1]; 396e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.rssi_ext[2] = rs->rs_rssi_ext[2]; 397e1b5ab97SAdrian Chadd 398e1b5ab97SAdrian Chadd /* evm */ 399e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.evm[0] = rs->rs_evm0; 400e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.evm[1] = rs->rs_evm1; 401e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.evm[2] = rs->rs_evm2; 4021896b088SAdrian Chadd /* These are only populated from the AR9300 or later */ 4031896b088SAdrian Chadd sc->sc_rx_th.wr_v.evm[3] = rs->rs_evm3; 4041896b088SAdrian Chadd sc->sc_rx_th.wr_v.evm[4] = rs->rs_evm4; 405e1b5ab97SAdrian Chadd 4060e168bb8SAdrian Chadd /* direction */ 4070e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_flags = ATH_VENDOR_PKT_RX; 4080e168bb8SAdrian Chadd 4090e168bb8SAdrian Chadd /* RX rate */ 4100e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_rx_hwrate = rs->rs_rate; 4110e168bb8SAdrian Chadd 4120e168bb8SAdrian Chadd /* RX flags */ 4130e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_rs_flags = rs->rs_flags; 4140e168bb8SAdrian Chadd 4150e168bb8SAdrian Chadd if (rs->rs_isaggr) 4160e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_flags |= ATH_VENDOR_PKT_ISAGGR; 4170e168bb8SAdrian Chadd if (rs->rs_moreaggr) 4180e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_flags |= ATH_VENDOR_PKT_MOREAGGR; 4190e168bb8SAdrian Chadd 420e1b5ab97SAdrian Chadd /* phyerr info */ 4210e168bb8SAdrian Chadd if (rs->rs_status & HAL_RXERR_PHY) { 422e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_phyerr_code = rs->rs_phyerr; 4230e168bb8SAdrian Chadd sc->sc_rx_th.wr_v.vh_flags |= ATH_VENDOR_PKT_RXPHYERR; 4240e168bb8SAdrian Chadd } else { 425e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_phyerr_code = 0xff; 4260e168bb8SAdrian Chadd } 427e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_rs_status = rs->rs_status; 428e1b5ab97SAdrian Chadd sc->sc_rx_th.wr_v.vh_rssi = rs->rs_rssi; 429e1b5ab97SAdrian Chadd } 430e1b5ab97SAdrian Chadd #endif /* ATH_ENABLE_RADIOTAP_VENDOR_EXT */ 431e1b5ab97SAdrian Chadd 432e60c4fc2SAdrian Chadd static void 433e60c4fc2SAdrian Chadd ath_rx_tap(struct ifnet *ifp, struct mbuf *m, 434e60c4fc2SAdrian Chadd const struct ath_rx_status *rs, u_int64_t tsf, int16_t nf) 435e60c4fc2SAdrian Chadd { 436e60c4fc2SAdrian Chadd #define CHAN_HT20 htole32(IEEE80211_CHAN_HT20) 437e60c4fc2SAdrian Chadd #define CHAN_HT40U htole32(IEEE80211_CHAN_HT40U) 438e60c4fc2SAdrian Chadd #define CHAN_HT40D htole32(IEEE80211_CHAN_HT40D) 439e60c4fc2SAdrian Chadd #define CHAN_HT (CHAN_HT20|CHAN_HT40U|CHAN_HT40D) 440e60c4fc2SAdrian Chadd struct ath_softc *sc = ifp->if_softc; 441e60c4fc2SAdrian Chadd const HAL_RATE_TABLE *rt; 442e60c4fc2SAdrian Chadd uint8_t rix; 443e60c4fc2SAdrian Chadd 444e60c4fc2SAdrian Chadd rt = sc->sc_currates; 445e60c4fc2SAdrian Chadd KASSERT(rt != NULL, ("no rate table, mode %u", sc->sc_curmode)); 446e60c4fc2SAdrian Chadd rix = rt->rateCodeToIndex[rs->rs_rate]; 447e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_rate = sc->sc_hwmap[rix].ieeerate; 448e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_flags = sc->sc_hwmap[rix].rxflags; 449e60c4fc2SAdrian Chadd #ifdef AH_SUPPORT_AR5416 450e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_chan_flags &= ~CHAN_HT; 45155caa1dfSAdrian Chadd if (rs->rs_status & HAL_RXERR_PHY) { 45255caa1dfSAdrian Chadd /* 45355caa1dfSAdrian Chadd * PHY error - make sure the channel flags 45455caa1dfSAdrian Chadd * reflect the actual channel configuration, 45555caa1dfSAdrian Chadd * not the received frame. 45655caa1dfSAdrian Chadd */ 457b8f355bfSAdrian Chadd if (IEEE80211_IS_CHAN_HT40U(sc->sc_curchan)) 45855caa1dfSAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT40U; 459b8f355bfSAdrian Chadd else if (IEEE80211_IS_CHAN_HT40D(sc->sc_curchan)) 46055caa1dfSAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT40D; 461b8f355bfSAdrian Chadd else if (IEEE80211_IS_CHAN_HT20(sc->sc_curchan)) 46255caa1dfSAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT20; 46355caa1dfSAdrian Chadd } else if (sc->sc_rx_th.wr_rate & IEEE80211_RATE_MCS) { /* HT rate */ 464e60c4fc2SAdrian Chadd struct ieee80211com *ic = ifp->if_l2com; 465e60c4fc2SAdrian Chadd 466e60c4fc2SAdrian Chadd if ((rs->rs_flags & HAL_RX_2040) == 0) 467e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT20; 468e60c4fc2SAdrian Chadd else if (IEEE80211_IS_CHAN_HT40U(ic->ic_curchan)) 469e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT40U; 470e60c4fc2SAdrian Chadd else 471e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_chan_flags |= CHAN_HT40D; 472e60c4fc2SAdrian Chadd if ((rs->rs_flags & HAL_RX_GI) == 0) 473e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_SHORTGI; 474e60c4fc2SAdrian Chadd } 47555caa1dfSAdrian Chadd 476e60c4fc2SAdrian Chadd #endif 477e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_tsf = htole64(ath_extend_tsf(sc, rs->rs_tstamp, tsf)); 478e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_CRC) 479e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; 480e60c4fc2SAdrian Chadd /* XXX propagate other error flags from descriptor */ 481e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_antnoise = nf; 482e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_antsignal = nf + rs->rs_rssi; 483e60c4fc2SAdrian Chadd sc->sc_rx_th.wr_antenna = rs->rs_antenna; 484e60c4fc2SAdrian Chadd #undef CHAN_HT 485e60c4fc2SAdrian Chadd #undef CHAN_HT20 486e60c4fc2SAdrian Chadd #undef CHAN_HT40U 487e60c4fc2SAdrian Chadd #undef CHAN_HT40D 488e60c4fc2SAdrian Chadd } 489e60c4fc2SAdrian Chadd 490e60c4fc2SAdrian Chadd static void 491e60c4fc2SAdrian Chadd ath_handle_micerror(struct ieee80211com *ic, 492e60c4fc2SAdrian Chadd struct ieee80211_frame *wh, int keyix) 493e60c4fc2SAdrian Chadd { 494e60c4fc2SAdrian Chadd struct ieee80211_node *ni; 495e60c4fc2SAdrian Chadd 496e60c4fc2SAdrian Chadd /* XXX recheck MIC to deal w/ chips that lie */ 497e60c4fc2SAdrian Chadd /* XXX discard MIC errors on !data frames */ 498e60c4fc2SAdrian Chadd ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) wh); 499e60c4fc2SAdrian Chadd if (ni != NULL) { 500e60c4fc2SAdrian Chadd ieee80211_notify_michael_failure(ni->ni_vap, wh, keyix); 501e60c4fc2SAdrian Chadd ieee80211_free_node(ni); 502e60c4fc2SAdrian Chadd } 503e60c4fc2SAdrian Chadd } 504e60c4fc2SAdrian Chadd 5058cc724d9SAdrian Chadd /* 5068cc724d9SAdrian Chadd * Process a single packet. 5078cc724d9SAdrian Chadd * 5088cc724d9SAdrian Chadd * The mbuf must already be synced, unmapped and removed from bf->bf_m 5098cc724d9SAdrian Chadd * by this stage. 5108cc724d9SAdrian Chadd * 5118cc724d9SAdrian Chadd * The mbuf must be consumed by this routine - either passed up the 5128cc724d9SAdrian Chadd * net80211 stack, put on the holding queue, or freed. 5138cc724d9SAdrian Chadd */ 514d434a377SAdrian Chadd int 515d542f7f6SAdrian Chadd ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status *rs, HAL_STATUS status, 5168cc724d9SAdrian Chadd uint64_t tsf, int nf, HAL_RX_QUEUE qtype, struct ath_buf *bf, 5178cc724d9SAdrian Chadd struct mbuf *m) 518e60c4fc2SAdrian Chadd { 519d542f7f6SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 520d542f7f6SAdrian Chadd uint64_t rstamp; 521d542f7f6SAdrian Chadd int len, type; 522e60c4fc2SAdrian Chadd struct ifnet *ifp = sc->sc_ifp; 523e60c4fc2SAdrian Chadd struct ieee80211com *ic = ifp->if_l2com; 524e60c4fc2SAdrian Chadd struct ieee80211_node *ni; 525d542f7f6SAdrian Chadd int is_good = 0; 526d434a377SAdrian Chadd struct ath_rx_edma *re = &sc->sc_rxedma[qtype]; 527e60c4fc2SAdrian Chadd 528e60c4fc2SAdrian Chadd /* 529e60c4fc2SAdrian Chadd * Calculate the correct 64 bit TSF given 530e60c4fc2SAdrian Chadd * the TSF64 register value and rs_tstamp. 531e60c4fc2SAdrian Chadd */ 532e60c4fc2SAdrian Chadd rstamp = ath_extend_tsf(sc, rs->rs_tstamp, tsf); 533e60c4fc2SAdrian Chadd 534e60c4fc2SAdrian Chadd /* These aren't specifically errors */ 535e60c4fc2SAdrian Chadd #ifdef AH_SUPPORT_AR5416 536e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_GI) 537e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_halfgi++; 538e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_2040) 539e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_2040++; 540e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_DELIM_CRC_PRE) 541e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_pre_crc_err++; 542e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_DELIM_CRC_POST) 543e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_post_crc_err++; 544e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_DECRYPT_BUSY) 545e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_decrypt_busy_err++; 546e60c4fc2SAdrian Chadd if (rs->rs_flags & HAL_RX_HI_RX_CHAIN) 547e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_hi_rx_chain++; 5482c47932cSAdrian Chadd if (rs->rs_flags & HAL_RX_STBC) 5492c47932cSAdrian Chadd sc->sc_stats.ast_rx_stbc++; 550e60c4fc2SAdrian Chadd #endif /* AH_SUPPORT_AR5416 */ 551e60c4fc2SAdrian Chadd 552e60c4fc2SAdrian Chadd if (rs->rs_status != 0) { 553e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_CRC) 554e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_crcerr++; 555e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_FIFO) 556e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_fifoerr++; 557e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_PHY) { 558e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_phyerr++; 559e60c4fc2SAdrian Chadd /* Process DFS radar events */ 560e60c4fc2SAdrian Chadd if ((rs->rs_phyerr == HAL_PHYERR_RADAR) || 561e60c4fc2SAdrian Chadd (rs->rs_phyerr == HAL_PHYERR_FALSE_RADAR_EXT)) { 562e60c4fc2SAdrian Chadd /* Now pass it to the radar processing code */ 563d77363adSAdrian Chadd ath_dfs_process_phy_err(sc, m, rstamp, rs); 564e60c4fc2SAdrian Chadd } 565e60c4fc2SAdrian Chadd 566e60c4fc2SAdrian Chadd /* Be suitably paranoid about receiving phy errors out of the stats array bounds */ 567e60c4fc2SAdrian Chadd if (rs->rs_phyerr < 64) 568e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_phy[rs->rs_phyerr]++; 569e60c4fc2SAdrian Chadd goto rx_error; /* NB: don't count in ierrors */ 570e60c4fc2SAdrian Chadd } 571e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_DECRYPT) { 572e60c4fc2SAdrian Chadd /* 573e60c4fc2SAdrian Chadd * Decrypt error. If the error occurred 574e60c4fc2SAdrian Chadd * because there was no hardware key, then 575e60c4fc2SAdrian Chadd * let the frame through so the upper layers 576e60c4fc2SAdrian Chadd * can process it. This is necessary for 5210 577e60c4fc2SAdrian Chadd * parts which have no way to setup a ``clear'' 578e60c4fc2SAdrian Chadd * key cache entry. 579e60c4fc2SAdrian Chadd * 580e60c4fc2SAdrian Chadd * XXX do key cache faulting 581e60c4fc2SAdrian Chadd */ 582e60c4fc2SAdrian Chadd if (rs->rs_keyix == HAL_RXKEYIX_INVALID) 583e60c4fc2SAdrian Chadd goto rx_accept; 584e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_badcrypt++; 585e60c4fc2SAdrian Chadd } 586c7f5bb7aSAdrian Chadd /* 587c7f5bb7aSAdrian Chadd * Similar as above - if the failure was a keymiss 588c7f5bb7aSAdrian Chadd * just punt it up to the upper layers for now. 589c7f5bb7aSAdrian Chadd */ 590c7f5bb7aSAdrian Chadd if (rs->rs_status & HAL_RXERR_KEYMISS) { 591c7f5bb7aSAdrian Chadd sc->sc_stats.ast_rx_keymiss++; 592c7f5bb7aSAdrian Chadd goto rx_accept; 593c7f5bb7aSAdrian Chadd } 594e60c4fc2SAdrian Chadd if (rs->rs_status & HAL_RXERR_MIC) { 595e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_badmic++; 596e60c4fc2SAdrian Chadd /* 597e60c4fc2SAdrian Chadd * Do minimal work required to hand off 598e60c4fc2SAdrian Chadd * the 802.11 header for notification. 599e60c4fc2SAdrian Chadd */ 600e60c4fc2SAdrian Chadd /* XXX frag's and qos frames */ 601e60c4fc2SAdrian Chadd len = rs->rs_datalen; 602e60c4fc2SAdrian Chadd if (len >= sizeof (struct ieee80211_frame)) { 603e60c4fc2SAdrian Chadd ath_handle_micerror(ic, 604e60c4fc2SAdrian Chadd mtod(m, struct ieee80211_frame *), 605e60c4fc2SAdrian Chadd sc->sc_splitmic ? 606e60c4fc2SAdrian Chadd rs->rs_keyix-32 : rs->rs_keyix); 607e60c4fc2SAdrian Chadd } 608e60c4fc2SAdrian Chadd } 609e60c4fc2SAdrian Chadd ifp->if_ierrors++; 610e60c4fc2SAdrian Chadd rx_error: 611e60c4fc2SAdrian Chadd /* 612e60c4fc2SAdrian Chadd * Cleanup any pending partial frame. 613e60c4fc2SAdrian Chadd */ 614d434a377SAdrian Chadd if (re->m_rxpending != NULL) { 615d434a377SAdrian Chadd m_freem(re->m_rxpending); 616d434a377SAdrian Chadd re->m_rxpending = NULL; 617e60c4fc2SAdrian Chadd } 618e60c4fc2SAdrian Chadd /* 619e60c4fc2SAdrian Chadd * When a tap is present pass error frames 620e60c4fc2SAdrian Chadd * that have been requested. By default we 621e60c4fc2SAdrian Chadd * pass decrypt+mic errors but others may be 622e60c4fc2SAdrian Chadd * interesting (e.g. crc). 623e60c4fc2SAdrian Chadd */ 624e60c4fc2SAdrian Chadd if (ieee80211_radiotap_active(ic) && 625e60c4fc2SAdrian Chadd (rs->rs_status & sc->sc_monpass)) { 626e60c4fc2SAdrian Chadd /* NB: bpf needs the mbuf length setup */ 627e60c4fc2SAdrian Chadd len = rs->rs_datalen; 628e60c4fc2SAdrian Chadd m->m_pkthdr.len = m->m_len = len; 629e60c4fc2SAdrian Chadd ath_rx_tap(ifp, m, rs, rstamp, nf); 630e1b5ab97SAdrian Chadd #ifdef ATH_ENABLE_RADIOTAP_VENDOR_EXT 631e1b5ab97SAdrian Chadd ath_rx_tap_vendor(ifp, m, rs, rstamp, nf); 632e1b5ab97SAdrian Chadd #endif /* ATH_ENABLE_RADIOTAP_VENDOR_EXT */ 633e60c4fc2SAdrian Chadd ieee80211_radiotap_rx_all(ic, m); 634e60c4fc2SAdrian Chadd } 635e60c4fc2SAdrian Chadd /* XXX pass MIC errors up for s/w reclaculation */ 6368cc724d9SAdrian Chadd m_freem(m); m = NULL; 637e60c4fc2SAdrian Chadd goto rx_next; 638e60c4fc2SAdrian Chadd } 639e60c4fc2SAdrian Chadd rx_accept: 640e60c4fc2SAdrian Chadd len = rs->rs_datalen; 641e60c4fc2SAdrian Chadd m->m_len = len; 642e60c4fc2SAdrian Chadd 643e60c4fc2SAdrian Chadd if (rs->rs_more) { 644e60c4fc2SAdrian Chadd /* 645e60c4fc2SAdrian Chadd * Frame spans multiple descriptors; save 646e60c4fc2SAdrian Chadd * it for the next completed descriptor, it 647e60c4fc2SAdrian Chadd * will be used to construct a jumbogram. 648e60c4fc2SAdrian Chadd */ 649d434a377SAdrian Chadd if (re->m_rxpending != NULL) { 650e60c4fc2SAdrian Chadd /* NB: max frame size is currently 2 clusters */ 651e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_toobig++; 652d434a377SAdrian Chadd m_freem(re->m_rxpending); 653e60c4fc2SAdrian Chadd } 654e60c4fc2SAdrian Chadd m->m_pkthdr.rcvif = ifp; 655e60c4fc2SAdrian Chadd m->m_pkthdr.len = len; 656d434a377SAdrian Chadd re->m_rxpending = m; 6578cc724d9SAdrian Chadd m = NULL; 658e60c4fc2SAdrian Chadd goto rx_next; 659d434a377SAdrian Chadd } else if (re->m_rxpending != NULL) { 660e60c4fc2SAdrian Chadd /* 661e60c4fc2SAdrian Chadd * This is the second part of a jumbogram, 662e60c4fc2SAdrian Chadd * chain it to the first mbuf, adjust the 663e60c4fc2SAdrian Chadd * frame length, and clear the rxpending state. 664e60c4fc2SAdrian Chadd */ 665d434a377SAdrian Chadd re->m_rxpending->m_next = m; 666d434a377SAdrian Chadd re->m_rxpending->m_pkthdr.len += len; 667d434a377SAdrian Chadd m = re->m_rxpending; 668d434a377SAdrian Chadd re->m_rxpending = NULL; 669e60c4fc2SAdrian Chadd } else { 670e60c4fc2SAdrian Chadd /* 671e60c4fc2SAdrian Chadd * Normal single-descriptor receive; setup 672e60c4fc2SAdrian Chadd * the rcvif and packet length. 673e60c4fc2SAdrian Chadd */ 674e60c4fc2SAdrian Chadd m->m_pkthdr.rcvif = ifp; 675e60c4fc2SAdrian Chadd m->m_pkthdr.len = len; 676e60c4fc2SAdrian Chadd } 677e60c4fc2SAdrian Chadd 678e60c4fc2SAdrian Chadd /* 679e60c4fc2SAdrian Chadd * Validate rs->rs_antenna. 680e60c4fc2SAdrian Chadd * 681e60c4fc2SAdrian Chadd * Some users w/ AR9285 NICs have reported crashes 682e60c4fc2SAdrian Chadd * here because rs_antenna field is bogusly large. 683e60c4fc2SAdrian Chadd * Let's enforce the maximum antenna limit of 8 684e60c4fc2SAdrian Chadd * (and it shouldn't be hard coded, but that's a 685e60c4fc2SAdrian Chadd * separate problem) and if there's an issue, print 686e60c4fc2SAdrian Chadd * out an error and adjust rs_antenna to something 687e60c4fc2SAdrian Chadd * sensible. 688e60c4fc2SAdrian Chadd * 689e60c4fc2SAdrian Chadd * This code should be removed once the actual 690e60c4fc2SAdrian Chadd * root cause of the issue has been identified. 691e60c4fc2SAdrian Chadd * For example, it may be that the rs_antenna 692e60c4fc2SAdrian Chadd * field is only valid for the lsat frame of 693e60c4fc2SAdrian Chadd * an aggregate and it just happens that it is 694e60c4fc2SAdrian Chadd * "mostly" right. (This is a general statement - 695e60c4fc2SAdrian Chadd * the majority of the statistics are only valid 696e60c4fc2SAdrian Chadd * for the last frame in an aggregate. 697e60c4fc2SAdrian Chadd */ 698e60c4fc2SAdrian Chadd if (rs->rs_antenna > 7) { 699e60c4fc2SAdrian Chadd device_printf(sc->sc_dev, "%s: rs_antenna > 7 (%d)\n", 700e60c4fc2SAdrian Chadd __func__, rs->rs_antenna); 701e60c4fc2SAdrian Chadd #ifdef ATH_DEBUG 702e60c4fc2SAdrian Chadd ath_printrxbuf(sc, bf, 0, status == HAL_OK); 703e60c4fc2SAdrian Chadd #endif /* ATH_DEBUG */ 704e60c4fc2SAdrian Chadd rs->rs_antenna = 0; /* XXX better than nothing */ 705e60c4fc2SAdrian Chadd } 706e60c4fc2SAdrian Chadd 707*3df7a8abSAdrian Chadd /* 708*3df7a8abSAdrian Chadd * If this is an AR9285/AR9485, then the receive and LNA 709*3df7a8abSAdrian Chadd * configuration is stored in RSSI[2] / EXTRSSI[2]. 710*3df7a8abSAdrian Chadd * We can extract this out to build a much better 711*3df7a8abSAdrian Chadd * receive antenna profile. 712*3df7a8abSAdrian Chadd * 713*3df7a8abSAdrian Chadd * Yes, this just blurts over the above RX antenna field 714*3df7a8abSAdrian Chadd * for now. It's fine, the AR9285 doesn't really use 715*3df7a8abSAdrian Chadd * that. 716*3df7a8abSAdrian Chadd * 717*3df7a8abSAdrian Chadd * Later on we should store away the fine grained LNA 718*3df7a8abSAdrian Chadd * information and keep separate counters just for 719*3df7a8abSAdrian Chadd * that. It'll help when debugging the AR9285/AR9485 720*3df7a8abSAdrian Chadd * combined diversity code. 721*3df7a8abSAdrian Chadd */ 722*3df7a8abSAdrian Chadd if (sc->sc_rx_lnamixer) { 723*3df7a8abSAdrian Chadd rs->rs_antenna = 0; 724*3df7a8abSAdrian Chadd 725*3df7a8abSAdrian Chadd /* Bits 0:1 - the LNA configuration used */ 726*3df7a8abSAdrian Chadd rs->rs_antenna |= 727*3df7a8abSAdrian Chadd ((rs->rs_rssi_ctl[2] & HAL_RX_LNA_CFG_USED) 728*3df7a8abSAdrian Chadd >> HAL_RX_LNA_CFG_USED_S); 729*3df7a8abSAdrian Chadd 730*3df7a8abSAdrian Chadd /* Bit 2 - the external RX antenna switch */ 731*3df7a8abSAdrian Chadd if (rs->rs_rssi_ctl[2] & HAL_RX_LNA_EXTCFG) 732*3df7a8abSAdrian Chadd rs->rs_antenna |= 0x4; 733*3df7a8abSAdrian Chadd } 734*3df7a8abSAdrian Chadd 735e60c4fc2SAdrian Chadd ifp->if_ipackets++; 736e60c4fc2SAdrian Chadd sc->sc_stats.ast_ant_rx[rs->rs_antenna]++; 737e60c4fc2SAdrian Chadd 738e60c4fc2SAdrian Chadd /* 739e60c4fc2SAdrian Chadd * Populate the rx status block. When there are bpf 740e60c4fc2SAdrian Chadd * listeners we do the additional work to provide 741e60c4fc2SAdrian Chadd * complete status. Otherwise we fill in only the 742e60c4fc2SAdrian Chadd * material required by ieee80211_input. Note that 743e60c4fc2SAdrian Chadd * noise setting is filled in above. 744e60c4fc2SAdrian Chadd */ 745e1b5ab97SAdrian Chadd if (ieee80211_radiotap_active(ic)) { 746e60c4fc2SAdrian Chadd ath_rx_tap(ifp, m, rs, rstamp, nf); 747e1b5ab97SAdrian Chadd #ifdef ATH_ENABLE_RADIOTAP_VENDOR_EXT 748e1b5ab97SAdrian Chadd ath_rx_tap_vendor(ifp, m, rs, rstamp, nf); 749e1b5ab97SAdrian Chadd #endif /* ATH_ENABLE_RADIOTAP_VENDOR_EXT */ 750e1b5ab97SAdrian Chadd } 751e60c4fc2SAdrian Chadd 752e60c4fc2SAdrian Chadd /* 753e60c4fc2SAdrian Chadd * From this point on we assume the frame is at least 754e60c4fc2SAdrian Chadd * as large as ieee80211_frame_min; verify that. 755e60c4fc2SAdrian Chadd */ 756e60c4fc2SAdrian Chadd if (len < IEEE80211_MIN_LEN) { 757e60c4fc2SAdrian Chadd if (!ieee80211_radiotap_active(ic)) { 758e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RECV, 759e60c4fc2SAdrian Chadd "%s: short packet %d\n", __func__, len); 760e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_tooshort++; 761e60c4fc2SAdrian Chadd } else { 762e60c4fc2SAdrian Chadd /* NB: in particular this captures ack's */ 763e60c4fc2SAdrian Chadd ieee80211_radiotap_rx_all(ic, m); 764e60c4fc2SAdrian Chadd } 7658cc724d9SAdrian Chadd m_freem(m); m = NULL; 766e60c4fc2SAdrian Chadd goto rx_next; 767e60c4fc2SAdrian Chadd } 768e60c4fc2SAdrian Chadd 769e60c4fc2SAdrian Chadd if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) { 770e60c4fc2SAdrian Chadd const HAL_RATE_TABLE *rt = sc->sc_currates; 771e60c4fc2SAdrian Chadd uint8_t rix = rt->rateCodeToIndex[rs->rs_rate]; 772e60c4fc2SAdrian Chadd 773e60c4fc2SAdrian Chadd ieee80211_dump_pkt(ic, mtod(m, caddr_t), len, 774e60c4fc2SAdrian Chadd sc->sc_hwmap[rix].ieeerate, rs->rs_rssi); 775e60c4fc2SAdrian Chadd } 776e60c4fc2SAdrian Chadd 777e60c4fc2SAdrian Chadd m_adj(m, -IEEE80211_CRC_LEN); 778e60c4fc2SAdrian Chadd 779e60c4fc2SAdrian Chadd /* 780e60c4fc2SAdrian Chadd * Locate the node for sender, track state, and then 781e60c4fc2SAdrian Chadd * pass the (referenced) node up to the 802.11 layer 782e60c4fc2SAdrian Chadd * for its use. 783e60c4fc2SAdrian Chadd */ 784e60c4fc2SAdrian Chadd ni = ieee80211_find_rxnode_withkey(ic, 785e60c4fc2SAdrian Chadd mtod(m, const struct ieee80211_frame_min *), 786e60c4fc2SAdrian Chadd rs->rs_keyix == HAL_RXKEYIX_INVALID ? 787e60c4fc2SAdrian Chadd IEEE80211_KEYIX_NONE : rs->rs_keyix); 788e60c4fc2SAdrian Chadd sc->sc_lastrs = rs; 789e60c4fc2SAdrian Chadd 790e60c4fc2SAdrian Chadd #ifdef AH_SUPPORT_AR5416 791e60c4fc2SAdrian Chadd if (rs->rs_isaggr) 792e60c4fc2SAdrian Chadd sc->sc_stats.ast_rx_agg++; 793e60c4fc2SAdrian Chadd #endif /* AH_SUPPORT_AR5416 */ 794e60c4fc2SAdrian Chadd 795e60c4fc2SAdrian Chadd if (ni != NULL) { 796e60c4fc2SAdrian Chadd /* 797e60c4fc2SAdrian Chadd * Only punt packets for ampdu reorder processing for 798e60c4fc2SAdrian Chadd * 11n nodes; net80211 enforces that M_AMPDU is only 799e60c4fc2SAdrian Chadd * set for 11n nodes. 800e60c4fc2SAdrian Chadd */ 801e60c4fc2SAdrian Chadd if (ni->ni_flags & IEEE80211_NODE_HT) 802e60c4fc2SAdrian Chadd m->m_flags |= M_AMPDU; 803e60c4fc2SAdrian Chadd 804e60c4fc2SAdrian Chadd /* 805e60c4fc2SAdrian Chadd * Sending station is known, dispatch directly. 806e60c4fc2SAdrian Chadd */ 807e60c4fc2SAdrian Chadd type = ieee80211_input(ni, m, rs->rs_rssi, nf); 808e60c4fc2SAdrian Chadd ieee80211_free_node(ni); 8098cc724d9SAdrian Chadd m = NULL; 810e60c4fc2SAdrian Chadd /* 811e60c4fc2SAdrian Chadd * Arrange to update the last rx timestamp only for 812e60c4fc2SAdrian Chadd * frames from our ap when operating in station mode. 813e60c4fc2SAdrian Chadd * This assumes the rx key is always setup when 814e60c4fc2SAdrian Chadd * associated. 815e60c4fc2SAdrian Chadd */ 816e60c4fc2SAdrian Chadd if (ic->ic_opmode == IEEE80211_M_STA && 817e60c4fc2SAdrian Chadd rs->rs_keyix != HAL_RXKEYIX_INVALID) 818d542f7f6SAdrian Chadd is_good = 1; 819e60c4fc2SAdrian Chadd } else { 820e60c4fc2SAdrian Chadd type = ieee80211_input_all(ic, m, rs->rs_rssi, nf); 8218cc724d9SAdrian Chadd m = NULL; 822e60c4fc2SAdrian Chadd } 8238cc724d9SAdrian Chadd 8248cc724d9SAdrian Chadd /* 8258cc724d9SAdrian Chadd * At this point we have passed the frame up the stack; thus 8268cc724d9SAdrian Chadd * the mbuf is no longer ours. 8278cc724d9SAdrian Chadd */ 8288cc724d9SAdrian Chadd 829e60c4fc2SAdrian Chadd /* 830e60c4fc2SAdrian Chadd * Track rx rssi and do any rx antenna management. 831e60c4fc2SAdrian Chadd */ 832e60c4fc2SAdrian Chadd ATH_RSSI_LPF(sc->sc_halstats.ns_avgrssi, rs->rs_rssi); 833e60c4fc2SAdrian Chadd if (sc->sc_diversity) { 834e60c4fc2SAdrian Chadd /* 835e60c4fc2SAdrian Chadd * When using fast diversity, change the default rx 836e60c4fc2SAdrian Chadd * antenna if diversity chooses the other antenna 3 837e60c4fc2SAdrian Chadd * times in a row. 838e60c4fc2SAdrian Chadd */ 839e60c4fc2SAdrian Chadd if (sc->sc_defant != rs->rs_antenna) { 840e60c4fc2SAdrian Chadd if (++sc->sc_rxotherant >= 3) 841e60c4fc2SAdrian Chadd ath_setdefantenna(sc, rs->rs_antenna); 842e60c4fc2SAdrian Chadd } else 843e60c4fc2SAdrian Chadd sc->sc_rxotherant = 0; 844e60c4fc2SAdrian Chadd } 845e60c4fc2SAdrian Chadd 846e60c4fc2SAdrian Chadd /* Newer school diversity - kite specific for now */ 847e60c4fc2SAdrian Chadd /* XXX perhaps migrate the normal diversity code to this? */ 848e60c4fc2SAdrian Chadd if ((ah)->ah_rxAntCombDiversity) 849e60c4fc2SAdrian Chadd (*(ah)->ah_rxAntCombDiversity)(ah, rs, ticks, hz); 850e60c4fc2SAdrian Chadd 851e60c4fc2SAdrian Chadd if (sc->sc_softled) { 852e60c4fc2SAdrian Chadd /* 853e60c4fc2SAdrian Chadd * Blink for any data frame. Otherwise do a 854e60c4fc2SAdrian Chadd * heartbeat-style blink when idle. The latter 855e60c4fc2SAdrian Chadd * is mainly for station mode where we depend on 856e60c4fc2SAdrian Chadd * periodic beacon frames to trigger the poll event. 857e60c4fc2SAdrian Chadd */ 858e60c4fc2SAdrian Chadd if (type == IEEE80211_FC0_TYPE_DATA) { 859e60c4fc2SAdrian Chadd const HAL_RATE_TABLE *rt = sc->sc_currates; 860e60c4fc2SAdrian Chadd ath_led_event(sc, 861e60c4fc2SAdrian Chadd rt->rateCodeToIndex[rs->rs_rate]); 862e60c4fc2SAdrian Chadd } else if (ticks - sc->sc_ledevent >= sc->sc_ledidle) 863e60c4fc2SAdrian Chadd ath_led_event(sc, 0); 864e60c4fc2SAdrian Chadd } 865e60c4fc2SAdrian Chadd rx_next: 8668cc724d9SAdrian Chadd /* 8678cc724d9SAdrian Chadd * Debugging - complain if we didn't NULL the mbuf pointer 8688cc724d9SAdrian Chadd * here. 8698cc724d9SAdrian Chadd */ 8708cc724d9SAdrian Chadd if (m != NULL) { 8718cc724d9SAdrian Chadd device_printf(sc->sc_dev, 8728cc724d9SAdrian Chadd "%s: mbuf %p should've been freed!\n", 8738cc724d9SAdrian Chadd __func__, 8748cc724d9SAdrian Chadd m); 8758cc724d9SAdrian Chadd } 876d542f7f6SAdrian Chadd return (is_good); 877d542f7f6SAdrian Chadd } 878d542f7f6SAdrian Chadd 879516f6796SAdrian Chadd #define ATH_RX_MAX 128 880516f6796SAdrian Chadd 881f8cc9b09SAdrian Chadd static void 882d542f7f6SAdrian Chadd ath_rx_proc(struct ath_softc *sc, int resched) 883d542f7f6SAdrian Chadd { 884d542f7f6SAdrian Chadd #define PA2DESC(_sc, _pa) \ 885d542f7f6SAdrian Chadd ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \ 886d542f7f6SAdrian Chadd ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr))) 887d542f7f6SAdrian Chadd struct ath_buf *bf; 888d542f7f6SAdrian Chadd struct ifnet *ifp = sc->sc_ifp; 889d542f7f6SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 890803f0c59SAdrian Chadd #ifdef IEEE80211_SUPPORT_SUPERG 891803f0c59SAdrian Chadd struct ieee80211com *ic = ifp->if_l2com; 892803f0c59SAdrian Chadd #endif 893d542f7f6SAdrian Chadd struct ath_desc *ds; 894d542f7f6SAdrian Chadd struct ath_rx_status *rs; 895d542f7f6SAdrian Chadd struct mbuf *m; 896d542f7f6SAdrian Chadd int ngood; 897d542f7f6SAdrian Chadd HAL_STATUS status; 898d542f7f6SAdrian Chadd int16_t nf; 899d542f7f6SAdrian Chadd u_int64_t tsf; 900d542f7f6SAdrian Chadd int npkts = 0; 901233af52dSAdrian Chadd int kickpcu = 0; 902d542f7f6SAdrian Chadd 903d542f7f6SAdrian Chadd /* XXX we must not hold the ATH_LOCK here */ 904d542f7f6SAdrian Chadd ATH_UNLOCK_ASSERT(sc); 905d542f7f6SAdrian Chadd ATH_PCU_UNLOCK_ASSERT(sc); 906d542f7f6SAdrian Chadd 907d542f7f6SAdrian Chadd ATH_PCU_LOCK(sc); 908d542f7f6SAdrian Chadd sc->sc_rxproc_cnt++; 909233af52dSAdrian Chadd kickpcu = sc->sc_kickpcu; 910d542f7f6SAdrian Chadd ATH_PCU_UNLOCK(sc); 911d542f7f6SAdrian Chadd 912d542f7f6SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s: called\n", __func__); 913d542f7f6SAdrian Chadd ngood = 0; 914d542f7f6SAdrian Chadd nf = ath_hal_getchannoise(ah, sc->sc_curchan); 915d542f7f6SAdrian Chadd sc->sc_stats.ast_rx_noise = nf; 916d542f7f6SAdrian Chadd tsf = ath_hal_gettsf64(ah); 917d542f7f6SAdrian Chadd do { 918516f6796SAdrian Chadd /* 919516f6796SAdrian Chadd * Don't process too many packets at a time; give the 920516f6796SAdrian Chadd * TX thread time to also run - otherwise the TX 921516f6796SAdrian Chadd * latency can jump by quite a bit, causing throughput 922516f6796SAdrian Chadd * degredation. 923516f6796SAdrian Chadd */ 924233af52dSAdrian Chadd if (!kickpcu && npkts >= ATH_RX_MAX) 925516f6796SAdrian Chadd break; 926516f6796SAdrian Chadd 927d542f7f6SAdrian Chadd bf = TAILQ_FIRST(&sc->sc_rxbuf); 928d542f7f6SAdrian Chadd if (sc->sc_rxslink && bf == NULL) { /* NB: shouldn't happen */ 929d542f7f6SAdrian Chadd if_printf(ifp, "%s: no buffer!\n", __func__); 930d542f7f6SAdrian Chadd break; 931d542f7f6SAdrian Chadd } else if (bf == NULL) { 932d542f7f6SAdrian Chadd /* 933d542f7f6SAdrian Chadd * End of List: 934d542f7f6SAdrian Chadd * this can happen for non-self-linked RX chains 935d542f7f6SAdrian Chadd */ 936d542f7f6SAdrian Chadd sc->sc_stats.ast_rx_hitqueueend++; 937d542f7f6SAdrian Chadd break; 938d542f7f6SAdrian Chadd } 939d542f7f6SAdrian Chadd m = bf->bf_m; 940d542f7f6SAdrian Chadd if (m == NULL) { /* NB: shouldn't happen */ 941d542f7f6SAdrian Chadd /* 942d542f7f6SAdrian Chadd * If mbuf allocation failed previously there 943d542f7f6SAdrian Chadd * will be no mbuf; try again to re-populate it. 944d542f7f6SAdrian Chadd */ 945d542f7f6SAdrian Chadd /* XXX make debug msg */ 946d542f7f6SAdrian Chadd if_printf(ifp, "%s: no mbuf!\n", __func__); 947d542f7f6SAdrian Chadd TAILQ_REMOVE(&sc->sc_rxbuf, bf, bf_list); 948d542f7f6SAdrian Chadd goto rx_proc_next; 949d542f7f6SAdrian Chadd } 950d542f7f6SAdrian Chadd ds = bf->bf_desc; 951d542f7f6SAdrian Chadd if (ds->ds_link == bf->bf_daddr) { 952d542f7f6SAdrian Chadd /* NB: never process the self-linked entry at the end */ 953d542f7f6SAdrian Chadd sc->sc_stats.ast_rx_hitqueueend++; 954d542f7f6SAdrian Chadd break; 955d542f7f6SAdrian Chadd } 956d542f7f6SAdrian Chadd /* XXX sync descriptor memory */ 957d542f7f6SAdrian Chadd /* 958d542f7f6SAdrian Chadd * Must provide the virtual address of the current 959d542f7f6SAdrian Chadd * descriptor, the physical address, and the virtual 960d542f7f6SAdrian Chadd * address of the next descriptor in the h/w chain. 961d542f7f6SAdrian Chadd * This allows the HAL to look ahead to see if the 962d542f7f6SAdrian Chadd * hardware is done with a descriptor by checking the 963d542f7f6SAdrian Chadd * done bit in the following descriptor and the address 964d542f7f6SAdrian Chadd * of the current descriptor the DMA engine is working 965d542f7f6SAdrian Chadd * on. All this is necessary because of our use of 966d542f7f6SAdrian Chadd * a self-linked list to avoid rx overruns. 967d542f7f6SAdrian Chadd */ 968d542f7f6SAdrian Chadd rs = &bf->bf_status.ds_rxstat; 969d542f7f6SAdrian Chadd status = ath_hal_rxprocdesc(ah, ds, 970d542f7f6SAdrian Chadd bf->bf_daddr, PA2DESC(sc, ds->ds_link), rs); 971d542f7f6SAdrian Chadd #ifdef ATH_DEBUG 972d542f7f6SAdrian Chadd if (sc->sc_debug & ATH_DEBUG_RECV_DESC) 973d542f7f6SAdrian Chadd ath_printrxbuf(sc, bf, 0, status == HAL_OK); 974d542f7f6SAdrian Chadd #endif 975bb327d28SAdrian Chadd 976bb327d28SAdrian Chadd #ifdef ATH_DEBUG_ALQ 977bb327d28SAdrian Chadd if (if_ath_alq_checkdebug(&sc->sc_alq, ATH_ALQ_EDMA_RXSTATUS)) 978bb327d28SAdrian Chadd if_ath_alq_post(&sc->sc_alq, ATH_ALQ_EDMA_RXSTATUS, 979bb327d28SAdrian Chadd sc->sc_rx_statuslen, (char *) ds); 980bb327d28SAdrian Chadd #endif /* ATH_DEBUG_ALQ */ 981bb327d28SAdrian Chadd 982d542f7f6SAdrian Chadd if (status == HAL_EINPROGRESS) 983d542f7f6SAdrian Chadd break; 984d542f7f6SAdrian Chadd 985d542f7f6SAdrian Chadd TAILQ_REMOVE(&sc->sc_rxbuf, bf, bf_list); 986d542f7f6SAdrian Chadd npkts++; 987d542f7f6SAdrian Chadd 988d542f7f6SAdrian Chadd /* 989d542f7f6SAdrian Chadd * Process a single frame. 990d542f7f6SAdrian Chadd */ 9918cc724d9SAdrian Chadd bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_POSTREAD); 9928cc724d9SAdrian Chadd bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); 9938cc724d9SAdrian Chadd bf->bf_m = NULL; 9948cc724d9SAdrian Chadd if (ath_rx_pkt(sc, rs, status, tsf, nf, HAL_RX_QUEUE_HP, bf, m)) 995d542f7f6SAdrian Chadd ngood++; 996d542f7f6SAdrian Chadd rx_proc_next: 997e60c4fc2SAdrian Chadd TAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); 998e60c4fc2SAdrian Chadd } while (ath_rxbuf_init(sc, bf) == 0); 999e60c4fc2SAdrian Chadd 1000e60c4fc2SAdrian Chadd /* rx signal state monitoring */ 1001e60c4fc2SAdrian Chadd ath_hal_rxmonitor(ah, &sc->sc_halstats, sc->sc_curchan); 1002e60c4fc2SAdrian Chadd if (ngood) 1003e60c4fc2SAdrian Chadd sc->sc_lastrx = tsf; 1004e60c4fc2SAdrian Chadd 100503682514SAdrian Chadd ATH_KTR(sc, ATH_KTR_RXPROC, 2, "ath_rx_proc: npkts=%d, ngood=%d", npkts, ngood); 1006e60c4fc2SAdrian Chadd /* Queue DFS tasklet if needed */ 1007e60c4fc2SAdrian Chadd if (resched && ath_dfs_tasklet_needed(sc, sc->sc_curchan)) 1008e60c4fc2SAdrian Chadd taskqueue_enqueue(sc->sc_tq, &sc->sc_dfstask); 1009e60c4fc2SAdrian Chadd 1010e60c4fc2SAdrian Chadd /* 1011e60c4fc2SAdrian Chadd * Now that all the RX frames were handled that 1012e60c4fc2SAdrian Chadd * need to be handled, kick the PCU if there's 1013e60c4fc2SAdrian Chadd * been an RXEOL condition. 1014e60c4fc2SAdrian Chadd */ 10151844ff16SAdrian Chadd if (resched && kickpcu) { 1016e60c4fc2SAdrian Chadd ATH_PCU_LOCK(sc); 101703682514SAdrian Chadd ATH_KTR(sc, ATH_KTR_ERROR, 0, "ath_rx_proc: kickpcu"); 1018e60c4fc2SAdrian Chadd device_printf(sc->sc_dev, "%s: kickpcu; handled %d packets\n", 1019e60c4fc2SAdrian Chadd __func__, npkts); 1020e60c4fc2SAdrian Chadd 10211844ff16SAdrian Chadd /* 10221844ff16SAdrian Chadd * Go through the process of fully tearing down 10231844ff16SAdrian Chadd * the RX buffers and reinitialising them. 10241844ff16SAdrian Chadd * 10251844ff16SAdrian Chadd * There's a hardware bug that causes the RX FIFO 10261844ff16SAdrian Chadd * to get confused under certain conditions and 10271844ff16SAdrian Chadd * constantly write over the same frame, leading 10281844ff16SAdrian Chadd * the RX driver code here to get heavily confused. 10291844ff16SAdrian Chadd */ 10301844ff16SAdrian Chadd #if 1 1031233af52dSAdrian Chadd ath_startrecv(sc); 1032233af52dSAdrian Chadd #else 1033e60c4fc2SAdrian Chadd /* 10341844ff16SAdrian Chadd * Disabled for now - it'd be nice to be able to do 10351844ff16SAdrian Chadd * this in order to limit the amount of CPU time spent 10361844ff16SAdrian Chadd * reinitialising the RX side (and thus minimise RX 10371844ff16SAdrian Chadd * drops) however there's a hardware issue that 10381844ff16SAdrian Chadd * causes things to get too far out of whack. 10391844ff16SAdrian Chadd */ 10401844ff16SAdrian Chadd /* 1041e60c4fc2SAdrian Chadd * XXX can we hold the PCU lock here? 1042e60c4fc2SAdrian Chadd * Are there any net80211 buffer calls involved? 1043e60c4fc2SAdrian Chadd */ 1044e60c4fc2SAdrian Chadd bf = TAILQ_FIRST(&sc->sc_rxbuf); 1045d60a0680SAdrian Chadd ath_hal_putrxbuf(ah, bf->bf_daddr, HAL_RX_QUEUE_HP); 1046e60c4fc2SAdrian Chadd ath_hal_rxena(ah); /* enable recv descriptors */ 1047e60c4fc2SAdrian Chadd ath_mode_init(sc); /* set filters, etc. */ 1048e60c4fc2SAdrian Chadd ath_hal_startpcurecv(ah); /* re-enable PCU/DMA engine */ 1049233af52dSAdrian Chadd #endif 1050e60c4fc2SAdrian Chadd 1051e60c4fc2SAdrian Chadd ath_hal_intrset(ah, sc->sc_imask); 1052e60c4fc2SAdrian Chadd sc->sc_kickpcu = 0; 1053e60c4fc2SAdrian Chadd ATH_PCU_UNLOCK(sc); 10541844ff16SAdrian Chadd } 1055e60c4fc2SAdrian Chadd 1056e60c4fc2SAdrian Chadd /* XXX check this inside of IF_LOCK? */ 1057e60c4fc2SAdrian Chadd if (resched && (ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0) { 1058e60c4fc2SAdrian Chadd #ifdef IEEE80211_SUPPORT_SUPERG 1059e60c4fc2SAdrian Chadd ieee80211_ff_age_all(ic, 100); 1060e60c4fc2SAdrian Chadd #endif 1061e60c4fc2SAdrian Chadd if (!IFQ_IS_EMPTY(&ifp->if_snd)) 106214d33c7eSAdrian Chadd ath_tx_kick(sc); 1063e60c4fc2SAdrian Chadd } 1064e60c4fc2SAdrian Chadd #undef PA2DESC 1065e60c4fc2SAdrian Chadd 1066516f6796SAdrian Chadd /* 1067516f6796SAdrian Chadd * If we hit the maximum number of frames in this round, 1068516f6796SAdrian Chadd * reschedule for another immediate pass. This gives 1069516f6796SAdrian Chadd * the TX and TX completion routines time to run, which 1070516f6796SAdrian Chadd * will reduce latency. 1071516f6796SAdrian Chadd */ 1072516f6796SAdrian Chadd if (npkts >= ATH_RX_MAX) 1073f0db652cSAdrian Chadd sc->sc_rx.recv_sched(sc, resched); 1074516f6796SAdrian Chadd 1075e60c4fc2SAdrian Chadd ATH_PCU_LOCK(sc); 1076e60c4fc2SAdrian Chadd sc->sc_rxproc_cnt--; 1077e60c4fc2SAdrian Chadd ATH_PCU_UNLOCK(sc); 1078e60c4fc2SAdrian Chadd } 1079e60c4fc2SAdrian Chadd 1080516f6796SAdrian Chadd #undef ATH_RX_MAX 1081516f6796SAdrian Chadd 1082e60c4fc2SAdrian Chadd /* 1083f8cc9b09SAdrian Chadd * Only run the RX proc if it's not already running. 1084f8cc9b09SAdrian Chadd * Since this may get run as part of the reset/flush path, 1085f8cc9b09SAdrian Chadd * the task can't clash with an existing, running tasklet. 1086f8cc9b09SAdrian Chadd */ 1087f8cc9b09SAdrian Chadd static void 1088f8cc9b09SAdrian Chadd ath_legacy_rx_tasklet(void *arg, int npending) 1089f8cc9b09SAdrian Chadd { 1090f8cc9b09SAdrian Chadd struct ath_softc *sc = arg; 1091f8cc9b09SAdrian Chadd 109203682514SAdrian Chadd ATH_KTR(sc, ATH_KTR_RXPROC, 1, "ath_rx_proc: pending=%d", npending); 1093f8cc9b09SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s: pending %u\n", __func__, npending); 1094f8cc9b09SAdrian Chadd ATH_PCU_LOCK(sc); 1095f8cc9b09SAdrian Chadd if (sc->sc_inreset_cnt > 0) { 1096f8cc9b09SAdrian Chadd device_printf(sc->sc_dev, 1097f8cc9b09SAdrian Chadd "%s: sc_inreset_cnt > 0; skipping\n", __func__); 1098f8cc9b09SAdrian Chadd ATH_PCU_UNLOCK(sc); 1099f8cc9b09SAdrian Chadd return; 1100f8cc9b09SAdrian Chadd } 1101f8cc9b09SAdrian Chadd ATH_PCU_UNLOCK(sc); 1102f8cc9b09SAdrian Chadd 1103f8cc9b09SAdrian Chadd ath_rx_proc(sc, 1); 1104f8cc9b09SAdrian Chadd } 1105f8cc9b09SAdrian Chadd 1106f8cc9b09SAdrian Chadd static void 1107f8cc9b09SAdrian Chadd ath_legacy_flushrecv(struct ath_softc *sc) 1108f8cc9b09SAdrian Chadd { 1109f8cc9b09SAdrian Chadd 1110f8cc9b09SAdrian Chadd ath_rx_proc(sc, 0); 1111f8cc9b09SAdrian Chadd } 1112f8cc9b09SAdrian Chadd 1113f8cc9b09SAdrian Chadd /* 1114e60c4fc2SAdrian Chadd * Disable the receive h/w in preparation for a reset. 1115e60c4fc2SAdrian Chadd */ 1116f8cc9b09SAdrian Chadd static void 1117f8cc9b09SAdrian Chadd ath_legacy_stoprecv(struct ath_softc *sc, int dodelay) 1118e60c4fc2SAdrian Chadd { 1119e60c4fc2SAdrian Chadd #define PA2DESC(_sc, _pa) \ 1120e60c4fc2SAdrian Chadd ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \ 1121e60c4fc2SAdrian Chadd ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr))) 1122e60c4fc2SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 1123e60c4fc2SAdrian Chadd 1124e60c4fc2SAdrian Chadd ath_hal_stoppcurecv(ah); /* disable PCU */ 1125e60c4fc2SAdrian Chadd ath_hal_setrxfilter(ah, 0); /* clear recv filter */ 1126e60c4fc2SAdrian Chadd ath_hal_stopdmarecv(ah); /* disable DMA engine */ 1127e60c4fc2SAdrian Chadd /* 1128e60c4fc2SAdrian Chadd * TODO: see if this particular DELAY() is required; it may be 1129e60c4fc2SAdrian Chadd * masking some missing FIFO flush or DMA sync. 1130e60c4fc2SAdrian Chadd */ 1131e60c4fc2SAdrian Chadd #if 0 1132e60c4fc2SAdrian Chadd if (dodelay) 1133e60c4fc2SAdrian Chadd #endif 1134e60c4fc2SAdrian Chadd DELAY(3000); /* 3ms is long enough for 1 frame */ 1135e60c4fc2SAdrian Chadd #ifdef ATH_DEBUG 1136e60c4fc2SAdrian Chadd if (sc->sc_debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) { 1137e60c4fc2SAdrian Chadd struct ath_buf *bf; 1138e60c4fc2SAdrian Chadd u_int ix; 1139e60c4fc2SAdrian Chadd 1140e60c4fc2SAdrian Chadd device_printf(sc->sc_dev, 1141e60c4fc2SAdrian Chadd "%s: rx queue %p, link %p\n", 1142e60c4fc2SAdrian Chadd __func__, 1143d60a0680SAdrian Chadd (caddr_t)(uintptr_t) ath_hal_getrxbuf(ah, HAL_RX_QUEUE_HP), 1144e60c4fc2SAdrian Chadd sc->sc_rxlink); 1145e60c4fc2SAdrian Chadd ix = 0; 1146e60c4fc2SAdrian Chadd TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { 1147e60c4fc2SAdrian Chadd struct ath_desc *ds = bf->bf_desc; 1148e60c4fc2SAdrian Chadd struct ath_rx_status *rs = &bf->bf_status.ds_rxstat; 1149e60c4fc2SAdrian Chadd HAL_STATUS status = ath_hal_rxprocdesc(ah, ds, 1150e60c4fc2SAdrian Chadd bf->bf_daddr, PA2DESC(sc, ds->ds_link), rs); 1151e60c4fc2SAdrian Chadd if (status == HAL_OK || (sc->sc_debug & ATH_DEBUG_FATAL)) 1152e60c4fc2SAdrian Chadd ath_printrxbuf(sc, bf, ix, status == HAL_OK); 1153e60c4fc2SAdrian Chadd ix++; 1154e60c4fc2SAdrian Chadd } 1155e60c4fc2SAdrian Chadd } 1156e60c4fc2SAdrian Chadd #endif 1157d434a377SAdrian Chadd /* 1158d434a377SAdrian Chadd * Free both high/low RX pending, just in case. 1159d434a377SAdrian Chadd */ 1160d434a377SAdrian Chadd if (sc->sc_rxedma[HAL_RX_QUEUE_LP].m_rxpending != NULL) { 1161d434a377SAdrian Chadd m_freem(sc->sc_rxedma[HAL_RX_QUEUE_LP].m_rxpending); 1162d434a377SAdrian Chadd sc->sc_rxedma[HAL_RX_QUEUE_LP].m_rxpending = NULL; 1163d434a377SAdrian Chadd } 1164d434a377SAdrian Chadd if (sc->sc_rxedma[HAL_RX_QUEUE_HP].m_rxpending != NULL) { 1165d434a377SAdrian Chadd m_freem(sc->sc_rxedma[HAL_RX_QUEUE_HP].m_rxpending); 1166d434a377SAdrian Chadd sc->sc_rxedma[HAL_RX_QUEUE_HP].m_rxpending = NULL; 1167e60c4fc2SAdrian Chadd } 1168e60c4fc2SAdrian Chadd sc->sc_rxlink = NULL; /* just in case */ 1169e60c4fc2SAdrian Chadd #undef PA2DESC 1170e60c4fc2SAdrian Chadd } 1171e60c4fc2SAdrian Chadd 1172e60c4fc2SAdrian Chadd /* 1173e60c4fc2SAdrian Chadd * Enable the receive h/w following a reset. 1174e60c4fc2SAdrian Chadd */ 1175f8cc9b09SAdrian Chadd static int 1176f8cc9b09SAdrian Chadd ath_legacy_startrecv(struct ath_softc *sc) 1177e60c4fc2SAdrian Chadd { 1178e60c4fc2SAdrian Chadd struct ath_hal *ah = sc->sc_ah; 1179e60c4fc2SAdrian Chadd struct ath_buf *bf; 1180e60c4fc2SAdrian Chadd 1181e60c4fc2SAdrian Chadd sc->sc_rxlink = NULL; 1182d434a377SAdrian Chadd sc->sc_rxedma[HAL_RX_QUEUE_LP].m_rxpending = NULL; 1183d434a377SAdrian Chadd sc->sc_rxedma[HAL_RX_QUEUE_HP].m_rxpending = NULL; 1184e60c4fc2SAdrian Chadd TAILQ_FOREACH(bf, &sc->sc_rxbuf, bf_list) { 1185e60c4fc2SAdrian Chadd int error = ath_rxbuf_init(sc, bf); 1186e60c4fc2SAdrian Chadd if (error != 0) { 1187e60c4fc2SAdrian Chadd DPRINTF(sc, ATH_DEBUG_RECV, 1188e60c4fc2SAdrian Chadd "%s: ath_rxbuf_init failed %d\n", 1189e60c4fc2SAdrian Chadd __func__, error); 1190e60c4fc2SAdrian Chadd return error; 1191e60c4fc2SAdrian Chadd } 1192e60c4fc2SAdrian Chadd } 1193e60c4fc2SAdrian Chadd 1194e60c4fc2SAdrian Chadd bf = TAILQ_FIRST(&sc->sc_rxbuf); 1195d60a0680SAdrian Chadd ath_hal_putrxbuf(ah, bf->bf_daddr, HAL_RX_QUEUE_HP); 1196e60c4fc2SAdrian Chadd ath_hal_rxena(ah); /* enable recv descriptors */ 1197e60c4fc2SAdrian Chadd ath_mode_init(sc); /* set filters, etc. */ 1198e60c4fc2SAdrian Chadd ath_hal_startpcurecv(ah); /* re-enable PCU/DMA engine */ 1199e60c4fc2SAdrian Chadd return 0; 1200e60c4fc2SAdrian Chadd } 1201f8cc9b09SAdrian Chadd 12023d184db2SAdrian Chadd static int 12033d184db2SAdrian Chadd ath_legacy_dma_rxsetup(struct ath_softc *sc) 12043d184db2SAdrian Chadd { 12053d184db2SAdrian Chadd int error; 12063d184db2SAdrian Chadd 12073d184db2SAdrian Chadd error = ath_descdma_setup(sc, &sc->sc_rxdma, &sc->sc_rxbuf, 12081006fc0cSAdrian Chadd "rx", sizeof(struct ath_desc), ath_rxbuf, 1); 12093d184db2SAdrian Chadd if (error != 0) 12103d184db2SAdrian Chadd return (error); 12113d184db2SAdrian Chadd 12123d184db2SAdrian Chadd return (0); 12133d184db2SAdrian Chadd } 12143d184db2SAdrian Chadd 12153d184db2SAdrian Chadd static int 12163d184db2SAdrian Chadd ath_legacy_dma_rxteardown(struct ath_softc *sc) 12173d184db2SAdrian Chadd { 12183d184db2SAdrian Chadd 12193d184db2SAdrian Chadd if (sc->sc_rxdma.dd_desc_len != 0) 12203d184db2SAdrian Chadd ath_descdma_cleanup(sc, &sc->sc_rxdma, &sc->sc_rxbuf); 12213d184db2SAdrian Chadd return (0); 12223d184db2SAdrian Chadd } 1223f8cc9b09SAdrian Chadd 1224f0db652cSAdrian Chadd static void 1225f0db652cSAdrian Chadd ath_legacy_recv_sched(struct ath_softc *sc, int dosched) 1226f0db652cSAdrian Chadd { 1227f0db652cSAdrian Chadd 1228f0db652cSAdrian Chadd taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); 1229f0db652cSAdrian Chadd } 1230f0db652cSAdrian Chadd 1231f0db652cSAdrian Chadd static void 1232f0db652cSAdrian Chadd ath_legacy_recv_sched_queue(struct ath_softc *sc, HAL_RX_QUEUE q, 1233f0db652cSAdrian Chadd int dosched) 1234f0db652cSAdrian Chadd { 1235f0db652cSAdrian Chadd 1236f0db652cSAdrian Chadd taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); 1237f0db652cSAdrian Chadd } 1238f0db652cSAdrian Chadd 1239f8cc9b09SAdrian Chadd void 1240f8cc9b09SAdrian Chadd ath_recv_setup_legacy(struct ath_softc *sc) 1241f8cc9b09SAdrian Chadd { 1242f8cc9b09SAdrian Chadd 12431006fc0cSAdrian Chadd /* Sensible legacy defaults */ 1244bb327d28SAdrian Chadd /* 1245bb327d28SAdrian Chadd * XXX this should be changed to properly support the 1246bb327d28SAdrian Chadd * exact RX descriptor size for each HAL. 1247bb327d28SAdrian Chadd */ 1248bb327d28SAdrian Chadd sc->sc_rx_statuslen = sizeof(struct ath_desc); 12491006fc0cSAdrian Chadd 1250f8cc9b09SAdrian Chadd sc->sc_rx.recv_start = ath_legacy_startrecv; 1251f8cc9b09SAdrian Chadd sc->sc_rx.recv_stop = ath_legacy_stoprecv; 1252f8cc9b09SAdrian Chadd sc->sc_rx.recv_flush = ath_legacy_flushrecv; 1253f8cc9b09SAdrian Chadd sc->sc_rx.recv_tasklet = ath_legacy_rx_tasklet; 1254f8cc9b09SAdrian Chadd sc->sc_rx.recv_rxbuf_init = ath_legacy_rxbuf_init; 12553d184db2SAdrian Chadd 12563d184db2SAdrian Chadd sc->sc_rx.recv_setup = ath_legacy_dma_rxsetup; 12573d184db2SAdrian Chadd sc->sc_rx.recv_teardown = ath_legacy_dma_rxteardown; 1258f0db652cSAdrian Chadd sc->sc_rx.recv_sched = ath_legacy_recv_sched; 1259f0db652cSAdrian Chadd sc->sc_rx.recv_sched_queue = ath_legacy_recv_sched_queue; 1260f8cc9b09SAdrian Chadd } 1261