1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #ifndef __RTW_MLME_EXT_H_
8 #define __RTW_MLME_EXT_H_
9 
10 
11 /* 	Commented by Albert 20101105 */
12 /* 	Increase the SURVEY_TO value from 100 to 150  (100ms to 150ms) */
13 /* 	The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
14 /* 	So, this driver tried to extend the dwell time for each scanning channel. */
15 /* 	This will increase the chance to receive the probe response from SoftAP. */
16 
17 #define SURVEY_TO		(100)
18 #define REAUTH_TO		(300) /* 50) */
19 #define REASSOC_TO		(300) /* 50) */
20 /* define DISCONNECT_TO	(3000) */
21 #define ADDBA_TO			(2000)
22 
23 #define LINKED_TO (1) /* unit:2 sec, 1x2 =2 sec */
24 
25 #define REAUTH_LIMIT	(4)
26 #define REASSOC_LIMIT	(4)
27 #define READDBA_LIMIT	(2)
28 
29 #define ROAMING_LIMIT	8
30 /* define	IOCMD_REG0		0x10250370 */
31 /* define	IOCMD_REG1		0x10250374 */
32 /* define	IOCMD_REG2		0x10250378 */
33 
34 /* define	FW_DYNAMIC_FUN_SWITCH	0x10250364 */
35 
36 /* define	WRITE_BB_CMD		0xF0000001 */
37 /* define	SET_CHANNEL_CMD	0xF3000000 */
38 /* define	UPDATE_RA_CMD	0xFD0000A2 */
39 
40 #define DYNAMIC_FUNC_DISABLE		(0x0)
41 
42 /*  ====== ODM_ABILITY_E ======== */
43 /*  BB ODM section BIT 0-15 */
44 #define DYNAMIC_BB_DIG				BIT0 /* ODM_BB_DIG */
45 #define DYNAMIC_BB_RA_MASK			BIT1 /* ODM_BB_RA_MASK */
46 #define DYNAMIC_BB_DYNAMIC_TXPWR	BIT2 /* ODM_BB_DYNAMIC_TXPWR */
47 #define DYNAMIC_BB_BB_FA_CNT		BIT3 /* ODM_BB_FA_CNT */
48 #define DYNAMIC_BB_RSSI_MONITOR		BIT4 /* ODM_BB_RSSI_MONITOR */
49 #define DYNAMIC_BB_CCK_PD			BIT5 /* ODM_BB_CCK_PD */
50 #define DYNAMIC_BB_ANT_DIV			BIT6 /* ODM_BB_ANT_DIV */
51 #define DYNAMIC_BB_PWR_SAVE			BIT7 /* ODM_BB_PWR_SAVE */
52 #define DYNAMIC_BB_PWR_TRAIN		BIT8 /* ODM_BB_PWR_TRAIN */
53 #define DYNAMIC_BB_RATE_ADAPTIVE	BIT9 /* ODM_BB_RATE_ADAPTIVE */
54 #define DYNAMIC_BB_PATH_DIV			BIT10/* ODM_BB_PATH_DIV */
55 #define DYNAMIC_BB_PSD				BIT11/* ODM_BB_PSD */
56 #define DYNAMIC_BB_RXHP				BIT12/* ODM_BB_RXHP */
57 #define DYNAMIC_BB_ADAPTIVITY		BIT13/* ODM_BB_ADAPTIVITY */
58 #define DYNAMIC_BB_DYNAMIC_ATC		BIT14/* ODM_BB_DYNAMIC_ATC */
59 
60 /*  MAC DM section BIT 16-23 */
61 #define DYNAMIC_MAC_EDCA_TURBO		BIT16/* ODM_MAC_EDCA_TURBO */
62 #define DYNAMIC_MAC_EARLY_MODE		BIT17/* ODM_MAC_EARLY_MODE */
63 
64 /*  RF ODM section BIT 24-31 */
65 #define DYNAMIC_RF_TX_PWR_TRACK		BIT24/* ODM_RF_TX_PWR_TRACK */
66 #define DYNAMIC_RF_RX_GAIN_TRACK	BIT25/* ODM_RF_RX_GAIN_TRACK */
67 #define DYNAMIC_RF_CALIBRATION		BIT26/* ODM_RF_CALIBRATION */
68 
69 #define DYNAMIC_ALL_FUNC_ENABLE		0xFFFFFFF
70 
71 #define _HW_STATE_NOLINK_		0x00
72 #define _HW_STATE_ADHOC_		0x01
73 #define _HW_STATE_STATION_	0x02
74 #define _HW_STATE_AP_			0x03
75 
76 
77 #define		_1M_RATE_	0
78 #define		_2M_RATE_	1
79 #define		_5M_RATE_	2
80 #define		_11M_RATE_	3
81 #define		_6M_RATE_	4
82 #define		_9M_RATE_	5
83 #define		_12M_RATE_	6
84 #define		_18M_RATE_	7
85 #define		_24M_RATE_	8
86 #define		_36M_RATE_	9
87 #define		_48M_RATE_	10
88 #define		_54M_RATE_	11
89 
90 /********************************************************
91 MCS rate definitions
92 *********************************************************/
93 #define MCS_RATE_1R	(0x000000ff)
94 #define MCS_RATE_2R	(0x0000ffff)
95 #define MCS_RATE_3R	(0x00ffffff)
96 #define MCS_RATE_4R	(0xffffffff)
97 #define MCS_RATE_2R_13TO15_OFF	(0x00001fff)
98 
99 
100 extern unsigned char RTW_WPA_OUI[];
101 extern unsigned char WMM_OUI[];
102 extern unsigned char WPS_OUI[];
103 extern unsigned char WFD_OUI[];
104 extern unsigned char P2P_OUI[];
105 
106 extern unsigned char WMM_INFO_OUI[];
107 extern unsigned char WMM_PARA_OUI[];
108 
109 
110 /*  */
111 /*  Channel Plan Type. */
112 /*  Note: */
113 /* 	We just add new channel plan when the new channel plan is different from any of the following */
114 /* 	channel plan. */
115 /* 	If you just want to customize the actions(scan period or join actions) about one of the channel plan, */
116 /* 	customize them in rt_channel_info in the RT_CHANNEL_LIST. */
117 /*  */
118 enum {
119 	/*  old channel plan mapping ===== */
120 	RT_CHANNEL_DOMAIN_FCC = 0x00,
121 	RT_CHANNEL_DOMAIN_IC = 0x01,
122 	RT_CHANNEL_DOMAIN_ETSI = 0x02,
123 	RT_CHANNEL_DOMAIN_SPAIN = 0x03,
124 	RT_CHANNEL_DOMAIN_FRANCE = 0x04,
125 	RT_CHANNEL_DOMAIN_MKK = 0x05,
126 	RT_CHANNEL_DOMAIN_MKK1 = 0x06,
127 	RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
128 	RT_CHANNEL_DOMAIN_TELEC = 0x08,
129 	RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
130 	RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
131 	RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
132 	RT_CHANNEL_DOMAIN_CHINA = 0x0C,
133 	RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
134 	RT_CHANNEL_DOMAIN_KOREA = 0x0E,
135 	RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
136 	RT_CHANNEL_DOMAIN_JAPAN = 0x10,
137 	RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
138 	RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
139 	RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13,
140 	RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
141 
142 	/*  new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
143 	RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
144 	RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
145 	RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
146 	RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
147 	RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
148 	RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
149 	RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
150 	RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
151 	RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
152 	RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
153 	RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
154 	RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
155 	RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
156 	RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
157 	RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
158 	RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
159 	RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
160 	RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
161 	RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
162 	RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
163 	RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
164 	RT_CHANNEL_DOMAIN_GLOBAL_NULL = 0x41,
165 	RT_CHANNEL_DOMAIN_ETSI1_ETSI4 = 0x42,
166 	RT_CHANNEL_DOMAIN_FCC1_FCC2 = 0x43,
167 	RT_CHANNEL_DOMAIN_FCC1_NCC3 = 0x44,
168 	RT_CHANNEL_DOMAIN_WORLD_ETSI5 = 0x45,
169 	RT_CHANNEL_DOMAIN_FCC1_FCC8 = 0x46,
170 	RT_CHANNEL_DOMAIN_WORLD_ETSI6 = 0x47,
171 	RT_CHANNEL_DOMAIN_WORLD_ETSI7 = 0x48,
172 	RT_CHANNEL_DOMAIN_WORLD_ETSI8 = 0x49,
173 	RT_CHANNEL_DOMAIN_WORLD_ETSI9 = 0x50,
174 	RT_CHANNEL_DOMAIN_WORLD_ETSI10 = 0x51,
175 	RT_CHANNEL_DOMAIN_WORLD_ETSI11 = 0x52,
176 	RT_CHANNEL_DOMAIN_FCC1_NCC4 = 0x53,
177 	RT_CHANNEL_DOMAIN_WORLD_ETSI12 = 0x54,
178 	RT_CHANNEL_DOMAIN_FCC1_FCC9 = 0x55,
179 	RT_CHANNEL_DOMAIN_WORLD_ETSI13 = 0x56,
180 	RT_CHANNEL_DOMAIN_FCC1_FCC10 = 0x57,
181 	/*  Add new channel plan above this line =============== */
182 	RT_CHANNEL_DOMAIN_MAX,
183 	RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
184 };
185 
186 enum {
187 	RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,		/* Worldwird 13 */
188 	RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,		/* Europe */
189 	RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,		/* US */
190 	RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03,		/* Japan */
191 	RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04,		/* France */
192 	RT_CHANNEL_DOMAIN_2G_GLOBAL = 0x05,		/* Global domain */
193 	RT_CHANNEL_DOMAIN_2G_NULL = 0x06,
194 	/*  Add new channel plan above this line =============== */
195 	RT_CHANNEL_DOMAIN_2G_MAX,
196 };
197 
198 #define rtw_is_channel_plan_valid(chplan) (chplan < RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
199 
200 struct rt_channel_plan {
201 	unsigned char Channel[MAX_CHANNEL_NUM];
202 	unsigned char Len;
203 };
204 
205 struct rt_channel_plan_2g {
206 	unsigned char Channel[MAX_CHANNEL_NUM_2G];
207 	unsigned char Len;
208 };
209 
210 struct rt_channel_plan_map {
211 	unsigned char Index2G;
212 };
213 
214 enum {
215 	HT_IOT_PEER_UNKNOWN			= 0,
216 	HT_IOT_PEER_REALTEK			= 1,
217 	HT_IOT_PEER_REALTEK_92SE		= 2,
218 	HT_IOT_PEER_BROADCOM		= 3,
219 	HT_IOT_PEER_RALINK			= 4,
220 	HT_IOT_PEER_ATHEROS			= 5,
221 	HT_IOT_PEER_CISCO				= 6,
222 	HT_IOT_PEER_MERU				= 7,
223 	HT_IOT_PEER_MARVELL			= 8,
224 	HT_IOT_PEER_REALTEK_SOFTAP	= 9,/*  peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
225 	HT_IOT_PEER_SELF_SOFTAP			= 10, /*  Self is SoftAP */
226 	HT_IOT_PEER_AIRGO				= 11,
227 	HT_IOT_PEER_INTEL				= 12,
228 	HT_IOT_PEER_RTK_APCLIENT		= 13,
229 	HT_IOT_PEER_REALTEK_81XX		= 14,
230 	HT_IOT_PEER_REALTEK_WOW			= 15,
231 	HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 16,
232 	HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 17,
233 	HT_IOT_PEER_MAX					= 18
234 };
235 
236 
237 enum {
238 	SCAN_DISABLE = 0,
239 	SCAN_START = 1,
240 	SCAN_TXNULL = 2,
241 	SCAN_PROCESS = 3,
242 	SCAN_COMPLETE = 4,
243 	SCAN_STATE_MAX,
244 };
245 
246 struct mlme_handler {
247 	unsigned int   num;
248 	char *str;
249 	unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
250 };
251 
252 struct action_handler {
253 	unsigned int   num;
254 	char *str;
255 	unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
256 };
257 
258 struct	ss_res {
259 	int	state;
260 	int	bss_cnt;
261 	int	channel_idx;
262 	int	scan_mode;
263 	u8 ssid_num;
264 	u8 ch_num;
265 	struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
266 	struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
267 };
268 
269 /* define AP_MODE				0x0C */
270 /* define STATION_MODE	0x08 */
271 /* define AD_HOC_MODE		0x04 */
272 /* define NO_LINK_MODE	0x00 */
273 
274 #define		WIFI_FW_NULL_STATE			_HW_STATE_NOLINK_
275 #define	WIFI_FW_STATION_STATE		_HW_STATE_STATION_
276 #define	WIFI_FW_AP_STATE				_HW_STATE_AP_
277 #define	WIFI_FW_ADHOC_STATE			_HW_STATE_ADHOC_
278 
279 #define	WIFI_FW_AUTH_NULL			0x00000100
280 #define	WIFI_FW_AUTH_STATE			0x00000200
281 #define	WIFI_FW_AUTH_SUCCESS			0x00000400
282 
283 #define	WIFI_FW_ASSOC_STATE			0x00002000
284 #define	WIFI_FW_ASSOC_SUCCESS		0x00004000
285 
286 #define	WIFI_FW_LINKING_STATE		(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE)
287 
288 struct FW_Sta_Info {
289 	struct sta_info *psta;
290 	u32 status;
291 	u32 rx_pkt;
292 	u32 retry;
293 	NDIS_802_11_RATES_EX  SupportedRates;
294 };
295 
296 /*
297  * Usage:
298  * When one iface acted as AP mode and the other iface is STA mode and scanning,
299  * it should switch back to AP's operating channel periodically.
300  * Parameters info:
301  * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
302  * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
303  * Example:
304  * For chip supports 2.4G and AP mode is operating in channel 1,
305  * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MILLISECOND is 3 and SURVEY_TO is 100.
306  * When it's STA mode gets set_scan command,
307  * it would
308  * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
309  * 2. Back to channel 1 for 300 milliseconds
310  * 3. Go through doing site survey on channel 9.10.11
311  * 4. Back to channel 1 for 300 milliseconds
312  * 5. ... and so on, till survey done.
313  */
314 struct mlme_ext_info {
315 	u32 state;
316 	u32 reauth_count;
317 	u32 reassoc_count;
318 	u32 link_count;
319 	u32 auth_seq;
320 	u32 auth_algo;	/*  802.11 auth, could be open, shared, auto */
321 	u32 authModeToggle;
322 	u32 enc_algo;/* encrypt algorithm; */
323 	u32 key_index;	/*  this is only valid for legendary wep, 0~3 for key id. */
324 	u32 iv;
325 	u8 chg_txt[128];
326 	u16 aid;
327 	u16 bcn_interval;
328 	u16 capability;
329 	u8 assoc_AP_vendor;
330 	u8 slotTime;
331 	u8 preamble_mode;
332 	u8 WMM_enable;
333 	u8 ERP_enable;
334 	u8 ERP_IE;
335 	u8 HT_enable;
336 	u8 HT_caps_enable;
337 	u8 HT_info_enable;
338 	u8 HT_protection;
339 	u8 turboMode_cts2self;
340 	u8 turboMode_rtsen;
341 	u8 SM_PS;
342 	u8 agg_enable_bitmap;
343 	u8 ADDBA_retry_count;
344 	u8 candidate_tid_bitmap;
345 	u8 dialogToken;
346 	/*  Accept ADDBA Request */
347 	bool accept_addba_req;
348 	u8 bwmode_updated;
349 	u8 hidden_ssid_mode;
350 	u8 VHT_enable;
351 
352 	struct ADDBA_request		ADDBA_req;
353 	struct WMM_para_element	WMM_param;
354 	struct HT_caps_element	HT_caps;
355 	struct HT_info_element		HT_info;
356 	struct wlan_bssid_ex			network;/* join network or bss_network, if in ap mode, it is the same to cur_network.network */
357 	struct FW_Sta_Info		FW_sta_info[NUM_STA];
358 };
359 
360 /*  The channel information about this channel including joining, scanning, and power constraints. */
361 struct rt_channel_info {
362 	u8 		ChannelNum;		/*  The channel number. */
363 	enum rt_scan_type	ScanType;		/*  Scan type such as passive or active scan. */
364 };
365 
366 int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch);
367 
368 /*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
369 #define P2P_MAX_REG_CLASSES 10
370 
371 /*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class */
372 #define P2P_MAX_REG_CLASS_CHANNELS 20
373 
374 /*   struct p2p_channels - List of supported channels */
375 struct p2p_channels {
376 	/*  struct p2p_reg_class - Supported regulatory class */
377 	struct p2p_reg_class {
378 		/*  reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
379 		u8 reg_class;
380 
381 		/*  channel - Supported channels */
382 		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
383 
384 		/*  channels - Number of channel entries in use */
385 		size_t channels;
386 	} reg_class[P2P_MAX_REG_CLASSES];
387 
388 	/*  reg_classes - Number of reg_class entries in use */
389 	size_t reg_classes;
390 };
391 
392 struct p2p_oper_class_map {
393 	enum hw_mode {IEEE80211G, IEEE80211A} mode;
394 	u8 op_class;
395 	u8 min_chan;
396 	u8 max_chan;
397 	u8 inc;
398 	enum { BW20, BW40PLUS, BW40MINUS } bw;
399 };
400 
401 struct mlme_ext_priv {
402 	struct adapter	*padapter;
403 	u8 mlmeext_init;
404 	atomic_t		event_seq;
405 	u16 mgnt_seq;
406 	u16 sa_query_seq;
407 	u64 mgnt_80211w_IPN;
408 	u64 mgnt_80211w_IPN_rx;
409 	/* struct fw_priv fwpriv; */
410 
411 	unsigned char cur_channel;
412 	unsigned char cur_bwmode;
413 	unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */
414 	unsigned char cur_wireless_mode;	/*  NETWORK_TYPE */
415 
416 	unsigned char max_chan_nums;
417 	struct rt_channel_info		channel_set[MAX_CHANNEL_NUM];
418 	struct p2p_channels channel_list;
419 	unsigned char basicrate[NumRates];
420 	unsigned char datarate[NumRates];
421 	unsigned char default_supported_mcs_set[16];
422 
423 	struct ss_res		sitesurvey_res;
424 	struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
425                                                      /* for ap mode, network includes ap's cap_info */
426 	struct timer_list		survey_timer;
427 	struct timer_list		link_timer;
428 	struct timer_list		sa_query_timer;
429 	/* struct timer_list		ADDBA_timer; */
430 	u16 		chan_scan_time;
431 	unsigned long last_scan_time;
432 	u8 scan_abort;
433 	u8 tx_rate; /*  TXRATE when USERATE is set. */
434 
435 	u32 retry; /* retry for issue probereq */
436 
437 	u64 TSFValue;
438 
439 	/* for LPS-32K to adaptive bcn early and timeout */
440 	u8 adaptive_tsf_done;
441 	u32 bcn_delay_cnt[9];
442 	u32 bcn_delay_ratio[9];
443 	u32 bcn_cnt;
444 	u8 DrvBcnEarly;
445 	u8 DrvBcnTimeOut;
446 
447 	unsigned char bstart_bss;
448 
449 	u8 update_channel_plan_by_ap_done;
450 
451 	/* recv_decache check for Action_public frame */
452 	u8 action_public_dialog_token;
453 	u16  action_public_rxseq;
454 
455 	u8 active_keep_alive_check;
456 #ifdef DBG_FIXED_CHAN
457 	u8 fixed_chan;
458 #endif
459 
460 };
461 
462 void init_mlme_default_rate_set(struct adapter *padapter);
463 void init_mlme_ext_priv(struct adapter *padapter);
464 int init_hw_mlme_ext(struct adapter *padapter);
465 void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext);
466 extern void init_mlme_ext_timer(struct adapter *padapter);
467 extern void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta);
468 extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
469 
470 /* void fill_fwpriv(struct adapter *padapter, struct fw_priv *pfwpriv); */
471 
472 u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta);
473 
474 void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len);
475 void set_mcs_rate_by_mask(u8 *mcs_set, u32 mask);
476 void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS);
477 void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen);
478 
479 void Save_DM_Func_Flag(struct adapter *padapter);
480 void Restore_DM_Func_Flag(struct adapter *padapter);
481 void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable);
482 
483 void Set_MSR(struct adapter *padapter, u8 type);
484 
485 u8 rtw_get_oper_ch(struct adapter *adapter);
486 void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
487 u8 rtw_get_oper_bw(struct adapter *adapter);
488 void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
489 u8 rtw_get_oper_choffset(struct adapter *adapter);
490 void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
491 u8 rtw_get_center_ch(u8 channel, u8 chnl_bw, u8 chnl_offset);
492 unsigned long rtw_get_on_cur_ch_time(struct adapter *adapter);
493 
494 void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode);
495 void SelectChannel(struct adapter *padapter, unsigned char channel);
496 
497 unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);
498 
499 void read_cam(struct adapter *padapter, u8 entry, u8 *get_key);
500 
501 /* modify HW only */
502 void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
503 void _clear_cam_entry(struct adapter *padapter, u8 entry);
504 
505 /* modify both HW and cache */
506 void write_cam(struct adapter *padapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
507 void clear_cam_entry(struct adapter *padapter, u8 id);
508 
509 /* modify cache only */
510 void write_cam_cache(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
511 void clear_cam_cache(struct adapter *adapter, u8 id);
512 
513 void invalidate_cam_all(struct adapter *padapter);
514 
515 
516 int allocate_fw_sta_entry(struct adapter *padapter);
517 void flush_all_cam_entry(struct adapter *padapter);
518 
519 void site_survey(struct adapter *padapter);
520 u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid);
521 void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *padapter, bool update_ie);
522 
523 u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork);
524 u16 get_beacon_interval(struct wlan_bssid_ex *bss);
525 
526 int is_client_associated_to_ap(struct adapter *padapter);
527 int is_client_associated_to_ibss(struct adapter *padapter);
528 int is_IBSS_empty(struct adapter *padapter);
529 
530 unsigned char check_assoc_AP(u8 *pframe, uint len);
531 
532 int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
533 void WMMOnAssocRsp(struct adapter *padapter);
534 
535 void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
536 void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
537 void HTOnAssocRsp(struct adapter *padapter);
538 
539 void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE);
540 void VCS_update(struct adapter *padapter, struct sta_info *psta);
541 void update_ldpc_stbc_cap(struct sta_info *psta);
542 
543 void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
544 int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len);
545 void update_IOT_info(struct adapter *padapter);
546 void update_capinfo(struct adapter *Adapter, u16 updateCap);
547 void update_wireless_mode(struct adapter *padapter);
548 void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode);
549 int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx);
550 
551 /* for sta/adhoc mode */
552 void update_sta_info(struct adapter *padapter, struct sta_info *psta);
553 void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta);
554 void set_sta_rate(struct adapter *padapter, struct sta_info *psta);
555 
556 unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
557 
558 unsigned char get_highest_rate_idx(u32 mask);
559 int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode);
560 unsigned int is_ap_in_tkip(struct adapter *padapter);
561 
562 s16 rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid);
563 s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid);
564 void rtw_camid_free(struct adapter *adapter, u8 cam_id);
565 
566 extern void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta);
567 extern void rtw_release_macid(struct adapter *padapter, struct sta_info *psta);
568 extern u8 rtw_search_max_mac_id(struct adapter *padapter);
569 
570 void report_join_res(struct adapter *padapter, int res);
571 void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame);
572 void report_surveydone_event(struct adapter *padapter);
573 void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
574 void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx);
575 void report_wmm_edca_update(struct adapter *padapter);
576 
577 u8 chk_bmc_sleepq_cmd(struct adapter *padapter);
578 extern u8 set_tx_beacon_cmd(struct adapter *padapter);
579 unsigned int setup_beacon_frame(struct adapter *padapter, unsigned char *beacon_frame);
580 void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
581 void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib);
582 void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *pmgntframe);
583 void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe);
584 s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms);
585 s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe);
586 
587 void issue_beacon(struct adapter *padapter, int timeout_ms);
588 void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq);
589 void issue_assocreq(struct adapter *padapter);
590 void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
591 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
592 void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
593 s32 issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, u8 ch, bool append_wps, int try_cnt, int wait_ms);
594 int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
595 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
596 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
597 int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason);
598 int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, int wait_ms);
599 void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status);
600 void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short tid);
601 unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
602 unsigned int send_beacon(struct adapter *padapter);
603 
604 void start_clnt_assoc(struct adapter *padapter);
605 void start_clnt_auth(struct adapter *padapter);
606 void start_clnt_join(struct adapter *padapter);
607 void start_create_ibss(struct adapter *padapter);
608 
609 unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame);
610 unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame);
611 unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame);
612 unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame);
613 unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame);
614 unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame);
615 unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame);
616 unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame);
617 unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame);
618 unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame);
619 unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame);
620 unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame);
621 
622 unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frame);
623 unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame);
624 unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame);
625 unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame);
626 unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precv_frame);
627 
628 void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
629 void mlmeext_sta_del_event_callback(struct adapter *padapter);
630 void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta);
631 
632 void linked_status_chk(struct adapter *padapter);
633 
634 void _linked_info_dump(struct adapter *padapter);
635 
636 void survey_timer_hdl(struct timer_list *t);
637 void link_timer_hdl(struct timer_list *t);
638 void addba_timer_hdl(struct timer_list *t);
639 void sa_query_timer_hdl(struct timer_list *t);
640 /* void reauth_timer_hdl(struct adapter *padapter); */
641 /* void reassoc_timer_hdl(struct adapter *padapter); */
642 
643 #define set_survey_timer(mlmeext, ms) \
644 	do { \
645 		_set_timer(&(mlmeext)->survey_timer, (ms)); \
646 	} while (0)
647 
648 #define set_link_timer(mlmeext, ms) \
649 	do { \
650 		_set_timer(&(mlmeext)->link_timer, (ms)); \
651 	} while (0)
652 #define set_sa_query_timer(mlmeext, ms) \
653 	do { \
654 		_set_timer(&(mlmeext)->sa_query_timer, (ms)); \
655 	} while (0)
656 
657 extern void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);
658 
659 extern void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
660 extern void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext);
661 extern void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
662 extern u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer);
663 
664 int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset);
665 int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset);
666 
667 struct cmd_hdl {
668 	uint	parmsize;
669 	u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf);
670 };
671 
672 
673 u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
674 u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
675 u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
676 u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
677 u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
678 u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
679 
680 
681 u8 NULL_hdl(struct adapter *padapter, u8 *pbuf);
682 u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
683 u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
684 u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
685 u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
686 u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
687 u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
688 u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
689 u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
690 u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
691 u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
692 u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);
693 
694 u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
695 u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
696 u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf);
697 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
698 u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
699 u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
700 u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);	/* Kurt: Handling DFS channel switch announcement ie. */
701 u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
702 u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf);
703 
704 
705 #define GEN_DRV_CMD_HANDLER(size, cmd)	{size, &cmd ## _hdl},
706 #define GEN_MLME_EXT_HANDLER(size, cmd)	{size, cmd},
707 
708 struct C2HEvent_Header {
709 
710 #ifdef __LITTLE_ENDIAN
711 
712 	unsigned int len:16;
713 	unsigned int ID:8;
714 	unsigned int seq:8;
715 #else
716 	unsigned int seq:8;
717 	unsigned int ID:8;
718 	unsigned int len:16;
719 #endif
720 	unsigned int rsvd;
721 };
722 
723 void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf);
724 void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf);
725 
726 enum {
727 	GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
728 	GEN_EVT_CODE(_Read_BBREG),
729 	GEN_EVT_CODE(_Read_RFREG),
730 	GEN_EVT_CODE(_Read_EEPROM),
731 	GEN_EVT_CODE(_Read_EFUSE),
732 	GEN_EVT_CODE(_Read_CAM),			/*5*/
733 	GEN_EVT_CODE(_Get_BasicRate),
734 	GEN_EVT_CODE(_Get_DataRate),
735 	GEN_EVT_CODE(_Survey),	 /*8*/
736 	GEN_EVT_CODE(_SurveyDone),	 /*9*/
737 
738 	GEN_EVT_CODE(_JoinBss), /*10*/
739 	GEN_EVT_CODE(_AddSTA),
740 	GEN_EVT_CODE(_DelSTA),
741 	GEN_EVT_CODE(_AtimDone),
742 	GEN_EVT_CODE(_TX_Report),
743 	GEN_EVT_CODE(_CCX_Report),			/*15*/
744 	GEN_EVT_CODE(_DTM_Report),
745 	GEN_EVT_CODE(_TX_Rate_Statistics),
746 	GEN_EVT_CODE(_C2HLBK),
747 	GEN_EVT_CODE(_FWDBG),
748 	GEN_EVT_CODE(_C2HFEEDBACK),               /*20*/
749 	GEN_EVT_CODE(_ADDBA),
750 	GEN_EVT_CODE(_C2HBCN),
751 	GEN_EVT_CODE(_ReportPwrState),		/* filen: only for PCIE, USB */
752 	GEN_EVT_CODE(_CloseRF),				/* filen: only for PCIE, work around ASPM */
753 	GEN_EVT_CODE(_WMM),					/*25*/
754 	MAX_C2HEVT
755 };
756 
757 
758 #ifdef _RTW_MLME_EXT_C_
759 
760 #endif/* _RTL8192C_CMD_C_ */
761 
762 #endif
763