From patchwork Tue Apr 15 12:37:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rostislav Lisovy X-Patchwork-Id: 3992591 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 5983A9F2CC for ; Tue, 15 Apr 2014 12:39:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 81E9A20219 for ; Tue, 15 Apr 2014 12:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC06920155 for ; Tue, 15 Apr 2014 12:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754748AbaDOMiQ (ORCPT ); Tue, 15 Apr 2014 08:38:16 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:40303 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754713AbaDOMiH (ORCPT ); Tue, 15 Apr 2014 08:38:07 -0400 Received: by mail-ee0-f48.google.com with SMTP id b57so7614035eek.7 for ; Tue, 15 Apr 2014 05:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jhtHJtPqE8LwnFoMAahJr01AwXucaEgpCVPt6qTMCqU=; b=YC/VPOn8lXhj3KbzGPQRkHQffgK6RpnCEgJVV7VVHrUotKf3IGTv9Gt5jB3h0EnAvA 06HJFsb43q2HAZqwuND9ZyF/K+M7QV/QEF/rqlkMormZ+YkzV7/llNkTHUbkPcKNMIvl JwvT96ZRgCbV7hizBB39FFpgoRPVdj/YZmYNgRR+XVHY7DsbGAt7kW6tSPLvjIWLB5d/ iZtsqs77D1E3kExi4L7Fp4SL1IAeZ5BTermUk1tccRxVKUptwDH8KLnsRFUKZJicK45b ohLn6wHnQySMla0jVUzqkMcl6YpMaExV6BVko4MgqznYVq3nvYsgr5q/Ouzm6A9xGPiK wPmA== X-Received: by 10.14.225.73 with SMTP id y49mr2187621eep.43.1397565485322; Tue, 15 Apr 2014 05:38:05 -0700 (PDT) Received: from c2c-vostro1.felk.cvut.cz ([147.32.86.112]) by mx.google.com with ESMTPSA id o4sm48873643eef.20.2014.04.15.05.38.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Apr 2014 05:38:04 -0700 (PDT) From: Rostislav Lisovy To: Johannes Berg , "John W. Linville" , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michal Sojka , s.sander@nordsys.de, jan-niklas.meier@volkswagen.de, Rostislav Lisovy Subject: [PATCH 2/2] cfg80211: Use 5MHz bandwidth by default when checking usable channels Date: Tue, 15 Apr 2014 14:37:56 +0200 Message-Id: <1397565476-4348-3-git-send-email-rostislav.lisovy@fel.cvut.cz> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1397565476-4348-1-git-send-email-rostislav.lisovy@fel.cvut.cz> References: <1397565476-4348-1-git-send-email-rostislav.lisovy@fel.cvut.cz> 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Current code checks if the 20MHz bandwidth is allowed for particular channel -- if it is not, the channel is disabled. Since we need to use 5/10 MHz channels, this code is modified in the way that the default bandwidth to check is 5MHz. If the maximum bandwidth allowed by the channel is smaller than 5MHz, the channel is disabled. Otherwise the channel is used and the flags are set according to the bandwidth allowed by the channel. Signed-off-by: Rostislav Lisovy --- net/wireless/reg.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 9d32633..3f3bc2e 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -927,7 +927,7 @@ freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq, if (!band_rule_found) band_rule_found = freq_in_rule_band(fr, center_freq); - bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20)); + bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(5)); if (band_rule_found && bw_fits) return rr; @@ -1011,10 +1011,10 @@ static void chan_reg_rule_print_dbg(const struct ieee80211_regdomain *regd, } #endif -/* - * Note that right now we assume the desired channel bandwidth - * is always 20 MHz for each individual channel (HT40 uses 20 MHz - * per channel, the primary and the extension channel). +/* Find an ieee80211_reg_rule such that a 5MHz channel with frequency + * @chan->center_freq fits there. + * If there is no such reg_rule, disable the channel, otherwise set the + * flags corresponding to the bandwidths allowed in the particular reg_rule */ static void handle_channel(struct wiphy *wiphy, enum nl80211_reg_initiator initiator, @@ -1075,8 +1075,12 @@ static void handle_channel(struct wiphy *wiphy, if (reg_rule->flags & NL80211_RRF_AUTO_BW) max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); + if (max_bandwidth_khz < MHZ_TO_KHZ(10)) + bw_flags = IEEE80211_CHAN_NO_10MHZ; + if (max_bandwidth_khz < MHZ_TO_KHZ(20)) + bw_flags |= IEEE80211_CHAN_NO_20MHZ; if (max_bandwidth_khz < MHZ_TO_KHZ(40)) - bw_flags = IEEE80211_CHAN_NO_HT40; + bw_flags |= IEEE80211_CHAN_NO_HT40; if (max_bandwidth_khz < MHZ_TO_KHZ(80)) bw_flags |= IEEE80211_CHAN_NO_80MHZ; if (max_bandwidth_khz < MHZ_TO_KHZ(160)) @@ -1510,8 +1514,12 @@ static void handle_channel_custom(struct wiphy *wiphy, if (reg_rule->flags & NL80211_RRF_AUTO_BW) max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); + if (max_bandwidth_khz < MHZ_TO_KHZ(10)) + bw_flags = IEEE80211_CHAN_NO_10MHZ; + if (max_bandwidth_khz < MHZ_TO_KHZ(20)) + bw_flags |= IEEE80211_CHAN_NO_20MHZ; if (max_bandwidth_khz < MHZ_TO_KHZ(40)) - bw_flags = IEEE80211_CHAN_NO_HT40; + bw_flags |= IEEE80211_CHAN_NO_HT40; if (max_bandwidth_khz < MHZ_TO_KHZ(80)) bw_flags |= IEEE80211_CHAN_NO_80MHZ; if (max_bandwidth_khz < MHZ_TO_KHZ(160))