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