From patchwork Wed Feb 6 15:01:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 2104871 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 B13D3DF2A1 for ; Wed, 6 Feb 2013 15:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756348Ab3BFPB2 (ORCPT ); Wed, 6 Feb 2013 10:01:28 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52017 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754169Ab3BFPB1 (ORCPT ); Wed, 6 Feb 2013 10:01:27 -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 1U36V4-0002Un-9C; Wed, 06 Feb 2013 15:01:26 +0000 From: Seth Forshee To: Johannes Berg , linux-wireless@vger.kernel.org Cc: Stanislaw Gruszka , Seth Forshee Subject: [PATCH 3/4] mac80211: Improve error handling for off-channel operation Date: Wed, 6 Feb 2013 09:01:12 -0600 Message-Id: <1360162873-17240-4-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 Errors in sending the nullfunc frame to set powersave at the AP for off-channel operation can lead to high packet loss. Add error handling to fail going off-channel when this happens, and return an error to userspace. Signed-off-by: Seth Forshee --- net/mac80211/ieee80211_i.h | 4 ++-- net/mac80211/mlme.c | 6 +++--- net/mac80211/offchannel.c | 24 ++++++++++++++++++------ net/mac80211/scan.c | 13 +++++++++++-- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 505ff3c..8adfdfb 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1368,7 +1368,7 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata); void ieee80211_sched_scan_stopped_work(struct work_struct *work); /* off-channel helpers */ -void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local); +bool ieee80211_offchannel_stop_vifs(struct ieee80211_local *local); void ieee80211_offchannel_return(struct ieee80211_local *local); void ieee80211_roc_setup(struct ieee80211_local *local); void ieee80211_start_next_roc(struct ieee80211_local *local); @@ -1581,7 +1581,7 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local, void ieee80211_dynamic_ps_enable_work(struct work_struct *work); void ieee80211_dynamic_ps_disable_work(struct work_struct *work); void ieee80211_dynamic_ps_timer(unsigned long data); -void ieee80211_send_nullfunc(struct ieee80211_local *local, +bool ieee80211_send_nullfunc(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, int powersave); void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index d5a3cf7..0f4e21f 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -664,7 +664,7 @@ void ieee80211_send_pspoll(struct ieee80211_local *local, ieee80211_tx_skb(sdata, skb); } -void ieee80211_send_nullfunc(struct ieee80211_local *local, +bool ieee80211_send_nullfunc(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, int powersave) { @@ -674,7 +674,7 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif); if (!skb) - return; + return false; nullfunc = (struct ieee80211_hdr_3addr *) skb->data; if (powersave) @@ -685,7 +685,7 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, IEEE80211_STA_CONNECTION_POLL)) IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_USE_MINRATE; - ieee80211_tx_skb_offchannel(sdata, skb); + return ieee80211_tx_skb_offchannel(sdata, skb) == IEEE80211_TX_OK; } static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local, diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index 5b9b3b8..650af94 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c @@ -24,10 +24,11 @@ * because we *may* be doing work on-operating channel, and want our * hardware unconditionally awake, but still let the AP send us normal frames. */ -static void ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata) +static bool ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; + bool ret = true; local->offchannel_ps_enabled = false; @@ -57,7 +58,9 @@ static void ieee80211_offchannel_ps_enable(struct ieee80211_sub_if_data *sdata) * to send a new nullfunc frame to inform the AP that we * are again sleeping. */ - ieee80211_send_nullfunc(local, sdata, 1); + ret = ieee80211_send_nullfunc(local, sdata, 1); + + return ret; } /* inform AP that we are awake again, unless power save is enabled */ @@ -102,12 +105,13 @@ static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata) ieee80211_sta_reset_conn_monitor(sdata); } -void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local) +bool ieee80211_offchannel_stop_vifs(struct ieee80211_local *local) { struct ieee80211_sub_if_data *sdata; + bool ret = true; if (WARN_ON(local->use_chanctx)) - return; + return false; /* * notify the AP about us leaving the channel and stop all @@ -138,10 +142,18 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local) } if (sdata->vif.type == NL80211_IFTYPE_STATION && - sdata->u.mgd.associated) - ieee80211_offchannel_ps_enable(sdata); + sdata->u.mgd.associated) { + ret = ieee80211_offchannel_ps_enable(sdata); + if (!ret) + break; + } } mutex_unlock(&local->iflist_mtx); + + /* Attempt to recover if failed */ + if (!ret) + ieee80211_offchannel_return(local); + return ret; } void ieee80211_offchannel_return(struct ieee80211_local *local) diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 607684c..beca4db 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -340,7 +340,8 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) local->next_scan_state = SCAN_DECISION; local->scan_channel_idx = 0; - ieee80211_offchannel_stop_vifs(local); + if (!ieee80211_offchannel_stop_vifs(local)) + goto error; ieee80211_configure_filter(local); @@ -351,6 +352,10 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local) &local->scan_work, 0); return 0; + +error: + drv_sw_scan_complete(local); + return -EBUSY; } static bool ieee80211_can_scan(struct ieee80211_local *local, @@ -688,7 +693,11 @@ static void ieee80211_scan_state_suspend(struct ieee80211_local *local, static void ieee80211_scan_state_resume(struct ieee80211_local *local, unsigned long *next_delay) { - ieee80211_offchannel_stop_vifs(local); + if (!ieee80211_offchannel_stop_vifs(local)) { + *next_delay = 0; + local->next_scan_state = SCAN_ABORT; + return; + } if (local->ops->flush) { drv_flush(local, false);