From patchwork Wed Feb 6 15:01:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 2104881 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8ED0D3FCFC for ; Wed, 6 Feb 2013 15:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756421Ab3BFPBa (ORCPT ); Wed, 6 Feb 2013 10:01:30 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52021 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754169Ab3BFPB3 (ORCPT ); Wed, 6 Feb 2013 10:01:29 -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 1U36V6-0002V1-Dx; Wed, 06 Feb 2013 15:01:28 +0000 From: Seth Forshee To: Johannes Berg , linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Seth Forshee Subject: [PATCH 4/4] mac80211: Add flushes before going off-channel Date: Wed, 6 Feb 2013 09:01:13 -0600 Message-Id: <1360162873-17240-5-git-send-email-seth.forshee@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360162873-17240-1-git-send-email-seth.forshee@canonical.com> References: <1360162873-17240-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 before the nullfunc frame to enable PS is 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 queues but before passing the nullfunc frame to the driver. Signed-off-by: Seth Forshee --- net/mac80211/offchannel.c | 5 +++++ net/mac80211/scan.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index 650af94..28274f9 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c @@ -118,8 +118,13 @@ bool ieee80211_offchannel_stop_vifs(struct ieee80211_local *local) * STA interfaces. */ + /* + * Stop queues and transmit all frames queued by the driver + * before sending nullfunc to enable powersave at the AP. + */ ieee80211_stop_queues_by_reason(&local->hw, IEEE80211_QUEUE_STOP_REASON_OFFCHANNEL); + drv_flush(local, false); mutex_lock(&local->iflist_mtx); list_for_each_entry(sdata, &local->interfaces, list) { diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index beca4db..9ecd1660 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -343,6 +343,9 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) if (!ieee80211_offchannel_stop_vifs(local)) goto error; + /* ensure nullfunc is transmitted before leaving operating channel */ + drv_flush(local, false); + ieee80211_configure_filter(local); /* We need to set power level at maximum rate for scanning. */