1 /* 2 * Copyright (c) 2011, 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _SPECTRAL_IOCTL_H_ 21 #define _SPECTRAL_IOCTL_H_ 22 #include <wlan_dfs_ioctl.h> 23 24 #ifndef AH_MAX_CHAINS 25 #define AH_MAX_CHAINS 3 26 #endif 27 28 /* Compile time Assert */ 29 #define SPECTRAL_COMPILE_TIME_ASSERT(assertion_name, predicate) \ 30 typedef char assertion_name[(predicate) ? 1 : -1] 31 32 /* 33 * ioctl defines 34 */ 35 36 #define SPECTRAL_SET_CONFIG (DFS_LAST_IOCTL + 1) 37 #define SPECTRAL_GET_CONFIG (DFS_LAST_IOCTL + 2) 38 #define SPECTRAL_SHOW_INTERFERENCE (DFS_LAST_IOCTL + 3) 39 #define SPECTRAL_ENABLE_SCAN (DFS_LAST_IOCTL + 4) 40 #define SPECTRAL_DISABLE_SCAN (DFS_LAST_IOCTL + 5) 41 #define SPECTRAL_ACTIVATE_SCAN (DFS_LAST_IOCTL + 6) 42 #define SPECTRAL_STOP_SCAN (DFS_LAST_IOCTL + 7) 43 #define SPECTRAL_SET_DEBUG_LEVEL (DFS_LAST_IOCTL + 8) 44 #define SPECTRAL_IS_ACTIVE (DFS_LAST_IOCTL + 9) 45 #define SPECTRAL_IS_ENABLED (DFS_LAST_IOCTL + 10) 46 #define SPECTRAL_CLASSIFY_SCAN (DFS_LAST_IOCTL + 11) 47 #define SPECTRAL_GET_CLASSIFIER_CONFIG (DFS_LAST_IOCTL + 12) 48 #define SPECTRAL_EACS (DFS_LAST_IOCTL + 13) 49 #define SPECTRAL_ACTIVATE_FULL_SCAN (DFS_LAST_IOCTL + 14) 50 #define SPECTRAL_STOP_FULL_SCAN (DFS_LAST_IOCTL + 15) 51 #define SPECTRAL_GET_CAPABILITY_INFO (DFS_LAST_IOCTL + 16) 52 #define SPECTRAL_GET_DIAG_STATS (DFS_LAST_IOCTL + 17) 53 #define SPECTRAL_GET_CHAN_WIDTH (DFS_LAST_IOCTL + 18) 54 #define SPECTRAL_GET_CHANINFO (DFS_LAST_IOCTL + 19) 55 #define SPECTRAL_CLEAR_CHANINFO (DFS_LAST_IOCTL + 20) 56 #define SPECTRAL_SET_ICM_ACTIVE (DFS_LAST_IOCTL + 21) 57 #define SPECTRAL_GET_NOMINAL_NOISEFLOOR (DFS_LAST_IOCTL + 22) 58 #define SPECTRAL_GET_DEBUG_LEVEL (DFS_LAST_IOCTL + 23) 59 #define SPECTRAL_SET_DMA_DEBUG (DFS_LAST_IOCTL + 24) 60 61 /* 62 * Increase spectral sub version if struct spectral_samp_msg updated. 63 */ 64 #define SPECTRAL_VERSION (3) 65 #define SPECTRAL_SUB_VERSION (1) 66 67 /* 68 * ioctl parameter types 69 */ 70 enum spectral_params { 71 SPECTRAL_PARAM_FFT_PERIOD, 72 SPECTRAL_PARAM_SCAN_PERIOD, 73 SPECTRAL_PARAM_FFT_RECAPTURE, 74 SPECTRAL_PARAM_SCAN_COUNT, 75 SPECTRAL_PARAM_SHORT_REPORT, 76 SPECTRAL_PARAM_SPECT_PRI, 77 SPECTRAL_PARAM_FFT_SIZE, 78 SPECTRAL_PARAM_GC_ENA, 79 SPECTRAL_PARAM_RESTART_ENA, 80 SPECTRAL_PARAM_NOISE_FLOOR_REF, 81 SPECTRAL_PARAM_INIT_DELAY, 82 SPECTRAL_PARAM_NB_TONE_THR, 83 SPECTRAL_PARAM_STR_BIN_THR, 84 SPECTRAL_PARAM_WB_RPT_MODE, 85 SPECTRAL_PARAM_RSSI_RPT_MODE, 86 SPECTRAL_PARAM_RSSI_THR, 87 SPECTRAL_PARAM_PWR_FORMAT, 88 SPECTRAL_PARAM_RPT_MODE, 89 SPECTRAL_PARAM_BIN_SCALE, 90 SPECTRAL_PARAM_DBM_ADJ, 91 SPECTRAL_PARAM_CHN_MASK, 92 SPECTRAL_PARAM_ACTIVE, 93 SPECTRAL_PARAM_STOP, 94 SPECTRAL_PARAM_ENABLE, 95 SPECTRAL_PARAM_FREQUENCY, 96 SPECTRAL_PARAM_CHAN_FREQUENCY, 97 SPECTRAL_PARAM_CHAN_WIDTH, 98 SPECTRAL_PARAM_MAX, 99 }; 100 101 /** 102 * enum spectral_report_mode: Spectral report mode 103 * @SPECTRAL_REPORT_MODE_0: No FFT report (only spectral scan summary report) 104 * @SPECTRAL_REPORT_MODE_1: FFT report header + spectral scan summary report 105 * @SPECTRAL_REPORT_MODE_2: FFt report header + in-band bins per 106 * FFT (half of the number of FFT bins), where the 107 * FFT input is sampled at two times the channel 108 * bandwidth + spectral scan summary report 109 * @SPECTRAL_REPORT_MODE_3: FFT report header + all bins per FFT, where the FFT 110 * input is sampled at two times the channel bandwidth 111 * + spectral scan summary report 112 * @SPECTRAL_REPORT_MODE_MAX: Max number of report modes 113 */ 114 enum spectral_report_mode { 115 SPECTRAL_REPORT_MODE_0, 116 SPECTRAL_REPORT_MODE_1, 117 SPECTRAL_REPORT_MODE_2, 118 SPECTRAL_REPORT_MODE_3, 119 SPECTRAL_REPORT_MODE_MAX, 120 }; 121 122 /** 123 * enum spectral_pwr_format: Spectral FFT bin pwr format 124 * @SPECTRAL_PWR_FORMAT_LINEAR: Linear mode 125 * @SPECTRAL_PWR_FORMAT_DBM: dBm mode 126 */ 127 enum spectral_pwr_format { 128 SPECTRAL_PWR_FORMAT_LINEAR = 0, 129 SPECTRAL_PWR_FORMAT_DBM = 1, 130 }; 131 132 /** 133 * enum spectral_scan_priority: Spectral scan priority 134 * @SPECTRAL_SCAN_PRIORITY_LOW: Low priority Spectral scan 135 * @SPECTRAL_SCAN_PRIORITY_HIGH: High priority Spectral scan 136 */ 137 enum spectral_scan_priority { 138 SPECTRAL_SCAN_PRIORITY_LOW = 0, 139 SPECTRAL_SCAN_PRIORITY_HIGH = 1, 140 }; 141 142 /** 143 * enum spectral_fft_size : FFT size values 144 * @SPECTRAL_FFT_SIZE_INVALID: Invalid FFT size 145 * @SPECTRAL_FFT_SIZE_1: FFT size 1 146 * @SPECTRAL_FFT_SIZE_2: FFT size 2 147 * @SPECTRAL_FFT_SIZE_3: FFT size 3 148 * @SPECTRAL_FFT_SIZE_4: FFT size 4 149 * @SPECTRAL_FFT_SIZE_5: FFT size 5 150 * @SPECTRAL_FFT_SIZE_6: FFT size 6 151 * @SPECTRAL_FFT_SIZE_7: FFT size 7 152 * @SPECTRAL_FFT_SIZE_8: FFT size 8 153 * @SPECTRAL_FFT_SIZE_9: FFT size 9 154 * @SPECTRAL_FFT_SIZE_10: FFT size 10 155 * @SPECTRAL_FFT_SIZE_MAX: Max number of FFT size 156 */ 157 enum spectral_fft_size { 158 SPECTRAL_FFT_SIZE_INVALID, 159 SPECTRAL_FFT_SIZE_1, 160 SPECTRAL_FFT_SIZE_2, 161 SPECTRAL_FFT_SIZE_3, 162 SPECTRAL_FFT_SIZE_4, 163 SPECTRAL_FFT_SIZE_5, 164 SPECTRAL_FFT_SIZE_6, 165 SPECTRAL_FFT_SIZE_7, 166 SPECTRAL_FFT_SIZE_8, 167 SPECTRAL_FFT_SIZE_9, 168 SPECTRAL_FFT_SIZE_10, 169 SPECTRAL_FFT_SIZE_MAX, 170 }; 171 172 /** 173 * enum spectral_scan_mode - Spectral scan mode 174 * @SPECTRAL_SCAN_MODE_NORMAL: Normal mode 175 * @SPECTRAL_SCAN_MODE_AGILE: Agile mode 176 * @SPECTRAL_SCAN_MODE_MAX: Max number of Spectral modes 177 * @SPECTRAL_SCAN_MODE_INVALID: Invalid Spectral mode 178 */ 179 enum spectral_scan_mode { 180 SPECTRAL_SCAN_MODE_NORMAL, 181 SPECTRAL_SCAN_MODE_AGILE, 182 SPECTRAL_SCAN_MODE_MAX, 183 SPECTRAL_SCAN_MODE_INVALID = 0xff, 184 }; 185 186 /** 187 * enum spectral_chan_width - Spectral-specific channel width enum 188 * @SPECTRAL_CH_WIDTH_20MHZ: 20 mhz width 189 * @SPECTRAL_CH_WIDTH_40MHZ: 40 mhz width 190 * @SPECTRAL_CH_WIDTH_80MHZ: 80 mhz width 191 * @SPECTRAL_CH_WIDTH_160MHZ: 160 mhz width 192 * @SPECTRAL_CH_WIDTH_80P80MHZ: 80+80 mhz width 193 * @SPECTRAL_CH_WIDTH_5MHZ: 5 mhz width 194 * @SPECTRAL_CH_WIDTH_10MHZ: 10 mhz width 195 * @SPECTRAL_CH_WIDTH_320MHZ: 320 mhz width 196 * @SPECTRAL_CH_WIDTH_MAX: Max possible width 197 * @SPECTRAL_CH_WIDTH_INVALID: invalid width 198 */ 199 enum spectral_chan_width { 200 SPECTRAL_CH_WIDTH_20MHZ, 201 SPECTRAL_CH_WIDTH_40MHZ, 202 SPECTRAL_CH_WIDTH_80MHZ, 203 SPECTRAL_CH_WIDTH_160MHZ, 204 SPECTRAL_CH_WIDTH_80P80MHZ, 205 SPECTRAL_CH_WIDTH_320MHZ, 206 SPECTRAL_CH_WIDTH_5MHZ, 207 SPECTRAL_CH_WIDTH_10MHZ, 208 SPECTRAL_CH_WIDTH_MAX, 209 SPECTRAL_CH_WIDTH_INVALID, 210 }; 211 212 struct spectral_ioctl_params { 213 int16_t spectral_fft_period; 214 int16_t pectral_period; 215 int16_t spectral_count; 216 uint16_t spectral_short_report; 217 uint16_t spectral_pri; 218 }; 219 220 /** 221 * spectral_cap_hw_gen: Definitions for the Spectral hardware generation. 222 * This corresponds to definitions in qca_wlan_vendor_spectral_scan_cap_hw_gen. 223 * @SPECTRAL_CAP_HW_GEN_1: Generation 1 224 * @SPECTRAL_CAP_HW_GEN_2: Generation 2 225 * @SPECTRAL_CAP_HW_GEN_3: Generation 3 226 */ 227 enum spectral_cap_hw_gen { 228 SPECTRAL_CAP_HW_GEN_1 = 0, 229 SPECTRAL_CAP_HW_GEN_2 = 1, 230 SPECTRAL_CAP_HW_GEN_3 = 2, 231 }; 232 233 /** 234 * struct spectral_config_frequency - Spectral scan frequency 235 * @cfreq1: Center frequency (in MHz) of the span of interest(primary 80 MHz 236 * span for 80 + 80 agile scan request) or center frequency (in MHz) 237 * of any WLAN channel in the span of interest. 238 * @cfreq2: Applicable only for Agile Spectral scan request in 80+80 MHz mode. 239 * For 80+80 mode it represents the center frequency (in MHz) of the 240 * secondary 80 MHz span of interest or center frequency (in MHz) of 241 * any WLAN channel in the secondary 80 MHz span of interest. 242 */ 243 struct spectral_config_frequency { 244 uint32_t cfreq1; 245 uint32_t cfreq2; 246 }; 247 248 /** 249 * struct spectral_config - spectral config parameters 250 * @ss_fft_period: Skip interval for FFT reports 251 * @ss_period: Spectral scan period 252 * @ss_recapture Set this to allow FFT recapture if scan period > 52us 253 * @ss_count: # of reports to return from ss_active 254 * @ss_short_report: Set to report only 1 set of FFT results 255 * @radar_bin_thresh_sel: Select threshold to classify strong bin for FFT 256 * @ss_spectral_pri: Priority, and are we doing a noise power cal ? 257 * @ss_fft_size: Defines the number of FFT data points to compute, 258 * defined as a log index num_fft_pts = 259 * 2^ss_fft_size 260 * @ss_gc_ena: Set, to enable targeted gain change before 261 * starting the spectral scan FFT 262 * @ss_restart_ena: Set, to enable abort of receive frames when in high 263 * priority and a spectral scan is queued 264 * @ss_noise_floor_ref: Noise floor reference number (signed) for the 265 * calculation of bin power (dBm) Though stored as an 266 * unsigned this should be treated as a signed 8-bit int. 267 * @ss_init_delay: Disallow spectral scan triggers after tx/rx packets 268 * by setting this delay value to roughly SIFS time 269 * period or greater Delay timer count in units of 0.25us 270 * @ss_nb_tone_thr: Number of strong bins (inclusive) per sub-channel, 271 * below which a signal is declared a narrowband tone 272 * @ss_str_bin_thr: Bin/max_bin ratio threshold over which a bin is 273 * declared strong (for spectral scan bandwidth analysis) 274 * @ss_wb_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER 275 * (phy_error=36), if none of the sub-channels are 276 * deemed narrowband 277 * @ss_rssi_rpt_mode: Set this bit to report spectral scans as EXT_BLOCKER 278 * (phy_error=36), if the ADC RSSI is below the 279 * threshold ss_rssi_thr 280 * @ss_rssi_thr: ADC RSSI must be greater than or equal to this 281 * threshold (signed Db) to ensure spectral scan 282 * reporting with normal phy error codes (please see 283 * ss_rssi_rpt_mode above).Though stored as an unsigned 284 * value, this should be treated as a signed 8-bit int 285 * @ss_pwr_format: Format of frequency bin magnitude for spectral scan 286 * triggered FFTs 0: linear magnitude 287 * 1: log magnitude (20*log10(lin_mag), 1/2 dB step size) 288 * @ss_rpt_mode: Format of per-FFT reports to software for spectral 289 * scan triggered FFTs 290 * 0: No FFT report (only pulse end summary) 291 * 1: 2-dword summary of metrics for each completed FFT 292 * 2: 2-dword summary + 1x-oversampled bins(in-band) per 293 * FFT 294 * 3: 2-dword summary + 2x-oversampled bins (all) per FFT 295 * @ss_bin_scale: Number of LSBs to shift out to scale the FFT bins 296 * for spectral scan triggered FFTs 297 * @ss_dbm_adj: Set (with ss_pwr_format=1), to report bin 298 * magnitudes 299 * converted to dBm power using the noisefloor 300 * calibration results 301 * @ss_chn_mask: Per chain enable mask to select input ADC for search 302 * FFT 303 * @ss_nf_cal: nf calibrated values for ctl+ext 304 * @ss_nf_pwr: nf pwr values for ctl+ext 305 * @ss_nf_temp_data: temperature data taken during nf scan 306 * @ss_frequency: This specifies the frequency span over which Spectral 307 * scan would be carried out. Its value depends on the 308 * Spectral scan mode. 309 * Normal mode:- 310 * Not applicable. Spectral scan would happen in the 311 * operating span. 312 * Agile mode:- 313 * cfreq1 represents the center frequency (in MHz) of 314 * the span of interest(primary 80 MHz span for 80 + 80 315 * agile scan request) or center frequency (in MHz) of 316 * any WLAN channel in the span of interest. cfreq2 is 317 * applicable only for Agile Spectral scan request in 318 * 80+80 MHz mode. For 80+80 mode it represents the 319 * center frequency (in MHz) of the secondary 80 MHz 320 * span of interest or center frequency (in MHz) of 321 * any WLAN channel in the secondary 80 MHz span of 322 * interest. 323 * @ss_bandwidth: Spectral scan bandwidth 324 */ 325 struct spectral_config { 326 uint16_t ss_fft_period; 327 uint16_t ss_period; 328 uint16_t ss_recapture; 329 uint16_t ss_count; 330 uint16_t ss_short_report; 331 uint8_t radar_bin_thresh_sel; 332 uint16_t ss_spectral_pri; 333 uint16_t ss_fft_size; 334 uint16_t ss_gc_ena; 335 uint16_t ss_restart_ena; 336 uint16_t ss_noise_floor_ref; 337 uint16_t ss_init_delay; 338 uint16_t ss_nb_tone_thr; 339 uint16_t ss_str_bin_thr; 340 uint16_t ss_wb_rpt_mode; 341 uint16_t ss_rssi_rpt_mode; 342 uint16_t ss_rssi_thr; 343 uint16_t ss_pwr_format; 344 uint16_t ss_rpt_mode; 345 uint16_t ss_bin_scale; 346 uint16_t ss_dbm_adj; 347 uint16_t ss_chn_mask; 348 int8_t ss_nf_cal[AH_MAX_CHAINS * 2]; 349 int8_t ss_nf_pwr[AH_MAX_CHAINS * 2]; 350 int32_t ss_nf_temp_data; 351 struct spectral_config_frequency ss_frequency; 352 uint16_t ss_bandwidth; 353 }; 354 355 /** 356 * struct spectral_caps - Spectral capabilities structure 357 * @phydiag_cap: Phydiag capability 358 * @radar_cap: Radar detection capability 359 * @spectral_cap: Spectral capability 360 * @advncd_spectral_cap: Advanced spectral capability 361 * @hw_gen: Spectral hw generation as defined in spectral_cap_hw_gen 362 * @is_scaling_params_populated: indicates whether scaling params is populated 363 * @formula_id: formula_id 364 * @low_level_offset: low_level_offset 365 * @high_level_offset: high_level_offset 366 * @rssi_thr: rssi_thr 367 * @default_agc_max_gain: default_agc_max_gain 368 * @agile_spectral_cap: agile Spectral capability for 20/40/80 369 * @agile_spectral_cap_160: agile Spectral capability for 160 MHz 370 * @agile_spectral_cap_80p80: agile Spectral capability for 80p80 371 * @agile_spectral_cap_320: agile Spectral capability for 320 MHz 372 * @num_detectors_20mhz: number of Spectral detectors in 20 MHz 373 * @num_detectors_40mhz: number of Spectral detectors in 40 MHz 374 * @num_detectors_80mhz: number of Spectral detectors in 80 MHz 375 * @num_detectors_160mhz: number of Spectral detectors in 160 MHz 376 * @num_detectors_80p80mhz: number of Spectral detectors in 80p80 MHz 377 * @num_detectors_320mhz: number of Spectral detectors in 320 MHz 378 */ 379 struct spectral_caps { 380 uint8_t phydiag_cap; 381 uint8_t radar_cap; 382 uint8_t spectral_cap; 383 uint8_t advncd_spectral_cap; 384 uint32_t hw_gen; 385 bool is_scaling_params_populated; 386 uint16_t formula_id; 387 int16_t low_level_offset; 388 int16_t high_level_offset; 389 int16_t rssi_thr; 390 uint8_t default_agc_max_gain; 391 bool agile_spectral_cap; 392 bool agile_spectral_cap_160; 393 bool agile_spectral_cap_80p80; 394 bool agile_spectral_cap_320; 395 uint32_t num_detectors_20mhz; 396 uint32_t num_detectors_40mhz; 397 uint32_t num_detectors_80mhz; 398 uint32_t num_detectors_160mhz; 399 uint32_t num_detectors_80p80mhz; 400 uint32_t num_detectors_320mhz; 401 }; 402 403 #define SPECTRAL_IOCTL_PARAM_NOVAL (65535) 404 405 #define MAX_SPECTRAL_CHAINS (3) 406 #define MAX_NUM_BINS (2048) 407 #define MAX_NUM_BINS_PRI80 (1024) 408 #define MAX_NUM_BINS_SEC80 (520) 409 #define MAX_NUM_BINS_5MHZ (32) 410 /* 5 categories x (lower + upper) bands */ 411 #define MAX_INTERF 10 412 #define SPECTRAL_MAC_ADDR_SIZE (6) 413 #define MAX_NUM_FREQ_SPANS (3) 414 #define MAX_NUM_DETECTORS (2) 415 #define MAX_SPECTRAL_PAYLOAD (3028) 416 417 #define SPECTRAL_RECAPTURE_SCAN_PERIOD_THRESHOLD (52) 418 419 /** 420 * enum dcs_int_type - Interference type indicated by DCS 421 * @SPECTRAL_DCS_INT_NONE: No interference 422 * @SPECTRAL_DCS_INT_CW: CW interference 423 * @SPECTRAL_DCS_INT_WIFI: WLAN interference 424 */ 425 enum dcs_int_type { 426 SPECTRAL_DCS_INT_NONE, 427 SPECTRAL_DCS_INT_CW, 428 SPECTRAL_DCS_INT_WIFI 429 }; 430 431 /** 432 * struct interf_rsp - Interference record 433 * @interf_type: eINTERF_TYPE giving type of interference 434 * @interf_min_freq: Minimum frequency in MHz at which interference has been 435 * found 436 * @interf_max_freq: Maximum frequency in MHz at which interference has been 437 * found 438 * @advncd_spectral_cap: Advanced spectral capability 439 */ 440 struct interf_rsp { 441 uint8_t interf_type; 442 uint16_t interf_min_freq; 443 uint16_t interf_max_freq; 444 } __packed; 445 446 /** 447 * struct interf_src_rsp - List of interference sources 448 * @count: Number of interference records 449 * @interf: Array of interference records 450 */ 451 struct interf_src_rsp { 452 uint16_t count; 453 struct interf_rsp interf[MAX_INTERF]; 454 } __packed; 455 456 /** 457 * struct spectral_classifier_params - spectral classifier parameters 458 * @spectral_20_40_mode: Is AP in 20/40 mode? 459 * @spectral_dc_index: DC index 460 * @spectral_dc_in_mhz: DC in MHz 461 * @upper_chan_in_mhz: Upper channel in MHz 462 * @lower_chan_in_mhz: Lower channel in MHz 463 */ 464 struct spectral_classifier_params { 465 int spectral_20_40_mode; 466 int spectral_dc_index; 467 int spectral_dc_in_mhz; 468 int upper_chan_in_mhz; 469 int lower_chan_in_mhz; 470 } __packed; 471 472 #ifdef OPTIMIZED_SAMP_MESSAGE 473 /** 474 * struct samp_edge_extra_bin_info - Spectral edge extra bins Information 475 * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are 476 * delivered. However, there can be additional bins reported for 477 * AR900B version 2.0 and QCA9984 as described next: 478 * AR900B version 2.0: An additional tone is processed on the right 479 * hand side in order to facilitate detection of radar pulses out to 480 * the extreme band-edge of the channel frequency. 481 * Since the HW design processes four tones at a time, 482 * this requires one additional Dword to be added to the 483 * search FFT report. 484 * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary + 485 * 1x-oversampled bins (in-band) per FFT, 486 * then 8 more bins (4 more on left side and 4 more on right side) 487 * are added. 488 * 489 * @num_bins: Number of edge extra bins 490 * @start_bin_idx: Indicates the start index of extra bins 491 */ 492 struct samp_edge_extra_bin_info { 493 uint16_t num_bins; 494 uint16_t start_bin_idx; 495 } __packed; 496 497 /* Compile time assert to check struct size is divisible by 4 Bytes */ 498 SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion, 499 (sizeof(struct samp_edge_extra_bin_info) % 4) 500 == 0); 501 502 /** 503 * struct samp_detector_info - SAMP per-detector information 504 * A detector here refers to the HW carrying out the Spectral scan, to 505 * detect the presence of interferences. 506 * @start_frequency: Indicates start frequency per-detector (in MHz) 507 * @end_frequency: Indicates last frequency per-detector (in MHz) 508 * @timestamp: Indicates Spectral HW timestamp (usec) 509 * @last_tstamp: Indicates the last time stamp 510 * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of 511 * 160Mhz it will be primary 80 segment's timestamp as both primary & secondary 512 * segment's timestamp are expected to be almost equal. 513 * @timestamp_war_offset: Offset calculated based on reset_delay and 514 * last_raw_timestamp. It will be added to raw_timestamp to get timestamp. 515 * @raw_timestamp: Actual FFT timestamp reported by HW 516 * @reset_delay: Time gap between the last spectral report before reset and the 517 * end of reset. It is provided by FW via direct DMA framework. 518 * @left_edge_bins: Number of extra bins on left band edge 519 * @right_edge_bins: Number of extra bins on right band edge 520 * @start_bin_idx: Indicates the first bin index per-detector 521 * @end_bin_idx: Indicates the last bin index per-detector 522 * @max_index: Indicates the index of max magnitude 523 * @max_magnitude: Indicates the maximum magnitude 524 * @noise_floor: Indicates the current noise floor 525 * @rssi: Indicates RSSI 526 * @pri80ind: Indication from hardware that the sample was received on the 527 * primary 80 MHz segment. If this is set for smode = SPECTRAL_SCAN_MODE_AGILE, 528 * it indicates that Spectral scan was carried out on pri80 instead of the 529 * Agile frequency due to a channel switch - Software may choose to ignore 530 * the sample in this case. 531 * @is_sec80: Indicates whether the frequency span corresponds to pri80 or 532 * sec80 (only applicable for 160/80p80 operating_bw for 533 * smode SPECTRAL_SCAN_MODE_NORMAL) 534 */ 535 struct samp_detector_info { 536 uint32_t start_frequency; 537 uint32_t end_frequency; 538 uint32_t timestamp; 539 uint32_t last_tstamp; 540 uint32_t last_raw_timestamp; 541 uint32_t timestamp_war_offset; 542 uint32_t raw_timestamp; 543 uint32_t reset_delay; 544 struct samp_edge_extra_bin_info left_edge_bins; 545 struct samp_edge_extra_bin_info right_edge_bins; 546 uint16_t start_bin_idx; 547 uint16_t end_bin_idx; 548 uint16_t max_index; 549 uint16_t max_magnitude; 550 int16_t noise_floor; 551 int8_t rssi; 552 uint8_t agc_total_gain; 553 uint8_t gainchange; 554 uint8_t pri80ind; 555 uint8_t is_sec80; 556 /* Padding bits to make struct size multiple of 4 bytes */ 557 uint8_t padding_detector_info[1]; 558 } __packed; 559 560 /* Compile time assert to check struct size is divisible by 4 Bytes */ 561 SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion, 562 (sizeof(struct samp_detector_info) % 4) == 0); 563 564 /** 565 * struct samp_freq_span_info - SAMP per-frequency span information 566 * A frequency span here refers to a contiguous span of frequencies in which 567 * Spectral scan and interference detection is carried out. 568 * @detector_info: Per-detector Spectral information 569 * @num_detectors: Number of detectors per span 570 */ 571 struct samp_freq_span_info { 572 struct samp_detector_info detector_info[MAX_NUM_DETECTORS]; 573 uint8_t num_detectors; 574 /* Padding bits to make struct size multiple of 4 bytes */ 575 uint8_t padding_span_info[3]; 576 } __packed; 577 578 /* Compile time assert to check struct size is divisible by 4 Bytes */ 579 SPECTRAL_COMPILE_TIME_ASSERT(struct_size_4byte_assertion, 580 (sizeof(struct samp_freq_span_info) % 4) == 0); 581 582 /** 583 * struct spectral_samp_msg - Spectral SAMP message 584 * @signature: Validates the SAMP message 585 * @target_reset_count: Indicates the number of times target went through 586 * reset routine after spectral was enabled. 587 * @pri20_freq: Primary 20MHz operating frequency in MHz 588 * @cfreq1: Segment 1 centre frequency in MHz 589 * @cfreq2: For 80p80, indicates segment 2 centre frequency in MHz. For 160MHz, 590 * indicates the center frequency of 160MHz span. 591 * @sscan_cfreq1: Normal/Agile scan Center frequency for Segment 1 592 * based on Spectral Scan mode. 593 * @sscan_cfreq2: Normal/Agile scan Center frequency for Segment 2 in case of 594 * 80p80, and for 160MHz center frequency of the 160MHz span based on Spectral 595 * Scan mode. 596 * @bin_pwr_count: Indicates the number of FFT bins 597 * @freq_span_info: Spectral per-contiguous frequency span information 598 * @spectral_upper_rssi: Indicates RSSI of upper band 599 * @spectral_lower_rssi: Indicates RSSI of lower band 600 * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas 601 * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas 602 * @macaddr: Indicates the device interface 603 * @spectral_mode: Spectral scan mode 604 * @operating_bw: Device's operating bandwidth. Values = enum phy_ch_width 605 * @sscan_bw: Normal/Agile Scan BW based on Spectral scan mode. 606 * Values = enum phy_ch_width 607 * @fft_width: Indicates the number of bits representing an FFT bin 608 * @dcs_enabled: Whether DCS is enabled 609 * @int_type: Interference type indicated by DCS. Values = enum dcs_int_type 610 * @num_freq_spans: Number of contiguous frequency spans in operating bandwidth 611 * @bin_pwr: Contains FFT magnitudes 612 */ 613 struct spectral_samp_msg { 614 uint32_t signature; 615 uint32_t target_reset_count; 616 uint32_t pri20_freq; 617 uint32_t cfreq1; 618 uint32_t cfreq2; 619 uint32_t sscan_cfreq1; 620 uint32_t sscan_cfreq2; 621 uint32_t bin_pwr_count; 622 struct samp_freq_span_info freq_span_info[MAX_NUM_FREQ_SPANS]; 623 int8_t spectral_lower_rssi; 624 int8_t spectral_upper_rssi; 625 int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS]; 626 int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS]; 627 uint8_t macaddr[SPECTRAL_MAC_ADDR_SIZE]; 628 uint8_t spectral_mode; 629 uint8_t operating_bw; 630 uint8_t sscan_bw; 631 uint8_t fft_width; 632 uint8_t dcs_enabled; 633 uint8_t int_type; 634 uint8_t num_freq_spans; 635 uint8_t bin_pwr[0]; /*This should be the last item in the structure*/ 636 } __packed; 637 638 #else 639 /** 640 * struct spectral_samp_data - Spectral Analysis Messaging Protocol Data format 641 * @spectral_data_len: Indicates the bin size 642 * @spectral_data_len_sec80: Indicates the bin size for secondary 80 segment 643 * @spectral_rssi: Indicates RSSI 644 * @spectral_rssi_sec80: Indicates RSSI for secondary 80 segment 645 * @spectral_combined_rssi: Indicates combined RSSI from all antennas 646 * @spectral_upper_rssi: Indicates RSSI of upper band 647 * @spectral_lower_rssi: Indicates RSSI of lower band 648 * @spectral_chain_ctl_rssi: RSSI for control channel, for all antennas 649 * @spectral_chain_ext_rssi: RSSI for extension channel, for all antennas 650 * @spectral_max_scale: Indicates scale factor 651 * @spectral_bwinfo: Indicates bandwidth info 652 * @spectral_tstamp: Indicates timestamp 653 * @spectral_max_index: Indicates the index of max magnitude 654 * @spectral_max_index_sec80: Indicates the index of max magnitude for secondary 655 * 80 segment 656 * @spectral_max_mag: Indicates the maximum magnitude 657 * @spectral_max_mag_sec80: Indicates the maximum magnitude for secondary 80 658 * segment 659 * @spectral_max_exp: Indicates the max exp 660 * @spectral_last_tstamp: Indicates the last time stamp 661 * @spectral_upper_max_index: Indicates the index of max mag in upper band 662 * @spectral_lower_max_index: Indicates the index of max mag in lower band 663 * @spectral_nb_upper: Not Used 664 * @spectral_nb_lower: Not Used 665 * @classifier_params: Indicates classifier parameters 666 * @bin_pwr_count: Indicates the number of FFT bins 667 * @lb_edge_extrabins: Number of extra bins on left band edge 668 * @rb_edge_extrabins: Number of extra bins on right band edge 669 * @bin_pwr_count_sec80: Indicates the number of FFT bins in secondary 80 670 * segment 671 * @bin_pwr: Contains FFT magnitudes 672 * @bin_pwr_sec80: Contains FFT magnitudes for the secondary 80 673 * segment 674 * @interf_list: List of interference sources 675 * @noise_floor: Indicates the current noise floor 676 * @noise_floor_sec80: Indicates the current noise floor for secondary 80 677 * segment 678 * @ch_width: Channel width 20/40/80/160 MHz 679 * @spectral_mode: Spectral scan mode 680 * @spectral_pri80ind: Indication from hardware that the sample was 681 * received on the primary 80 MHz segment. If this 682 * is set when smode = SPECTRAL_SCAN_MODE_AGILE, it 683 * indicates that Spectral was carried out on pri80 684 * instead of the Agile frequency due to a 685 * channel switch - Software may choose 686 * to ignore the sample in this case. 687 * @spectral_pri80ind_sec80: Indication from hardware that the sample was 688 * received on the primary 80 MHz segment instead of 689 * the secondary 80 MHz segment due to a channel 690 * switch - Software may choose to ignore the sample 691 * if this is set. Applicable only if smode = 692 * SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz 693 * Spectral operation. 694 * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of 695 * 160Mhz it will be primary 80 segment's timestamp 696 * as both primary & secondary segment's timestamp 697 * are expected to be almost equal. 698 * @timestamp_war_offset: Offset calculated based on reset_delay and 699 * last_raw_timestamp. It will be added to 700 * raw_timestamp to get spectral_tstamp. 701 * @raw_timestamp: Actual FFT timestamp reported by HW on primary 702 * segment. 703 * @raw_timestamp_sec80: Actual FFT timestamp reported by HW on sec80 MHz 704 * segment. 705 * @reset_delay: Time gap between the last spectral report before 706 * reset and the end of reset. It is provided by FW 707 * via direct DMA framework. 708 * @target_reset_count: Indicates the number of times target went through 709 * reset routine after spectral was enabled. 710 * @bin_pwr_count_5mhz: Indicates the number of FFT bins in the extra 711 * 5 MHz for 165 MHz/ Restricted 80p80 mode 712 * @bin_pwr_5mhz: Contains FFT magnitudes corresponding to the extra 713 * 5 MHz in 165 MHz/ Restricted 80p80 mode 714 */ 715 struct spectral_samp_data { 716 int16_t spectral_data_len; 717 int16_t spectral_data_len_sec80; 718 int16_t spectral_rssi; 719 int16_t spectral_rssi_sec80; 720 int8_t spectral_combined_rssi; 721 int8_t spectral_upper_rssi; 722 int8_t spectral_lower_rssi; 723 int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS]; 724 int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS]; 725 uint8_t spectral_max_scale; 726 int16_t spectral_bwinfo; 727 int32_t spectral_tstamp; 728 int16_t spectral_max_index; 729 int16_t spectral_max_index_sec80; 730 int16_t spectral_max_mag; 731 int16_t spectral_max_mag_sec80; 732 uint8_t spectral_max_exp; 733 int32_t spectral_last_tstamp; 734 int16_t spectral_upper_max_index; 735 int16_t spectral_lower_max_index; 736 uint8_t spectral_nb_upper; 737 uint8_t spectral_nb_lower; 738 struct spectral_classifier_params classifier_params; 739 uint16_t bin_pwr_count; 740 /* 741 * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are 742 * delivered. However, there can be additional bins reported for 743 * AR900B version 2.0 and QCA9984 as described next: 744 * 745 * AR900B version 2.0: An additional tone is processed on the right 746 * hand side in order to facilitate detection of radar pulses out to 747 * the extreme band-edge of the channel frequency. 748 * Since the HW design processes four tones at a time, 749 * this requires one additional Dword to be added to the 750 * search FFT report. 751 * 752 * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary + 753 * 1x-oversampled bins (in-band) per FFT, 754 * then 8 more bins (4 more on left side and 4 more on right side) 755 * are added. 756 */ 757 uint8_t lb_edge_extrabins; 758 uint8_t rb_edge_extrabins; 759 uint16_t bin_pwr_count_sec80; 760 uint8_t bin_pwr[MAX_NUM_BINS_PRI80]; 761 uint8_t bin_pwr_sec80[MAX_NUM_BINS_SEC80]; 762 struct interf_src_rsp interf_list; 763 int16_t noise_floor; 764 int16_t noise_floor_sec80; 765 uint32_t ch_width; 766 uint8_t spectral_agc_total_gain; 767 uint8_t spectral_agc_total_gain_sec80; 768 uint8_t spectral_gainchange; 769 uint8_t spectral_gainchange_sec80; 770 enum spectral_scan_mode spectral_mode; 771 uint8_t spectral_pri80ind; 772 uint8_t spectral_pri80ind_sec80; 773 uint32_t last_raw_timestamp; 774 uint32_t timestamp_war_offset; 775 uint32_t raw_timestamp; 776 uint32_t raw_timestamp_sec80; 777 uint32_t reset_delay; 778 uint32_t target_reset_count; 779 uint32_t agile_ch_width; 780 uint16_t bin_pwr_count_5mhz; 781 uint8_t bin_pwr_5mhz[MAX_NUM_BINS_5MHZ]; 782 } __packed; 783 784 /** 785 * struct spectral_samp_msg - Spectral SAMP message 786 * @signature: Validates the SAMP message 787 * @freq: Operating frequency in MHz 788 * @vhtop_ch_freq_seg1: VHT Segment 1 centre frequency in MHz 789 * @vhtop_ch_freq_seg2: VHT Segment 2 centre frequency in MHz 790 * @agile_freq1: Center frequency in MHz of the entire span(for 80+80 MHz 791 * agile Scan it is primary 80 MHz span) across which 792 * Agile Spectral is carried out. Applicable only for Agile 793 * Spectral samples. 794 * @agile_freq2: Center frequency in MHz of the secondary 80 MHz span 795 * across which Agile Spectral is carried out. Applicable 796 * only for Agile Spectral samples in 80+80 MHz mode. 797 * @freq_loading: How busy was the channel 798 * @dcs_enabled: Whether DCS is enabled 799 * @int_type: Interference type indicated by DCS 800 * @macaddr: Indicates the device interface 801 * @samp_data: SAMP Data 802 */ 803 struct spectral_samp_msg { 804 uint32_t signature; 805 uint16_t freq; 806 uint16_t vhtop_ch_freq_seg1; 807 uint16_t vhtop_ch_freq_seg2; 808 uint16_t agile_freq1; 809 uint16_t agile_freq2; 810 uint16_t freq_loading; 811 uint16_t dcs_enabled; 812 enum dcs_int_type int_type; 813 uint8_t macaddr[6]; 814 struct spectral_samp_data samp_data; 815 } __packed; 816 817 #endif /* OPTIMIZED_SAMP_MESSAGE */ 818 #endif 819