From owner-freebsd-net@FreeBSD.ORG Fri Feb 4 08:54:45 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D92F4106566B for ; Fri, 4 Feb 2011 08:54:45 +0000 (UTC) (envelope-from bschmidt@techwires.net) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 733B88FC15 for ; Fri, 4 Feb 2011 08:54:45 +0000 (UTC) Received: by fxm16 with SMTP id 16so2149231fxm.13 for ; Fri, 04 Feb 2011 00:54:44 -0800 (PST) Received: by 10.223.79.6 with SMTP id n6mr2187912fak.122.1296809684259; Fri, 04 Feb 2011 00:54:44 -0800 (PST) Received: from julie.lab.techwires.net (dslb-088-067-208-143.pools.arcor-ip.net [88.67.208.143]) by mx.google.com with ESMTPS id o17sm113569fal.25.2011.02.04.00.54.40 (version=SSLv3 cipher=RC4-MD5); Fri, 04 Feb 2011 00:54:42 -0800 (PST) Sender: Bernhard Schmidt From: Bernhard Schmidt To: Alexander Zagrebin Date: Fri, 4 Feb 2011 09:51:34 +0100 User-Agent: KMail/1.13.5 (FreeBSD/8.1-RELEASE; KDE/4.5.5; amd64; ; ) References: <20110204060808.GA97298@gw.zagrebin.ru> In-Reply-To: <20110204060808.GA97298@gw.zagrebin.ru> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_W47SNdY1J+fqshI" Message-Id: <201102040951.34201.bschmidt@freebsd.org> Cc: freebsd-net@freebsd.org Subject: Re: if_run in hostap mode: issue with stations in the power save mode X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2011 08:54:45 -0000 --Boundary-00=_W47SNdY1J+fqshI Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Friday 04 February 2011 07:08:08 Alexander Zagrebin wrote: > I'm using an Ralink RT2870 based adapter (run(4) driver) in the > hostap mode. and I've noticed that if_run doesn't support stations > working in the power save mode (PSM). The reason is in lack of the > TIM in beacons. The attached patch adds this functionality and > completely fixes this issue. Despite the fact that patch is working, > it seems that it needs an additional work. For example, now the > result of ieee80211_beacon_update is ignored with a corresponding > message, but may be necessary to process it... > > Can somebody review it? That looks about right, good catch! Handling ieee80211_beacon_update()'s return value doesn't seem to be necessary, the mbuf's length is handled in the next few lines of code anyways, doesn't matter if it changed or not. Though, I have a some doubts about just restoring bo_flags is enough (Can't prove that with some obvious code, still..). It feels saner to me if we just reuse the whole mbuf, similar to what ath(4) does. Can you look at attached patch? Completely untested, so I'm not sure what does happen on e.g. changing the SSID. -- Bernhard --Boundary-00=_W47SNdY1J+fqshI Content-Type: text/x-patch; charset="ISO-8859-1"; name="run-beacon.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="run-beacon.diff" Index: sys/dev/usb/wlan/if_runvar.h =================================================================== --- sys/dev/usb/wlan/if_runvar.h (revision 218083) +++ sys/dev/usb/wlan/if_runvar.h (working copy) @@ -121,6 +121,7 @@ struct run_cmdq { struct run_vap { struct ieee80211vap vap; struct ieee80211_beacon_offsets bo; + struct mbuf *beacon_mbuf; int (*newstate)(struct ieee80211vap *, enum ieee80211_state, int); Index: sys/dev/usb/wlan/if_run.c =================================================================== --- sys/dev/usb/wlan/if_run.c (revision 218083) +++ sys/dev/usb/wlan/if_run.c (working copy) @@ -856,6 +856,8 @@ run_vap_delete(struct ieee80211vap *vap) RUN_LOCK(sc); + m_freem(rvp->beacon_mbuf); + rvp_id = rvp->rvp_id; sc->ratectl_run &= ~(1 << rvp_id); sc->rvp_bmap &= ~(1 << rvp_id); @@ -3903,6 +3905,7 @@ run_update_beacon(struct ieee80211vap *vap, int it struct run_softc *sc = ic->ic_ifp->if_softc; uint32_t i; + setbit(RUN_VAP(vap)->bo.bo_flags, item); i = RUN_CMDQ_GET(&sc->cmdq_store); DPRINTF("cmdq_store=%d\n", i); sc->cmdq[i].func = run_update_beacon_cb; @@ -3916,6 +3919,7 @@ static void run_update_beacon_cb(void *arg) { struct ieee80211vap *vap = arg; + struct run_vap *rvp = RUN_VAP(vap); struct ieee80211com *ic = vap->iv_ic; struct run_softc *sc = ic->ic_ifp->if_softc; struct rt2860_txwi txwi; @@ -3925,8 +3929,15 @@ run_update_beacon_cb(void *arg) if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC) return; - if ((m = ieee80211_beacon_alloc(vap->iv_bss, &RUN_VAP(vap)->bo)) == NULL) - return; + if (&RUN_VAP(vap)->beacon_mbuf == NULL) { + m = ieee80211_beacon_alloc(vap->iv_bss, &RUN_VAP(vap)->bo); + if (m == NULL) + return; + rvp->beacon_mbuf = m; + } else { + m = rvp->beacon_mbuf; + ieee80211_beacon_update(vap->iv_bss, &rvp->bo, m, 1); + } memset(&txwi, 0, sizeof txwi); txwi.wcid = 0xff; @@ -3941,13 +3952,11 @@ run_update_beacon_cb(void *arg) txwi.flags = RT2860_TX_TS; txwi.xflags = RT2860_TX_NSEQ; - run_write_region_1(sc, RT2860_BCN_BASE(RUN_VAP(vap)->rvp_id), - (uint8_t *)&txwi, sizeof txwi); - run_write_region_1(sc, RT2860_BCN_BASE(RUN_VAP(vap)->rvp_id) + sizeof txwi, + run_write_region_1(sc, RT2860_BCN_BASE(rvp->rvp_id), (uint8_t *)&txwi, + sizeof txwi); + run_write_region_1(sc, RT2860_BCN_BASE(rvp->rvp_id) + sizeof txwi, mtod(m, uint8_t *), (m->m_pkthdr.len + 1) & ~1); /* roundup len */ - m_freem(m); - return; } --Boundary-00=_W47SNdY1J+fqshI--