| .. | .. |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | sample = sample_end - SPECTRAL_HT20_SAMPLE_LEN + 1; |
|---|
| 61 | 61 | |
|---|
| 62 | | - max_index = spectral_max_index(mag_info->all_bins, |
|---|
| 63 | | - SPECTRAL_HT20_NUM_BINS); |
|---|
| 62 | + max_index = spectral_max_index_ht20(mag_info->all_bins); |
|---|
| 64 | 63 | max_magnitude = spectral_max_magnitude(mag_info->all_bins); |
|---|
| 65 | 64 | |
|---|
| 66 | 65 | max_exp = mag_info->max_exp & 0xf; |
|---|
| .. | .. |
|---|
| 72 | 71 | if (bytes_read < SPECTRAL_HT20_SAMPLE_LEN && max_index < 1) |
|---|
| 73 | 72 | return -1; |
|---|
| 74 | 73 | |
|---|
| 75 | | - if (sample[max_index] != (max_magnitude >> max_exp)) |
|---|
| 74 | + if ((sample[max_index] & 0xf8) != ((max_magnitude >> max_exp) & 0xf8)) |
|---|
| 76 | 75 | return -1; |
|---|
| 77 | 76 | else |
|---|
| 78 | 77 | return 0; |
|---|
| .. | .. |
|---|
| 100 | 99 | sample = sample_end - SPECTRAL_HT20_40_SAMPLE_LEN + 1; |
|---|
| 101 | 100 | |
|---|
| 102 | 101 | lower_mag = spectral_max_magnitude(mag_info->lower_bins); |
|---|
| 103 | | - lower_max_index = spectral_max_index(mag_info->lower_bins, |
|---|
| 104 | | - SPECTRAL_HT20_40_NUM_BINS); |
|---|
| 102 | + lower_max_index = spectral_max_index_ht40(mag_info->lower_bins); |
|---|
| 105 | 103 | |
|---|
| 106 | 104 | upper_mag = spectral_max_magnitude(mag_info->upper_bins); |
|---|
| 107 | | - upper_max_index = spectral_max_index(mag_info->upper_bins, |
|---|
| 108 | | - SPECTRAL_HT20_40_NUM_BINS); |
|---|
| 105 | + upper_max_index = spectral_max_index_ht40(mag_info->upper_bins); |
|---|
| 109 | 106 | |
|---|
| 110 | 107 | max_exp = mag_info->max_exp & 0xf; |
|---|
| 111 | 108 | |
|---|
| .. | .. |
|---|
| 117 | 114 | ((upper_max_index < 1) || (lower_max_index < 1))) |
|---|
| 118 | 115 | return -1; |
|---|
| 119 | 116 | |
|---|
| 120 | | - /* Some time hardware messes up the index and adds |
|---|
| 121 | | - * the index of the middle point (dc_pos). Try to fix it. |
|---|
| 122 | | - */ |
|---|
| 123 | | - if ((upper_max_index - dc_pos > 0) && |
|---|
| 124 | | - (sample[upper_max_index] == (upper_mag >> max_exp))) |
|---|
| 125 | | - upper_max_index -= dc_pos; |
|---|
| 126 | | - |
|---|
| 127 | | - if ((lower_max_index - dc_pos > 0) && |
|---|
| 128 | | - (sample[lower_max_index - dc_pos] == (lower_mag >> max_exp))) |
|---|
| 129 | | - lower_max_index -= dc_pos; |
|---|
| 130 | | - |
|---|
| 131 | | - if ((sample[upper_max_index + dc_pos] != (upper_mag >> max_exp)) || |
|---|
| 132 | | - (sample[lower_max_index] != (lower_mag >> max_exp))) |
|---|
| 117 | + if (((sample[upper_max_index + dc_pos] & 0xf8) != |
|---|
| 118 | + ((upper_mag >> max_exp) & 0xf8)) || |
|---|
| 119 | + ((sample[lower_max_index] & 0xf8) != |
|---|
| 120 | + ((lower_mag >> max_exp) & 0xf8))) |
|---|
| 133 | 121 | return -1; |
|---|
| 134 | 122 | else |
|---|
| 135 | 123 | return 0; |
|---|
| .. | .. |
|---|
| 169 | 157 | magnitude = spectral_max_magnitude(mag_info->all_bins); |
|---|
| 170 | 158 | fft_sample_20.max_magnitude = __cpu_to_be16(magnitude); |
|---|
| 171 | 159 | |
|---|
| 172 | | - max_index = spectral_max_index(mag_info->all_bins, |
|---|
| 173 | | - SPECTRAL_HT20_NUM_BINS); |
|---|
| 160 | + max_index = spectral_max_index_ht20(mag_info->all_bins); |
|---|
| 174 | 161 | fft_sample_20.max_index = max_index; |
|---|
| 175 | 162 | |
|---|
| 176 | 163 | bitmap_w = spectral_bitmap_weight(mag_info->all_bins); |
|---|
| .. | .. |
|---|
| 188 | 175 | magnitude >> max_exp, |
|---|
| 189 | 176 | max_index); |
|---|
| 190 | 177 | |
|---|
| 191 | | - if (fft_sample_20.data[max_index] != (magnitude >> max_exp)) { |
|---|
| 178 | + if ((fft_sample_20.data[max_index] & 0xf8) != |
|---|
| 179 | + ((magnitude >> max_exp) & 0xf8)) { |
|---|
| 192 | 180 | ath_dbg(common, SPECTRAL_SCAN, "Magnitude mismatch !\n"); |
|---|
| 193 | 181 | ret = -1; |
|---|
| 194 | 182 | } |
|---|
| .. | .. |
|---|
| 302 | 290 | upper_mag = spectral_max_magnitude(mag_info->upper_bins); |
|---|
| 303 | 291 | fft_sample_40.upper_max_magnitude = __cpu_to_be16(upper_mag); |
|---|
| 304 | 292 | |
|---|
| 305 | | - lower_max_index = spectral_max_index(mag_info->lower_bins, |
|---|
| 306 | | - SPECTRAL_HT20_40_NUM_BINS); |
|---|
| 293 | + lower_max_index = spectral_max_index_ht40(mag_info->lower_bins); |
|---|
| 307 | 294 | fft_sample_40.lower_max_index = lower_max_index; |
|---|
| 308 | 295 | |
|---|
| 309 | | - upper_max_index = spectral_max_index(mag_info->upper_bins, |
|---|
| 310 | | - SPECTRAL_HT20_40_NUM_BINS); |
|---|
| 296 | + upper_max_index = spectral_max_index_ht40(mag_info->upper_bins); |
|---|
| 311 | 297 | fft_sample_40.upper_max_index = upper_max_index; |
|---|
| 312 | 298 | |
|---|
| 313 | 299 | lower_bitmap_w = spectral_bitmap_weight(mag_info->lower_bins); |
|---|
| .. | .. |
|---|
| 331 | 317 | upper_mag >> max_exp, |
|---|
| 332 | 318 | upper_max_index); |
|---|
| 333 | 319 | |
|---|
| 334 | | - /* Some time hardware messes up the index and adds |
|---|
| 335 | | - * the index of the middle point (dc_pos). Try to fix it. |
|---|
| 336 | | - */ |
|---|
| 337 | | - if ((upper_max_index - dc_pos > 0) && |
|---|
| 338 | | - (fft_sample_40.data[upper_max_index] == (upper_mag >> max_exp))) { |
|---|
| 339 | | - upper_max_index -= dc_pos; |
|---|
| 340 | | - fft_sample_40.upper_max_index = upper_max_index; |
|---|
| 341 | | - } |
|---|
| 342 | | - |
|---|
| 343 | | - if ((lower_max_index - dc_pos > 0) && |
|---|
| 344 | | - (fft_sample_40.data[lower_max_index - dc_pos] == |
|---|
| 345 | | - (lower_mag >> max_exp))) { |
|---|
| 346 | | - lower_max_index -= dc_pos; |
|---|
| 347 | | - fft_sample_40.lower_max_index = lower_max_index; |
|---|
| 348 | | - } |
|---|
| 349 | | - |
|---|
| 350 | 320 | /* Check if we got the expected magnitude values at |
|---|
| 351 | 321 | * the expected bins |
|---|
| 352 | 322 | */ |
|---|
| 353 | | - if ((fft_sample_40.data[upper_max_index + dc_pos] |
|---|
| 354 | | - != (upper_mag >> max_exp)) || |
|---|
| 355 | | - (fft_sample_40.data[lower_max_index] |
|---|
| 356 | | - != (lower_mag >> max_exp))) { |
|---|
| 323 | + if (((fft_sample_40.data[upper_max_index + dc_pos] & 0xf8) |
|---|
| 324 | + != ((upper_mag >> max_exp) & 0xf8)) || |
|---|
| 325 | + ((fft_sample_40.data[lower_max_index] & 0xf8) |
|---|
| 326 | + != ((lower_mag >> max_exp) & 0xf8))) { |
|---|
| 357 | 327 | ath_dbg(common, SPECTRAL_SCAN, "Magnitude mismatch !\n"); |
|---|
| 358 | 328 | ret = -1; |
|---|
| 359 | 329 | } |
|---|
| .. | .. |
|---|
| 501 | 471 | u8 sample_buf[SPECTRAL_SAMPLE_MAX_LEN] = {0}; |
|---|
| 502 | 472 | struct ath_hw *ah = spec_priv->ah; |
|---|
| 503 | 473 | struct ath_common *common = ath9k_hw_common(spec_priv->ah); |
|---|
| 474 | + struct ath_softc *sc = (struct ath_softc *)common->priv; |
|---|
| 504 | 475 | u8 num_bins, *vdata = (u8 *)hdr; |
|---|
| 505 | 476 | struct ath_radar_info *radar_info; |
|---|
| 506 | 477 | int len = rs->rs_datalen; |
|---|
| .. | .. |
|---|
| 649 | 620 | sample_buf, sample_len, |
|---|
| 650 | 621 | sample_bytes); |
|---|
| 651 | 622 | |
|---|
| 652 | | - fft_handler(rs, spec_priv, sample_buf, |
|---|
| 653 | | - tsf, freq, chan_type); |
|---|
| 623 | + ret = fft_handler(rs, spec_priv, sample_buf, |
|---|
| 624 | + tsf, freq, chan_type); |
|---|
| 625 | + |
|---|
| 626 | + if (ret == 0) |
|---|
| 627 | + RX_STAT_INC(sc, rx_spectral_sample_good); |
|---|
| 628 | + else |
|---|
| 629 | + RX_STAT_INC(sc, rx_spectral_sample_err); |
|---|
| 654 | 630 | |
|---|
| 655 | 631 | memset(sample_buf, 0, SPECTRAL_SAMPLE_MAX_LEN); |
|---|
| 656 | 632 | |
|---|
| .. | .. |
|---|
| 665 | 641 | ret = fft_handler(rs, spec_priv, sample_start, |
|---|
| 666 | 642 | tsf, freq, chan_type); |
|---|
| 667 | 643 | |
|---|
| 644 | + if (ret == 0) |
|---|
| 645 | + RX_STAT_INC(sc, rx_spectral_sample_good); |
|---|
| 646 | + else |
|---|
| 647 | + RX_STAT_INC(sc, rx_spectral_sample_err); |
|---|
| 648 | + |
|---|
| 668 | 649 | /* Mix the received bins to the /dev/random |
|---|
| 669 | 650 | * pool |
|---|
| 670 | 651 | */ |
|---|
| .. | .. |
|---|
| 675 | 656 | * loop. |
|---|
| 676 | 657 | */ |
|---|
| 677 | 658 | if (len <= fft_len + 2) |
|---|
| 678 | | - break; |
|---|
| 659 | + return 1; |
|---|
| 679 | 660 | |
|---|
| 680 | 661 | sample_start = &vdata[i + 1]; |
|---|
| 681 | 662 | |
|---|
| .. | .. |
|---|
| 1058 | 1039 | |
|---|
| 1059 | 1040 | buf_file = debugfs_create_file(filename, mode, parent, buf, |
|---|
| 1060 | 1041 | &relay_file_operations); |
|---|
| 1042 | + if (IS_ERR(buf_file)) |
|---|
| 1043 | + return NULL; |
|---|
| 1044 | + |
|---|
| 1061 | 1045 | *is_global = 1; |
|---|
| 1062 | 1046 | return buf_file; |
|---|
| 1063 | 1047 | } |
|---|