xref: /wlan-dirver/qca-wifi-host-cmn/spectral/dispatcher/inc/spectral_ioctl.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2011, 2017-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _SPECTRAL_IOCTL_H_
20 #define _SPECTRAL_IOCTL_H_
21 #include <wlan_dfs_ioctl.h>
22 
23 #ifndef AH_MAX_CHAINS
24 #define AH_MAX_CHAINS 3
25 #endif
26 
27 /*
28  * ioctl defines
29  */
30 
31 #define SPECTRAL_SET_CONFIG              (DFS_LAST_IOCTL + 1)
32 #define SPECTRAL_GET_CONFIG              (DFS_LAST_IOCTL + 2)
33 #define SPECTRAL_SHOW_INTERFERENCE       (DFS_LAST_IOCTL + 3)
34 #define SPECTRAL_ENABLE_SCAN             (DFS_LAST_IOCTL + 4)
35 #define SPECTRAL_DISABLE_SCAN            (DFS_LAST_IOCTL + 5)
36 #define SPECTRAL_ACTIVATE_SCAN           (DFS_LAST_IOCTL + 6)
37 #define SPECTRAL_STOP_SCAN               (DFS_LAST_IOCTL + 7)
38 #define SPECTRAL_SET_DEBUG_LEVEL         (DFS_LAST_IOCTL + 8)
39 #define SPECTRAL_IS_ACTIVE               (DFS_LAST_IOCTL + 9)
40 #define SPECTRAL_IS_ENABLED              (DFS_LAST_IOCTL + 10)
41 #define SPECTRAL_CLASSIFY_SCAN           (DFS_LAST_IOCTL + 11)
42 #define SPECTRAL_GET_CLASSIFIER_CONFIG   (DFS_LAST_IOCTL + 12)
43 #define SPECTRAL_EACS                    (DFS_LAST_IOCTL + 13)
44 #define SPECTRAL_ACTIVATE_FULL_SCAN      (DFS_LAST_IOCTL + 14)
45 #define SPECTRAL_STOP_FULL_SCAN          (DFS_LAST_IOCTL + 15)
46 #define SPECTRAL_GET_CAPABILITY_INFO     (DFS_LAST_IOCTL + 16)
47 #define SPECTRAL_GET_DIAG_STATS          (DFS_LAST_IOCTL + 17)
48 #define SPECTRAL_GET_CHAN_WIDTH          (DFS_LAST_IOCTL + 18)
49 #define SPECTRAL_GET_CHANINFO            (DFS_LAST_IOCTL + 19)
50 #define SPECTRAL_CLEAR_CHANINFO          (DFS_LAST_IOCTL + 20)
51 #define SPECTRAL_SET_ICM_ACTIVE          (DFS_LAST_IOCTL + 21)
52 #define SPECTRAL_GET_NOMINAL_NOISEFLOOR  (DFS_LAST_IOCTL + 22)
53 #define SPECTRAL_GET_DEBUG_LEVEL         (DFS_LAST_IOCTL + 23)
54 #define SPECTRAL_SET_DMA_DEBUG           (DFS_LAST_IOCTL + 24)
55 
56 /*
57  * ioctl parameter types
58  */
59 enum spectral_params {
60 	SPECTRAL_PARAM_FFT_PERIOD,
61 	SPECTRAL_PARAM_SCAN_PERIOD,
62 	SPECTRAL_PARAM_SCAN_COUNT,
63 	SPECTRAL_PARAM_SHORT_REPORT,
64 	SPECTRAL_PARAM_SPECT_PRI,
65 	SPECTRAL_PARAM_FFT_SIZE,
66 	SPECTRAL_PARAM_GC_ENA,
67 	SPECTRAL_PARAM_RESTART_ENA,
68 	SPECTRAL_PARAM_NOISE_FLOOR_REF,
69 	SPECTRAL_PARAM_INIT_DELAY,
70 	SPECTRAL_PARAM_NB_TONE_THR,
71 	SPECTRAL_PARAM_STR_BIN_THR,
72 	SPECTRAL_PARAM_WB_RPT_MODE,
73 	SPECTRAL_PARAM_RSSI_RPT_MODE,
74 	SPECTRAL_PARAM_RSSI_THR,
75 	SPECTRAL_PARAM_PWR_FORMAT,
76 	SPECTRAL_PARAM_RPT_MODE,
77 	SPECTRAL_PARAM_BIN_SCALE,
78 	SPECTRAL_PARAM_DBM_ADJ,
79 	SPECTRAL_PARAM_CHN_MASK,
80 	SPECTRAL_PARAM_ACTIVE,
81 	SPECTRAL_PARAM_STOP,
82 	SPECTRAL_PARAM_ENABLE,
83 	SPECTRAL_PARAM_FREQUENCY,
84 	SPECTRAL_PARAM_CHAN_FREQUENCY,
85 	SPECTRAL_PARAM_CHAN_WIDTH,
86 	SPECTRAL_PARAM_MAX,
87 };
88 
89 /**
90  * enum spectral_report_mode: Spectral report mode
91  * @SPECTRAL_REPORT_MODE_0: No FFT report (only spectral scan summary report)
92  * @SPECTRAL_REPORT_MODE_1: FFT report header + spectral scan summary report
93  * @SPECTRAL_REPORT_MODE_2: FFt report header + in-band bins per
94  *                          FFT (half of the number of FFT bins), where the
95  *                          FFT input is sampled at two times the channel
96  *                          bandwidth + spectral scan summary report
97  * @SPECTRAL_REPORT_MODE_3: FFT report header + all bins per FFT, where the FFT
98  *                          input is sampled at two times the channel bandwidth
99  *                          + spectral scan summary report
100  * @SPECTRAL_REPORT_MODE_MAX: Max number of report modes
101  */
102 enum spectral_report_mode {
103 	SPECTRAL_REPORT_MODE_0,
104 	SPECTRAL_REPORT_MODE_1,
105 	SPECTRAL_REPORT_MODE_2,
106 	SPECTRAL_REPORT_MODE_3,
107 	SPECTRAL_REPORT_MODE_MAX,
108 };
109 
110 /**
111  * enum spectral_fft_size : FFT size values
112  * @SPECTRAL_FFT_SIZE_INVALID: Invalid FFT size
113  * @SPECTRAL_FFT_SIZE_1: FFT size 1
114  * @SPECTRAL_FFT_SIZE_2: FFT size 2
115  * @SPECTRAL_FFT_SIZE_3: FFT size 3
116  * @SPECTRAL_FFT_SIZE_4: FFT size 4
117  * @SPECTRAL_FFT_SIZE_5: FFT size 5
118  * @SPECTRAL_FFT_SIZE_6: FFT size 6
119  * @SPECTRAL_FFT_SIZE_7: FFT size 7
120  * @SPECTRAL_FFT_SIZE_8: FFT size 8
121  * @SPECTRAL_FFT_SIZE_9: FFT size 9
122  * @SPECTRAL_FFT_SIZE_10: FFT size 10
123  * @SPECTRAL_FFT_SIZE_MAX: Max number of FFT size
124  */
125 enum spectral_fft_size {
126 	SPECTRAL_FFT_SIZE_INVALID,
127 	SPECTRAL_FFT_SIZE_1,
128 	SPECTRAL_FFT_SIZE_2,
129 	SPECTRAL_FFT_SIZE_3,
130 	SPECTRAL_FFT_SIZE_4,
131 	SPECTRAL_FFT_SIZE_5,
132 	SPECTRAL_FFT_SIZE_6,
133 	SPECTRAL_FFT_SIZE_7,
134 	SPECTRAL_FFT_SIZE_8,
135 	SPECTRAL_FFT_SIZE_9,
136 	SPECTRAL_FFT_SIZE_10,
137 	SPECTRAL_FFT_SIZE_MAX,
138 };
139 
140 /**
141  * enum spectral_scan_mode - Spectral scan mode
142  * @SPECTRAL_SCAN_MODE_NORMAL: Normal mode
143  * @SPECTRAL_SCAN_MODE_AGILE: Agile mode
144  * @SPECTRAL_SCAN_MODE_MAX: Max number of Spectral modes
145  * @SPECTRAL_SCAN_MODE_INVALID: Invalid Spectral mode
146  */
147 enum spectral_scan_mode {
148 	SPECTRAL_SCAN_MODE_NORMAL,
149 	SPECTRAL_SCAN_MODE_AGILE,
150 	SPECTRAL_SCAN_MODE_MAX,
151 	SPECTRAL_SCAN_MODE_INVALID = 0xff,
152 };
153 
154 struct spectral_ioctl_params {
155 	int16_t   spectral_fft_period;
156 	int16_t   pectral_period;
157 	int16_t   spectral_count;
158 	uint16_t spectral_short_report;
159 	uint16_t spectral_pri;
160 };
161 
162 /**
163  * spectral_cap_hw_gen: Definitions for the Spectral hardware generation.
164  * This corresponds to definitions in qca_wlan_vendor_spectral_scan_cap_hw_gen.
165  * @SPECTRAL_CAP_HW_GEN_1: Generation 1
166  * @SPECTRAL_CAP_HW_GEN_2: Generation 2
167  * @SPECTRAL_CAP_HW_GEN_3: Generation 3
168  */
169 enum spectral_cap_hw_gen {
170 	SPECTRAL_CAP_HW_GEN_1 = 0,
171 	SPECTRAL_CAP_HW_GEN_2 = 1,
172 	SPECTRAL_CAP_HW_GEN_3 = 2,
173 };
174 
175 /**
176  * struct spectral_config_frequency - Spectral scan frequency
177  * @cfreq1: Center frequency (in MHz) of the span of interest(primary 80 MHz
178  *          span for 80 + 80 agile scan request) or center frequency (in MHz)
179  *          of any WLAN channel in the span of interest.
180  * @cfreq2: Applicable only for Agile Spectral scan request in 80+80 MHz mode.
181  *          For 80+80 mode it represents  the center frequency (in MHz) of the
182  *          secondary 80 MHz span of interest or center frequency (in MHz) of
183  *          any WLAN channel in the secondary 80 MHz span of interest.
184  */
185 struct spectral_config_frequency {
186 	uint32_t cfreq1;
187 	uint32_t cfreq2;
188 };
189 
190 /**
191  * struct spectral_config - spectral config parameters
192  * @ss_fft_period:        Skip interval for FFT reports
193  * @ss_period:            Spectral scan period
194  * @ss_count:             # of reports to return from ss_active
195  * @ss_short_report:      Set to report only 1 set of FFT results
196  * @radar_bin_thresh_sel: Select threshold to classify strong bin for FFT
197  * @ss_spectral_pri:      Priority, and are we doing a noise power cal ?
198  * @ss_fft_size:          Defines the number of FFT data points to compute,
199  *                        defined as a log index num_fft_pts =
200  *                        2^ss_fft_size
201  * @ss_gc_ena:            Set, to enable targeted gain change before
202  *                        starting the spectral scan FFT
203  * @ss_restart_ena:       Set, to enable abort of receive frames when in high
204  *                        priority and a spectral scan is queued
205  * @ss_noise_floor_ref:   Noise floor reference number (signed) for the
206  *                        calculation of bin power (dBm) Though stored as an
207  *                        unsigned this should be treated as a signed 8-bit int.
208  * @ss_init_delay:        Disallow spectral scan triggers after tx/rx packets
209  *                        by setting this delay value to roughly SIFS time
210  *                        period or greater Delay timer count in units of 0.25us
211  * @ss_nb_tone_thr:       Number of strong bins (inclusive) per sub-channel,
212  *                        below which a signal is declared a narrowband tone
213  * @ss_str_bin_thr:       Bin/max_bin ratio threshold over which a bin is
214  *                        declared strong (for spectral scan bandwidth analysis)
215  * @ss_wb_rpt_mode:       Set this bit to report spectral scans as EXT_BLOCKER
216  *                        (phy_error=36), if none of the sub-channels are
217  *                        deemed narrowband
218  * @ss_rssi_rpt_mode:     Set this bit to report spectral scans as EXT_BLOCKER
219  *                        (phy_error=36), if the ADC RSSI is below the
220  *                        threshold ss_rssi_thr
221  * @ss_rssi_thr:          ADC RSSI must be greater than or equal to this
222  *                        threshold (signed Db) to ensure spectral scan
223  *                        reporting with normal phy error codes (please see
224  *                        ss_rssi_rpt_mode above).Though stored as an unsigned
225  *                        value, this should be treated as a signed 8-bit int
226  * @ss_pwr_format:        Format of frequency bin magnitude for spectral scan
227  *                        triggered FFTs 0: linear magnitude
228  *                        1: log magnitude (20*log10(lin_mag), 1/2 dB step size)
229  * @ss_rpt_mode:          Format of per-FFT reports to software for spectral
230  *                        scan triggered FFTs
231  *                        0: No FFT report (only pulse end summary)
232  *                        1: 2-dword summary of metrics for each completed FFT
233  *                        2: 2-dword summary + 1x-oversampled bins(in-band) per
234  *                           FFT
235  *                        3: 2-dword summary + 2x-oversampled bins (all) per FFT
236  * @ss_bin_scale:         Number of LSBs to shift out to scale the FFT bins
237  *                        for spectral scan triggered FFTs
238  * @ss_dbm_adj:           Set (with ss_pwr_format=1), to report bin
239  *                        magnitudes
240  *                        converted to dBm power using the noisefloor
241  *                        calibration results
242  * @ss_chn_mask:          Per chain enable mask to select input ADC for search
243  *                        FFT
244  * @ss_nf_cal:            nf calibrated values for ctl+ext
245  * @ss_nf_pwr:            nf pwr values for ctl+ext
246  * @ss_nf_temp_data:      temperature data taken during nf scan
247  * @ss_frequency:         This specifies the frequency span over which Spectral
248  *                        scan would be carried out. Its value depends on the
249  *                        Spectral scan mode.
250  *                        Normal mode:-
251  *                          Not applicable. Spectral scan would happen in the
252  *                          operating span.
253  *                        Agile mode:-
254  *                          cfreq1 represents the center frequency (in MHz) of
255  *                          the span of interest(primary 80 MHz span for 80 + 80
256  *                          agile scan request) or center frequency (in MHz) of
257  *                          any WLAN channel in the span of interest. cfreq2 is
258  *                          applicable only for Agile Spectral scan request in
259  *                          80+80 MHz mode. For 80+80 mode it represents  the
260  *                          center frequency (in MHz) of the secondary 80 MHz
261 *                           span of interest or center frequency (in MHz) of
262  *                          any WLAN channel in the secondary 80 MHz span of
263  *                          interest.
264  */
265 struct spectral_config {
266 	uint16_t ss_fft_period;
267 	uint16_t ss_period;
268 	uint16_t ss_count;
269 	uint16_t ss_short_report;
270 	uint8_t radar_bin_thresh_sel;
271 	uint16_t ss_spectral_pri;
272 	uint16_t ss_fft_size;
273 	uint16_t ss_gc_ena;
274 	uint16_t ss_restart_ena;
275 	uint16_t ss_noise_floor_ref;
276 	uint16_t ss_init_delay;
277 	uint16_t ss_nb_tone_thr;
278 	uint16_t ss_str_bin_thr;
279 	uint16_t ss_wb_rpt_mode;
280 	uint16_t ss_rssi_rpt_mode;
281 	uint16_t ss_rssi_thr;
282 	uint16_t ss_pwr_format;
283 	uint16_t ss_rpt_mode;
284 	uint16_t ss_bin_scale;
285 	uint16_t ss_dbm_adj;
286 	uint16_t ss_chn_mask;
287 	int8_t ss_nf_cal[AH_MAX_CHAINS * 2];
288 	int8_t ss_nf_pwr[AH_MAX_CHAINS * 2];
289 	int32_t ss_nf_temp_data;
290 	struct spectral_config_frequency ss_frequency;
291 };
292 
293 /**
294  * struct spectral_caps - Spectral capabilities structure
295  * @phydiag_cap:         Phydiag capability
296  * @radar_cap:           Radar detection capability
297  * @spectral_cap:        Spectral capability
298  * @advncd_spectral_cap: Advanced spectral capability
299  * @hw_gen: Spectral hw generation as defined in spectral_cap_hw_gen
300  * @is_scaling_params_populated: indicates whether scaling params is populated
301  * @formula_id: formula_id
302  * @low_level_offset: low_level_offset
303  * @high_level_offset: high_level_offset
304  * @rssi_thr: rssi_thr
305  * @default_agc_max_gain: default_agc_max_gain
306  * @agile_spectral_cap: agile Spectral capability for 20/40/80
307  * @agile_spectral_cap_160: agile Spectral capability for 160 MHz
308  * @agile_spectral_cap_80p80: agile Spectral capability for 80p80
309  * @num_detectors_20mhz: number of Spectral detectors in 20 MHz
310  * @num_detectors_40mhz: number of Spectral detectors in 40 MHz
311  * @num_detectors_80mhz: number of Spectral detectors in 80 MHz
312  * @num_detectors_160mhz: number of Spectral detectors in 160 MHz
313  * @num_detectors_80p80mhz: number of Spectral detectors in 80p80 MHz
314  */
315 struct spectral_caps {
316 	uint8_t phydiag_cap;
317 	uint8_t radar_cap;
318 	uint8_t spectral_cap;
319 	uint8_t advncd_spectral_cap;
320 	uint32_t hw_gen;
321 	bool is_scaling_params_populated;
322 	uint16_t formula_id;
323 	int16_t low_level_offset;
324 	int16_t high_level_offset;
325 	int16_t rssi_thr;
326 	uint8_t default_agc_max_gain;
327 	bool agile_spectral_cap;
328 	bool agile_spectral_cap_160;
329 	bool agile_spectral_cap_80p80;
330 	uint32_t num_detectors_20mhz;
331 	uint32_t num_detectors_40mhz;
332 	uint32_t num_detectors_80mhz;
333 	uint32_t num_detectors_160mhz;
334 	uint32_t num_detectors_80p80mhz;
335 };
336 
337 #define SPECTRAL_IOCTL_PARAM_NOVAL (65535)
338 
339 #define MAX_SPECTRAL_CHAINS           (3)
340 #define MAX_NUM_BINS                  (1024)
341 #define MAX_NUM_BINS_PRI80            (1024)
342 #define MAX_NUM_BINS_SEC80            (520)
343 #define MAX_NUM_BINS_5MHZ             (32)
344 /* 5 categories x (lower + upper) bands */
345 #define MAX_INTERF                   10
346 
347 /**
348  * enum dcs_int_type - Interference type indicated by DCS
349  * @SPECTRAL_DCS_INT_NONE:  No interference
350  * @SPECTRAL_DCS_INT_CW:  CW interference
351  * @SPECTRAL_DCS_INT_WIFI:  WLAN interference
352  */
353 enum dcs_int_type {
354 	SPECTRAL_DCS_INT_NONE,
355 	SPECTRAL_DCS_INT_CW,
356 	SPECTRAL_DCS_INT_WIFI
357 };
358 
359 /**
360  * struct interf_rsp - Interference record
361  * @interf_type:         eINTERF_TYPE giving type of interference
362  * @interf_min_freq:     Minimum frequency in MHz at which interference has been
363  * found
364  * @interf_max_freq:     Maximum frequency in MHz at which interference has been
365  * found
366  * @advncd_spectral_cap: Advanced spectral capability
367  */
368 struct interf_rsp {
369 	uint8_t interf_type;
370 	uint16_t interf_min_freq;
371 	uint16_t interf_max_freq;
372 } __packed;
373 
374 /**
375  * struct interf_src_rsp - List of interference sources
376  * @count: Number of interference records
377  * @interf: Array of interference records
378  */
379 struct interf_src_rsp {
380 	uint16_t count;
381 	struct interf_rsp interf[MAX_INTERF];
382 } __packed;
383 
384 /**
385  * struct spectral_classifier_params - spectral classifier parameters
386  * @spectral_20_40_mode:  Is AP in 20/40 mode?
387  * @spectral_dc_index:    DC index
388  * @spectral_dc_in_mhz:   DC in MHz
389  * @upper_chan_in_mhz:    Upper channel in MHz
390  * @lower_chan_in_mhz:    Lower channel in MHz
391  */
392 struct spectral_classifier_params {
393 	int spectral_20_40_mode;
394 	int spectral_dc_index;
395 	int spectral_dc_in_mhz;
396 	int upper_chan_in_mhz;
397 	int lower_chan_in_mhz;
398 } __packed;
399 
400 /**
401  * struct spectral_samp_data - Spectral Analysis Messaging Protocol Data format
402  * @spectral_data_len:        Indicates the bin size
403  * @spectral_data_len_sec80:  Indicates the bin size for secondary 80 segment
404  * @spectral_rssi:            Indicates RSSI
405  * @spectral_rssi_sec80:      Indicates RSSI for secondary 80 segment
406  * @spectral_combined_rssi:   Indicates combined RSSI from all antennas
407  * @spectral_upper_rssi:      Indicates RSSI of upper band
408  * @spectral_lower_rssi:      Indicates RSSI of lower band
409  * @spectral_chain_ctl_rssi:  RSSI for control channel, for all antennas
410  * @spectral_chain_ext_rssi:  RSSI for extension channel, for all antennas
411  * @spectral_max_scale:       Indicates scale factor
412  * @spectral_bwinfo:          Indicates bandwidth info
413  * @spectral_tstamp:          Indicates timestamp
414  * @spectral_max_index:       Indicates the index of max magnitude
415  * @spectral_max_index_sec80: Indicates the index of max magnitude for secondary
416  *                            80 segment
417  * @spectral_max_mag:         Indicates the maximum magnitude
418  * @spectral_max_mag_sec80:   Indicates the maximum magnitude for secondary 80
419  *                            segment
420  * @spectral_max_exp:         Indicates the max exp
421  * @spectral_last_tstamp:     Indicates the last time stamp
422  * @spectral_upper_max_index: Indicates the index of max mag in upper band
423  * @spectral_lower_max_index: Indicates the index of max mag in lower band
424  * @spectral_nb_upper:        Not Used
425  * @spectral_nb_lower:        Not Used
426  * @classifier_params:        Indicates classifier parameters
427  * @bin_pwr_count:            Indicates the number of FFT bins
428  * @lb_edge_extrabins:        Number of extra bins on left band edge
429  * @rb_edge_extrabins:        Number of extra bins on right band edge
430  * @bin_pwr_count_sec80:      Indicates the number of FFT bins in secondary 80
431  *                            segment
432  * @bin_pwr:                  Contains FFT magnitudes
433  * @bin_pwr_sec80:            Contains FFT magnitudes for the secondary 80
434  *                            segment
435  * @interf_list:              List of interfernce sources
436  * @noise_floor:              Indicates the current noise floor
437  * @noise_floor_sec80:        Indicates the current noise floor for secondary 80
438  *                            segment
439  * @ch_width:                 Channel width 20/40/80/160 MHz
440  * @spectral_mode:            Spectral scan mode
441  * @spectral_pri80ind:        Indication from hardware that the sample was
442  *                            received on the primary 80 MHz segment. If this
443  *                            is set when smode = SPECTRAL_SCAN_MODE_AGILE, it
444  *                            indicates that Spectral was carried out on pri80
445  *                            instead of the Agile frequency due to a
446  *                            channel switch - Software may choose
447  *                            to ignore the sample in this case.
448  * @spectral_pri80ind_sec80:  Indication from hardware that the sample was
449  *                            received on the primary 80 MHz segment instead of
450  *                            the secondary 80 MHz segment due to a channel
451  *                            switch - Software may choose to ignore the sample
452  *                            if this is set. Applicable only if smode =
453  *                            SPECTRAL_SCAN_MODE_NORMAL and for 160/80+80 MHz
454  *                            Spectral operation.
455  * @last_raw_timestamp:       Previous FFT report's raw timestamp. In case of
456  *                            160Mhz it will be primary 80 segment's timestamp
457  *                            as both primary & secondary segment's timestamp
458  *                            are expected to be almost equal.
459  * @timestamp_war_offset:     Offset calculated based on reset_delay and
460  *                            last_raw_timestamp. It will be added to
461  *                            raw_timestamp to get spectral_tstamp.
462  * @raw_timestamp:            Actual FFT timestamp reported by HW on primary
463  *                            segment.
464  * @raw_timestamp_sec80:      Actual FFT timestamp reported by HW on sec80 MHz
465  *                            segment.
466  * @reset_delay:              Time gap between the last spectral report before
467  *                            reset and the end of reset. It is provided by FW
468  *                            via direct DMA framework.
469  * @target_reset_count:       Indicates the number of times target went through
470  *                            reset routine after spectral was enabled.
471  * @bin_pwr_count_5mhz:       Indicates the number of FFT bins in the extra
472  *                            5 MHz for 165 MHz/ Restricted 80p80 mode
473  * @bin_pwr_5mhz:             Contains FFT magnitudes corresponding to the extra
474  *                            5 MHz in 165 MHz/ Restricted 80p80 mode
475  */
476 struct spectral_samp_data {
477 	int16_t spectral_data_len;
478 	int16_t spectral_data_len_sec80;
479 	int16_t spectral_rssi;
480 	int16_t spectral_rssi_sec80;
481 	int8_t spectral_combined_rssi;
482 	int8_t spectral_upper_rssi;
483 	int8_t spectral_lower_rssi;
484 	int8_t spectral_chain_ctl_rssi[MAX_SPECTRAL_CHAINS];
485 	int8_t spectral_chain_ext_rssi[MAX_SPECTRAL_CHAINS];
486 	uint8_t spectral_max_scale;
487 	int16_t spectral_bwinfo;
488 	int32_t spectral_tstamp;
489 	int16_t spectral_max_index;
490 	int16_t spectral_max_index_sec80;
491 	int16_t spectral_max_mag;
492 	int16_t spectral_max_mag_sec80;
493 	uint8_t spectral_max_exp;
494 	int32_t spectral_last_tstamp;
495 	int16_t spectral_upper_max_index;
496 	int16_t spectral_lower_max_index;
497 	uint8_t spectral_nb_upper;
498 	uint8_t spectral_nb_lower;
499 	struct spectral_classifier_params classifier_params;
500 	uint16_t bin_pwr_count;
501 	/*
502 	 * For 11ac chipsets prior to AR900B version 2.0, a max of 512 bins are
503 	 * delivered.  However, there can be additional bins reported for
504 	 * AR900B version 2.0 and QCA9984 as described next:
505 	 *
506 	 * AR900B version 2.0: An additional tone is processed on the right
507 	 * hand side in order to facilitate detection of radar pulses out to
508 	 * the extreme band-edge of the channel frequency.
509 	 * Since the HW design processes four tones at a time,
510 	 * this requires one additional Dword to be added to the
511 	 * search FFT report.
512 	 *
513 	 * QCA9984: When spectral_scan_rpt_mode=2, i.e 2-dword summary +
514 	 * 1x-oversampled bins (in-band) per FFT,
515 	 * then 8 more bins (4 more on left side and 4 more on right side)
516 	 * are added.
517 	 */
518 	uint8_t lb_edge_extrabins;
519 	uint8_t rb_edge_extrabins;
520 	uint16_t bin_pwr_count_sec80;
521 	uint8_t bin_pwr[MAX_NUM_BINS_PRI80];
522 	uint8_t bin_pwr_sec80[MAX_NUM_BINS_SEC80];
523 	struct interf_src_rsp interf_list;
524 	int16_t noise_floor;
525 	int16_t noise_floor_sec80;
526 	uint32_t ch_width;
527 	uint8_t spectral_agc_total_gain;
528 	uint8_t spectral_agc_total_gain_sec80;
529 	uint8_t spectral_gainchange;
530 	uint8_t spectral_gainchange_sec80;
531 	enum spectral_scan_mode spectral_mode;
532 	uint8_t spectral_pri80ind;
533 	uint8_t spectral_pri80ind_sec80;
534 	uint32_t last_raw_timestamp;
535 	uint32_t timestamp_war_offset;
536 	uint32_t raw_timestamp;
537 	uint32_t raw_timestamp_sec80;
538 	uint32_t reset_delay;
539 	uint32_t target_reset_count;
540 	uint32_t agile_ch_width;
541 	uint16_t bin_pwr_count_5mhz;
542 	uint8_t bin_pwr_5mhz[MAX_NUM_BINS_5MHZ];
543 } __packed;
544 
545 /**
546  * struct spectral_samp_msg - Spectral SAMP message
547  * @signature:          Validates the SAMP message
548  * @freq:               Operating frequency in MHz
549  * @vhtop_ch_freq_seg1: VHT Segment 1 centre frequency in MHz
550  * @vhtop_ch_freq_seg2: VHT Segment 2 centre frequency in MHz
551  * @agile_freq1:        Center frequency in MHz of the entire span(for 80+80 MHz
552  *                      agile Scan it is primary 80 MHz span) across which
553  *                      Agile Spectral is carried out. Applicable only for Agile
554  *                      Spectral samples.
555  * @agile_freq2:        Center frequency in MHz of the secondary 80 MHz span
556  *                      across which Agile Spectral is carried out. Applicable
557  *                      only for Agile Spectral samples in 80+80 MHz mode.
558  * @freq_loading:       How busy was the channel
559  * @dcs_enabled:        Whether DCS is enabled
560  * @int_type:           Interference type indicated by DCS
561  * @macaddr:            Indicates the device interface
562  * @samp_data:          SAMP Data
563  */
564 struct spectral_samp_msg {
565 	uint32_t signature;
566 	uint16_t freq;
567 	uint16_t vhtop_ch_freq_seg1;
568 	uint16_t vhtop_ch_freq_seg2;
569 	uint16_t agile_freq1;
570 	uint16_t agile_freq2;
571 	uint16_t freq_loading;
572 	uint16_t dcs_enabled;
573 	enum dcs_int_type int_type;
574 	uint8_t macaddr[6];
575 	struct spectral_samp_data samp_data;
576 } __packed;
577 
578 #endif
579