Skip to contentSkip to conversation

ath10k spectral scan support

PATCH In review Simon Wunderlich 3 participants 7 messages Aug 1, 2014 – Aug 5, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v5 cover ath10k spectral scan support

This is the fifth "PATCH" patchset iteration for the ath10k spectral scan feature. It includes a small change compared to Kalles PATCHv4
series: the parameter initialization has been moved to ath10k_spectral_start() so that the parameters also get reset when the firmware crashes.

To view the samples, please have a look at the fft_eval tool [1] which now supports both ath9k and ath10k formats.

The count issue is still open: Even when a count is specified, the hardware seems to send endless samples. It seems to work most of the time in VHT80 mode though, but in HT20 and HT40 the count value seems to be ignored. To reproduce this, start hostapd with the desired channel width and do:

echo 8 > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_count echo manual > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl echo trigger > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl cat /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan0 >> /tmp/fft.dump

Repeating the last line and checking the filesize will easily show whether ath10k still sends samples or not. We would expect 8 samples in this configuration.

Please see the patches for more information on the changes.

Cheers,
Simon

[1] https://github.com/simonwunderlich/FFT_eval

Simon Wunderlich (1):
ath10k: add spectral scan feature

Sven Eckelmann (1):
ath: Move spectral debugfs structs to shared header

 drivers/net/wireless/ath/ath10k/Kconfig    |   1 +
 drivers/net/wireless/ath/ath10k/Makefile   |   1 +
 drivers/net/wireless/ath/ath10k/core.c     |  10 +
 drivers/net/wireless/ath/ath10k/core.h     |  11 +
 drivers/net/wireless/ath/ath10k/mac.c      |   8 +
 drivers/net/wireless/ath/ath10k/spectral.c | 561 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/spectral.h |  90 +++++
 drivers/net/wireless/ath/ath10k/wmi.c      | 105 +++++-
 drivers/net/wireless/ath/ath10k/wmi.h      |  97 +++++
 drivers/net/wireless/ath/ath9k/spectral.h  |  71 +---
 drivers/net/wireless/ath/spectral_common.h | 113 ++++++
 11 files changed, 998 insertions(+), 70 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath10k/spectral.c
 create mode 100644 drivers/net/wireless/ath/ath10k/spectral.h
 create mode 100644 drivers/net/wireless/ath/spectral_common.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v5 1/2 ath: Move spectral debugfs structs to shared header

From: Sven Eckelmann <[email protected]>

The ath9k and ath10k will share the definitions of the debugfs spectral structures and enums. Having them in the same place helps to avoid conflicts.

---
 drivers/net/wireless/ath/ath9k/spectral.h  | 71 +-----------------------
 drivers/net/wireless/ath/spectral_common.h | 88 ++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 69 deletions(-)
 create mode 100644 drivers/net/wireless/ath/spectral_common.h
drivers/net/wireless/ath/ath9k/spectral.h +2 -69
index ead6341..7b410c6 100644
@@ -17,6 +17,8 @@
 #ifndef SPECTRAL_H
 #define SPECTRAL_H
 
+#include "../spectral_common.h"
+
 /* enum spectral_mode:
  *
  * @SPECTRAL_DISABLED: spectral mode is disabled
@@ -54,8 +56,6 @@ struct ath_ht20_mag_info {
 	u8 max_exp;
 } __packed;
 
-#define SPECTRAL_HT20_NUM_BINS		56
-
 /* WARNING: don't actually use this struct! MAC may vary the amount of
  * data by -1/+2. This struct is for reference only.
  */
@@ -83,8 +83,6 @@ struct ath_ht20_40_mag_info {
 	u8 max_exp;
 } __packed;
 
-#define SPECTRAL_HT20_40_NUM_BINS		128
-
 /* WARNING: don't actually use this struct! MAC may vary the amount of
  * data. This struct is for reference only.
  */
@@ -125,71 +123,6 @@ static inline u8 spectral_bitmap_weight(u8 *bins)
 	return bins[0] & 0x3f;
 }
 
