wlcore, wl1251: fix spelling: "Couldnt" -> "Couldn't" and remove error on -ENOMEM
[linux-2.6/btrfs-unstable.git] / drivers / staging / rtl8723bs / include / rtw_mlme_ext.h
blob6613dea2b283c5ea2e9cd4be6a9349bf0b6d04d1
1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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.
14 ******************************************************************************/
15 #ifndef __RTW_MLME_EXT_H_
16 #define __RTW_MLME_EXT_H_
19 /* Commented by Albert 20101105 */
20 /* Increase the SURVEY_TO value from 100 to 150 (100ms to 150ms) */
21 /* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */
22 /* So, this driver tried to extend the dwell time for each scanning channel. */
23 /* This will increase the chance to receive the probe response from SoftAP. */
25 #define SURVEY_TO (100)
26 #define REAUTH_TO (300) /* 50) */
27 #define REASSOC_TO (300) /* 50) */
28 /* define DISCONNECT_TO (3000) */
29 #define ADDBA_TO (2000)
31 #define LINKED_TO (1) /* unit:2 sec, 1x2 =2 sec */
33 #define REAUTH_LIMIT (4)
34 #define REASSOC_LIMIT (4)
35 #define READDBA_LIMIT (2)
37 #define ROAMING_LIMIT 8
38 /* define IOCMD_REG0 0x10250370 */
39 /* define IOCMD_REG1 0x10250374 */
40 /* define IOCMD_REG2 0x10250378 */
42 /* define FW_DYNAMIC_FUN_SWITCH 0x10250364 */
44 /* define WRITE_BB_CMD 0xF0000001 */
45 /* define SET_CHANNEL_CMD 0xF3000000 */
46 /* define UPDATE_RA_CMD 0xFD0000A2 */
48 #define DYNAMIC_FUNC_DISABLE (0x0)
50 /* ====== ODM_ABILITY_E ======== */
51 /* BB ODM section BIT 0-15 */
52 #define DYNAMIC_BB_DIG BIT0 /* ODM_BB_DIG */
53 #define DYNAMIC_BB_RA_MASK BIT1 /* ODM_BB_RA_MASK */
54 #define DYNAMIC_BB_DYNAMIC_TXPWR BIT2 /* ODM_BB_DYNAMIC_TXPWR */
55 #define DYNAMIC_BB_BB_FA_CNT BIT3 /* ODM_BB_FA_CNT */
56 #define DYNAMIC_BB_RSSI_MONITOR BIT4 /* ODM_BB_RSSI_MONITOR */
57 #define DYNAMIC_BB_CCK_PD BIT5 /* ODM_BB_CCK_PD */
58 #define DYNAMIC_BB_ANT_DIV BIT6 /* ODM_BB_ANT_DIV */
59 #define DYNAMIC_BB_PWR_SAVE BIT7 /* ODM_BB_PWR_SAVE */
60 #define DYNAMIC_BB_PWR_TRAIN BIT8 /* ODM_BB_PWR_TRAIN */
61 #define DYNAMIC_BB_RATE_ADAPTIVE BIT9 /* ODM_BB_RATE_ADAPTIVE */
62 #define DYNAMIC_BB_PATH_DIV BIT10/* ODM_BB_PATH_DIV */
63 #define DYNAMIC_BB_PSD BIT11/* ODM_BB_PSD */
64 #define DYNAMIC_BB_RXHP BIT12/* ODM_BB_RXHP */
65 #define DYNAMIC_BB_ADAPTIVITY BIT13/* ODM_BB_ADAPTIVITY */
66 #define DYNAMIC_BB_DYNAMIC_ATC BIT14/* ODM_BB_DYNAMIC_ATC */
68 /* MAC DM section BIT 16-23 */
69 #define DYNAMIC_MAC_EDCA_TURBO BIT16/* ODM_MAC_EDCA_TURBO */
70 #define DYNAMIC_MAC_EARLY_MODE BIT17/* ODM_MAC_EARLY_MODE */
72 /* RF ODM section BIT 24-31 */
73 #define DYNAMIC_RF_TX_PWR_TRACK BIT24/* ODM_RF_TX_PWR_TRACK */
74 #define DYNAMIC_RF_RX_GAIN_TRACK BIT25/* ODM_RF_RX_GAIN_TRACK */
75 #define DYNAMIC_RF_CALIBRATION BIT26/* ODM_RF_CALIBRATION */
77 #define DYNAMIC_ALL_FUNC_ENABLE 0xFFFFFFF
79 #define _HW_STATE_NOLINK_ 0x00
80 #define _HW_STATE_ADHOC_ 0x01
81 #define _HW_STATE_STATION_ 0x02
82 #define _HW_STATE_AP_ 0x03
85 #define _1M_RATE_ 0
86 #define _2M_RATE_ 1
87 #define _5M_RATE_ 2
88 #define _11M_RATE_ 3
89 #define _6M_RATE_ 4
90 #define _9M_RATE_ 5
91 #define _12M_RATE_ 6
92 #define _18M_RATE_ 7
93 #define _24M_RATE_ 8
94 #define _36M_RATE_ 9
95 #define _48M_RATE_ 10
96 #define _54M_RATE_ 11
98 /********************************************************
99 MCS rate definitions
100 *********************************************************/
101 #define MCS_RATE_1R (0x000000ff)
102 #define MCS_RATE_2R (0x0000ffff)
103 #define MCS_RATE_3R (0x00ffffff)
104 #define MCS_RATE_4R (0xffffffff)
105 #define MCS_RATE_2R_13TO15_OFF (0x00001fff)
108 extern unsigned char RTW_WPA_OUI[];
109 extern unsigned char WMM_OUI[];
110 extern unsigned char WPS_OUI[];
111 extern unsigned char WFD_OUI[];
112 extern unsigned char P2P_OUI[];
114 extern unsigned char WMM_INFO_OUI[];
115 extern unsigned char WMM_PARA_OUI[];
118 /* */
119 /* Channel Plan Type. */
120 /* Note: */
121 /* We just add new channel plan when the new channel plan is different from any of the following */
122 /* channel plan. */
123 /* If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */
124 /* customize them in RT_CHANNEL_INFO in the RT_CHANNEL_LIST. */
125 /* */
126 typedef enum _RT_CHANNEL_DOMAIN
128 /* old channel plan mapping ===== */
129 RT_CHANNEL_DOMAIN_FCC = 0x00,
130 RT_CHANNEL_DOMAIN_IC = 0x01,
131 RT_CHANNEL_DOMAIN_ETSI = 0x02,
132 RT_CHANNEL_DOMAIN_SPAIN = 0x03,
133 RT_CHANNEL_DOMAIN_FRANCE = 0x04,
134 RT_CHANNEL_DOMAIN_MKK = 0x05,
135 RT_CHANNEL_DOMAIN_MKK1 = 0x06,
136 RT_CHANNEL_DOMAIN_ISRAEL = 0x07,
137 RT_CHANNEL_DOMAIN_TELEC = 0x08,
138 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09,
139 RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A,
140 RT_CHANNEL_DOMAIN_TAIWAN = 0x0B,
141 RT_CHANNEL_DOMAIN_CHINA = 0x0C,
142 RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D,
143 RT_CHANNEL_DOMAIN_KOREA = 0x0E,
144 RT_CHANNEL_DOMAIN_TURKEY = 0x0F,
145 RT_CHANNEL_DOMAIN_JAPAN = 0x10,
146 RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11,
147 RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12,
148 RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13,
149 RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14,
151 /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */
152 RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20,
153 RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21,
154 RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22,
155 RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23,
156 RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24,
157 RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25,
158 RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26,
159 RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27,
160 RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28,
161 RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29,
162 RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30,
163 RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31,
164 RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32,
165 RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33,
166 RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34,
167 RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35,
168 RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36,
169 RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37,
170 RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38,
171 RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39,
172 RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40,
173 RT_CHANNEL_DOMAIN_GLOBAL_NULL = 0x41,
174 RT_CHANNEL_DOMAIN_ETSI1_ETSI4 = 0x42,
175 RT_CHANNEL_DOMAIN_FCC1_FCC2 = 0x43,
176 RT_CHANNEL_DOMAIN_FCC1_NCC3 = 0x44,
177 RT_CHANNEL_DOMAIN_WORLD_ETSI5 = 0x45,
178 RT_CHANNEL_DOMAIN_FCC1_FCC8 = 0x46,
179 RT_CHANNEL_DOMAIN_WORLD_ETSI6 = 0x47,
180 RT_CHANNEL_DOMAIN_WORLD_ETSI7 = 0x48,
181 RT_CHANNEL_DOMAIN_WORLD_ETSI8 = 0x49,
182 RT_CHANNEL_DOMAIN_WORLD_ETSI9 = 0x50,
183 RT_CHANNEL_DOMAIN_WORLD_ETSI10 = 0x51,
184 RT_CHANNEL_DOMAIN_WORLD_ETSI11 = 0x52,
185 RT_CHANNEL_DOMAIN_FCC1_NCC4 = 0x53,
186 RT_CHANNEL_DOMAIN_WORLD_ETSI12 = 0x54,
187 RT_CHANNEL_DOMAIN_FCC1_FCC9 = 0x55,
188 RT_CHANNEL_DOMAIN_WORLD_ETSI13 = 0x56,
189 RT_CHANNEL_DOMAIN_FCC1_FCC10 = 0x57,
190 /* Add new channel plan above this line =============== */
191 RT_CHANNEL_DOMAIN_MAX,
192 RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F,
193 }RT_CHANNEL_DOMAIN, *PRT_CHANNEL_DOMAIN;
195 typedef enum _RT_CHANNEL_DOMAIN_2G
197 RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwird 13 */
198 RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */
199 RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */
200 RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03, /* Japan */
201 RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04, /* France */
202 RT_CHANNEL_DOMAIN_2G_GLOBAL = 0x05, /* Global domain */
203 RT_CHANNEL_DOMAIN_2G_NULL = 0x06,
204 /* Add new channel plan above this line =============== */
205 RT_CHANNEL_DOMAIN_2G_MAX,
206 }RT_CHANNEL_DOMAIN_2G, *PRT_CHANNEL_DOMAIN_2G;
208 typedef enum _RT_CHANNEL_DOMAIN_5G
210 RT_CHANNEL_DOMAIN_5G_NULL = 0x00,
211 RT_CHANNEL_DOMAIN_5G_ETSI1 = 0x01, /* Europe */
212 RT_CHANNEL_DOMAIN_5G_ETSI2 = 0x02, /* Australia, New Zealand */
213 RT_CHANNEL_DOMAIN_5G_ETSI3 = 0x03, /* Russia */
214 RT_CHANNEL_DOMAIN_5G_FCC1 = 0x04, /* US */
215 RT_CHANNEL_DOMAIN_5G_FCC2 = 0x05, /* FCC o/w DFS Channels */
216 RT_CHANNEL_DOMAIN_5G_FCC3 = 0x06, /* India, Mexico */
217 RT_CHANNEL_DOMAIN_5G_FCC4 = 0x07, /* Venezuela */
218 RT_CHANNEL_DOMAIN_5G_FCC5 = 0x08, /* China */
219 RT_CHANNEL_DOMAIN_5G_FCC6 = 0x09, /* Israel */
220 RT_CHANNEL_DOMAIN_5G_FCC7_IC1 = 0x0A, /* US, Canada */
221 RT_CHANNEL_DOMAIN_5G_KCC1 = 0x0B, /* Korea */
222 RT_CHANNEL_DOMAIN_5G_MKK1 = 0x0C, /* Japan */
223 RT_CHANNEL_DOMAIN_5G_MKK2 = 0x0D, /* Japan (W52, W53) */
224 RT_CHANNEL_DOMAIN_5G_MKK3 = 0x0E, /* Japan (W56) */
225 RT_CHANNEL_DOMAIN_5G_NCC1 = 0x0F, /* Taiwan */
226 RT_CHANNEL_DOMAIN_5G_NCC2 = 0x10, /* Taiwan o/w DFS */
227 RT_CHANNEL_DOMAIN_5G_NCC3 = 0x11, /* Taiwan w/o DFS, Band4 only */
228 RT_CHANNEL_DOMAIN_5G_ETSI4 = 0x12, /* Europe w/o DFS, Band1 only */
229 RT_CHANNEL_DOMAIN_5G_ETSI5 = 0x13, /* Australia, New Zealand(w/o Weather radar) */
230 RT_CHANNEL_DOMAIN_5G_FCC8 = 0x14, /* Latin America */
231 RT_CHANNEL_DOMAIN_5G_ETSI6 = 0x15, /* Israel, Bahrain, Egypt, India, China, Malaysia */
232 RT_CHANNEL_DOMAIN_5G_ETSI7 = 0x16, /* China */
233 RT_CHANNEL_DOMAIN_5G_ETSI8 = 0x17, /* Jordan */
234 RT_CHANNEL_DOMAIN_5G_ETSI9 = 0x18, /* Lebanon */
235 RT_CHANNEL_DOMAIN_5G_ETSI10 = 0x19, /* Qatar */
236 RT_CHANNEL_DOMAIN_5G_ETSI11 = 0x1A, /* Russia */
237 RT_CHANNEL_DOMAIN_5G_NCC4 = 0x1B, /* Taiwan, (w/o Weather radar) */
238 RT_CHANNEL_DOMAIN_5G_ETSI12 = 0x1C, /* Indonesia */
239 RT_CHANNEL_DOMAIN_5G_FCC9 = 0x1D, /* w/o Weather radar) */
240 RT_CHANNEL_DOMAIN_5G_ETSI13 = 0x1E, /* w/o Weather radar) */
241 RT_CHANNEL_DOMAIN_5G_FCC10 = 0x1F, /* Argentina (w/o Weather radar) */
242 /* Add new channel plan above this line =============== */
243 /* Driver Self Defined ===== */
244 RT_CHANNEL_DOMAIN_5G_FCC = 0x20,
245 RT_CHANNEL_DOMAIN_5G_JAPAN_NO_DFS = 0x21,
246 RT_CHANNEL_DOMAIN_5G_FCC4_NO_DFS = 0x22,
247 RT_CHANNEL_DOMAIN_5G_MAX,
248 }RT_CHANNEL_DOMAIN_5G, *PRT_CHANNEL_DOMAIN_5G;
250 #define rtw_is_channel_plan_valid(chplan) (chplan<RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE)
252 typedef struct _RT_CHANNEL_PLAN
254 unsigned char Channel[MAX_CHANNEL_NUM];
255 unsigned char Len;
256 }RT_CHANNEL_PLAN, *PRT_CHANNEL_PLAN;
258 typedef struct _RT_CHANNEL_PLAN_2G
260 unsigned char Channel[MAX_CHANNEL_NUM_2G];
261 unsigned char Len;
262 }RT_CHANNEL_PLAN_2G, *PRT_CHANNEL_PLAN_2G;
264 typedef struct _RT_CHANNEL_PLAN_5G
266 unsigned char Channel[MAX_CHANNEL_NUM_5G];
267 unsigned char Len;
268 }RT_CHANNEL_PLAN_5G, *PRT_CHANNEL_PLAN_5G;
270 typedef struct _RT_CHANNEL_PLAN_MAP
272 unsigned char Index2G;
273 unsigned char Index5G;
274 }RT_CHANNEL_PLAN_MAP, *PRT_CHANNEL_PLAN_MAP;
276 enum Associated_AP
278 atherosAP = 0,
279 broadcomAP = 1,
280 ciscoAP = 2,
281 marvellAP = 3,
282 ralinkAP = 4,
283 realtekAP = 5,
284 airgocapAP = 6,
285 unknownAP = 7,
286 maxAP,
289 typedef enum _HT_IOT_PEER
291 HT_IOT_PEER_UNKNOWN = 0,
292 HT_IOT_PEER_REALTEK = 1,
293 HT_IOT_PEER_REALTEK_92SE = 2,
294 HT_IOT_PEER_BROADCOM = 3,
295 HT_IOT_PEER_RALINK = 4,
296 HT_IOT_PEER_ATHEROS = 5,
297 HT_IOT_PEER_CISCO = 6,
298 HT_IOT_PEER_MERU = 7,
299 HT_IOT_PEER_MARVELL = 8,
300 HT_IOT_PEER_REALTEK_SOFTAP = 9,/* peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
301 HT_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */
302 HT_IOT_PEER_AIRGO = 11,
303 HT_IOT_PEER_INTEL = 12,
304 HT_IOT_PEER_RTK_APCLIENT = 13,
305 HT_IOT_PEER_REALTEK_81XX = 14,
306 HT_IOT_PEER_REALTEK_WOW = 15,
307 HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 16,
308 HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 17,
309 HT_IOT_PEER_MAX = 18
310 }HT_IOT_PEER_E, *PHTIOT_PEER_E;
313 enum SCAN_STATE
315 SCAN_DISABLE = 0,
316 SCAN_START = 1,
317 SCAN_TXNULL = 2,
318 SCAN_PROCESS = 3,
319 SCAN_COMPLETE = 4,
320 SCAN_STATE_MAX,
323 struct mlme_handler {
324 unsigned int num;
325 char* str;
326 unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
329 struct action_handler {
330 unsigned int num;
331 char* str;
332 unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame);
335 struct ss_res
337 int state;
338 int bss_cnt;
339 int channel_idx;
340 int scan_mode;
341 u8 ssid_num;
342 u8 ch_num;
343 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
344 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
347 /* define AP_MODE 0x0C */
348 /* define STATION_MODE 0x08 */
349 /* define AD_HOC_MODE 0x04 */
350 /* define NO_LINK_MODE 0x00 */
352 #define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_
353 #define WIFI_FW_STATION_STATE _HW_STATE_STATION_
354 #define WIFI_FW_AP_STATE _HW_STATE_AP_
355 #define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_
357 #define WIFI_FW_AUTH_NULL 0x00000100
358 #define WIFI_FW_AUTH_STATE 0x00000200
359 #define WIFI_FW_AUTH_SUCCESS 0x00000400
361 #define WIFI_FW_ASSOC_STATE 0x00002000
362 #define WIFI_FW_ASSOC_SUCCESS 0x00004000
364 #define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | WIFI_FW_AUTH_SUCCESS |WIFI_FW_ASSOC_STATE)
366 struct FW_Sta_Info
368 struct sta_info *psta;
369 u32 status;
370 u32 rx_pkt;
371 u32 retry;
372 NDIS_802_11_RATES_EX SupportedRates;
376 * Usage:
377 * When one iface acted as AP mode and the other iface is STA mode and scanning,
378 * it should switch back to AP's operating channel periodically.
379 * Parameters info:
380 * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to AP's operating channel for
381 * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds.
382 * Example:
383 * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1,
384 * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MILLISECOND is 3 and SURVEY_TO is 100.
385 * When it's STA mode gets set_scan command,
386 * it would
387 * 1. Doing the scan on channel 1.2.3.4.5.6.7.8
388 * 2. Back to channel 1 for 300 milliseconds
389 * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52
390 * 4. Back to channel 1 for 300 milliseconds
391 * 5. ... and so on, till survey done.
393 struct mlme_ext_info
395 u32 state;
396 u32 reauth_count;
397 u32 reassoc_count;
398 u32 link_count;
399 u32 auth_seq;
400 u32 auth_algo; /* 802.11 auth, could be open, shared, auto */
401 u32 authModeToggle;
402 u32 enc_algo;/* encrypt algorithm; */
403 u32 key_index; /* this is only valid for legendary wep, 0~3 for key id. */
404 u32 iv;
405 u8 chg_txt[128];
406 u16 aid;
407 u16 bcn_interval;
408 u16 capability;
409 u8 assoc_AP_vendor;
410 u8 slotTime;
411 u8 preamble_mode;
412 u8 WMM_enable;
413 u8 ERP_enable;
414 u8 ERP_IE;
415 u8 HT_enable;
416 u8 HT_caps_enable;
417 u8 HT_info_enable;
418 u8 HT_protection;
419 u8 turboMode_cts2self;
420 u8 turboMode_rtsen;
421 u8 SM_PS;
422 u8 agg_enable_bitmap;
423 u8 ADDBA_retry_count;
424 u8 candidate_tid_bitmap;
425 u8 dialogToken;
426 /* Accept ADDBA Request */
427 bool accept_addba_req;
428 u8 bwmode_updated;
429 u8 hidden_ssid_mode;
430 u8 VHT_enable;
432 struct ADDBA_request ADDBA_req;
433 struct WMM_para_element WMM_param;
434 struct HT_caps_element HT_caps;
435 struct HT_info_element HT_info;
436 struct wlan_bssid_ex network;/* join network or bss_network, if in ap mode, it is the same to cur_network.network */
437 struct FW_Sta_Info FW_sta_info[NUM_STA];
440 /* The channel information about this channel including joining, scanning, and power constraints. */
441 typedef struct _RT_CHANNEL_INFO
443 u8 ChannelNum; /* The channel number. */
444 RT_SCAN_TYPE ScanType; /* Scan type such as passive or active scan. */
445 }RT_CHANNEL_INFO, *PRT_CHANNEL_INFO;
447 int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch);
448 bool rtw_mlme_band_check(struct adapter *adapter, const u32 ch);
450 /* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */
451 #define P2P_MAX_REG_CLASSES 10
453 /* P2P_MAX_REG_CLASS_CHANNELS - Maximum number of channels per regulatory class */
454 #define P2P_MAX_REG_CLASS_CHANNELS 20
456 /* struct p2p_channels - List of supported channels */
457 struct p2p_channels {
458 /* struct p2p_reg_class - Supported regulatory class */
459 struct p2p_reg_class {
460 /* reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */
461 u8 reg_class;
463 /* channel - Supported channels */
464 u8 channel[P2P_MAX_REG_CLASS_CHANNELS];
466 /* channels - Number of channel entries in use */
467 size_t channels;
468 } reg_class[P2P_MAX_REG_CLASSES];
470 /* reg_classes - Number of reg_class entries in use */
471 size_t reg_classes;
474 struct p2p_oper_class_map {
475 enum hw_mode {IEEE80211G, IEEE80211A} mode;
476 u8 op_class;
477 u8 min_chan;
478 u8 max_chan;
479 u8 inc;
480 enum { BW20, BW40PLUS, BW40MINUS } bw;
483 struct mlme_ext_priv
485 struct adapter *padapter;
486 u8 mlmeext_init;
487 atomic_t event_seq;
488 u16 mgnt_seq;
489 u16 sa_query_seq;
490 u64 mgnt_80211w_IPN;
491 u64 mgnt_80211w_IPN_rx;
492 /* struct fw_priv fwpriv; */
494 unsigned char cur_channel;
495 unsigned char cur_bwmode;
496 unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */
497 unsigned char cur_wireless_mode; /* NETWORK_TYPE */
499 unsigned char max_chan_nums;
500 RT_CHANNEL_INFO channel_set[MAX_CHANNEL_NUM];
501 struct p2p_channels channel_list;
502 unsigned char basicrate[NumRates];
503 unsigned char datarate[NumRates];
504 unsigned char default_supported_mcs_set[16];
506 struct ss_res sitesurvey_res;
507 struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including current scanning/connecting/connected related info. */
508 /* for ap mode, network includes ap's cap_info */
509 _timer survey_timer;
510 _timer link_timer;
511 _timer sa_query_timer;
512 /* _timer ADDBA_timer; */
513 u16 chan_scan_time;
514 unsigned long last_scan_time;
515 u8 scan_abort;
516 u8 tx_rate; /* TXRATE when USERATE is set. */
518 u32 retry; /* retry for issue probereq */
520 u64 TSFValue;
522 /* for LPS-32K to adaptive bcn early and timeout */
523 u8 adaptive_tsf_done;
524 u32 bcn_delay_cnt[9];
525 u32 bcn_delay_ratio[9];
526 u32 bcn_cnt;
527 u8 DrvBcnEarly;
528 u8 DrvBcnTimeOut;
530 unsigned char bstart_bss;
532 u8 update_channel_plan_by_ap_done;
534 /* recv_decache check for Action_public frame */
535 u8 action_public_dialog_token;
536 u16 action_public_rxseq;
538 u8 active_keep_alive_check;
539 #ifdef DBG_FIXED_CHAN
540 u8 fixed_chan;
541 #endif
545 void init_mlme_default_rate_set(struct adapter *padapter);
546 int init_mlme_ext_priv(struct adapter *padapter);
547 int init_hw_mlme_ext(struct adapter *padapter);
548 void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext);
549 extern void init_mlme_ext_timer(struct adapter *padapter);
550 extern void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta);
551 extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv);
553 /* void fill_fwpriv(struct adapter *padapter, struct fw_priv *pfwpriv); */
555 unsigned char networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta);
557 void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len);
558 void set_mcs_rate_by_mask(u8 *mcs_set, u32 mask);
559 void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS);
560 void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen);
562 void Save_DM_Func_Flag(struct adapter *padapter);
563 void Restore_DM_Func_Flag(struct adapter *padapter);
564 void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable);
566 void Set_MSR(struct adapter *padapter, u8 type);
568 u8 rtw_get_oper_ch(struct adapter *adapter);
569 void rtw_set_oper_ch(struct adapter *adapter, u8 ch);
570 u8 rtw_get_oper_bw(struct adapter *adapter);
571 void rtw_set_oper_bw(struct adapter *adapter, u8 bw);
572 u8 rtw_get_oper_choffset(struct adapter *adapter);
573 void rtw_set_oper_choffset(struct adapter *adapter, u8 offset);
574 u8 rtw_get_center_ch(u8 channel, u8 chnl_bw, u8 chnl_offset);
575 unsigned long rtw_get_on_cur_ch_time(struct adapter *adapter);
577 void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode);
578 void SelectChannel(struct adapter *padapter, unsigned char channel);
580 unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval);
582 void read_cam(struct adapter *padapter , u8 entry, u8 *get_key);
584 /* modify HW only */
585 void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key);
586 void _clear_cam_entry(struct adapter *padapter, u8 entry);
587 void write_cam_from_cache(struct adapter *adapter, u8 id);
589 /* modify both HW and cache */
590 void write_cam(struct adapter *padapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
591 void clear_cam_entry(struct adapter *padapter, u8 id);
593 /* modify cache only */
594 void write_cam_cache(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key);
595 void clear_cam_cache(struct adapter *adapter, u8 id);
597 void invalidate_cam_all(struct adapter *padapter);
600 int allocate_fw_sta_entry(struct adapter *padapter);
601 void flush_all_cam_entry(struct adapter *padapter);
603 void site_survey(struct adapter *padapter);
604 u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid);
605 void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *padapter, bool update_ie);
607 u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork);
608 u16 get_beacon_interval(struct wlan_bssid_ex *bss);
610 int is_client_associated_to_ap(struct adapter *padapter);
611 int is_client_associated_to_ibss(struct adapter *padapter);
612 int is_IBSS_empty(struct adapter *padapter);
614 unsigned char check_assoc_AP(u8 *pframe, uint len);
616 int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
617 void WMMOnAssocRsp(struct adapter *padapter);
619 void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
620 void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
621 void HTOnAssocRsp(struct adapter *padapter);
623 void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE);
624 void VCS_update(struct adapter *padapter, struct sta_info *psta);
625 void update_ldpc_stbc_cap(struct sta_info *psta);
627 void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, struct sta_info *psta);
628 int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len);
629 void update_IOT_info(struct adapter *padapter);
630 void update_capinfo(struct adapter * Adapter, u16 updateCap);
631 void update_wireless_mode(struct adapter *padapter);
632 void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode);
633 int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx);
635 /* for sta/adhoc mode */
636 void update_sta_info(struct adapter *padapter, struct sta_info *psta);
637 void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta);
638 void set_sta_rate(struct adapter *padapter, struct sta_info *psta);
640 unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason);
642 unsigned char get_highest_rate_idx(u32 mask);
643 int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode);
644 unsigned int is_ap_in_tkip(struct adapter *padapter);
646 s16 rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid);
647 s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid);
648 void rtw_camid_free(struct adapter *adapter, u8 cam_id);
650 extern void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta);
651 extern void rtw_release_macid(struct adapter *padapter, struct sta_info *psta);
652 extern u8 rtw_search_max_mac_id(struct adapter *padapter);
654 void report_join_res(struct adapter *padapter, int res);
655 void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame);
656 void report_surveydone_event(struct adapter *padapter);
657 void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, unsigned short reason);
658 void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, int cam_idx);
659 bool rtw_port_switch_chk(struct adapter *adapter);
660 void report_wmm_edca_update(struct adapter *padapter);
662 void beacon_timing_control(struct adapter *padapter);
663 u8 chk_bmc_sleepq_cmd(struct adapter *padapter);
664 extern u8 set_tx_beacon_cmd(struct adapter *padapter);
665 unsigned int setup_beacon_frame(struct adapter *padapter, unsigned char *beacon_frame);
666 void update_mgnt_tx_rate(struct adapter *padapter, u8 rate);
667 void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib);
668 void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *pmgntframe);
669 void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe);
670 s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms);
671 s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe);
673 void issue_beacon(struct adapter *padapter, int timeout_ms);
674 void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq);
675 void issue_assocreq(struct adapter *padapter);
676 void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type);
677 void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status);
678 void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da);
679 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);
680 int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms);
681 s32 issue_nulldata_in_interrupt(struct adapter *padapter, u8 *da);
682 int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms);
683 int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason);
684 int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, int wait_ms);
685 void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status);
686 void issue_action_SA_Query(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short tid);
687 unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr);
688 unsigned int send_beacon(struct adapter *padapter);
690 void start_clnt_assoc(struct adapter *padapter);
691 void start_clnt_auth(struct adapter *padapter);
692 void start_clnt_join(struct adapter *padapter);
693 void start_create_ibss(struct adapter *padapter);
695 unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame);
696 unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame);
697 unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame);
698 unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame);
699 unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame);
700 unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame);
701 unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame);
702 unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame);
703 unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame);
704 unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame);
705 unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame);
706 unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame);
708 unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frame);
709 unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame);
710 unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame);
711 unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame);
712 unsigned int OnAction_sa_query(struct adapter *padapter, union recv_frame *precv_frame);
714 void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res);
715 void mlmeext_sta_del_event_callback(struct adapter *padapter);
716 void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta);
718 void linked_status_chk(struct adapter *padapter);
720 void _linked_info_dump(struct adapter *padapter);
722 void survey_timer_hdl (struct timer_list *t);
723 void link_timer_hdl (struct timer_list *t);
724 void addba_timer_hdl(struct timer_list *t);
725 void sa_query_timer_hdl(struct timer_list *t);
726 /* void reauth_timer_hdl(struct adapter *padapter); */
727 /* void reassoc_timer_hdl(struct adapter *padapter); */
729 #define set_survey_timer(mlmeext, ms) \
730 do { \
731 /*DBG_871X("%s set_survey_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
732 _set_timer(&(mlmeext)->survey_timer, (ms)); \
733 } while (0)
735 #define set_link_timer(mlmeext, ms) \
736 do { \
737 /*DBG_871X("%s set_link_timer(%p, %d)\n", __func__, (mlmeext), (ms));*/ \
738 _set_timer(&(mlmeext)->link_timer, (ms)); \
739 } while (0)
740 #define set_sa_query_timer(mlmeext, ms) \
741 do { \
742 DBG_871X("%s set_sa_query_timer(%p, %d)\n", __func__, (mlmeext), (ms)); \
743 _set_timer(&(mlmeext)->sa_query_timer, (ms)); \
744 } while (0)
745 extern int cckrates_included(unsigned char *rate, int ratelen);
746 extern int cckratesonly_included(unsigned char *rate, int ratelen);
748 extern void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);
750 extern void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
751 extern void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext);
752 extern void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len);
753 extern u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer);
755 int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset);
756 int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset);
758 struct cmd_hdl {
759 uint parmsize;
760 u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf);
764 u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf);
765 u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf);
766 u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
767 u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf);
768 u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
769 u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf);
772 u8 NULL_hdl(struct adapter *padapter, u8 *pbuf);
773 u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf);
774 u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf);
775 u8 createbss_hdl(struct adapter *padapter, u8 *pbuf);
776 u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf);
777 u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf);
778 u8 setauth_hdl(struct adapter *padapter, u8 *pbuf);
779 u8 setkey_hdl(struct adapter *padapter, u8 *pbuf);
780 u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf);
781 u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
782 u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf);
783 u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf);
785 u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf);
786 u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf);
787 u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf);
788 u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf);
789 u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf);
790 u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf);
791 u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);
792 u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); /* Kurt: Handling DFS channel switch announcement ie. */
793 u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf);
794 u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf);
797 #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl},
798 #define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd},
800 struct C2HEvent_Header
803 #ifdef __LITTLE_ENDIAN
805 unsigned int len:16;
806 unsigned int ID:8;
807 unsigned int seq:8;
808 #else
809 unsigned int seq:8;
810 unsigned int ID:8;
811 unsigned int len:16;
812 #endif
813 unsigned int rsvd;
816 void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf);
817 void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf);
819 enum rtw_c2h_event
821 GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
822 GEN_EVT_CODE(_Read_BBREG),
823 GEN_EVT_CODE(_Read_RFREG),
824 GEN_EVT_CODE(_Read_EEPROM),
825 GEN_EVT_CODE(_Read_EFUSE),
826 GEN_EVT_CODE(_Read_CAM), /*5*/
827 GEN_EVT_CODE(_Get_BasicRate),
828 GEN_EVT_CODE(_Get_DataRate),
829 GEN_EVT_CODE(_Survey), /*8*/
830 GEN_EVT_CODE(_SurveyDone), /*9*/
832 GEN_EVT_CODE(_JoinBss) , /*10*/
833 GEN_EVT_CODE(_AddSTA),
834 GEN_EVT_CODE(_DelSTA),
835 GEN_EVT_CODE(_AtimDone) ,
836 GEN_EVT_CODE(_TX_Report),
837 GEN_EVT_CODE(_CCX_Report), /*15*/
838 GEN_EVT_CODE(_DTM_Report),
839 GEN_EVT_CODE(_TX_Rate_Statistics),
840 GEN_EVT_CODE(_C2HLBK),
841 GEN_EVT_CODE(_FWDBG),
842 GEN_EVT_CODE(_C2HFEEDBACK), /*20*/
843 GEN_EVT_CODE(_ADDBA),
844 GEN_EVT_CODE(_C2HBCN),
845 GEN_EVT_CODE(_ReportPwrState), /* filen: only for PCIE, USB */
846 GEN_EVT_CODE(_CloseRF), /* filen: only for PCIE, work around ASPM */
847 GEN_EVT_CODE(_WMM), /*25*/
848 MAX_C2HEVT
852 #ifdef _RTW_MLME_EXT_C_
854 static struct fwevent wlanevents[] =
856 {0, rtw_dummy_event_callback}, /*0*/
857 {0, NULL},
858 {0, NULL},
859 {0, NULL},
860 {0, NULL},
861 {0, NULL},
862 {0, NULL},
863 {0, NULL},
864 {0, &rtw_survey_event_callback}, /*8*/
865 {sizeof (struct surveydone_event), &rtw_surveydone_event_callback}, /*9*/
867 {0, &rtw_joinbss_event_callback}, /*10*/
868 {sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
869 {sizeof(struct stadel_event), &rtw_stadel_event_callback},
870 {0, &rtw_atimdone_event_callback},
871 {0, rtw_dummy_event_callback},
872 {0, NULL}, /*15*/
873 {0, NULL},
874 {0, NULL},
875 {0, NULL},
876 {0, rtw_fwdbg_event_callback},
877 {0, NULL}, /*20*/
878 {0, NULL},
879 {0, NULL},
880 {0, &rtw_cpwm_event_callback},
881 {0, NULL},
882 {0, &rtw_wmm_event_callback},
886 #endif/* _RTL8192C_CMD_C_ */
888 #endif