Update v3.4 driver for v3.5 rflib API
[wave300.git] / wireless / driver / shared / aocs.h
blob4044d7608b5fee5d98ee1e18d8aba39bca2d7cc8
1 /******************************************************************************
3 Copyright (c) 2012
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
7 this software module.
9 ******************************************************************************/
10 #ifndef __MTLK_AOCS_H__
11 #define __MTLK_AOCS_H__
13 #include "mtlk_osal.h"
15 #include "mhi_umi.h"
16 #include "mtlklist.h"
18 #include "txmm.h"
19 #include "frame.h"
21 #include "aocshistory.h"
22 #include "mtlk_clipboard.h"
24 #define MTLK_IDEFS_ON
25 #include "mtlkidefs.h"
27 #include "bt_acs.h"
29 #ifdef MTCFG_DEBUG
30 #define AOCS_DEBUG
31 /* #define BT_ACS_DEBUG */
32 #endif
34 #define MTLK_AOCS_PENALTIES_BUFSIZE 2
35 #define AOCS_SCAN_RANK_INVALID (255)
36 #define AOCS_CONFIRM_RANK_INVALID (255)
38 /* restrict channels mode */
39 enum {
40 AOCS_RESTRICT_CHAN_MODE_PRIMARY = 0,
41 AOCS_RESTRICT_CHAN_MODE_ALL,
42 AOCS_RESTRICT_CHAN_MODE_LAST
45 typedef enum _mtlk_aocs_weight_e {
46 AOCS_WEIGHT_IDX_CL,
47 AOCS_WEIGHT_IDX_TX,
48 AOCS_WEIGHT_IDX_BSS,
49 AOCS_WEIGHT_IDX_SM,
50 AOCS_WEIGHT_IDX_LAST
51 } mtlk_aocs_weight_e;
53 typedef struct _mtlk_aocs_channels_stat_t {
54 /* interference */
55 BOOL DrIf;
56 uint32 FwIf;
57 int8 fl_noise_metric;
58 int8 noise_current;
59 /* affected by 40MHz intolerance */
60 BOOL forty_mhz_int_affected;
61 BOOL forty_mhz_intolerant;
62 BOOL sm_required;
63 uint16 channel;
64 uint16 nof_bss;
65 uint8 channel_load;
66 uint16 num_20mhz_bss;
67 uint16 num_40mhz_up_bss;
68 uint16 num_40mhz_lw_bss;
69 } __MTLK_IDATA mtlk_aocs_channels_stat_t;
71 typedef struct {
72 uint8 channel;
73 int8 DetMetric;
74 int8 MaxMetric;
75 int8 MinMetric;
76 int8 selected_threshold;
77 } __MTLK_IDATA mtlk_aocs_interfered_stat_entry_t;
79 /* channel's list entry */
80 typedef struct _mtlk_aocs_channel_data_t {
81 mtlk_aocs_channels_stat_t stat;
82 mtlk_osal_timestamp_t time_cl;
84 /* linked list */
85 mtlk_slist_entry_t link_entry;
86 } __MTLK_IDATA mtlk_aocs_channel_data_t;
88 /* AOCS supported events */
89 typedef enum _mtlk_aocs_event_e {
90 /* on radar detected */
91 MTLK_AOCS_EVENT_RADAR_DETECTED,
92 /* request to select a new channel */
93 MTLK_AOCS_EVENT_SELECT_CHANNEL,
94 /* channel switch started */
95 MTLK_AOCS_EVENT_SWITCH_STARTED,
96 /* channel switch done */
97 MTLK_AOCS_EVENT_SWITCH_DONE,
98 /* initial channel selected */
99 MTLK_AOCS_EVENT_INITIAL_SELECTED,
100 /* MAC TCP AOCS indication received */
101 MTLK_AOCS_EVENT_TCP_IND,
102 /* on interference detection */
103 MTLK_AOCS_EVENT_INTERF_IND,
104 /* interference detection statistics */
105 MTLK_AOCS_EVENT_INTERF_STAT,
106 MTLK_AOCS_EVENT_LAST
107 } mtlk_aocs_event_e;
109 /* on channel select event data */
110 typedef struct _mtlk_aocs_evt_select_t {
111 uint16 channel;
112 uint8 bonding;
113 mtlk_aocs_channel_switch_reasons_t reason;
114 channel_criteria_t criteria;
115 channel_criteria_details_t criteria_details;
116 } mtlk_aocs_evt_select_t;
118 /* API */
119 typedef struct _mtlk_aocs_wrap_api_t {
120 /* card's context */
121 void (__MTLK_IDATA *on_channel_change)(mtlk_vap_handle_t vap_handle, int channel);
122 void (__MTLK_IDATA *on_bonding_change)(mtlk_vap_handle_t vap_handle, uint8 bonding);
123 void (__MTLK_IDATA *on_spectrum_change)(mtlk_vap_handle_t vap_handle, int spectrum);
124 } __MTLK_IDATA mtlk_aocs_wrap_api_t;
126 struct mtlk_scan;
127 struct _mtlk_dot11h_t;
128 struct _scan_cache_t;
130 typedef struct _mtlk_aocs_init_t {
131 mtlk_aocs_wrap_api_t *api;
132 struct mtlk_scan *scan_data;
133 struct _scan_cache_t *cache;
134 struct _mtlk_dot11h_t *dot11h;
135 mtlk_txmm_t *txmm;
136 BOOL disable_sm_channels;
137 } mtlk_aocs_init_t;
139 typedef struct {
140 mtlk_osal_msec_t time_ms_non_occupied_period;
141 mtlk_osal_msec_t time_ms_last_clear_check;
142 BOOL radar_detected;
143 BOOL is_in_radar_timeout;
144 BOOL dont_use;
145 BOOL exclude;
146 uint16 channel_primary;
147 uint16 channel_secondary;
148 uint16 tx_power;
149 uint16 max_tx_power;
150 uint16 tx_power_penalty;
151 uint8 channel_load;
152 uint8 scan_rank;
153 uint8 confirm_rank;
154 uint16 nof_bss_in_range;
155 uint8 sm;
156 uint8 is_noisy;
157 int8 floor_noise_metric;
158 int8 noise_current;
159 uint32 bt_acs_excl_reason;
160 } __MTLK_IDATA mtlk_aocs_table_stat_entry_t;
162 typedef struct {
163 uint16 freq;
164 uint16 penalty;
165 } __MTLK_IDATA mtlk_aocs_penalties_stat_entry_t;
167 typedef struct _mtlk_aocs_t mtlk_aocs_t;
169 mtlk_aocs_t* __MTLK_IFUNC mtlk_aocs_create (mtlk_aocs_init_t *ini_data, mtlk_vap_handle_t vap_handle);
170 void __MTLK_IFUNC mtlk_aocs_delete (mtlk_aocs_t *aocs);
171 int __MTLK_IFUNC mtlk_aocs_start (mtlk_aocs_t *aocs, BOOL keep_chnl_info, BOOL is_20_40_coexistence_active);
172 void __MTLK_IFUNC mtlk_aocs_stop (mtlk_aocs_t *aocs);
174 int __MTLK_IFUNC mtlk_aocs_start_watchdog (mtlk_aocs_t *aocs);
175 void __MTLK_IFUNC mtlk_aocs_stop_watchdog (mtlk_aocs_t *aocs);
177 int __MTLK_IFUNC mtlk_aocs_indicate_event (mtlk_aocs_t *aocs,
178 mtlk_aocs_event_e event, void *data, uint32 data_size);
179 int __MTLK_IFUNC mtlk_aocs_channel_in_validity_time(mtlk_aocs_t *aocs);
180 int __MTLK_IFUNC mtlk_aocs_update_cl_on_scan_cfm (mtlk_aocs_t *aocs, void* data);
181 void __MTLK_IFUNC mtlk_aocs_update_cl (mtlk_aocs_t *aocs, uint16 channel, uint8 channel_load);
182 void __MTLK_IFUNC aocs_optimize_channel(mtlk_aocs_t *aocs, mtlk_aocs_channel_switch_reasons_t reason);
184 int __MTLK_IFUNC mtlk_aocs_get_history(mtlk_aocs_t *aocs, mtlk_clpb_t *clpb);
185 int __MTLK_IFUNC mtlk_aocs_get_table (mtlk_aocs_t *aocs, mtlk_clpb_t *clpb);
186 int __MTLK_IFUNC mtlk_aocs_get_channels (mtlk_aocs_t *aocs, mtlk_clpb_t *clpb);
187 int __MTLK_IFUNC mtlk_aocs_get_penalties (mtlk_aocs_t *aocs, mtlk_clpb_t *clpb);
188 int __MTLK_IFUNC mtlk_aocs_get_interfered(mtlk_aocs_t *aocs, mtlk_clpb_t *clpb);
190 int __MTLK_IFUNC mtlk_aocs_get_weight(mtlk_aocs_t *aocs, mtlk_aocs_weight_e index);
191 int __MTLK_IFUNC mtlk_aocs_set_weight(mtlk_aocs_t *aocs, mtlk_aocs_weight_e index, int32 weight);
193 int __MTLK_IFUNC mtlk_aocs_get_cfm_rank_sw_threshold(mtlk_aocs_t *aocs);
194 int __MTLK_IFUNC mtlk_aocs_set_cfm_rank_sw_threshold(mtlk_aocs_t *aocs, uint8 value);
195 int __MTLK_IFUNC mtlk_aocs_get_scan_aging(mtlk_aocs_t *aocs);
196 int __MTLK_IFUNC mtlk_aocs_set_scan_aging(mtlk_aocs_t *aocs, int value);
197 int __MTLK_IFUNC mtlk_aocs_get_confirm_rank_aging(mtlk_aocs_t *aocs);
198 int __MTLK_IFUNC mtlk_aocs_set_confirm_rank_aging(mtlk_aocs_t *aocs, int value);
199 int __MTLK_IFUNC mtlk_aocs_get_afilter(mtlk_aocs_t *aocs);
200 int __MTLK_IFUNC mtlk_aocs_set_afilter(mtlk_aocs_t *aocs, uint8 value);
201 int __MTLK_IFUNC mtlk_aocs_get_penalty_enabled(mtlk_aocs_t *aocs);
202 int __MTLK_IFUNC mtlk_aocs_set_penalty_enabled(mtlk_aocs_t *aocs, BOOL value);
204 void __MTLK_IFUNC mtlk_aocs_on_rcvry_isol(mtlk_aocs_t *aocs);
205 int __MTLK_IFUNC mtlk_aocs_on_rcvry_restore(mtlk_aocs_t *aocs);
207 #ifdef AOCS_DEBUG
208 void mtlk_aocs_debug_update_cl(mtlk_aocs_t *aocs, uint32 cl);
209 #endif
211 #ifdef BT_ACS_DEBUG
212 void mtlk_aocs_set_channels_dbg(mtlk_aocs_t *aocs, mtlk_aocs_channel_data_t *entry);
213 mtlk_slist_t* get_aocs_channel_list(mtlk_aocs_t *aocs);
214 #endif /* BT_ACS_DEBUG */
216 int __MTLK_IFUNC mtlk_aocs_get_msdu_threshold(mtlk_aocs_t *aocs);
217 int __MTLK_IFUNC mtlk_aocs_set_msdu_threshold(mtlk_aocs_t *aocs, uint32 value);
218 int __MTLK_IFUNC mtlk_aocs_get_lower_threshold(mtlk_aocs_t *aocs);
219 int __MTLK_IFUNC mtlk_aocs_set_lower_threshold(mtlk_aocs_t *aocs, uint32 value);
220 int __MTLK_IFUNC mtlk_aocs_get_threshold_window(mtlk_aocs_t *aocs);
221 int __MTLK_IFUNC mtlk_aocs_set_threshold_window(mtlk_aocs_t *aocs, uint32 value);
223 int __MTLK_IFUNC mtlk_aocs_get_win_time(mtlk_aocs_t *aocs);
224 int __MTLK_IFUNC mtlk_aocs_set_win_time(mtlk_aocs_t *aocs, uint32 value);
225 int __MTLK_IFUNC mtlk_aocs_get_msdu_win_thr(mtlk_aocs_t *aocs);
226 int __MTLK_IFUNC mtlk_aocs_set_msdu_win_thr(mtlk_aocs_t *aocs, uint32 value);
227 int __MTLK_IFUNC mtlk_aocs_get_msdu_debug_enabled(mtlk_aocs_t *aocs);
228 int __MTLK_IFUNC mtlk_aocs_set_msdu_debug_enabled(mtlk_aocs_t *aocs, uint32 value);
229 int __MTLK_IFUNC mtlk_aocs_get_type(mtlk_aocs_t *aocs);
230 int __MTLK_IFUNC mtlk_aocs_set_type(mtlk_aocs_t *aocs, uint32 value);
231 BOOL __MTLK_IFUNC mtlk_aocs_is_type_none(mtlk_aocs_t *aocs);
233 struct _mtlk_aocs_ac_t;
234 void __MTLK_IFUNC mtlk_aocs_get_restricted_ch(mtlk_aocs_t *aocs, uint8 *restr_chnl);
235 void __MTLK_IFUNC mtlk_aocs_set_restricted_ch(mtlk_aocs_t *aocs, uint8 *restr_chnl);
236 size_t __MTLK_IFUNC mtlk_aocs_get_tx_penalty(mtlk_handle_t handle, char *buffer);
237 int __MTLK_IFUNC mtlk_aocs_set_tx_penalty (mtlk_aocs_t *aocs, int32 *v, int nof_ints);
238 void __MTLK_IFUNC mtlk_aocs_get_msdu_tx_ac(mtlk_aocs_t *aocs, struct _mtlk_aocs_ac_t *ac);
239 int __MTLK_IFUNC mtlk_aocs_set_msdu_tx_ac(mtlk_aocs_t *aocs, struct _mtlk_aocs_ac_t *ac);
240 void __MTLK_IFUNC mtlk_aocs_get_msdu_rx_ac(mtlk_aocs_t *aocs, struct _mtlk_aocs_ac_t *ac);
241 int __MTLK_IFUNC mtlk_aocs_set_msdu_rx_ac(mtlk_aocs_t *aocs, struct _mtlk_aocs_ac_t *ac);
242 int __MTLK_IFUNC mtlk_aocs_set_non_wifi_interf_is_enabled(mtlk_aocs_t *aocs, BOOL value);
243 int __MTLK_IFUNC mtlk_aocs_set_non_wifi_ch_load_trh(mtlk_aocs_t *aocs, uint8 value);
244 int __MTLK_IFUNC mtlk_aocs_set_non_wifi_RSSI_trh(mtlk_aocs_t *aocs, int8 value);
245 struct _mtlk_interf_t;
246 void __MTLK_IFUNC mtlk_aocs_get_non_wifi_interf(mtlk_aocs_t *aocs, struct _mtlk_interf_t *non_wifi_interf);
248 #ifndef MBSS_FORCE_NO_AOCS_INITIAL_SELECTION
249 void __MTLK_IFUNC mtlk_aocs_on_bss_data_update(mtlk_aocs_t *aocs, bss_data_t *bss_data);
250 #endif
252 BOOL __MTLK_IFUNC mtlk_aocs_set_auto_spectrum(mtlk_aocs_t *aocs, uint8 spectrum);
253 BOOL __MTLK_IFUNC mtlk_aocs_is_unrestricted_available(mtlk_aocs_t *aocs, uint8 *exclude_chans);
254 BOOL __MTLK_IFUNC mtlk_aocs_is_restricted_chnl(mtlk_aocs_t *aocs, uint16 channel);
256 /* NOTE: aocs_effective_tx_ac[ac] and aocs_effective_rx_ac[ac] become 0 when
257 * some of the following conditions are true:
258 * - AOCS is disabled
259 * - a non-UDP AOCS algorithm is enabled (for example, TCP)
260 * - UDP AOCS algotrithm for this AC is disabled by user
263 #ifndef MBSS_FORCE_NO_CHANNEL_SWITCH
264 void __MTLK_IFUNC /*HOTPATH*/
265 mtlk_aocs_on_tx_msdu_sent(mtlk_aocs_t *aocs, uint8 ac,
266 uint16 sq_size_limit, uint16 sq_used);
268 void __MTLK_IFUNC /*HOTPATH*/
269 mtlk_aocs_on_tx_msdu_enqued(mtlk_aocs_t *aocs, uint16 ac,
270 uint16 sq_size, uint16 sq_size_limit);
272 void __MTLK_IFUNC /*HOTPATH*/
273 mtlk_aocs_on_tx_msdu_returned (mtlk_aocs_t *aocs, uint8 ac);
275 void __MTLK_IFUNC /*HOTPATH*/
276 mtlk_aocs_on_rx_msdu (mtlk_aocs_t *aocs, uint8 ac);
277 #endif
279 void __MTLK_IFUNC
280 mtlk_aocs_enable_smrequired(mtlk_aocs_t *aocs);
282 void __MTLK_IFUNC
283 mtlk_aocs_disable_smrequired(mtlk_aocs_t *aocs);
285 BOOL __MTLK_IFUNC
286 mtlk_aocs_is_smrequired_disabled(mtlk_aocs_t *aocs);
288 mtlk_aocs_channel_switch_reasons_t __MTLK_IFUNC
289 mtlk_aocs_get_last_switch_reason(mtlk_aocs_t *aocs);
291 /****************************************************************************
292 * TCP AOCS algorithm related stuff
293 ****************************************************************************/
294 int __MTLK_IFUNC
295 mtlk_aocs_set_measurement_window (mtlk_aocs_t *aocs, uint16 val);
297 uint16 __MTLK_IFUNC
298 mtlk_aocs_get_measurement_window (mtlk_aocs_t *aocs);
300 int __MTLK_IFUNC
301 mtlk_aocs_set_troughput_threshold (mtlk_aocs_t *aocs, uint32 val);
303 uint32 __MTLK_IFUNC
304 mtlk_aocs_get_troughput_threshold (mtlk_aocs_t *aocs);
306 uint8 __MTLK_IFUNC
307 mtlk_aocs_get_spectrum_mode(mtlk_aocs_t *aocs);
309 void __MTLK_IFUNC
310 mtlk_aocs_set_spectrum_mode(mtlk_aocs_t *aocs, uint8 spectrum_mode);
312 void __MTLK_IFUNC
313 mtlk_aocs_set_bonding(mtlk_aocs_t *aocs, uint8 bonding);
315 uint8 __MTLK_IFUNC
316 mtlk_aocs_get_bonding(mtlk_aocs_t *aocs);
318 uint16 __MTLK_IFUNC
319 mtlk_aocs_get_cur_channel(mtlk_aocs_t *aocs);
321 void __MTLK_IFUNC
322 mtlk_aocs_set_dbg_non_occupied_period(mtlk_aocs_t *aocs, int8 dbg_non_occupied_period);
324 int8 __MTLK_IFUNC
325 mtlk_aocs_get_dbg_non_occupied_period(mtlk_aocs_t *aocs);
327 void __MTLK_IFUNC
328 mtlk_aocs_set_restrict_mode(mtlk_aocs_t *aocs, uint8 restrict_mode);
330 uint8 __MTLK_IFUNC
331 mtlk_aocs_get_restrict_mode(mtlk_aocs_t *aocs);
333 void __MTLK_IFUNC
334 mtlk_aocs_set_config_is_ht(mtlk_aocs_t *aocs, BOOL is_ht);
336 void __MTLK_IFUNC
337 mtlk_aocs_set_config_frequency_band(mtlk_aocs_t *aocs, uint8 frequency_band);
339 uint16 __MTLK_IFUNC
340 mtlk_aocs_get_channel_availability_check_time(mtlk_aocs_t *aocs);
342 #ifndef MBSS_FORCE_NO_CHANNEL_SWITCH
343 void __MTLK_IFUNC
344 mtlk_aocs_msdu_tx_inc_nof_used(mtlk_aocs_t *aocs, uint8 ac);
346 void __MTLK_IFUNC
347 mtlk_aocs_msdu_tx_dec_nof_used(mtlk_aocs_t *aocs, uint8 ac);
348 #endif
350 mtlk_aocs_channel_data_t **__MTLK_IFUNC
351 mtlk_aocs_create_chann_arr_asc(mtlk_aocs_t *aocs);
353 uint32 __MTLK_IFUNC
354 mtlk_aocs_chan_list_size(mtlk_aocs_t *aocs);
356 void __MTLK_IFUNC
357 mtlk_aocs_scan_floor_noise_ind(mtlk_aocs_t *aocs, UMI_INTERFERER *umi_interf_ind);
359 BOOL __MTLK_IFUNC
360 mtlk_aocs_find_secondary_channel_no(mtlk_aocs_t *aocs, uint16 primary, uint16 secondary);
362 #define MTLK_IDEFS_OFF
363 #include "mtlkidefs.h"
365 #endif