ATH10K Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] Channels in licensed bands, noise floor override
@ 2017-03-16 15:13 Simon Wunderlich
  2017-03-16 15:13 ` [PATCH 1/3] ath9k: Support channels in licensed bands Simon Wunderlich
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-16 15:13 UTC (permalink / raw)
  To: ath10k, ath9k-devel; +Cc: linux-wireless, Simon Wunderlich

This series contains two patches to enable channels in licensed bands.
Note that there are quite a few requirements to enable those:

 * channels must be explicitly enabled using a licensed band kernel config
   which contains a warning
 * it depends on CFG80211_CERTIFICATION_ONUS
 * users must install a custom regdb, since channels in those licensed
   bands are not included in the standard regdb

The ath9k patch has been proposed two times and rejected, but it also
included some channels on fractional center frequencies, which is not
the case this time (this would require more changes in mac80211 and
also userspace). The other concern about useres accidently tuning
should not be a problem based on the requirements mentioned above. I've
added another patch doing the same thing for ath10k.

Here is some more info on our need/background:

"We are working on a project that involves the use of Public Safety 
channels (4.9x GHz). It is typical 'First Responder' scenario where a 
communication network infrastructure should be set up in catastrophe 
situations.

As this is a controlled and managed network, the organization setting up 
the network has control over the channels that are being used, when and 
for how long and in which geographical area.  The enforcement of such a 
temporary license is a major requirement in this project.

To reduce the cost for the equipment (compared to commercial offerings 
in the 4k USD range), the outdoor devices run on hardened, but standard 
embedded hardware with a recent linux kernel and use Atheros radios.

We believe, that driver support for 4.9GHz channels should be included 
in the Linux kernel, as the driver just exposes specified hardware 
features which are disabled by default via

a) a separate compile-time flag. This is similar to the code used for 
compliance testing.

b) The default CRDA should (and does) not enable such channels.

Those two safeguards seem sufficient to protect against accidental misuse."

The third patch is adding an experimental debug option to override
the noise floor level, which is usually calibrated automatically.

Cheers,
     Simon

Ben Greear (1):
  ath9k: Support channels in licensed bands

Simon Wunderlich (2):
  ath10k: add support for channels in licensed bands
  ath9k: add noise floor override option

 drivers/net/wireless/ath/ath10k/Kconfig      | 20 +++++++++
 drivers/net/wireless/ath/ath10k/core.h       |  4 ++
 drivers/net/wireless/ath/ath10k/mac.c        |  9 ++++
 drivers/net/wireless/ath/ath10k/wmi.c        |  7 +++-
 drivers/net/wireless/ath/ath9k/Kconfig       | 20 +++++++++
 drivers/net/wireless/ath/ath9k/ath9k.h       |  2 +-
 drivers/net/wireless/ath/ath9k/calib.c       |  5 ++-
 drivers/net/wireless/ath/ath9k/common-init.c | 35 ++++++++++++----
 drivers/net/wireless/ath/ath9k/debug.c       | 62 ++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h          |  5 ++-
 10 files changed, 155 insertions(+), 14 deletions(-)

-- 
2.11.0


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] ath9k: Support channels in licensed bands
  2017-03-16 15:13 [PATCH 0/3] Channels in licensed bands, noise floor override Simon Wunderlich
@ 2017-03-16 15:13 ` Simon Wunderlich
  2017-03-17 13:40   ` Zefir Kurtisi
  2017-03-16 15:13 ` [PATCH 2/3] ath10k: add support for " Simon Wunderlich
  2017-03-16 15:13 ` [PATCH 3/3] ath9k: add noise floor override option Simon Wunderlich
  2 siblings, 1 reply; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-16 15:13 UTC (permalink / raw)
  To: ath10k, ath9k-devel
  Cc: Julian Calaby, Ben Greear, Mathias Kretschmer, linux-wireless,
	Simon Wunderlich

From: Ben Greear <greearb@candelatech.com>

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!

Signed-off-by: Ben Greear <greearb@candelatech.com>
[Hide this support behind a Kconfig option]
Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
[only use the 20 mhz channels, add 5 ghz, change to 4.9ghz to licensed bands]
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
---
 drivers/net/wireless/ath/ath9k/Kconfig       | 20 ++++++++++++++++
 drivers/net/wireless/ath/ath9k/ath9k.h       |  2 +-
 drivers/net/wireless/ath/ath9k/common-init.c | 35 +++++++++++++++++++++-------
 drivers/net/wireless/ath/ath9k/hw.h          |  4 ++--
 4 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 783a38f1a626..23b8abf4449a 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -116,6 +116,26 @@ config ATH9K_DFS_CERTIFIED
 	  developed. At this point enabling this option won't do anything
 	  except increase code size.
 
+config ATH9K_LICENSED_CHAN
+	bool "Support channels in licensed bands"
+	depends on ATH9K && 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.
+
 config ATH9K_DYNACK
 	bool "Atheros ath9k ACK timeout estimation algorithm (EXPERIMENTAL)"
 	depends on ATH9K
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index cf076719c27e..d215c3f968d4 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -996,7 +996,7 @@ struct ath_softc {
 	struct device *dev;
 
 	struct survey_info *cur_survey;
-	struct survey_info survey[ATH9K_NUM_CHANNELS];
+	struct survey_info survey[ATH9K_MAX_NUM_CHANNELS];
 
 	spinlock_t intr_lock;
 	struct tasklet_struct intr_tq;
diff --git a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
index 8b4f7fdabf58..0d632c22bc16 100644
--- a/drivers/net/wireless/ath/ath9k/common-init.c
+++ b/drivers/net/wireless/ath/ath9k/common-init.c
@@ -86,6 +86,22 @@ static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
 	CHAN5G(5785, 35), /* Channel 157 */
 	CHAN5G(5805, 36), /* Channel 161 */
 	CHAN5G(5825, 37), /* Channel 165 */
+
+#ifdef CONFIG_ATH9K_LICENSED_CHAN
+	/* 4.9Ghz channels, public safety channels, license is required in US
+	 * and most other regulatory domains!
+	 */
+	/* 802.11j 4.9 GHz (20 MHz) */
+	CHAN5G(4920, 38), /* channel 184 */
+	CHAN5G(4940, 39), /* channel 188 */
+	CHAN5G(4960, 40), /* channel 192 */
+	CHAN5G(4980, 41), /* channel 196 */
+	/* 802.11j 5.030 - 5.080 GHz (20 MHz) */
+	CHAN5G(5040, 42), /* channel 8 */
+	CHAN5G(5060, 43), /* channel 12 */
+	CHAN5G(5080, 44), /* channel 16 */
+#endif
+#define ATH9K_NUM_LICENSED_CHANNELS 7
 };
 
 /* Atheros hardware rate code addition for short premble */
@@ -126,10 +142,14 @@ int ath9k_cmn_init_channels_rates(struct ath_common *common)
 {
 	struct ath_hw *ah = (struct ath_hw *)common->ah;
 	void *channels;
+	int num_5ghz_chan = ARRAY_SIZE(ath9k_5ghz_chantable);
+
+	if (!IS_ENABLED(CONFIG_ATH9K_LICENSED_CHAN))
+		num_5ghz_chan -= ATH9K_NUM_LICENSED_CHANNELS;
 
 	BUILD_BUG_ON(ARRAY_SIZE(ath9k_2ghz_chantable) +
-		     ARRAY_SIZE(ath9k_5ghz_chantable) !=
-		     ATH9K_NUM_CHANNELS);
+		     ARRAY_SIZE(ath9k_5ghz_chantable) >
+		     ATH9K_MAX_NUM_CHANNELS);
 
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
 		channels = devm_kzalloc(ah->dev,
@@ -149,17 +169,16 @@ int ath9k_cmn_init_channels_rates(struct ath_common *common)
 	}
 
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
-		channels = devm_kzalloc(ah->dev,
-			sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
+		int ch_sz = num_5ghz_chan * sizeof(ath9k_5ghz_chantable[0]);
+
+		channels = devm_kzalloc(ah->dev, ch_sz, GFP_KERNEL);
 		if (!channels)
 			return -ENOMEM;
 
-		memcpy(channels, ath9k_5ghz_chantable,
-		       sizeof(ath9k_5ghz_chantable));
+		memcpy(channels, ath9k_5ghz_chantable, ch_sz);
 		common->sbands[NL80211_BAND_5GHZ].channels = channels;
 		common->sbands[NL80211_BAND_5GHZ].band = NL80211_BAND_5GHZ;
-		common->sbands[NL80211_BAND_5GHZ].n_channels =
-			ARRAY_SIZE(ath9k_5ghz_chantable);
+		common->sbands[NL80211_BAND_5GHZ].n_channels = num_5ghz_chan;
 		common->sbands[NL80211_BAND_5GHZ].bitrates =
 			ath9k_legacy_rates + 4;
 		common->sbands[NL80211_BAND_5GHZ].n_bitrates =
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 9cbca1229bac..496e3cd1b509 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -73,7 +73,7 @@
 
 #define ATH9K_RSSI_BAD			-128
 
-#define ATH9K_NUM_CHANNELS	38
+#define ATH9K_MAX_NUM_CHANNELS	45
 
 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
@@ -777,7 +777,7 @@ struct ath_hw {
 	struct ath9k_hw_version hw_version;
 	struct ath9k_ops_config config;
 	struct ath9k_hw_capabilities caps;
-	struct ath9k_channel channels[ATH9K_NUM_CHANNELS];
+	struct ath9k_channel channels[ATH9K_MAX_NUM_CHANNELS];
 	struct ath9k_channel *curchan;
 
 	union {
-- 
2.11.0


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/3] ath10k: add support for channels in licensed bands
  2017-03-16 15:13 [PATCH 0/3] Channels in licensed bands, noise floor override Simon Wunderlich
  2017-03-16 15:13 ` [PATCH 1/3] ath9k: Support channels in licensed bands Simon Wunderlich
