From owner-p4-projects@FreeBSD.ORG Fri Oct 17 14:29:04 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8B07F16A4C0; Fri, 17 Oct 2003 14:29:04 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5064316A4B3 for ; Fri, 17 Oct 2003 14:29:04 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A703043FB1 for ; Fri, 17 Oct 2003 14:29:03 -0700 (PDT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h9HLT3XJ040007 for ; Fri, 17 Oct 2003 14:29:03 -0700 (PDT) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h9HLT3rh040004 for perforce@freebsd.org; Fri, 17 Oct 2003 14:29:03 -0700 (PDT) (envelope-from sam@freebsd.org) Date: Fri, 17 Oct 2003 14:29:03 -0700 (PDT) Message-Id: <200310172129.h9HLT3rh040004@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 39860 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Oct 2003 21:29:05 -0000 http://perforce.freebsd.org/chv.cgi?CH=39860 Change 39860 by sam@sam_ebb on 2003/10/17 14:28:03 o consolidate rx filter calculations in one place o enable beacon reception when operating in adhoc mode so the 802.11 layer can use them to create nodes for peers Affected files ... .. //depot/projects/netperf/sys/dev/ath/if_ath.c#25 edit Differences ... ==== //depot/projects/netperf/sys/dev/ath/if_ath.c#25 (text+ko) ==== @@ -919,20 +919,30 @@ } } -static void -ath_mode_init(struct ath_softc *sc) +/* + * Calculate the receive filter according to the + * operating mode and state: + * + * o always accept unicast, broadcast, and multicast traffic + * o maintain current state of phy error reception + * o probe request frames are accepted only when operating in + * hostap, adhoc, or monitor modes + * o enable promiscuous mode according to the interface state + * o accept beacons: + * - when operating in adhoc mode so the 802.11 layer creates + * node table entries for peers, + * - when operating in station mode for collecting rssi data when + * the station is otherwise quiet, or + * - when scanning + */ +static u_int32_t +ath_calcrxfilter(struct ath_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct ath_hal *ah = sc->sc_ah; struct ifnet *ifp = &ic->ic_if; - u_int32_t rfilt, mfilt[2], val; - u_int8_t pos; - struct ifmultiaddr *ifma; + u_int32_t rfilt; - /* configure operational mode */ - ath_hal_setopmode(ah, ic->ic_opmode); - - /* receive filter */ rfilt = (ath_hal_getrxfilter(ah) & HAL_RX_FILTER_PHYERR) | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; if (ic->ic_opmode != IEEE80211_M_STA) @@ -941,10 +951,29 @@ (ifp->if_flags & IFF_PROMISC)) rfilt |= HAL_RX_FILTER_PROM; if (ic->ic_opmode == IEEE80211_M_STA || + ic->ic_opmode == IEEE80211_M_IBSS || ic->ic_state == IEEE80211_S_SCAN) rfilt |= HAL_RX_FILTER_BEACON; + return rfilt; +} + +static void +ath_mode_init(struct ath_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ath_hal *ah = sc->sc_ah; + struct ifnet *ifp = &ic->ic_if; + u_int32_t rfilt, mfilt[2], val; + u_int8_t pos; + struct ifmultiaddr *ifma; + + /* configure rx filter */ + rfilt = ath_calcrxfilter(sc); ath_hal_setrxfilter(ah, rfilt); + /* configure operational mode */ + ath_hal_setopmode(ah, ic->ic_opmode); + /* calculate and install multicast filter */ if ((ifp->if_flags & IFF_ALLMULTI) == 0) { mfilt[0] = mfilt[1] = 0; @@ -2370,16 +2399,7 @@ error = ath_chan_set(sc, ni->ni_chan); if (error != 0) goto bad; - rfilt = (ath_hal_getrxfilter(ah) & HAL_RX_FILTER_PHYERR) - | HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; - if (ic->ic_opmode != IEEE80211_M_STA) - rfilt |= HAL_RX_FILTER_PROBEREQ; - if (ic->ic_opmode != IEEE80211_M_HOSTAP && - (ifp->if_flags & IFF_PROMISC)) - rfilt |= HAL_RX_FILTER_PROM; - if (ic->ic_opmode == IEEE80211_M_STA || - ic->ic_state == IEEE80211_S_SCAN) - rfilt |= HAL_RX_FILTER_BEACON; + rfilt = ath_calcrxfilter(sc); if (nstate == IEEE80211_S_SCAN) { callout_reset(&sc->sc_scan_ch, (hz * ath_dwelltime) / 1000, ath_next_scan, sc);