-/* FFT sample format given to userspace via debugfs.
- *
- * Please keep the type/length at the front position and change
- * other fields after adding another sample type
- *
- * TODO: this might need rework when switching to nl80211-based
- * interface.
- */
-enum ath_fft_sample_type {
-	ATH_FFT_SAMPLE_HT20 = 1,
-	ATH_FFT_SAMPLE_HT20_40,
-};
-
-struct fft_sample_tlv {
-	u8 type;	/* see ath_fft_sample */
-	__be16 length;
-	/* type dependent data follows */
-} __packed;
-
-struct fft_sample_ht20 {
-	struct fft_sample_tlv tlv;
-
-	u8 max_exp;
-
-	__be16 freq;
-	s8 rssi;
-	s8 noise;
-
-	__be16 max_magnitude;
-	u8 max_index;
-	u8 bitmap_weight;
-
-	__be64 tsf;
-
-	u8 data[SPECTRAL_HT20_NUM_BINS];
-} __packed;
-
-struct fft_sample_ht20_40 {
-	struct fft_sample_tlv tlv;
-
-	u8 channel_type;
-	__be16 freq;
-
-	s8 lower_rssi;
-	s8 upper_rssi;
-
-	__be64 tsf;
-
-	s8 lower_noise;
-	s8 upper_noise;
-
-	__be16 lower_max_magnitude;
-	__be16 upper_max_magnitude;
-
-	u8 lower_max_index;
-	u8 upper_max_index;
-
-	u8 lower_bitmap_weight;
-	u8 upper_bitmap_weight;
-
-	u8 max_exp;
-
-	u8 data[SPECTRAL_HT20_40_NUM_BINS];
-} __packed;
-
 void ath9k_spectral_init_debug(struct ath_softc *sc);
 void ath9k_spectral_deinit_debug(struct ath_softc *sc);
 
drivers/net/wireless/ath/spectral_common.h new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v5 2/2 ath10k: add spectral scan feature

In reply to Simon Wunderlich

Adds the spectral scan feature for ath10k. The spectral scan is triggered by configuring a mode through a debugfs control file. Samples can be gathered via another relay debugfs file.

Essentially, to try it out:

ip link set dev wlan0 up
echo background > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl echo trigger > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl iw dev wlan0 scan
echo disable > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl cat /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan0 > samples

This feature is still experimental. Based on the original RFC patch of Sven Eckelmann.

---
PATCHv4:
siwu: move parameter initialization into spectral_start() to reset
parameters after firmware crash

PATCHv3:
kvalo: CPTCFG_ -> CONFIG_, rework how spectral.c is initialised

---
 drivers/net/wireless/ath/ath10k/Kconfig    |   1 +
 drivers/net/wireless/ath/ath10k/Makefile   |   1 +
 drivers/net/wireless/ath/ath10k/core.c     |  10 +
 drivers/net/wireless/ath/ath10k/core.h     |  11 +
 drivers/net/wireless/ath/ath10k/mac.c      |   8 +
 drivers/net/wireless/ath/ath10k/spectral.c | 561 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/spectral.h |  90 +++++
 drivers/net/wireless/ath/ath10k/wmi.c      | 105 +++++-
 drivers/net/wireless/ath/ath10k/wmi.h      |  97 +++++
 drivers/net/wireless/ath/spectral_common.h |  25 ++
 10 files changed, 908 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/ath/ath10k/spectral.c
 create mode 100644 drivers/net/wireless/ath/ath10k/spectral.h
drivers/net/wireless/ath/ath10k/Kconfig +1 -0
index a6f5285..1053bb5 100644
@@ -25,6 +25,7 @@ config ATH10K_DEBUG
 config ATH10K_DEBUGFS
 	bool "Atheros ath10k debugfs support"
 	depends on ATH10K
+	select RELAY
 	---help---
 	  Enabled debugfs support
 
