From patchwork Tue Jan 8 18:10:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 1947021 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 040D7DF23A for ; Tue, 8 Jan 2013 18:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756880Ab3AHSKv (ORCPT ); Tue, 8 Jan 2013 13:10:51 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:55075 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756834Ab3AHSKv (ORCPT ); Tue, 8 Jan 2013 13:10:51 -0500 Received: from 64-126-113-177.dyn.everestkc.net ([64.126.113.177] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1TsddS-00027s-6p; Tue, 08 Jan 2013 18:10:50 +0000 From: Seth Forshee To: Johannes Berg Cc: linux-wireless@vger.kernel.org Subject: [RFC 1/3] mac80211: Add flushes to ensure off-channel PS is enabled during sw scans Date: Tue, 8 Jan 2013 12:10:43 -0600 Message-Id: <1357668645-5101-2-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357668645-5101-1-git-send-email-seth.forshee@canonical.com> References: <1357668645-5101-1-git-send-email-seth.forshee@canonical.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We've got a couple of races when enabling powersave with an AP for off-channel operation. The first is fairly simple. If we go off-channel prior to the nullfunc frame to enable PS is actually transmitted then it may not be received by the AP. Add a flush after enabling off-channel PS to prevent this from happening. The second race is a bit more subtle. If the driver supports QoS and has frames queued when the nullfunc frame is queued, those frames may get transmitted after the nullfunc frame. If PM is not set then the AP is being told that we've exited PS before we go off-channel and may try to deliver frames. To prevent this, add a flush after stopping the netdev queues but before passing the nullfunc frame to the driver. Signed-off-by: Seth Forshee --- net/mac80211/offchannel.c | 17 ++++++++++++++++- net/mac80211/scan.c | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index a5379ae..ccb91a2 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c @@ -136,8 +136,23 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local, netif_tx_stop_all_queues(sdata->dev); if (offchannel_ps_enable && (sdata->vif.type == NL80211_IFTYPE_STATION) && - sdata->u.mgd.associated) + sdata->u.mgd.associated) { + /* + * Need to flush frames in driver queues + * before sending nullfunc. Otherwise + * devices which support QoS may send the + * nullfunc before these queued frames, and + * those frames may not have PM set. + * + * XXX: Would be nice to not flush for each + * vif, however I don't see that there's any + * protection to prevent frames being handed + * to the driver before stopping the netdev + * queue. + */ + drv_flush(local, false); ieee80211_offchannel_ps_enable(sdata); + } } } mutex_unlock(&local->iflist_mtx); diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 8ed83dc..a875f74 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -355,6 +355,14 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) ieee80211_offchannel_stop_vifs(local, true); + /* + * Flush hw queues to ensure that the nullfunc to enable powersave + * gets sent before going off-channel. + * + * XXX: Delay for drivers not supporting flush? + */ + drv_flush(local, false); + ieee80211_configure_filter(local); /* We need to set power level at maximum rate for scanning. */