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