drivers/net/wireless/ath/ath10k/Makefile +1 -0
index a4179f4..2cfb63c 100644
@@ -10,6 +10,7 @@ ath10k_core-y += mac.o \
 		 wmi.o \
 		 bmi.o
 
+ath10k_core-$(CONFIG_ATH10K_DEBUGFS) += spectral.o
 ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
 
 obj-$(CONFIG_ATH10K_PCI) += ath10k_pci.o
drivers/net/wireless/ath/ath10k/core.c +10 -0
index bef797d..440c3ff 100644
@@ -1000,9 +1000,17 @@ static void ath10k_core_register_work(struct work_struct *work)
 		goto err_unregister_mac;
 	}
 
+	status = ath10k_spectral_create(ar);
+	if (status) {
+		ath10k_err("failed to initialize spectral\n");
+		goto err_debug_destroy;
+	}
+
 	set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
 	return;
 
+err_debug_destroy:
+	ath10k_debug_destroy(ar);
 err_unregister_mac:
 	ath10k_mac_unregister(ar);
 err_release_fw:
@@ -1046,6 +1054,8 @@ void ath10k_core_unregister(struct ath10k *ar)
 
 	ath10k_core_free_firmware_files(ar);
 
+	ath10k_spectral_destroy(ar);
+
 	ath10k_debug_destroy(ar);
 }
 EXPORT_SYMBOL(ath10k_core_unregister);
drivers/net/wireless/ath/ath10k/core.h +11 -0
index ded3af2..d5c95d4 100644
@@ -31,6 +31,7 @@
 #include "../ath.h"
 #include "../regd.h"
 #include "../dfs_pattern_detector.h"
+#include "spectral.h"
 
 #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
 #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
@@ -237,6 +238,7 @@ struct ath10k_vif {
 
 	bool is_started;
 	bool is_up;
+	bool spectral_enabled;
 	u32 aid;
 	u8 bssid[ETH_ALEN];
 
@@ -499,6 +501,15 @@ struct ath10k {
 #ifdef CONFIG_ATH10K_DEBUGFS
 	struct ath10k_debug debug;
 #endif
+
+	struct {
+		/* relay(fs) channel for spectral scan */
+		struct rchan *rfs_chan_spec_scan;
+
+		/* spectral_mode and spec_config are protected by conf_mutex */
+		enum ath10k_spectral_mode mode;
+		struct ath10k_spec_scan config;
+	} spectral;
 };
 
 struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
drivers/net/wireless/ath/ath10k/mac.c +8 -0
index 9d61bb1..d14f142 100644
@@ -2485,6 +2485,8 @@ static int ath10k_start(struct ieee80211_hw *hw)
 	ar->num_started_vdevs = 0;
 	ath10k_regd_update(ar);
 
+	ath10k_spectral_start(ar);
+
 	mutex_unlock(&ar->conf_mutex);
 	return 0;
 
@@ -2892,8 +2894,14 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
 		dev_kfree_skb_any(arvif->beacon);
 		arvif->beacon = NULL;
 	}
+
 	spin_unlock_bh(&ar->data_lock);
 
+	ret = ath10k_spectral_vif_stop(arvif);
+	if (ret)
+		ath10k_warn("failed to stop spectral for vdev %i: %d\n",
+			    arvif->vdev_id, ret);
+
 	ar->free_vdev_map |= 1 << (arvif->vdev_id);
 	list_del(&arvif->list);
 
drivers/net/wireless/ath/ath10k/spectral.c new file +561 -0

561 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/spectral.h new file +90 -0

90 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi.c +104 -1

117 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi.h +97 -0

115 lines not on this page · raw message

drivers/net/wireless/ath/spectral_common.h +25 -0
index b9ab722..0d742ac 100644
@@ -20,6 +20,11 @@
 #define SPECTRAL_HT20_NUM_BINS		56
 #define SPECTRAL_HT20_40_NUM_BINS		128
 
