From owner-freebsd-net@FreeBSD.ORG Fri Feb 4 06:08:12 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 70C371065670 for ; Fri, 4 Feb 2011 06:08:12 +0000 (UTC) (envelope-from alex@zagrebin.ru) Received: from mail.zagrebin.ru (gw.zagrebin.ru [91.215.205.128]) by mx1.freebsd.org (Postfix) with ESMTP id 171198FC13 for ; Fri, 4 Feb 2011 06:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zagrebin.ru; s=mail; h=Content-Type:MIME-Version:Message-ID:Subject:To:From:Date; bh=bkysoeGCfcLnGrCULB66IKRlWVij2dTv3UJohu4ndtE=; b=xLdfH86RLFrWWjwfu1UkPsG5rjVTIcQ3fgmS2/6BCStDd2lidz3DCmLBMi5yp75ycQc7wJMz6nWZ5DnH9PI9dMPl+iWhhLBpt+UaIeMSzsX3jeaZh3uhhwevI/0lC2BlxANhXsGTbIn6kb3zsp+Ec/rCAF0yWeToyqsVl78YTVQ=; Received: from alex by mail.zagrebin.ru with local (Exim 4.74 (FreeBSD)) (envelope-from ) id 1PlEq1-000PXM-4e for freebsd-net@freebsd.org; Fri, 04 Feb 2011 09:08:09 +0300 Date: Fri, 4 Feb 2011 09:08:08 +0300 From: Alexander Zagrebin To: freebsd-net@freebsd.org Message-ID: <20110204060808.GA97298@gw.zagrebin.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: 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 06:08:12 -0000 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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? -- Alexander Zagrebin --ew6BAiZeqk4r7MaW Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch-if_run.c" --- sys/dev/usb/wlan/if_run.c.orig 2011-01-21 08:28:14.000000000 +0300 +++ sys/dev/usb/wlan/if_run.c 2011-02-03 20:46:16.809999991 +0300 @@ -3903,6 +3903,7 @@ 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; @@ -3921,13 +3922,25 @@ struct rt2860_txwi txwi; struct mbuf *m; uint8_t ridx; + uint8_t flags[4]; if (vap->iv_bss->ni_chan == IEEE80211_CHAN_ANYC) return; + /* + * ieee80211_beacon_construct called from ieee80211_beacon_alloc + * will clear bo_flags, so we need store it for later use + */ + memcpy(&flags, &RUN_VAP(vap)->bo.bo_flags, sizeof(flags)); + if ((m = ieee80211_beacon_alloc(vap->iv_bss, &RUN_VAP(vap)->bo)) == NULL) return; + /* Now we may restore bo_flags and update the dynamic beacon contents */ + memcpy(&RUN_VAP(vap)->bo.bo_flags, &flags, sizeof(flags)); + if (ieee80211_beacon_update(vap->iv_bss, &RUN_VAP(vap)->bo, m, 1)) + device_printf(sc->sc_dev, "ieee80211_beacon_update failed\n"); + memset(&txwi, 0, sizeof txwi); txwi.wcid = 0xff; txwi.len = htole16(m->m_pkthdr.len); --ew6BAiZeqk4r7MaW--