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 want to customize the actions(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 	int	state;
275 	int	bss_cnt;
276 	int	channel_idx;
277 	int	scan_mode;
278 	u8 ssid_num;
279 	u8 ch_num;
280 	struct cfg80211_ssid ssid[RTW_SSID_SCAN_AMOUNT];
281 	struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
282 };
283 
284 #define	WIFI_FW_AUTH_NULL			0x00000100
285 #define	WIFI_FW_AUTH_STATE			0x00000200
286 #define	WIFI_FW_AUTH_SUCCESS			0x00000400
287 
288 #define	WIFI_FW_ASSOC_STATE			0x00002000
289 #define	WIFI_FW_ASSOC_SUCCESS		0x00004000
290 
291 #define	WIFI_FW_LINKING_STATE		(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | WIFI_FW_AUTH_SUCCESS |WIFI_FW_ASSOC_STATE)
292 
293 struct FW_Sta_Info {
294 	struct sta_info	*psta;
295 	u32	status;
296 	u32	rx_pkt;
297 	u32	retry;
298 	unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
299 };
300 
301 /*
302  * Usage:
303  * When one iface acted as AP mode and the other iface is STA mode and scanning,
304  * it should switch back to AP's operating channel periodically.
305  * Parameters info:
306  * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
307  * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
308  * Example:
309  * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
310  * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MILLISECOND is 3 and SURVEY_TO is 100.
311  * When it's STA mode gets set_scan command,
312  * it would
313  * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
314  * 2. Back to channel 1 for 300 milliseconds
315  * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
316  * 4. Back to channel 1 for 300 milliseconds
317  * 5. ... and so on, till survey done.
318  */
319 
320 struct mlme_ext_info {
321 	u32	state;
322 	u32	reauth_count;
323 	u32	reassoc_count;
324 	u32	link_count;
325 	u32	auth_seq;
326 	u32	auth_algo;	/*  802.11 auth, could be open, shared, auto */
327 	u32	authModeToggle;
328 	u32	enc_algo;/* encrypt algorithm; */
329 	u32	key_index;	/*  this is only valid for legendary wep, 0~3 for key id. */
330 	u32	iv;
331 	u8	chg_txt[128];
332 	u16	aid;
333 	u16	bcn_interval;
334 	u16	capability;
335 	u8	assoc_AP_vendor;
336 	u8	slotTime;
337 	u8	preamble_mode;
338 	u8	WMM_enable;
339 	u8	ERP_enable;
340 	u8	ERP_IE;
341 	u8	HT_enable;
342 	u8	HT_caps_enable;
343 	u8	HT_info_enable;
344 	u8	HT_protection;
345 	u8	turboMode_cts2self;
346 	u8	turboMode_rtsen;
347 	u8	SM_PS;
348 	u8	ADDBA_retry_count;
349 	u8	dialogToken;
350 	/*  Accept ADDBA Request */
351 	bool bAcceptAddbaReq;
352 	u8	bwmode_updated;
353 	u8	hidden_ssid_mode;
354 
355 	struct ADDBA_request		ADDBA_req;
356 	struct WMM_para_element	WMM_param;
357 	struct ieee80211_ht_cap ht_cap;
358 	struct ieee80211_ht_operation HT_info;
359 	struct wlan_bssid_ex			network;/* join network or bss_network, if in ap mode, it is the same to cur_network.network */
360 	struct FW_Sta_Info		FW_sta_info[NUM_STA];
361 };
362 
363 /*  The channel information about this channel including joining, scanning, and power constraints. */
364 struct rt_channel_info {
365 	u8		ChannelNum;		/*  The channel number. */
366 	enum rt_scan_type ScanType;		/*  Scan type such as passive or active scan. */
367 };
368 
369 int rtw_ch_set_search_ch23a(struct rt_channel_info *ch_set, const u32 ch);
370 
371 /*  P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
372 #define P2P_MAX_REG_CLASSES 10
373 
374 /*  P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class */
375 #define P2P_MAX_REG_CLASS_CHANNELS 20
376 
377 /*   struct p2p_channels - List of supported channels */
378 struct p2p_channels {
379 	/*  struct p2p_reg_class - Supported regulatory class */
380 	struct p2p_reg_class {
381 		/*  reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
382 		u8 reg_class;
383 
384 		/*  channel - Supported channels */
385 		u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
386 
387 		/*  channels - Number of channel entries in use */
388 		size_t channels;
389 	} reg_class[P2P_MAX_REG_CLASSES];
390 
391 	/*  reg_classes - Number of reg_class entries in use */
392 	size_t reg_classes;
393 };
394 
395 struct p2p_oper_class_map {
396 	enum hw_mode {IEEE80211G, IEEE80211A} mode;
397 	u8 op_class;
398 	u8 min_chan;
399 	u8 max_chan;
400 	u8 inc;
401 	enum {
402 		BW20, BW40PLUS, BW40MINUS
403 	} bw;
404 };
405 
406 struct mlme_ext_priv {
407 	struct rtw_adapter	*padapter;
408 	u8	mlmeext_init;
409 	atomic_t		event_seq;
410 	u16	mgnt_seq;
411 
412 	/* struct fw_priv	fwpriv; */
413 
414 	unsigned char	cur_channel;
415 	unsigned char	cur_bwmode;
416 	unsigned char	cur_ch_offset;/* PRIME_CHNL_OFFSET */
417 	unsigned char	cur_wireless_mode;	/*  NETWORK_TYPE */
418 
419 	unsigned char	max_chan_nums;
420 	struct rt_channel_info		channel_set[MAX_CHANNEL_NUM];
421 	struct p2p_channels channel_list;
422 	unsigned char	basicrate[NumRates];
423 	unsigned char	datarate[NumRates];
424 
425 	struct ss_res		sitesurvey_res;
426 	struct mlme_ext_info	mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
427                                                      /* for ap mode, network includes ap's cap_info */
428 	struct timer_list		survey_timer;
429 	struct timer_list		link_timer;
430 	u16			chan_scan_time;
431 
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 	unsigned char bstart_bss;
440 	u8 update_channel_plan_by_ap_done;
441 	/* recv_decache check for Action_public frame */
442 	u8 action_public_dialog_token;
443 	u16	 action_public_rxseq;
444 	u8 active_keep_alive_check;
445 };
446 
447 int init_mlme_ext_priv23a(struct rtw_adapter *padapter);
448 int init_hw_mlme_ext23a(struct rtw_adapter *padapter);
449 void free_mlme_ext_priv23a (struct mlme_ext_priv *pmlmeext);
450 void init_mlme_ext_timer23a(struct rtw_adapter *padapter);
451 void init_addba_retry_timer23a(struct sta_info *psta);
452 struct xmit_frame *alloc_mgtxmitframe23a(struct xmit_priv *pxmitpriv);
453 
454 unsigned char networktype_to_raid23a(unsigned char network_type);
455 u8 judge_network_type23a(struct rtw_adapter *padapter, unsigned char *rate,
456 		      int ratelen);
457 void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate,
458 		  int *bssrate_len);
459 void UpdateBrateTbl23a(struct rtw_adapter *padapter, u8 *mBratesOS);
460 void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen);
461 
462 u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter);
463 void rtw_set_oper_ch23a(struct rtw_adapter *adapter, u8 ch);
464 u8 rtw_get_oper_bw23a(struct rtw_adapter *adapter);
465 void rtw_set_oper_bw23a(struct rtw_adapter *adapter, u8 bw);
466 u8 rtw_get_oper_ch23aoffset(struct rtw_adapter *adapter);
467 void rtw_set_oper_ch23aoffset23a(struct rtw_adapter *adapter, u8 offset);
468 
469 void set_channel_bwmode23a(struct rtw_adapter *padapter, unsigned char channel,
470 			unsigned char channel_offset, unsigned short bwmode);
471 void SelectChannel23a(struct rtw_adapter *padapter, unsigned char channel);
472 
473 unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval);
474 
475 void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry);
476 
477 void invalidate_cam_all23a(struct rtw_adapter *padapter);
478 
479 int allocate_fw_sta_entry23a(struct rtw_adapter *padapter);
480 void flush_all_cam_entry23a(struct rtw_adapter *padapter);
481 
482 bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel);
483 
484 void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
485 		    struct rtw_adapter *padapter, bool update_ie);
486 
487 u8 *get_my_bssid23a(struct wlan_bssid_ex *pnetwork);
488 
489 bool is_client_associated_to_ap23a(struct rtw_adapter *padapter);
490 bool is_client_associated_to_ibss23a(struct rtw_adapter *padapter);
491 bool is_IBSS_empty23a(struct rtw_adapter *padapter);
492 
493 unsigned char check_assoc_AP23a(u8 *pframe, uint len);
494 
495 int WMM_param_handler23a(struct rtw_adapter *padapter, const u8 *p);
496 void WMMOnAssocRsp23a(struct rtw_adapter *padapter);
497 
498 void HT_caps_handler23a(struct rtw_adapter *padapter, const u8 *p);
499 void HT_info_handler23a(struct rtw_adapter *padapter, const u8 *p);
500 void HTOnAssocRsp23a(struct rtw_adapter *padapter);
501 
502 void ERP_IE_handler23a(struct rtw_adapter *padapter, const u8 *p);
503 void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta);
504 
505 void update_beacon23a_info(struct rtw_adapter *padapter,
506 			   struct ieee80211_mgmt *mgmt, uint len,
507 			   struct sta_info *psta);
508 int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
509 			  struct ieee80211_mgmt *mgmt, u32 packet_len);
510 void update_IOT_info23a(struct rtw_adapter *padapter);
511 void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap);
512 void update_wireless_mode23a(struct rtw_adapter *padapter);
513 void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 modulation);
514 void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id);
515 int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie,
516 			    uint var_ie_len, int cam_idx);
517 
518 /* for sta/adhoc mode */
519 void update_sta_info23a(struct rtw_adapter *padapter, struct sta_info *psta);
520 unsigned int update_basic_rate23a(unsigned char *ptn, unsigned int ptn_sz);
521 unsigned int update_supported_rate23a(unsigned char *ptn, unsigned int ptn_sz);
522 unsigned int update_MSC_rate23a(struct ieee80211_ht_cap *ht_cap);
523 void Update_RA_Entry23a(struct rtw_adapter *padapter, struct sta_info *psta);
524 void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta);
525 
526 int receive_disconnect23a(struct rtw_adapter *padapter,
527 			  unsigned char *MacAddr, unsigned short reason);
528 
529 unsigned char get_highest_rate_idx23a(u32 mask);
530 int support_short_GI23a(struct rtw_adapter *padapter,
531 			struct ieee80211_ht_cap *ht_cap);
532 bool is_ap_in_tkip23a(struct rtw_adapter *padapter);
533 bool is_ap_in_wep23a(struct rtw_adapter *padapter);
534 bool should_forbid_n_rate23a(struct rtw_adapter *padapter);
535 
536 void report_join_res23a(struct rtw_adapter *padapter, int res);
537 void report_survey_event23a(struct rtw_adapter *padapter,
538 			 struct recv_frame *precv_frame);
539 void report_surveydone_event23a(struct rtw_adapter *padapter);
540 void report_del_sta_event23a(struct rtw_adapter *padapter,
541 			  unsigned char *MacAddr, unsigned short reason);
542 void report_add_sta_event23a(struct rtw_adapter *padapter,
543 			  unsigned char *MacAddr, int cam_idx);
544 
545 int set_tx_beacon_cmd23a(struct rtw_adapter*padapter);
546 unsigned int setup_beacon_frame(struct rtw_adapter *padapter,
547 				unsigned char *beacon_frame);
548 void update_mgnt_tx_rate23a(struct rtw_adapter *padapter, u8 rate);
549 void update_mgntframe_attrib23a(struct rtw_adapter *padapter,
550 			     struct pkt_attrib *pattrib);
551 void dump_mgntframe23a(struct rtw_adapter *padapter,
552 		    struct xmit_frame *pmgntframe);
553 s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter,
554 			    struct xmit_frame *pmgntframe, int timeout_ms);
555 s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter,
556 				struct xmit_frame *pmgntframe);
557 
558 void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms);
559 int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
560 		   unsigned int power_mode, int try_cnt, int wait_ms);
561 int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da, u16 tid,
562 		       int try_cnt, int wait_ms);
563 int issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da,
564 		 unsigned short reason);
565 void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter, u8 *ra,
566 				 u8 new_ch, u8 ch_offset);
567 void issue_action_BA23a(struct rtw_adapter *padapter,
568 			const unsigned char *raddr,
569 			unsigned char action, unsigned short status);
570 int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr);
571 int send_beacon23a(struct rtw_adapter *padapter);
572 
573 void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res);
574 void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter);
575 void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_info *psta);
576 
577 void linked_status_chk23a(struct rtw_adapter *padapter);
578 
579 #define set_survey_timer(mlmeext, ms) \
580 	/*DBG_8723A("%s set_survey_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
581 	mod_timer(&mlmeext->survey_timer, jiffies + msecs_to_jiffies(ms));
582 
583 #define set_link_timer(mlmeext, ms) \
584 	/*DBG_8723A("%s set_link_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
585 	mod_timer(&mlmeext->link_timer, jiffies + msecs_to_jiffies(ms));
586 
587 int cckrates_included23a(unsigned char *rate, int ratelen);
588 int cckratesonly_included23a(unsigned char *rate, int ratelen);
589 
590 void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr);
591 
592 void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext);
593 
594 struct cmd_hdl {
595 	uint	parmsize;
596 	int (*h2cfuns)(struct rtw_adapter *padapter, const u8 *pbuf);
597 };
598 
599 
600 int read_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
601 int write_macreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
602 int read_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
603 int write_bbreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
604 int read_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
605 int write_rfreg_hdl(struct rtw_adapter *padapter, u8 *pbuf);
606 
607 
608 int NULL_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
609 int join_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
610 int disconnect_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
611 int createbss_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
612 int setopmode_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
613 int sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
614 int setauth_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
615 int setkey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
616 int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
617 int set_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
618 int del_assocsta_hdl(struct rtw_adapter *padapter, const u8 *pbuf);
619 int add_ba_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
620 
621 int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
622 int h2c_msg_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
623 int tx_beacon_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
624 int set_ch_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
625 int set_chplan_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
626 int led_blink_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
627 int set_csa_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);	/* Kurt: Handling DFS channel switch announcement ie. */
628 int tdls_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf);
629 
630 #define GEN_DRV_CMD_HANDLER(size, cmd)	{size, &cmd ## _hdl23a},
631 #define GEN_MLME_EXT_HANDLER(size, cmd)	{size, cmd},
632 
633 struct C2HEvent_Header {
634 #ifdef __LITTLE_ENDIAN
635 
636 	unsigned int len:16;
637 	unsigned int ID:8;
638 	unsigned int seq:8;
639 
640 #elif defined(__BIG_ENDIAN)
641 
642 	unsigned int seq:8;
643 	unsigned int ID:8;
644 	unsigned int len:16;
645 
646 #else
647 
648 #  error "Must be LITTLE or BIG Endian"
649 
650 #endif
651 
652 	unsigned int rsvd;
653 };
654 
655 enum rtw_c2h_event {
656 	GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
657 	GEN_EVT_CODE(_Read_BBREG),
658 	GEN_EVT_CODE(_Read_RFREG),
659 	GEN_EVT_CODE(_Read_EEPROM),
660 	GEN_EVT_CODE(_Read_EFUSE),
661 	GEN_EVT_CODE(_Read_CAM),			/*5*/
662 	GEN_EVT_CODE(_Get_BasicRate),
663 	GEN_EVT_CODE(_Get_DataRate),
664 	GEN_EVT_CODE(_Survey),	 /*8*/
665 	GEN_EVT_CODE(_SurveyDone),	 /*9*/
666 
667 	GEN_EVT_CODE(_JoinBss) , /*10*/
668 	GEN_EVT_CODE(_AddSTA),
669 	GEN_EVT_CODE(_DelSTA),
670 	GEN_EVT_CODE(_AtimDone) ,
671 	GEN_EVT_CODE(_TX_Report),
672 	GEN_EVT_CODE(_CCX_Report),			/*15*/
673 	GEN_EVT_CODE(_DTM_Report),
674 	GEN_EVT_CODE(_TX_Rate_Statistics),
675 	GEN_EVT_CODE(_C2HLBK),
676 	GEN_EVT_CODE(_FWDBG),
677 	GEN_EVT_CODE(_C2HFEEDBACK),               /*20*/
678 	GEN_EVT_CODE(_ADDBA),
679 	GEN_EVT_CODE(_C2HBCN),
680 	GEN_EVT_CODE(_ReportPwrState),		/* filen: only for PCIE, USB */
681 	GEN_EVT_CODE(_CloseRF),				/* filen: only for PCIE, work around ASPM */
682 	MAX_C2HEVT
683 };
684 
685 #endif
686