xref: /wlan-dirver/qca-wifi-host-cmn/spectral/dispatcher/inc/wlan_spectral_public_structs.h (revision 503663c6daafffe652fa360bde17243568cd6d2a)
1 /*
2  * Copyright (c) 2011,2017-2019 The Linux Foundation. All rights reserved.
3  *
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include <qdf_types.h>
21 #include "wlan_dfs_ioctl.h"
22 #include <spectral_ioctl.h>
23 
24 #ifndef __KERNEL__
25 #include <math.h>
26 #endif /*  __KERNEL__  */
27 
28 #ifndef _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_
29 #define _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_
30 
31 #ifndef AH_MAX_CHAINS
32 #define AH_MAX_CHAINS 3
33 #endif
34 
35 #define MAX_NUM_CHANNELS             255
36 #define SPECTRAL_PHYERR_PARAM_NOVAL  65535
37 
38 #ifdef SPECTRAL_USE_EMU_DEFAULTS
39 /* Use defaults from emulation */
40 #define SPECTRAL_SCAN_ACTIVE_DEFAULT           (0x0)
41 #define SPECTRAL_SCAN_ENABLE_DEFAULT           (0x0)
42 #define SPECTRAL_SCAN_COUNT_DEFAULT            (0x0)
43 #define SPECTRAL_SCAN_PERIOD_DEFAULT           (250)
44 #define SPECTRAL_SCAN_PRIORITY_DEFAULT         (0x1)
45 #define SPECTRAL_SCAN_FFT_SIZE_DEFAULT         (0x7)
46 #define SPECTRAL_SCAN_GC_ENA_DEFAULT           (0x1)
47 #define SPECTRAL_SCAN_RESTART_ENA_DEFAULT      (0x0)
48 #define SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT  (0xa0)
49 #define SPECTRAL_SCAN_INIT_DELAY_DEFAULT       (0x50)
50 #define SPECTRAL_SCAN_NB_TONE_THR_DEFAULT      (0xc)
51 #define SPECTRAL_SCAN_STR_BIN_THR_DEFAULT      (0x7)
52 #define SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT      (0x0)
53 #define SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT    (0x1)
54 #define SPECTRAL_SCAN_RSSI_THR_DEFAULT         (0xf)
55 #define SPECTRAL_SCAN_PWR_FORMAT_DEFAULT       (0x1)
56 #define SPECTRAL_SCAN_RPT_MODE_DEFAULT         (0x2)
57 #define SPECTRAL_SCAN_BIN_SCALE_DEFAULT        (0x1)
58 #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT          (0x0)
59 #define SPECTRAL_SCAN_CHN_MASK_DEFAULT         (0x1)
60 #else
61 /*
62  * Static default values for spectral state and configuration.
63  * These definitions should be treated as temporary. Ideally,
64  * we should get the defaults from firmware - this will be discussed.
65  *
66  * Use defaults from Spectral Hardware Micro-Architecture
67  * document (v1.0)
68  */
69 #define SPECTRAL_SCAN_ACTIVE_DEFAULT           (0)
70 #define SPECTRAL_SCAN_ENABLE_DEFAULT           (0)
71 #define SPECTRAL_SCAN_COUNT_DEFAULT            (0)
72 #define SPECTRAL_SCAN_PERIOD_GEN_I_DEFAULT     (35)
73 #define SPECTRAL_SCAN_PERIOD_GEN_II_DEFAULT    (35)
74 #define SPECTRAL_SCAN_PERIOD_GEN_III_DEFAULT   (224)
75 #define SPECTRAL_SCAN_PRIORITY_DEFAULT         (1)
76 #define SPECTRAL_SCAN_FFT_SIZE_DEFAULT         (7)
77 #define SPECTRAL_SCAN_GC_ENA_DEFAULT           (1)
78 #define SPECTRAL_SCAN_RESTART_ENA_DEFAULT      (0)
79 #define SPECTRAL_SCAN_NOISE_FLOOR_REF_DEFAULT  (-96)
80 #define SPECTRAL_SCAN_INIT_DELAY_DEFAULT       (80)
81 #define SPECTRAL_SCAN_NB_TONE_THR_DEFAULT      (12)
82 #define SPECTRAL_SCAN_STR_BIN_THR_DEFAULT      (8)
83 #define SPECTRAL_SCAN_WB_RPT_MODE_DEFAULT      (0)
84 #define SPECTRAL_SCAN_RSSI_RPT_MODE_DEFAULT    (0)
85 #define SPECTRAL_SCAN_RSSI_THR_DEFAULT         (0xf0)
86 #define SPECTRAL_SCAN_PWR_FORMAT_DEFAULT       (0)
87 #define SPECTRAL_SCAN_RPT_MODE_DEFAULT         (2)
88 #define SPECTRAL_SCAN_BIN_SCALE_DEFAULT        (1)
89 #define SPECTRAL_SCAN_DBM_ADJ_DEFAULT          (1)
90 #define SPECTRAL_SCAN_CHN_MASK_DEFAULT         (1)
91 #define SPECTRAL_SCAN_FREQUENCY_DEFAULT        (0)
92 #endif				/* SPECTRAL_USE_EMU_DEFAULTS */
93 
94 /* The below two definitions apply only to pre-11ac chipsets */
95 #define SPECTRAL_SCAN_SHORT_REPORT_DEFAULT     (1)
96 #define SPECTRAL_SCAN_FFT_PERIOD_DEFAULT       (1)
97 
98 /*
99  * Definitions to help in scaling of gen3 linear format Spectral bins to values
100  * similar to those from gen2 chipsets.
101  */
102 
103 /*
104  * Max gain for QCA9984. Since this chipset is a prime representative of gen2
105  * chipsets, it is chosen for this value.
106  */
107 #define SPECTRAL_QCA9984_MAX_GAIN                               (78)
108 
109 /* Temporary section for hard-coded values. These need to come from FW. */
110 
111 /* Max gain for IPQ8074 */
112 #define SPECTRAL_IPQ8074_DEFAULT_MAX_GAIN_HARDCODE              (62)
113 
114 /*
115  * Section for values needing tuning per customer platform. These too may need
116  * to come from FW. To be considered as hard-coded for now.
117  */
118 
119 /*
120  * If customers have a different gain line up than QCA reference designs for
121  * IPQ8074 and/or QCA9984, they may have to tune the low level threshold and
122  * the RSSI threshold.
123  */
124 #define SPECTRAL_SCALING_LOW_LEVEL_OFFSET                       (7)
125 #define SPECTRAL_SCALING_RSSI_THRESH                            (5)
126 
127 /*
128  * If customers set the AGC backoff differently, they may have to tune the high
129  * level threshold.
130  */
131 #define SPECTRAL_SCALING_HIGH_LEVEL_OFFSET                      (5)
132 
133 /* End of section for values needing fine tuning. */
134 /* End of temporary section for hard-coded values */
135 
136 /**
137  * enum spectral_msg_buf_type - Spectral message buffer type
138  * @SPECTRAL_MSG_BUF_NEW: Allocate new buffer
139  * @SPECTRAL_MSG_BUF_SAVED: Reuse last buffer, used for secondary segment report
140  *                          in case of 160 MHz.
141  */
142 enum spectral_msg_buf_type {
143 	SPECTRAL_MSG_BUF_NEW,
144 	SPECTRAL_MSG_BUF_SAVED,
145 	SPECTRAL_MSG_BUF_TYPE_MAX,
146 };
147 
148 /**
149  * enum spectral_msg_type - Spectral SAMP message type
150  * @SPECTRAL_MSG_NORMAL_MODE: Normal mode Spectral SAMP message
151  * @SPECTRAL_MSG_AGILE_MODE: Agile mode Spectral SAMP message
152  * @SPECTRAL_MSG_INTERFERENCE_NOTIFICATION: Interference notification to
153  *                                          external auto channel selection
154  *                                          entity
155  * @SPECTRAL_MSG_TYPE_MAX: Spectral SAMP message type max
156  */
157 enum spectral_msg_type {
158 	SPECTRAL_MSG_NORMAL_MODE,
159 	SPECTRAL_MSG_AGILE_MODE,
160 	SPECTRAL_MSG_INTERFERENCE_NOTIFICATION,
161 	SPECTRAL_MSG_TYPE_MAX,
162 };
163 
164 /**
165  * enum wlan_cfg80211_spectral_vendorcmd_handler_idx - Indices to cfg80211
166  * spectral vendor command handlers
167  * @SPECTRAL_SCAN_START_HANDLER_IDX:  Index to SPECTRAL_SCAN_START handler
168  * @SPECTRAL_SCAN_STOP_HANDLER_IDX:  Index to SPECTRAL_SCAN_STOP handler
169  * @SPECTRAL_SCAN_GET_CONFIG_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_CONFIG
170  * handler
171  * @SPECTRAL_SCAN_GET_DIAG_STATS_HANDLER_IDX: Index to
172  * SPECTRAL_SCAN_GET_DIAG_STATS handler
173  * @SPECTRAL_SCAN_GET_CAP_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_CAP handler
174  * @SPECTRAL_SCAN_GET_STATUS_HANDLER_IDX: Index to SPECTRAL_SCAN_GET_STATUS
175  * handler
176  * @SPECTRAL_SCAN_VENDOR_CMD_HANDLER_MAX: Number of cfg80211 spectral
177  * vendor command handlers supported
178  */
179 enum wlan_cfg80211_spectral_vendorcmd_handler_idx {
180 	SPECTRAL_SCAN_START_HANDLER_IDX,
181 	SPECTRAL_SCAN_STOP_HANDLER_IDX,
182 	SPECTRAL_SCAN_GET_CONFIG_HANDLER_IDX,
183 	SPECTRAL_SCAN_GET_DIAG_STATS_HANDLER_IDX,
184 	SPECTRAL_SCAN_GET_CAP_HANDLER_IDX,
185 	SPECTRAL_SCAN_GET_STATUS_HANDLER_IDX,
186 	SPECTRAL_SCAN_VENDOR_CMD_HANDLER_MAX,
187 };
188 
189 /**
190  * enum spectral_debug - Spectral debug level
191  * @DEBUG_SPECTRAL:  Minimal SPECTRAL debug
192  * @DEBUG_SPECTRAL1: Normal SPECTRAL debug
193  * @DEBUG_SPECTRAL2: Maximal SPECTRAL debug
194  * @DEBUG_SPECTRAL3: Matched filterID display
195  * @DEBUG_SPECTRAL4: One time dump of FFT report
196  */
197 enum spectral_debug {
198 	DEBUG_SPECTRAL = 0x00000100,
199 	DEBUG_SPECTRAL1 = 0x00000200,
200 	DEBUG_SPECTRAL2 = 0x00000400,
201 	DEBUG_SPECTRAL3 = 0x00000800,
202 	DEBUG_SPECTRAL4 = 0x00001000,
203 };
204 
205 /**
206  * enum spectral_capability_type - Spectral capability type
207  * @SPECTRAL_CAP_PHYDIAG:              Phydiag capability
208  * @SPECTRAL_CAP_RADAR:                Radar detection capability
209  * @SPECTRAL_CAP_SPECTRAL_SCAN:        Spectral capability
210  * @SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN: Advanced spectral capability
211  */
212 enum spectral_capability_type {
213 	SPECTRAL_CAP_PHYDIAG,
214 	SPECTRAL_CAP_RADAR,
215 	SPECTRAL_CAP_SPECTRAL_SCAN,
216 	SPECTRAL_CAP_ADVNCD_SPECTRAL_SCAN,
217 };
218 
219 /**
220  * enum spectral_cp_error_code - Spectral control path response code
221  * @SPECTRAL_SCAN_RESP_ERR_INVALID: Invalid error identifier
222  * @SPECTRAL_SCAN_RESP_ERR_PARAM_UNSUPPORTED: parameter unsupported
223  * @SPECTRAL_SCAN_RESP_ERR_MODE_UNSUPPORTED: mode unsupported
224  * @SPECTRAL_SCAN_RESP_ERR_PARAM_INVALID_VALUE: invalid parameter value
225  * @SPECTRAL_SCAN_RESP_ERR_PARAM_NOT_INITIALIZED: parameter uninitialized
226  */
227 enum spectral_cp_error_code {
228 	SPECTRAL_SCAN_ERR_INVALID,
229 	SPECTRAL_SCAN_ERR_PARAM_UNSUPPORTED,
230 	SPECTRAL_SCAN_ERR_MODE_UNSUPPORTED,
231 	SPECTRAL_SCAN_ERR_PARAM_INVALID_VALUE,
232 	SPECTRAL_SCAN_ERR_PARAM_NOT_INITIALIZED,
233 };
234 
235 /**
236  * enum spectral_dma_debug -   Spectral DMA debug
237  * @SPECTRAL_DMA_RING_DEBUG:   Spectral DMA ring debug
238  * @SPECTRAL_DMA_BUFFER_DEBUG: Spectral DMA buffer debug
239  */
240 enum spectral_dma_debug {
241 	SPECTRAL_DMA_RING_DEBUG,
242 	SPECTRAL_DMA_BUFFER_DEBUG,
243 };
244 
245 /**
246  * struct spectral_chan_stats - channel status info
247  * @cycle_count:         Cycle count
248  * @channel_load:        Channel load
249  * @per:                 Period
250  * @noisefloor:          Noise floor
251  * @comp_usablity:       Computed usability
252  * @maxregpower:         Maximum allowed regulatory power
253  * @comp_usablity_sec80: Computed usability of secondary 80 Mhz
254  * @maxregpower_sec80:   Max regulatory power of secondary 80 Mhz
255  */
256 struct spectral_chan_stats {
257 	int cycle_count;
258 	int channel_load;
259 	int per;
260 	int noisefloor;
261 	uint16_t comp_usablity;
262 	int8_t maxregpower;
263 	uint16_t comp_usablity_sec80;
264 	int8_t maxregpower_sec80;
265 };
266 
267 /**
268  * struct spectral_diag_stats - spectral diag stats
269  * @spectral_mismatch:             Spectral TLV signature mismatches
270  * @spectral_sec80_sfft_insufflen: Insufficient length when parsing for
271  *                                 Secondary 80 Search FFT report
272  * @spectral_no_sec80_sfft:        Secondary 80 Search FFT report
273  *                                 TLV not found
274  * @spectral_vhtseg1id_mismatch:   VHT Operation Segment 1 ID
275  *                                 mismatches in Search FFT report
276  * @spectral_vhtseg2id_mismatch:   VHT Operation Segment 2 ID
277  *                                 mismatches in Search FFT report
278  * @spectral_invalid_detector_id:  Invalid detector id
279  */
280 struct spectral_diag_stats {
281 	uint64_t spectral_mismatch;
282 	uint64_t spectral_sec80_sfft_insufflen;
283 	uint64_t spectral_no_sec80_sfft;
284 	uint64_t spectral_vhtseg1id_mismatch;
285 	uint64_t spectral_vhtseg2id_mismatch;
286 	uint64_t spectral_invalid_detector_id;
287 };
288 
289 /**
290  * struct spectral_scan_state - State of spectral scan
291  * @is_active:  Is spectral scan active
292  * @is_enabled: Is spectral scan enabled
293  */
294 struct spectral_scan_state {
295 	uint8_t is_active;
296 	uint8_t is_enabled;
297 };
298 
299 /* Forward declarations */
300 struct wlan_objmgr_pdev;
301 
302 /**
303  * struct spectral_nl_cb - Spectral Netlink callbacks
304  * @get_sbuff:      Get the socket buffer to send the data to the application
305  * @send_nl_bcast:  Send data to the application using netlink broadcast
306  * @send_nl_unicast:  Send data to the application using netlink unicast
307  * @free_sbuff: Free the socket buffer for a particular message type
308  */
309 struct spectral_nl_cb {
310 	void *(*get_sbuff)(struct wlan_objmgr_pdev *pdev,
311 			   enum spectral_msg_type smsg_type,
312 			   enum spectral_msg_buf_type buf_type);
313 	int (*send_nl_bcast)(struct wlan_objmgr_pdev *pdev,
314 			     enum spectral_msg_type smsg_type);
315 	int (*send_nl_unicast)(struct wlan_objmgr_pdev *pdev,
316 			       enum spectral_msg_type smsg_type);
317 	void (*free_sbuff)(struct wlan_objmgr_pdev *pdev,
318 			   enum spectral_msg_type smsg_type);
319 };
320 
321 /**
322  * struct spectral_scan_config_request - Config request
323  * @sscan_config: Spectral parameters
324  * @sscan_err_code: Spectral scan error code
325  */
326 struct spectral_scan_config_request {
327 	struct spectral_config sscan_config;
328 	enum spectral_cp_error_code sscan_err_code;
329 };
330 
331 /**
332  * struct spectral_scan_action_request - Action request
333  * @sscan_err_code: Spectral scan error code
334  */
335 struct spectral_scan_action_request {
336 	enum spectral_cp_error_code sscan_err_code;
337 };
338 
339 /**
340  * struct spectral_scan_get_caps_request - Get caps request
341  * @sscan_caps: Spectral capabilities
342  * @sscan_err_code: Spectral scan error code
343  */
344 struct spectral_scan_get_caps_request {
345 	struct spectral_caps sscan_caps;
346 	enum spectral_cp_error_code sscan_err_code;
347 };
348 
349 /**
350  * struct spectral_scan_get_diag_request - Get diag request
351  * @sscan_diag: Spectral diag stats
352  * @sscan_err_code: Spectral scan error code
353  */
354 struct spectral_scan_get_diag_request {
355 	struct spectral_diag_stats sscan_diag;
356 	enum spectral_cp_error_code sscan_err_code;
357 };
358 
359 /**
360  * struct spectral_scan_get_chan_width_request - Get channel width request
361  * @chan_width: Channel width
362  * @sscan_err_code: Spectral scan error code
363  */
364 struct spectral_scan_get_chan_width_request {
365 	uint32_t chan_width;
366 	enum spectral_cp_error_code sscan_err_code;
367 };
368 
369 /**
370  * struct spectral_scan_get_status_request - Get status request
371  * @is_active: is Spectral scan active
372  * @is_enabled: is Spectral scan enabled
373  * @sscan_err_code: Spectral scan error code
374  */
375 struct spectral_scan_get_status_request {
376 	bool is_active;
377 	bool is_enabled;
378 	enum spectral_cp_error_code sscan_err_code;
379 };
380 
381 /**
382  * struct spectral_scan_debug_request - Get/set debug level request
383  * @spectral_dbg_level: Spectral debug level
384  * @sscan_err_code: Spectral scan error code
385  */
386 struct spectral_scan_debug_request {
387 	uint32_t spectral_dbg_level;
388 	enum spectral_cp_error_code sscan_err_code;
389 };
390 
391 /**
392  * struct spectral_scan_dma_debug_request - DMA debug request
393  * @dma_debug_enable: Enable/disable @dma_debug_type
394  * @dma_debug_type: Type of Spectral DMA debug i.e., ring or buffer debug
395  * @sscan_err_code: Spectral scan error code
396  */
397 struct spectral_scan_dma_debug_request {
398 	bool dma_debug_enable;
399 	enum spectral_dma_debug dma_debug_type;
400 	enum spectral_cp_error_code sscan_err_code;
401 };
402 
403 /**
404  * struct spectral_cp_request - Spectral control path request
405  *                              Creating request and extracting response has to
406  *                              be atomic.
407  * @ss_mode: Spectral scan mode
408  * @req_id: Request identifier
409  * @dma_debug_req: Spectral DMA debug request
410  */
411 struct spectral_cp_request {
412 	enum spectral_scan_mode ss_mode;
413 	uint8_t req_id;
414 	union {
415 		struct spectral_scan_config_request config_req;
416 		struct spectral_scan_action_request action_req;
417 		struct spectral_scan_get_caps_request caps_req;
418 		struct spectral_scan_get_diag_request diag_req;
419 		struct spectral_scan_get_chan_width_request chan_width_req;
420 		struct spectral_scan_get_status_request status_req;
421 		struct spectral_scan_debug_request debug_req;
422 		struct spectral_scan_dma_debug_request dma_debug_req;
423 	};
424 };
425 
426 #ifndef __KERNEL__
427 
428 static inline int16_t
429 spectral_pwfactor_max(int16_t pwfactor1,
430 		      int16_t pwfactor2)
431 {
432 	return ((pwfactor1 > pwfactor2) ? pwfactor1 : pwfactor2);
433 }
434 
435 /**
436  * get_spectral_scale_rssi_corr() - Compute RSSI correction factor for scaling
437  * @agc_total_gain_db: AGC total gain in dB steps
438  * @gen3_defmaxgain: Default max gain value of the gen III chipset
439  * @gen2_maxgain: Max gain value used by the reference gen II chipset
440  * @lowlevel_offset: Low level offset for scaling
441  * @inband_pwr: In band power in dB steps
442  * @rssi_thr: RSSI threshold for scaling
443  *
444  * Helper function to compute RSSI correction factor for Gen III linear format
445  * Spectral scaling. It is the responsibility of the caller to ensure that
446  * correct values are passed.
447  *
448  * Return: RSSI correction factor
449  */
450 static inline int16_t
451 get_spectral_scale_rssi_corr(u_int8_t agc_total_gain_db,
452 			     u_int8_t gen3_defmaxgain, u_int8_t gen2_maxgain,
453 			     int16_t lowlevel_offset, int16_t inband_pwr,
454 			     int16_t rssi_thr)
455 {
456 	return ((agc_total_gain_db < gen3_defmaxgain) ?
457 		(gen2_maxgain - gen3_defmaxgain + lowlevel_offset) :
458 		spectral_pwfactor_max((inband_pwr - rssi_thr), 0));
459 }
460 
461 /**
462  * spectral_scale_linear_to_gen2() - Scale linear bin value to gen II equivalent
463  * @gen3_binmag: Captured FFT bin value from the Spectral Search FFT report
464  * generated by the Gen III chipset
465  * @gen2_maxgain: Max gain value used by the reference gen II chipset
466  * @gen3_defmaxgain: Default max gain value of the gen III chipset
467  * @lowlevel_offset: Low level offset for scaling
468  * @inband_pwr: In band power in dB steps
469  * @rssi_thr: RSSI threshold for scaling
470  * @agc_total_gain_db: AGC total gain in dB steps
471  * @highlevel_offset: High level offset for scaling
472  * @gen2_bin_scale: Bin scale value used on reference gen II chipset
473  * @gen3_bin_scale: Bin scale value used on gen III chipset
474  *
475  * Helper function to scale a given gen III linear format bin value into an
476  * approximately equivalent gen II value. The scaled value can possibly be
477  * higher than 8 bits.  If the caller is incapable of handling values larger
478  * than 8 bits, the caller can saturate the value at 255. This function does not
479  * carry out this saturation for the sake of flexibility so that callers
480  * interested in the larger values can avail of this. Also note it is the
481  * responsibility of the caller to ensure that correct values are passed.
482  *
483  * Return: Scaled bin value
484  */
485 static inline u_int32_t
486 spectral_scale_linear_to_gen2(u_int8_t gen3_binmag,
487 			      u_int8_t gen2_maxgain, u_int8_t gen3_defmaxgain,
488 			      int16_t lowlevel_offset, int16_t inband_pwr,
489 			      int16_t rssi_thr, u_int8_t agc_total_gain_db,
490 			      int16_t highlevel_offset, u_int8_t gen2_bin_scale,
491 			      u_int8_t gen3_bin_scale)
492 {
493 	return (gen3_binmag *
494 		sqrt(pow(10, (((double)spectral_pwfactor_max(gen2_maxgain -
495 			gen3_defmaxgain + lowlevel_offset -
496 			get_spectral_scale_rssi_corr(agc_total_gain_db,
497 						     gen3_defmaxgain,
498 						     gen2_maxgain,
499 						     lowlevel_offset,
500 						     inband_pwr,
501 						     rssi_thr),
502 			(agc_total_gain_db < gen3_defmaxgain) *
503 				highlevel_offset)) / 10))) *
504 		 pow(2, (gen3_bin_scale - gen2_bin_scale)));
505 }
506 
507 #endif /*  __KERNEL__  */
508 
509 #endif				/* _WLAN_SPECTRAL_PUBLIC_STRUCTS_H_ */
510