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