• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  ******************************************************************************/
15 #ifndef __RTW_MLME_EXT_H_
16 #define __RTW_MLME_EXT_H_
17 
18 #include <osdep_service.h>
19 #include <drv_types.h>
20 #include <wlan_bssdef.h>
21 
22 
23 /*	Commented by Albert 20101105 */
24 /*	Increase the SURVEY_TO value from 100 to 150  ( 100ms to 150ms ) */
25 /*	The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
26 /*	So, this driver tried to extend the dwell time for each scanning channel. */
27 /*	This will increase the chance to receive the probe response from SoftAP. */
28 
29 #define SURVEY_TO		(100)
30 #define REAUTH_TO		(300) /* 50) */
31 #define REASSOC_TO		(300) /* 50) */
32 /* define DISCONNECT_TO	(3000) */
33 #define ADDBA_TO			(2000)
34 
35 #define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */
36 
37 #define REAUTH_LIMIT	(4)
38 #define REASSOC_LIMIT	(4)
39 #define READDBA_LIMIT	(2)
40 
41 #define ROAMING_LIMIT	8
42 
43 #define	DYNAMIC_FUNC_DISABLE			(0x0)
44 
45 /*  ====== enum odm_ability ======== */
46 /*  BB ODM section BIT 0-15 */
47 #define	DYNAMIC_BB_DIG				BIT(0)
48 #define	DYNAMIC_BB_RA_MASK			BIT(1)
49 #define	DYNAMIC_BB_DYNAMIC_TXPWR	BIT(2)
50 #define	DYNAMIC_BB_BB_FA_CNT			BIT(3)
51 
52 #define		DYNAMIC_BB_RSSI_MONITOR		BIT(4)
53 #define		DYNAMIC_BB_CCK_PD			BIT(5)
54 #define		DYNAMIC_BB_ANT_DIV			BIT(6)
55 #define		DYNAMIC_BB_PWR_SAVE			BIT(7)
56 #define		DYNAMIC_BB_PWR_TRAIN			BIT(8)
57 #define		DYNAMIC_BB_RATE_ADAPTIVE		BIT(9)
58 #define		DYNAMIC_BB_PATH_DIV			BIT(10)
59 #define		DYNAMIC_BB_PSD				BIT(11)
60 
61 /*  MAC DM section BIT 16-23 */
62 #define		DYNAMIC_MAC_struct edca_turboURBO		BIT(16)
63 #define		DYNAMIC_MAC_EARLY_MODE		BIT(17)
64 
65 /*  RF ODM section BIT 24-31 */
66 #define		DYNAMIC_RF_TX_PWR_TRACK		BIT(24)
67 #define		DYNAMIC_RF_RX_GAIN_TRACK		BIT(25)
68 #define		DYNAMIC_RF_CALIBRATION		BIT(26)
69 
70 #define		DYNAMIC_ALL_FUNC_ENABLE		0xFFFFFFF
71 
72 #define _HW_STATE_NOLINK_		0x00
73 #define _HW_STATE_ADHOC_		0x01
74 #define _HW_STATE_STATION_	0x02
75 #define _HW_STATE_AP_			0x03
76 
77 
78 #define		_1M_RATE_	0
79 #define		_2M_RATE_	1
80 #define		_5M_RATE_	2
81 #define		_11M_RATE_	3
82 #define		_6M_RATE_	4
83 #define		_9M_RATE_	5
84 #define		_12M_RATE_	6
85 #define		_18M_RATE_	7
86 #define		_24M_RATE_	8
87 #define		_36M_RATE_	9
88 #define		_48M_RATE_	10
89 #define		_54M_RATE_	11
90 
91 
92 extern unsigned char WMM_OUI23A[];
93 extern unsigned char WPS_OUI23A[];
94 extern unsigned char WFD_OUI23A[];
95 extern unsigned char P2P_OUI23A[];
96 
97 extern unsigned char WMM_INFO_OUI23A[];
98 extern unsigned char WMM_PARA_OUI23A[];
99 
100 
101 /*  */
102 /*  Channel Plan Type. */
103 /*  Note: */
104 /*	We just add new channel plan when the new channel plan is different from any of the following */
105 /*	channel plan. */
106 /*	If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */
107 /*	customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
108 /*  */
109 enum  { /* _RT_CHANNEL_DOMAIN */
110 	/*  old channel plan mapping ===== */
111 	RT_CHANNEL_DOMAIN_FCC = 0x00,
112 	RT_CHANNEL_DOMAIN_IC = 0x01,
113 	RT_CHANNEL_DOMAIN_ETSI = 0x02,
114 	RT_CHANNEL_DOMAIN_SPAIN = 0x03,
115 	RT_CHANNEL_DOMAIN_FRANCE = 0x04,
116 	RT_CHANNEL_DOMAIN_MKK = 0x05,
117 	RT_CHANNEL_DOMAIN_MKK1 = 0x06,
118 	RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
119 	RT_CHANNEL_DOMAIN_TELEC = 0x08,
120 	RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
121 	RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
122 	RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
123 	RT_CHANNEL_DOMAIN_CHINA = 0x0C,
124 	RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
125 	RT_CHANNEL_DOMAIN_KOREA = 0x0E,
126 	RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
127 	RT_CHANNEL_DOMAIN_JAPAN = 0x10,
128 	RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
129 	RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
130 	RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13,
131 	RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
132 
133 	/*  new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
134 	RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
135 	RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
136 	RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
137 	RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
138 	RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
139 	RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
140 	RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
141 	RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
142 	RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
143 	RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
144 	RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
145 	RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
146 	RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
147 	RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
148 	RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
149 	RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
150 	RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
151 	RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
152 	RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
153 	RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
154 	RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
155 	RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41,
156 	/*  Add new channel plan above this line=============== */
157 	RT_CHANNEL_DOMAIN_MAX,
158 	RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
159 };
160 
161 enum { /* _RT_CHANNEL_DOMAIN_2G */
162 	RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,		/* Worldwird 13 */
163 	RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,		/* Europe */
164 	RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,		/* US */
165 	RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03,		/* Japan */
166 	RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04,		/* France */
167 	RT_CHANNEL_DOMAIN_2G_NULL = 0x05,
168 	/*  Add new channel plan above this line=============== */
169 	RT_CHANNEL_DOMAIN_2G_MAX,
170 };
171 
172 enum { /* _RT_CHANNEL_DOMAIN_5G */
173 	RT_CHANNEL_DOMAIN_5G_NULL = 0x00,
174 	RT_CHANNEL_DOMAIN_5G_ETSI1 = 0x01,		/* Europe */
175 	RT_CHANNEL_DOMAIN_5G_ETSI2 = 0x02,		/* Australia, New Zealand */
176 	RT_CHANNEL_DOMAIN_5G_ETSI3 = 0x03,		/* Russia */
177 	RT_CHANNEL_DOMAIN_5G_FCC1 = 0x04,		/* US */
178 	RT_CHANNEL_DOMAIN_5G_FCC2 = 0x05,		/* FCC o/w DFS Channels */
179 	RT_CHANNEL_DOMAIN_5G_FCC3 = 0x06,		/* India, Mexico */
180 	RT_CHANNEL_DOMAIN_5G_FCC4 = 0x07,		/* Venezuela */
181 	RT_CHANNEL_DOMAIN_5G_FCC5 = 0x08,		/* China */
182 	RT_CHANNEL_DOMAIN_5G_FCC6 = 0x09,		/* Israel */
183 	RT_CHANNEL_DOMAIN_5G_FCC7_IC1 = 0x0A,	/* US, Canada */
184 	RT_CHANNEL_DOMAIN_5G_KCC1 = 0x0B,		/* Korea */
185 	RT_CHANNEL_DOMAIN_5G_MKK1 = 0x0C,		/* Japan */
186 	RT_CHANNEL_DOMAIN_5G_MKK2 = 0x0D,		/* Japan (W52, W53) */
187 	RT_CHANNEL_DOMAIN_5G_MKK3 = 0x0E,		/* Japan (W56) */
188 	RT_CHANNEL_DOMAIN_5G_NCC1 = 0x0F,		/* Taiwan */
189 	RT_CHANNEL_DOMAIN_5G_NCC2 = 0x10,		/* Taiwan o/w DFS */
190 	/*  Add new channel plan above this line=============== */
191 	/*  Driver Self Defined ===== */
192 	RT_CHANNEL_DOMAIN_5G_FCC = 0x11,
193 	RT_CHANNEL_DOMAIN_5G_JAPAN_NO_DFS = 0x12,
194 	RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS = 0x13,
195 	RT_CHANNEL_DOMAIN_5G_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_5g {
211 	unsigned char	Channel[MAX_CHANNEL_NUM_5G];
212 	unsigned char	Len;
213 };
214 
215 struct rt_channel_plan_map {
216 	unsigned char	Index2G;
217 	unsigned char	Index5G;
218 };
219 
220 enum Associated_AP {
221 	atherosAP	= 0,
222 	broadcomAP	= 1,
223 	ciscoAP		= 2,
224 	marvellAP	= 3,
225 	ralinkAP	= 4,
226 	realtekAP	= 5,
227 	airgocapAP	= 6,
228 	unknownAP	= 7,
229 	maxAP,
230 };
231 
232 enum { /* HT_IOT_PEER_E */
233 	HT_IOT_PEER_UNKNOWN		= 0,
234 	HT_IOT_PEER_REALTEK		= 1,
235 	HT_IOT_PEER_REALTEK_92SE	= 2,
236 	HT_IOT_PEER_BROADCOM		= 3,
237 	HT_IOT_PEER_RALINK		= 4,
238 	HT_IOT_PEER_ATHEROS		= 5,
239 	HT_IOT_PEER_CISCO		= 6,
240 	HT_IOT_PEER_MERU		= 7,
241 	HT_IOT_PEER_MARVELL		= 8,
242 	HT_IOT_PEER_REALTEK_SOFTAP	= 9,/*  peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
243 	HT_IOT_PEER_SELF_SOFTAP		= 10, /*  Self is SoftAP */
244 	HT_IOT_PEER_AIRGO		= 11,
245 	HT_IOT_PEER_INTEL		= 12,
246 	HT_IOT_PEER_RTK_APCLIENT	= 13,
247 	HT_IOT_PEER_REALTEK_81XX	= 14,
248 	HT_IOT_PEER_REALTEK_WOW		= 15,
249 	HT_IOT_PEER_TENDA		= 16,
250 	HT_IOT_PEER_MAX			= 17
251 };
252 
253 enum SCAN_STATE {
254 	SCAN_DISABLE = 0,
255 	SCAN_START = 1,
256 	SCAN_TXNULL = 2,
257 	SCAN_PROCESS = 3,
258 	SCAN_COMPLETE = 4,
259 	SCAN_STATE_MAX,
260 };
261 
262 struct mlme_handler {
263 	char *str;
264 	int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
265 };
266 
267 struct action_handler {
268 	unsigned int   num;
269 	char *str;
270 	int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame);
271 };
272 
273 struct	ss_res
274 {
275 	int	state;
276 	int	bss_cnt;
277 	int	channel_idx;
278 	int	scan_mode;
279 	u8 ssid_num;
280 	u8 ch_num;
281 	struct cfg80211_ssid ssid[RTW_SSID_SCAN_AMOUNT];
282 	struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
283 };
284 
285 #define	WIFI_FW_AUTH_NULL			0x00000100
286 #define	WIFI_FW_AUTH_STATE			0x00000200
287 #define	WIFI_FW_AUTH_SUCCESS			0x00000400
288 
289 #define	WIFI_FW_ASSOC_STATE			0x00002000
290 #define	WIFI_FW_ASSOC_SUCCESS		0x00004000
291 
292 #define	WIFI_FW_LINKING_STATE		(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | WIFI_FW_AUTH_SUCCESS |WIFI_FW_ASSOC_STATE)
293 
294 struct FW_Sta_Info {
295 	struct sta_info	*psta;
296 	u32	status;
297 	u32	rx_pkt;
298 	u32	retry;
299 	unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
300 };
301 
302 /*
303  * Usage:
304  * When one iface acted as AP mode and the other iface is STA mode and scanning,
305  * it should switch back to AP's operating channel periodically.
306  * Parameters info:
307  * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
308  * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
309  * Example:
310  * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
311  * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MILLISECOND is 3 and SURVEY_TO is 100.
312  * When it's STA mode gets set_scan command,
313  * it would
314  * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
315  * 2. Back to channel 1 for 300 milliseconds
316  * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
317  * 4. Back to channel 1 for 300 milliseconds
318  * 5. ... and so on, till survey done.
319  */
320 
321 struct mlme_ext_info
322 {
323 	u32	state;
324 	u32	reauth_count;
325 	u32	reassoc_count;
326 	u32	link_count;
327 	u32	auth_seq;
328 	u32	auth_algo;	/*  802.11 auth, could be open, shared, auto */
329 	u32	authModeToggle;
330 	u32	enc_algo;/* encrypt algorithm; */
331 	u32	key_index;	/*  this is only valid for legendary wep, 0~3 for key id. */
332 	u32	iv;
333 	u8	chg_txt[128];
334 	u16	aid;
335 	u16	bcn_interval;
336 	u16	capability;
337 	u8	assoc_AP_vendor;
338 	u8	slotTime;
339 	u8	preamble_mode;
340 	u8	WMM_enable;
341 	u8	ERP_enable;
342 	u8	ERP_IE;
343 	u8	HT_enable;
344 	u8	HT_caps_enable;
345 	u8	HT_info_enable;
346 	u8	HT_protection;
347 	u8	turboMode_cts2self;
348 	u8	turboMode_rtsen;
349 	u8	SM_PS;
350 	u8	ADDBA_retry_count;
351 	u8	dialogToken;
352 	/*  Accept ADDBA Request */
353 	bool bAcceptAddbaReq;
354 	u8	bwmode_updated;
355 	u8	hidden_ssid_mode;
356 
357 	struct ADDBA_request		ADDBA_req;
358 	struct WMM_para_element	WMM_param;
359 	struct ieee80211_ht_cap ht_cap;
360 	struct ieee80211_ht_operation HT_info;
361 	struct wlan_bssid_ex			network;/* join network or bss_network, if in ap mode, it is the same to cur_network.network */
362 	struct FW_Sta_Info		FW_sta_info[NUM_STA];
363 };
364 
365 /*  The channel information about this channel including joining, scanning, and power constraints. */
366 struct rt_channel_info {
367 	u8		ChannelNum;		/*  The channel number. */
368 	enum rt_scan_type ScanType;		/*  Scan type such as passive or active scan. */
369 };
370 
371 int rtw_ch_set_search_ch23a(struct rt_channel_info *ch_set, const u32 ch);
372 
373 /*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
374 #define P2P_MAX_REG_CLASSES 10
375 
376 /*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class */
377 #define P2P_MAX_REG_CLASS_CHANNELS 20
378 
379 /*   struct p2p_channels - List of supported channels */
380 struct p2p_channels {
381 	/*  struct p2p_reg_class - Supported regulatory class */
382 	struct p2p_reg_class {
383 		/*  reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
384 		u8 reg_class;
385 
386 		/*  channel - Supported channels */
387 		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
388 
389 		/*  channels - Number of channel entries in use */
390 		size_t channels;
391 	} reg_class[P2P_MAX_REG_CLASSES];
392 
393 	/*  reg_classes - Number of reg_class entries in use */
394 	size_t reg_classes;
395 };
396 
397 struct p2p_oper_class_map {
398 	enum hw_mode {IEEE80211G, IEEE80211A} mode;
399 	u8 op_class;
400 	u8 min_chan;
401 	u8 max_chan;
402 	u8 inc;
403 	enum {
404 		BW20, BW40PLUS, BW40MINUS
405 	} bw;
406 };
407 
408 struct mlme_ext_priv {
409 	struct rtw_adapter	*padapter;
410 	u8	mlmeext_init;
411 	atomic_t		event_seq;
412 	u16	mgnt_seq;
413 
414 	/* struct fw_priv	fwpriv; */
415 
416 	unsigned char	cur_channel;
417 	unsigned char	cur_bwmode;
418 	unsigned char	cur_ch_offset;/* PRIME_CHNL_OFFSET */
419 	unsigned char	cur_wireless_mode;	/*  NETWORK_TYPE */
420 
421 	unsigned char	max_chan_nums;
422 	struct rt_channel_info		channel_set[MAX_CHANNEL_NUM];
423 	struct p2p_channels channel_list;
424 	unsigned char	basicrate[NumRates];
425 	unsigned char	datarate[NumRates];
426 
427 	struct ss_res		sitesurvey_res;
428 	struct mlme_ext_info	mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
429                                                      /* for ap mode, network includes ap's cap_info */
430 	struct timer_list		survey_timer;
431 	struct timer_list		link_timer;
432 	u16			chan_scan_time;
433 
434 	u8	scan_abort;
435 	u8	tx_rate; /*  TXRATE when USERATE is set. */
436 
437 	u32	retry; /* retry for issue probereq */
438 
439 	u64 TSFValue;
440 
441 	unsigned char bstart_bss;
442 	u8 update_channel_plan_by_ap_done;
443 	/* recv_decache check for Action_public frame */
444 	u8 action_public_dialog_token;
445 	u16	 action_public_rxseq;
446 	u8 active_keep_alive_check;
447 };
448 
449 int init_mlme_ext_priv23a(struct rtw_adapter *padapter);
450 int init_hw_mlme_ext23a(struct rtw_adapter *padapter);
451 void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext);
452 void init_mlme_ext_timer23a(struct rtw_adapter *padapter);
453 void init_addba_retry_timer23a(struct sta_info *psta);
454 struct xmit_frame *alloc_mgtxmitframe23a(struct xmit_priv *pxmitpriv);
455 
456 unsigned char networktype_to_raid23a(unsigned char network_type);
457 u8 judge_network_type23a(struct rtw_adapter *padapter, unsigned char *rate,
458 		      int ratelen);
459 void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate,
460 		  int *bssrate_len);
461 void UpdateBrateTbl23a(struct rtw_adapter *padapter, u8 *mBratesOS);
462 void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen);
463 
464 u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter);
465 void rtw_set_oper_ch23a(struct rtw_adapter *adapter, u8 ch);
466 u8 rtw_get_oper_bw23a(struct rtw_adapter *adapter);
467 void rtw_set_oper_bw23a(struct rtw_adapter *adapter, u8 bw);
468 u8 rtw_get_oper_ch23aoffset(struct rtw_adapter *adapter);
469 void rtw_set_oper_ch23aoffset23a(struct rtw_adapter *adapter, u8 offset);
470 
471 void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel,
472 			unsigned char channel_offset, unsigned short bwmode);
473 void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel);
474 
475 unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval);
476 
477 void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry);
478 
479 void invalidate_cam_all23a(struct rtw_adapter *padapter);
480 
481 int allocate_fw_sta_entry23a(struct rtw_adapter *padapter);
482 void flush_all_cam_entry23a(struct rtw_adapter *padapter);
483 
484 bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel);
485 
486 void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
487 		    struct rtw_adapter *padapter, bool update_ie);
488 
489 u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork);
490 
491 bool is_client_associated_to_ap23a(struct rtw_adapter *padapter);
492 bool is_client_associated_to_ibss23a(struct rtw_adapter *padapter);
493 bool is_IBSS_empty23a(struct rtw_adapter *padapter);
494 
495 unsigned char check_assoc_AP23a(u8 *pframe, uint len);
496 
497 int WMM_param_handler23a(struct rtw_adapter *padapter, const u8 *p);
498 void WMMOnAssocRsp23a(struct rtw_adapter *padapter);
499 
500 void HT_caps_handler23a(struct rtw_adapter *padapter, const u8 *p);
501 void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p);
502 void HTOnAssocRsp23a(struct rtw_adapter *padapter);
503 
504 void ERP_IE_handler23a(struct rtw_adapter *padapter, const u8 *p);
505 void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta);
506 
507 void update_beacon23a_info(struct rtw_adapter *padapter,
508 			   struct ieee80211_mgmt *mgmt, uint len,
509 			   struct sta_info *psta);
510 int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
511 			  struct ieee80211_mgmt *mgmt, u32 packet_len);
512 void update_IOT_info23a(struct rtw_adapter *padapter);
513 void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap);
514 void update_wireless_mode23a(struct rtw_adapter * padapter);
515 void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 modulation);
516 void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id);
517 int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie,
518 			    uint var_ie_len, int cam_idx);
519 
520 /* for sta/adhoc mode */
521 void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta);
522 unsigned int update_basic_rate23a(unsigned char *ptn, unsigned int ptn_sz);
523 unsigned int update_supported_rate23a(unsigned char *ptn, unsigned int ptn_sz);
524 unsigned int update_MSC_rate23a(struct ieee80211_ht_cap *ht_cap);
525 void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta);
526 void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta);
527 
528 int receive_disconnect23a(struct rtw_adapter *padapter,
529 			  unsigned char *MacAddr, unsigned short reason);
530 
531 unsigned char get_highest_rate_idx23a(u32 mask);
532 int support_short_GI23a(struct rtw_adapter *padapter,
533 			struct ieee80211_ht_cap *ht_cap);
534 bool is_ap_in_tkip23a(struct rtw_adapter *padapter);
535 bool is_ap_in_wep23a(struct rtw_adapter *padapter);
536 bool should_forbid_n_rate23a(struct rtw_adapter *padapter);
537 
538 void report_join_res23a(struct rtw_adapter *padapter, int res);
539 void report_survey_event23a(struct rtw_adapter *padapter,
540 			 struct recv_frame *precv_frame);
541 void report_surveydone_event23a(struct rtw_adapter *padapter);
542 void report_del_sta_event23a(struct rtw_adapter *padapter,
543 			  unsigned char *MacAddr, unsigned short reason);
544 void report_add_sta_event23a(struct rtw_adapter *padapter,
545 			  unsigned char *MacAddr, int cam_idx);
546 
547 int set_tx_beacon_cmd23a(struct rtw_adapter*padapter);
548 unsigned int setup_beacon_frame(struct rtw_adapter *padapter,
549 				unsigned char *beacon_frame);
550 void update_mgnt_tx_rate23a(struct rtw_adapter *padapter, u8 rate);
551 void update_mgntframe_attrib23a(struct rtw_adapter *padapter,
552 			     struct pkt_attrib *pattrib);
553 void dump_mgntframe23a(struct rtw_adapter *padapter,
554 		    struct xmit_frame *pmgntframe);
555 s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
556 			    struct xmit_frame *pmgntframe, int timeout_ms);
557 s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter,
558 				struct xmit_frame *pmgntframe);
559 
560 void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms);
561 int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
562 		   unsigned int power_mode, int try_cnt, int wait_ms);
563 int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, u16 tid,
564 		       int try_cnt, int wait_ms);
565 int issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da,
566 		 unsigned short reason);
567 void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra,
568 				 u8 new_ch, u8 ch_offset);
569 void issue_action_BA23a(struct rtw_adapter *padapter,
570 			const unsigned char *raddr,
571 			unsigned char action, unsigned short status);
572 int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr);
573 int send_beacon23a(struct rtw_adapter *padapter);
574 
575 void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res);
576 void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter);
577 void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_info *psta);
578 
579 void linked_status_chk23a(struct rtw_adapter *padapter);
580 
581 #define set_survey_timer(mlmeext, ms) \
582 	/*DBG_8723A("%s set_survey_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
583 	mod_timer(&mlmeext->survey_timer, jiffies + msecs_to_jiffies(ms));
584 
585 #define set_link_timer(mlmeext, ms) \
586 	/*DBG_8723A("%s set_link_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
587 	mod_timer(&mlmeext->link_timer, jiffies + msecs_to_jiffies(ms));
588 
589 int cckrates_included23a(unsigned char *rate, int ratelen);
590 int cckratesonly_included23a(unsigned char *rate, int ratelen);
591 
592 void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr);
593 
594 void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext);
595 
596 struct cmd_hdl {
597 	uint	parmsize;
598 	int (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf);
599 };
600 
601 
602 int read_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
603 int write_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
604 int read_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
605 int write_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
606 int read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
607 int write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
608 
609 
610 int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
611 int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
612 int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
613 int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
614 int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
615 int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
616 int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
617 int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
618 int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
619 int set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
620 int del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
621 int add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
622 
623 int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
624 int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
625 int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
626 int set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
627 int set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
628 int led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
629 int set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);	/* Kurt: Handling DFS channel switch announcement ie. */
630 int tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
631 
632 #define GEN_DRV_CMD_HANDLER(size, cmd)	{size, &cmd ## _hdl23a},
633 #define GEN_MLME_EXT_HANDLER(size, cmd)	{size, cmd},
634 
635 struct C2HEvent_Header {
636 #ifdef __LITTLE_ENDIAN
637 
638 	unsigned int len:16;
639 	unsigned int ID:8;
640 	unsigned int seq:8;
641 
642 #elif defined(__BIG_ENDIAN)
643 
644 	unsigned int seq:8;
645 	unsigned int ID:8;
646 	unsigned int len:16;
647 
648 #else
649 
650 #  error "Must be LITTLE or BIG Endian"
651 
652 #endif
653 
654 	unsigned int rsvd;
655 };
656 
657 enum rtw_c2h_event {
658 	GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
659 	GEN_EVT_CODE(_Read_BBREG),
660 	GEN_EVT_CODE(_Read_RFREG),
661 	GEN_EVT_CODE(_Read_EEPROM),
662 	GEN_EVT_CODE(_Read_EFUSE),
663 	GEN_EVT_CODE(_Read_CAM),			/*5*/
664 	GEN_EVT_CODE(_Get_BasicRate),
665 	GEN_EVT_CODE(_Get_DataRate),
666 	GEN_EVT_CODE(_Survey),	 /*8*/
667 	GEN_EVT_CODE(_SurveyDone),	 /*9*/
668 
669 	GEN_EVT_CODE(_JoinBss) , /*10*/
670 	GEN_EVT_CODE(_AddSTA),
671 	GEN_EVT_CODE(_DelSTA),
672 	GEN_EVT_CODE(_AtimDone) ,
673 	GEN_EVT_CODE(_TX_Report),
674 	GEN_EVT_CODE(_CCX_Report),			/*15*/
675 	GEN_EVT_CODE(_DTM_Report),
676 	GEN_EVT_CODE(_TX_Rate_Statistics),
677 	GEN_EVT_CODE(_C2HLBK),
678 	GEN_EVT_CODE(_FWDBG),
679 	GEN_EVT_CODE(_C2HFEEDBACK),               /*20*/
680 	GEN_EVT_CODE(_ADDBA),
681 	GEN_EVT_CODE(_C2HBCN),
682 	GEN_EVT_CODE(_ReportPwrState),		/* filen: only for PCIE, USB */
683 	GEN_EVT_CODE(_CloseRF),				/* filen: only for PCIE, work around ASPM */
684 	MAX_C2HEVT
685 };
686 
687 #endif
688