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