blob: 83c0655262cae3c94c4a43d6d74c82388c688670 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*===========================================================================
29
30 ath_dfs_structs.h
31
32 OVERVIEW:
33
34 Source code borrowed from QCA_MAIN DFS module
35
36 DEPENDENCIES:
37
38 Are listed for each API below.
39
40 ===========================================================================*/
41
42/*===========================================================================
43
44 EDIT HISTORY FOR FILE
45
46 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
49 when who what, where, why
50 ---------- --- --------------------------------------------------------
51
52 ===========================================================================*/
53
54#ifndef _DFS__STRUCTS_H_
55#define _DFS__STRUCTS_H_
Anurag Chouhan600c3a02016-03-01 10:33:54 +053056#include <qdf_mem.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58#ifdef ANDROID
59#include <linux/string.h>
60#endif
61
62/*
63 * For the dfs_nol_clist_update() method - this is the
64 * update command.
65 */
66enum {
67 DFS_NOL_CLIST_CMD_NONE = 0x0,
68 DFS_NOL_CLIST_CMD_UPDATE = 0x1,
69};
70
71struct ath_dfs_caps {
72 uint32_t ath_dfs_ext_chan_ok:1,
73 /* Can radar be detected on the extension chan? */
74 ath_dfs_combined_rssi_ok:1,
75 /* Can use combined radar RSSI?
76 * the following flag is used to indicate if radar detection
77 * scheme should use enhanced chirping detection algorithm.
78 * This flag also determines if certain radar data should be
79 * discarded to minimize false detection of radar.
80 */
81 ath_dfs_use_enhancement:1,
82 ath_strong_signal_diversiry:1,
83 ath_chip_is_bb_tlv:1;
84
85 /*
86 * goes with ath_strong_signal_diversiry:
87 * If we have fast diversity capability, read off
88 * Strong Signal fast diversity count set in the ini
89 * file, and store so we can restore the value when
90 * radar is disabled
91 */
92 uint32_t ath_fastdiv_val;
93};
94
95/*
96 * These are defined in the HAL for now, and must be migrated outside
97 * of there in order to be used by the new partial offload data path.
98 */
99
100struct dfs_pulse {
101 uint32_t rp_numpulses; /* Num of pulses in radar burst */
102 uint32_t rp_pulsedur; /* Duration of each pulse in usecs */
103 uint32_t rp_pulsefreq; /* Frequency of pulses in burst */
104 uint32_t rp_max_pulsefreq; /* Frequency of pulses in burst */
105 uint32_t rp_patterntype; /* fixed or variable pattern type */
106 uint32_t rp_pulsevar; /* Time variation of pulse duration for
107 matched filter (single-sided) in usecs */
108 uint32_t rp_threshold; /* Threshold for MF output to indicateC
109 radar match */
110 uint32_t rp_mindur; /* Min pulse duration to be considered for
111 this pulse type */
112 uint32_t rp_maxdur; /* Max pusle duration to be considered for
113 this pulse type */
114 uint32_t rp_rssithresh; /* Min rssi to be considered a radar pulse */
115 uint32_t rp_meanoffset; /* Offset for timing adjustment */
116 int32_t rp_rssimargin; /* rssi threshold margin. In Turbo Mode HW
117 * reports rssi 3dBm lower than in non TURBO
118 * mode. This will be used to offset that
119 * diff.
120 */
121 uint32_t rp_ignore_pri_window;
122 uint32_t rp_pulseid; /* Unique ID for identifying filter */
123};
124
125struct dfs_staggered_pulse {
126 uint32_t rp_numpulses; /* Num of pulses in radar burst */
127 uint32_t rp_pulsedur; /* Duration of each pulse in usecs */
128 uint32_t rp_min_pulsefreq; /* Frequency of pulses in burst */
129 uint32_t rp_max_pulsefreq; /* Frequency of pulses in burst */
130 uint32_t rp_patterntype; /* fixed or variable pattern type */
131 uint32_t rp_pulsevar; /* Time variation of pulse duration for
132 matched filter (single-sided) in usecs */
133 uint32_t rp_threshold; /* Thershold for MF output to indicateC
134 radar match */
135 uint32_t rp_mindur; /* Min pulse duration to be considered for
136 this pulse type */
137 uint32_t rp_maxdur; /* Max pusle duration to be considered for
138 this pulse type */
139 uint32_t rp_rssithresh; /* Min rssi to be considered a radar pulse */
140 uint32_t rp_meanoffset; /* Offset for timing adjustment */
141 int32_t rp_rssimargin; /* rssi threshold margin. In Turbo Mode HW
142 reports rssi 3dBm lower than in non TURBO
143 mode. This will be used to offset that
144 diff. */
145 uint32_t rp_pulseid; /* Unique ID for identifying filter */
146};
147
148struct dfs_bin5pulse {
149 uint32_t b5_threshold; /* Num of bin5 pulses to indicate detection */
150 uint32_t b5_mindur; /* Min duration for a bin5 pulse */
151 uint32_t b5_maxdur; /* Max duration for a bin5 pulse */
152 uint32_t b5_timewindow; /* Window over which to count bin5 pulses */
153 uint32_t b5_rssithresh; /* Min rssi to be considered a pulse */
154 uint32_t b5_rssimargin; /* rssi threshold margin. In Turbo Mode HW
155 * reports rssi 3dB
156 */
157};
158
159/*
160 * DFS NOL representation.
161 *
162 * This is used to represent the DFS NOL information between the
163 * NOL code in lmac/dfs/dfs_nol.c and any driver layer wishing
164 * to use it.
165 */
166struct dfs_nol_chan_entry {
167 uint32_t nol_chfreq; /* Centre frequency, MHz */
168 uint32_t nol_chwidth; /* Width, MHz */
169 unsigned long nol_start_ticks; /* start ticks, OS specific */
170 uint32_t nol_timeout_ms; /* timeout, mS */
171};
172
173/* HAL_PHYERR_PARAM; */
174
175/*
176 * This represents the general case of the radar PHY configuration,
177 * across all chips.
178 *
179 * It's then up to each chip layer to translate to/from this
180 * (eg to HAL_PHYERR_PARAM for the HAL case.)
181 */
182
183#define ATH_DFS_PHYERR_PARAM_NOVAL 0xFFFF
184#define ATH_DFS_PHYERR_PARAM_ENABLE 0x8000
185
186struct ath_dfs_phyerr_param {
187 int32_t pe_firpwr; /* FIR pwr out threshold */
188 int32_t pe_rrssi; /* Radar rssi thresh */
189 int32_t pe_height; /* Pulse height thresh */
190 int32_t pe_prssi; /* Pulse rssi thresh */
191 int32_t pe_inband; /* Inband thresh */
192
193 /* The following params are only for AR5413 and later */
194 /*
195 * Relative power threshold in 0.5dB steps
196 */
197 uint32_t pe_relpwr;
198
199 /*
200 * Pulse Relative step threshold in 0.5dB steps
201 */
202 uint32_t pe_relstep;
203
204 /*
205 * Max length of radar sign in 0.8us units
206 */
207 uint32_t pe_maxlen;
208
209 /*
210 * Use the average in-band power measured over 128 cycles
211 */
212 bool pe_usefir128;
213
214 /*
215 * Enable to block radar check if pkt detect is done via OFDM
216 * weak signal detect or pkt is detected immediately after tx
217 * to rx transition
218 */
219 bool pe_blockradar;
220
221 /*
222 * Enable to use the max rssi instead of the last rssi during
223 * fine gain changes for radar detection
224 */
225 bool pe_enmaxrssi;
226};
227
228static inline void ath_dfs_phyerr_param_copy(struct ath_dfs_phyerr_param *dst,
229 struct ath_dfs_phyerr_param *src)
230{
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530231 qdf_mem_copy(dst, src, sizeof(*dst));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232}
233
234static inline void ath_dfs_phyerr_init_noval(struct ath_dfs_phyerr_param *pe)
235{
236 pe->pe_firpwr = ATH_DFS_PHYERR_PARAM_NOVAL;
237 pe->pe_rrssi = ATH_DFS_PHYERR_PARAM_NOVAL;
238 pe->pe_height = ATH_DFS_PHYERR_PARAM_NOVAL;
239 pe->pe_prssi = ATH_DFS_PHYERR_PARAM_NOVAL;
240 pe->pe_inband = ATH_DFS_PHYERR_PARAM_NOVAL;
241 pe->pe_relpwr = ATH_DFS_PHYERR_PARAM_NOVAL;
242 pe->pe_relstep = ATH_DFS_PHYERR_PARAM_NOVAL;
243 pe->pe_maxlen = ATH_DFS_PHYERR_PARAM_NOVAL;
244
245 /* XXX what about usefir128, blockradar, enmaxrssi? */
246}
247
248struct ath_dfs_radar_tab_info {
249 uint32_t dfsdomain;
250 int numradars;
251 struct dfs_pulse *dfs_radars;
252 int numb5radars;
253 struct dfs_bin5pulse *b5pulses;
254 struct ath_dfs_phyerr_param dfs_defaultparams;
255 int dfs_pri_multiplier;
256};
257#endif /* _DFS__STRUCTS_H_ */