+/* TODO: could possibly be 512, but no samples this large
+ * could be acquired so far.
+ */
+#define SPECTRAL_ATH10K_MAX_NUM_BINS		256
+
 /* FFT sample format given to userspace via debugfs.
  *
  * Please keep the type/length at the front position and change
@@ -31,6 +36,7 @@
 enum ath_fft_sample_type {
 	ATH_FFT_SAMPLE_HT20 = 1,
 	ATH_FFT_SAMPLE_HT20_40,
+	ATH_FFT_SAMPLE_ATH10K,
 };
 
 struct fft_sample_tlv {
@@ -85,4 +91,23 @@ struct fft_sample_ht20_40 {
 	u8 data[SPECTRAL_HT20_40_NUM_BINS];
 } __packed;
 
+struct fft_sample_ath10k {
+	struct fft_sample_tlv tlv;
+	u8 chan_width_mhz;
+	__be16 freq1;
+	__be16 freq2;
+	__be16 noise;
+	__be16 max_magnitude;
+	__be16 total_gain_db;
+	__be16 base_pwr_db;
+	__be64 tsf;
+	s8 max_index;
+	u8 rssi;
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;
+
 #endif /* SPECTRAL_COMMON_H */
Signature · 1 line
1.9.1
#3 lore raw
In reply to Simon Wunderlich
Quoted 29 lines · Simon Wunderlich

This is the fifth "PATCH" patchset iteration for the ath10k spectral scan feature. It includes a small change compared to Kalles PATCHv4
series: the parameter initialization has been moved to ath10k_spectral_start() so that the parameters also get reset when the firmware crashes.

To view the samples, please have a look at the fft_eval tool [1] which now supports both ath9k and ath10k formats.

The count issue is still open: Even when a count is specified, the hardware seems to send endless samples. It seems to work most of the time in VHT80 mode though, but in HT20 and HT40 the count value seems to be ignored. To reproduce this, start hostapd with the desired channel width and do:

echo 8 > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_count echo manual > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl echo trigger > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl cat /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan0 >> /tmp/fft.dump

Repeating the last line and checking the filesize will easily show whether ath10k still sends samples or not. We would expect 8 samples in this configuration.

Please see the patches for more information on the changes.

Cheers,
Simon

Quoted 7 lines

[1] https://github.com/simonwunderlich/FFT_eval

Simon Wunderlich (1):
ath10k: add spectral scan feature

Sven Eckelmann (1):
ath: Move spectral debugfs structs to shared header

Thanks, both patches applied.

And thanks for fixing a bug I introduced!

Signature · 1 line
Kalle Valo
#4 lore raw
In reply to Simon Wunderlich
Quoted 2 lines · Simon Wunderlich

To view the samples, please have a look at the fft_eval tool [1] which now supports both ath9k and ath10k formats.

Can you please edit the ath9k and ath10k wiki about this tool and reference to it?

Luis

#5 lore raw
Quoted 6 lines · Luis R. Rodriguez
Quoted 2 lines · Simon Wunderlich

To view the samples, please have a look at the fft_eval tool [1] which now supports both ath9k and ath10k formats.

Can you please edit the ath9k and ath10k wiki about this tool and reference to it?

While at it also please update the iw wiki page too.

Luis

#6 lore raw
In reply to Luis R. Rodriguez
Quoted 2 lines

On Fri, Aug 1, 2014 at 6:17 AM, Simon Wunderlich <[email protected]>

Quoted 5 lines · wrote:
Quoted 2 lines

To view the samples, please have a look at the fft_eval tool [1] which now supports both ath9k and ath10k formats.

Can you please edit the ath9k and ath10k wiki about this tool and reference to it?

Thanks for pointing that out. I've updated ath9k with some instructions how to actually run the spectral scan. A link to the tool was already included. I've also added an ath10k page with test instructions and description of the debugfs files, including a reference to fft_eval. Feel free to update/improve/edit, everyone. :)

I did not update the iw page because there is (no longer) any changes neccesary in iw for running spectral - we had this only in the very first version of the ath9k patch. I've updated the README/usage in fft_eval to reflect that properly, though.

Thanks,
Simon