From 4df2d580a7f10793efbe2bf2946d9aebaa0efc40 Mon Sep 17 00:00:00 2001 From: mtaylor Date: Tue, 27 Nov 2007 10:06:02 +0000 Subject: [PATCH] port of r2879 from madwifi-dfs git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2980 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath/if_ath.c | 26 ++++++++++++++++++++------ net80211/ieee80211.h | 5 ++++- net80211/ieee80211_beacon.c | 6 +++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ath/if_ath.c b/ath/if_ath.c index 07a8ded..75d09dd 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -4246,6 +4246,14 @@ ath_beaconq_config(struct ath_softc *sc) } #undef ATH_EXPONENT_TO_VALUE } +/* Return 1 if beacon was already allocated, 0 otherwise. */ +static int +ath_beacon_allocated(struct ath_softc *sc, struct ieee80211_node *ni) { + return ni != NULL && + ni->ni_vap != NULL && + ATH_VAP(ni->ni_vap)->av_bcbuf != NULL && + ATH_VAP(ni->ni_vap)->av_bcbuf->bf_skb != NULL; +} /* * Allocate and setup an initial beacon frame. @@ -4260,6 +4268,8 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni) struct ath_buf *bf; struct sk_buff *skb; + KASSERT(!ath_beacon_allocated(sc, ni), ("beacon alloc called twice!")); + /* * release the previous beacon's skb if it already exists. */ @@ -4448,6 +4458,7 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar struct ath_vap *avp; struct sk_buff *skb; unsigned int curlen, ncabq; + u_int8_t tim_bitctl; if (vap->iv_state != IEEE80211_S_RUN) { DPRINTF(sc, ATH_DEBUG_BEACON_PROC, "%s: skip VAP in %s state\n", @@ -4511,7 +4522,8 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar * the cabq so that the current VAPs CAB traffic can be scheduled. * XXX: Need to handle the last MORE_DATA bit here. */ - if (ncabq && (avp->av_boff.bo_tim[4] & 1) && sc->sc_cabq->axq_depth) { + tim_bitctl = ((struct ieee80211_tim_ie *)avp->av_boff.bo_tim)->tim_bitctl; + if (ncabq && (tim_bitctl & BITCTL_BUFD_MCAST) && sc->sc_cabq->axq_depth) { if (sc->sc_nvaps > 1 && sc->sc_stagbeacons) { ath_tx_draintxq(sc, sc->sc_cabq); DPRINTF(sc, ATH_DEBUG_BEACON, @@ -4530,8 +4542,8 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap, int *needmar /* * Enable the CAB queue before the beacon queue to * ensure cab frames are triggered by this beacon. - */ - if (avp->av_boff.bo_tim[4] & 1) { /* NB: only at DTIM */ + * We only set BITCTL_BUFD_MCAST bit when its DTIM */ + if (tim_bitctl & BITCTL_BUFD_MCAST) { struct ath_txq *cabq = sc->sc_cabq; struct ath_buf *bfmcast; /* @@ -8568,9 +8580,11 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg) ni->ni_ath_defkeyindex = vap->iv_def_txkey; } - error = ath_beacon_alloc(sc, ni); - if (error < 0) - goto bad; + if (!ath_beacon_allocated(sc,ni)) { + error = ath_beacon_alloc(sc, ni); + if (error < 0) + goto bad; + } /* * if the turbo flags have changed, then beacon and turbo * need to be reconfigured. diff --git a/net80211/ieee80211.h b/net80211/ieee80211.h index 815017b..80e4d47 100644 --- a/net80211/ieee80211.h +++ b/net80211/ieee80211.h @@ -713,7 +713,10 @@ enum { IEEE80211_ELEMID_VENDOR = 221, /* vendor private */ }; -#define IEEE80211_CHANSWITCHANN_BYTES 5 +#define IEEE80211_CHANSWITCHANN_BYTES 5 +#define BITCTL_BUFD_MCAST 1 +#define BITCTL_BUFD_UCAST_AID_MASK ((u_int8_t)~(BITCTL_BUFD_MCAST)) +#define BITCTL_BUFD_UCAST_AID_SHIFT 1 struct ieee80211_tim_ie { u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ diff --git a/net80211/ieee80211_beacon.c b/net80211/ieee80211_beacon.c index ca6f192..4487a3c 100644 --- a/net80211/ieee80211_beacon.c +++ b/net80211/ieee80211_beacon.c @@ -422,7 +422,7 @@ ieee80211_beacon_update(struct ieee80211_node *ni, timoff = 128; /* impossibly large */ for (i = 0; i < vap->iv_tim_len; i++) if (vap->iv_tim_bitmap[i]) { - timoff = i &~ 1; + timoff = i & BITCTL_BUFD_UCAST_AID_MASK; break; } KASSERT(timoff != 128, ("tim bitmap empty!")); @@ -473,9 +473,9 @@ ieee80211_beacon_update(struct ieee80211_node *ni, tie->tim_count--; /* update state for buffered multicast frames on DTIM */ if (mcast && (tie->tim_count == 0)) - tie->tim_bitctl |= 1; + tie->tim_bitctl |= BITCTL_BUFD_MCAST; else - tie->tim_bitctl &= ~1; + tie->tim_bitctl &= BITCTL_BUFD_UCAST_AID_MASK; if ((ic->ic_flags & IEEE80211_F_DOTH) && (ic->ic_flags & IEEE80211_F_CHANSWITCH)) { -- 2.35.1