From patchwork Mon Jan 6 07:52:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 3436271 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AE21A9F2E9 for ; Mon, 6 Jan 2014 07:58:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7632C20170 for ; Mon, 6 Jan 2014 07:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 313EC2016A for ; Mon, 6 Jan 2014 07:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107AbaAFH6W (ORCPT ); Mon, 6 Jan 2014 02:58:22 -0500 Received: from li674-96.members.linode.com ([212.71.239.96]:43890 "EHLO li674-96.members.linode.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbaAFH6W (ORCPT ); Mon, 6 Jan 2014 02:58:22 -0500 Received: from jm (a91-155-81-93.elisa-laajakaista.fi [91.155.81.93]) by li674-96.members.linode.com (Postfix) with ESMTPSA id 8926B118CB; Mon, 6 Jan 2014 07:52:10 +0000 (UTC) Received: by jm (sSMTP sendmail emulation); Mon, 06 Jan 2014 09:52:10 +0200 Date: Mon, 6 Jan 2014 09:52:10 +0200 From: Jouni Malinen To: Johannes Berg Cc: linux-wireless@vger.kernel.org Subject: [RFC 3/3] mac80211: Allow channel time for scans to be modified Message-ID: <20140106075210.GA31061@w1.fi> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This uses the MaxChannelTime value, if specified, from the scan request to control how long the mac80211 sw_scan spends on the channels. Signed-off-by: Jouni Malinen --- net/mac80211/scan.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 88c8161..53252a5 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -29,6 +29,27 @@ #define IEEE80211_CHANNEL_TIME (HZ / 33) #define IEEE80211_PASSIVE_CHANNEL_TIME (HZ / 9) +static unsigned long ieee80211_scan_active_time(struct ieee80211_local *local) +{ + /* + * Note: Could use min_chan_time to speed scans if we supported + * PHY-CCA.indication detection or maybe an emulation of that based on + * frame RX. + */ + if (!local->scan_req->max_chan_time) + return IEEE80211_CHANNEL_TIME; + return max_t(unsigned long, + TU_TO_JIFFIES(local->scan_req->max_chan_time), 1); +} + +static unsigned long ieee80211_scan_passive_time(struct ieee80211_local *local) +{ + if (!local->scan_req->max_chan_time) + return IEEE80211_PASSIVE_CHANNEL_TIME; + return max_t(unsigned long, + TU_TO_JIFFIES(local->scan_req->max_chan_time), 1); +} + void ieee80211_rx_bss_put(struct ieee80211_local *local, struct ieee80211_bss *bss) { @@ -447,7 +468,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, * After sending probe requests, wait for probe responses * on the channel. */ - *next_delay = IEEE80211_CHANNEL_TIME; + *next_delay = ieee80211_scan_active_time(local); local->next_scan_state = SCAN_DECISION; } @@ -489,6 +510,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, req->n_channels * sizeof(req->channels[0]); local->hw_scan_req->ie = ies; local->hw_scan_req->flags = req->flags; + local->hw_scan_req->min_chan_time = req->min_chan_time; + local->hw_scan_req->max_chan_time = req->max_chan_time; local->hw_scan_band = 0; @@ -527,14 +550,11 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, /* We need to ensure power level is at max for scanning. */ ieee80211_hw_config(local, 0); - if ((req->channels[0]->flags & - IEEE80211_CHAN_NO_IR) || - !local->scan_req->n_ssids) { - next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; - } else { + if ((req->channels[0]->flags & IEEE80211_CHAN_NO_IR) || + !local->scan_req->n_ssids) + next_delay = ieee80211_scan_passive_time(local); + else ieee80211_scan_state_send_probe(local, &next_delay); - next_delay = IEEE80211_CHANNEL_TIME; - } /* Now, just wait a bit and we are all done! */ ieee80211_queue_delayed_work(&local->hw, &local->scan_work, @@ -700,7 +720,7 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, */ if (chan->flags & IEEE80211_CHAN_NO_IR || !local->scan_req->n_ssids) { - *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME; + *next_delay = ieee80211_scan_passive_time(local); local->next_scan_state = SCAN_DECISION; return; }