Skip to contentSkip to conversation

ath10k spectral scan support

PATCH Superseded Simon Wunderlich 4 participants 11 messages Jul 21, 2014 – Jul 23, 2014

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover ath10k spectral scan support

This is the second "PATCH" patchset iteration for the ath10k spectral scan feature. It includes a few cosmetic changes and now handles firmware crashes (Thanks Michal and Chun-Yeow!).

The fft_eval tool has also been updated based on the new patchset, and now supports both ath9k and ath10k sample formats in the same branch, which has been merged into master [1]. Please make sure to use the latest version of both fft_eval and this patchset for testing.

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.

See the patch 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   |   3 +-
 drivers/net/wireless/ath/ath10k/core.c     |   4 +
 drivers/net/wireless/ath/ath10k/core.h     |   8 +
 drivers/net/wireless/ath/ath10k/debug.c    |   3 +
 drivers/net/wireless/ath/ath10k/mac.c      |   9 +
 drivers/net/wireless/ath/ath10k/spectral.c | 563 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/spectral.h |  64 ++++
 drivers/net/wireless/ath/ath10k/wmi.c      | 104 +++++-
 drivers/net/wireless/ath/ath10k/wmi.h      |  94 +++++
 drivers/net/wireless/ath/ath9k/spectral.h  |  71 +---
 drivers/net/wireless/ath/spectral_common.h | 112 ++++++
 12 files changed, 965 insertions(+), 71 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 v2 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 137e2e6..0b9465e 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 v2 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 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.

--
PATCHv2:
* fixed usage example in commit message (Thanks Chun-Yeow Yeoh)
* adding lockdep asserts and comment (Thanks Michal)
* debug message cleanups (Michal)
* disable spectral on firmware crash (Michal)

PATCH:
* change the tlv format to a variable-length format, depending on the number of bins
* perform dc interpolation and max_exp calculation in the driver (as for ath9k)
* make fft_size configurable
* background scan will only start after beeing trigger, like in ath9k
* document at least some spectral configuration members (thanks Kathy)
* fix sparse problems
* sample bandwidth appears to be 110% of what is reported by the hardware according to the plotter (e.g. 20->22, 40->44 MHz etc), so fix that in the driver.
* disable spectral for a vif when it's beeing deleted and still active (Michals comment)
* modify ath_ prefix of function/struct/enum to ath10k_ (Michal)
* changed variable ret to res (Michal)
* added ath10k_warn messages (Michal)
* renamed wmi functions (Michal)
* use ar->conf_mutex for locking (Michal)
* renamed mhz to chan_width_mhz (Michal)
* only enable spectral scan files when ATH10K_DEBUGFS is enabled

---
 drivers/net/wireless/ath/ath10k/Kconfig    |   1 +
 drivers/net/wireless/ath/ath10k/Makefile   |   3 +-
 drivers/net/wireless/ath/ath10k/core.c     |   4 +
 drivers/net/wireless/ath/ath10k/core.h     |   8 +
 drivers/net/wireless/ath/ath10k/debug.c    |   3 +
 drivers/net/wireless/ath/ath10k/mac.c      |   9 +
 drivers/net/wireless/ath/ath10k/spectral.c | 563 +++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/spectral.h |  64 ++++
 drivers/net/wireless/ath/ath10k/wmi.c      | 104 +++++-
 drivers/net/wireless/ath/ath10k/wmi.h      |  94 +++++
 drivers/net/wireless/ath/spectral_common.h |  24 ++
 11 files changed, 875 insertions(+), 2 deletions(-)
 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 489bf8b..095dcaf 100644
@@ -27,6 +27,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 +2 -1
index 2110a5c..e1dcefd 100644
@@ -8,7 +8,8 @@ ath10k_core-y += mac.o \
 		 htt_tx.o \
 		 txrx.o \
 		 wmi.o \
-		 bmi.o
+		 bmi.o \
+		 spectral.o
 
 ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
 
drivers/net/wireless/ath/ath10k/core.c +4 -0
index ebc5fc2..3a113fb 100644
@@ -699,6 +699,10 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
 	ar->hif.priv = hif_priv;
 	ar->hif.ops = hif_ops;
 
