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