@ 2017-03-16 15:13 ` Simon Wunderlich
  2017-03-17 18:49   ` Sebastian Gottschall
  2017-03-16 15:13 ` [PATCH 3/3] ath9k: add noise floor override option Simon Wunderlich
  2 siblings, 1 reply; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-16 15:13 UTC (permalink / raw)
  To: ath10k, ath9k-devel; +Cc: Mathias Kretschmer, linux-wireless, Simon Wunderlich

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!

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
---
 drivers/net/wireless/ath/ath10k/Kconfig | 20 ++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/core.h  |  4 ++++
 drivers/net/wireless/ath/ath10k/mac.c   |  9 +++++++++
 drivers/net/wireless/ath/ath10k/wmi.c   |  7 +++++--
 4 files changed, 38 insertions(+), 2 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 a25f0ec15cf8..23895af0fc63 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -7669,6 +7669,15 @@ 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..de7a4fa9d347 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -2323,10 +2323,13 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
 	/* 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.
+	 *
+	 * On the other hand, channel 8, 12 and 16 are defined in 5GHz as well
+	 * (5040 - 5080 MHz), therefore apply the override only for channels <=7
 	 */
-	if (channel >= 1 && channel <= 14) {
+	if (channel >= 1 && channel <= 7) {
 		status->band = NL80211_BAND_2GHZ;
-	} else if (channel >= 36 && channel <= 169) {
+	} else if (channel >= 8 && channel <= 196) {
 		status->band = NL80211_BAND_5GHZ;
 	} else {
 		/* Shouldn't happen unless list of advertised channels to
-- 
2.11.0


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/3] ath9k: add noise floor override option
  2017-03-16 15:13 [PATCH 0/3] Channels in licensed bands, noise floor override Simon Wunderlich
  2017-03-16 15:13 ` [PATCH 1/3] ath9k: Support channels in licensed bands Simon Wunderlich
  2017-03-16 15:13 ` [PATCH 2/3] ath10k: add support for " Simon Wunderlich
@ 2017-03-16 15:13 ` Simon Wunderlich
  2017-03-17  8:48   ` Janusz Dziedzic
  2 siblings, 1 reply; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-16 15:13 UTC (permalink / raw)
  To: ath10k, ath9k-devel; +Cc: Mathias Kretschmer, linux-wireless, Simon Wunderlich

Introduce a debugfs option to manually override the noise floor,
ignoring the automatically tuned noise floor of the driver/hw.

In my tests with a AR9580 based module and a tx99 5 MHz interferer,
I could tune the noisefloor to -95 dBm or above to allow communication
again. The automatic noise floor calibration sometimes could adapt to
the situation as well, but not reliably and permanently.

I would consider this "feature" experimental and interesting for people
debugging the noise floor calibration or other effects of the hardware.

Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
---
 drivers/net/wireless/ath/ath9k/calib.c |  5 ++-
 drivers/net/wireless/ath/ath9k/debug.c | 62 ++++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h    |  1 +
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 0f71146b781d..13ab6bc46775 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -254,7 +254,9 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
 			if ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(chan))
 				continue;
 
-			if (h)
+			if (ah->nf_override)
+				nfval = ah->nf_override;
+			else if (h)
 				nfval = h[i].privNF;
 			else
 				nfval = default_nf;
@@ -348,6 +350,7 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
 
 	return 0;
 }
+EXPORT_SYMBOL(ath9k_hw_loadnf);
 
 
 static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 43930c336987..2e64977a8ab6 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1191,6 +1191,65 @@ static const struct file_operations fops_tpc = {
 	.llseek = default_llseek,
 };
 
+static ssize_t read_file_nf_override(struct file *file,
+				     char __user *user_buf,
+				     size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_hw *ah = sc->sc_ah;
+	char buf[32];
+	unsigned int len;
+
+	if (ah->nf_override == 0)
+		len = sprintf(buf, "off\n");
+	else
+		len = sprintf(buf, "%d\n", ah->nf_override);
+
+	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+static ssize_t write_file_nf_override(struct file *file,
+				      const char __user *user_buf,
+				      size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_hw *ah = sc->sc_ah;
+	long val;
+	char buf[32];
+	ssize_t len;
+
+	len = min(count, sizeof(buf) - 1);
+	if (copy_from_user(buf, user_buf, len))
+		return -EFAULT;
+
+	buf[len] = '\0';
+	if (strncmp("off", buf, 3) == 0)
+		val = 0;
+	else if (kstrtol(buf, 0, &val))
+		return -EINVAL;
+
+	if (val > 0)
+		return -EINVAL;
+
+	if (val < -120)
+		return -EINVAL;
+
+	ah->nf_override = val;
+
+	if (ah->curchan)
+		ath9k_hw_loadnf(ah, ah->curchan);
+
+	return count;
+}
+
+static const struct file_operations fops_nf_override = {
+	.read = read_file_nf_override,
+	.write = write_file_nf_override,
+	.open = simple_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 /* Ethtool support for get-stats */
 
 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
@@ -1402,5 +1461,8 @@ int ath9k_init_debug(struct ath_hw *ah)
 	debugfs_create_u16("airtime_flags", S_IRUSR | S_IWUSR,
 			   sc->debug.debugfs_phy, &sc->airtime_flags);
 
+	debugfs_create_file("nf_override", S_IRUSR | S_IWUSR,
+			    sc->debug.debugfs_phy, sc, &fops_nf_override);
+
 	return 0;
 }
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 496e3cd1b509..eba478f052b9 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -803,6 +803,7 @@ struct ath_hw {
 	u32 rfkill_gpio;
 	u32 rfkill_polarity;
 	u32 ah_flags;
+	s16 nf_override;
 
 	bool reset_power_on;
 	bool htc_reset_init;
-- 
2.11.0


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] ath9k: add noise floor override option
  2017-03-16 15:13 ` [PATCH 3/3] ath9k: add noise floor override option Simon Wunderlich
