From patchwork Thu Mar 23 13:30:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 9641113 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 01BAE60328 for ; Thu, 23 Mar 2017 13:31:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63C6284FF for ; Thu, 23 Mar 2017 13:31:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D932E284EC; Thu, 23 Mar 2017 13:31:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A113284EC for ; Thu, 23 Mar 2017 13:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=k7q6W2d3Xvz8Sab8IevI53lj8j9lGnPoxa+zjnDlgOA=; b=QqS08qSmOAQxmZ6JgRuJUeBGnS AWUEJ2EJ8X09m5Rczd7DHzEbdnHyc5L5lMDIJpW3sJXOuPbIrbO3T6aeq3hL4AqT4R1Ezz6rs2YQy moT/xDqolFCp/Ea84kgEV16RnuHss4LpagNHtST+S9R4qy/Kje9cI4svlB0GqO5qRl/wgbH5EWOeN wc+fB92PF3Gb8UEFjjF0fObhINFio4ALW11Kho2BZ9RAsJWkw9PBiLEXQfHh2eQUdiqf7XHbpmSLZ U+cMkuD5zsvPapu6+vPRO72XpXJVxc73ZWIDx+oc1BmrNcooCpu9Ed1cmJn2u8zD2hd0uZieotqtp uiYdWX9g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cr2pl-0001Z2-Vg; Thu, 23 Mar 2017 13:31:22 +0000 Received: from packetmixer.de ([2001:4d88:2000:24::c0de] helo=mail.mail.packetmixer.de) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cr2pd-0001St-Uu for ath10k@lists.infradead.org; Thu, 23 Mar 2017 13:31:18 +0000 Received: from kero.packetmixer.de (p2003007C6F5BE70009DEAF779F8714A6.dip0.t-ipconnect.de [IPv6:2003:7c:6f5b:e700:9de:af77:9f87:14a6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mail.packetmixer.de (Postfix) with ESMTPSA id 4452C62287; Thu, 23 Mar 2017 14:30:52 +0100 (CET) From: Simon Wunderlich To: ath10k@lists.infradead.org, ath9k-devel@qca.qualcomm.com Subject: [PATCH v2 2/3] ath10k: add support for channels in licensed bands Date: Thu, 23 Mar 2017 14:30:47 +0100 Message-Id: <20170323133048.30062-3-sw@simonwunderlich.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170323133048.30062-1-sw@simonwunderlich.de> References: <20170323133048.30062-1-sw@simonwunderlich.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_063114_385834_FB8B3D0D X-CRM114-Status: GOOD ( 17.22 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mathias Kretschmer , linux-wireless@vger.kernel.org, Simon Wunderlich MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Many chips support channels in licensed bands. Add support for those, along with a corresponding kernel config option to disable them by default. Note that these channels are not selectable even if the option has been compiled unless the user modifies the regulatory database to explicitly enable the corresponding channels. NOTE: These channels must not be used in most regulatory domains unless you have a license from the FCC or similar! This patch also re-introduces the phy_mode_to_band function to allow selecting the band in a more clean way. Signed-off-by: Simon Wunderlich Signed-off-by: Mathias Kretschmer --- Changes to PATCHv1: * re-introduce and clean up phy to mode conversion (thanks Sebastian) --- drivers/net/wireless/ath/ath10k/Kconfig | 20 +++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 4 +++ drivers/net/wireless/ath/ath10k/mac.c | 10 +++++++ drivers/net/wireless/ath/ath10k/wmi.c | 53 +++++++++++++++++++++++---------- 4 files changed, 71 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/Kconfig b/drivers/net/wireless/ath/ath10k/Kconfig index b4241cf9b7ed..13a23ed33f91 100644 --- a/drivers/net/wireless/ath/ath10k/Kconfig +++ b/drivers/net/wireless/ath/ath10k/Kconfig @@ -53,3 +53,23 @@ config ATH10K_DFS_CERTIFIED ---help--- This option enables DFS support for initiating radiation on ath10k. + +config ATH10K_LICENSED_CHAN + bool "Support channels in licensed bands" + depends on ATH10K && CFG80211_CERTIFICATION_ONUS + default n + ---help--- + This option enables support for licensed channels on such as + 4.9 GHz (public safety). + + These are PUBLIC SAFETY CHANNELS and MUST NOT BE USED in most + regulatory domains UNLESS YOU HAVE A FULL LICENSE for their use from + your local radio regulator, e.g. the FCC or equivalent. Using these + channels without proper authorisation may result in serious legal + consequences. + + You will also have to build a regulatory database with these channels + enabled to actually use them. + + If you are a distro kernel builder or have any doubt whatsoever about + your legal ability to use these channels, say N. diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index d4b9a0ec1bdc..7674641537b4 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -46,7 +46,11 @@ #define WMI_READY_TIMEOUT (5 * HZ) #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ) #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ) +#ifdef CONFIG_ATH10K_LICENSED_CHAN +#define ATH10K_NUM_CHANS 47 +#else #define ATH10K_NUM_CHANS 40 +#endif /* Antenna noise floor */ #define ATH10K_DEFAULT_NOISE_FLOOR -95 diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index d60086cdc584..81848e0a3a5e 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -7669,6 +7669,16 @@ static const struct ieee80211_channel ath10k_5ghz_channels[] = { CHAN5G(161, 5805, 0), CHAN5G(165, 5825, 0), CHAN5G(169, 5845, 0), +#ifdef CONFIG_ATH10K_LICENSED_CHAN + CHAN5G(184, 4920, 0), + CHAN5G(188, 4940, 0), + CHAN5G(192, 4960, 0), + CHAN5G(196, 4980, 0), + CHAN5G(8, 5040, 0), + CHAN5G(12, 5060, 0), + CHAN5G(16, 5080, 0), +#endif + }; struct ath10k *ath10k_mac_create(size_t priv_size) diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 4e60caec7ab4..d78c778eae4c 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -2271,6 +2271,41 @@ static bool ath10k_wmi_rx_is_decrypted(struct ath10k *ar, return true; } +static inline enum nl80211_band phy_mode_to_band(u32 phy_mode, u32 channel) +{ + enum nl80211_band band; + + switch (phy_mode) { + case MODE_11A: + case MODE_11NA_HT20: + case MODE_11NA_HT40: + case MODE_11AC_VHT20: + case MODE_11AC_VHT40: + case MODE_11AC_VHT80: + band = NL80211_BAND_5GHZ; + break; + case MODE_11B: + /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is + * set to MODE_11B. + */ + if (channel < 1 || channel > 14) { + band = NL80211_BAND_5GHZ; + break; + } + case MODE_11G: + case MODE_11GONLY: + case MODE_11NG_HT20: + case MODE_11NG_HT40: + case MODE_11AC_VHT20_2G: + case MODE_11AC_VHT40_2G: + case MODE_11AC_VHT80_2G: + default: + band = NL80211_BAND_2GHZ; + } + + return band; +} + int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) { struct wmi_mgmt_rx_ev_arg arg = {}; @@ -2320,22 +2355,8 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb) __le64_to_cpu(arg.ext_info.rx_mac_timestamp); status->flag |= RX_FLAG_MACTIME_END; } - /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to - * MODE_11B. This means phy_mode is not a reliable source for the band - * of mgmt rx. - */ - if (channel >= 1 && channel <= 14) { - status->band = NL80211_BAND_2GHZ; - } else if (channel >= 36 && channel <= 169) { - status->band = NL80211_BAND_5GHZ; - } else { - /* Shouldn't happen unless list of advertised channels to - * mac80211 has been changed. - */ - WARN_ON_ONCE(1); - dev_kfree_skb(skb); - return 0; - } + + status->band = phy_mode_to_band(phy_mode, channel); if (phy_mode == MODE_11B && status->band == NL80211_BAND_5GHZ) ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");