1 /******************************************************************************
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
9 ******************************************************************************/
10 #ifndef __MTLK_AOCS_H__
11 #define __MTLK_AOCS_H__
13 #include "mtlk_osal.h"
21 #include "aocshistory.h"
22 #include "mtlk_clipboard.h"
25 #include "mtlkidefs.h"
31 /* #define BT_ACS_DEBUG */
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 */
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
{
53 typedef struct _mtlk_aocs_channels_stat_t
{
59 /* affected by 40MHz intolerance */
60 BOOL forty_mhz_int_affected
;
61 BOOL forty_mhz_intolerant
;
67 uint16 num_40mhz_up_bss
;
68 uint16 num_40mhz_lw_bss
;
69 } __MTLK_IDATA mtlk_aocs_channels_stat_t
;
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
;
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
,
109 /* on channel select event data */
110 typedef struct _mtlk_aocs_evt_select_t
{
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
;
119 typedef struct _mtlk_aocs_wrap_api_t
{
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
;
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
;
136 BOOL disable_sm_channels
;
140 mtlk_osal_msec_t time_ms_non_occupied_period
;
141 mtlk_osal_msec_t time_ms_last_clear_check
;
143 BOOL is_in_radar_timeout
;
146 uint16 channel_primary
;
147 uint16 channel_secondary
;
150 uint16 tx_power_penalty
;
154 uint16 nof_bss_in_range
;
157 int8 floor_noise_metric
;
159 uint32 bt_acs_excl_reason
;
160 } __MTLK_IDATA mtlk_aocs_table_stat_entry_t
;
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
);
208 void mtlk_aocs_debug_update_cl(mtlk_aocs_t
*aocs
, uint32 cl
);
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
);
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:
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
);
280 mtlk_aocs_enable_smrequired(mtlk_aocs_t
*aocs
);
283 mtlk_aocs_disable_smrequired(mtlk_aocs_t
*aocs
);
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 ****************************************************************************/
295 mtlk_aocs_set_measurement_window (mtlk_aocs_t
*aocs
, uint16 val
);
298 mtlk_aocs_get_measurement_window (mtlk_aocs_t
*aocs
);
301 mtlk_aocs_set_troughput_threshold (mtlk_aocs_t
*aocs
, uint32 val
);
304 mtlk_aocs_get_troughput_threshold (mtlk_aocs_t
*aocs
);
307 mtlk_aocs_get_spectrum_mode(mtlk_aocs_t
*aocs
);
310 mtlk_aocs_set_spectrum_mode(mtlk_aocs_t
*aocs
, uint8 spectrum_mode
);
313 mtlk_aocs_set_bonding(mtlk_aocs_t
*aocs
, uint8 bonding
);
316 mtlk_aocs_get_bonding(mtlk_aocs_t
*aocs
);
319 mtlk_aocs_get_cur_channel(mtlk_aocs_t
*aocs
);
322 mtlk_aocs_set_dbg_non_occupied_period(mtlk_aocs_t
*aocs
, int8 dbg_non_occupied_period
);
325 mtlk_aocs_get_dbg_non_occupied_period(mtlk_aocs_t
*aocs
);
328 mtlk_aocs_set_restrict_mode(mtlk_aocs_t
*aocs
, uint8 restrict_mode
);
331 mtlk_aocs_get_restrict_mode(mtlk_aocs_t
*aocs
);
334 mtlk_aocs_set_config_is_ht(mtlk_aocs_t
*aocs
, BOOL is_ht
);
337 mtlk_aocs_set_config_frequency_band(mtlk_aocs_t
*aocs
, uint8 frequency_band
);
340 mtlk_aocs_get_channel_availability_check_time(mtlk_aocs_t
*aocs
);
342 #ifndef MBSS_FORCE_NO_CHANNEL_SWITCH
344 mtlk_aocs_msdu_tx_inc_nof_used(mtlk_aocs_t
*aocs
, uint8 ac
);
347 mtlk_aocs_msdu_tx_dec_nof_used(mtlk_aocs_t
*aocs
, uint8 ac
);
350 mtlk_aocs_channel_data_t
**__MTLK_IFUNC
351 mtlk_aocs_create_chann_arr_asc(mtlk_aocs_t
*aocs
);
354 mtlk_aocs_chan_list_size(mtlk_aocs_t
*aocs
);
357 mtlk_aocs_scan_floor_noise_ind(mtlk_aocs_t
*aocs
, UMI_INTERFERER
*umi_interf_ind
);
360 mtlk_aocs_find_secondary_channel_no(mtlk_aocs_t
*aocs
, uint16 primary
, uint16 secondary
);
362 #define MTLK_IDEFS_OFF
363 #include "mtlkidefs.h"