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