@ 2017-03-17  8:48   ` Janusz Dziedzic
  2017-03-17  8:55     ` Simon Wunderlich
  0 siblings, 1 reply; 12+ messages in thread
From: Janusz Dziedzic @ 2017-03-17  8:48 UTC (permalink / raw)
  To: Simon Wunderlich; +Cc: Mathias Kretschmer, linux-wireless, ath9k-devel, ath10k

On 16 March 2017 at 16:13, Simon Wunderlich <sw@simonwunderlich.de> wrote:
> Introduce a debugfs option to manually override the noise floor,
> ignoring the automatically tuned noise floor of the driver/hw.
>
> In my tests with a AR9580 based module and a tx99 5 MHz interferer,
> I could tune the noisefloor to -95 dBm or above to allow communication
> again. The automatic noise floor calibration sometimes could adapt to
> the situation as well, but not reliably and permanently.
>
> I would consider this "feature" experimental and interesting for people
> debugging the noise floor calibration or other effects of the hardware.
>
> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
> ---
>  drivers/net/wireless/ath/ath9k/calib.c |  5 ++-
>  drivers/net/wireless/ath/ath9k/debug.c | 62 ++++++++++++++++++++++++++++++++++
>  drivers/net/wireless/ath/ath9k/hw.h    |  1 +
>  3 files changed, 67 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
> index 0f71146b781d..13ab6bc46775 100644
> --- a/drivers/net/wireless/ath/ath9k/calib.c
> +++ b/drivers/net/wireless/ath/ath9k/calib.c
> @@ -254,7 +254,9 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
>                         if ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(chan))
>                                 continue;
>
> -                       if (h)
> +                       if (ah->nf_override)
> +                               nfval = ah->nf_override;
> +                       else if (h)
>                                 nfval = h[i].privNF;
>                         else
>                                 nfval = default_nf;
> @@ -348,6 +350,7 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
>
>         return 0;
>  }
> +EXPORT_SYMBOL(ath9k_hw_loadnf);
>
>
>  static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
> diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
> index 43930c336987..2e64977a8ab6 100644
> --- a/drivers/net/wireless/ath/ath9k/debug.c
> +++ b/drivers/net/wireless/ath/ath9k/debug.c
> @@ -1191,6 +1191,65 @@ static const struct file_operations fops_tpc = {
>         .llseek = default_llseek,
>  };
>
> +static ssize_t read_file_nf_override(struct file *file,
> +                                    char __user *user_buf,
> +                                    size_t count, loff_t *ppos)
> +{
> +       struct ath_softc *sc = file->private_data;
> +       struct ath_hw *ah = sc->sc_ah;
> +       char buf[32];
> +       unsigned int len;
> +
> +       if (ah->nf_override == 0)
> +               len = sprintf(buf, "off\n");
> +       else
> +               len = sprintf(buf, "%d\n", ah->nf_override);
> +
> +       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
> +}
> +
> +static ssize_t write_file_nf_override(struct file *file,
> +                                     const char __user *user_buf,
> +                                     size_t count, loff_t *ppos)
> +{
> +       struct ath_softc *sc = file->private_data;
> +       struct ath_hw *ah = sc->sc_ah;
> +       long val;
> +       char buf[32];
> +       ssize_t len;
> +
> +       len = min(count, sizeof(buf) - 1);
> +       if (copy_from_user(buf, user_buf, len))
> +               return -EFAULT;
> +
> +       buf[len] = '\0';
> +       if (strncmp("off", buf, 3) == 0)
> +               val = 0;
> +       else if (kstrtol(buf, 0, &val))
> +               return -EINVAL;
> +
> +       if (val > 0)
> +               return -EINVAL;
> +
> +       if (val < -120)
> +               return -EINVAL;
> +
> +       ah->nf_override = val;
> +
> +       if (ah->curchan)
> +               ath9k_hw_loadnf(ah, ah->curchan);
> +
> +       return count;
> +}
> +
> +static const struct file_operations fops_nf_override = {
> +       .read = read_file_nf_override,
> +       .write = write_file_nf_override,
> +       .open = simple_open,
> +       .owner = THIS_MODULE,
> +       .llseek = default_llseek,
> +};
> +
>  /* Ethtool support for get-stats */
>
>  #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
> @@ -1402,5 +1461,8 @@ int ath9k_init_debug(struct ath_hw *ah)
>         debugfs_create_u16("airtime_flags", S_IRUSR | S_IWUSR,
>                            sc->debug.debugfs_phy, &sc->airtime_flags);
>
> +       debugfs_create_file("nf_override", S_IRUSR | S_IWUSR,
> +                           sc->debug.debugfs_phy, sc, &fops_nf_override);
> +

