arn_recv.c revision 3ae945c326c1fc078149f2c8b11fac0cc8f6d1d6
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Use is subject to license terms.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Copyright (c) 2008 Atheros Communications Inc.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Permission to use, copy, modify, and/or distribute this software for any
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * purpose with or without fee is hereby granted, provided that the above
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * copyright notice and this permission notice appear in all copies.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#include <sys/byteorder.h>
54d34259930c76758a7e9e03732cb1e37f9a6ba9Marcel Telka
d34083bdb88c46438e20789b3e42044428239a21Jan Kryl#include "arn_core.h"
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesvoid
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_setdefantenna(struct arn_softc *sc, uint32_t antenna)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* XXX block beacon interrupts */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_setantenna(sc->sc_ah, antenna);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_defant = (uint8_t)antenna; /* LINT */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_rxotherant = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Extend 15-bit time stamp from rx descriptor to
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * a full 64-bit TSF using the current h/w TSF.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic uint64_t
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_extend_tsf(struct arn_softc *sc, uint32_t rstamp)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
54d34259930c76758a7e9e03732cb1e37f9a6ba9Marcel Telka uint64_t tsf;
54d34259930c76758a7e9e03732cb1e37f9a6ba9Marcel Telka
54d34259930c76758a7e9e03732cb1e37f9a6ba9Marcel Telka tsf = ath9k_hw_gettsf64(sc->sc_ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((tsf & 0x7fff) < rstamp)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States tsf -= 0x8000;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return ((tsf & ~0x7fff) | rstamp);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic void
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_opmode_init(struct arn_softc *sc)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct ath_hal *ah = sc->sc_ah;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States uint32_t rfilt;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States uint32_t mfilt[2];
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ieee80211com_t *ic = (ieee80211com_t *)sc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* configure rx filter */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rfilt = arn_calcrxfilter(sc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_setrxfilter(ah, rfilt);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* configure bssid mask */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (void) ath9k_hw_setbssidmask(ah, sc->sc_bssidmask);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* configure operational mode */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_setopmode(ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* Handle any link-level address change. */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (void) ath9k_hw_setmac(ah, sc->sc_myaddr);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* calculate and install multicast filter */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mfilt[0] = ~((uint32_t)0); /* LINT */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mfilt[1] = ~((uint32_t)0); /* LINT */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ARN_DBG((ARN_DBG_RECV, "arn: arn_opmode_init(): "
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "mode = %d RX filter 0x%x, MC filter %08x:%08x\n",
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ic->ic_opmode, rfilt, mfilt[0], mfilt[1]));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Calculate the receive filter according to the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * operating mode and state:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * o always accept unicast, broadcast, and multicast traffic
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * o maintain current state of phy error reception (the hal
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * may enable phy error frames for noise immunity work)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * o probe request frames are accepted only when operating in
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * hostap, adhoc, or monitor modes
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * o enable promiscuous mode according to the interface state
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * o accept beacons:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * - when operating in adhoc mode so the 802.11 layer creates
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * node table entries for peers,
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * - when operating in station mode for collecting rssi data when
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * the station is otherwise quiet, or
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * - when operating as a repeater so we see repeater-sta beacons
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * - when scanning
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesuint32_t
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telkaarn_calcrxfilter(struct arn_softc *sc)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | \
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka ATH9K_RX_FILTER_PHYRADAR)
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States uint32_t rfilt;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rfilt = (ath9k_hw_getrxfilter(sc->sc_ah) & RX_FILTER_PRESERVE) |
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST |
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka ATH9K_RX_FILTER_MCAST;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* If not a STA, enable processing of Probe Requests */
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka if (sc->sc_ah->ah_opmode != ATH9K_M_STA)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rfilt |= ATH9K_RX_FILTER_PROBEREQ;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* Can't set HOSTAP into promiscous mode */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (((sc->sc_ah->ah_opmode != ATH9K_M_HOSTAP) &&
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (sc->sc_promisc)) ||
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (sc->sc_ah->ah_opmode == ATH9K_M_MONITOR)) {
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka rfilt |= ATH9K_RX_FILTER_PROM;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* ??? To prevent from sending ACK */
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka rfilt &= ~ATH9K_RX_FILTER_UCAST;
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (sc->sc_ah->ah_opmode == ATH9K_M_STA ||
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_ah->ah_opmode == ATH9K_M_IBSS)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rfilt |= ATH9K_RX_FILTER_BEACON;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * If in HOSTAP mode, want to enable reception of PSPOLL
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * frames & beacon frames
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (sc->sc_ah->ah_opmode == ATH9K_M_HOSTAP)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rfilt |= (ATH9K_RX_FILTER_BEACON | ATH9K_RX_FILTER_PSPOLL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (rfilt);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#undef RX_FILTER_PRESERVE
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesint
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_startrecv(struct arn_softc *sc)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct ath_hal *ah = sc->sc_ah;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct ath_buf *bf;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* clean up rx link firstly */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_rxlink = NULL;
a9685eaab1313767d1d4dac672c3a468519aa899Marcel Telka
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* rx descriptor link set up */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bf = list_head(&sc->sc_rxbuf_list);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States while (bf != NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States arn_rx_buf_link(sc, bf);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bf = list_next(&sc->sc_rxbuf_list, bf);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bf = list_head(&sc->sc_rxbuf_list);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_putrxbuf(ah, bf->bf_daddr);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_rxena(ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States arn_opmode_init(sc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_startpcureceive(ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (0);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesboolean_t
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_stoprecv(struct arn_softc *sc)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct ath_hal *ah = sc->sc_ah;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States boolean_t stopped;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_stoppcurecv(ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ath9k_hw_setrxfilter(ah, 0);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States stopped = ath9k_hw_stopdmarecv(ah);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* 3ms is long enough for 1 frame ??? */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States drv_usecwait(3000);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_rxlink = NULL;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (stopped);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Intercept management frames to collect beacon rssi data
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * and to do ibss merges.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesvoid
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesarn_recv_mgmt(struct ieee80211com *ic, mblk_t *mp, struct ieee80211_node *in,
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States int subtype, int rssi, uint32_t rstamp)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct arn_softc *sc = (struct arn_softc *)ic;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Call up first so subsequent work can use information
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * potentially stored in the node (e.g. for ibss merge).
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States sc->sc_recv_mgmt(ic, mp, in, subtype, rssi, rstamp);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ARN_LOCK(sc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States switch (subtype) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case IEEE80211_FC0_SUBTYPE_BEACON:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* update rssi statistics */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (sc->sc_bsync && in == ic->ic_bss &&
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ic->ic_state == IEEE80211_S_RUN) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Resync beacon timers using the tsf of the beacon
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * frame we just received.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States arn_beacon_config(sc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* FALLTHRU */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case IEEE80211_FC0_SUBTYPE_PROBE_RESP:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (ic->ic_opmode == IEEE80211_M_IBSS &&
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ic->ic_state == IEEE80211_S_RUN &&
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (in->in_capinfo & IEEE80211_CAPINFO_IBSS)) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States uint64_t tsf = arn_extend_tsf(sc, rstamp);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Handle ibss merge as needed; check the tsf on the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * frame before attempting the merge. The 802.11 spec
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * says the station should change it's bssid to match
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * the oldest station with the same ssid, where oldest
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * is determined by the tsf. Note that hardware
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * reconfiguration happens through callback to
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ath_newstate as the state machine will go from
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * RUN -> RUN when this happens.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (LE_64(in->in_tstamp.tsf) >= tsf) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ARN_DBG((ARN_DBG_BEACON, "arn: arn_recv_mgmt:"
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "ibss merge, rstamp %u tsf %lu "
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "tstamp %lu\n", rstamp, tsf,
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.tsf));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ARN_UNLOCK(sc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ARN_DBG((ARN_DBG_BEACON, "arn_recv_mgmt():"
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "ibss_merge: rstamp=%d in_tstamp=%02x %02x"
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States " %02x %02x %02x %02x %02x %02x\n",
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rstamp, in->in_tstamp.data[0],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[1],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[2],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[3],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[4],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[5],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[6],
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States in->in_tstamp.data[7]));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (void) ieee80211_ibss_merge(in);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
}
break;
}
ARN_UNLOCK(sc);
}
static void
arn_printrxbuf(struct ath_buf *bf, int32_t done)
{
struct ath_desc *ds = bf->bf_desc;
const struct ath_rx_status *rs = &ds->ds_rxstat;
ARN_DBG((ARN_DBG_RECV, "arn: R (%p %p) %08x %08x %08x "
"%08x %08x %08x %c\n",
ds, bf->bf_daddr,
ds->ds_link, ds->ds_data,
ds->ds_ctl0, ds->ds_ctl1,
ds->ds_hw[0], ds->ds_hw[1],
!done ? ' ' : (rs->rs_status == 0) ? '*' : '!'));
}
static void
arn_rx_handler(struct arn_softc *sc)
{
#define PA2DESC(_sc, _pa) \
((struct ath_desc *)((caddr_t)(_sc)->sc_desc + \
((_pa) - (_sc)->sc_desc_dma.cookie.dmac_address)))
ieee80211com_t *ic = (ieee80211com_t *)sc;
struct ath_buf *bf;
struct ath_hal *ah = sc->sc_ah;
struct ath_desc *ds;
struct ath_rx_status *rs;
mblk_t *rx_mp;
struct ieee80211_frame *wh;
int32_t len, ngood, loop = 1;
uint8_t phyerr;
int status;
struct ieee80211_node *in;
uint32_t cur_signal;
uint32_t subtype;
ngood = 0;
do {
mutex_enter(&sc->sc_rxbuflock);
bf = list_head(&sc->sc_rxbuf_list);
if (bf == NULL) {
ARN_DBG((ARN_DBG_RECV, "arn: arn_rx_handler(): "
"no buffer\n"));
mutex_exit(&sc->sc_rxbuflock);
break;
}
ASSERT(bf->bf_dma.cookie.dmac_address != NULL);
ds = bf->bf_desc;
if (ds->ds_link == bf->bf_daddr) {
/*
* Never process the self-linked entry at the end,
* this may be met at heavy load.
*/
mutex_exit(&sc->sc_rxbuflock);
break;
}
/*
* Must provide the virtual address of the current
* descriptor, the physical address, and the virtual
* address of the next descriptor in the h/w chain.
* This allows the HAL to look ahead to see if the
* hardware is done with a descriptor by checking the
* done bit in the following descriptor and the address
* of the current descriptor the DMA engine is working
* on. All this is necessary because of our use of
* a self-linked list to avoid rx overruns.
*/
status = ath9k_hw_rxprocdesc(ah, ds,
bf->bf_daddr,
PA2DESC(sc, ds->ds_link), 0);
if (status == EINPROGRESS) {
mutex_exit(&sc->sc_rxbuflock);
break;
}
list_remove(&sc->sc_rxbuf_list, bf);
mutex_exit(&sc->sc_rxbuflock);
rs = &ds->ds_rxstat;
if (rs->rs_status != 0) {
if (rs->rs_status & ATH9K_RXERR_CRC) {
sc->sc_stats.ast_rx_crcerr++;
}
if (rs->rs_status & ATH9K_RXERR_FIFO) {
sc->sc_stats.ast_rx_fifoerr++;
}
if (rs->rs_status & ATH9K_RXERR_DECRYPT) {
sc->sc_stats.ast_rx_badcrypt++;
}
if (rs->rs_status & ATH9K_RXERR_PHY) {
sc->sc_stats.ast_rx_phyerr++;
phyerr = rs->rs_phyerr & 0x1f;
sc->sc_stats.ast_rx_phy[phyerr]++;
}
goto rx_next;
}
len = rs->rs_datalen;
/* less than sizeof(struct ieee80211_frame) */
if (len < 20) {
sc->sc_stats.ast_rx_tooshort++;
goto rx_next;
}
if ((rx_mp = allocb(sc->sc_dmabuf_size, BPRI_MED)) == NULL) {
arn_problem("arn: arn_rx_handler(): "
"allocing mblk buffer failed.\n");
return;
}
ARN_DMA_SYNC(bf->bf_dma, DDI_DMA_SYNC_FORCPU);
bcopy(bf->bf_dma.mem_va, rx_mp->b_rptr, len);
rx_mp->b_wptr += len;
wh = (struct ieee80211_frame *)rx_mp->b_rptr;
if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
IEEE80211_FC0_TYPE_CTL) {
/*
* Ignore control frame received in promisc mode.
*/
freemsg(rx_mp);
goto rx_next;
}
/* Remove the CRC at the end of IEEE80211 frame */
rx_mp->b_wptr -= IEEE80211_CRC_LEN;
/*
* Locate the node for sender, track state, and then
* pass the (referenced) node up to the 802.11 layer
* for its use.
*/
in = ieee80211_find_rxnode(ic, wh);
if (ds->ds_rxstat.rs_rssi < 0)
ds->ds_rxstat.rs_rssi = 0;
if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
IEEE80211_FC0_TYPE_MGT) {
subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
/* Update Beacon RSSI, this is used by ANI. */
if (subtype == IEEE80211_FC0_SUBTYPE_BEACON)
sc->sc_halstats.ns_avgbrssi =
ds->ds_rxstat.rs_rssi;
}
#ifdef DEBUG
arn_printrxbuf(bf, status == 0);
#endif
/*
* signal 13-15 DLADM_WLAN_STRENGTH_EXCELLENT
* signal 10-12 DLADM_WLAN_STRENGTH_VERY_GOOD
* signal 6-9 DLADM_WLAN_STRENGTH_GOOD
* signal 3-5 DLADM_WLAN_STRENGTH_WEAK
* signal 0-2 DLADM_WLAN_STRENGTH_VERY_WEAK
*/
if (rs->rs_rssi == 0)
cur_signal = 0;
else if (rs->rs_rssi >= 45)
cur_signal = MAX_RSSI;
else
cur_signal = rs->rs_rssi * MAX_RSSI / 45 + 1;
/*
* Send the frame to net80211 for processing
*/
if (cur_signal <= 2 && ic->ic_state == IEEE80211_S_RUN)
(void) ieee80211_input(ic, rx_mp, in,
(rs->rs_rssi + 10), rs->rs_tstamp);
else
(void) ieee80211_input(ic, rx_mp, in,
rs->rs_rssi, rs->rs_tstamp);
/* release node */
ieee80211_free_node(in);
/*
* Arrange to update the last rx timestamp only for
* frames from our ap when operating in station mode.
* This assumes the rx key is always setup when associated.
*/
if (ic->ic_opmode == IEEE80211_M_STA &&
rs->rs_keyix != ATH9K_RXKEYIX_INVALID) {
ngood++;
}
/*
* change the default rx antenna if rx diversity chooses the
* other antenna 3 times in a row.
*/
if (sc->sc_defant != ds->ds_rxstat.rs_antenna) {
if (++sc->sc_rxotherant >= 3) {
ath9k_hw_setantenna(sc->sc_ah,
ds->ds_rxstat.rs_antenna);
sc->sc_defant = ds->ds_rxstat.rs_antenna;
sc->sc_rxotherant = 0;
}
} else {
sc->sc_rxotherant = 0;
}
rx_next:
mutex_enter(&sc->sc_rxbuflock);
list_insert_tail(&sc->sc_rxbuf_list, bf);
mutex_exit(&sc->sc_rxbuflock);
arn_rx_buf_link(sc, bf);
} while (loop);
if (ngood)
sc->sc_lastrx = ath9k_hw_gettsf64(ah);
#undef PA2DESC
}
uint_t
arn_softint_handler(caddr_t data)
{
struct arn_softc *sc = (struct arn_softc *)data;
ARN_LOCK(sc);
if (sc->sc_rx_pend) {
/* Soft interrupt for this driver */
sc->sc_rx_pend = 0;
ARN_UNLOCK(sc);
arn_rx_handler(sc);
return (DDI_INTR_CLAIMED);
}
ARN_UNLOCK(sc);
return (DDI_INTR_UNCLAIMED);
}