Commit 1cae9c00 authored by Karthikeyan Periyasamy's avatar Karthikeyan Periyasamy Committed by Kalle Valo

ath11k: Introduce spectral hw configurable param

Below parameters have been identified as configurable across the platforms.
So to scale the spectral across the platforms, move these parameter
into hw param.

	1. Maximum FFT bins
	2. Summary report pad size
	3. FFT report header length

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-01492-QCAHKSWPL_SILICONZ-1
Tested-on: IPQ6018 hw1.0 AHB WLAN.HK.2.4.0.1-00330-QCAHKSWPL_SILICONZ-1
Signed-off-by: default avatarKarthikeyan Periyasamy <periyasa@codeaurora.org>
Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210721180809.90960-3-jouni@codeaurora.org
parent cc2ad754
...@@ -66,6 +66,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { ...@@ -66,6 +66,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
* so added pad size as 2 bytes to compensate the BIN size * so added pad size as 2 bytes to compensate the BIN size
*/ */
.fft_pad_sz = 2, .fft_pad_sz = 2,
.summary_pad_sz = 0,
.fft_hdr_len = 16,
.max_fft_bins = 512,
}, },
.interface_modes = BIT(NL80211_IFTYPE_STATION) | .interface_modes = BIT(NL80211_IFTYPE_STATION) |
...@@ -111,6 +114,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { ...@@ -111,6 +114,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.spectral = { .spectral = {
.fft_sz = 4, .fft_sz = 4,
.fft_pad_sz = 0, .fft_pad_sz = 0,
.summary_pad_sz = 0,
.fft_hdr_len = 16,
.max_fft_bins = 512,
}, },
.interface_modes = BIT(NL80211_IFTYPE_STATION) | .interface_modes = BIT(NL80211_IFTYPE_STATION) |
...@@ -156,6 +162,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { ...@@ -156,6 +162,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.spectral = { .spectral = {
.fft_sz = 0, .fft_sz = 0,
.fft_pad_sz = 0, .fft_pad_sz = 0,
.summary_pad_sz = 0,
.fft_hdr_len = 0,
.max_fft_bins = 0,
}, },
.interface_modes = BIT(NL80211_IFTYPE_STATION) | .interface_modes = BIT(NL80211_IFTYPE_STATION) |
...@@ -244,6 +253,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = { ...@@ -244,6 +253,9 @@ static const struct ath11k_hw_params ath11k_hw_params[] = {
.spectral = { .spectral = {
.fft_sz = 0, .fft_sz = 0,
.fft_pad_sz = 0, .fft_pad_sz = 0,
.summary_pad_sz = 0,
.fft_hdr_len = 0,
.max_fft_bins = 0,
}, },
.interface_modes = BIT(NL80211_IFTYPE_STATION) | .interface_modes = BIT(NL80211_IFTYPE_STATION) |
......
...@@ -157,6 +157,9 @@ struct ath11k_hw_params { ...@@ -157,6 +157,9 @@ struct ath11k_hw_params {
struct { struct {
u8 fft_sz; u8 fft_sz;
u8 fft_pad_sz; u8 fft_pad_sz;
u8 summary_pad_sz;
u8 fft_hdr_len;
u16 max_fft_bins;
} spectral; } spectral;
u16 interface_modes; u16 interface_modes;
......
...@@ -11,20 +11,20 @@ ...@@ -11,20 +11,20 @@
#define ATH11K_SPECTRAL_EVENT_TIMEOUT_MS 1 #define ATH11K_SPECTRAL_EVENT_TIMEOUT_MS 1
#define ATH11K_SPECTRAL_DWORD_SIZE 4 #define ATH11K_SPECTRAL_DWORD_SIZE 4
#define ATH11K_SPECTRAL_ATH11K_MIN_BINS 64 #define ATH11K_SPECTRAL_MIN_BINS 64
#define ATH11K_SPECTRAL_ATH11K_MIN_IB_BINS 32 #define ATH11K_SPECTRAL_MIN_IB_BINS (ATH11K_SPECTRAL_MIN_BINS >> 1)
#define ATH11K_SPECTRAL_ATH11K_MAX_IB_BINS 256 #define ATH11K_SPECTRAL_MAX_IB_BINS(x) ((x)->hw_params.spectral.max_fft_bins >> 1)
#define ATH11K_SPECTRAL_SCAN_COUNT_MAX 4095 #define ATH11K_SPECTRAL_SCAN_COUNT_MAX 4095
/* Max channel computed by sum of 2g and 5g band channels */ /* Max channel computed by sum of 2g and 5g band channels */
#define ATH11K_SPECTRAL_TOTAL_CHANNEL 41 #define ATH11K_SPECTRAL_TOTAL_CHANNEL 41
#define ATH11K_SPECTRAL_SAMPLES_PER_CHANNEL 70 #define ATH11K_SPECTRAL_SAMPLES_PER_CHANNEL 70
#define ATH11K_SPECTRAL_PER_SAMPLE_SIZE (sizeof(struct fft_sample_ath11k) + \ #define ATH11K_SPECTRAL_PER_SAMPLE_SIZE(x) (sizeof(struct fft_sample_ath11k) + \
ATH11K_SPECTRAL_ATH11K_MAX_IB_BINS) ATH11K_SPECTRAL_MAX_IB_BINS(x))
#define ATH11K_SPECTRAL_TOTAL_SAMPLE (ATH11K_SPECTRAL_TOTAL_CHANNEL * \ #define ATH11K_SPECTRAL_TOTAL_SAMPLE (ATH11K_SPECTRAL_TOTAL_CHANNEL * \
ATH11K_SPECTRAL_SAMPLES_PER_CHANNEL) ATH11K_SPECTRAL_SAMPLES_PER_CHANNEL)
#define ATH11K_SPECTRAL_SUB_BUFF_SIZE ATH11K_SPECTRAL_PER_SAMPLE_SIZE #define ATH11K_SPECTRAL_SUB_BUFF_SIZE(x) ATH11K_SPECTRAL_PER_SAMPLE_SIZE(x)
#define ATH11K_SPECTRAL_NUM_SUB_BUF ATH11K_SPECTRAL_TOTAL_SAMPLE #define ATH11K_SPECTRAL_NUM_SUB_BUF ATH11K_SPECTRAL_TOTAL_SAMPLE
#define ATH11K_SPECTRAL_20MHZ 20 #define ATH11K_SPECTRAL_20MHZ 20
...@@ -442,8 +442,8 @@ static ssize_t ath11k_write_file_spectral_bins(struct file *file, ...@@ -442,8 +442,8 @@ static ssize_t ath11k_write_file_spectral_bins(struct file *file,
if (kstrtoul(buf, 0, &val)) if (kstrtoul(buf, 0, &val))
return -EINVAL; return -EINVAL;
if (val < ATH11K_SPECTRAL_ATH11K_MIN_BINS || if (val < ATH11K_SPECTRAL_MIN_BINS ||
val > SPECTRAL_ATH11K_MAX_NUM_BINS) val > ar->ab->hw_params.spectral.max_fft_bins)
return -EINVAL; return -EINVAL;
if (!is_power_of_2(val)) if (!is_power_of_2(val))
...@@ -594,7 +594,7 @@ int ath11k_spectral_process_fft(struct ath11k *ar, ...@@ -594,7 +594,7 @@ int ath11k_spectral_process_fft(struct ath11k *ar,
tlv_len = FIELD_GET(SPECTRAL_TLV_HDR_LEN, __le32_to_cpu(tlv->header)); tlv_len = FIELD_GET(SPECTRAL_TLV_HDR_LEN, __le32_to_cpu(tlv->header));
/* convert Dword into bytes */ /* convert Dword into bytes */
tlv_len *= ATH11K_SPECTRAL_DWORD_SIZE; tlv_len *= ATH11K_SPECTRAL_DWORD_SIZE;
bin_len = tlv_len - (sizeof(*fft_report) - sizeof(*tlv)); bin_len = tlv_len - ab->hw_params.spectral.fft_hdr_len;
if (data_len < (bin_len + sizeof(*fft_report))) { if (data_len < (bin_len + sizeof(*fft_report))) {
ath11k_warn(ab, "mismatch in expected bin len %d and data len %d\n", ath11k_warn(ab, "mismatch in expected bin len %d and data len %d\n",
...@@ -607,8 +607,8 @@ int ath11k_spectral_process_fft(struct ath11k *ar, ...@@ -607,8 +607,8 @@ int ath11k_spectral_process_fft(struct ath11k *ar,
/* Only In-band bins are useful to user for visualize */ /* Only In-band bins are useful to user for visualize */
num_bins >>= 1; num_bins >>= 1;
if (num_bins < ATH11K_SPECTRAL_ATH11K_MIN_IB_BINS || if (num_bins < ATH11K_SPECTRAL_MIN_IB_BINS ||
num_bins > ATH11K_SPECTRAL_ATH11K_MAX_IB_BINS || num_bins > ATH11K_SPECTRAL_MAX_IB_BINS(ab) ||
!is_power_of_2(num_bins)) { !is_power_of_2(num_bins)) {
ath11k_warn(ab, "Invalid num of bins %d\n", num_bins); ath11k_warn(ab, "Invalid num of bins %d\n", num_bins);
return -EINVAL; return -EINVAL;
...@@ -689,7 +689,7 @@ static int ath11k_spectral_process_data(struct ath11k *ar, ...@@ -689,7 +689,7 @@ static int ath11k_spectral_process_data(struct ath11k *ar,
goto unlock; goto unlock;
} }
sample_sz = sizeof(*fft_sample) + ATH11K_SPECTRAL_ATH11K_MAX_IB_BINS; sample_sz = sizeof(*fft_sample) + ATH11K_SPECTRAL_MAX_IB_BINS(ab);
fft_sample = kmalloc(sample_sz, GFP_ATOMIC); fft_sample = kmalloc(sample_sz, GFP_ATOMIC);
if (!fft_sample) { if (!fft_sample) {
ret = -ENOBUFS; ret = -ENOBUFS;
...@@ -737,7 +737,8 @@ static int ath11k_spectral_process_data(struct ath11k *ar, ...@@ -737,7 +737,8 @@ static int ath11k_spectral_process_data(struct ath11k *ar,
* is 4 DWORD size (16 bytes). * is 4 DWORD size (16 bytes).
* Need to remove this workaround once HW bug fixed * Need to remove this workaround once HW bug fixed
*/ */
tlv_len = sizeof(*summary) - sizeof(*tlv); tlv_len = sizeof(*summary) - sizeof(*tlv) +
ab->hw_params.spectral.summary_pad_sz;
if (tlv_len < (sizeof(*summary) - sizeof(*tlv))) { if (tlv_len < (sizeof(*summary) - sizeof(*tlv))) {
ath11k_warn(ab, "failed to parse spectral summary at bytes %d tlv_len:%d\n", ath11k_warn(ab, "failed to parse spectral summary at bytes %d tlv_len:%d\n",
...@@ -900,7 +901,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar) ...@@ -900,7 +901,7 @@ static inline int ath11k_spectral_debug_register(struct ath11k *ar)
ar->spectral.rfs_scan = relay_open("spectral_scan", ar->spectral.rfs_scan = relay_open("spectral_scan",
ar->debug.debugfs_pdev, ar->debug.debugfs_pdev,
ATH11K_SPECTRAL_SUB_BUFF_SIZE, ATH11K_SPECTRAL_SUB_BUFF_SIZE(ar->ab),
ATH11K_SPECTRAL_NUM_SUB_BUF, ATH11K_SPECTRAL_NUM_SUB_BUF,
&rfs_scan_cb, NULL); &rfs_scan_cb, NULL);
if (!ar->spectral.rfs_scan) { if (!ar->spectral.rfs_scan) {
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
* could be acquired so far. * could be acquired so far.
*/ */
#define SPECTRAL_ATH10K_MAX_NUM_BINS 256 #define SPECTRAL_ATH10K_MAX_NUM_BINS 256
#define SPECTRAL_ATH11K_MAX_NUM_BINS 512
/* FFT sample format given to userspace via debugfs. /* FFT sample format given to userspace via debugfs.
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment