From patchwork Mon Jul 23 09:17:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh Palivela X-Patchwork-Id: 1226861 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 4042DE0079 for ; Mon, 23 Jul 2012 09:17:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751561Ab2GWJRm (ORCPT ); Mon, 23 Jul 2012 05:17:42 -0400 Received: from hub022-nj-2.exch022.serverdata.net ([206.225.164.185]:21685 "EHLO HUB022-nj-2.exch022.serverdata.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041Ab2GWJRl convert rfc822-to-8bit (ORCPT ); Mon, 23 Jul 2012 05:17:41 -0400 Received: from MBX022-E1-NJ-10.exch022.domain.local ([10.240.6.62]) by HUB022-NJ-2.exch022.domain.local ([10.240.6.33]) with mapi id 14.02.0309.002; Mon, 23 Jul 2012 02:17:40 -0700 From: Mahesh Palivela To: "linville@tuxdriver.com" CC: "linux-wireless@vger.kernel.org" , "johannes@sipsolutions.net" Subject: [PATCH] cfg80211: 80MHz (11ac) regulatory change Thread-Topic: [PATCH] cfg80211: 80MHz (11ac) regulatory change Thread-Index: Ac1otAJSr6owh0dVRh+3qAmLKlwqgQ== Date: Mon, 23 Jul 2012 09:17:40 +0000 Message-ID: <952C5D5D0470AE4FB7D8A75C6ADC71CA0FCC5E3B@mbx022-e1-nj-10.exch022.domain.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [122.183.20.86] MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 80MHz Regulatory changes for 11ac. Signed-off-by: Mahesh Palivela --- include/net/cfg80211.h | 8 +++++ net/wireless/reg.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 0 deletions(-) To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 493fa0c..bde0fee 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -104,10 +104,18 @@ enum ieee80211_channel_flags { IEEE80211_CHAN_RADAR = 1<<3, IEEE80211_CHAN_NO_HT40PLUS = 1<<4, IEEE80211_CHAN_NO_HT40MINUS = 1<<5, + IEEE80211_CHAN_NO_VHT80PLUS = 1<<6, + IEEE80211_CHAN_NO_VHT80MINUS = 1<<7, + IEEE80211_CHAN_NO_VHT160PLUS = 1<<8, + IEEE80211_CHAN_NO_VHT160MINUS = 1<<9, }; #define IEEE80211_CHAN_NO_HT40 \ (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) +#define IEEE80211_CHAN_NO_VHT80 \ + (IEEE80211_CHAN_NO_VHT80PLUS | IEEE80211_CHAN_NO_VHT80MINUS) +#define IEEE80211_CHAN_NO_VHT160 \ + (IEEE80211_CHAN_NO_VHT160PLUS | IEEE80211_CHAN_NO_VHT160MINUS) /** * struct ieee80211_channel - channel definition diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 2303ee7..0ad6c15 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1124,6 +1124,81 @@ static void reg_process_beacons(struct wiphy *wiphy) wiphy_update_beacon_reg(wiphy); } +static bool is_vht80_not_allowed(struct ieee80211_channel *chan) +{ + if (!chan) + return true; + if (chan->flags & IEEE80211_CHAN_DISABLED) + return true; + /* This would happen when regulatory rules disallow VHT80 completely */ + if (IEEE80211_CHAN_NO_VHT80 == (chan->flags & (IEEE80211_CHAN_NO_VHT80))) + return true; + return false; +} + +static void reg_process_vht_flags_channel(struct wiphy *wiphy, + unsigned int chan_idx) +{ + struct ieee80211_supported_band *sband; + struct ieee80211_channel *channel; + struct ieee80211_channel *channel_before = NULL, *channel_after = NULL; + unsigned int i; + + assert_cfg80211_lock(); + + sband = wiphy->bands[IEEE80211_BAND_5GHZ]; + BUG_ON(chan_idx >= sband->n_channels); + channel = &sband->channels[chan_idx]; + + if (is_vht80_not_allowed(channel)) { + channel->flags |= IEEE80211_CHAN_NO_VHT80; + return; + } + + /* + * We need to ensure the extension channels exist to + * be able to use VHT80- or VHT80+, this finds them (or not) + */ + for (i = 0; i < sband->n_channels; i++) { + struct ieee80211_channel *c = &sband->channels[i]; + if (c->center_freq == (channel->center_freq - 40)) + channel_before = c; + if (c->center_freq == (channel->center_freq + 40)) + channel_after = c; + } + + /* + * Please note that this assumes target bandwidth is 40 MHz, + * if that ever changes we also need to change the below logic + * to include that as well. + */ + if (is_vht80_not_allowed(channel_before)) + channel->flags |= IEEE80211_CHAN_NO_VHT80MINUS; + else + channel->flags &= ~IEEE80211_CHAN_NO_VHT80MINUS; + + if (is_vht80_not_allowed(channel_after)) + channel->flags |= IEEE80211_CHAN_NO_VHT80PLUS; + else + channel->flags &= ~IEEE80211_CHAN_NO_VHT80PLUS; +} + +static void reg_process_vht_flags(struct wiphy *wiphy) +{ + unsigned int i; + struct ieee80211_supported_band *sband; + + if(!wiphy->bands[IEEE80211_BAND_5GHZ]) { + /* 5GHz band is not supported, which is + * mandatory for VHT. so simply return */ + return; + } + sband = wiphy->bands[IEEE80211_BAND_5GHZ]; + + for (i = 0; i < sband->n_channels; i++) + reg_process_vht_flags_channel(wiphy, i); +} + static bool is_ht40_not_allowed(struct ieee80211_channel *chan) { if (!chan) @@ -1230,6 +1305,7 @@ static void wiphy_update_regulatory(struct wiphy *wiphy, reg_process_beacons(wiphy); reg_process_ht_flags(wiphy); + reg_process_vht_flags(wiphy); if (wiphy->reg_notifier) wiphy->reg_notifier(wiphy, last_request); }--