Why not simply:
        debugfs_create_u32("nf_override", S_IRUSR|S_IWUSR ,
sc->debug.debugfs_phy,
                          &ah->nf_override);

One line patch :)

>         return 0;
>  }
> diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
> index 496e3cd1b509..eba478f052b9 100644
> --- a/drivers/net/wireless/ath/ath9k/hw.h
> +++ b/drivers/net/wireless/ath/ath9k/hw.h
> @@ -803,6 +803,7 @@ struct ath_hw {
>         u32 rfkill_gpio;
>         u32 rfkill_polarity;
>         u32 ah_flags;
> +       s16 nf_override;
>
>         bool reset_power_on;
>         bool htc_reset_init;
> --
> 2.11.0
>
>
> _______________________________________________
> ath10k mailing list
> ath10k@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/ath10k

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] ath9k: add noise floor override option
  2017-03-17  8:48   ` Janusz Dziedzic
@ 2017-03-17  8:55     ` Simon Wunderlich
  2017-03-17 12:44       ` Janusz Dziedzic
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-17  8:55 UTC (permalink / raw)
  To: Janusz Dziedzic; +Cc: Mathias Kretschmer, linux-wireless, ath9k-devel, ath10k

[-- Attachment #1.1: Type: text/plain, Size: 5715 bytes --]

On Friday, March 17, 2017 9:48:07 AM CET Janusz Dziedzic wrote:
> On 16 March 2017 at 16:13, Simon Wunderlich <sw@simonwunderlich.de> wrote:
> > Introduce a debugfs option to manually override the noise floor,
> > ignoring the automatically tuned noise floor of the driver/hw.
> > 
> > In my tests with a AR9580 based module and a tx99 5 MHz interferer,
> > I could tune the noisefloor to -95 dBm or above to allow communication
> > again. The automatic noise floor calibration sometimes could adapt to
> > the situation as well, but not reliably and permanently.
> > 
> > I would consider this "feature" experimental and interesting for people
> > debugging the noise floor calibration or other effects of the hardware.
> > 
> > Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
> > Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
> > ---
> > 
> >  drivers/net/wireless/ath/ath9k/calib.c |  5 ++-
> >  drivers/net/wireless/ath/ath9k/debug.c | 62
> >  ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h  
> >   |  1 +
> >  3 files changed, 67 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/wireless/ath/ath9k/calib.c
> > b/drivers/net/wireless/ath/ath9k/calib.c index 0f71146b781d..13ab6bc46775
> > 100644
> > --- a/drivers/net/wireless/ath/ath9k/calib.c
> > +++ b/drivers/net/wireless/ath/ath9k/calib.c
> > @@ -254,7 +254,9 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct
> > ath9k_channel *chan)> 
> >                         if ((i >= AR5416_MAX_CHAINS) &&
> >                         !IS_CHAN_HT40(chan))
> >                         
> >                                 continue;
> > 
> > -                       if (h)
> > +                       if (ah->nf_override)
> > +                               nfval = ah->nf_override;
> > +                       else if (h)
> > 
> >                                 nfval = h[i].privNF;
> >                         
> >                         else
> >                         
> >                                 nfval = default_nf;
> > 
> > @@ -348,6 +350,7 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct
> > ath9k_channel *chan)> 
> >         return 0;
> >  
> >  }
> > 
> > +EXPORT_SYMBOL(ath9k_hw_loadnf);
> > 
> >  static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
> > 
> > diff --git a/drivers/net/wireless/ath/ath9k/debug.c
> > b/drivers/net/wireless/ath/ath9k/debug.c index 43930c336987..2e64977a8ab6
> > 100644
> > --- a/drivers/net/wireless/ath/ath9k/debug.c
> > +++ b/drivers/net/wireless/ath/ath9k/debug.c
> > @@ -1191,6 +1191,65 @@ static const struct file_operations fops_tpc = {
> > 
> >         .llseek = default_llseek,
> >  
> >  };
> > 
> > +static ssize_t read_file_nf_override(struct file *file,
> > +                                    char __user *user_buf,
> > +                                    size_t count, loff_t *ppos)
> > +{
> > +       struct ath_softc *sc = file->private_data;
> > +       struct ath_hw *ah = sc->sc_ah;
> > +       char buf[32];
> > +       unsigned int len;
> > +
> > +       if (ah->nf_override == 0)
> > +               len = sprintf(buf, "off\n");
> > +       else
> > +               len = sprintf(buf, "%d\n", ah->nf_override);
> > +
> > +       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
> > +}
> > +
> > +static ssize_t write_file_nf_override(struct file *file,
> > +                                     const char __user *user_buf,
> > +                                     size_t count, loff_t *ppos)
> > +{
> > +       struct ath_softc *sc = file->private_data;
> > +       struct ath_hw *ah = sc->sc_ah;
> > +       long val;
> > +       char buf[32];
> > +       ssize_t len;
> > +
> > +       len = min(count, sizeof(buf) - 1);
> > +       if (copy_from_user(buf, user_buf, len))
> > +               return -EFAULT;
> > +
> > +       buf[len] = '\0';
> > +       if (strncmp("off", buf, 3) == 0)
> > +               val = 0;
> > +       else if (kstrtol(buf, 0, &val))
> > +               return -EINVAL;
> > +
> > +       if (val > 0)
> > +               return -EINVAL;
> > +
> > +       if (val < -120)
> > +               return -EINVAL;
> > +
> > +       ah->nf_override = val;
> > +
> > +       if (ah->curchan)
> > +               ath9k_hw_loadnf(ah, ah->curchan);
> > +
> > +       return count;
> > +}
> > +
> > +static const struct file_operations fops_nf_override = {
> > +       .read = read_file_nf_override,
> > +       .write = write_file_nf_override,
> > +       .open = simple_open,
> > +       .owner = THIS_MODULE,
> > +       .llseek = default_llseek,
> > +};
> > +
> > 
> >  /* Ethtool support for get-stats */
> >  
> >  #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
> > 
> > @@ -1402,5 +1461,8 @@ int ath9k_init_debug(struct ath_hw *ah)
> > 
> >         debugfs_create_u16("airtime_flags", S_IRUSR | S_IWUSR,
> >         
> >                            sc->debug.debugfs_phy, &sc->airtime_flags);
> > 
> > +       debugfs_create_file("nf_override", S_IRUSR | S_IWUSR,
> > +                           sc->debug.debugfs_phy, sc, &fops_nf_override);
> > +
> 
> Why not simply:
>         debugfs_create_u32("nf_override", S_IRUSR|S_IWUSR ,
> sc->debug.debugfs_phy,
>                           &ah->nf_override);
> 
> One line patch :)

Thanks Janusz, good idea! That doesn't check the limits, which is probably not 
a big deal anyway. What bothers me more is that it doesn't update the noise 
floor immediately (ath9k_hw_loadnf()), which would be nice to have. Otherwise 
you have to wait up to ~30 seconds or so until the noise floor is updated next 
time. So I'd keep my variant for now, unless you have a good idea to fix the 
latter. :)

Cheers,
      Simon

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 146 bytes --]

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] ath9k: add noise floor override option
  2017-03-17  8:55     ` Simon Wunderlich
