1 /* 2 * Copyright (c) 2011,2017-2019 The Linux Foundation. All rights reserved. 3 * 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 _TARGET_IF_SPECTRAL_H_ 21 #define _TARGET_IF_SPECTRAL_H_ 22 23 #include <wlan_objmgr_cmn.h> 24 #include <wlan_objmgr_psoc_obj.h> 25 #include <wlan_objmgr_pdev_obj.h> 26 #include <wlan_objmgr_vdev_obj.h> 27 #include <qdf_lock.h> 28 #include <wlan_spectral_public_structs.h> 29 #include <reg_services_public_struct.h> 30 #ifdef DIRECT_BUF_RX_ENABLE 31 #include <target_if_direct_buf_rx_api.h> 32 #endif 33 #ifdef WIN32 34 #pragma pack(push, target_if_spectral, 1) 35 #define __ATTRIB_PACK 36 #else 37 #ifndef __ATTRIB_PACK 38 #define __ATTRIB_PACK __attribute__ ((packed)) 39 #endif 40 #endif 41 42 #include <spectral_defs_i.h> 43 44 #define FREQ_OFFSET_10MHZ 10 45 #ifndef SPECTRAL_USE_NL_BCAST 46 #define SPECTRAL_USE_NL_BCAST (0) 47 #endif 48 49 #define STATUS_PASS 1 50 #define STATUS_FAIL 0 51 #undef spectral_dbg_line 52 #define spectral_dbg_line() \ 53 spectral_debug("----------------------------------------------------") 54 55 #undef spectral_ops_not_registered 56 #define spectral_ops_not_registered(str) \ 57 spectral_info("SPECTRAL : %s not registered\n", (str)) 58 #undef not_yet_implemented 59 #define not_yet_implemented() \ 60 spectral_info("SPECTRAL : %s : %d Not yet implemented\n", \ 61 __func__, __LINE__) 62 63 #define SPECTRAL_HT20_NUM_BINS 56 64 #define SPECTRAL_HT20_FFT_LEN 56 65 #define SPECTRAL_HT20_DC_INDEX (SPECTRAL_HT20_FFT_LEN / 2) 66 #define SPECTRAL_HT20_DATA_LEN 60 67 #define SPECTRAL_HT20_TOTAL_DATA_LEN (SPECTRAL_HT20_DATA_LEN + 3) 68 #define SPECTRAL_HT40_TOTAL_NUM_BINS 128 69 #define SPECTRAL_HT40_DATA_LEN 135 70 #define SPECTRAL_HT40_TOTAL_DATA_LEN (SPECTRAL_HT40_DATA_LEN + 3) 71 #define SPECTRAL_HT40_FFT_LEN 128 72 #define SPECTRAL_HT40_DC_INDEX (SPECTRAL_HT40_FFT_LEN / 2) 73 74 /* 75 * Used for the SWAR to obtain approximate combined rssi 76 * in secondary 80Mhz segment 77 */ 78 #define OFFSET_CH_WIDTH_20 65 79 #define OFFSET_CH_WIDTH_40 62 80 #define OFFSET_CH_WIDTH_80 56 81 #define OFFSET_CH_WIDTH_160 50 82 83 /* Min and max for relevant Spectral params */ 84 #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN2 (1) 85 #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN2 (9) 86 #define SPECTRAL_PARAM_FFT_SIZE_MIN_GEN3 (5) 87 #define SPECTRAL_PARAM_FFT_SIZE_MAX_GEN3 (9) 88 #define SPECTRAL_PARAM_RPT_MODE_MIN (0) 89 #define SPECTRAL_PARAM_RPT_MODE_MAX (3) 90 91 /* DBR ring debug size for Spectral */ 92 #define SPECTRAL_DBR_RING_DEBUG_SIZE 512 93 94 #ifdef BIG_ENDIAN_HOST 95 #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) do { \ 96 int j; \ 97 uint32_t *src, *dest; \ 98 src = (uint32_t *)(srcp); \ 99 dest = (uint32_t *)(destp); \ 100 for (j = 0; j < roundup((len), sizeof(uint32_t)) / 4; j++) { \ 101 *(dest + j) = qdf_le32_to_cpu(*(src + j)); \ 102 } \ 103 } while (0) 104 #else 105 #define SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(destp, srcp, len) \ 106 OS_MEMCPY((destp), (srcp), (len)); 107 #endif 108 109 #define DUMMY_NF_VALUE (-123) 110 /* 5 categories x (lower + upper) bands */ 111 #define MAX_INTERF 10 112 #define HOST_MAX_ANTENNA 3 113 /* Mask for time stamp from descriptor */ 114 #define SPECTRAL_TSMASK 0xFFFFFFFF 115 #define SPECTRAL_SIGNATURE 0xdeadbeef 116 /* Signature to write onto spectral buffer and then later validate */ 117 #define MEM_POISON_SIGNATURE (htobe32(0xdeadbeef)) 118 119 /* START of spectral GEN II HW specific details */ 120 #define SPECTRAL_PHYERR_SIGNATURE_GEN2 0xbb 121 #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN2 0xF9 122 #define TLV_TAG_ADC_REPORT_GEN2 0xFA 123 #define TLV_TAG_SEARCH_FFT_REPORT_GEN2 0xFB 124 125 /** 126 * enum spectral_160mhz_report_delivery_state - 160 MHz state machine states 127 * @SPECTRAL_REPORT_WAIT_PRIMARY80: Wait for primary80 report 128 * @SPECTRAL_REPORT_RX_PRIMARY80: Receive primary 80 report 129 * @SPECTRAL_REPORT_WAIT_SECONDARY80: Wait for secondory 80 report 130 * @SPECTRAL_REPORT_RX_SECONDARY80: Receive secondary 80 report 131 */ 132 enum spectral_160mhz_report_delivery_state { 133 SPECTRAL_REPORT_WAIT_PRIMARY80, 134 SPECTRAL_REPORT_RX_PRIMARY80, 135 SPECTRAL_REPORT_WAIT_SECONDARY80, 136 SPECTRAL_REPORT_RX_SECONDARY80, 137 }; 138 139 /** 140 * enum spectral_detector_id - Spectral detector id 141 * @SPECTRAL_DETECTOR_PRIMARY: Primary detector 142 * @SPECTRAL_DETECTOR_SECONDARY: Secondary detector 143 * @SPECTRAL_DETECTOR_AGILE: Agile detector 144 * @SPECTRAL_DETECTOR_INVALID: Invalid detector 145 */ 146 enum spectral_detector_id { 147 SPECTRAL_DETECTOR_PRIMARY, 148 SPECTRAL_DETECTOR_SECONDARY, 149 SPECTRAL_DETECTOR_AGILE, 150 SPECTRAL_DETECTOR_INVALID, 151 }; 152 153 /** 154 * struct spectral_search_fft_info_gen2 - spectral search fft report for gen2 155 * @relpwr_db: Total bin power in db 156 * @num_str_bins_ib: Number of strong bins 157 * @base_pwr: Base power 158 * @total_gain_info: Total gain 159 * @fft_chn_idx: FFT chain on which report is originated 160 * @avgpwr_db: Average power in db 161 * @peak_mag: Peak power seen in the bins 162 * @peak_inx: Index of bin holding peak power 163 */ 164 struct spectral_search_fft_info_gen2 { 165 uint32_t relpwr_db; 166 uint32_t num_str_bins_ib; 167 uint32_t base_pwr; 168 uint32_t total_gain_info; 169 uint32_t fft_chn_idx; 170 uint32_t avgpwr_db; 171 uint32_t peak_mag; 172 int16_t peak_inx; 173 }; 174 175 /* 176 * XXX Check if we should be handling the endinness difference in some 177 * other way opaque to the host 178 */ 179 #ifdef BIG_ENDIAN_HOST 180 181 /** 182 * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for big endian host 183 * @signature: signature 184 * @tag: tag 185 * @length: length 186 */ 187 struct spectral_phyerr_tlv_gen2 { 188 uint8_t signature; 189 uint8_t tag; 190 uint16_t length; 191 } __ATTRIB_PACK; 192 193 #else 194 195 /** 196 * struct spectral_phyerr_tlv_gen2 - phyerr tlv info for little endian host 197 * @length: length 198 * @tag: tag 199 * @signature: signature 200 */ 201 struct spectral_phyerr_tlv_gen2 { 202 uint16_t length; 203 uint8_t tag; 204 uint8_t signature; 205 } __ATTRIB_PACK; 206 207 #endif /* BIG_ENDIAN_HOST */ 208 209 /** 210 * struct spectral_phyerr_hdr_gen2 - phyerr header for gen2 HW 211 * @hdr_a: Header[0:31] 212 * @hdr_b: Header[32:63] 213 */ 214 struct spectral_phyerr_hdr_gen2 { 215 uint32_t hdr_a; 216 uint32_t hdr_b; 217 }; 218 219 /* 220 * Segment ID information for 80+80. 221 * 222 * If the HW micro-architecture specification extends this DWORD for other 223 * purposes, then redefine+rename accordingly. For now, the specification 224 * mentions only segment ID (though this doesn't require an entire DWORD) 225 * without mention of any generic terminology for the DWORD, or any reservation. 226 * We use nomenclature accordingly. 227 */ 228 typedef uint32_t SPECTRAL_SEGID_INFO; 229 230 /** 231 * struct spectral_phyerr_fft_gen2 - fft info in phyerr event 232 * @buf: fft report 233 */ 234 struct spectral_phyerr_fft_gen2 { 235 uint8_t buf[0]; 236 }; 237 /* END of spectral GEN II HW specific details */ 238 239 /* START of spectral GEN III HW specific details */ 240 241 #define get_bitfield(value, size, pos) \ 242 (((value) >> (pos)) & ((1 << (size)) - 1)) 243 #define unsigned_to_signed(value, width) \ 244 (((value) >= (1 << ((width) - 1))) ? \ 245 (value - (1 << (width))) : (value)) 246 247 #define SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_POS_GEN3 (29) 248 #define SSCAN_SUMMARY_REPORT_HDR_A_DETECTOR_ID_SIZE_GEN3 (2) 249 #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_POS_GEN3 (0) 250 #define SSCAN_SUMMARY_REPORT_HDR_A_AGC_TOTAL_GAIN_SIZE_GEN3 (8) 251 #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_POS_GEN3 (18) 252 #define SSCAN_SUMMARY_REPORT_HDR_A_INBAND_PWR_DB_SIZE_GEN3 (10) 253 #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_POS_GEN3 (31) 254 #define SSCAN_SUMMARY_REPORT_HDR_A_PRI80_SIZE_GEN3 (1) 255 #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_POS_GEN3 (30) 256 #define SSCAN_SUMMARY_REPORT_HDR_B_GAINCHANGE_SIZE_GEN3 (1) 257 258 #define SPECTRAL_PHYERR_SIGNATURE_GEN3 (0xFA) 259 #define TLV_TAG_SPECTRAL_SUMMARY_REPORT_GEN3 (0x02) 260 #define TLV_TAG_SEARCH_FFT_REPORT_GEN3 (0x03) 261 #define SPECTRAL_PHYERR_TLVSIZE_GEN3 (4) 262 263 #define PHYERR_HDR_SIG_POS \ 264 (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_sig)) 265 #define PHYERR_HDR_TAG_POS \ 266 (offsetof(struct spectral_phyerr_fft_report_gen3, fft_hdr_tag)) 267 #define SPECTRAL_FFT_BINS_POS \ 268 (offsetof(struct spectral_phyerr_fft_report_gen3, buf)) 269 270 /** 271 * struct phyerr_info - spectral search fft report for gen3 272 * @data: handle to phyerror buffer 273 * @datalen: length of phyerror bufer 274 * @p_rfqual: rf quality matrices 275 * @p_chaninfo: pointer to chaninfo 276 * @tsf64: 64 bit TSF 277 * @acs_stats: acs stats 278 */ 279 struct phyerr_info { 280 uint8_t *data; 281 uint32_t datalen; 282 struct target_if_spectral_rfqual_info *p_rfqual; 283 struct target_if_spectral_chan_info *p_chaninfo; 284 uint64_t tsf64; 285 struct target_if_spectral_acs_stats *acs_stats; 286 }; 287 288 /** 289 * struct spectral_search_fft_info_gen3 - spectral search fft report for gen3 290 * @timestamp: Timestamp at which fft report was generated 291 * @fft_detector_id: Which radio generated this report 292 * @fft_num: The FFT count number. Set to 0 for short FFT. 293 * @fft_radar_check: NA for spectral 294 * @fft_peak_sidx: Index of bin with maximum power 295 * @fft_chn_idx: Rx chain index 296 * @fft_base_pwr_db: Base power in dB 297 * @fft_total_gain_db: Total gain in dB 298 * @fft_num_str_bins_ib: Number of strong bins in the report 299 * @fft_peak_mag: Peak magnitude 300 * @fft_avgpwr_db: Average power in dB 301 * @fft_relpwr_db: Relative power in dB 302 */ 303 struct spectral_search_fft_info_gen3 { 304 uint32_t timestamp; 305 uint32_t fft_detector_id; 306 uint32_t fft_num; 307 uint32_t fft_radar_check; 308 int32_t fft_peak_sidx; 309 uint32_t fft_chn_idx; 310 uint32_t fft_base_pwr_db; 311 uint32_t fft_total_gain_db; 312 uint32_t fft_num_str_bins_ib; 313 int32_t fft_peak_mag; 314 uint32_t fft_avgpwr_db; 315 uint32_t fft_relpwr_db; 316 }; 317 318 /** 319 * struct spectral_phyerr_sfftreport_gen3 - fft info in phyerr event 320 * @fft_timestamp: Timestamp at which fft report was generated 321 * @fft_hdr_sig: signature 322 * @fft_hdr_tag: tag 323 * @fft_hdr_length: length 324 * @hdr_a: Header[0:31] 325 * @hdr_b: Header[32:63] 326 * @hdr_c: Header[64:95] 327 * @resv: Header[96:127] 328 * @buf: fft bins 329 */ 330 struct spectral_phyerr_fft_report_gen3 { 331 uint32_t fft_timestamp; 332 #ifdef BIG_ENDIAN_HOST 333 uint8_t fft_hdr_sig; 334 uint8_t fft_hdr_tag; 335 uint16_t fft_hdr_length; 336 #else 337 uint16_t fft_hdr_length; 338 uint8_t fft_hdr_tag; 339 uint8_t fft_hdr_sig; 340 #endif /* BIG_ENDIAN_HOST */ 341 uint32_t hdr_a; 342 uint32_t hdr_b; 343 uint32_t hdr_c; 344 uint32_t resv; 345 uint8_t buf[0]; 346 } __ATTRIB_PACK; 347 348 /** 349 * struct sscan_report_fields_gen3 - Fields of spectral report 350 * @sscan_agc_total_gain: The AGC total gain in DB. 351 * @inband_pwr_db: The in-band power of the signal in 1/2 DB steps 352 * @sscan_gainchange: This bit is set to 1 if a gainchange occurred during 353 * the spectral scan FFT. Software may choose to 354 * disregard the results. 355 * @sscan_pri80: This is set to 1 to indicate that the Spectral scan was 356 * performed on the pri80 segment. Software may choose to 357 * disregard the FFT sample if this is set to 1 but detector ID 358 * does not correspond to the ID for the pri80 segment. 359 */ 360 struct sscan_report_fields_gen3 { 361 uint8_t sscan_agc_total_gain; 362 int16_t inband_pwr_db; 363 uint8_t sscan_gainchange; 364 uint8_t sscan_pri80; 365 }; 366 367 /** 368 * struct spectral_sscan_summary_report_gen3 - Spectral summary report 369 * event 370 * @sscan_timestamp: Timestamp at which fft report was generated 371 * @sscan_hdr_sig: signature 372 * @sscan_hdr_tag: tag 373 * @sscan_hdr_length: length 374 * @hdr_a: Header[0:31] 375 * @resv: Header[32:63] 376 * @hdr_b: Header[64:95] 377 * @resv: Header[96:127] 378 */ 379 struct spectral_sscan_summary_report_gen3 { 380 u_int32_t sscan_timestamp; 381 #ifdef BIG_ENDIAN_HOST 382 u_int8_t sscan_hdr_sig; 383 u_int8_t sscan_hdr_tag; 384 u_int16_t sscan_hdr_length; 385 #else 386 u_int16_t sscan_hdr_length; 387 u_int8_t sscan_hdr_tag; 388 u_int8_t sscan_hdr_sig; 389 #endif /* BIG_ENDIAN_HOST */ 390 u_int32_t hdr_a; 391 u_int32_t res1; 392 u_int32_t hdr_b; 393 u_int32_t res2; 394 } __ATTRIB_PACK; 395 396 #ifdef DIRECT_BUF_RX_ENABLE 397 /** 398 * struct Spectral_report - spectral report 399 * @data: Report buffer 400 * @noisefloor: Noise floor values 401 * @reset_delay: Time taken for warm reset in us 402 */ 403 struct spectral_report { 404 uint8_t *data; 405 int32_t noisefloor[DBR_MAX_CHAINS]; 406 uint32_t reset_delay; 407 }; 408 #endif 409 /* END of spectral GEN III HW specific details */ 410 411 typedef signed char pwr_dbm; 412 413 /** 414 * enum spectral_gen - spectral hw generation 415 * @SPECTRAL_GEN1 : spectral hw gen 1 416 * @SPECTRAL_GEN2 : spectral hw gen 2 417 * @SPECTRAL_GEN3 : spectral hw gen 3 418 */ 419 enum spectral_gen { 420 SPECTRAL_GEN1, 421 SPECTRAL_GEN2, 422 SPECTRAL_GEN3, 423 }; 424 425 /** 426 * enum spectral_fftbin_size_war - spectral fft bin size war 427 * @SPECTRAL_FFTBIN_SIZE_NO_WAR : No WAR applicable for Spectral FFT bin size 428 * @SPECTRAL_FFTBIN_SIZE_2BYTE_TO_1BYTE : Spectral FFT bin size: Retain only 429 * least significant byte from 2 byte 430 * FFT bin transferred by HW 431 * @SPECTRAL_FFTBIN_SIZE_4BYTE_TO_1BYTE : Spectral FFT bin size: Retain only 432 * least significant byte from 4 byte 433 * FFT bin transferred by HW 434 */ 435 enum spectral_fftbin_size_war { 436 SPECTRAL_FFTBIN_SIZE_NO_WAR = 0, 437 SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE = 1, 438 SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE = 2, 439 }; 440 441 #if ATH_PERF_PWR_OFFLOAD 442 /** 443 * enum target_if_spectral_info - Enumerations for specifying which spectral 444 * information (among parameters and states) 445 * is desired. 446 * @TARGET_IF_SPECTRAL_INFO_ACTIVE: Indicated whether spectral is active 447 * @TARGET_IF_SPECTRAL_INFO_ENABLED: Indicated whether spectral is enabled 448 * @TARGET_IF_SPECTRAL_INFO_PARAMS: Config params 449 */ 450 enum target_if_spectral_info { 451 TARGET_IF_SPECTRAL_INFO_ACTIVE, 452 TARGET_IF_SPECTRAL_INFO_ENABLED, 453 TARGET_IF_SPECTRAL_INFO_PARAMS, 454 }; 455 #endif /* ATH_PERF_PWR_OFFLOAD */ 456 457 /* forward declaration */ 458 struct target_if_spectral; 459 460 /** 461 * struct target_if_spectral_chan_info - Channel information 462 * @center_freq1: center frequency 1 in MHz 463 * @center_freq2: center frequency 2 in MHz -valid only for 464 * 11ACVHT 80PLUS80 mode 465 * @chan_width: channel width in MHz 466 */ 467 struct target_if_spectral_chan_info { 468 uint16_t center_freq1; 469 uint16_t center_freq2; 470 uint8_t chan_width; 471 }; 472 473 /** 474 * struct target_if_spectral_acs_stats - EACS stats from spectral samples 475 * @nfc_ctl_rssi: Control chan rssi 476 * @nfc_ext_rssi: Extension chan rssi 477 * @ctrl_nf: Control chan Noise Floor 478 * @ext_nf: Extension chan Noise Floor 479 */ 480 struct target_if_spectral_acs_stats { 481 int8_t nfc_ctl_rssi; 482 int8_t nfc_ext_rssi; 483 int8_t ctrl_nf; 484 int8_t ext_nf; 485 }; 486 487 /** 488 * struct target_if_spectral_perchain_rssi_info - per chain rssi info 489 * @rssi_pri20: Rssi of primary 20 Mhz 490 * @rssi_sec20: Rssi of secondary 20 Mhz 491 * @rssi_sec40: Rssi of secondary 40 Mhz 492 * @rssi_sec80: Rssi of secondary 80 Mhz 493 */ 494 struct target_if_spectral_perchain_rssi_info { 495 int8_t rssi_pri20; 496 int8_t rssi_sec20; 497 int8_t rssi_sec40; 498 int8_t rssi_sec80; 499 }; 500 501 /** 502 * struct target_if_spectral_rfqual_info - RF measurement information 503 * @rssi_comb: RSSI Information 504 * @pc_rssi_info: XXX : For now, we know we are getting information 505 * for only 4 chains at max. For future extensions 506 * use a define 507 * @noise_floor: Noise floor information 508 */ 509 struct target_if_spectral_rfqual_info { 510 int8_t rssi_comb; 511 struct target_if_spectral_perchain_rssi_info pc_rssi_info[4]; 512 int16_t noise_floor[4]; 513 }; 514 515 #define GET_TARGET_IF_SPECTRAL_OPS(spectral) \ 516 ((struct target_if_spectral_ops *)(&((spectral)->spectral_ops))) 517 518 /** 519 * struct target_if_spectral_ops - spectral low level ops table 520 * @get_tsf64: Get 64 bit TSF value 521 * @get_capability: Get capability info 522 * @set_rxfilter: Set rx filter 523 * @get_rxfilter: Get rx filter 524 * @is_spectral_active: Check whether icm is active 525 * @is_spectral_enabled: Check whether spectral is enabled 526 * @start_spectral_scan: Start spectral scan 527 * @stop_spectral_scan: Stop spectral scan 528 * @get_extension_channel: Get extension channel 529 * @get_ctl_noisefloor: Get control noise floor 530 * @get_ext_noisefloor: Get extension noise floor 531 * @configure_spectral: Set spectral configurations 532 * @get_spectral_config: Get spectral configurations 533 * @get_ent_spectral_mask: Get spectral mask 534 * @get_mac_address: Get mac address 535 * @get_current_channel: Get current channel 536 * @reset_hw: Reset HW 537 * @get_chain_noise_floor: Get Channel noise floor 538 * @spectral_process_phyerr: Process phyerr event 539 * @process_spectral_report: Process spectral report 540 */ 541 struct target_if_spectral_ops { 542 uint64_t (*get_tsf64)(void *arg); 543 uint32_t (*get_capability)( 544 void *arg, enum spectral_capability_type type); 545 uint32_t (*set_rxfilter)(void *arg, int rxfilter); 546 uint32_t (*get_rxfilter)(void *arg); 547 uint32_t (*is_spectral_active)(void *arg, 548 enum spectral_scan_mode smode); 549 uint32_t (*is_spectral_enabled)(void *arg, 550 enum spectral_scan_mode smode); 551 uint32_t (*start_spectral_scan)(void *arg, 552 enum spectral_scan_mode smode, 553 enum spectral_cp_error_code *err); 554 uint32_t (*stop_spectral_scan)(void *arg, 555 enum spectral_scan_mode smode); 556 uint32_t (*get_extension_channel)(void *arg); 557 int8_t (*get_ctl_noisefloor)(void *arg); 558 int8_t (*get_ext_noisefloor)(void *arg); 559 uint32_t (*configure_spectral)( 560 void *arg, 561 struct spectral_config *params, 562 enum spectral_scan_mode smode); 563 uint32_t (*get_spectral_config)( 564 void *arg, 565 struct spectral_config *params, 566 enum spectral_scan_mode smode); 567 uint32_t (*get_ent_spectral_mask)(void *arg); 568 uint32_t (*get_mac_address)(void *arg, char *addr); 569 uint32_t (*get_current_channel)(void *arg); 570 uint32_t (*reset_hw)(void *arg); 571 uint32_t (*get_chain_noise_floor)(void *arg, int16_t *nf_buf); 572 int (*spectral_process_phyerr)(struct target_if_spectral *spectral, 573 uint8_t *data, uint32_t datalen, 574 struct target_if_spectral_rfqual_info *p_rfqual, 575 struct target_if_spectral_chan_info *p_chaninfo, 576 uint64_t tsf64, 577 struct target_if_spectral_acs_stats *acs_stats); 578 int (*process_spectral_report)(struct wlan_objmgr_pdev *pdev, 579 void *payload); 580 }; 581 582 /** 583 * struct target_if_spectral_stats - spectral stats info 584 * @num_spectral_detects: Total num. of spectral detects 585 * @total_phy_errors: Total number of phyerrors 586 * @owl_phy_errors: Indicated phyerrors in old gen1 chipsets 587 * @pri_phy_errors: Phyerrors in primary channel 588 * @ext_phy_errors: Phyerrors in secondary channel 589 * @dc_phy_errors: Phyerrors due to dc 590 * @early_ext_phy_errors: Early secondary channel phyerrors 591 * @bwinfo_errors: Bandwidth info errors 592 * @datalen_discards: Invalid data length errors, seen in gen1 chipsets 593 * @rssi_discards bw: Indicates reports dropped due to RSSI threshold 594 * @last_reset_tstamp: Last reset time stamp 595 */ 596 struct target_if_spectral_stats { 597 uint32_t num_spectral_detects; 598 uint32_t total_phy_errors; 599 uint32_t owl_phy_errors; 600 uint32_t pri_phy_errors; 601 uint32_t ext_phy_errors; 602 uint32_t dc_phy_errors; 603 uint32_t early_ext_phy_errors; 604 uint32_t bwinfo_errors; 605 uint32_t datalen_discards; 606 uint32_t rssi_discards; 607 uint64_t last_reset_tstamp; 608 }; 609 610 /** 611 * struct target_if_spectral_event - spectral event structure 612 * @se_ts: Original 15 bit recv timestamp 613 * @se_full_ts: 64-bit full timestamp from interrupt time 614 * @se_rssi: Rssi of spectral event 615 * @se_bwinfo: Rssi of spectral event 616 * @se_dur: Duration of spectral pulse 617 * @se_chanindex: Channel of event 618 * @se_list: List of spectral events 619 */ 620 struct target_if_spectral_event { 621 uint32_t se_ts; 622 uint64_t se_full_ts; 623 uint8_t se_rssi; 624 uint8_t se_bwinfo; 625 uint8_t se_dur; 626 uint8_t se_chanindex; 627 628 STAILQ_ENTRY(spectral_event) se_list; 629 }; 630 631 /** 632 * struct target_if_chain_noise_pwr_info - Noise power info for each channel 633 * @rptcount: Count of reports in pwr array 634 * @un_cal_nf: Uncalibrated noise floor 635 * @factory_cal_nf: Noise floor as calibrated at the factory for module 636 * @median_pwr: Median power (median of pwr array) 637 * @pwr: Power reports 638 */ 639 struct target_if_chain_noise_pwr_info { 640 int rptcount; 641 pwr_dbm un_cal_nf; 642 pwr_dbm factory_cal_nf; 643 pwr_dbm median_pwr; 644 pwr_dbm pwr[]; 645 } __ATTRIB_PACK; 646 647 /** 648 * struct target_if_spectral_chan_stats - Channel information 649 * @cycle_count: Cycle count 650 * @channel_load: Channel load 651 * @per: Period 652 * @noisefloor: Noise floor 653 * @comp_usablity: Computed usability 654 * @maxregpower: Maximum allowed regulatary power 655 * @comp_usablity_sec80: Computed usability of secondary 80 Mhz 656 * @maxregpower_sec80: Max regulatory power in secondary 80 Mhz 657 */ 658 struct target_if_spectral_chan_stats { 659 int cycle_count; 660 int channel_load; 661 int per; 662 int noisefloor; 663 uint16_t comp_usablity; 664 int8_t maxregpower; 665 uint16_t comp_usablity_sec80; 666 int8_t maxregpower_sec80; 667 }; 668 669 #if ATH_PERF_PWR_OFFLOAD 670 671 /** 672 * struct target_if_spectral_cache - Cache used to minimize WMI operations 673 * in offload architecture 674 * @osc_spectral_enabled: Whether Spectral is enabled 675 * @osc_spectral_active: Whether spectral is active 676 * XXX: Ideally, we should NOT cache this 677 * since the hardware can self clear the bit, 678 * the firmware can possibly stop spectral due to 679 * intermittent off-channel activity, etc 680 * A WMI read command should be introduced to handle 681 * this This will be discussed. 682 * @osc_params: Spectral parameters 683 * @osc_is_valid: Whether the cache is valid 684 */ 685 struct target_if_spectral_cache { 686 uint8_t osc_spectral_enabled; 687 uint8_t osc_spectral_active; 688 struct spectral_config osc_params; 689 uint8_t osc_is_valid; 690 }; 691 692 /** 693 * struct target_if_spectral_param_state_info - Structure used to represent and 694 * manage spectral information 695 * (parameters and states) 696 * @osps_lock: Lock to synchronize accesses to information 697 * @osps_cache: Cacheable' information 698 */ 699 struct target_if_spectral_param_state_info { 700 qdf_spinlock_t osps_lock; 701 struct target_if_spectral_cache osps_cache; 702 /* XXX - Non-cacheable information goes here, in the future */ 703 }; 704 #endif /* ATH_PERF_PWR_OFFLOAD */ 705 706 struct vdev_spectral_configure_params; 707 struct vdev_spectral_enable_params; 708 709 /** 710 * struct wmi_spectral_cmd_ops - structure used holding the operations 711 * related to wmi commands on spectral parameters. 712 * @wmi_spectral_configure_cmd_send: Configure Spectral parameters 713 * @wmi_spectral_enable_cmd_send: Enable/Disable Spectral 714 * @wmi_spectral_crash_inject: Inject FW crash 715 */ 716 struct wmi_spectral_cmd_ops { 717 QDF_STATUS (*wmi_spectral_configure_cmd_send)( 718 wmi_unified_t wmi_hdl, 719 struct vdev_spectral_configure_params *param); 720 QDF_STATUS (*wmi_spectral_enable_cmd_send)( 721 wmi_unified_t wmi_hdl, 722 struct vdev_spectral_enable_params *param); 723 QDF_STATUS(*wmi_spectral_crash_inject)( 724 wmi_unified_t wmi_handle, struct crash_inject *param); 725 }; 726 727 /** 728 * struct spectral_param_properties - structure holding Spectral 729 * parameter properties 730 * @supported: Parameter is supported or not 731 * @common_all_modes: Parameter should be common for all modes or not 732 */ 733 struct spectral_param_properties { 734 bool supported; 735 bool common_all_modes; 736 }; 737 738 /** 739 * struct target_if_spectral - main spectral structure 740 * @pdev: Pointer to pdev 741 * @spectral_ops: Target if internal Spectral low level operations table 742 * @capability: Spectral capabilities structure 743 * @properties: Spectral parameter properties per mode 744 * @spectral_lock: Lock used for internal Spectral operations 745 * @spectral_curchan_radindex: Current channel spectral index 746 * @spectral_extchan_radindex: Extension channel spectral index 747 * @spectraldomain: Current Spectral domain 748 * @spectral_proc_phyerr: Flags to process for PHY errors 749 * @spectral_defaultparams: Default PHY params per Spectral stat 750 * @spectral_stats: Spectral related stats 751 * @events: Events structure 752 * @sc_spectral_ext_chan_ok: Can spectral be detected on the extension channel? 753 * @sc_spectral_combined_rssi_ok: Can use combined spectral RSSI? 754 * @sc_spectral_20_40_mode: Is AP in 20-40 mode? 755 * @sc_spectral_noise_pwr_cal: Noise power cal required? 756 * @sc_spectral_non_edma: Is the spectral capable device Non-EDMA? 757 * @upper_is_control: Upper segment is primary 758 * @upper_is_extension: Upper segment is secondary 759 * @lower_is_control: Lower segment is primary 760 * @lower_is_extension: Lower segment is secondary 761 * @sc_spectraltest_ieeechan: IEEE channel number to return to after a spectral 762 * mute test 763 * @spectral_numbins: Number of bins 764 * @spectral_fft_len: FFT length 765 * @spectral_data_len: Total phyerror report length 766 * @lb_edge_extrabins: Number of extra bins on left band edge 767 * @rb_edge_extrabins: Number of extra bins on right band edge 768 * @spectral_max_index_offset: Max FFT index offset (20 MHz mode) 769 * @spectral_upper_max_index_offset: Upper max FFT index offset (20/40 MHz mode) 770 * @spectral_lower_max_index_offset: Lower max FFT index offset (20/40 MHz mode) 771 * @spectral_dc_index: At which index DC is present 772 * @send_single_packet: Deprecated 773 * @spectral_sent_msg: Indicates whether we send report to upper layers 774 * @params: Spectral parameters 775 * @last_capture_time: Indicates timestamp of previouse report 776 * @num_spectral_data: Number of Spectral samples received in current session 777 * @total_spectral_data: Total number of Spectral samples received 778 * @max_rssi: Maximum RSSI 779 * @detects_control_channel: NA 780 * @detects_extension_channel: NA 781 * @detects_below_dc: NA 782 * @detects_above_dc: NA 783 * @sc_scanning: Indicates active wifi scan 784 * @sc_spectral_scan: Indicates active specral scan 785 * @sc_spectral_full_scan: Deprecated 786 * @scan_start_tstamp: Deprecated 787 * @last_tstamp: Deprecated 788 * @first_tstamp: Deprecated 789 * @spectral_samp_count: Deprecated 790 * @sc_spectral_samp_count: Deprecated 791 * @noise_pwr_reports_reqd: Number of noise power reports required 792 * @noise_pwr_reports_recv: Number of noise power reports received 793 * @noise_pwr_reports_lock: Lock used for Noise power report processing 794 * @noise_pwr_chain_ctl: Noise power report - control channel 795 * @noise_pwr_chain_ext: Noise power report - extension channel 796 * @chaninfo: Channel statistics 797 * @tsf64: Latest TSF Value 798 * @param_info: Offload architecture Spectral parameter cache information 799 * @ch_width: Indicates Channel Width 20/40/80/160 MHz with values 0, 1, 2, 3 800 * respectively 801 * @diag_stats: Diagnostic statistics 802 * @is_160_format: Indicates whether information provided by HW is in altered 803 * format for 802.11ac 160/80+80 MHz support (QCA9984 onwards) 804 * @is_lb_edge_extrabins_format: Indicates whether information provided by 805 * HW has 4 extra bins, at left band edge, for report mode 2 806 * @is_rb_edge_extrabins_format: Indicates whether information provided 807 * by HW has 4 extra bins, at right band edge, for report mode 2 808 * @is_sec80_rssi_war_required: Indicates whether the software workaround is 809 * required to obtain approximate combined RSSI for secondary 80Mhz segment 810 * @simctx: Spectral Simulation context 811 * @spectral_gen: Spectral hardware generation 812 * @hdr_sig_exp: Expected signature in PHYERR TLV header, for the given hardware 813 * generation 814 * @tag_sscan_summary_exp: Expected Spectral Scan Summary tag in PHYERR TLV 815 * header, for the given hardware generation 816 * @tag_sscan_fft_exp: Expected Spectral Scan FFT report tag in PHYERR TLV 817 * header, for the given hardware generation 818 * @tlvhdr_size: Expected PHYERR TLV header size, for the given hardware 819 * generation 820 * @nl_cb: Netlink callbacks 821 * @use_nl_bcast: Whether to use Netlink broadcast/unicast 822 * @send_phy_data: Send data to the application layer for a particular msg type 823 * @inband_fftbin_size_adj: Whether to carry out FFT bin size adjustment for 824 * in-band report format. This would be required on some chipsets under the 825 * following circumstances: In report mode 2 only the in-band bins are DMA'ed. 826 * Scatter/gather is used. However, the HW generates all bins, not just in-band, 827 * and reports the number of bins accordingly. The subsystem arranging for the 828 * DMA cannot change this value. On such chipsets the adjustment required at the 829 * host driver is to check if report format is 2, and if so halve the number of 830 * bins reported to get the number actually DMA'ed. 831 * @null_fftbin_adj: Whether to remove NULL FFT bins for report mode (1) in 832 * which only summary of metrics for each completed FFT + spectral scan summary 833 * report are to be provided. This would be required on some chipsets under the 834 * following circumstances: In report mode 1, HW reports a length corresponding 835 * to all bins, and provides bins with value 0. This is because the subsystem 836 * arranging for the FFT information does not arrange for DMA of FFT bin values 837 * (as expected), but cannot arrange for a smaller length to be reported by HW. 838 * In these circumstances, the driver would have to disregard the NULL bins and 839 * report a bin count of 0 to higher layers. 840 * @last_fft_timestamp: last fft report timestamp 841 * @timestamp_war_offset: Offset to be added to correct timestamp 842 * @dbr_ring_debug: Whether Spectral DBR ring debug is enabled 843 * @dbr_buff_debug: Whether Spectral DBR buffer debug is enabled 844 * @direct_dma_support: Whether Direct-DMA is supported on the current radio 845 * @prev_tstamp: Timestamp of the previously received sample, which has to be 846 * compared with the current tstamp to check descrepancy 847 * @target_reset_count: Number of times target excercised the reset routine 848 */ 849 struct target_if_spectral { 850 struct wlan_objmgr_pdev *pdev_obj; 851 struct target_if_spectral_ops spectral_ops; 852 struct spectral_caps capability; 853 struct spectral_param_properties 854 properties[SPECTRAL_SCAN_MODE_MAX][SPECTRAL_PARAM_MAX]; 855 qdf_spinlock_t spectral_lock; 856 int16_t spectral_curchan_radindex; 857 int16_t spectral_extchan_radindex; 858 uint32_t spectraldomain; 859 uint32_t spectral_proc_phyerr; 860 struct spectral_config spectral_defaultparams; 861 struct target_if_spectral_stats spectral_stats; 862 struct target_if_spectral_event *events; 863 unsigned int sc_spectral_ext_chan_ok:1, 864 sc_spectral_combined_rssi_ok:1, 865 sc_spectral_20_40_mode:1, 866 sc_spectral_noise_pwr_cal:1, 867 sc_spectral_non_edma:1; 868 int upper_is_control; 869 int upper_is_extension; 870 int lower_is_control; 871 int lower_is_extension; 872 uint8_t sc_spectraltest_ieeechan; 873 int spectral_numbins; 874 int spectral_fft_len; 875 int spectral_data_len; 876 877 /* 878 * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are 879 * delivered. However, there can be additional bins reported for 880 * AR900B version 2.0 and QCA9984 as described next: 881 * 882 * AR900B version 2.0: An additional tone is processed on the right 883 * hand side in order to facilitate detection of radar pulses out to 884 * the extreme band-edge of the channel frequency. Since the HW design 885 * processes four tones at a time, this requires one additional Dword 886 * to be added to the search FFT report. 887 * 888 * QCA9984: When spectral_scan_rpt_mode = 2, i.e 2-dword summary + 889 * 1x-oversampled bins (in-band) per FFT, then 8 more bins 890 * (4 more on left side and 4 more on right side)are added. 891 */ 892 893 int lb_edge_extrabins; 894 int rb_edge_extrabins; 895 int spectral_max_index_offset; 896 int spectral_upper_max_index_offset; 897 int spectral_lower_max_index_offset; 898 int spectral_dc_index; 899 int send_single_packet; 900 int spectral_sent_msg; 901 int classify_scan; 902 qdf_timer_t classify_timer; 903 struct spectral_config params[SPECTRAL_SCAN_MODE_MAX]; 904 bool params_valid[SPECTRAL_SCAN_MODE_MAX]; 905 struct spectral_classifier_params classifier_params; 906 int last_capture_time; 907 int num_spectral_data; 908 int total_spectral_data; 909 int max_rssi; 910 int detects_control_channel; 911 int detects_extension_channel; 912 int detects_below_dc; 913 int detects_above_dc; 914 int sc_scanning; 915 int sc_spectral_scan; 916 int sc_spectral_full_scan; 917 uint64_t scan_start_tstamp; 918 uint32_t last_tstamp; 919 uint32_t first_tstamp; 920 uint32_t spectral_samp_count; 921 uint32_t sc_spectral_samp_count; 922 int noise_pwr_reports_reqd; 923 int noise_pwr_reports_recv; 924 qdf_spinlock_t noise_pwr_reports_lock; 925 struct target_if_chain_noise_pwr_info 926 *noise_pwr_chain_ctl[HOST_MAX_ANTENNA]; 927 struct target_if_chain_noise_pwr_info 928 *noise_pwr_chain_ext[HOST_MAX_ANTENNA]; 929 uint64_t tsf64; 930 #if ATH_PERF_PWR_OFFLOAD 931 struct target_if_spectral_param_state_info 932 param_info[SPECTRAL_SCAN_MODE_MAX]; 933 #endif 934 uint32_t ch_width; 935 uint32_t agile_ch_width; 936 struct spectral_diag_stats diag_stats; 937 bool is_160_format; 938 bool is_lb_edge_extrabins_format; 939 bool is_rb_edge_extrabins_format; 940 bool is_sec80_rssi_war_required; 941 #ifdef QCA_SUPPORT_SPECTRAL_SIMULATION 942 void *simctx; 943 #endif 944 enum spectral_gen spectral_gen; 945 uint8_t hdr_sig_exp; 946 uint8_t tag_sscan_summary_exp; 947 uint8_t tag_sscan_fft_exp; 948 uint8_t tlvhdr_size; 949 struct wmi_spectral_cmd_ops param_wmi_cmd_ops; 950 struct spectral_nl_cb nl_cb; 951 bool use_nl_bcast; 952 int (*send_phy_data)(struct wlan_objmgr_pdev *pdev, 953 enum spectral_msg_type smsg_type); 954 enum spectral_fftbin_size_war fftbin_size_war; 955 u_int8_t inband_fftbin_size_adj; 956 u_int8_t null_fftbin_adj; 957 enum spectral_160mhz_report_delivery_state state_160mhz_delivery; 958 void *spectral_report_cache; 959 uint32_t last_fft_timestamp[SPECTRAL_SCAN_MODE_MAX]; 960 uint32_t timestamp_war_offset[SPECTRAL_SCAN_MODE_MAX]; 961 uint16_t fft_size_min; 962 uint16_t fft_size_max; 963 bool dbr_ring_debug; 964 bool dbr_buff_debug; 965 bool direct_dma_support; 966 uint32_t prev_tstamp; 967 uint32_t target_reset_count; 968 }; 969 970 /** 971 * struct target_if_samp_msg_params - Spectral Analysis Messaging Protocol 972 * data format 973 * @rssi: RSSI (except for secondary 80 segment) 974 * @rssi_sec80: RSSI for secondary 80 segment 975 * @lower_rssi: RSSI of lower band 976 * @upper_rssi: RSSI of upper band 977 * @chain_ctl_rssi: RSSI for control channel, for all antennas 978 * @chain_ext_rssi: RSSI for extension channel, for all antennas 979 * @bwinfo: bandwidth info 980 * @data_len: length of FFT data (except for secondary 80 segment) 981 * @data_len_sec80: length of FFT data for secondary 80 segment 982 * @tstamp: timestamp 983 * @last_tstamp: last time stamp 984 * @max_mag: maximum magnitude (except for secondary 80 segment) 985 * @max_mag_sec80: maximum magnitude for secondary 80 segment 986 * @max_index: index of max magnitude (except for secondary 80 segment) 987 * @max_index_sec80: index of max magnitude for secondary 80 segment 988 * @max_exp: max exp 989 * @peak: peak frequency (obsolete) 990 * @pwr_count: number of FFT bins (except for secondary 80 segment) 991 * @pwr_count_sec80: number of FFT bins in secondary 80 segment 992 * @nb_lower: This is deprecated 993 * @nb_upper: This is deprecated 994 * @max_upper_index: index of max mag in upper band 995 * @max_lower_index: index of max mag in lower band 996 * @bin_pwr_data: Contains FFT magnitudes (except for secondary 80 segment) 997 * @bin_pwr_data_sec80: Contains FFT magnitudes for the secondary 80 segment 998 * @freq: Center frequency of primary 20MHz channel in MHz 999 * @vhtop_ch_freq_seg1: VHT operation first segment center frequency in MHz 1000 * @vhtop_ch_freq_seg2: VHT operation second segment center frequency in MHz 1001 * @agile_freq: Center frequency in MHz of the entire span across which Agile 1002 * Spectral is carried out. Applicable only for Agile Spectral samples. 1003 * @freq_loading: spectral control duty cycles 1004 * @noise_floor: current noise floor (except for secondary 80 segment) 1005 * @noise_floor_sec80: current noise floor for secondary 80 segment 1006 * @interf_list: List of interfernce sources 1007 * @classifier_params: classifier parameters 1008 * @sc: classifier parameters 1009 * @pri80ind: Indication from hardware that the sample was received on the 1010 * primary 80 MHz segment. If this is set when smode = 1011 * SPECTRAL_SCAN_MODE_AGILE, it indicates that Spectral was carried out on 1012 * pri80 instead of the Agile frequency due to a channel switch - Software may 1013 * choose to ignore the sample in this case. 1014 * @pri80ind_sec80: Indication from hardware that the sample was received on the 1015 * primary 80 MHz segment instead of the secondary 80 MHz segment due to a 1016 * channel switch - Software may choose to ignore the sample if this is set. 1017 * Applicable only if smode = SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz 1018 * Spectral operation. 1019 * @last_raw_timestamp: Previous FFT report's raw timestamp. In case of 160MHz 1020 * it will be primary 80 segment's timestamp as both primary & secondary 1021 * segment's timestamps are expected to be almost equal 1022 * @timestamp_war_offset: Offset calculated based on reset_delay and 1023 * last_raw_stamp. It will be added to raw_timestamp to get tstamp. 1024 * @raw_timestamp: FFT timestamp reported by HW on primary segment. 1025 * @raw_timestamp_sec80: FFT timestamp reported by HW on secondary 80 segment. 1026 * @reset_delay: Time gap between the last spectral report before reset and the 1027 * end of reset. 1028 * @target_reset_count: Indicates the the number of times the target went 1029 * through reset routine after spectral was enabled. 1030 */ 1031 struct target_if_samp_msg_params { 1032 int8_t rssi; 1033 int8_t rssi_sec80; 1034 int8_t lower_rssi; 1035 int8_t upper_rssi; 1036 int8_t chain_ctl_rssi[HOST_MAX_ANTENNA]; 1037 int8_t chain_ext_rssi[HOST_MAX_ANTENNA]; 1038 uint16_t bwinfo; 1039 uint16_t datalen; 1040 uint16_t datalen_sec80; 1041 uint32_t tstamp; 1042 uint32_t last_tstamp; 1043 uint16_t max_mag; 1044 uint16_t max_mag_sec80; 1045 uint16_t max_index; 1046 uint16_t max_index_sec80; 1047 uint8_t max_exp; 1048 int peak; 1049 int pwr_count; 1050 int pwr_count_sec80; 1051 int8_t nb_lower; 1052 int8_t nb_upper; 1053 uint16_t max_lower_index; 1054 uint16_t max_upper_index; 1055 uint8_t *bin_pwr_data; 1056 uint8_t *bin_pwr_data_sec80; 1057 uint16_t freq; 1058 uint16_t vhtop_ch_freq_seg1; 1059 uint16_t vhtop_ch_freq_seg2; 1060 uint16_t agile_freq; 1061 uint16_t freq_loading; 1062 int16_t noise_floor; 1063 int16_t noise_floor_sec80; 1064 struct interf_src_rsp interf_list; 1065 struct spectral_classifier_params classifier_params; 1066 struct ath_softc *sc; 1067 uint8_t agc_total_gain; 1068 uint8_t agc_total_gain_sec80; 1069 uint8_t gainchange; 1070 uint8_t gainchange_sec80; 1071 enum spectral_scan_mode smode; 1072 uint8_t pri80ind; 1073 uint8_t pri80ind_sec80; 1074 uint32_t last_raw_timestamp; 1075 uint32_t timestamp_war_offset; 1076 uint32_t raw_timestamp; 1077 uint32_t raw_timestamp_sec80; 1078 uint32_t reset_delay; 1079 uint32_t target_reset_count; 1080 }; 1081 1082 #ifdef WLAN_CONV_SPECTRAL_ENABLE 1083 /** 1084 * target_if_spectral_dump_fft() - Dump Spectral FFT 1085 * @pfft: Pointer to Spectral Phyerr FFT 1086 * @fftlen: FFT length 1087 * 1088 * Return: Success or failure 1089 */ 1090 int target_if_spectral_dump_fft(uint8_t *pfft, int fftlen); 1091 1092 /** 1093 * target_if_dbg_print_samp_param() - Print contents of SAMP struct 1094 * @p: Pointer to SAMP message 1095 * 1096 * Return: Void 1097 */ 1098 void target_if_dbg_print_samp_param(struct target_if_samp_msg_params *p); 1099 1100 /** 1101 * target_if_get_offset_swar_sec80() - Get offset for SWAR according to 1102 * the channel width 1103 * @channel_width: Channel width 1104 * 1105 * Return: Offset for SWAR 1106 */ 1107 uint32_t target_if_get_offset_swar_sec80(uint32_t channel_width); 1108 1109 /** 1110 * target_if_sptrl_register_tx_ops() - Register Spectral target_if Tx Ops 1111 * @tx_ops: Tx Ops 1112 * 1113 * Return: void 1114 */ 1115 void target_if_sptrl_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops); 1116 1117 /** 1118 * target_if_spectral_create_samp_msg() - Create the spectral samp message 1119 * @spectral : Pointer to spectral internal structure 1120 * @params : spectral samp message parameters 1121 * 1122 * API to create the spectral samp message 1123 * 1124 * Return: void 1125 */ 1126 void target_if_spectral_create_samp_msg( 1127 struct target_if_spectral *spectral, 1128 struct target_if_samp_msg_params *params); 1129 1130 /** 1131 * target_if_spectral_process_phyerr_gen3() - Process phyerror event for gen3 1132 * @pdev: Pointer to pdev object 1133 * @payload: Pointer to spectral report 1134 * 1135 * Process phyerror event for gen3 1136 * 1137 * Return: Success/Failure 1138 */ 1139 int target_if_spectral_process_report_gen3( 1140 struct wlan_objmgr_pdev *pdev, 1141 void *buf); 1142 1143 /** 1144 * target_if_process_phyerr_gen2() - Process PHY Error for gen2 1145 * @spectral: Pointer to Spectral object 1146 * @data: Pointer to phyerror event buffer 1147 * @datalen: Data length 1148 * @p_rfqual: RF quality info 1149 * @p_chaninfo: Channel info 1150 * @tsf64: 64 bit tsf timestamp 1151 * @acs_stats: ACS stats 1152 * 1153 * Process PHY Error for gen2 1154 * 1155 * Return: Success/Failure 1156 */ 1157 int target_if_process_phyerr_gen2( 1158 struct target_if_spectral *spectral, 1159 uint8_t *data, 1160 uint32_t datalen, struct target_if_spectral_rfqual_info *p_rfqual, 1161 struct target_if_spectral_chan_info *p_chaninfo, 1162 uint64_t tsf64, 1163 struct target_if_spectral_acs_stats *acs_stats); 1164 1165 /** 1166 * target_if_spectral_send_intf_found_msg() - Indicate to application layer that 1167 * interference has been found 1168 * @pdev: Pointer to pdev 1169 * @cw_int: 1 if CW interference is found, 0 if WLAN interference is found 1170 * @dcs_enabled: 1 if DCS is enabled, 0 if DCS is disabled 1171 * 1172 * Send message to application layer 1173 * indicating that interference has been found 1174 * 1175 * Return: None 1176 */ 1177 void target_if_spectral_send_intf_found_msg( 1178 struct wlan_objmgr_pdev *pdev, 1179 uint16_t cw_int, uint32_t dcs_enabled); 1180 1181 /** 1182 * target_if_stop_spectral_scan() - Stop spectral scan 1183 * @pdev: Pointer to pdev object 1184 * @smode: Spectral scan mode 1185 * @err: Pointer to error code 1186 * 1187 * API to stop the current on-going spectral scan 1188 * 1189 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1190 */ 1191 QDF_STATUS target_if_stop_spectral_scan(struct wlan_objmgr_pdev *pdev, 1192 const enum spectral_scan_mode smode, 1193 enum spectral_cp_error_code *err); 1194 1195 /** 1196 * target_if_spectral_get_vdev() - Get pointer to vdev to be used for Spectral 1197 * operations 1198 * @spectral: Pointer to Spectral target_if internal private data 1199 * 1200 * Spectral operates on pdev. However, in order to retrieve some WLAN 1201 * properties, a vdev is required. To facilitate this, the function returns the 1202 * first vdev in our pdev. The caller should release the reference to the vdev 1203 * once it is done using it. 1204 * TODO: If the framework later provides an API to obtain the first active 1205 * vdev, then it would be preferable to use this API. 1206 * 1207 * Return: Pointer to vdev on success, NULL on failure 1208 */ 1209 struct wlan_objmgr_vdev *target_if_spectral_get_vdev( 1210 struct target_if_spectral *spectral); 1211 1212 /** 1213 * target_if_spectral_dump_hdr_gen2() - Dump Spectral header for gen2 1214 * @phdr: Pointer to Spectral Phyerr Header 1215 * 1216 * Dump Spectral header 1217 * 1218 * Return: Success/Failure 1219 */ 1220 int target_if_spectral_dump_hdr_gen2(struct spectral_phyerr_hdr_gen2 *phdr); 1221 1222 /** 1223 * target_if_get_combrssi_sec80_seg_gen2() - Get approximate combined RSSI 1224 * for Secondary 80 segment 1225 * @spectral: Pointer to spectral object 1226 * @p_sfft_sec80: Pointer to search fft info of secondary 80 segment 1227 * 1228 * Get approximate combined RSSI for Secondary 80 segment 1229 * 1230 * Return: Combined RSSI for secondary 80Mhz segment 1231 */ 1232 int8_t target_if_get_combrssi_sec80_seg_gen2( 1233 struct target_if_spectral *spectral, 1234 struct spectral_search_fft_info_gen2 *p_sfft_sec80); 1235 1236 /** 1237 * target_if_spectral_dump_tlv_gen2() - Dump Spectral TLV for gen2 1238 * @ptlv: Pointer to Spectral Phyerr TLV 1239 * @is_160_format: Indicates 160 format 1240 * 1241 * Dump Spectral TLV for gen2 1242 * 1243 * Return: Success/Failure 1244 */ 1245 int target_if_spectral_dump_tlv_gen2( 1246 struct spectral_phyerr_tlv_gen2 *ptlv, bool is_160_format); 1247 1248 /** 1249 * target_if_spectral_dump_phyerr_data_gen2() - Dump Spectral 1250 * related PHY Error for gen2 1251 * @data: Pointer to phyerror buffer 1252 * @datalen: Data length 1253 * @is_160_format: Indicates 160 format 1254 * 1255 * Dump Spectral related PHY Error for gen2 1256 * 1257 * Return: Success/Failure 1258 */ 1259 int target_if_spectral_dump_phyerr_data_gen2( 1260 uint8_t *data, 1261 uint32_t datalen, 1262 bool is_160_format); 1263 1264 /** 1265 * target_if_dump_fft_report_gen3() - Dump FFT Report for gen3 1266 * @spectral: Pointer to Spectral object 1267 * @smode: Spectral scan mode 1268 * @p_fft_report: Pointer to fft report 1269 * @p_sfft: Pointer to search fft report 1270 * 1271 * Dump FFT Report for gen3 1272 * 1273 * Return: Success/Failure 1274 */ 1275 int target_if_dump_fft_report_gen3(struct target_if_spectral *spectral, 1276 enum spectral_scan_mode smode, 1277 struct spectral_phyerr_fft_report_gen3 *p_fft_report, 1278 struct spectral_search_fft_info_gen3 *p_sfft); 1279 1280 /** 1281 * target_if_dbg_print_samp_msg() - Print contents of SAMP Message 1282 * @p: Pointer to SAMP message 1283 * 1284 * Print contents of SAMP Message 1285 * 1286 * Return: Void 1287 */ 1288 void target_if_dbg_print_samp_msg(struct spectral_samp_msg *pmsg); 1289 1290 /** 1291 * target_if_process_sfft_report_gen3() - Process Search FFT Report for gen3 1292 * @p_fft_report: Pointer to fft report 1293 * @p_sfft: Pointer to search fft report 1294 * 1295 * Process Search FFT Report for gen3 1296 * 1297 * Return: Success/Failure 1298 */ 1299 int target_if_process_sfft_report_gen3( 1300 struct spectral_phyerr_fft_report_gen3 *p_fft_report, 1301 struct spectral_search_fft_info_gen3 *p_fft_info); 1302 1303 /** 1304 * get_target_if_spectral_handle_from_pdev() - Get handle to target_if internal 1305 * Spectral data 1306 * @pdev: Pointer to pdev 1307 * 1308 * Return: Handle to target_if internal Spectral data on success, NULL on 1309 * failure 1310 */ 1311 static inline 1312 struct target_if_spectral *get_target_if_spectral_handle_from_pdev( 1313 struct wlan_objmgr_pdev *pdev) 1314 { 1315 struct target_if_spectral *spectral; 1316 struct wlan_objmgr_psoc *psoc; 1317 1318 if (!pdev) { 1319 spectral_err("pdev is null"); 1320 return NULL; 1321 } 1322 1323 psoc = wlan_pdev_get_psoc(pdev); 1324 if (!psoc) { 1325 spectral_err("psoc is null"); 1326 return NULL; 1327 } 1328 1329 spectral = (struct target_if_spectral *) 1330 psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_get_target_handle( 1331 pdev); 1332 return spectral; 1333 } 1334 1335 /** 1336 * target_if_vdev_get_chan_freq() - Get the operating channel frequency of a 1337 * given vdev 1338 * @pdev: Pointer to vdev 1339 * 1340 * Get the operating channel frequency of a given vdev 1341 * 1342 * Return: Operating channel frequency of a vdev 1343 */ 1344 static inline 1345 int16_t target_if_vdev_get_chan_freq(struct wlan_objmgr_vdev *vdev) 1346 { 1347 struct wlan_objmgr_psoc *psoc = NULL; 1348 1349 psoc = wlan_vdev_get_psoc(vdev); 1350 if (!psoc) { 1351 spectral_err("psoc is NULL"); 1352 return -EINVAL; 1353 } 1354 1355 return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_chan_freq( 1356 vdev); 1357 } 1358 1359 /** 1360 * target_if_vdev_get_chan_freq_seg2() - Get center frequency of secondary 80 of 1361 * given vdev 1362 * @vdev: Pointer to vdev 1363 * 1364 * Get the center frequency of secondary 80 of given vdev 1365 * 1366 * Return: center frequency of secondary 80 1367 */ 1368 static inline 1369 int16_t target_if_vdev_get_chan_freq_seg2(struct wlan_objmgr_vdev *vdev) 1370 { 1371 struct wlan_objmgr_psoc *psoc = NULL; 1372 1373 psoc = wlan_vdev_get_psoc(vdev); 1374 if (!psoc) { 1375 spectral_err("psoc is NULL"); 1376 return -EINVAL; 1377 } 1378 1379 return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_chan_freq_seg2( 1380 vdev); 1381 } 1382 1383 /** 1384 * target_if_vdev_get_ch_width() - Get the operating channel bandwidth of a 1385 * given vdev 1386 * @pdev: Pointer to vdev 1387 * 1388 * Get the operating channel bandwidth of a given vdev 1389 * 1390 * Return: channel bandwidth enumeration corresponding to the vdev 1391 */ 1392 static inline 1393 enum phy_ch_width target_if_vdev_get_ch_width(struct wlan_objmgr_vdev *vdev) 1394 { 1395 struct wlan_objmgr_psoc *psoc = NULL; 1396 1397 psoc = wlan_vdev_get_psoc(vdev); 1398 if (!psoc) { 1399 spectral_err("psoc is NULL"); 1400 return CH_WIDTH_INVALID; 1401 } 1402 1403 return psoc->soc_cb.rx_ops.sptrl_rx_ops.sptrlro_vdev_get_ch_width( 1404 vdev); 1405 } 1406 1407 /** 1408 * target_if_vdev_get_sec20chan_freq_mhz() - Get the frequency of secondary 1409 * 20 MHz channel for a given vdev 1410 * @pdev: Pointer to vdev 1411 * 1412 * Get the frequency of secondary 20Mhz channel for a given vdev 1413 * 1414 * Return: Frequency of secondary 20Mhz channel for a given vdev 1415 */ 1416 static inline 1417 int target_if_vdev_get_sec20chan_freq_mhz( 1418 struct wlan_objmgr_vdev *vdev, 1419 uint16_t *sec20chan_freq) 1420 { 1421 struct wlan_objmgr_psoc *psoc = NULL; 1422 1423 psoc = wlan_vdev_get_psoc(vdev); 1424 if (!psoc) { 1425 spectral_err("psoc is NULL"); 1426 return -EINVAL; 1427 } 1428 1429 return psoc->soc_cb.rx_ops.sptrl_rx_ops. 1430 sptrlro_vdev_get_sec20chan_freq_mhz(vdev, sec20chan_freq); 1431 } 1432 1433 /** 1434 * target_if_spectral_set_rxchainmask() - Set Spectral Rx chainmask 1435 * @pdev: Pointer to pdev 1436 * @spectral_rx_chainmask: Spectral Rx chainmask 1437 * 1438 * Return: None 1439 */ 1440 static inline 1441 void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev, 1442 uint8_t spectral_rx_chainmask) 1443 { 1444 struct wlan_objmgr_psoc *psoc = NULL; 1445 struct target_if_spectral *spectral = NULL; 1446 enum spectral_scan_mode smode = SPECTRAL_SCAN_MODE_NORMAL; 1447 1448 psoc = wlan_pdev_get_psoc(pdev); 1449 if (!psoc) { 1450 spectral_err("psoc is NULL"); 1451 return; 1452 } 1453 1454 if (smode >= SPECTRAL_SCAN_MODE_MAX) { 1455 spectral_err("Invalid Spectral mode %u", smode); 1456 return; 1457 } 1458 1459 if (psoc->soc_cb.rx_ops.sptrl_rx_ops. 1460 sptrlro_spectral_is_feature_disabled(psoc)) { 1461 spectral_info("Spectral is disabled"); 1462 return; 1463 } 1464 1465 spectral = get_target_if_spectral_handle_from_pdev(pdev); 1466 if (!spectral) { 1467 spectral_err("Spectral target if object is null"); 1468 return; 1469 } 1470 1471 /* set chainmask for all the modes */ 1472 for (; smode < SPECTRAL_SCAN_MODE_MAX; smode++) 1473 spectral->params[smode].ss_chn_mask = spectral_rx_chainmask; 1474 } 1475 1476 /** 1477 * target_if_spectral_process_phyerr() - Process Spectral PHY error 1478 * @pdev: Pointer to pdev 1479 * @data: PHY error data received from FW 1480 * @datalen: Length of data 1481 * @p_rfqual: Pointer to RF Quality information 1482 * @p_chaninfo: Pointer to channel information 1483 * @tsf: TSF time instance at which the Spectral sample was received 1484 * @acs_stats: ACS stats 1485 * 1486 * Process Spectral PHY error by extracting necessary information from the data 1487 * sent by FW, and send the extracted information to application layer. 1488 * 1489 * Return: None 1490 */ 1491 static inline 1492 void target_if_spectral_process_phyerr( 1493 struct wlan_objmgr_pdev *pdev, 1494 uint8_t *data, uint32_t datalen, 1495 struct target_if_spectral_rfqual_info *p_rfqual, 1496 struct target_if_spectral_chan_info *p_chaninfo, 1497 uint64_t tsf64, 1498 struct target_if_spectral_acs_stats *acs_stats) 1499 { 1500 struct target_if_spectral *spectral = NULL; 1501 struct target_if_spectral_ops *p_sops = NULL; 1502 1503 spectral = get_target_if_spectral_handle_from_pdev(pdev); 1504 if (!spectral) { 1505 spectral_err("Spectral target if object is null"); 1506 return; 1507 } 1508 1509 p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); 1510 p_sops->spectral_process_phyerr(spectral, data, datalen, 1511 p_rfqual, p_chaninfo, 1512 tsf64, acs_stats); 1513 } 1514 1515 static QDF_STATUS 1516 target_if_get_spectral_msg_type(enum spectral_scan_mode smode, 1517 enum spectral_msg_type *msg_type) { 1518 1519 switch (smode) { 1520 case SPECTRAL_SCAN_MODE_NORMAL: 1521 *msg_type = SPECTRAL_MSG_NORMAL_MODE; 1522 break; 1523 1524 case SPECTRAL_SCAN_MODE_AGILE: 1525 *msg_type = SPECTRAL_MSG_AGILE_MODE; 1526 break; 1527 1528 default: 1529 spectral_err("Invalid spectral mode"); 1530 return QDF_STATUS_E_FAILURE; 1531 } 1532 1533 return QDF_STATUS_SUCCESS; 1534 } 1535 1536 /** 1537 * init_160mhz_delivery_state_machine() - Initialize 160MHz Spectral 1538 * state machine 1539 * @spectral: Pointer to Spectral 1540 * 1541 * Initialize 160MHz Spectral state machine 1542 * 1543 * Return: void 1544 */ 1545 static inline void 1546 init_160mhz_delivery_state_machine(struct target_if_spectral *spectral) 1547 { 1548 spectral->state_160mhz_delivery = 1549 SPECTRAL_REPORT_WAIT_PRIMARY80; 1550 } 1551 1552 /** 1553 * reset_160mhz_delivery_state_machine() - Reset 160MHz Spectral state machine 1554 * @spectral: Pointer to Spectral 1555 * 1556 * Reset 160MHz Spectral state machine 1557 * 1558 * Return: void 1559 */ 1560 static inline void 1561 reset_160mhz_delivery_state_machine(struct target_if_spectral *spectral, 1562 enum spectral_scan_mode smode) 1563 { 1564 enum spectral_msg_type smsg_type; 1565 QDF_STATUS ret; 1566 1567 if (spectral->ch_width == CH_WIDTH_160MHZ) { 1568 spectral->state_160mhz_delivery = 1569 SPECTRAL_REPORT_WAIT_PRIMARY80; 1570 1571 ret = target_if_get_spectral_msg_type(smode, &smsg_type); 1572 if (QDF_IS_STATUS_ERROR(ret)) { 1573 spectral_err("Failed to reset 160 MHz state machine"); 1574 return; 1575 } 1576 1577 spectral->nl_cb.free_sbuff(spectral->pdev_obj, 1578 smsg_type); 1579 } 1580 } 1581 1582 /** 1583 * is_secondaryseg_expected() - Is waiting for secondary 80 report 1584 * @spectral: Pointer to Spectral 1585 * 1586 * Return true if secondary 80 report expected and mode is 160 MHz 1587 * 1588 * Return: true or false 1589 */ 1590 static inline 1591 bool is_secondaryseg_expected(struct target_if_spectral *spectral) 1592 { 1593 return 1594 ((spectral->ch_width == CH_WIDTH_160MHZ) && 1595 (spectral->state_160mhz_delivery == SPECTRAL_REPORT_WAIT_SECONDARY80)); 1596 } 1597 1598 /** 1599 * is_primaryseg_expected() - Is waiting for primary 80 report 1600 * @spectral: Pointer to Spectral 1601 * 1602 * Return true if mode is 160 Mhz and primary 80 report expected or 1603 * mode is not 160 Mhz 1604 * 1605 * Return: true or false 1606 */ 1607 static inline 1608 bool is_primaryseg_expected(struct target_if_spectral *spectral) 1609 { 1610 return 1611 ((spectral->ch_width != CH_WIDTH_160MHZ) || 1612 ((spectral->ch_width == CH_WIDTH_160MHZ) && 1613 (spectral->state_160mhz_delivery == SPECTRAL_REPORT_WAIT_PRIMARY80))); 1614 } 1615 1616 /** 1617 * is_primaryseg_rx_inprog() - Is primary 80 report processing is in progress 1618 * @spectral: Pointer to Spectral 1619 * 1620 * Is primary 80 report processing is in progress 1621 * 1622 * Return: true or false 1623 */ 1624 static inline 1625 bool is_primaryseg_rx_inprog(struct target_if_spectral *spectral) 1626 { 1627 return 1628 ((spectral->ch_width != CH_WIDTH_160MHZ) || 1629 ((spectral->ch_width == CH_WIDTH_160MHZ) && 1630 ((spectral->spectral_gen == SPECTRAL_GEN2) || 1631 ((spectral->spectral_gen == SPECTRAL_GEN3) && 1632 (spectral->state_160mhz_delivery == SPECTRAL_REPORT_RX_PRIMARY80))))); 1633 } 1634 1635 /** 1636 * is_secondaryseg_rx_inprog() - Is secondary80 report processing is in progress 1637 * @spectral: Pointer to Spectral 1638 * 1639 * Is secondary 80 report processing is in progress 1640 * 1641 * Return: true or false 1642 */ 1643 static inline 1644 bool is_secondaryseg_rx_inprog(struct target_if_spectral *spectral) 1645 { 1646 return 1647 ((spectral->ch_width == CH_WIDTH_160MHZ) && 1648 ((spectral->spectral_gen == SPECTRAL_GEN2) || 1649 ((spectral->spectral_gen == SPECTRAL_GEN3) && 1650 (spectral->state_160mhz_delivery == SPECTRAL_REPORT_RX_SECONDARY80)))); 1651 } 1652 1653 /** 1654 * target_if_160mhz_delivery_state_change() - State transition for 160Mhz 1655 * Spectral 1656 * @spectral: Pointer to spectral object 1657 * @detector_id: Detector id 1658 * 1659 * Move the states of state machine for 160MHz spectral scan report receive 1660 * 1661 * Return: QDF_STATUS 1662 */ 1663 QDF_STATUS 1664 target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral, 1665 uint8_t detector_id); 1666 1667 /** 1668 * target_if_sops_is_spectral_enabled() - Get whether Spectral is enabled 1669 * @arg: Pointer to handle for Spectral target_if internal private data 1670 * @smode: Spectral scan mode 1671 * 1672 * Function to check whether Spectral is enabled 1673 * 1674 * Return: True if Spectral is enabled, false if Spectral is not enabled 1675 */ 1676 uint32_t target_if_sops_is_spectral_enabled(void *arg, 1677 enum spectral_scan_mode smode); 1678 1679 /** 1680 * target_if_sops_is_spectral_active() - Get whether Spectral is active 1681 * @arg: Pointer to handle for Spectral target_if internal private data 1682 * @smode: Spectral scan mode 1683 * 1684 * Function to check whether Spectral is active 1685 * 1686 * Return: True if Spectral is active, false if Spectral is not active 1687 */ 1688 uint32_t target_if_sops_is_spectral_active(void *arg, 1689 enum spectral_scan_mode smode); 1690 1691 /** 1692 * target_if_sops_start_spectral_scan() - Start Spectral scan 1693 * @arg: Pointer to handle for Spectral target_if internal private data 1694 * @smode: Spectral scan mode 1695 * @err: Pointer to error code 1696 * 1697 * Function to start spectral scan 1698 * 1699 * Return: 0 on success else failure 1700 */ 1701 uint32_t target_if_sops_start_spectral_scan(void *arg, 1702 enum spectral_scan_mode smode, 1703 enum spectral_cp_error_code *err); 1704 1705 /** 1706 * target_if_sops_stop_spectral_scan() - Stop Spectral scan 1707 * @arg: Pointer to handle for Spectral target_if internal private data 1708 * @smode: Spectral scan mode 1709 * 1710 * Function to stop spectral scan 1711 * 1712 * Return: 0 in case of success, -1 on failure 1713 */ 1714 uint32_t target_if_sops_stop_spectral_scan(void *arg, 1715 enum spectral_scan_mode smode); 1716 1717 /** 1718 * target_if_spectral_get_extension_channel() - Get the current Extension 1719 * channel (in MHz) 1720 * @arg: Pointer to handle for Spectral target_if internal private data 1721 * 1722 * Return: Current Extension channel (in MHz) on success, 0 on failure or if 1723 * extension channel is not present. 1724 */ 1725 uint32_t target_if_spectral_get_extension_channel(void *arg); 1726 1727 /** 1728 * target_if_spectral_get_current_channel() - Get the current channel (in MHz) 1729 * @arg: Pointer to handle for Spectral target_if internal private data 1730 * 1731 * Return: Current channel (in MHz) on success, 0 on failure 1732 */ 1733 uint32_t target_if_spectral_get_current_channel(void *arg); 1734 1735 1736 /** 1737 * target_if_spectral_reset_hw() - Reset the hardware 1738 * @arg: Pointer to handle for Spectral target_if internal private data 1739 * 1740 * This is only a placeholder since it is not currently required in the offload 1741 * case. 1742 * 1743 * Return: 0 1744 */ 1745 uint32_t target_if_spectral_reset_hw(void *arg); 1746 1747 /** 1748 * target_if_spectral_get_chain_noise_floor() - Get the Chain noise floor from 1749 * Noisefloor history buffer 1750 * @arg: Pointer to handle for Spectral target_if internal private data 1751 * @nf_buf: Pointer to buffer into which chain Noise Floor data should be copied 1752 * 1753 * This is only a placeholder since it is not currently required in the offload 1754 * case. 1755 * 1756 * Return: 0 1757 */ 1758 uint32_t target_if_spectral_get_chain_noise_floor(void *arg, int16_t *nf_buf); 1759 1760 /** 1761 * target_if_spectral_get_ext_noisefloor() - Get the extension channel 1762 * noisefloor 1763 * @arg: Pointer to handle for Spectral target_if internal private data 1764 * 1765 * This is only a placeholder since it is not currently required in the offload 1766 * case. 1767 * 1768 * Return: 0 1769 */ 1770 int8_t target_if_spectral_get_ext_noisefloor(void *arg); 1771 1772 /** 1773 * target_if_spectral_get_ctl_noisefloor() - Get the control channel noisefloor 1774 * @arg: Pointer to handle for Spectral target_if internal private data 1775 * 1776 * This is only a placeholder since it is not currently required in the offload 1777 * case. 1778 * 1779 * Return: 0 1780 */ 1781 int8_t target_if_spectral_get_ctl_noisefloor(void *arg); 1782 1783 /** 1784 * target_if_spectral_get_capability() - Get whether a given Spectral hardware 1785 * capability is available 1786 * @arg: Pointer to handle for Spectral target_if internal private data 1787 * @type: Spectral hardware capability type 1788 * 1789 * Return: True if the capability is available, false if the capability is not 1790 * available 1791 */ 1792 uint32_t target_if_spectral_get_capability( 1793 void *arg, enum spectral_capability_type type); 1794 1795 /** 1796 * target_if_spectral_set_rxfilter() - Set the RX Filter before Spectral start 1797 * @arg: Pointer to handle for Spectral target_if internal private data 1798 * @rxfilter: Rx filter to be used 1799 * 1800 * Note: This is only a placeholder function. It is not currently required since 1801 * FW should be taking care of setting the required filters. 1802 * 1803 * Return: 0 1804 */ 1805 uint32_t target_if_spectral_set_rxfilter(void *arg, int rxfilter); 1806 1807 /** 1808 * target_if_spectral_sops_configure_params() - Configure user supplied Spectral 1809 * parameters 1810 * @arg: Pointer to handle for Spectral target_if internal private data 1811 * @params: Spectral parameters 1812 * @smode: Spectral scan mode 1813 * 1814 * Return: 0 in case of success, -1 on failure 1815 */ 1816 uint32_t target_if_spectral_sops_configure_params( 1817 void *arg, struct spectral_config *params, 1818 enum spectral_scan_mode smode); 1819 1820 /** 1821 * target_if_spectral_get_rxfilter() - Get the current RX Filter settings 1822 * @arg: Pointer to handle for Spectral target_if internal private data 1823 * 1824 * Note: This is only a placeholder function. It is not currently required since 1825 * FW should be taking care of setting the required filters. 1826 * 1827 * Return: 0 1828 */ 1829 uint32_t target_if_spectral_get_rxfilter(void *arg); 1830 1831 /** 1832 * target_if_pdev_spectral_deinit() - De-initialize target_if Spectral 1833 * functionality for the given pdev 1834 * @pdev: Pointer to pdev object 1835 * 1836 * Return: None 1837 */ 1838 void target_if_pdev_spectral_deinit(struct wlan_objmgr_pdev *pdev); 1839 1840 /** 1841 * target_if_set_spectral_config() - Set spectral config 1842 * @pdev: Pointer to pdev object 1843 * @threshtype: config type 1844 * @value: config value 1845 * @smode: Spectral scan mode 1846 * @err: Pointer to Spectral error code 1847 * 1848 * API to set spectral configurations 1849 * 1850 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1851 */ 1852 QDF_STATUS target_if_set_spectral_config(struct wlan_objmgr_pdev *pdev, 1853 const uint32_t threshtype, 1854 const uint32_t value, 1855 const enum spectral_scan_mode smode, 1856 enum spectral_cp_error_code *err); 1857 1858 /** 1859 * target_if_pdev_spectral_init() - Initialize target_if Spectral 1860 * functionality for the given pdev 1861 * @pdev: Pointer to pdev object 1862 * 1863 * Return: On success, pointer to Spectral target_if internal private data, on 1864 * failure, NULL 1865 */ 1866 void *target_if_pdev_spectral_init(struct wlan_objmgr_pdev *pdev); 1867 1868 /** 1869 * target_if_spectral_sops_get_params() - Get user configured Spectral 1870 * parameters 1871 * @arg: Pointer to handle for Spectral target_if internal private data 1872 * @params: Pointer to buffer into which Spectral parameters should be copied 1873 * @smode: Spectral scan mode 1874 * 1875 * Return: 0 in case of success, -1 on failure 1876 */ 1877 uint32_t target_if_spectral_sops_get_params( 1878 void *arg, struct spectral_config *params, 1879 enum spectral_scan_mode smode); 1880 1881 /** 1882 * target_if_init_spectral_capability() - Initialize Spectral capability 1883 * @spectral: Pointer to Spectral target_if internal private data 1884 * 1885 * This is a workaround. 1886 * 1887 * Return: QDF_STATUS 1888 */ 1889 QDF_STATUS 1890 target_if_init_spectral_capability(struct target_if_spectral *spectral); 1891 1892 /** 1893 * target_if_start_spectral_scan() - Start spectral scan 1894 * @pdev: Pointer to pdev object 1895 * @smode: Spectral scan mode 1896 * @err: Spectral error code 1897 * 1898 * API to start spectral scan 1899 * 1900 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1901 */ 1902 QDF_STATUS target_if_start_spectral_scan(struct wlan_objmgr_pdev *pdev, 1903 enum spectral_scan_mode smode, 1904 enum spectral_cp_error_code *err); 1905 1906 /** 1907 * target_if_get_spectral_config() - Get spectral configuration 1908 * @pdev: Pointer to pdev object 1909 * @param: Pointer to spectral_config structure in which the configuration 1910 * should be returned 1911 * @smode: Spectral scan mode 1912 * 1913 * API to get the current spectral configuration 1914 * 1915 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1916 */ 1917 QDF_STATUS target_if_get_spectral_config(struct wlan_objmgr_pdev *pdev, 1918 struct spectral_config *param, 1919 enum spectral_scan_mode smode); 1920 1921 /** 1922 * target_if_spectral_scan_enable_params() - Enable use of desired Spectral 1923 * parameters 1924 * @spectral: Pointer to Spectral target_if internal private data 1925 * @spectral_params: Pointer to Spectral parameters 1926 * @smode: Spectral scan mode 1927 * @err: Spectral error code 1928 * 1929 * Enable use of desired Spectral parameters by configuring them into HW, and 1930 * starting Spectral scan 1931 * 1932 * Return: 0 on success, 1 on failure 1933 */ 1934 int target_if_spectral_scan_enable_params( 1935 struct target_if_spectral *spectral, 1936 struct spectral_config *spectral_params, 1937 enum spectral_scan_mode smode, 1938 enum spectral_cp_error_code *err); 1939 1940 /** 1941 * target_if_is_spectral_active() - Get whether Spectral is active 1942 * @pdev: Pointer to pdev object 1943 * @smode: Spectral scan mode 1944 * 1945 * Return: True if Spectral is active, false if Spectral is not active 1946 */ 1947 bool target_if_is_spectral_active(struct wlan_objmgr_pdev *pdev, 1948 enum spectral_scan_mode smode); 1949 1950 /** 1951 * target_if_is_spectral_enabled() - Get whether Spectral is enabled 1952 * @pdev: Pointer to pdev object 1953 * @smode: Spectral scan mode 1954 * 1955 * Return: True if Spectral is enabled, false if Spectral is not enabled 1956 */ 1957 bool target_if_is_spectral_enabled(struct wlan_objmgr_pdev *pdev, 1958 enum spectral_scan_mode smode); 1959 1960 /** 1961 * target_if_set_debug_level() - Set debug level for Spectral 1962 * @pdev: Pointer to pdev object 1963 * @debug_level: Debug level 1964 * 1965 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1966 * 1967 */ 1968 QDF_STATUS target_if_set_debug_level(struct wlan_objmgr_pdev *pdev, 1969 uint32_t debug_level); 1970 1971 /** 1972 * target_if_get_debug_level() - Get debug level for Spectral 1973 * @pdev: Pointer to pdev object 1974 * 1975 * Return: Current debug level 1976 */ 1977 uint32_t target_if_get_debug_level(struct wlan_objmgr_pdev *pdev); 1978 1979 1980 /** 1981 * target_if_get_spectral_capinfo() - Get Spectral capability information 1982 * @pdev: Pointer to pdev object 1983 * @scaps: Buffer into which data should be copied 1984 * 1985 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1986 */ 1987 QDF_STATUS target_if_get_spectral_capinfo(struct wlan_objmgr_pdev *pdev, 1988 struct spectral_caps *scaps); 1989 1990 1991 /** 1992 * target_if_get_spectral_diagstats() - Get Spectral diagnostic statistics 1993 * @pdev: Pointer to pdev object 1994 * @stats: Buffer into which data should be copied 1995 * 1996 * Return: QDF_STATUS_SUCCESS in case of success, else QDF_STATUS_E_FAILURE 1997 */ 1998 QDF_STATUS target_if_get_spectral_diagstats(struct wlan_objmgr_pdev *pdev, 1999 struct spectral_diag_stats *stats); 2000 2001 void target_if_register_wmi_spectral_cmd_ops( 2002 struct wlan_objmgr_pdev *pdev, 2003 struct wmi_spectral_cmd_ops *cmd_ops); 2004 2005 QDF_STATUS 2006 target_if_160mhz_delivery_state_change(struct target_if_spectral *spectral, 2007 uint8_t detector_id); 2008 #ifdef DIRECT_BUF_RX_ENABLE 2009 /** 2010 * target_if_consume_sfft_report_gen3() - Process fft report for gen3 2011 * @spectral: Pointer to spectral object 2012 * @report: Pointer to spectral report 2013 * 2014 * Process fft report for gen3 2015 * 2016 * Return: Success/Failure 2017 */ 2018 int 2019 target_if_consume_spectral_report_gen3( 2020 struct target_if_spectral *spectral, 2021 struct spectral_report *report); 2022 #endif 2023 2024 /** 2025 * target_if_spectral_fw_hang() - Crash the FW from Spectral module 2026 * @spectral: Pointer to Spectral LMAC object 2027 * 2028 * Return: QDF_STATUS of operation 2029 */ 2030 QDF_STATUS target_if_spectral_fw_hang(struct target_if_spectral *spectral); 2031 2032 #ifdef WIN32 2033 #pragma pack(pop, target_if_spectral) 2034 #endif 2035 #ifdef __ATTRIB_PACK 2036 #undef __ATTRIB_PACK 2037 #endif 2038 2039 #endif /* WLAN_CONV_SPECTRAL_ENABLE */ 2040 #endif /* _TARGET_IF_SPECTRAL_H_ */ 2041