+	ar->spectral_mode = SPECTRAL_DISABLED;
+	ar->spec_config.count = WMI_SPECTRAL_COUNT_DEFAULT;
+	ar->spec_config.fft_size = WMI_SPECTRAL_FFT_SIZE_DEFAULT;
+
 	init_completion(&ar->scan.started);
 	init_completion(&ar->scan.completed);
 	init_completion(&ar->scan.on_channel);
drivers/net/wireless/ath/ath10k/core.h +8 -0
index 80aa5a4..4af527a 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)
@@ -230,6 +231,7 @@ struct ath10k_vif {
 
 	bool is_started;
 	bool is_up;
+	bool spectral_enabled;
 	u32 aid;
 	u8 bssid[ETH_ALEN];
 
@@ -469,6 +471,12 @@ struct ath10k {
 #ifdef CONFIG_ATH10K_DEBUGFS
 	struct ath10k_debug debug;
 #endif
+
+	/* 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 spectral_mode;
+	struct ath10k_spec_scan spec_config;
 };
 
 struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
drivers/net/wireless/ath/ath10k/debug.c +3 -0
index f56f358..f8f4f6f 100644
@@ -853,12 +853,15 @@ int ath10k_debug_create(struct ath10k *ar)
 				    &fops_dfs_stats);
 	}
 
+	ath10k_spectral_init_debug(ar);
+
 	return 0;
 }
 
 void ath10k_debug_destroy(struct ath10k *ar)
 {
 	cancel_delayed_work_sync(&ar->debug.htt_stats_dwork);
+	ath10k_spectral_deinit_debug(ar);
 }
 
 #endif /* CONFIG_ATH10K_DEBUGFS */
drivers/net/wireless/ath/ath10k/mac.c +9 -0
index 348a639..14d6234 100644
@@ -2201,6 +2201,7 @@ void ath10k_halt(struct ath10k *ar)
 	ath10k_peer_cleanup_all(ar);
 	ath10k_core_stop(ar);
 	ath10k_hif_power_down(ar);
+	ath10k_disable_spectral(ar);
 
 	spin_lock_bh(&ar->data_lock);
 	if (ar->scan.in_progress) {
@@ -2671,8 +2672,16 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
 		dev_kfree_skb_any(arvif->beacon);
 		arvif->beacon = NULL;
 	}
+
 	spin_unlock_bh(&ar->data_lock);
 
+	if (arvif->spectral_enabled) {
+		ret = ath10k_disable_spectral(ar);
+		if (ret)
+			ath10k_warn("Failed to disable 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 +563 -0

563 lines not on this page · raw message

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

64 lines not on this page · raw message

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

116 lines not on this page · raw message

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

112 lines not on this page · raw message

drivers/net/wireless/ath/spectral_common.h +24 -0
index b9ab722..0827cb7 100644
@@ -19,6 +19,10 @@
 
 #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.
  *
@@ -31,6 +35,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 +90,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

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

Quoted 12 lines · 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 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

Quoted 5 lines

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

While I was commiting this to ath-next-test for build tests and review, I had a trivial conflict. Please check the patch:

https://github.com/kvalo/ath/commit/85dec746d1f4728176bd06a53b6da4ef014f2a27

Oddly enough with this patch I see a new warning:

include/uapi/linux/swab.h:71:16: error: undefined identifier '__builtin_bswap64'

But I guess there's not much we can do about that?

Signature · 1 line
Kalle Valo
#4 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

In reply to Simon Wunderlich

drivers/net/wireless/ath/ath10k/Makefile ath10k_core-y += mac.o \ · line 12

Quoted 11 lines · On Monday 21 July 2014 14:32:23 Simon Wunderlich wrote:
(quoted diff) +0 -0

b/drivers/net/wireless/ath/ath10k/Makefile index 2110a5c..e1dcefd 100644

drivers/net/wireless/ath/ath10k/Makefile +2 -1
@@ -8,7 +8,8 @@ ath10k_core-y += mac.o \
 		 htt_tx.o \
 		 txrx.o \
 		 wmi.o \
-		 bmi.o
+		 bmi.o \
+		 spectral.o

ath9k doesn't compile the debugfs+spectral source files when CONFIG_ATH9K_DEBUGFS is not enabled. So this most likely has to be changed to

ath10k_core-$(CONFIG_ATH10K_DEBUGFS) += spectral.o

Otherwise the static inline functions in the spectral.h may collide with the functions inside spectral.c when CONFIG_ATH10K_DEBUGFS is disabled.

Kind regards,
Sven

#5 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

In reply to Simon Wunderlich
Quoted 3 lines · 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.

[...]

drivers/net/wireless/ath/ath10k/mac.c void ath10k_halt(struct ath10k *ar) · line 2204

Quoted 10 lines

#endif /* CONFIG_ATH10K_DEBUGFS */

drivers/net/wireless/ath/ath10k/mac.c +1 -0
index 348a639..14d6234 100644
@@ -2201,6 +2201,7 @@ void ath10k_halt(struct ath10k *ar)
        ath10k_peer_cleanup_all(ar);
        ath10k_core_stop(ar);
        ath10k_hif_power_down(ar);
+       ath10k_disable_spectral(ar);

It makes little sense to call it after powering off the chip, no? ath10k_disable_spectral() calls ath10k_wmi_vdev_spectral_enable() which requires WMI (and thus firmware as a whole) to be running, otherwise you'll fail to submit the command. Anyway, if you try to send a WMI command when hw is restarting firmware won't respond properly anyway and it'll print a warning.

Quoted 5 lines
drivers/net/wireless/ath/ath10k/mac.c +0 -0
        spin_lock_bh(&ar->data_lock);
        if (ar->scan.in_progress) {
@@ -2671,8 +2672,16 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
                dev_kfree_skb_any(arvif->beacon);

drivers/net/wireless/ath/ath10k/mac.c static void ath10k_remove_interface(struct ieee80211_hw *hw, · line 2682

Quoted 10 lines
drivers/net/wireless/ath/ath10k/mac.c +6 -0
                arvif->beacon = NULL;
        }
+
        spin_unlock_bh(&ar->data_lock);
 
+       if (arvif->spectral_enabled) {
+               ret = ath10k_disable_spectral(ar);
+               if (ret)
+                       ath10k_warn("Failed to disable spectral for vdev %i: %d\n",
+                                   arvif->vdev_id, ret);

I'm aware ath10k still has some capitalized warnings but it'd be nice to have this lower case (this is something that has been agreed upon some time ago but still not all prints have been updated since then).

Michał

#6 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

In reply to Simon Wunderlich
Quoted 12 lines · 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 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

Quoted 5 lines

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

Quick comments about the style.

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev, · line 704

Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.c +3 -0
@@ -699,6 +699,10 @@ struct ath10k *ath10k_core_create(void *hif_priv, struct device *dev,
 	ar->hif.priv = hif_priv;
 	ar->hif.ops = hif_ops;
 
+	ar->spectral_mode = SPECTRAL_DISABLED;
+	ar->spec_config.count = WMI_SPECTRAL_COUNT_DEFAULT;
+	ar->spec_config.fft_size = WMI_SPECTRAL_FFT_SIZE_DEFAULT;

I would rather have ath10k_spectral_init() or similar to avoid sprinkling this stuff all over the driver.

Quoted 11 lines
drivers/net/wireless/ath/ath10k/core.h +1 -0
@@ -230,6 +231,7 @@ struct ath10k_vif {
 
 	bool is_started;
 	bool is_up;
+	bool spectral_enabled;
 	u32 aid;
 	u8 bssid[ETH_ALEN];
 

drivers/net/wireless/ath/ath10k/core.h struct ath10k { · line 480

Quoted 10 lines
drivers/net/wireless/ath/ath10k/core.h +6 -0
@@ -469,6 +471,12 @@ struct ath10k {
 #ifdef CONFIG_ATH10K_DEBUGFS
 	struct ath10k_debug debug;
 #endif
+
+	/* 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 spectral_mode;
+	struct ath10k_spec_scan spec_config;
 };

For all spectral stuff I would prefer to have a "substructure", just like mac has. That way it's easier to know who owns what fields.

I know this structure is a mess now, I have been sloppy on review...

drivers/net/wireless/ath/ath10k/mac.c void ath10k_halt(struct ath10k *ar) · line 2204

Quoted 9 lines
drivers/net/wireless/ath/ath10k/mac.c +1 -0
index 348a639..14d6234 100644
@@ -2201,6 +2201,7 @@ void ath10k_halt(struct ath10k *ar)
 	ath10k_peer_cleanup_all(ar);
 	ath10k_core_stop(ar);
 	ath10k_hif_power_down(ar);
+	ath10k_disable_spectral(ar);

Maybe ath10k_spectral_stop()?

Quoted 6 lines
drivers/net/wireless/ath/ath10k/mac.c +0 -0
 	spin_lock_bh(&ar->data_lock);
 	if (ar->scan.in_progress) {
@@ -2671,8 +2672,16 @@ static void ath10k_remove_interface(struct ieee80211_hw *hw,
 		dev_kfree_skb_any(arvif->beacon);
 		arvif->beacon = NULL;

drivers/net/wireless/ath/ath10k/mac.c static void ath10k_remove_interface(struct ieee80211_hw *hw, · line 2683

Quoted 10 lines
drivers/net/wireless/ath/ath10k/mac.c +7 -0
 	}
+
 	spin_unlock_bh(&ar->data_lock);
 
+	if (arvif->spectral_enabled) {
+		ret = ath10k_disable_spectral(ar);
+		if (ret)
+			ath10k_warn("Failed to disable spectral for vdev %i: %d\n",
+				    arvif->vdev_id, ret);
+	}

And here as well? And move the check for arvif->spectral_enabled inside spectral.c?

Quoted 40 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +34 -0
new file mode 100644
index 0000000..4179efb
@@ -0,0 +1,563 @@
+/*
+ * Copyright (c) 2013 Qualcomm Atheros, Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/relay.h>
+#include "core.h"
+#include "debug.h"
+
+static void
+ath10k_debug_send_fft_sample(struct ath10k *ar,
+			     const struct fft_sample_tlv *fft_sample_tlv)
+{
+	int length;
+
+	if (!ar->rfs_chan_spec_scan)
+		return;
+
+	length = __be16_to_cpu(fft_sample_tlv->length) +
+		 sizeof(*fft_sample_tlv);
+	relay_write(ar->rfs_chan_spec_scan, fft_sample_tlv, length);
+}
+

drivers/net/wireless/ath/ath10k/spectral.c line 44

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+static uint8_t get_max_exp(s8 max_index, u16 max_magnitude, size_t bin_len,
+			   u8 *data)
+{
+	int dc_pos;
+	u8 max_exp;
+
+	dc_pos = bin_len / 2;
+	/* peak index outside of bins */
+	if (dc_pos < max_index || -dc_pos >= max_index)
+		return 0;

Empty line before the comment, please.

Quoted 8 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +8 -0
+int ath10k_process_fft(struct ath10k *ar,
+		       struct wmi_single_phyerr_rx_event *event,
+		       struct phyerr_fft_report *fftr, size_t bin_len, u64 tsf)
+{
+	struct fft_sample_ath10k *fft_sample;
+	u8 buf[sizeof(*fft_sample) + SPECTRAL_ATH10K_MAX_NUM_BINS];
+	int dc_pos;
+	u32 reg0, reg1;

drivers/net/wireless/ath/ath10k/spectral.c line 75

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+	u16 peak_mag;
+	u8 *bins;
+	u16 freq1;
+	u16 freq2;
+	u16 total_gain_db;
+	u16 base_pwr_db;
+	u8 chain_idx;
+	u32 nf_list1;
+	u32 nf_list2;
+	u16 length;

You could combine the variable declarations, for example:

u16 freq1, freq2, total_gain_db, and_so_on;

Quoted 26 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +26 -0
+	fft_sample = (struct fft_sample_ath10k *)&buf;
+
+	if (bin_len < 64 || bin_len > SPECTRAL_ATH10K_MAX_NUM_BINS)
+		return -EINVAL;
+
+	reg0 = __le32_to_cpu(fftr->reg0);
+	reg1 = __le32_to_cpu(fftr->reg1);
+
+	length = sizeof(*fft_sample) - sizeof(struct fft_sample_tlv) + bin_len;
+	fft_sample->tlv.type = ATH_FFT_SAMPLE_ATH10K;
+	fft_sample->tlv.length = __cpu_to_be16(length);
+
+	/* TODO: there might be a reason why the hardware reports 20/40/80 MHz,
+	 * but the results/plots suggest that its actually 22/44/88 MHz.
+	 */
+	switch (event->hdr.chan_width_mhz) {
+	case 20:
+		fft_sample->chan_width_mhz = 22;
+		break;
+	case 40:
+		fft_sample->chan_width_mhz = 44;
+		break;
+	case 80:
+		/* TODO: As experiments with an analogue sender and various
+		 * configuaritions (fft-sizes of 64/128/256 and 20/40/80 Mhz)
+		 * show, the particular configuration of 80 MHz/64 bins does

drivers/net/wireless/ath/ath10k/spectral.c line 112

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+		 * not match with the other smaples at all. Until the reason
+		 * for that is found, don't report these samples.
+		 */
+		if (bin_len == 64)
+			return -EINVAL;
+		fft_sample->chan_width_mhz = 88;
+		break;
+	default:
+		fft_sample->chan_width_mhz = event->hdr.chan_width_mhz;
+	}

Empty line here.

Quoted 11 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +11 -0
+	fft_sample->relpwr_db = MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB);
+	fft_sample->avgpwr_db = MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB);
+
+	peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
+	fft_sample->max_magnitude = __cpu_to_be16(peak_mag);
+	fft_sample->max_index = MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX);
+	fft_sample->rssi = event->hdr.rssi_combined;
+
+	total_gain_db = MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB);
+	base_pwr_db = MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB);
+	fft_sample->total_gain_db = __cpu_to_be16(total_gain_db);

drivers/net/wireless/ath/ath10k/spectral.c line 133

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+	fft_sample->base_pwr_db = __cpu_to_be16(base_pwr_db);
+
+	freq1 = __le16_to_cpu(event->hdr.freq1);
+	freq2 = __le16_to_cpu(event->hdr.freq2);
+	fft_sample->freq1 = __cpu_to_be16(freq1);
+	fft_sample->freq2 = __cpu_to_be16(freq2);
+
+	nf_list1 = __le32_to_cpu(event->hdr.nf_list_1);
+	nf_list2 = __le32_to_cpu(event->hdr.nf_list_2);
+	chain_idx = MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX);

Empty line here.

Quoted 9 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +9 -0
+	switch (chain_idx) {
+	case 0:
+		fft_sample->noise = __cpu_to_be16(nf_list1 & 0xffffu);
+		break;
+	case 1:
+		fft_sample->noise = __cpu_to_be16((nf_list1 >> 16) & 0xffffu);
+		break;
+	case 2:
+		fft_sample->noise = __cpu_to_be16(nf_list2 & 0xffffu);

drivers/net/wireless/ath/ath10k/spectral.c line 152

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+		break;
+	case 3:
+		fft_sample->noise = __cpu_to_be16((nf_list2 >> 16) & 0xffffu);
+		break;
+	}
+
+	bins = (u8 *)fftr;
+	bins += sizeof(*fftr);
+
+	fft_sample->tsf = __cpu_to_be64(tsf);

Empty line here.

Quoted 9 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +9 -0
+	arg.vdev_id              = vdev_id;
+	arg.scan_count           = count;
+	arg.scan_period          = WMI_SPECTRAL_PERIOD_DEFAULT;
+	arg.scan_priority        = WMI_SPECTRAL_PRIORITY_DEFAULT;
+	arg.scan_fft_size        = ar->spec_config.fft_size;
+	arg.scan_gc_ena          = WMI_SPECTRAL_GC_ENA_DEFAULT;
+	arg.scan_restart_ena     = WMI_SPECTRAL_RESTART_ENA_DEFAULT;
+	arg.scan_noise_floor_ref = WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
+	arg.scan_init_delay      = WMI_SPECTRAL_INIT_DELAY_DEFAULT;

drivers/net/wireless/ath/ath10k/spectral.c line 274

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+	arg.scan_nb_tone_thr     = WMI_SPECTRAL_NB_TONE_THR_DEFAULT;
+	arg.scan_str_bin_thr     = WMI_SPECTRAL_STR_BIN_THR_DEFAULT;
+	arg.scan_wb_rpt_mode     = WMI_SPECTRAL_WB_RPT_MODE_DEFAULT;
+	arg.scan_rssi_rpt_mode   = WMI_SPECTRAL_RSSI_RPT_MODE_DEFAULT;
+	arg.scan_rssi_thr        = WMI_SPECTRAL_RSSI_THR_DEFAULT;
+	arg.scan_pwr_format      = WMI_SPECTRAL_PWR_FORMAT_DEFAULT;
+	arg.scan_rpt_mode        = WMI_SPECTRAL_RPT_MODE_DEFAULT;
+	arg.scan_bin_scale       = WMI_SPECTRAL_BIN_SCALE_DEFAULT;
+	arg.scan_dbm_adj         = WMI_SPECTRAL_DBM_ADJ_DEFAULT;
+	arg.scan_chn_mask        = WMI_SPECTRAL_CHN_MASK_DEFAULT;

Please don't indent the '=':

arg.scan_dbm_adj = WMI_SPECTRAL_DBM_ADJ_DEFAULT arg.scan_chn_mask = WMI_SPECTRAL_CHN_MASK_DEFAULT;

drivers/net/wireless/ath/ath10k/spectral.c line 387

Quoted 3 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +3 -0
+/******************/
+/* spectral_count */
+/******************/

I don't think there's any point of adding these comments for each debugfs file. I don't see how spectral.c even needs these kind of comments, it's only 500 lines long.

Quoted 19 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +19 -0
+void ath10k_spectral_deinit_debug(struct ath10k *ar)
+{
+	if (config_enabled(CONFIG_ATH10K_DEBUGFS) && ar->rfs_chan_spec_scan) {
+		relay_close(ar->rfs_chan_spec_scan);
+		ar->rfs_chan_spec_scan = NULL;
+	}
+}
+
+void ath10k_spectral_init_debug(struct ath10k *ar)
+{
+#ifdef CONFIG_ATH10K_DEBUGFS
+	ar->rfs_chan_spec_scan = relay_open("spectral_scan",
+					    ar->debug.debugfs_phy,
+					    1024, 256, &rfs_spec_scan_cb,
+					    NULL);
+	debugfs_create_file("spectral_scan_ctl",
+			    S_IRUSR | S_IWUSR,
+			    ar->debug.debugfs_phy, ar,
+			    &fops_spec_scan_ctl);

drivers/net/wireless/ath/ath10k/spectral.c line 563

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c new file +10 -0
+	debugfs_create_file("spectral_count",
+			    S_IRUSR | S_IWUSR,
+			    ar->debug.debugfs_phy, ar,
+			    &fops_spectral_count);
+	debugfs_create_file("spectral_bins",
+			    S_IRUSR | S_IWUSR,
+			    ar->debug.debugfs_phy, ar,
+			    &fops_spectral_bins);
+#endif
+}

Do we even bother compiling spectral.c when ATH10K_DEBUGFS is disabled? Should we instead just do this:

ath10k_core-$(CONFIG_ATH10K_DEBUGFS) += spectral.o

Quoted 5 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +0 -0
new file mode 100644
index 0000000..ee10ad2

[...]

Quoted 7 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +7 -0
+void ath10k_spectral_init_debug(struct ath10k *ar);
+void ath10k_spectral_deinit_debug(struct ath10k *ar);
+int ath10k_disable_spectral(struct ath10k *ar);
+
+#ifdef CONFIG_ATH10K_DEBUGFS
+int ath10k_process_fft(struct ath10k *ar,
+		       struct wmi_single_phyerr_rx_event *event,

drivers/net/wireless/ath/ath10k/spectral.h line 62

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +10 -0
+		       struct phyerr_fft_report *fftr, size_t bin_len, u64 tsf);
+#else
+static inline int
+ath10k_process_fft(struct ath10k *ar,
+		   struct wmi_single_phyerr_rx_event *event,
+		   struct phyerr_fft_report *fftr, size_t bin_len, u64 tsf)
+{
+	return 0;
+}
+#endif /* CONFIG_ATH10K_DEBUGFS */

Why ath10k_spectral_init_debug() are not within the ifdef?

Quoted 6 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +6 -0
+int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
+				  const struct wmi_vdev_spectral_conf_arg *arg)
+{
+	struct wmi_vdev_spectral_conf_cmd *cmd;
+	struct sk_buff *skb;
+	u32 cmdid;

drivers/net/wireless/ath/ath10k/spectral.h

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +10 -0
+
+	skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+	if (!skb)
+		return -ENOMEM;
+
+	cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
+	cmd->vdev_id              = __cpu_to_le32(arg->vdev_id);
+	cmd->scan_count           = __cpu_to_le32(arg->scan_count);
+	cmd->scan_period          = __cpu_to_le32(arg->scan_period);
+	cmd->scan_priority        = __cpu_to_le32(arg->scan_priority);

Please do not indent the '='.

Quoted 5 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +5 -0
+int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger,
+				    u32 enable)
+{
+	struct wmi_vdev_spectral_enable_cmd *cmd;
+	struct sk_buff *skb;

drivers/net/wireless/ath/ath10k/spectral.h

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +10 -0
+	u32 cmdid;
+
+	skb = ath10k_wmi_alloc_skb(sizeof(*cmd));
+	if (!skb)
+		return -ENOMEM;
+
+	cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
+	cmd->vdev_id     = __cpu_to_le32(vdev_id);
+	cmd->trigger_cmd = __cpu_to_le32(trigger);
+	cmd->enable_cmd  = __cpu_to_le32(enable);

Here as well.

Quoted 25 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +25 -0
+/* TODO: please add more comments if you have in-depth information */
+struct wmi_vdev_spectral_conf_cmd {
+	__le32 vdev_id;
+	/* number of fft samples to send (0 for infinite) */
+	__le32 scan_count;
+	__le32 scan_period;
+	__le32 scan_priority;
+	/* number of bins in the FFT: 2^(fft_size - bin_scale) */
+	__le32 scan_fft_size;
+	__le32 scan_gc_ena;
+	__le32 scan_restart_ena;
+	__le32 scan_noise_floor_ref;
+	__le32 scan_init_delay;
+	__le32 scan_nb_tone_thr;
+	__le32 scan_str_bin_thr;
+	__le32 scan_wb_rpt_mode;
+	__le32 scan_rssi_rpt_mode;
+	__le32 scan_rssi_thr;
+	__le32 scan_pwr_format;
+	/* rpt_mode: Format of FFT report to software for spectral scan
+	 * triggered FFTs:
+	 *	0: No FFT report (only spectral scan summary report)
+	 *	1: 2-dword summary of metrics for each completed FFT + spectral
+	 *	   scan	summary report
+	 *	2: 2-dword summary of metrics for each completed FFT +

drivers/net/wireless/ath/ath10k/spectral.h

Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.h new file +10 -0
+	 *	   1x- oversampled bins(in-band) per FFT + spectral scan summary
+	 *	   report
+	 *	3: 2-dword summary of metrics for each completed FFT +
+	 *	   2x- oversampled bins	(all) per FFT + spectral scan summary
+	 */
+	__le32 scan_rpt_mode;
+	__le32 scan_bin_scale;
+	__le32 scan_dbm_adj;
+	__le32 scan_chn_mask;
+} __packed;

Empty lines before the comments.

drivers/net/wireless/ath/spectral_common.h line 25

Quoted 10 lines
drivers/net/wireless/ath/spectral_common.h +4 -0
@@ -19,6 +19,10 @@
 
 #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

Empty line before the comment.

Quoted 8 lines
drivers/net/wireless/ath/spectral_common.h +8 -0
+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;

drivers/net/wireless/ath/spectral_common.h struct fft_sample_ht20_40 { · line 110

Quoted 10 lines
drivers/net/wireless/ath/spectral_common.h +10 -0
+	__be16 base_pwr_db;
+	__be64 tsf;
+	s8 max_index;
+	u8 rssi;
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;

__be16, that's a first. Just making sure that this really is big endian?

Signature · 1 line
Kalle Valo
#7 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

Hey Kalle,

thanks for all the comments!

I'll make the changes as you suggested, although I'd like to point out that the "empty line before comment" and the "no indentation for WMI command parameters" things are not really consistent - there are also empty lines missing (e.g. struct wmi_start_scan_cmd) and indentation present (e.g. ath10k_wmi_peer_assoc and many others). Maybe that should be cleaned up at some point if you think that's important. :)

Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/ath/spectral_common.h +12 -0
+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;
Quoted 8 lines

drivers/net/wireless/ath/spectral_common.h struct fft_sample_ht20_40 { · line 110

Quoted 6 lines
drivers/net/wireless/ath/spectral_common.h +6 -0
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;

__be16, that's a first. Just making sure that this really is big endian?

As the __le32 you use in other ath10k structs, this is just for checking - at least sparse should check that, maybe other tools as well.

I'll send a new patchset with the suggestions of Michal, Chun-Yeow and you soon. :)

Thanks!
Simon

#8 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

Quoted 10 lines · Simon Wunderlich

Hey Kalle,

thanks for all the comments!

I'll make the changes as you suggested, although I'd like to point out that the "empty line before comment" and the "no indentation for WMI command parameters" things are not really consistent - there are also empty lines missing (e.g. struct wmi_start_scan_cmd) and indentation present (e.g. ath10k_wmi_peer_assoc and many others). Maybe that should be cleaned up at some point if you think that's important. :)

Yeah, I have been sloppy in reviewing those part before but not anymore :) Also struct ath10k is quite a mess now. Sorry for the confusion.

I'm planning to fix these at some point, but if someone else wants to do it I'm very happy to take patches.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/ath/spectral_common.h +12 -0
+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;
Quoted 8 lines

drivers/net/wireless/ath/spectral_common.h struct fft_sample_ht20_40 { · line 110

Quoted 6 lines
drivers/net/wireless/ath/spectral_common.h +6 -0
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;

__be16, that's a first. Just making sure that this really is big endian?

Quoted 2 lines

As the __le32 you use in other ath10k structs, this is just for checking - at least sparse should check that, maybe other tools as well.

Sorry, I didn't understand your comment here. But basically I was asking is the fft sample really in big endian? I assume it would be little endian as everything else coming from the firmware.

Signature · 1 line
Kalle Valo
#9 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

Hey Kalle,

Quoted 22 lines
Quoted 21 lines · Simon Wunderlich
Quoted 20 lines
Quoted 8 lines
drivers/net/wireless/ath/spectral_common.h +8 -0
+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;

drivers/net/wireless/ath/spectral_common.h struct fft_sample_ht20_40 { · line 110

Quoted 10 lines
drivers/net/wireless/ath/spectral_common.h +10 -0
+	__be16 base_pwr_db;
+	__be64 tsf;
+	s8 max_index;
+	u8 rssi;
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;

__be16, that's a first. Just making sure that this really is big endian?

Quoted 6 lines
Quoted 2 lines

As the __le32 you use in other ath10k structs, this is just for checking
- at least sparse should check that, maybe other tools as well.

Sorry, I didn't understand your comment here. But basically I was asking is the fft sample really in big endian? I assume it would be little endian as everything else coming from the firmware.

Yeah that is intended - we are also using big endian in ath9k to send fft samples to userspace, because that is the network byte order and we then just use ntohs() and friends in userspace to read samples from any system. Therefore we intent to use the same encoding in ath10k. :)

Cheers,
Simon

#10 lore raw

Re: [PATCHv2 2/2] ath10k: add spectral scan feature

Quoted 27 lines · Simon Wunderlich

Hey Kalle,

Quoted 25 lines
Quoted 23 lines · Simon Wunderlich
Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/ath/spectral_common.h +12 -0
+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;
Quoted 8 lines

drivers/net/wireless/ath/spectral_common.h struct fft_sample_ht20_40 { · line 110

Quoted 6 lines
drivers/net/wireless/ath/spectral_common.h +6 -0
+	u8 relpwr_db;
+	u8 avgpwr_db;
+	u8 max_exp;
+
+	u8 data[0];
+} __packed;

__be16, that's a first. Just making sure that this really is big endian?

As the __le32 you use in other ath10k structs, this is just for checking
- at least sparse should check that, maybe other tools as well.

Quoted 8 lines
Quoted 3 lines

Sorry, I didn't understand your comment here. But basically I was asking is the fft sample really in big endian? I assume it would be little endian as everything else coming from the firmware.

Yeah that is intended - we are also using big endian in ath9k to send fft samples to userspace, because that is the network byte order and we then just use ntohs() and friends in userspace to read samples from any system. Therefore we intent to use the same encoding in ath10k. :)

Ah, this is the struct going to user space? I thought it's coming from the firmware. Then forget my question :)

Signature · 1 line
Kalle Valo