@ 2017-03-17 12:44       ` Janusz Dziedzic
  0 siblings, 0 replies; 12+ messages in thread
From: Janusz Dziedzic @ 2017-03-17 12:44 UTC (permalink / raw)
  To: Simon Wunderlich; +Cc: Mathias Kretschmer, linux-wireless, ath9k-devel, ath10k

On 17 March 2017 at 09:55, Simon Wunderlich <sw@simonwunderlich.de> wrote:
> On Friday, March 17, 2017 9:48:07 AM CET Janusz Dziedzic wrote:
>> On 16 March 2017 at 16:13, Simon Wunderlich <sw@simonwunderlich.de> wrote:
>> > Introduce a debugfs option to manually override the noise floor,
>> > ignoring the automatically tuned noise floor of the driver/hw.
>> >
>> > In my tests with a AR9580 based module and a tx99 5 MHz interferer,
>> > I could tune the noisefloor to -95 dBm or above to allow communication
>> > again. The automatic noise floor calibration sometimes could adapt to
>> > the situation as well, but not reliably and permanently.
>> >
>> > I would consider this "feature" experimental and interesting for people
>> > debugging the noise floor calibration or other effects of the hardware.
>> >
>> > Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
>> > Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
>> > ---
>> >
>> >  drivers/net/wireless/ath/ath9k/calib.c |  5 ++-
>> >  drivers/net/wireless/ath/ath9k/debug.c | 62
>> >  ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h
>> >   |  1 +
>> >  3 files changed, 67 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/net/wireless/ath/ath9k/calib.c
>> > b/drivers/net/wireless/ath/ath9k/calib.c index 0f71146b781d..13ab6bc46775
>> > 100644
>> > --- a/drivers/net/wireless/ath/ath9k/calib.c
>> > +++ b/drivers/net/wireless/ath/ath9k/calib.c
>> > @@ -254,7 +254,9 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct
>> > ath9k_channel *chan)>
>> >                         if ((i >= AR5416_MAX_CHAINS) &&
>> >                         !IS_CHAN_HT40(chan))
>> >
>> >                                 continue;
>> >
>> > -                       if (h)
>> > +                       if (ah->nf_override)
>> > +                               nfval = ah->nf_override;
>> > +                       else if (h)
>> >
>> >                                 nfval = h[i].privNF;
>> >
>> >                         else
>> >
>> >                                 nfval = default_nf;
>> >
>> > @@ -348,6 +350,7 @@ int ath9k_hw_loadnf(struct ath_hw *ah, struct
>> > ath9k_channel *chan)>
>> >         return 0;
>> >
>> >  }
>> >
>> > +EXPORT_SYMBOL(ath9k_hw_loadnf);
>> >
>> >  static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
>> >
>> > diff --git a/drivers/net/wireless/ath/ath9k/debug.c
>> > b/drivers/net/wireless/ath/ath9k/debug.c index 43930c336987..2e64977a8ab6
>> > 100644
>> > --- a/drivers/net/wireless/ath/ath9k/debug.c
>> > +++ b/drivers/net/wireless/ath/ath9k/debug.c
>> > @@ -1191,6 +1191,65 @@ static const struct file_operations fops_tpc = {
>> >
>> >         .llseek = default_llseek,
>> >
>> >  };
>> >
>> > +static ssize_t read_file_nf_override(struct file *file,
>> > +                                    char __user *user_buf,
>> > +                                    size_t count, loff_t *ppos)
>> > +{
>> > +       struct ath_softc *sc = file->private_data;
>> > +       struct ath_hw *ah = sc->sc_ah;
>> > +       char buf[32];
>> > +       unsigned int len;
>> > +
>> > +       if (ah->nf_override == 0)
>> > +               len = sprintf(buf, "off\n");
>> > +       else
>> > +               len = sprintf(buf, "%d\n", ah->nf_override);
>> > +
>> > +       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
>> > +}
>> > +
>> > +static ssize_t write_file_nf_override(struct file *file,
>> > +                                     const char __user *user_buf,
>> > +                                     size_t count, loff_t *ppos)
>> > +{
>> > +       struct ath_softc *sc = file->private_data;
>> > +       struct ath_hw *ah = sc->sc_ah;
>> > +       long val;
>> > +       char buf[32];
>> > +       ssize_t len;
>> > +
>> > +       len = min(count, sizeof(buf) - 1);
>> > +       if (copy_from_user(buf, user_buf, len))
>> > +               return -EFAULT;
>> > +
>> > +       buf[len] = '\0';
>> > +       if (strncmp("off", buf, 3) == 0)
>> > +               val = 0;
>> > +       else if (kstrtol(buf, 0, &val))
>> > +               return -EINVAL;
>> > +
>> > +       if (val > 0)
>> > +               return -EINVAL;
>> > +
>> > +       if (val < -120)
>> > +               return -EINVAL;
>> > +
>> > +       ah->nf_override = val;
>> > +
>> > +       if (ah->curchan)
>> > +               ath9k_hw_loadnf(ah, ah->curchan);
>> > +
>> > +       return count;
>> > +}
>> > +
>> > +static const struct file_operations fops_nf_override = {
>> > +       .read = read_file_nf_override,
>> > +       .write = write_file_nf_override,
>> > +       .open = simple_open,
>> > +       .owner = THIS_MODULE,
>> > +       .llseek = default_llseek,
>> > +};
>> > +
>> >
>> >  /* Ethtool support for get-stats */
>> >
>> >  #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
>> >
>> > @@ -1402,5 +1461,8 @@ int ath9k_init_debug(struct ath_hw *ah)
>> >
>> >         debugfs_create_u16("airtime_flags", S_IRUSR | S_IWUSR,
>> >
>> >                            sc->debug.debugfs_phy, &sc->airtime_flags);
>> >
>> > +       debugfs_create_file("nf_override", S_IRUSR | S_IWUSR,
>> > +                           sc->debug.debugfs_phy, sc, &fops_nf_override);
>> > +
>>
>> Why not simply:
>>         debugfs_create_u32("nf_override", S_IRUSR|S_IWUSR ,
>> sc->debug.debugfs_phy,
>>                           &ah->nf_override);
>>
>> One line patch :)
>
> Thanks Janusz, good idea! That doesn't check the limits, which is probably not
> a big deal anyway. What bothers me more is that it doesn't update the noise
> floor immediately (ath9k_hw_loadnf()), which would be nice to have. Otherwise
> you have to wait up to ~30 seconds or so until the noise floor is updated next
> time. So I'd keep my variant for now, unless you have a good idea to fix the
> latter. :)
>
I see, seems I miss ath9k_hw_loadnf() call :)

> Cheers,
>       Simon

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] ath9k: Support channels in licensed bands
  2017-03-16 15:13 ` [PATCH 1/3] ath9k: Support channels in licensed bands Simon Wunderlich
