These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / net / wireless / ath / ath10k / spectral.c
index d22addf..4671cfb 100644 (file)
@@ -57,7 +57,7 @@ static uint8_t get_max_exp(s8 max_index, u16 max_magnitude, size_t bin_len,
 }
 
 int ath10k_spectral_process_fft(struct ath10k *ar,
-                               const struct wmi_phyerr *phyerr,
+                               struct wmi_phyerr_ev_arg *phyerr,
                                const struct phyerr_fft_report *fftr,
                                size_t bin_len, u64 tsf)
 {
@@ -73,6 +73,15 @@ int ath10k_spectral_process_fft(struct ath10k *ar,
        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);
 
@@ -118,15 +127,14 @@ int ath10k_spectral_process_fft(struct ath10k *ar,
        fft_sample->total_gain_db = __cpu_to_be16(total_gain_db);
        fft_sample->base_pwr_db = __cpu_to_be16(base_pwr_db);
 
-       freq1 = __le16_to_cpu(phyerr->freq1);
-       freq2 = __le16_to_cpu(phyerr->freq2);
+       freq1 = phyerr->freq1;
+       freq2 = phyerr->freq2;
        fft_sample->freq1 = __cpu_to_be16(freq1);
        fft_sample->freq2 = __cpu_to_be16(freq2);
 
        chain_idx = MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX);
 
-       fft_sample->noise = __cpu_to_be16(
-                       __le16_to_cpu(phyerr->nf_chains[chain_idx]));
+       fft_sample->noise = __cpu_to_be16(phyerr->nf_chains[chain_idx]);
 
        bins = (u8 *)fftr;
        bins += sizeof(*fftr);
@@ -519,9 +527,12 @@ int ath10k_spectral_vif_stop(struct ath10k_vif *arvif)
 
 int ath10k_spectral_create(struct ath10k *ar)
 {
+       /* The buffer size covers whole channels in dual bands up to 128 bins.
+        * Scan with bigger than 128 bins needs to be run on single band each.
+        */
        ar->spectral.rfs_chan_spec_scan = relay_open("spectral_scan",
                                                     ar->debug.debugfs_phy,
-                                                    1024, 256,
+                                                    1140, 2500,
                                                     &rfs_spec_scan_cb, NULL);
        debugfs_create_file("spectral_scan_ctl",
                            S_IRUSR | S_IWUSR,