ath10k: Fix spectral scan for QCA99X0 family of chipsets
PATCH 1/1 ath10k: Fix spectral scan for QCA99X0 family of chipsets
From: Mohammed Shafi Shajakhan <[email protected]>
spectral_bin length (number of bins per fft sample) is usually a value where (2^n = value), n is an integer. All of the QCA99X0 family of chipsets seems to report a spectral_bin length of 2^n + 'm' bytes, where m = 4, 12 based on the chipset. This 'm' bytes seems to carry some radar related info which is currenly discarded only for 'bin_len = 68' bytes. Extend this discarding of irrelevant 'bin_len' for QCA9984, QCA9888, IPQ4019 as well by introducing a hardware parameter 'spectral_bin_discard'. Also for QCA988X based family of chipsets which doesn't seem to have this issue and also for some of the hardware which I have not tested like QCA6174/QCA9377 the existing behaviour is retained as it is.
---
drivers/net/wireless/ath/ath10k/core.c | 12 ++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 3 +++ drivers/net/wireless/ath/ath10k/spectral.c | 25 +++++++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +12 -0
@@ -71,6 +71,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA9887_HW_1_0_VERSION,
@@ -91,6 +92,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -110,6 +112,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_2_1_VERSION,
@@ -129,6 +132,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_3_0_VERSION,
@@ -148,6 +152,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_3_2_VERSION,
@@ -168,6 +173,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA99X0_HW_2_0_DEV_VERSION,
@@ -193,6 +199,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 4, }, { .id = QCA9984_HW_1_0_DEV_VERSION,
@@ -219,6 +226,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 12, }, { .id = QCA9888_HW_2_0_DEV_VERSION,
@@ -244,6 +252,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 12, }, { .id = QCA9377_HW_1_0_DEV_VERSION,
@@ -263,6 +272,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA9377_HW_1_1_DEV_VERSION,
@@ -282,6 +292,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA4019_HW_1_0_DEV_VERSION,
@@ -308,6 +319,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 4, }, };
drivers/net/wireless/ath/ath10k/hw.h +3 -0
@@ -416,6 +416,9 @@ struct ath10k_hw_params {/* Number of bytes used for alignment in rx_hdr_status of rx desc. */ int decap_align_bytes; + +/* Number of bytes to be discarded for each FFT sample */ +int spectral_bin_discard; };struct htt_rx_desc ;
drivers/net/wireless/ath/ath10k/spectral.c +17 -8
@@ -56,6 +56,21 @@ static uint8_t get_max_exp(s8 max_index, u16 max_magnitude, size_t bin_len,return max_exp; } +static inline size_t ath10k_spectral_fix_bin_size (struct ath10k *ar, +size_t bin_len) +{ +/* some chipsets reports bin size as 2^n bytes + 'm' bytes in +* report mode 2. First 2^n bytes carries inband tones and last +* 'm' bytes carries band edge detection data mainly used in +* radar detection purpose. Strip last 'm' bytes to make bin size +* as a valid one. 'm' can take possible values of 4, 12. +*/ +if (!is_power_of_2 (bin_len)) + bin_len -= ar->hw_params.spectral_bin_discard; + +return bin_len; +} + int ath10k_spectral_process_fft(struct ath10k *ar, struct wmi_phyerr_ev_arg *phyerr, const struct phyerr_fft_report *fftr,
@@ -70,17 +85,11 @@ int ath10k_spectral_process_fft(struct ath10k *ar, fft_sample = (struct fft_sample_ath10k *)&buf; + bin_len =ath10k_spectral_fix_bin_size (ar, bin_len); +if (bin_len <64 || bin_len >SPECTRAL_ATH10K_MAX_NUM_BINS )return -EINVAL ; -/* qca99x0 reports bin size as 68 bytes (64 bytes + 4 bytes) in -* report mode 2. First 64 bytes carries inband tones (-32 to +31) -* and last 4 byte carries band edge detection data (+32) mainly -* used in radar detection purpose. Strip last 4 byte to make bin -* size is valid one. -*/ -if (bin_len ==68 ) - bin_len -=4 ; reg0 =__le32_to_cpu (fftr->reg0); reg1 =__le32_to_cpu (fftr->reg1);
Signature · 1 line
1.9.1
hi!
For reference, would you mind pulling out what hte format of the edge detection dword is?
Thanks!
-adrian
Quoted 185 lines · Mohammed Shafi Shajakhan
From: Mohammed Shafi Shajakhan <[email protected]>
spectral_binlength (number of bins per fft sample) is usually a value where (2^n = value), n is an integer. All of the QCA99X0 family of chipsets seems to report aspectral_binlength of 2^n + 'm' bytes, where m = 4, 12 based on the chipset. This 'm' bytes seems to carry some radar related info which is currenly discarded only for 'bin_len= 68' bytes. Extend this discarding of irrelevant 'bin_len' for QCA9984, QCA9888, IPQ4019 as well by introducing a hardware parameter 'spectral_bin_discard'. Also for QCA988X based family of chipsets which doesn't seem to have this issue and also for some of the hardware which I have not tested like QCA6174/QCA9377 the existing behaviour is retained as it is.Signed-off-by Mohammed Shafi Shajakhan <[email protected]>---
drivers/net/wireless/ath/ath10k/core.c | 12 ++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 3 +++ drivers/net/wireless/ath/ath10k/spectral.c | 25 +++++++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-)drivers/net/wireless/ath/ath10k/core.c +12
-0@@ -71,6 +71,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA9887_HW_1_0_VERSION,@@ -91,6 +92,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_2_1_VERSION,@@ -110,6 +112,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_2_1_VERSION,@@ -129,6 +132,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_3_0_VERSION,@@ -148,6 +152,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA6174_HW_3_2_VERSION,@@ -168,6 +173,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA99X0_HW_2_0_DEV_VERSION,@@ -193,6 +199,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 4, }, { .id = QCA9984_HW_1_0_DEV_VERSION,@@ -219,6 +226,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 12, }, { .id = QCA9888_HW_2_0_DEV_VERSION,@@ -244,6 +252,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 12, }, { .id = QCA9377_HW_1_0_DEV_VERSION,@@ -263,6 +272,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA9377_HW_1_1_DEV_VERSION,@@ -282,6 +292,7 @@ }, .hw_ops = &qca988x_ops, .decap_align_bytes = 4, + .spectral_bin_discard = 0, }, { .id = QCA4019_HW_1_0_DEV_VERSION,@@ -308,6 +319,7 @@ .sw_decrypt_mcast_mgmt = true, .hw_ops = &qca99x0_ops, .decap_align_bytes = 1, + .spectral_bin_discard = 4, }, };drivers/net/wireless/ath/ath10k/hw.h +3
-0@@ -416,6 +416,9 @@ struct ath10k_hw_params {/* Number of bytes used for alignment in rx_hdr_status of rx desc. */ int decap_align_bytes; + +/* Number of bytes to be discarded for each FFT sample */ +int spectral_bin_discard; };struct htt_rx_desc ;drivers/net/wireless/ath/ath10k/spectral.c +17
-9@@ -56,6 +56,21 @@ static uint8_t get_max_exp(s8 max_index, u16 max_magnitude, size_t bin_len,return max_exp; } +static inline size_t ath10k_spectral_fix_bin_size (struct ath10k *ar, +size_t bin_len) +{ +/* some chipsets reports bin size as 2^n bytes + 'm' bytes in +* report mode 2. First 2^n bytes carries inband tones and last +* 'm' bytes carries band edge detection data mainly used in +* radar detection purpose. Strip last 'm' bytes to make bin size +* as a valid one. 'm' can take possible values of 4, 12. +*/ +if (!is_power_of_2 (bin_len)) + bin_len -= ar->hw_params.spectral_bin_discard; + +return bin_len; +} + int ath10k_spectral_process_fft(struct ath10k *ar, struct wmi_phyerr_ev_arg *phyerr, const struct phyerr_fft_report *fftr,@@ -70,17 +85,11 @@ int ath10k_spectral_process_fft(struct ath10k *ar, fft_sample = (struct fft_sample_ath10k *)&buf; + bin_len =ath10k_spectral_fix_bin_size (ar, bin_len); +if (bin_len <64 || bin_len >SPECTRAL_ATH10K_MAX_NUM_BINS )return -EINVAL ; -/* qca99x0 reports bin size as 68 bytes (64 bytes + 4 bytes) in -* report mode 2. First 64 bytes carries inband tones (-32 to +31) -* and last 4 byte carries band edge detection data (+32) mainly -* used in radar detection purpose. Strip last 4 byte to make bin -* size is valid one. -*/ -if (bin_len ==68 ) - bin_len -=4 ; reg0 =__le32_to_cpu (fftr->reg0); reg1 =__le32_to_cpu (fftr->reg1); --1.9.1
Hello Adrian,=0A=
=0A=
For reference, would you mind pulling out what hte format of the edge=0A= detection dword is?=0A=
=0A=
[shafi] Sorry I did not dig into the DWORD carrying some radar related info= ,=0A=
as this gets discarded anyway for spectral processing. If you think the dis= carded=0A=
data is going to be useful in some way ??, let me get the dump for you. But=
feel=0A=
free to experiment with this patch !=0A=
=0A=
This is anyway needed for fixing spectral scan ...=0A=
=0A=
If you look into this patch more closely it just extends what Raja had fixe= d=0A=
long time back for QCA99X0 alone=0A=
https://patchwork.kernel.org/patch/7040681/=0A=
=0A=
regards,=0A=
shafi=0A=
=0A=
=0A=
On 10 April 2017 at 07:26, Mohammed Shafi Shajakhan=0A= <[email protected]> wrote:=0A=
Quoted 14 lines
From: Mohammed Shafi Shajakhan <[email protected]>=0A= =0A=
spectral_binlength (number of bins per fft sample) is usually=0A= a value where (2^n =3D value), n is an integer. All of the QCA99X0=0A= family of chipsets seems to report aspectral_binlength of=0A= 2^n + 'm' bytes, where m =3D 4, 12 based on the chipset. This 'm'=0A= bytes seems to carry some radar related info which is currenly=0A= discarded only for 'bin_len=3D 68' bytes. Extend this discarding of=0A= irrelevant 'bin_len' for QCA9984, QCA9888, IPQ4019 as well by=0A= introducing a hardware parameter 'spectral_bin_discard'. Also=0A= for QCA988X based family of chipsets which doesn't seem to have this=0A= issue and also for some of the hardware which I have not tested=0A= like QCA6174/QCA9377 the existing behaviour is retained as it is.=0A= =0A=
Quoted 6 lines
Signed-off-by Mohammed Shafi Shajakhan <[email protected]>=0A=---=0A=
=0A=drivers/net/wireless/ath/ath10k/core.c | 12 ++++++++++++=0A= drivers/net/wireless/ath/ath10k/hw.h | 3 +++=0A= drivers/net/wireless/ath/ath10k/spectral.c | 25 +++++++++++++++++-------=
-=0A=
drivers/net/wireles=
Quoted 3 lines
3 files changed, 32 insertions(+), 8 deletions(-)=0A==0A=
drivers/net/wireles= renamed from drivers/net/wireless/ath/ath10k/core.c +0
-0
s/ath/ath10k/core.c=0A=
drivers/net/wireless/=
Quoted 100 lines
index 5736f79..b543c84 100644=0A=
drivers/net/wireless/ath/ath10k/core.c=0A= +12
-0@@ -71,6 +71,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA9887_HW_1_0_VERSION,=0A=@@ -91,6 +92,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA6174_HW_2_1_VERSION,=0A=@@ -110,6 +112,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA6174_HW_2_1_VERSION,=0A=@@ -129,6 +132,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA6174_HW_3_0_VERSION,=0A=@@ -148,6 +152,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA6174_HW_3_2_VERSION,=0A=@@ -168,6 +173,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA99X0_HW_2_0_DEV_VERSION,=0A=@@ -193,6 +199,7 @@=0A= .sw_decrypt_mcast_mgmt =3D true,=0A= .hw_ops =3D &qca99x0_ops,=0A= .decap_align_bytes =3D 1,=0A= + .spectral_bin_discard =3D 4,=0A= },=0A= {=0A= .id =3D QCA9984_HW_1_0_DEV_VERSION,=0A=@@ -219,6 +226,7 @@=0A= .sw_decrypt_mcast_mgmt =3D true,=0A= .hw_ops =3D &qca99x0_ops,=0A= .decap_align_bytes =3D 1,=0A= + .spectral_bin_discard =3D 12,=0A= },=0A= {=0A= .id =3D QCA9888_HW_2_0_DEV_VERSION,=0A=@@ -244,6 +252,7 @@=0A= .sw_decrypt_mcast_mgmt =3D true,=0A= .hw_ops =3D &qca99x0_ops,=0A= .decap_align_bytes =3D 1,=0A= + .spectral_bin_discard =3D 12,=0A= },=0A= {=0A= .id =3D QCA9377_HW_1_0_DEV_VERSION,=0A=@@ -263,6 +272,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA9377_HW_1_1_DEV_VERSION,=0A=@@ -282,6 +292,7 @@=0A= },=0A= .hw_ops =3D &qca988x_ops,=0A= .decap_align_bytes =3D 4,=0A= + .spectral_bin_discard =3D 0,=0A= },=0A= {=0A= .id =3D QCA4019_HW_1_0_DEV_VERSION,=0A=@@ -308,6 +319,7 @@=0A= .sw_decrypt_mcast_mgmt =3D true,=0A= .hw_ops =3D &qca99x0_ops,=0A= .decap_align_bytes =3D 1,=0A= + .spectral_bin_discard =3D 4,=0A= },=0A= };=0A==0A=
drivers/net/wireless/= renamed from drivers/net/wireless/ath/ath10k/hw.h +0
-0
ath/ath10k/hw.h=0A=
Quoted 6 lines
index f0fda0f..8a0f9db 100644=0A=
drivers/net/wireless/ath/ath10k/hw.h=0A= +0
-0@@ -416,6 +416,9 @@ struct ath10k_hw_params {=0A==0A=
/* Number of bytes used for alignment in rx_hdr_status of rx desc=
. */=0A=
drivers/net/wir=
Quoted 8 lines
int decap_align_bytes;=0A=
+=0A=drivers/net/wireless/ath/ath10k/hw.h=0A= +2
-0+ /* Number of bytes to be discarded for each FFT sample */=0A= + int spectral_bin_discard;=0A= };=0A==0A=
struct htt_rx_desc;=0A=drivers/net/wir= renamed from drivers/net/wireless/ath/ath10k/spectral.c +0
-0
eless/ath/ath10k/spectral.c=0A=
drivers/net/wireless/ath/ath10k/spectral.c=0A= static uint8_t get_max_exp(s8 max_index, u16 max_magni=
Quoted 4 lines
index c061d69..3fd5d7d 100644=0A=
drivers/net/wireless/ath/ath10k/spectral.c=0A= +0
-0@@ -56,6 +56,21 @@ static uint8_t get_max_exp(s8 max_index, u16 max_magni=
tude, size_t bin_len,=0A=
drivers/net/wireless/ath/ath10k/spectral.c=0A=
Quoted 8 lines
drivers/net/wireless/ath/ath10k/spectral.c=0A= +0
-0return max_exp;=0A= }=0A==0A=
drivers/net/wireless/ath/ath10k/spectral.c=0A= +5
-0+static inline size_t ath10k_spectral_fix_bin_size(struct ath10k *ar,=0A= + size_t bin_len)=0A= +{=0A= + /* some chipsets reports bin size as 2^n bytes + 'm' bytes in=0A= + * report mode 2. First 2^n bytes carries inband tones and last=
=0A=
drivers/net/wireless/ath/ath10k/spectral.c=0A=
Quoted 2 lines
drivers/net/wireless/ath/ath10k/spectral.c=0A= +2
-0+ * 'm' bytes carries band edge detection data mainly used in=0A= + * radar detection purpose. Strip last 'm' bytes to make bin size=
=0A=
Quoted 13 lines
drivers/net/wireless/ath/ath10k/spectral.c=0A= +8
-0+ * as a valid one. 'm' can take possible values of 4, 12.=0A= + */=0A= + if (!is_power_of_2(bin_len))=0A= + bin_len -=3D ar->hw_params.spectral_bin_discard;=0A= +=0A= + return bin_len;=0A= +}=0A= +=0A= int ath10k_spectral_process_fft(struct ath10k *ar,=0A= struct wmi_phyerr_ev_arg *phyerr,=0A= const struct phyerr_fft_report *fftr,=0A=@@ -70,17 +85,11 @@ int ath10k_spectral_process_fft(struct ath10k *ar,=0A==0A=
Quoted 8 lines
fft_sample =3D (struct fft_sample_ath10k *)&buf;=0A= =0A= + bin_len =3D ath10k_spectral_fix_bin_size(ar, bin_len);=0A= +=0A= if (bin_len < 64 || bin_len > SPECTRAL_ATH10K_MAX_NUM_BINS)=0A= return -EINVAL;=0A==0A=
- /* qca99x0 reports bin size as 68 bytes (64 bytes + 4 bytes) in=
=0A=
Quoted 1 line
- * report mode 2. First 64 bytes carries inband tones (-32 to +31=
)=0A=
Quoted 1 line
- * and last 4 byte carries band edge detection data (+32) mainly=
=0A=
Quoted 1 line
- * used in radar detection purpose. Strip last 4 byte to make bin=
=0A=
Quoted 10 lines
drivers/net/wireless/ath/ath10k/spectral.c=0A= +0
-4- * size is valid one.=0A= - */=0A= - if (bin_len =3D=3D 68)=0A= - bin_len -=3D 4;=0A==0A=
reg0 =3D __le32_to_cpu(fftr->reg0);=0A= reg1 =3D __le32_to_cpu(fftr->reg1);=0A=--=0A=
1.9.1=0A=
=0A=