@ 2017-03-17 13:40   ` Zefir Kurtisi
  2017-03-17 14:02     ` Simon Wunderlich
  2017-03-17 16:00     ` [PATCHv2 " Simon Wunderlich
  0 siblings, 2 replies; 12+ messages in thread
From: Zefir Kurtisi @ 2017-03-17 13:40 UTC (permalink / raw)
  To: Simon Wunderlich, ath10k, ath9k-devel
  Cc: Julian Calaby, Ben Greear, Mathias Kretschmer, linux-wireless

On 03/16/2017 04:13 PM, Simon Wunderlich wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> 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!
> 
> Signed-off-by: Ben Greear <greearb@candelatech.com>
> [Hide this support behind a Kconfig option]
> Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
> [only use the 20 mhz channels, add 5 ghz, change to 4.9ghz to licensed bands]
> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
> ---
>  drivers/net/wireless/ath/ath9k/Kconfig       | 20 ++++++++++++++++
>  drivers/net/wireless/ath/ath9k/ath9k.h       |  2 +-
>  drivers/net/wireless/ath/ath9k/common-init.c | 35 +++++++++++++++++++++-------
>  drivers/net/wireless/ath/ath9k/hw.h          |  4 ++--
>  4 files changed, 50 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
> index 783a38f1a626..23b8abf4449a 100644
> --- a/drivers/net/wireless/ath/ath9k/Kconfig
> +++ b/drivers/net/wireless/ath/ath9k/Kconfig
> @@ -116,6 +116,26 @@ config ATH9K_DFS_CERTIFIED
>  	  developed. At this point enabling this option won't do anything
>  	  except increase code size.
>  
> +config ATH9K_LICENSED_CHAN
> +	bool "Support channels in licensed bands"
> +	depends on ATH9K && 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.
> +
>  config ATH9K_DYNACK
>  	bool "Atheros ath9k ACK timeout estimation algorithm (EXPERIMENTAL)"
>  	depends on ATH9K
> diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
> index cf076719c27e..d215c3f968d4 100644
> --- a/drivers/net/wireless/ath/ath9k/ath9k.h
> +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
> @@ -996,7 +996,7 @@ struct ath_softc {
>  	struct device *dev;
>  
>  	struct survey_info *cur_survey;
> -	struct survey_info survey[ATH9K_NUM_CHANNELS];
> +	struct survey_info survey[ATH9K_MAX_NUM_CHANNELS];
>  
>  	spinlock_t intr_lock;
>  	struct tasklet_struct intr_tq;
> diff --git a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
> index 8b4f7fdabf58..0d632c22bc16 100644
> --- a/drivers/net/wireless/ath/ath9k/common-init.c
> +++ b/drivers/net/wireless/ath/ath9k/common-init.c
> @@ -86,6 +86,22 @@ static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
>  	CHAN5G(5785, 35), /* Channel 157 */
>  	CHAN5G(5805, 36), /* Channel 161 */
>  	CHAN5G(5825, 37), /* Channel 165 */
> +
> +#ifdef CONFIG_ATH9K_LICENSED_CHAN
> +	/* 4.9Ghz channels, public safety channels, license is required in US
> +	 * and most other regulatory domains!
> +	 */
> +	/* 802.11j 4.9 GHz (20 MHz) */
> +	CHAN5G(4920, 38), /* channel 184 */
> +	CHAN5G(4940, 39), /* channel 188 */
> +	CHAN5G(4960, 40), /* channel 192 */
> +	CHAN5G(4980, 41), /* channel 196 */
> +	/* 802.11j 5.030 - 5.080 GHz (20 MHz) */
> +	CHAN5G(5040, 42), /* channel 8 */
> +	CHAN5G(5060, 43), /* channel 12 */
> +	CHAN5G(5080, 44), /* channel 16 */
> +#endif
> +#define ATH9K_NUM_LICENSED_CHANNELS 7
>  };
>  
>  /* Atheros hardware rate code addition for short premble */
> @@ -126,10 +142,14 @@ int ath9k_cmn_init_channels_rates(struct ath_common *common)
>  {
>  	struct ath_hw *ah = (struct ath_hw *)common->ah;
>  	void *channels;
> +	int num_5ghz_chan = ARRAY_SIZE(ath9k_5ghz_chantable);
> +
> +	if (!IS_ENABLED(CONFIG_ATH9K_LICENSED_CHAN))
> +		num_5ghz_chan -= ATH9K_NUM_LICENSED_CHANNELS;
These two lines seem wrong to me, since the extra channels are only added to the
list if CONFIG_ATH9K_LICENSED_CHAN is defined. If it is not, this cuts off the
last 7 regular channels, no?

Cheers,
Zefir


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] ath9k: Support channels in licensed bands
  2017-03-17 13:40   ` Zefir Kurtisi
