[go: nahoru, domu]

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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20#ifndef __RTW_MLME_EXT_H_
21#define __RTW_MLME_EXT_H_
22
23#include <osdep_service.h>
24#include <drv_types.h>
25#include <wlan_bssdef.h>
26
27
28/*	Commented by Albert 20101105 */
29/*	Increase the SURVEY_TO value from 100 to 150  ( 100ms to 150ms ) */
30/*	The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
31/*	So, this driver tried to extend the dwell time for each scanning channel. */
32/*	This will increase the chance to receive the probe response from SoftAP. */
33
34#define SURVEY_TO		(100)
35#define REAUTH_TO		(300) /* 50) */
36#define REASSOC_TO		(300) /* 50) */
37/* define DISCONNECT_TO	(3000) */
38#define ADDBA_TO			(2000)
39
40#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */
41
42#define REAUTH_LIMIT	(4)
43#define REASSOC_LIMIT	(4)
44#define READDBA_LIMIT	(2)
45
46#define ROAMING_LIMIT	8
47
48#define	DYNAMIC_FUNC_DISABLE			(0x0)
49
50/*  ====== ODM_ABILITY_E ======== */
51/*  BB ODM section BIT 0-15 */
52#define	DYNAMIC_BB_DIG				BIT(0)
53#define	DYNAMIC_BB_RA_MASK			BIT(1)
54#define	DYNAMIC_BB_DYNAMIC_TXPWR	BIT(2)
55#define	DYNAMIC_BB_BB_FA_CNT			BIT(3)
56
57#define		DYNAMIC_BB_RSSI_MONITOR		BIT(4)
58#define		DYNAMIC_BB_CCK_PD			BIT(5)
59#define		DYNAMIC_BB_ANT_DIV			BIT(6)
60#define		DYNAMIC_BB_PWR_SAVE			BIT(7)
61#define		DYNAMIC_BB_PWR_TRA			BIT(8)
62#define		DYNAMIC_BB_RATE_ADAPTIVE		BIT(9)
63#define		DYNAMIC_BB_PATH_DIV			BIT(10)
64#define		DYNAMIC_BB_PSD				BIT(11)
65
66/*  MAC DM section BIT 16-23 */
67#define		DYNAMIC_MAC_EDCA_TURBO		BIT(16)
68#define		DYNAMIC_MAC_EARLY_MODE		BIT(17)
69
70/*  RF ODM section BIT 24-31 */
71#define		DYNAMIC_RF_TX_PWR_TRACK		BIT(24)
72#define		DYNAMIC_RF_RX_GAIN_TRACK		BIT(25)
73#define		DYNAMIC_RF_CALIBRATION		BIT(26)
74
75#define		DYNAMIC_ALL_FUNC_ENABLE		0xFFFFFFF
76
77#define _HW_STATE_NOLINK_		0x00
78#define _HW_STATE_ADHOC_		0x01
79#define _HW_STATE_STATION_	0x02
80#define _HW_STATE_AP_			0x03
81
82
83#define		_1M_RATE_	0
84#define		_2M_RATE_	1
85#define		_5M_RATE_	2
86#define		_11M_RATE_	3
87#define		_6M_RATE_	4
88#define		_9M_RATE_	5
89#define		_12M_RATE_	6
90#define		_18M_RATE_	7
91#define		_24M_RATE_	8
92#define		_36M_RATE_	9
93#define		_48M_RATE_	10
94#define		_54M_RATE_	11
95
96
97extern unsigned char RTW_WPA_OUI[];
98extern unsigned char WMM_OUI[];
99extern unsigned char WPS_OUI[];
100extern unsigned char WFD_OUI[];
101extern unsigned char P2P_OUI[];
102
103extern unsigned char WMM_INFO_OUI[];
104extern unsigned char WMM_PARA_OUI[];
105
106/*  Channel Plan Type. */
107/*  Note: */
108/*	We just add new channel plan when the new channel plan is different
109 *      from any of the following channel plan. */
110/*	If you just want to customize the actions(scan period or join actions)
111 *      about one of the channel plan, */
112/*	customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
113enum RT_CHANNEL_DOMAIN {
114	/*  old channel plan mapping =====  */
115	RT_CHANNEL_DOMAIN_FCC = 0x00,
116	RT_CHANNEL_DOMAIN_IC = 0x01,
117	RT_CHANNEL_DOMAIN_ETSI = 0x02,
118	RT_CHANNEL_DOMAIN_SPAIN = 0x03,
119	RT_CHANNEL_DOMAIN_FRANCE = 0x04,
120	RT_CHANNEL_DOMAIN_MKK = 0x05,
121	RT_CHANNEL_DOMAIN_MKK1 = 0x06,
122	RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
123	RT_CHANNEL_DOMAIN_TELEC = 0x08,
124	RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
125	RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
126	RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
127	RT_CHANNEL_DOMAIN_CHINA = 0x0C,
128	RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
129	RT_CHANNEL_DOMAIN_KOREA = 0x0E,
130	RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
131	RT_CHANNEL_DOMAIN_JAPAN = 0x10,
132	RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
133	RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
134	RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13,
135	RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
136
137	/*  new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
138	RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
139	RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
140	RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
141	RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
142	RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
143	RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
144	RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
145	RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
146	RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
147	RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
148	RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
149	RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
150	RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
151	RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
152	RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
153	RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
154	RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
155	RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
156	RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
157	RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
158	RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
159	RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41,
160	/*  Add new channel plan above this line=============== */
161	RT_CHANNEL_DOMAIN_MAX,
162	RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
163};
164
165enum RT_CHANNEL_DOMAIN_2G {
166	RT_CHANNEL_DOMAIN_2G_WORLD = 0x00,		/* Worldwide 13 */
167	RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01,		/* Europe */
168	RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02,		/* US */
169	RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03,		/* Japan */
170	RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04,		/* France */
171	RT_CHANNEL_DOMAIN_2G_NULL = 0x05,
172	/*  Add new channel plan above this line=============== */
173	RT_CHANNEL_DOMAIN_2G_MAX,
174};
175
176#define rtw_is_channel_plan_valid(chplan)			\
177	(chplan < RT_CHANNEL_DOMAIN_MAX ||			\
178	 chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
179
180struct rt_channel_plan {
181	unsigned char	Channel[MAX_CHANNEL_NUM];
182	unsigned char	Len;
183};
184
185struct rt_channel_plan_2g {
186	unsigned char	Channel[MAX_CHANNEL_NUM_2G];
187	unsigned char	Len;
188};
189
190struct rt_channel_plan_map {
191	unsigned char	Index2G;
192};
193
194enum Associated_AP {
195	atherosAP	= 0,
196	broadcomAP	= 1,
197	ciscoAP		= 2,
198	marvellAP	= 3,
199	ralinkAP	= 4,
200	realtekAP	= 5,
201	airgocapAP	= 6,
202	unknownAP	= 7,
203	maxAP,
204};
205
206enum HT_IOT_PEER {
207	HT_IOT_PEER_UNKNOWN		= 0,
208	HT_IOT_PEER_REALTEK		= 1,
209	HT_IOT_PEER_REALTEK_92SE	= 2,
210	HT_IOT_PEER_BROADCOM		= 3,
211	HT_IOT_PEER_RALINK		= 4,
212	HT_IOT_PEER_ATHEROS		= 5,
213	HT_IOT_PEER_CISCO		= 6,
214	HT_IOT_PEER_MERU		= 7,
215	HT_IOT_PEER_MARVELL		= 8,
216	HT_IOT_PEER_REALTEK_SOFTAP	= 9,/*  peer is RealTek SOFT_AP */
217	HT_IOT_PEER_SELF_SOFTAP		= 10, /*  Self is SoftAP */
218	HT_IOT_PEER_AIRGO		= 11,
219	HT_IOT_PEER_INTEL		= 12,
220	HT_IOT_PEER_RTK_APCLIENT	= 13,
221	HT_IOT_PEER_REALTEK_81XX	= 14,
222	HT_IOT_PEER_REALTEK_WOW		= 15,
223	HT_IOT_PEER_TENDA		= 16,
224	HT_IOT_PEER_MAX			= 17
225};
226
227enum SCAN_STATE {
228	SCAN_DISABLE = 0,
229	SCAN_START = 1,
230	SCAN_TXNULL = 2,
231	SCAN_PROCESS = 3,
232	SCAN_COMPLETE = 4,
233	SCAN_STATE_MAX,
234};
235
236struct mlme_handler {
237	unsigned int   num;
238	char *str;
239	unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
240};
241
242struct action_handler {
243	unsigned int   num;
244	char *str;
245	unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
246};
247
248struct	ss_res {
249	int	state;
250	int	bss_cnt;
251	int	channel_idx;
252	int	scan_mode;
253	u8 ssid_num;
254	u8 ch_num;
255	struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
256	struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
257};
258
259/* define AP_MODE				0x0C */
260/* define STATION_MODE	0x08 */
261/* define AD_HOC_MODE		0x04 */
262/* define NO_LINK_MODE	0x00 */
263
264#define WIFI_FW_NULL_STATE		_HW_STATE_NOLINK_
265#define	WIFI_FW_STATION_STATE		_HW_STATE_STATION_
266#define	WIFI_FW_AP_STATE		_HW_STATE_AP_
267#define	WIFI_FW_ADHOC_STATE		_HW_STATE_ADHOC_
268
269#define	WIFI_FW_AUTH_NULL		0x00000100
270#define	WIFI_FW_AUTH_STATE		0x00000200
271#define	WIFI_FW_AUTH_SUCCESS		0x00000400
272
273#define	WIFI_FW_ASSOC_STATE		0x00002000
274#define	WIFI_FW_ASSOC_SUCCESS		0x00004000
275
276#define	WIFI_FW_LINKING_STATE		(WIFI_FW_AUTH_NULL |		\
277					WIFI_FW_AUTH_STATE |		\
278					WIFI_FW_AUTH_SUCCESS |		\
279					WIFI_FW_ASSOC_STATE)
280
281struct FW_Sta_Info {
282	struct sta_info	*psta;
283	u32	status;
284	u32	rx_pkt;
285	u32	retry;
286	unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
287};
288
289/*
290 * Usage:
291 * When one iface acted as AP mode and the other iface is STA mode and scanning,
292 * it should switch back to AP's operating channel periodically.
293 * Parameters info:
294 * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to
295 * AP's operating channel for
296 * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
297 * Example:
298 * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
299 * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100.
300 * When it's STA mode gets set_scan command,
301 * it would
302 * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
303 * 2. Back to channel 1 for 300 milliseconds
304 * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
305 * 4. Back to channel 1 for 300 milliseconds
306 * 5. ... and so on, till survey done.
307 */
308
309struct mlme_ext_info {
310	u32	state;
311	u32	reauth_count;
312	u32	reassoc_count;
313	u32	link_count;
314	u32	auth_seq;
315	u32	auth_algo;	/*  802.11 auth, could be open, shared, auto */
316	u32	authModeToggle;
317	u32	enc_algo;/* encrypt algorithm; */
318	u32	key_index;	/*  this is only valid for legacy wep,
319				 *  0~3 for key id. */
320	u32	iv;
321	u8	chg_txt[128];
322	u16	aid;
323	u16	bcn_interval;
324	u16	capability;
325	u8	assoc_AP_vendor;
326	u8	slotTime;
327	u8	preamble_mode;
328	u8	WMM_enable;
329	u8	ERP_enable;
330	u8	ERP_IE;
331	u8	HT_enable;
332	u8	HT_caps_enable;
333	u8	HT_info_enable;
334	u8	HT_protection;
335	u8	turboMode_cts2self;
336	u8	turboMode_rtsen;
337	u8	SM_PS;
338	u8	agg_enable_bitmap;
339	u8	ADDBA_retry_count;
340	u8	candidate_tid_bitmap;
341	u8	dialogToken;
342	/*  Accept ADDBA Request */
343	bool bAcceptAddbaReq;
344	u8	bwmode_updated;
345	u8	hidden_ssid_mode;
346
347	struct ADDBA_request	ADDBA_req;
348	struct WMM_para_element	WMM_param;
349	struct HT_caps_element	HT_caps;
350	struct HT_info_element	HT_info;
351	struct wlan_bssid_ex	network;/* join network or bss_network,
352					 * if in ap mode, it is the same
353					 * as cur_network.network */
354	struct FW_Sta_Info	FW_sta_info[NUM_STA];
355};
356
357/*  The channel information about this channel including joining,
358 *  scanning, and power constraints. */
359struct rt_channel_info {
360	u8	ChannelNum;	/*  The channel number. */
361	enum rt_scan_type ScanType;	/*  Scan type such as passive
362					 *  or active scan. */
363	u32	rx_count;
364};
365
366int 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 chan per regulatory class */
372#define P2P_MAX_REG_CLASS_CHANNELS 20
373
374/*   struct p2p_channels - List of supported channels */
375struct 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
392struct p2p_oper_class_map {
393	enum hw_mode {IEEE80211G} mode;
394	u8 op_class;
395	u8 min_chan;
396	u8 max_chan;
397	u8 inc;
398	enum {BW20, BW40PLUS, BW40MINUS} bw;
399};
400
401struct mlme_ext_priv {
402	struct adapter	*padapter;
403	u8	mlmeext_init;
404	atomic_t	event_seq;
405	u16	mgnt_seq;
406
407	unsigned char	cur_channel;
408	unsigned char	cur_bwmode;
409	unsigned char	cur_ch_offset;/* PRIME_CHNL_OFFSET */
410	unsigned char	cur_wireless_mode;	/*  NETWORK_TYPE */
411
412	unsigned char	oper_channel; /* saved chan info when call
413				       * set_channel_bw */
414	unsigned char	oper_bwmode;
415	unsigned char	oper_ch_offset;/* PRIME_CHNL_OFFSET */
416
417	unsigned char	max_chan_nums;
418	struct rt_channel_info channel_set[MAX_CHANNEL_NUM];
419	struct p2p_channels channel_list;
420	unsigned char	basicrate[NumRates];
421	unsigned char	datarate[NumRates];
422
423	struct ss_res		sitesurvey_res;
424	struct mlme_ext_info	mlmext_info;/* for sta/adhoc mode, including
425					     * current scan/connecting/connected
426					     * related info. For ap mode,
427					     * 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#ifdef CONFIG_88EU_AP_MODE
440	unsigned char bstart_bss;
441#endif
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
449int init_mlme_ext_priv(struct adapter *adapter);
450int init_hw_mlme_ext(struct adapter *padapter);
451void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext);
452extern void init_mlme_ext_timer(struct adapter *padapter);
453extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta);
454extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
455
456unsigned char networktype_to_raid(unsigned char network_type);
457u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len);
458void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len);
459void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS);
460void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen);
461
462void Save_DM_Func_Flag(struct adapter *padapter);
463void Restore_DM_Func_Flag(struct adapter *padapter);
464void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable);
465
466void Set_MSR(struct adapter *padapter, u8 type);
467
468u8 rtw_get_oper_ch(struct adapter *adapter);
469void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
470u8 rtw_get_oper_bw(struct adapter *adapter);
471void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
472u8 rtw_get_oper_choffset(struct adapter *adapter);
473void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
474
475void set_channel_bwmode(struct adapter *padapter, unsigned char channel,
476			unsigned char channel_offset, unsigned short bwmode);
477void SelectChannel(struct adapter *padapter, unsigned char channel);
478void SetBWMode(struct adapter *padapter, unsigned short bwmode,
479	       unsigned char channel_offset);
480
481unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);
482
483void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
484void clear_cam_entry(struct adapter *padapter, u8 entry);
485
486void invalidate_cam_all(struct adapter *padapter);
487void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex);
488
489int allocate_fw_sta_entry(struct adapter *padapter);
490void flush_all_cam_entry(struct adapter *padapter);
491
492void site_survey(struct adapter *padapter);
493u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame,
494		    struct wlan_bssid_ex *bssid);
495void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src,
496		    struct adapter *adapter, bool update_ie);
497
498int get_bsstype(unsigned short capability);
499u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork);
500u16 get_beacon_interval(struct wlan_bssid_ex *bss);
501
502int is_client_associated_to_ap(struct adapter *padapter);
503int is_client_associated_to_ibss(struct adapter *padapter);
504int is_IBSS_empty(struct adapter *padapter);
505
506unsigned char check_assoc_AP(u8 *pframe, uint len);
507
508int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
509void WMMOnAssocRsp(struct adapter *padapter);
510
511void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
512void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
513void HTOnAssocRsp(struct adapter *padapter);
514
515void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE);
516void VCS_update(struct adapter *padapter, struct sta_info *psta);
517
518void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len,
519		        struct sta_info *psta);
520int rtw_check_bcn_info(struct adapter  *Adapter, u8 *pframe, u32 packet_len);
521void update_IOT_info(struct adapter *padapter);
522void update_capinfo(struct adapter *adapter, u16 updatecap);
523void update_wireless_mode(struct adapter *padapter);
524void update_tx_basic_rate(struct adapter *padapter, u8 modulation);
525void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id);
526int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie,
527			    uint var_ie_len, int cam_idx);
528
529/* for sta/adhoc mode */
530void update_sta_info(struct adapter *padapter, struct sta_info *psta);
531unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz);
532unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz);
533unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps);
534void Update_RA_Entry(struct adapter *padapter, u32 mac_id);
535void set_sta_rate(struct adapter *padapter, struct sta_info *psta);
536
537unsigned int receive_disconnect(struct adapter *padapter,
538				unsigned char *macaddr, unsigned short reason);
539
540unsigned char get_highest_rate_idx(u32 mask);
541int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps);
542unsigned int is_ap_in_tkip(struct adapter *padapter);
543unsigned int is_ap_in_wep(struct adapter *padapter);
544unsigned int should_forbid_n_rate(struct adapter *padapter);
545
546void report_join_res(struct adapter *padapter, int res);
547void report_survey_event(struct adapter *padapter,
548			 struct recv_frame *precv_frame);
549void report_surveydone_event(struct adapter *padapter);
550void report_del_sta_event(struct adapter *padapter,
551			  unsigned char *addr, unsigned short reason);
552void report_add_sta_event(struct adapter *padapter, unsigned char *addr,
553			  int cam_idx);
554
555void beacon_timing_control(struct adapter *padapter);
556extern u8 set_tx_beacon_cmd(struct adapter *padapter);
557unsigned int setup_beacon_frame(struct adapter *padapter,
558				unsigned char *beacon_frame);
559void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
560void update_mgntframe_attrib(struct adapter *padapter,
561			     struct pkt_attrib *pattrib);
562void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe);
563s32 dump_mgntframe_and_wait(struct adapter *padapter,
564			    struct xmit_frame *pmgntframe, int timeout_ms);
565s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
566				struct xmit_frame *pmgntframe);
567
568void issue_beacon(struct adapter *padapter, int timeout_ms);
569void issue_probersp(struct adapter *padapter, unsigned char *da,
570		    u8 is_valid_p2p_probereq);
571void issue_assocreq(struct adapter *padapter);
572void issue_asocrsp(struct adapter *padapter, unsigned short status,
573		   struct sta_info *pstat, int pkt_type);
574void issue_auth(struct adapter *padapter, struct sta_info *psta,
575		unsigned short status);
576void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid,
577		    u8 *da);
578s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid,
579		      u8 *da, int try_cnt, int wait_ms);
580int issue_nulldata(struct adapter *padapter, unsigned char *da,
581		   unsigned int power_mode, int try_cnt, int wait_ms);
582int issue_qos_nulldata(struct adapter *padapter, unsigned char *da,
583		       u16 tid, int try_cnt, int wait_ms);
584int issue_deauth(struct adapter *padapter, unsigned char *da,
585		 unsigned short reason);
586int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason,
587		    int try_cnt, int wait_ms);
588void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch,
589				 u8 ch_offset);
590void issue_action_BA(struct adapter *padapter, unsigned char *raddr,
591		     unsigned char action, unsigned short status);
592unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
593unsigned int send_beacon(struct adapter *padapter);
594
595void start_clnt_assoc(struct adapter *padapter);
596void start_clnt_auth(struct adapter *padapter);
597void start_clnt_join(struct adapter *padapter);
598void start_create_ibss(struct adapter *padapter);
599
600unsigned int OnAssocReq(struct adapter *padapter,
601			struct recv_frame *precv_frame);
602unsigned int OnAssocRsp(struct adapter *padapter,
603			struct recv_frame *precv_frame);
604unsigned int OnProbeReq(struct adapter *padapter,
605			struct recv_frame *precv_frame);
606unsigned int OnProbeRsp(struct adapter *padapter,
607			struct recv_frame *precv_frame);
608unsigned int DoReserved(struct adapter *padapter,
609			struct recv_frame *precv_frame);
610unsigned int OnBeacon(struct adapter *padapter,
611		      struct recv_frame *precv_frame);
612unsigned int OnAtim(struct adapter *padapter,
613		    struct recv_frame *precv_frame);
614unsigned int OnDisassoc(struct adapter *padapter,
615			struct recv_frame *precv_frame);
616unsigned int OnAuth(struct adapter *padapter,
617		    struct recv_frame *precv_frame);
618unsigned int OnAuthClient(struct adapter *padapter,
619			  struct recv_frame *precv_frame);
620unsigned int OnDeAuth(struct adapter *padapter,
621		      struct recv_frame *precv_frame);
622unsigned int OnAction(struct adapter *padapter,
623		      struct recv_frame *precv_frame);
624
625unsigned int on_action_spct(struct adapter *padapter,
626			    struct recv_frame *precv_frame);
627unsigned int OnAction_qos(struct adapter *padapter,
628			  struct recv_frame *precv_frame);
629unsigned int OnAction_dls(struct adapter *padapter,
630			  struct recv_frame *precv_frame);
631unsigned int OnAction_back(struct adapter *padapter,
632			   struct recv_frame *precv_frame);
633unsigned int on_action_public(struct adapter *padapter,
634			      struct recv_frame *precv_frame);
635unsigned int OnAction_ht(struct adapter *padapter,
636			 struct recv_frame *precv_frame);
637unsigned int OnAction_wmm(struct adapter *padapter,
638			  struct recv_frame *precv_frame);
639unsigned int OnAction_p2p(struct adapter *padapter,
640			  struct recv_frame *precv_frame);
641
642void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
643void mlmeext_sta_del_event_callback(struct adapter *padapter);
644void mlmeext_sta_add_event_callback(struct adapter *padapter,
645				    struct sta_info *psta);
646
647void linked_status_chk(struct adapter *padapter);
648
649void survey_timer_hdl (void *function_context);
650void link_timer_hdl (void *funtion_context);
651void addba_timer_hdl(void *function_context);
652
653#define set_survey_timer(mlmeext, ms) \
654	do { \
655		_set_timer(&(mlmeext)->survey_timer, (ms)); \
656	} while (0)
657
658#define set_link_timer(mlmeext, ms) \
659	do { \
660		_set_timer(&(mlmeext)->link_timer, (ms)); \
661	} while (0)
662
663int cckrates_included(unsigned char *rate, int ratelen);
664int cckratesonly_included(unsigned char *rate, int ratelen);
665
666void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);
667
668void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
669void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext);
670
671struct cmd_hdl {
672	uint	parmsize;
673	u8 (*h2cfuns)(struct adapter  *padapter, u8 *pbuf);
674};
675
676u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
677u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
678u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
679u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
680u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
681u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
682u8 NULL_hdl(struct adapter *padapter, u8 *pbuf);
683u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
684u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
685u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
686u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
687u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
688u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
689u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
690u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
691u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
692u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
693u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);
694
695u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
696u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
697u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
698u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
699u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
700u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
701/* Handling DFS channel switch announcement ie. */
702u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf);
703u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
704
705#define GEN_DRV_CMD_HANDLER(size, cmd)	{size, &cmd ## _hdl},
706#define GEN_MLME_EXT_HANDLER(size, cmd)	{size, cmd},
707
708#ifdef _RTW_CMD_C_
709
710static struct cmd_hdl wlancmds[] = {
711	GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), join_cmd_hdl)
712	GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl)
713	GEN_MLME_EXT_HANDLER(sizeof (struct wlan_bssid_ex), createbss_hdl)
714	GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl)
715	GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl)
716	GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl)
717	GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl)
718	GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl)
719	GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL)
720	GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl)
721	GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl)
722	GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), tx_beacon_hdl)
723	GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl)
724	GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl)
725	GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), set_chplan_hdl)
726};
727
728#endif
729
730struct C2HEvent_Header {
731#ifdef __LITTLE_ENDIAN
732	unsigned int len:16;
733	unsigned int ID:8;
734	unsigned int seq:8;
735#elif defined(__BIG_ENDIAN)
736	unsigned int seq:8;
737	unsigned int ID:8;
738	unsigned int len:16;
739#endif
740	unsigned int rsvd;
741};
742
743void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf);
744void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf);
745
746enum rtw_c2h_event {
747	GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
748	GEN_EVT_CODE(_Read_BBREG),
749	GEN_EVT_CODE(_Read_RFREG),
750	GEN_EVT_CODE(_Read_EEPROM),
751	GEN_EVT_CODE(_Read_EFUSE),
752	GEN_EVT_CODE(_Read_CAM),	/*5*/
753	GEN_EVT_CODE(_Get_BasicRate),
754	GEN_EVT_CODE(_Get_DataRate),
755	GEN_EVT_CODE(_Survey),	 /*8*/
756	GEN_EVT_CODE(_SurveyDone),	 /*9*/
757
758	GEN_EVT_CODE(_JoinBss) , /*10*/
759	GEN_EVT_CODE(_AddSTA),
760	GEN_EVT_CODE(_DelSTA),
761	GEN_EVT_CODE(_AtimDone),
762	GEN_EVT_CODE(_TX_Report),
763	GEN_EVT_CODE(_CCX_Report),		/*15*/
764	GEN_EVT_CODE(_DTM_Report),
765	GEN_EVT_CODE(_TX_Rate_Statistics),
766	GEN_EVT_CODE(_C2HLBK),
767	GEN_EVT_CODE(_FWDBG),
768	GEN_EVT_CODE(_C2HFEEDBACK),             /*20*/
769	GEN_EVT_CODE(_ADDBA),
770	GEN_EVT_CODE(_C2HBCN),
771	GEN_EVT_CODE(_ReportPwrState),	/* filen: only for PCIE, USB */
772	GEN_EVT_CODE(_CloseRF),		/* filen: only for PCIE,
773					 * work around ASPM */
774	MAX_C2HEVT
775};
776
777
778#ifdef _RTW_MLME_EXT_C_
779
780static struct fwevent wlanevents[] = {
781	{0, rtw_dummy_event_callback},	/*0*/
782	{0, NULL},
783	{0, NULL},
784	{0, NULL},
785	{0, NULL},
786	{0, NULL},
787	{0, NULL},
788	{0, NULL},
789	{0, &rtw_survey_event_callback},		/*8*/
790	{sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/
791	{0, &rtw_joinbss_event_callback},		/*10*/
792	{sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
793	{sizeof(struct stadel_event), &rtw_stadel_event_callback},
794	{0, &rtw_atimdone_event_callback},
795	{0, rtw_dummy_event_callback},
796	{0, NULL},	/*15*/
797	{0, NULL},
798	{0, NULL},
799	{0, NULL},
800	{0, rtw_fwdbg_event_callback},
801	{0, NULL},	 /*20*/
802	{0, NULL},
803	{0, NULL},
804	{0, &rtw_cpwm_event_callback},
805	{0, NULL},
806};
807
808#endif/* _RTL_MLME_EXT_C_ */
809
810#endif /* __RTW_MLME_EXT_H_ */
811