From patchwork Fri Jan 16 10:38:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 5647041 X-Patchwork-Delegate: johannes@sipsolutions.net 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 356199F357 for ; Fri, 16 Jan 2015 10:47:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EC3720160 for ; Fri, 16 Jan 2015 10:47:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 365B02011D for ; Fri, 16 Jan 2015 10:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752070AbbAPKqz (ORCPT ); Fri, 16 Jan 2015 05:46:55 -0500 Received: from mail-we0-f178.google.com ([74.125.82.178]:56477 "EHLO mail-we0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbbAPKqs (ORCPT ); Fri, 16 Jan 2015 05:46:48 -0500 Received: by mail-we0-f178.google.com with SMTP id p10so19508217wes.9 for ; Fri, 16 Jan 2015 02:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PKzCJ1Lgm1/tEn5kcYm8uUmuPjtFZaW8mQq4bxz12Sg=; b=UxDoyy4FDvV02BtZf1arUnjQp6nqsCLX92/JdgIlrku8T0lX1yz/1oW1X7szfnfLyD Xqd2tW1JleZzYmDPNnwVtd2sHaWn70CvQ7OhGnzq7dSDCCzNh1BgQx2MHHd30ZcFlQg7 lMdn4DqH1246tzkY2yeqWbbjf60tvplLY9hXw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PKzCJ1Lgm1/tEn5kcYm8uUmuPjtFZaW8mQq4bxz12Sg=; b=I3T1q0598CAogFJJDn9XxzOFx4Uh2HR8NPeJ7mtgXmkI5jZjeijV5gk3vA4wO1GvR6 I0sYm+28W13nHqDMHQLL9LMgqZhn+u0VccE7LHxX+xbm5YKi3pm8fQ3/Lw6/8YBO5ZTG 9Z75M0n+TZ773yq5VA3Ws1axZteywguaK7zBSVLsk7zdU4ZzancdJYkYsjSp+Y/0fTvO EPq/UVdH1dCEWguJm0cRtgwpIM55vAW4gZ31DzGi0RO34ts38hnUAo1+x4loV8yLsvhf wzxS1XTKv8vmD/HLcEJk7AagxYTlQgsR0ePcGXJmn34E75tS5W66T9lqo0CoSLB7QgxJ CiOA== X-Gm-Message-State: ALoCoQnIRDeDNrEF0imJJsHQJjvSJNG/p2uOdtmaTU2QZk41BGB7iJfoaqToluwL7kkmCnqilIRUlIsAA0rX5opjsiAbR0gvHzHvkN7SzVnOEJp3vKu9QlhToGfWxxVyLutfzo58mEyjgGKW+AxzRjoBl0A9P1FXv38ITSxw5gvJJ6DOD4ITqTWmA/emQ/UK7Q4Any39gkxq X-Received: by 10.180.82.137 with SMTP id i9mr5047438wiy.38.1421404778976; Fri, 16 Jan 2015 02:39:38 -0800 (PST) Received: from localhost.localdomain (apn-46-76-65-212.dynamic.gprs.plus.pl. [46.76.65.212]) by mx.google.com with ESMTPSA id bo5sm148423wjc.39.2015.01.16.02.39.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 02:39:38 -0800 (PST) From: Janusz Dziedzic To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Janusz Dziedzic Subject: [RFCv2 4/6] mac80211: IBSS fix scan request Date: Fri, 16 Jan 2015 11:38:42 +0100 Message-Id: <1421404724-32326-4-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421404724-32326-1-git-send-email-janusz.dziedzic@tieto.com> References: <1421404724-32326-1-git-send-email-janusz.dziedzic@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 In case of wide bandwidth (HT40/VHT80/VHT160) scan all channels we have in chandef, not only control one. Signed-off-by: Janusz Dziedzic --- net/mac80211/ibss.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/scan.c | 25 ++++++++++++------- 3 files changed, 77 insertions(+), 12 deletions(-) diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 1ffcfab..b1e9e9b 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c @@ -1289,7 +1289,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef); ieee80211_request_ibss_scan(sdata, ifibss->ssid, ifibss->ssid_len, - NULL, scan_width); + NULL, 0, scan_width); } static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) @@ -1328,6 +1328,56 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) capability, 0, true); } +static unsigned int +ieee80211_ibss_setup_scan_channels(struct wiphy *wiphy, + const struct cfg80211_chan_def *chandef, + struct ieee80211_channel **channels, + unsigned int channels_max) +{ + struct ieee80211_channel *chan = NULL; + unsigned int n_chan = 0; + u32 start_freq, end_freq, width, center_freq, freq; + + switch (chandef->width) { + case NL80211_CHAN_WIDTH_40: + width = 40; + break; + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_80: + width = 80; + break; + case NL80211_CHAN_WIDTH_160: + width = 160; + break; + default: + width = 20; + break; + } + + center_freq = chandef->center_freq1; + + if (width <= 20) { + start_freq = center_freq; + end_freq = center_freq; + } else { + start_freq = center_freq - width/2 + 10; + end_freq = center_freq + width/2 - 10; + } + + for (freq = start_freq; freq <= end_freq; freq += 20) { + chan = ieee80211_get_channel(wiphy, freq); + if (!chan) + continue; + if (n_chan >= channels_max) + return n_chan; + + channels[n_chan] = chan; + n_chan++; + } + + return n_chan; +} + /* * This function is called with state == IEEE80211_IBSS_MLME_SEARCH */ @@ -1397,11 +1447,18 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) /* Selected IBSS not found in current scan results - try to scan */ if (time_after(jiffies, ifibss->last_scan_completed + IEEE80211_SCAN_INTERVAL)) { + struct ieee80211_channel *channels[8]; + unsigned int num = 0; + sdata_info(sdata, "Trigger new scan to find an IBSS to join\n"); + num = ieee80211_ibss_setup_scan_channels(local->hw.wiphy, + &ifibss->chandef, + channels, + ARRAY_SIZE(channels)); scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef); ieee80211_request_ibss_scan(sdata, ifibss->ssid, - ifibss->ssid_len, chan, + ifibss->ssid_len, channels, num, scan_width); } else { int interval = IEEE80211_SCAN_INTERVAL; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 95ce152..05d3af5 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1556,7 +1556,8 @@ int ieee80211_mesh_finish_csa(struct ieee80211_sub_if_data *sdata); void ieee80211_scan_work(struct work_struct *work); int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, const u8 *ssid, u8 ssid_len, - struct ieee80211_channel *chan, + struct ieee80211_channel **channels, + unsigned int n_channels, enum nl80211_bss_scan_width scan_width); int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, struct cfg80211_scan_request *req); diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 7807fa4..18730b97 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -923,11 +923,12 @@ int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, const u8 *ssid, u8 ssid_len, - struct ieee80211_channel *chan, + struct ieee80211_channel **channels, + unsigned int n_channels, enum nl80211_bss_scan_width scan_width) { struct ieee80211_local *local = sdata->local; - int ret = -EBUSY; + int ret = -EBUSY, i, n_ch = 0; enum ieee80211_band band; mutex_lock(&local->mtx); @@ -937,9 +938,8 @@ int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, goto unlock; /* fill internal scan request */ - if (!chan) { - int i, max_n; - int n_ch = 0; + if (!channels) { + int max_n; for (band = 0; band < IEEE80211_NUM_BANDS; band++) { if (!local->hw.wiphy->bands[band]) @@ -964,12 +964,19 @@ int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, local->int_scan_req->n_channels = n_ch; } else { - if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IR | - IEEE80211_CHAN_DISABLED))) + for (i = 0; i < n_channels; i++) { + if (channels[i]->flags & (IEEE80211_CHAN_NO_IR | + IEEE80211_CHAN_DISABLED)) + continue; + + local->int_scan_req->channels[n_ch] = channels[i]; + n_ch++; + } + + if (WARN_ON_ONCE(n_ch == 0)) goto unlock; - local->int_scan_req->channels[0] = chan; - local->int_scan_req->n_channels = 1; + local->int_scan_req->n_channels = n_ch; } local->int_scan_req->ssids = &local->scan_ssid;