@ 2017-03-17 14:02     ` Simon Wunderlich
  2017-03-17 16:00     ` [PATCHv2 " Simon Wunderlich
  1 sibling, 0 replies; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-17 14:02 UTC (permalink / raw)
  To: Zefir Kurtisi
  Cc: Julian Calaby, linux-wireless, ath9k-devel, ath10k, Ben Greear,
	Mathias Kretschmer

[-- Attachment #1.1: Type: text/plain, Size: 799 bytes --]

On Friday, March 17, 2017 2:40:50 PM CET Zefir Kurtisi wrote:
> On 03/16/2017 04:13 PM, Simon Wunderlich wrote:
> > @@ -126,10 +142,14 @@ int ath9k_cmn_init_channels_rates(struct ath_common
> > *common)> 
> >  {
> >  
> >  	struct ath_hw *ah = (struct ath_hw *)common->ah;
> >  	void *channels;
> > 
> > +	int num_5ghz_chan = ARRAY_SIZE(ath9k_5ghz_chantable);
> > +
> > +	if (!IS_ENABLED(CONFIG_ATH9K_LICENSED_CHAN))
> > +		num_5ghz_chan -= ATH9K_NUM_LICENSED_CHANNELS;
> 
> These two lines seem wrong to me, since the extra channels are only added to
> the list if CONFIG_ATH9K_LICENSED_CHAN is defined. If it is not, this cuts
> off the last 7 regular channels, no?

Oh, I think you are right!

I'll revise this part and re-send. Seems I can just get rid of those two lines 
...

Cheers,
    Simon

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 146 bytes --]

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCHv2 1/3] ath9k: Support channels in licensed bands
  2017-03-17 13:40   ` Zefir Kurtisi
  2017-03-17 14:02     ` Simon Wunderlich
@ 2017-03-17 16:00     ` Simon Wunderlich
  1 sibling, 0 replies; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-17 16:00 UTC (permalink / raw)
  To: ath10k, ath9k-devel
  Cc: Julian Calaby, Ben Greear, Mathias Kretschmer, linux-wireless,
	Simon Wunderlich

From: Ben Greear <greearb@candelatech.com>

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!

Signed-off-by: Ben Greear <greearb@candelatech.com>
[Hide this support behind a Kconfig option]
Signed-off-by: Julian Calaby <julian.calaby@gmail.com>
[only use the 20 mhz channels, add 5 ghz, change to 4.9ghz to licensed bands, simplify]
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
---
Changes to PATCHv1:
 * fix bug reported by Zefir, and simplify patch more
---
 drivers/net/wireless/ath/ath9k/Kconfig       | 20 ++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common-init.c | 15 +++++++++++++++
 drivers/net/wireless/ath/ath9k/hw.h          |  4 ++++
 3 files changed, 39 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 783a38f1a626..23b8abf4449a 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -116,6 +116,26 @@ config ATH9K_DFS_CERTIFIED
 	  developed. At this point enabling this option won't do anything
 	  except increase code size.
 
+config ATH9K_LICENSED_CHAN
+	bool "Support channels in licensed bands"
+	depends on ATH9K && 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.
+
 config ATH9K_DYNACK
 	bool "Atheros ath9k ACK timeout estimation algorithm (EXPERIMENTAL)"
 	depends on ATH9K
diff --git a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
index 8b4f7fdabf58..3d65dce13048 100644
--- a/drivers/net/wireless/ath/ath9k/common-init.c
+++ b/drivers/net/wireless/ath/ath9k/common-init.c
@@ -86,6 +86,21 @@ static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
 	CHAN5G(5785, 35), /* Channel 157 */
 	CHAN5G(5805, 36), /* Channel 161 */
 	CHAN5G(5825, 37), /* Channel 165 */
+
+#ifdef CONFIG_ATH9K_LICENSED_CHAN
+	/* 4.9Ghz channels, public safety channels, license is required in US
+	 * and most other regulatory domains!
+	 */
+	/* 802.11j 4.9 GHz (20 MHz) */
+	CHAN5G(4920, 38), /* channel 184 */
+	CHAN5G(4940, 39), /* channel 188 */
+	CHAN5G(4960, 40), /* channel 192 */
+	CHAN5G(4980, 41), /* channel 196 */
+	/* 802.11j 5.030 - 5.080 GHz (20 MHz) */
+	CHAN5G(5040, 42), /* channel 8 */
+	CHAN5G(5060, 43), /* channel 12 */
+	CHAN5G(5080, 44), /* channel 16 */
+#endif
 };
 
 /* Atheros hardware rate code addition for short premble */
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 9cbca1229bac..2166f644599d 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -73,7 +73,11 @@
 
 #define ATH9K_RSSI_BAD			-128
 
+#ifdef CONFIG_ATH9K_LICENSED_CHAN
+#define ATH9K_NUM_CHANNELS	45
+#else
 #define ATH9K_NUM_CHANNELS	38
+#endif
 
 /* Register read/write primitives */
 #define REG_WRITE(_ah, _reg, _val) \
-- 
2.11.0


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] ath10k: add support for channels in licensed bands
  2017-03-16 15:13 ` [PATCH 2/3] ath10k: add support for " Simon Wunderlich
@ 2017-03-17 18:49   ` Sebastian Gottschall
  2017-03-23  9:00     ` Simon Wunderlich
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastian Gottschall @ 2017-03-17 18:49 UTC (permalink / raw)
  To: Simon Wunderlich, ath10k, ath9k-devel; +Cc: Mathias Kretschmer, linux-wireless

you may quickly realize that this patch cannot be a solution
example:

-	if (channel >= 1 && channel <= 14) {
+	if (channel >= 1 && channel <= 7) {
  		status->band = NL80211_BAND_2GHZ;


do you you really want to limit the 2.4 channels for all users?


Am 16.03.2017 um 16:13 schrieb Simon Wunderlich:
> 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!
>
> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fit.fraunhofer.de>
> ---
>   drivers/net/wireless/ath/ath10k/Kconfig | 20 ++++++++++++++++++++
>   drivers/net/wireless/ath/ath10k/core.h  |  4 ++++
>   drivers/net/wireless/ath/ath10k/mac.c   |  9 +++++++++
>   drivers/net/wireless/ath/ath10k/wmi.c   |  7 +++++--
>   4 files changed, 38 insertions(+), 2 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 a25f0ec15cf8..23895af0fc63 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -7669,6 +7669,15 @@ 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..de7a4fa9d347 100644
> --- a/drivers/net/wireless/ath/ath10k/wmi.c
> +++ b/drivers/net/wireless/ath/ath10k/wmi.c
> @@ -2323,10 +2323,13 @@ int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
>   	/* 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.
> +	 *
> +	 * On the other hand, channel 8, 12 and 16 are defined in 5GHz as well
> +	 * (5040 - 5080 MHz), therefore apply the override only for channels <=7
>   	 */
> -	if (channel >= 1 && channel <= 14) {
> +	if (channel >= 1 && channel <= 7) {
>   		status->band = NL80211_BAND_2GHZ;
> -	} else if (channel >= 36 && channel <= 169) {
> +	} else if (channel >= 8 && channel <= 196) {
>   		status->band = NL80211_BAND_5GHZ;
>   	} else {
>   		/* Shouldn't happen unless list of advertised channels to


-- 
Mit freundlichen Grüssen / Regards

Sebastian Gottschall / CTO

NewMedia-NET GmbH - DD-WRT
Firmensitz:  Berliner Ring 101, 64625 Bensheim
Registergericht: Amtsgericht Darmstadt, HRB 25473
Geschäftsführer: Peter Steinhäuser, Christian Scheele
http://www.dd-wrt.com
email: s.gottschall@dd-wrt.com
Tel.: +496251-582650 / Fax: +496251-5826565


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] ath10k: add support for channels in licensed bands
  2017-03-17 18:49   ` Sebastian Gottschall
@ 2017-03-23  9:00     ` Simon Wunderlich
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Wunderlich @ 2017-03-23  9:00 UTC (permalink / raw)
  To: ath10k
  Cc: Mathias Kretschmer, linux-wireless, ath9k-devel, Sebastian Gottschall

[-- Attachment #1.1: Type: text/plain, Size: 444 bytes --]

On Friday, March 17, 2017 7:49:55 PM CET Sebastian Gottschall wrote:
> you may quickly realize that this patch cannot be a solution
> example:
> 
> -	if (channel >= 1 && channel <= 14) {
> +	if (channel >= 1 && channel <= 7) {
>   		status->band = NL80211_BAND_2GHZ;
> 
> 
> do you you really want to limit the 2.4 channels for all users?

Hi Sebastian,

you are right, this seems to be too limiting. I'll rework this part.

Cheers,
     Simon

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 146 bytes --]

_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 15:13 [PATCH 0/3] Channels in licensed bands, noise floor override Simon Wunderlich
2017-03-16 15:13 ` [PATCH 1/3] ath9k: Support channels in licensed bands Simon Wunderlich
2017-03-17 13:40   ` Zefir Kurtisi
2017-03-17 14:02     ` Simon Wunderlich
2017-03-17 16:00     ` [PATCHv2 " Simon Wunderlich
2017-03-16 15:13 ` [PATCH 2/3] ath10k: add support for " Simon Wunderlich
2017-03-17 18:49   ` Sebastian Gottschall
2017-03-23  9:00     ` Simon Wunderlich
2017-03-16 15:13 ` [PATCH 3/3] ath9k: add noise floor override option Simon Wunderlich
2017-03-17  8:48   ` Janusz Dziedzic
2017-03-17  8:55     ` Simon Wunderlich
2017-03-17 12:44       ` Janusz Dziedzic

ATH10K Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/ath10k/0 ath10k/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ath10k ath10k/ https://lore.kernel.org/ath10k \
		ath10k@lists.infradead.org
	public-inbox-index ath10k

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.ath10k


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git