Commit | Line | Data |
---|---|---|
94a79942 LF |
1 | /* |
2 | * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11 | |
3 | * remains copyright by the original authors | |
4 | * | |
5 | * Portions of the merged code are based on Host AP (software wireless | |
6 | * LAN access point) driver for Intersil Prism2/2.5/3. | |
7 | * | |
8 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen | |
9 | * <jkmaline@cc.hut.fi> | |
10 | * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> | |
11 | * | |
12 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos | |
13 | * <jketreno@linux.intel.com> | |
14 | * Copyright (c) 2004, Intel Corporation | |
15 | * | |
16 | * Modified for Realtek's wi-fi cards by Andrea Merello | |
17 | * <andreamrl@tiscali.it> | |
18 | * | |
19 | * This program is free software; you can redistribute it and/or modify | |
20 | * it under the terms of the GNU General Public License version 2 as | |
21 | * published by the Free Software Foundation. See README and COPYING for | |
22 | * more details. | |
23 | */ | |
24 | #ifndef RTLLIB_H | |
25 | #define RTLLIB_H | |
26 | #include <linux/if_ether.h> /* ETH_ALEN */ | |
27 | #include <linux/kernel.h> /* ARRAY_SIZE */ | |
94a79942 LF |
28 | #include <linux/module.h> |
29 | #include <linux/interrupt.h> | |
94a79942 | 30 | #include <linux/jiffies.h> |
94a79942 LF |
31 | #include <linux/timer.h> |
32 | #include <linux/sched.h> | |
93916157 | 33 | #include <linux/semaphore.h> |
94a79942 LF |
34 | |
35 | #include <linux/delay.h> | |
36 | #include <linux/wireless.h> | |
37 | ||
ea74fedc | 38 | #include "rtllib_debug.h" |
94a79942 LF |
39 | #include "rtl819x_HT.h" |
40 | #include "rtl819x_BA.h" | |
41 | #include "rtl819x_TS.h" | |
42 | ||
43 | #include <linux/netdevice.h> | |
44 | #include <linux/if_arp.h> /* ARPHRD_ETHER */ | |
184f1938 | 45 | #include <net/lib80211.h> |
94a79942 | 46 | |
2eed3dee LF |
47 | #define MAX_PRECMD_CNT 16 |
48 | #define MAX_RFDEPENDCMD_CNT 16 | |
49 | #define MAX_POSTCMD_CNT 16 | |
50 | ||
94a79942 LF |
51 | #ifndef WIRELESS_SPY |
52 | #define WIRELESS_SPY | |
53 | #endif | |
54 | #include <net/iw_handler.h> | |
55 | ||
94a79942 LF |
56 | #ifndef IW_MODE_MONITOR |
57 | #define IW_MODE_MONITOR 6 | |
58 | #endif | |
59 | ||
60 | #ifndef IWEVCUSTOM | |
61 | #define IWEVCUSTOM 0x8c02 | |
62 | #endif | |
63 | ||
64 | #ifndef IW_CUSTOM_MAX | |
65 | /* Max number of char in custom event - use multiple of them if needed */ | |
66 | #define IW_CUSTOM_MAX 256 /* In bytes */ | |
67 | #endif | |
68 | ||
94a79942 LF |
69 | #ifndef container_of |
70 | /** | |
71 | * container_of - cast a member of a structure out to the containing structure | |
72 | * | |
8567829a | 73 | * @ptr: the pointer to the member. |
94a79942 LF |
74 | * @type: the type of the container struct this is embedded in. |
75 | * @member: the name of the member within the struct. | |
76 | * | |
77 | */ | |
8567829a LF |
78 | #define container_of(ptr, type, member) ({ \ |
79 | const typeof(((type *)0)->member)*__mptr = (ptr); \ | |
80 | (type *)((char *)__mptr - offsetof(type, member)); }) | |
94a79942 LF |
81 | #endif |
82 | ||
94a79942 | 83 | #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb) |
94a79942 | 84 | |
cb762154 | 85 | #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x) |
94a79942 | 86 | |
94a79942 | 87 | |
8567829a LF |
88 | #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z) |
89 | #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y) | |
94a79942 | 90 | |
8567829a LF |
91 | #define queue_work_rsl(x, y) queue_work(x, y) |
92 | #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y) | |
94a79942 | 93 | |
8567829a LF |
94 | #define container_of_work_rsl(x, y, z) container_of(x, y, z) |
95 | #define container_of_dwork_rsl(x, y, z) \ | |
96 | container_of(container_of(x, struct delayed_work, work), y, z) | |
94a79942 | 97 | |
8567829a LF |
98 | #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \ |
99 | iwe_stream_add_event(info, start, stop, iwe, len) | |
94a79942 | 100 | |
8567829a LF |
101 | #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \ |
102 | iwe_stream_add_point(info, start, stop, iwe, p) | |
94a79942 | 103 | |
8567829a LF |
104 | #define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y) |
105 | #define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y) | |
94a79942 LF |
106 | |
107 | static inline void *netdev_priv_rsl(struct net_device *dev) | |
108 | { | |
94a79942 | 109 | return netdev_priv(dev); |
94a79942 LF |
110 | } |
111 | ||
112 | #define KEY_TYPE_NA 0x0 | |
113 | #define KEY_TYPE_WEP40 0x1 | |
114 | #define KEY_TYPE_TKIP 0x2 | |
115 | #define KEY_TYPE_CCMP 0x4 | |
116 | #define KEY_TYPE_WEP104 0x5 | |
117 | /* added for rtl819x tx procedure */ | |
118 | #define MAX_QUEUE_SIZE 0x10 | |
119 | ||
8567829a LF |
120 | #define BK_QUEUE 0 |
121 | #define BE_QUEUE 1 | |
122 | #define VI_QUEUE 2 | |
123 | #define VO_QUEUE 3 | |
124 | #define HCCA_QUEUE 4 | |
125 | #define TXCMD_QUEUE 5 | |
126 | #define MGNT_QUEUE 6 | |
127 | #define HIGH_QUEUE 7 | |
128 | #define BEACON_QUEUE 8 | |
94a79942 | 129 | |
8567829a LF |
130 | #define LOW_QUEUE BE_QUEUE |
131 | #define NORMAL_QUEUE MGNT_QUEUE | |
94a79942 LF |
132 | |
133 | #ifndef IW_MODE_MESH | |
134 | #define IW_MODE_MESH 7 | |
135 | #endif | |
136 | #define AMSDU_SUBHEADER_LEN 14 | |
137 | #define SWRF_TIMEOUT 50 | |
138 | ||
139 | #define IE_CISCO_FLAG_POSITION 0x08 | |
140 | #define SUPPORT_CKIP_MIC 0x08 | |
141 | #define SUPPORT_CKIP_PK 0x10 | |
142 | #define RT_RF_OFF_LEVL_ASPM BIT0 | |
143 | #define RT_RF_OFF_LEVL_CLK_REQ BIT1 | |
144 | #define RT_RF_OFF_LEVL_PCI_D3 BIT2 | |
145 | #define RT_RF_OFF_LEVL_HALT_NIC BIT3 | |
146 | #define RT_RF_OFF_LEVL_FREE_FW BIT4 | |
147 | #define RT_RF_OFF_LEVL_FW_32K BIT5 | |
148 | #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6 | |
149 | #define RT_RF_LPS_DISALBE_2R BIT30 | |
150 | #define RT_RF_LPS_LEVEL_ASPM BIT31 | |
8567829a LF |
151 | #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \ |
152 | ((pPSC->CurPsLevel & _PS_FLAG) ? true : false) | |
153 | #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \ | |
154 | (pPSC->CurPsLevel &= (~(_PS_FLAG))) | |
94a79942 LF |
155 | #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG) |
156 | ||
157 | /* defined for skb cb field */ | |
158 | /* At most 28 byte */ | |
3b83db43 | 159 | struct cb_desc { |
94a79942 LF |
160 | /* Tx Desc Related flags (8-9) */ |
161 | u8 bLastIniPkt:1; | |
162 | u8 bCmdOrInit:1; | |
163 | u8 bFirstSeg:1; | |
164 | u8 bLastSeg:1; | |
165 | u8 bEncrypt:1; | |
166 | u8 bTxDisableRateFallBack:1; | |
167 | u8 bTxUseDriverAssingedRate:1; | |
168 | u8 bHwSec:1; | |
169 | ||
170 | u8 nStuckCount; | |
171 | ||
172 | /* Tx Firmware Relaged flags (10-11)*/ | |
173 | u8 bCTSEnable:1; | |
174 | u8 bRTSEnable:1; | |
175 | u8 bUseShortGI:1; | |
176 | u8 bUseShortPreamble:1; | |
177 | u8 bTxEnableFwCalcDur:1; | |
178 | u8 bAMPDUEnable:1; | |
179 | u8 bRTSSTBC:1; | |
180 | u8 RTSSC:1; | |
181 | ||
182 | u8 bRTSBW:1; | |
183 | u8 bPacketBW:1; | |
184 | u8 bRTSUseShortPreamble:1; | |
185 | u8 bRTSUseShortGI:1; | |
186 | u8 bMulticast:1; | |
187 | u8 bBroadcast:1; | |
188 | u8 drv_agg_enable:1; | |
189 | u8 reserved2:1; | |
190 | ||
191 | /* Tx Desc related element(12-19) */ | |
192 | u8 rata_index; | |
193 | u8 queue_index; | |
194 | u16 txbuf_size; | |
195 | u8 RATRIndex; | |
196 | u8 bAMSDU:1; | |
197 | u8 bFromAggrQ:1; | |
198 | u8 reserved6:6; | |
199 | u8 macId; | |
200 | u8 priority; | |
201 | ||
202 | /* Tx firmware related element(20-27) */ | |
203 | u8 data_rate; | |
204 | u8 rts_rate; | |
205 | u8 ampdu_factor; | |
206 | u8 ampdu_density; | |
207 | u8 DrvAggrNum; | |
208 | u8 bdhcp; | |
209 | u16 pkt_size; | |
210 | u8 bIsSpecialDataFrame; | |
211 | ||
212 | u8 bBTTxPacket; | |
213 | u8 bIsBTProbRsp; | |
d3b2c172 | 214 | }; |
94a79942 | 215 | |
2eed3dee LF |
216 | enum sw_chnl_cmd_id { |
217 | CmdID_End, | |
218 | CmdID_SetTxPowerLevel, | |
219 | CmdID_BBRegWrite10, | |
220 | CmdID_WritePortUlong, | |
221 | CmdID_WritePortUshort, | |
222 | CmdID_WritePortUchar, | |
223 | CmdID_RF_WriteReg, | |
224 | }; | |
225 | ||
226 | struct sw_chnl_cmd { | |
227 | enum sw_chnl_cmd_id CmdID; | |
228 | u32 Para1; | |
229 | u32 Para2; | |
230 | u32 msDelay; | |
231 | } __packed; | |
232 | ||
94a79942 | 233 | /*--------------------------Define -------------------------------------------*/ |
8567829a LF |
234 | #define MGN_1M 0x02 |
235 | #define MGN_2M 0x04 | |
236 | #define MGN_5_5M 0x0b | |
237 | #define MGN_11M 0x16 | |
238 | ||
239 | #define MGN_6M 0x0c | |
240 | #define MGN_9M 0x12 | |
241 | #define MGN_12M 0x18 | |
242 | #define MGN_18M 0x24 | |
243 | #define MGN_24M 0x30 | |
244 | #define MGN_36M 0x48 | |
245 | #define MGN_48M 0x60 | |
246 | #define MGN_54M 0x6c | |
247 | ||
248 | #define MGN_MCS0 0x80 | |
249 | #define MGN_MCS1 0x81 | |
250 | #define MGN_MCS2 0x82 | |
251 | #define MGN_MCS3 0x83 | |
252 | #define MGN_MCS4 0x84 | |
253 | #define MGN_MCS5 0x85 | |
254 | #define MGN_MCS6 0x86 | |
255 | #define MGN_MCS7 0x87 | |
256 | #define MGN_MCS8 0x88 | |
257 | #define MGN_MCS9 0x89 | |
258 | #define MGN_MCS10 0x8a | |
259 | #define MGN_MCS11 0x8b | |
260 | #define MGN_MCS12 0x8c | |
261 | #define MGN_MCS13 0x8d | |
262 | #define MGN_MCS14 0x8e | |
263 | #define MGN_MCS15 0x8f | |
94a79942 LF |
264 | #define MGN_MCS0_SG 0x90 |
265 | #define MGN_MCS1_SG 0x91 | |
266 | #define MGN_MCS2_SG 0x92 | |
267 | #define MGN_MCS3_SG 0x93 | |
268 | #define MGN_MCS4_SG 0x94 | |
269 | #define MGN_MCS5_SG 0x95 | |
270 | #define MGN_MCS6_SG 0x96 | |
271 | #define MGN_MCS7_SG 0x97 | |
272 | #define MGN_MCS8_SG 0x98 | |
273 | #define MGN_MCS9_SG 0x99 | |
274 | #define MGN_MCS10_SG 0x9a | |
275 | #define MGN_MCS11_SG 0x9b | |
276 | #define MGN_MCS12_SG 0x9c | |
277 | #define MGN_MCS13_SG 0x9d | |
278 | #define MGN_MCS14_SG 0x9e | |
279 | #define MGN_MCS15_SG 0x9f | |
280 | ||
281 | ||
8567829a | 282 | enum _ReasonCode { |
94a79942 LF |
283 | unspec_reason = 0x1, |
284 | auth_not_valid = 0x2, | |
285 | deauth_lv_ss = 0x3, | |
286 | inactivity = 0x4, | |
287 | ap_overload = 0x5, | |
288 | class2_err = 0x6, | |
289 | class3_err = 0x7, | |
290 | disas_lv_ss = 0x8, | |
291 | asoc_not_auth = 0x9, | |
292 | ||
293 | mic_failure = 0xe, | |
294 | ||
295 | invalid_IE = 0x0d, | |
296 | four_way_tmout = 0x0f, | |
297 | two_way_tmout = 0x10, | |
298 | IE_dismatch = 0x11, | |
299 | invalid_Gcipher = 0x12, | |
300 | invalid_Pcipher = 0x13, | |
301 | invalid_AKMP = 0x14, | |
302 | unsup_RSNIEver = 0x15, | |
303 | invalid_RSNIE = 0x16, | |
8567829a | 304 | auth_802_1x_fail = 0x17, |
94a79942 LF |
305 | ciper_reject = 0x18, |
306 | ||
307 | QoS_unspec = 0x20, | |
308 | QAP_bandwidth = 0x21, | |
309 | poor_condition = 0x22, | |
310 | no_facility = 0x23, | |
311 | req_declined = 0x25, | |
312 | invalid_param = 0x26, | |
8567829a | 313 | req_not_honored = 0x27, |
94a79942 LF |
314 | TS_not_created = 0x2F, |
315 | DL_not_allowed = 0x30, | |
316 | dest_not_exist = 0x31, | |
317 | dest_not_QSTA = 0x32, | |
318 | }; | |
319 | ||
839370c5 | 320 | enum hal_def_variable { |
94a79942 LF |
321 | HAL_DEF_TPC_ENABLE, |
322 | HAL_DEF_INIT_GAIN, | |
323 | HAL_DEF_PROT_IMP_MODE, | |
324 | HAL_DEF_HIGH_POWER_MECHANISM, | |
325 | HAL_DEF_RATE_ADAPTIVE_MECHANISM, | |
326 | HAL_DEF_ANTENNA_DIVERSITY_MECHANISM, | |
327 | HAL_DEF_LED, | |
328 | HAL_DEF_CW_MAX_MIN, | |
329 | ||
330 | HAL_DEF_WOWLAN, | |
331 | HAL_DEF_ENDPOINTS, | |
332 | HAL_DEF_MIN_TX_POWER_DBM, | |
333 | HAL_DEF_MAX_TX_POWER_DBM, | |
334 | HW_DEF_EFUSE_REPG_SECTION1_FLAG, | |
335 | HW_DEF_EFUSE_REPG_DATA, | |
336 | HW_DEF_GPIO, | |
337 | HAL_DEF_PCI_SUPPORT_ASPM, | |
338 | HAL_DEF_THERMAL_VALUE, | |
8567829a | 339 | HAL_DEF_USB_IN_TOKEN_REV, |
839370c5 | 340 | }; |
94a79942 | 341 | |
bb5e4822 | 342 | enum hw_variables { |
94a79942 LF |
343 | HW_VAR_ETHER_ADDR, |
344 | HW_VAR_MULTICAST_REG, | |
345 | HW_VAR_BASIC_RATE, | |
346 | HW_VAR_BSSID, | |
347 | HW_VAR_MEDIA_STATUS, | |
348 | HW_VAR_SECURITY_CONF, | |
349 | HW_VAR_BEACON_INTERVAL, | |
350 | HW_VAR_ATIM_WINDOW, | |
351 | HW_VAR_LISTEN_INTERVAL, | |
352 | HW_VAR_CS_COUNTER, | |
353 | HW_VAR_DEFAULTKEY0, | |
354 | HW_VAR_DEFAULTKEY1, | |
355 | HW_VAR_DEFAULTKEY2, | |
356 | HW_VAR_DEFAULTKEY3, | |
357 | HW_VAR_SIFS, | |
358 | HW_VAR_DIFS, | |
359 | HW_VAR_EIFS, | |
360 | HW_VAR_SLOT_TIME, | |
361 | HW_VAR_ACK_PREAMBLE, | |
362 | HW_VAR_CW_CONFIG, | |
363 | HW_VAR_CW_VALUES, | |
364 | HW_VAR_RATE_FALLBACK_CONTROL, | |
365 | HW_VAR_CONTENTION_WINDOW, | |
366 | HW_VAR_RETRY_COUNT, | |
367 | HW_VAR_TR_SWITCH, | |
368 | HW_VAR_COMMAND, | |
369 | HW_VAR_WPA_CONFIG, | |
370 | HW_VAR_AMPDU_MIN_SPACE, | |
371 | HW_VAR_SHORTGI_DENSITY, | |
372 | HW_VAR_AMPDU_FACTOR, | |
373 | HW_VAR_MCS_RATE_AVAILABLE, | |
374 | HW_VAR_AC_PARAM, | |
375 | HW_VAR_ACM_CTRL, | |
376 | HW_VAR_DIS_Req_Qsize, | |
377 | HW_VAR_CCX_CHNL_LOAD, | |
378 | HW_VAR_CCX_NOISE_HISTOGRAM, | |
379 | HW_VAR_CCX_CLM_NHM, | |
380 | HW_VAR_TxOPLimit, | |
381 | HW_VAR_TURBO_MODE, | |
382 | HW_VAR_RF_STATE, | |
383 | HW_VAR_RF_OFF_BY_HW, | |
384 | HW_VAR_BUS_SPEED, | |
8567829a | 385 | HW_VAR_SET_DEV_POWER, |
94a79942 LF |
386 | |
387 | HW_VAR_RCR, | |
388 | HW_VAR_RATR_0, | |
389 | HW_VAR_RRSR, | |
390 | HW_VAR_CPU_RST, | |
391 | HW_VAR_CECHK_BSSID, | |
8567829a | 392 | HW_VAR_LBK_MODE, |
94a79942 LF |
393 | HW_VAR_AES_11N_FIX, |
394 | HW_VAR_USB_RX_AGGR, | |
395 | HW_VAR_USER_CONTROL_TURBO_MODE, | |
396 | HW_VAR_RETRY_LIMIT, | |
397 | HW_VAR_INIT_TX_RATE, | |
398 | HW_VAR_TX_RATE_REG, | |
399 | HW_VAR_EFUSE_USAGE, | |
400 | HW_VAR_EFUSE_BYTES, | |
401 | HW_VAR_AUTOLOAD_STATUS, | |
402 | HW_VAR_RF_2R_DISABLE, | |
403 | HW_VAR_SET_RPWM, | |
404 | HW_VAR_H2C_FW_PWRMODE, | |
405 | HW_VAR_H2C_FW_JOINBSSRPT, | |
406 | HW_VAR_1X1_RECV_COMBINE, | |
407 | HW_VAR_STOP_SEND_BEACON, | |
408 | HW_VAR_TSF_TIMER, | |
409 | HW_VAR_IO_CMD, | |
410 | ||
411 | HW_VAR_RF_RECOVERY, | |
412 | HW_VAR_H2C_FW_UPDATE_GTK, | |
413 | HW_VAR_WF_MASK, | |
414 | HW_VAR_WF_CRC, | |
415 | HW_VAR_WF_IS_MAC_ADDR, | |
416 | HW_VAR_H2C_FW_OFFLOAD, | |
417 | HW_VAR_RESET_WFCRC, | |
418 | ||
419 | HW_VAR_HANDLE_FW_C2H, | |
420 | HW_VAR_DL_FW_RSVD_PAGE, | |
421 | HW_VAR_AID, | |
422 | HW_VAR_HW_SEQ_ENABLE, | |
423 | HW_VAR_CORRECT_TSF, | |
424 | HW_VAR_BCN_VALID, | |
425 | HW_VAR_FWLPS_RF_ON, | |
426 | HW_VAR_DUAL_TSF_RST, | |
427 | HW_VAR_SWITCH_EPHY_WoWLAN, | |
428 | HW_VAR_INT_MIGRATION, | |
429 | HW_VAR_INT_AC, | |
8567829a | 430 | HW_VAR_RF_TIMING, |
bb5e4822 | 431 | }; |
94a79942 | 432 | |
e93e0f6a | 433 | enum rt_op_mode { |
94a79942 LF |
434 | RT_OP_MODE_AP, |
435 | RT_OP_MODE_INFRASTRUCTURE, | |
436 | RT_OP_MODE_IBSS, | |
437 | RT_OP_MODE_NO_LINK, | |
e93e0f6a | 438 | }; |
94a79942 LF |
439 | |
440 | ||
8567829a LF |
441 | #define aSifsTime \ |
442 | (((priv->rtllib->current_network.mode == IEEE_A) \ | |
443 | || (priv->rtllib->current_network.mode == IEEE_N_24G) \ | |
444 | || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10) | |
94a79942 LF |
445 | |
446 | #define MGMT_QUEUE_NUM 5 | |
447 | ||
448 | #define IEEE_CMD_SET_WPA_PARAM 1 | |
449 | #define IEEE_CMD_SET_WPA_IE 2 | |
450 | #define IEEE_CMD_SET_ENCRYPTION 3 | |
451 | #define IEEE_CMD_MLME 4 | |
452 | ||
453 | #define IEEE_PARAM_WPA_ENABLED 1 | |
454 | #define IEEE_PARAM_TKIP_COUNTERMEASURES 2 | |
455 | #define IEEE_PARAM_DROP_UNENCRYPTED 3 | |
456 | #define IEEE_PARAM_PRIVACY_INVOKED 4 | |
457 | #define IEEE_PARAM_AUTH_ALGS 5 | |
458 | #define IEEE_PARAM_IEEE_802_1X 6 | |
459 | #define IEEE_PARAM_WPAX_SELECT 7 | |
460 | #define IEEE_PROTO_WPA 1 | |
461 | #define IEEE_PROTO_RSN 2 | |
462 | #define IEEE_WPAX_USEGROUP 0 | |
463 | #define IEEE_WPAX_WEP40 1 | |
464 | #define IEEE_WPAX_TKIP 2 | |
465 | #define IEEE_WPAX_WRAP 3 | |
466 | #define IEEE_WPAX_CCMP 4 | |
467 | #define IEEE_WPAX_WEP104 5 | |
468 | ||
469 | #define IEEE_KEY_MGMT_IEEE8021X 1 | |
470 | #define IEEE_KEY_MGMT_PSK 2 | |
471 | ||
472 | #define IEEE_MLME_STA_DEAUTH 1 | |
473 | #define IEEE_MLME_STA_DISASSOC 2 | |
474 | ||
475 | ||
476 | #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 | |
477 | #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 | |
478 | #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 | |
479 | #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 | |
480 | #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 | |
481 | #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 | |
482 | #define IEEE_CRYPT_ALG_NAME_LEN 16 | |
483 | ||
484 | #define MAX_IE_LEN 0xff | |
8567829a LF |
485 | #define RT_ASSERT_RET(_Exp) do {} while (0) |
486 | #define RT_ASSERT_RET_VALUE(_Exp, Ret) \ | |
487 | do {} while (0) | |
94a79942 | 488 | |
65dab9a0 | 489 | struct ieee_param { |
94a79942 LF |
490 | u32 cmd; |
491 | u8 sta_addr[ETH_ALEN]; | |
8567829a | 492 | union { |
94a79942 LF |
493 | struct { |
494 | u8 name; | |
495 | u32 value; | |
496 | } wpa_param; | |
497 | struct { | |
498 | u32 len; | |
499 | u8 reserved[32]; | |
500 | u8 data[0]; | |
501 | } wpa_ie; | |
8567829a | 502 | struct { |
94a79942 LF |
503 | int command; |
504 | int reason_code; | |
505 | } mlme; | |
506 | struct { | |
507 | u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; | |
508 | u8 set_tx; | |
509 | u32 err; | |
510 | u8 idx; | |
511 | u8 seq[8]; /* sequence counter (set: RX, get: TX) */ | |
512 | u16 key_len; | |
513 | u8 key[0]; | |
514 | } crypt; | |
515 | } u; | |
d3b2c172 | 516 | }; |
94a79942 LF |
517 | |
518 | ||
519 | #if WIRELESS_EXT < 17 | |
520 | #define IW_QUAL_QUAL_INVALID 0x10 | |
521 | #define IW_QUAL_LEVEL_INVALID 0x20 | |
522 | #define IW_QUAL_NOISE_INVALID 0x40 | |
523 | #define IW_QUAL_QUAL_UPDATED 0x1 | |
524 | #define IW_QUAL_LEVEL_UPDATED 0x2 | |
525 | #define IW_QUAL_NOISE_UPDATED 0x4 | |
526 | #endif | |
527 | ||
94a79942 LF |
528 | #define MSECS(t) msecs_to_jiffies(t) |
529 | #define msleep_interruptible_rsl msleep_interruptible | |
94a79942 LF |
530 | |
531 | #define RTLLIB_DATA_LEN 2304 | |
532 | /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section | |
533 | 6.2.1.1.2. | |
534 | ||
535 | The figure in section 7.1.2 suggests a body size of up to 2312 | |
536 | bytes is allowed, which is a bit confusing, I suspect this | |
537 | represents the 2304 bytes of real data, plus a possible 8 bytes of | |
538 | WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ | |
539 | #define RTLLIB_1ADDR_LEN 10 | |
540 | #define RTLLIB_2ADDR_LEN 16 | |
541 | #define RTLLIB_3ADDR_LEN 24 | |
542 | #define RTLLIB_4ADDR_LEN 30 | |
543 | #define RTLLIB_FCS_LEN 4 | |
8567829a LF |
544 | #define RTLLIB_HLEN (RTLLIB_4ADDR_LEN) |
545 | #define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN) | |
94a79942 LF |
546 | #define RTLLIB_MGMT_HDR_LEN 24 |
547 | #define RTLLIB_DATA_HDR3_LEN 24 | |
548 | #define RTLLIB_DATA_HDR4_LEN 30 | |
549 | ||
550 | #define RTLLIB_SKBBUFFER_SIZE 2500 | |
551 | ||
552 | #define MIN_FRAG_THRESHOLD 256U | |
553 | #define MAX_FRAG_THRESHOLD 2346U | |
554 | #define MAX_HT_DATA_FRAG_THRESHOLD 0x2000 | |
555 | ||
556 | #define HT_AMSDU_SIZE_4K 3839 | |
557 | #define HT_AMSDU_SIZE_8K 7935 | |
558 | ||
559 | /* Frame control field constants */ | |
560 | #define RTLLIB_FCTL_VERS 0x0003 | |
561 | #define RTLLIB_FCTL_FTYPE 0x000c | |
562 | #define RTLLIB_FCTL_STYPE 0x00f0 | |
563 | #define RTLLIB_FCTL_FRAMETYPE 0x00fc | |
564 | #define RTLLIB_FCTL_TODS 0x0100 | |
565 | #define RTLLIB_FCTL_FROMDS 0x0200 | |
566 | #define RTLLIB_FCTL_DSTODS 0x0300 | |
567 | #define RTLLIB_FCTL_MOREFRAGS 0x0400 | |
568 | #define RTLLIB_FCTL_RETRY 0x0800 | |
569 | #define RTLLIB_FCTL_PM 0x1000 | |
570 | #define RTLLIB_FCTL_MOREDATA 0x2000 | |
571 | #define RTLLIB_FCTL_WEP 0x4000 | |
572 | #define RTLLIB_FCTL_ORDER 0x8000 | |
573 | ||
574 | #define RTLLIB_FTYPE_MGMT 0x0000 | |
575 | #define RTLLIB_FTYPE_CTL 0x0004 | |
576 | #define RTLLIB_FTYPE_DATA 0x0008 | |
577 | ||
578 | /* management */ | |
579 | #define RTLLIB_STYPE_ASSOC_REQ 0x0000 | |
580 | #define RTLLIB_STYPE_ASSOC_RESP 0x0010 | |
581 | #define RTLLIB_STYPE_REASSOC_REQ 0x0020 | |
582 | #define RTLLIB_STYPE_REASSOC_RESP 0x0030 | |
583 | #define RTLLIB_STYPE_PROBE_REQ 0x0040 | |
584 | #define RTLLIB_STYPE_PROBE_RESP 0x0050 | |
585 | #define RTLLIB_STYPE_BEACON 0x0080 | |
586 | #define RTLLIB_STYPE_ATIM 0x0090 | |
587 | #define RTLLIB_STYPE_DISASSOC 0x00A0 | |
588 | #define RTLLIB_STYPE_AUTH 0x00B0 | |
589 | #define RTLLIB_STYPE_DEAUTH 0x00C0 | |
590 | #define RTLLIB_STYPE_MANAGE_ACT 0x00D0 | |
591 | ||
592 | /* control */ | |
593 | #define RTLLIB_STYPE_PSPOLL 0x00A0 | |
594 | #define RTLLIB_STYPE_RTS 0x00B0 | |
595 | #define RTLLIB_STYPE_CTS 0x00C0 | |
596 | #define RTLLIB_STYPE_ACK 0x00D0 | |
597 | #define RTLLIB_STYPE_CFEND 0x00E0 | |
598 | #define RTLLIB_STYPE_CFENDACK 0x00F0 | |
599 | #define RTLLIB_STYPE_BLOCKACK 0x0094 | |
600 | ||
601 | /* data */ | |
602 | #define RTLLIB_STYPE_DATA 0x0000 | |
603 | #define RTLLIB_STYPE_DATA_CFACK 0x0010 | |
604 | #define RTLLIB_STYPE_DATA_CFPOLL 0x0020 | |
605 | #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030 | |
606 | #define RTLLIB_STYPE_NULLFUNC 0x0040 | |
607 | #define RTLLIB_STYPE_CFACK 0x0050 | |
608 | #define RTLLIB_STYPE_CFPOLL 0x0060 | |
609 | #define RTLLIB_STYPE_CFACKPOLL 0x0070 | |
610 | #define RTLLIB_STYPE_QOS_DATA 0x0080 | |
611 | #define RTLLIB_STYPE_QOS_NULL 0x00C0 | |
612 | ||
613 | #define RTLLIB_SCTL_FRAG 0x000F | |
614 | #define RTLLIB_SCTL_SEQ 0xFFF0 | |
615 | ||
616 | /* QOS control */ | |
8567829a | 617 | #define RTLLIB_QCTL_TID 0x000F |
94a79942 LF |
618 | |
619 | #define FC_QOS_BIT BIT7 | |
8567829a LF |
620 | #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) |
621 | #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT))) | |
622 | #define IsQoSDataFrame(pframe) \ | |
623 | ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \ | |
624 | (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) | |
625 | #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER) | |
626 | #define SN_LESS(a, b) (((a-b)&0x800) != 0) | |
94a79942 LF |
627 | #define SN_EQUAL(a, b) (a == b) |
628 | #define MAX_DEV_ADDR_SIZE 8 | |
629 | ||
09ced23d | 630 | enum act_category { |
8567829a LF |
631 | ACT_CAT_QOS = 1, |
632 | ACT_CAT_DLS = 2, | |
633 | ACT_CAT_BA = 3, | |
634 | ACT_CAT_HT = 7, | |
635 | ACT_CAT_WMM = 17, | |
09ced23d | 636 | }; |
94a79942 | 637 | |
5a604053 | 638 | enum ts_action { |
8567829a LF |
639 | ACT_ADDTSREQ = 0, |
640 | ACT_ADDTSRSP = 1, | |
641 | ACT_DELTS = 2, | |
642 | ACT_SCHEDULE = 3, | |
5a604053 | 643 | }; |
94a79942 | 644 | |
07276bac | 645 | enum ba_action { |
8567829a LF |
646 | ACT_ADDBAREQ = 0, |
647 | ACT_ADDBARSP = 1, | |
648 | ACT_DELBA = 2, | |
07276bac | 649 | }; |
94a79942 | 650 | |
062de0a9 | 651 | enum init_gain_op_type { |
8567829a | 652 | IG_Backup = 0, |
94a79942 LF |
653 | IG_Restore, |
654 | IG_Max | |
062de0a9 | 655 | }; |
d3b2c172 | 656 | |
4fd7cedc | 657 | enum led_ctl_mode { |
8567829a LF |
658 | LED_CTL_POWER_ON = 1, |
659 | LED_CTL_LINK = 2, | |
660 | LED_CTL_NO_LINK = 3, | |
661 | LED_CTL_TX = 4, | |
662 | LED_CTL_RX = 5, | |
663 | LED_CTL_SITE_SURVEY = 6, | |
664 | LED_CTL_POWER_OFF = 7, | |
665 | LED_CTL_START_TO_LINK = 8, | |
666 | LED_CTL_START_WPS = 9, | |
667 | LED_CTL_STOP_WPS = 10, | |
668 | LED_CTL_START_WPS_BOTTON = 11, | |
669 | LED_CTL_STOP_WPS_FAIL = 12, | |
94a79942 | 670 | LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, |
4fd7cedc | 671 | }; |
94a79942 | 672 | |
e6080633 | 673 | enum rt_rf_type_def { |
94a79942 LF |
674 | RF_1T2R = 0, |
675 | RF_2T4R, | |
676 | RF_2T2R, | |
677 | RF_1T1R, | |
678 | RF_2T2R_GREEN, | |
679 | RF_819X_MAX_TYPE | |
e6080633 | 680 | }; |
94a79942 | 681 | |
dc20a326 | 682 | enum wireless_mode { |
94a79942 LF |
683 | WIRELESS_MODE_UNKNOWN = 0x00, |
684 | WIRELESS_MODE_A = 0x01, | |
685 | WIRELESS_MODE_B = 0x02, | |
686 | WIRELESS_MODE_G = 0x04, | |
687 | WIRELESS_MODE_AUTO = 0x08, | |
688 | WIRELESS_MODE_N_24G = 0x10, | |
689 | WIRELESS_MODE_N_5G = 0x20 | |
dc20a326 | 690 | }; |
94a79942 | 691 | |
80f839d4 | 692 | enum wireless_network_type { |
94a79942 LF |
693 | WIRELESS_11B = 1, |
694 | WIRELESS_11G = 2, | |
695 | WIRELESS_11A = 4, | |
696 | WIRELESS_11N = 8 | |
80f839d4 | 697 | }; |
94a79942 LF |
698 | |
699 | #define OUI_SUBTYPE_WMM_INFO 0 | |
700 | #define OUI_SUBTYPE_WMM_PARAM 1 | |
701 | #define OUI_SUBTYPE_QOS_CAPABI 5 | |
702 | ||
703 | /* debug macros */ | |
94a79942 LF |
704 | extern u32 rtllib_debug_level; |
705 | #define RTLLIB_DEBUG(level, fmt, args...) \ | |
8567829a LF |
706 | do { \ |
707 | if (rtllib_debug_level & (level)) \ | |
708 | printk(KERN_DEBUG "rtllib: " fmt, ## args); \ | |
709 | } while (0) | |
710 | ||
94a79942 | 711 | #define RTLLIB_DEBUG_DATA(level, data, datalen) \ |
8567829a LF |
712 | do { \ |
713 | if ((rtllib_debug_level & (level)) == (level)) { \ | |
94a79942 | 714 | int i; \ |
8567829a | 715 | u8 *pdata = (u8 *)data; \ |
94a79942 | 716 | printk(KERN_DEBUG "rtllib: %s()\n", __func__); \ |
8567829a | 717 | for (i = 0; i < (int)(datalen); i++) { \ |
94a79942 | 718 | printk("%2.2x ", pdata[i]); \ |
8567829a LF |
719 | if ((i+1)%16 == 0) \ |
720 | printk("\n"); \ | |
94a79942 LF |
721 | } \ |
722 | printk("\n"); \ | |
723 | } \ | |
724 | } while (0) | |
94a79942 | 725 | |
94a79942 LF |
726 | /* |
727 | * To use the debug system; | |
728 | * | |
729 | * If you are defining a new debug classification, simply add it to the #define | |
730 | * list here in the form of: | |
731 | * | |
732 | * #define RTLLIB_DL_xxxx VALUE | |
733 | * | |
734 | * shifting value to the left one bit from the previous entry. xxxx should be | |
735 | * the name of the classification (for example, WEP) | |
736 | * | |
737 | * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your | |
738 | * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want | |
739 | * to send output to that classification. | |
740 | * | |
741 | * To add your debug level to the list of levels seen when you perform | |
742 | * | |
743 | * % cat /proc/net/ipw/debug_level | |
744 | * | |
745 | * you simply need to add your entry to the ipw_debug_levels array. | |
746 | * | |
94a79942 LF |
747 | * |
748 | */ | |
749 | ||
8567829a LF |
750 | #define RTLLIB_DL_INFO (1<<0) |
751 | #define RTLLIB_DL_WX (1<<1) | |
752 | #define RTLLIB_DL_SCAN (1<<2) | |
753 | #define RTLLIB_DL_STATE (1<<3) | |
754 | #define RTLLIB_DL_MGMT (1<<4) | |
755 | #define RTLLIB_DL_FRAG (1<<5) | |
756 | #define RTLLIB_DL_EAP (1<<6) | |
757 | #define RTLLIB_DL_DROP (1<<7) | |
94a79942 | 758 | |
8567829a LF |
759 | #define RTLLIB_DL_TX (1<<8) |
760 | #define RTLLIB_DL_RX (1<<9) | |
94a79942 LF |
761 | |
762 | #define RTLLIB_DL_HT (1<<10) | |
763 | #define RTLLIB_DL_BA (1<<11) | |
764 | #define RTLLIB_DL_TS (1<<12) | |
8567829a | 765 | #define RTLLIB_DL_QOS (1<<13) |
94a79942 LF |
766 | #define RTLLIB_DL_REORDER (1<<14) |
767 | #define RTLLIB_DL_IOT (1<<15) | |
768 | #define RTLLIB_DL_IPS (1<<16) | |
769 | #define RTLLIB_DL_TRACE (1<<29) | |
770 | #define RTLLIB_DL_DATA (1<<30) | |
771 | #define RTLLIB_DL_ERR (1<<31) | |
772 | #define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a) | |
773 | #define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a) | |
774 | #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a) | |
775 | ||
776 | #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a) | |
777 | #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a) | |
778 | #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a) | |
779 | #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a) | |
780 | #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a) | |
781 | #define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a) | |
782 | #define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a) | |
783 | #define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a) | |
784 | #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a) | |
785 | #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a) | |
786 | ||
94a79942 LF |
787 | /* Added by Annie, 2005-11-22. */ |
788 | #define MAX_STR_LEN 64 | |
8567829a LF |
789 | /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */ |
790 | #define PRINTABLE(_ch) (_ch > '!' && _ch < '~') | |
791 | #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ | |
792 | if ((_Comp) & level) { \ | |
793 | int __i; \ | |
794 | u8 struct buffer[MAX_STR_LEN]; \ | |
795 | int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\ | |
796 | memset(struct buffer, 0, MAX_STR_LEN); \ | |
797 | memcpy(struct buffer, (u8 *)_Ptr, length); \ | |
798 | for (__i = 0; __i < MAX_STR_LEN; __i++) { \ | |
799 | if (!PRINTABLE(struct buffer[__i])) \ | |
800 | struct buffer[__i] = '?'; \ | |
801 | } \ | |
802 | struct buffer[length] = '\0'; \ | |
803 | printk(KERN_INFO "Rtl819x: "); \ | |
804 | printk(_TitleString); \ | |
805 | printk(": %d, <%s>\n", _Len, struct buffer); \ | |
806 | } | |
94a79942 LF |
807 | #ifndef ETH_P_PAE |
808 | #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ | |
809 | #define ETH_P_IP 0x0800 /* Internet Protocol packet */ | |
810 | #define ETH_P_ARP 0x0806 /* Address Resolution packet */ | |
811 | #endif /* ETH_P_PAE */ | |
812 | ||
813 | #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ | |
814 | ||
815 | #ifndef ETH_P_80211_RAW | |
816 | #define ETH_P_80211_RAW (ETH_P_ECONET + 1) | |
817 | #endif | |
818 | ||
819 | /* IEEE 802.11 defines */ | |
820 | ||
821 | #define P80211_OUI_LEN 3 | |
822 | ||
823 | struct rtllib_snap_hdr { | |
824 | ||
8567829a LF |
825 | u8 dsap; /* always 0xAA */ |
826 | u8 ssap; /* always 0xAA */ | |
827 | u8 ctrl; /* always 0x03 */ | |
828 | u8 oui[P80211_OUI_LEN]; /* organizational universal id */ | |
94a79942 | 829 | |
8567829a | 830 | } __packed; |
94a79942 | 831 | |
8567829a | 832 | enum _REG_PREAMBLE_MODE { |
94a79942 LF |
833 | PREAMBLE_LONG = 1, |
834 | PREAMBLE_AUTO = 2, | |
8567829a | 835 | PREAMBLE_SHORT = 3, |
94a79942 LF |
836 | }; |
837 | ||
838 | #define SNAP_SIZE sizeof(struct rtllib_snap_hdr) | |
839 | ||
840 | #define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS) | |
841 | #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE) | |
842 | #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE) | |
843 | #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA) | |
844 | ||
845 | #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE) | |
846 | #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG) | |
847 | #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4) | |
848 | ||
94a79942 LF |
849 | /* Authentication algorithms */ |
850 | #define WLAN_AUTH_OPEN 0 | |
851 | #define WLAN_AUTH_SHARED_KEY 1 | |
852 | #define WLAN_AUTH_LEAP 128 | |
853 | ||
854 | #define WLAN_AUTH_CHALLENGE_LEN 128 | |
855 | ||
856 | #define WLAN_CAPABILITY_ESS (1<<0) | |
857 | #define WLAN_CAPABILITY_IBSS (1<<1) | |
858 | #define WLAN_CAPABILITY_CF_POLLABLE (1<<2) | |
859 | #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) | |
860 | #define WLAN_CAPABILITY_PRIVACY (1<<4) | |
861 | #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) | |
862 | #define WLAN_CAPABILITY_PBCC (1<<6) | |
863 | #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) | |
864 | #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) | |
865 | #define WLAN_CAPABILITY_QOS (1<<9) | |
866 | #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) | |
867 | #define WLAN_CAPABILITY_DSSS_OFDM (1<<13) | |
868 | ||
869 | /* 802.11g ERP information element */ | |
870 | #define WLAN_ERP_NON_ERP_PRESENT (1<<0) | |
871 | #define WLAN_ERP_USE_PROTECTION (1<<1) | |
872 | #define WLAN_ERP_BARKER_PREAMBLE (1<<2) | |
873 | ||
94a79942 LF |
874 | #define RTLLIB_STATMASK_SIGNAL (1<<0) |
875 | #define RTLLIB_STATMASK_RSSI (1<<1) | |
876 | #define RTLLIB_STATMASK_NOISE (1<<2) | |
877 | #define RTLLIB_STATMASK_RATE (1<<3) | |
878 | #define RTLLIB_STATMASK_WEMASK 0x7 | |
879 | ||
880 | #define RTLLIB_CCK_MODULATION (1<<0) | |
881 | #define RTLLIB_OFDM_MODULATION (1<<1) | |
882 | ||
883 | #define RTLLIB_24GHZ_BAND (1<<0) | |
884 | #define RTLLIB_52GHZ_BAND (1<<1) | |
885 | ||
886 | #define RTLLIB_CCK_RATE_LEN 4 | |
8567829a LF |
887 | #define RTLLIB_CCK_RATE_1MB 0x02 |
888 | #define RTLLIB_CCK_RATE_2MB 0x04 | |
889 | #define RTLLIB_CCK_RATE_5MB 0x0B | |
890 | #define RTLLIB_CCK_RATE_11MB 0x16 | |
94a79942 | 891 | #define RTLLIB_OFDM_RATE_LEN 8 |
8567829a LF |
892 | #define RTLLIB_OFDM_RATE_6MB 0x0C |
893 | #define RTLLIB_OFDM_RATE_9MB 0x12 | |
94a79942 LF |
894 | #define RTLLIB_OFDM_RATE_12MB 0x18 |
895 | #define RTLLIB_OFDM_RATE_18MB 0x24 | |
896 | #define RTLLIB_OFDM_RATE_24MB 0x30 | |
897 | #define RTLLIB_OFDM_RATE_36MB 0x48 | |
898 | #define RTLLIB_OFDM_RATE_48MB 0x60 | |
899 | #define RTLLIB_OFDM_RATE_54MB 0x6C | |
900 | #define RTLLIB_BASIC_RATE_MASK 0x80 | |
901 | ||
902 | #define RTLLIB_CCK_RATE_1MB_MASK (1<<0) | |
903 | #define RTLLIB_CCK_RATE_2MB_MASK (1<<1) | |
904 | #define RTLLIB_CCK_RATE_5MB_MASK (1<<2) | |
905 | #define RTLLIB_CCK_RATE_11MB_MASK (1<<3) | |
906 | #define RTLLIB_OFDM_RATE_6MB_MASK (1<<4) | |
907 | #define RTLLIB_OFDM_RATE_9MB_MASK (1<<5) | |
908 | #define RTLLIB_OFDM_RATE_12MB_MASK (1<<6) | |
909 | #define RTLLIB_OFDM_RATE_18MB_MASK (1<<7) | |
910 | #define RTLLIB_OFDM_RATE_24MB_MASK (1<<8) | |
911 | #define RTLLIB_OFDM_RATE_36MB_MASK (1<<9) | |
912 | #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10) | |
913 | #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11) | |
914 | ||
8567829a | 915 | #define RTLLIB_CCK_RATES_MASK 0x0000000F |
94a79942 LF |
916 | #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \ |
917 | RTLLIB_CCK_RATE_2MB_MASK) | |
918 | #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \ | |
8567829a LF |
919 | RTLLIB_CCK_RATE_5MB_MASK | \ |
920 | RTLLIB_CCK_RATE_11MB_MASK) | |
94a79942 LF |
921 | |
922 | #define RTLLIB_OFDM_RATES_MASK 0x00000FF0 | |
923 | #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \ | |
924 | RTLLIB_OFDM_RATE_12MB_MASK | \ | |
925 | RTLLIB_OFDM_RATE_24MB_MASK) | |
926 | #define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \ | |
927 | RTLLIB_OFDM_RATE_9MB_MASK | \ | |
928 | RTLLIB_OFDM_RATE_18MB_MASK | \ | |
929 | RTLLIB_OFDM_RATE_36MB_MASK | \ | |
930 | RTLLIB_OFDM_RATE_48MB_MASK | \ | |
931 | RTLLIB_OFDM_RATE_54MB_MASK) | |
932 | #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \ | |
8567829a | 933 | RTLLIB_CCK_DEFAULT_RATES_MASK) |
94a79942 LF |
934 | |
935 | #define RTLLIB_NUM_OFDM_RATES 8 | |
8567829a LF |
936 | #define RTLLIB_NUM_CCK_RATES 4 |
937 | #define RTLLIB_OFDM_SHIFT_MASK_A 4 | |
94a79942 LF |
938 | |
939 | ||
940 | /* this is stolen and modified from the madwifi driver*/ | |
941 | #define RTLLIB_FC0_TYPE_MASK 0x0c | |
942 | #define RTLLIB_FC0_TYPE_DATA 0x08 | |
943 | #define RTLLIB_FC0_SUBTYPE_MASK 0xB0 | |
944 | #define RTLLIB_FC0_SUBTYPE_QOS 0x80 | |
945 | ||
946 | #define RTLLIB_QOS_HAS_SEQ(fc) \ | |
947 | (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \ | |
948 | (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS)) | |
949 | ||
950 | /* this is stolen from ipw2200 driver */ | |
951 | #define IEEE_IBSS_MAC_HASH_SIZE 31 | |
952 | struct ieee_ibss_seq { | |
953 | u8 mac[ETH_ALEN]; | |
954 | u16 seq_num[17]; | |
955 | u16 frag_num[17]; | |
956 | unsigned long packet_time[17]; | |
957 | struct list_head list; | |
958 | }; | |
959 | ||
960 | /* NOTE: This data is for statistical purposes; not all hardware provides this | |
961 | * information for frames received. Not setting these will not cause | |
962 | * any adverse affects. */ | |
963 | struct rtllib_rx_stats { | |
0dd56506 | 964 | u64 mac_time; |
94a79942 LF |
965 | s8 rssi; |
966 | u8 signal; | |
967 | u8 noise; | |
968 | u16 rate; /* in 100 kbps */ | |
969 | u8 received_channel; | |
970 | u8 control; | |
971 | u8 mask; | |
972 | u8 freq; | |
973 | u16 len; | |
974 | u64 tsf; | |
975 | u32 beacon_time; | |
976 | u8 nic_type; | |
977 | u16 Length; | |
978 | u8 SignalQuality; | |
979 | s32 RecvSignalPower; | |
980 | s8 RxPower; | |
981 | u8 SignalStrength; | |
982 | u16 bHwError:1; | |
983 | u16 bCRC:1; | |
984 | u16 bICV:1; | |
985 | u16 bShortPreamble:1; | |
986 | u16 Antenna:1; | |
987 | u16 Decrypted:1; | |
988 | u16 Wakeup:1; | |
989 | u16 Reserved0:1; | |
990 | u8 AGC; | |
991 | u32 TimeStampLow; | |
992 | u32 TimeStampHigh; | |
993 | bool bShift; | |
994 | bool bIsQosData; | |
995 | u8 UserPriority; | |
996 | ||
997 | u8 RxDrvInfoSize; | |
998 | u8 RxBufShift; | |
999 | bool bIsAMPDU; | |
1000 | bool bFirstMPDU; | |
1001 | bool bContainHTC; | |
1002 | bool RxIs40MHzPacket; | |
1003 | u32 RxPWDBAll; | |
1004 | u8 RxMIMOSignalStrength[4]; | |
1005 | s8 RxMIMOSignalQuality[2]; | |
1006 | bool bPacketMatchBSSID; | |
1007 | bool bIsCCK; | |
1008 | bool bPacketToSelf; | |
8567829a | 1009 | u8 *virtual_address; |
94a79942 LF |
1010 | u16 packetlength; |
1011 | u16 fraglength; | |
1012 | u16 fragoffset; | |
1013 | u16 ntotalfrag; | |
1014 | bool bisrxaggrsubframe; | |
1015 | bool bPacketBeacon; | |
1016 | bool bToSelfBA; | |
1017 | char cck_adc_pwdb[4]; | |
1018 | u16 Seq_Num; | |
1019 | u8 nTotalAggPkt; | |
94a79942 LF |
1020 | }; |
1021 | ||
1022 | /* IEEE 802.11 requires that STA supports concurrent reception of at least | |
1023 | * three fragmented frames. This define can be increased to support more | |
1024 | * concurrent frames, but it should be noted that each entry can consume about | |
1025 | * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ | |
1026 | #define RTLLIB_FRAG_CACHE_LEN 4 | |
1027 | ||
1028 | struct rtllib_frag_entry { | |
1029 | unsigned long first_frag_time; | |
1030 | unsigned int seq; | |
1031 | unsigned int last_frag; | |
1032 | struct sk_buff *skb; | |
1033 | u8 src_addr[ETH_ALEN]; | |
1034 | u8 dst_addr[ETH_ALEN]; | |
1035 | }; | |
1036 | ||
1037 | struct rtllib_stats { | |
1038 | unsigned int tx_unicast_frames; | |
1039 | unsigned int tx_multicast_frames; | |
1040 | unsigned int tx_fragments; | |
1041 | unsigned int tx_unicast_octets; | |
1042 | unsigned int tx_multicast_octets; | |
1043 | unsigned int tx_deferred_transmissions; | |
1044 | unsigned int tx_single_retry_frames; | |
1045 | unsigned int tx_multiple_retry_frames; | |
1046 | unsigned int tx_retry_limit_exceeded; | |
1047 | unsigned int tx_discards; | |
1048 | unsigned int rx_unicast_frames; | |
1049 | unsigned int rx_multicast_frames; | |
1050 | unsigned int rx_fragments; | |
1051 | unsigned int rx_unicast_octets; | |
1052 | unsigned int rx_multicast_octets; | |
1053 | unsigned int rx_fcs_errors; | |
1054 | unsigned int rx_discards_no_buffer; | |
1055 | unsigned int tx_discards_wrong_sa; | |
1056 | unsigned int rx_discards_undecryptable; | |
1057 | unsigned int rx_message_in_msg_fragments; | |
1058 | unsigned int rx_message_in_bad_msg_fragments; | |
1059 | }; | |
1060 | ||
1061 | struct rtllib_device; | |
1062 | ||
1063 | #include "rtllib_crypt.h" | |
1064 | ||
8567829a LF |
1065 | #define SEC_KEY_1 (1<<0) |
1066 | #define SEC_KEY_2 (1<<1) | |
1067 | #define SEC_KEY_3 (1<<2) | |
1068 | #define SEC_KEY_4 (1<<3) | |
94a79942 LF |
1069 | #define SEC_ACTIVE_KEY (1<<4) |
1070 | #define SEC_AUTH_MODE (1<<5) | |
1071 | #define SEC_UNICAST_GROUP (1<<6) | |
8567829a | 1072 | #define SEC_LEVEL (1<<7) |
94a79942 LF |
1073 | #define SEC_ENABLED (1<<8) |
1074 | #define SEC_ENCRYPT (1<<9) | |
1075 | ||
1076 | #define SEC_LEVEL_0 0 /* None */ | |
1077 | #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ | |
1078 | #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ | |
1079 | #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ | |
1080 | #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ | |
1081 | ||
8567829a LF |
1082 | #define SEC_ALG_NONE 0 |
1083 | #define SEC_ALG_WEP 1 | |
1084 | #define SEC_ALG_TKIP 2 | |
1085 | #define SEC_ALG_CCMP 4 | |
94a79942 | 1086 | |
94a79942 | 1087 | #define WEP_KEY_LEN 13 |
8567829a | 1088 | #define SCM_KEY_LEN 32 |
94a79942 LF |
1089 | #define SCM_TEMPORAL_KEY_LENGTH 16 |
1090 | ||
1091 | struct rtllib_security { | |
1092 | u16 active_key:2, | |
8567829a | 1093 | enabled:1, |
94a79942 | 1094 | auth_mode:2, |
8567829a LF |
1095 | auth_algo:4, |
1096 | unicast_uses_group:1, | |
94a79942 | 1097 | encrypt:1; |
184f1938 SM |
1098 | u8 key_sizes[NUM_WEP_KEYS]; |
1099 | u8 keys[NUM_WEP_KEYS][SCM_KEY_LEN]; | |
94a79942 LF |
1100 | u8 level; |
1101 | u16 flags; | |
8567829a | 1102 | } __packed; |
94a79942 LF |
1103 | |
1104 | ||
1105 | /* | |
1106 | 802.11 data frame from AP | |
1107 | ,-------------------------------------------------------------------. | |
1108 | Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | | |
1109 | |------|------|---------|---------|---------|------|---------|------| | |
1110 | Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | | |
8567829a | 1111 | | | tion | (BSSID) | | | ence | data | | |
94a79942 LF |
1112 | `-------------------------------------------------------------------' |
1113 | Total: 28-2340 bytes | |
1114 | */ | |
1115 | ||
1116 | /* Management Frame Information Element Types */ | |
1117 | enum rtllib_mfie { | |
8567829a LF |
1118 | MFIE_TYPE_SSID = 0, |
1119 | MFIE_TYPE_RATES = 1, | |
1120 | MFIE_TYPE_FH_SET = 2, | |
1121 | MFIE_TYPE_DS_SET = 3, | |
1122 | MFIE_TYPE_CF_SET = 4, | |
1123 | MFIE_TYPE_TIM = 5, | |
1124 | MFIE_TYPE_IBSS_SET = 6, | |
1125 | MFIE_TYPE_COUNTRY = 7, | |
1126 | MFIE_TYPE_HOP_PARAMS = 8, | |
1127 | MFIE_TYPE_HOP_TABLE = 9, | |
1128 | MFIE_TYPE_REQUEST = 10, | |
1129 | MFIE_TYPE_CHALLENGE = 16, | |
1130 | MFIE_TYPE_POWER_CONSTRAINT = 32, | |
1131 | MFIE_TYPE_POWER_CAPABILITY = 33, | |
1132 | MFIE_TYPE_TPC_REQUEST = 34, | |
1133 | MFIE_TYPE_TPC_REPORT = 35, | |
1134 | MFIE_TYPE_SUPP_CHANNELS = 36, | |
1135 | MFIE_TYPE_CSA = 37, | |
1136 | MFIE_TYPE_MEASURE_REQUEST = 38, | |
1137 | MFIE_TYPE_MEASURE_REPORT = 39, | |
1138 | MFIE_TYPE_QUIET = 40, | |
1139 | MFIE_TYPE_IBSS_DFS = 41, | |
1140 | MFIE_TYPE_ERP = 42, | |
1141 | MFIE_TYPE_HT_CAP = 45, | |
94a79942 LF |
1142 | MFIE_TYPE_RSN = 48, |
1143 | MFIE_TYPE_RATES_EX = 50, | |
8567829a LF |
1144 | MFIE_TYPE_HT_INFO = 61, |
1145 | MFIE_TYPE_AIRONET = 133, | |
94a79942 | 1146 | MFIE_TYPE_GENERIC = 221, |
8567829a | 1147 | MFIE_TYPE_QOS_PARAMETER = 222, |
94a79942 LF |
1148 | }; |
1149 | ||
1150 | /* Minimal header; can be used for passing 802.11 frames with sufficient | |
1151 | * information to determine what type of underlying data type is actually | |
1152 | * stored in the data. */ | |
1153 | struct rtllib_pspoll_hdr { | |
8567829a LF |
1154 | __le16 frame_ctl; |
1155 | __le16 aid; | |
94a79942 | 1156 | u8 bssid[ETH_ALEN]; |
8567829a LF |
1157 | u8 ta[ETH_ALEN]; |
1158 | } __packed; | |
94a79942 LF |
1159 | |
1160 | struct rtllib_hdr { | |
8567829a LF |
1161 | __le16 frame_ctl; |
1162 | __le16 duration_id; | |
1163 | u8 payload[0]; | |
1164 | } __packed; | |
94a79942 LF |
1165 | |
1166 | struct rtllib_hdr_1addr { | |
8567829a LF |
1167 | __le16 frame_ctl; |
1168 | __le16 duration_id; | |
1169 | u8 addr1[ETH_ALEN]; | |
1170 | u8 payload[0]; | |
1171 | } __packed; | |
94a79942 LF |
1172 | |
1173 | struct rtllib_hdr_2addr { | |
8567829a LF |
1174 | __le16 frame_ctl; |
1175 | __le16 duration_id; | |
1176 | u8 addr1[ETH_ALEN]; | |
1177 | u8 addr2[ETH_ALEN]; | |
1178 | u8 payload[0]; | |
1179 | } __packed; | |
94a79942 LF |
1180 | |
1181 | struct rtllib_hdr_3addr { | |
1182 | __le16 frame_ctl; | |
1183 | __le16 duration_id; | |
1184 | u8 addr1[ETH_ALEN]; | |
1185 | u8 addr2[ETH_ALEN]; | |
1186 | u8 addr3[ETH_ALEN]; | |
1187 | __le16 seq_ctl; | |
8567829a LF |
1188 | u8 payload[0]; |
1189 | } __packed; | |
94a79942 LF |
1190 | |
1191 | struct rtllib_hdr_4addr { | |
1192 | __le16 frame_ctl; | |
1193 | __le16 duration_id; | |
1194 | u8 addr1[ETH_ALEN]; | |
1195 | u8 addr2[ETH_ALEN]; | |
1196 | u8 addr3[ETH_ALEN]; | |
1197 | __le16 seq_ctl; | |
1198 | u8 addr4[ETH_ALEN]; | |
8567829a LF |
1199 | u8 payload[0]; |
1200 | } __packed; | |
94a79942 LF |
1201 | |
1202 | struct rtllib_hdr_3addrqos { | |
1203 | __le16 frame_ctl; | |
1204 | __le16 duration_id; | |
1205 | u8 addr1[ETH_ALEN]; | |
1206 | u8 addr2[ETH_ALEN]; | |
1207 | u8 addr3[ETH_ALEN]; | |
1208 | __le16 seq_ctl; | |
1209 | __le16 qos_ctl; | |
1210 | u8 payload[0]; | |
8567829a | 1211 | } __packed; |
94a79942 LF |
1212 | |
1213 | struct rtllib_hdr_4addrqos { | |
1214 | __le16 frame_ctl; | |
1215 | __le16 duration_id; | |
1216 | u8 addr1[ETH_ALEN]; | |
1217 | u8 addr2[ETH_ALEN]; | |
1218 | u8 addr3[ETH_ALEN]; | |
1219 | __le16 seq_ctl; | |
1220 | u8 addr4[ETH_ALEN]; | |
1221 | __le16 qos_ctl; | |
1222 | u8 payload[0]; | |
8567829a | 1223 | } __packed; |
94a79942 LF |
1224 | |
1225 | struct rtllib_info_element { | |
1226 | u8 id; | |
1227 | u8 len; | |
1228 | u8 data[0]; | |
8567829a | 1229 | } __packed; |
94a79942 LF |
1230 | |
1231 | struct rtllib_authentication { | |
1232 | struct rtllib_hdr_3addr header; | |
1233 | __le16 algorithm; | |
1234 | __le16 transaction; | |
1235 | __le16 status; | |
1236 | /*challenge*/ | |
1237 | struct rtllib_info_element info_element[0]; | |
8567829a | 1238 | } __packed; |
94a79942 LF |
1239 | |
1240 | struct rtllib_disauth { | |
8567829a LF |
1241 | struct rtllib_hdr_3addr header; |
1242 | __le16 reason; | |
1243 | } __packed; | |
94a79942 LF |
1244 | |
1245 | struct rtllib_disassoc { | |
8567829a LF |
1246 | struct rtllib_hdr_3addr header; |
1247 | __le16 reason; | |
1248 | } __packed; | |
94a79942 LF |
1249 | |
1250 | struct rtllib_probe_request { | |
1251 | struct rtllib_hdr_3addr header; | |
1252 | /* SSID, supported rates */ | |
8567829a LF |
1253 | struct rtllib_info_element info_element[0]; |
1254 | } __packed; | |
94a79942 LF |
1255 | |
1256 | struct rtllib_probe_response { | |
1257 | struct rtllib_hdr_3addr header; | |
1258 | u32 time_stamp[2]; | |
1259 | __le16 beacon_interval; | |
1260 | __le16 capability; | |
8567829a LF |
1261 | /* SSID, supported rates, FH params, DS params, |
1262 | * CF params, IBSS params, TIM (if beacon), RSN */ | |
1263 | struct rtllib_info_element info_element[0]; | |
1264 | } __packed; | |
94a79942 LF |
1265 | |
1266 | /* Alias beacon for probe_response */ | |
1267 | #define rtllib_beacon rtllib_probe_response | |
1268 | ||
1269 | struct rtllib_assoc_request_frame { | |
1270 | struct rtllib_hdr_3addr header; | |
1271 | __le16 capability; | |
1272 | __le16 listen_interval; | |
1273 | /* SSID, supported rates, RSN */ | |
8567829a LF |
1274 | struct rtllib_info_element info_element[0]; |
1275 | } __packed; | |
94a79942 LF |
1276 | |
1277 | struct rtllib_reassoc_request_frame { | |
1278 | struct rtllib_hdr_3addr header; | |
1279 | __le16 capability; | |
1280 | __le16 listen_interval; | |
1281 | u8 current_ap[ETH_ALEN]; | |
1282 | /* SSID, supported rates, RSN */ | |
8567829a LF |
1283 | struct rtllib_info_element info_element[0]; |
1284 | } __packed; | |
94a79942 LF |
1285 | |
1286 | struct rtllib_assoc_response_frame { | |
1287 | struct rtllib_hdr_3addr header; | |
1288 | __le16 capability; | |
1289 | __le16 status; | |
1290 | __le16 aid; | |
1291 | struct rtllib_info_element info_element[0]; /* supported rates */ | |
8567829a | 1292 | } __packed; |
94a79942 LF |
1293 | |
1294 | struct rtllib_txb { | |
1295 | u8 nr_frags; | |
1296 | u8 encrypted; | |
1297 | u8 queue_index; | |
1298 | u8 rts_included; | |
1299 | u16 reserved; | |
1300 | __le16 frag_size; | |
1301 | __le16 payload_size; | |
1302 | struct sk_buff *fragments[0]; | |
1303 | }; | |
1304 | ||
1305 | #define MAX_TX_AGG_COUNT 16 | |
1306 | struct rtllib_drv_agg_txb { | |
1307 | u8 nr_drv_agg_frames; | |
1308 | struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; | |
8567829a | 1309 | } __packed; |
94a79942 LF |
1310 | |
1311 | #define MAX_SUBFRAME_COUNT 64 | |
1312 | struct rtllib_rxb { | |
1313 | u8 nr_subframes; | |
1314 | struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; | |
1315 | u8 dst[ETH_ALEN]; | |
1316 | u8 src[ETH_ALEN]; | |
8567829a | 1317 | } __packed; |
94a79942 | 1318 | |
66ba443a | 1319 | union frameqos { |
94a79942 LF |
1320 | u16 shortdata; |
1321 | u8 chardata[2]; | |
1322 | struct { | |
1323 | u16 tid:4; | |
1324 | u16 eosp:1; | |
1325 | u16 ack_policy:2; | |
1326 | u16 reserved:1; | |
1327 | u16 txop:8; | |
8567829a | 1328 | } field; |
66ba443a | 1329 | }; |
94a79942 LF |
1330 | |
1331 | /* SWEEP TABLE ENTRIES NUMBER*/ | |
1332 | #define MAX_SWEEP_TAB_ENTRIES 42 | |
1333 | #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 | |
1334 | /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs | |
1335 | * only use 8, and then use extended rates for the remaining supported | |
1336 | * rates. Other APs, however, stick all of their supported rates on the | |
1337 | * main rates information element... */ | |
8567829a LF |
1338 | #define MAX_RATES_LENGTH ((u8)12) |
1339 | #define MAX_RATES_EX_LENGTH ((u8)16) | |
1340 | #define MAX_NETWORK_COUNT 96 | |
94a79942 | 1341 | |
8567829a | 1342 | #define MAX_CHANNEL_NUMBER 161 |
94a79942 LF |
1343 | #define RTLLIB_SOFTMAC_SCAN_TIME 100 |
1344 | #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) | |
1345 | ||
8567829a | 1346 | #define CRC_LENGTH 4U |
94a79942 LF |
1347 | |
1348 | #define MAX_WPA_IE_LEN 64 | |
1349 | #define MAX_WZC_IE_LEN 256 | |
1350 | ||
1351 | #define NETWORK_EMPTY_ESSID (1<<0) | |
1352 | #define NETWORK_HAS_OFDM (1<<1) | |
1353 | #define NETWORK_HAS_CCK (1<<2) | |
1354 | ||
1355 | /* QoS structure */ | |
1356 | #define NETWORK_HAS_QOS_PARAMETERS (1<<3) | |
1357 | #define NETWORK_HAS_QOS_INFORMATION (1<<4) | |
8567829a LF |
1358 | #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \ |
1359 | NETWORK_HAS_QOS_INFORMATION) | |
94a79942 LF |
1360 | /* 802.11h */ |
1361 | #define NETWORK_HAS_POWER_CONSTRAINT (1<<5) | |
8567829a LF |
1362 | #define NETWORK_HAS_CSA (1<<6) |
1363 | #define NETWORK_HAS_QUIET (1<<7) | |
1364 | #define NETWORK_HAS_IBSS_DFS (1<<8) | |
1365 | #define NETWORK_HAS_TPC_REPORT (1<<9) | |
1366 | ||
1367 | #define NETWORK_HAS_ERP_VALUE (1<<10) | |
1368 | ||
1369 | #define QOS_QUEUE_NUM 4 | |
1370 | #define QOS_OUI_LEN 3 | |
1371 | #define QOS_OUI_TYPE 2 | |
1372 | #define QOS_ELEMENT_ID 221 | |
1373 | #define QOS_OUI_INFO_SUB_TYPE 0 | |
1374 | #define QOS_OUI_PARAM_SUB_TYPE 1 | |
1375 | #define QOS_VERSION_1 1 | |
1376 | #define QOS_AIFSN_MIN_VALUE 2 | |
1377 | ||
94a79942 | 1378 | struct rtllib_qos_information_element { |
8567829a LF |
1379 | u8 elementID; |
1380 | u8 length; | |
1381 | u8 qui[QOS_OUI_LEN]; | |
1382 | u8 qui_type; | |
1383 | u8 qui_subtype; | |
1384 | u8 version; | |
1385 | u8 ac_info; | |
1386 | } __packed; | |
94a79942 LF |
1387 | |
1388 | struct rtllib_qos_ac_parameter { | |
8567829a LF |
1389 | u8 aci_aifsn; |
1390 | u8 ecw_min_max; | |
1391 | __le16 tx_op_limit; | |
1392 | } __packed; | |
94a79942 LF |
1393 | |
1394 | struct rtllib_qos_parameter_info { | |
8567829a LF |
1395 | struct rtllib_qos_information_element info_element; |
1396 | u8 reserved; | |
1397 | struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; | |
1398 | } __packed; | |
94a79942 LF |
1399 | |
1400 | struct rtllib_qos_parameters { | |
8567829a LF |
1401 | __le16 cw_min[QOS_QUEUE_NUM]; |
1402 | __le16 cw_max[QOS_QUEUE_NUM]; | |
1403 | u8 aifs[QOS_QUEUE_NUM]; | |
1404 | u8 flag[QOS_QUEUE_NUM]; | |
1405 | __le16 tx_op_limit[QOS_QUEUE_NUM]; | |
1406 | } __packed; | |
94a79942 LF |
1407 | |
1408 | struct rtllib_qos_data { | |
8567829a | 1409 | struct rtllib_qos_parameters parameters; |
94a79942 | 1410 | unsigned int wmm_acm; |
8567829a LF |
1411 | int active; |
1412 | int supported; | |
1413 | u8 param_count; | |
1414 | u8 old_param_count; | |
94a79942 LF |
1415 | }; |
1416 | ||
1417 | struct rtllib_tim_parameters { | |
8567829a LF |
1418 | u8 tim_count; |
1419 | u8 tim_period; | |
1420 | } __packed; | |
94a79942 LF |
1421 | |
1422 | struct rtllib_wmm_ac_param { | |
1423 | u8 ac_aci_acm_aifsn; | |
1424 | u8 ac_ecwmin_ecwmax; | |
1425 | u16 ac_txop_limit; | |
1426 | }; | |
1427 | ||
1428 | struct rtllib_wmm_ts_info { | |
1429 | u8 ac_dir_tid; | |
1430 | u8 ac_up_psb; | |
1431 | u8 reserved; | |
8567829a | 1432 | } __packed; |
94a79942 LF |
1433 | |
1434 | struct rtllib_wmm_tspec_elem { | |
1435 | struct rtllib_wmm_ts_info ts_info; | |
1436 | u16 norm_msdu_size; | |
1437 | u16 max_msdu_size; | |
1438 | u32 min_serv_inter; | |
1439 | u32 max_serv_inter; | |
1440 | u32 inact_inter; | |
1441 | u32 suspen_inter; | |
1442 | u32 serv_start_time; | |
1443 | u32 min_data_rate; | |
1444 | u32 mean_data_rate; | |
1445 | u32 peak_data_rate; | |
1446 | u32 max_burst_size; | |
1447 | u32 delay_bound; | |
1448 | u32 min_phy_rate; | |
1449 | u16 surp_band_allow; | |
1450 | u16 medium_time; | |
8567829a LF |
1451 | } __packed; |
1452 | ||
94a79942 LF |
1453 | enum eap_type { |
1454 | EAP_PACKET = 0, | |
1455 | EAPOL_START, | |
1456 | EAPOL_LOGOFF, | |
1457 | EAPOL_KEY, | |
1458 | EAPOL_ENCAP_ASF_ALERT | |
1459 | }; | |
1460 | ||
1461 | static const char *eap_types[] = { | |
1462 | [EAP_PACKET] = "EAP-Packet", | |
1463 | [EAPOL_START] = "EAPOL-Start", | |
1464 | [EAPOL_LOGOFF] = "EAPOL-Logoff", | |
1465 | [EAPOL_KEY] = "EAPOL-Key", | |
1466 | [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert" | |
1467 | }; | |
1468 | ||
1469 | static inline const char *eap_get_type(int type) | |
1470 | { | |
8567829a LF |
1471 | return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : |
1472 | eap_types[type]; | |
94a79942 | 1473 | } |
8567829a | 1474 | static inline u8 Frame_QoSTID(u8 *buf) |
94a79942 LF |
1475 | { |
1476 | struct rtllib_hdr_3addr *hdr; | |
1477 | u16 fc; | |
1478 | hdr = (struct rtllib_hdr_3addr *)buf; | |
1479 | fc = le16_to_cpu(hdr->frame_ctl); | |
8567829a LF |
1480 | return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) && |
1481 | (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid; | |
94a79942 LF |
1482 | } |
1483 | ||
1484 | ||
1485 | struct eapol { | |
1486 | u8 snap[6]; | |
1487 | u16 ethertype; | |
1488 | u8 version; | |
1489 | u8 type; | |
1490 | u16 length; | |
8567829a | 1491 | } __packed; |
94a79942 | 1492 | |
8567829a | 1493 | struct rtllib_softmac_stats { |
94a79942 LF |
1494 | unsigned int rx_ass_ok; |
1495 | unsigned int rx_ass_err; | |
1496 | unsigned int rx_probe_rq; | |
1497 | unsigned int tx_probe_rs; | |
1498 | unsigned int tx_beacons; | |
1499 | unsigned int rx_auth_rq; | |
1500 | unsigned int rx_auth_rs_ok; | |
1501 | unsigned int rx_auth_rs_err; | |
1502 | unsigned int tx_auth_rq; | |
1503 | unsigned int no_auth_rs; | |
1504 | unsigned int no_ass_rs; | |
1505 | unsigned int tx_ass_rq; | |
1506 | unsigned int rx_ass_rq; | |
1507 | unsigned int tx_probe_rq; | |
1508 | unsigned int reassoc; | |
1509 | unsigned int swtxstop; | |
1510 | unsigned int swtxawake; | |
1511 | unsigned char CurrentShowTxate; | |
1512 | unsigned char last_packet_rate; | |
1513 | unsigned int txretrycount; | |
1514 | }; | |
1515 | ||
1516 | #define BEACON_PROBE_SSID_ID_POSITION 12 | |
1517 | ||
1518 | struct rtllib_info_element_hdr { | |
1519 | u8 id; | |
1520 | u8 len; | |
8567829a | 1521 | } __packed; |
94a79942 LF |
1522 | |
1523 | /* | |
1524 | * These are the data types that can make up management packets | |
1525 | * | |
1526 | u16 auth_algorithm; | |
1527 | u16 auth_sequence; | |
1528 | u16 beacon_interval; | |
1529 | u16 capability; | |
1530 | u8 current_ap[ETH_ALEN]; | |
1531 | u16 listen_interval; | |
1532 | struct { | |
1533 | u16 association_id:14, reserved:2; | |
8567829a | 1534 | } __packed; |
94a79942 LF |
1535 | u32 time_stamp[2]; |
1536 | u16 reason; | |
1537 | u16 status; | |
1538 | */ | |
1539 | ||
1540 | #define RTLLIB_DEFAULT_TX_ESSID "Penguin" | |
1541 | #define RTLLIB_DEFAULT_BASIC_RATE 2 | |
1542 | ||
1543 | enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; | |
1544 | #define MAX_SP_Len (WMM_all_frame << 4) | |
1545 | #define RTLLIB_QOS_TID 0x0f | |
1546 | #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5) | |
1547 | ||
1548 | #define RTLLIB_DTIM_MBCAST 4 | |
1549 | #define RTLLIB_DTIM_UCAST 2 | |
1550 | #define RTLLIB_DTIM_VALID 1 | |
1551 | #define RTLLIB_DTIM_INVALID 0 | |
1552 | ||
1553 | #define RTLLIB_PS_DISABLED 0 | |
1554 | #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST | |
1555 | #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST | |
1556 | ||
94a79942 LF |
1557 | #define WME_AC_BK 0x00 |
1558 | #define WME_AC_BE 0x01 | |
1559 | #define WME_AC_VI 0x02 | |
1560 | #define WME_AC_VO 0x03 | |
1561 | #define WME_ACI_MASK 0x03 | |
1562 | #define WME_AIFSN_MASK 0x03 | |
1563 | #define WME_AC_PRAM_LEN 16 | |
1564 | ||
1565 | #define MAX_RECEIVE_BUFFER_SIZE 9100 | |
1566 | ||
94a79942 LF |
1567 | #define UP2AC(up) ( \ |
1568 | ((up) < 1) ? WME_AC_BE : \ | |
1569 | ((up) < 3) ? WME_AC_BK : \ | |
1570 | ((up) < 4) ? WME_AC_BE : \ | |
1571 | ((up) < 6) ? WME_AC_VI : \ | |
1572 | WME_AC_VO) | |
eccf634f | 1573 | |
94a79942 LF |
1574 | #define AC2UP(_ac) ( \ |
1575 | ((_ac) == WME_AC_VO) ? 6 : \ | |
1576 | ((_ac) == WME_AC_VI) ? 5 : \ | |
1577 | ((_ac) == WME_AC_BK) ? 1 : \ | |
1578 | 0) | |
1579 | ||
1580 | #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ | |
8567829a LF |
1581 | #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address |
1582 | * plus ether type*/ | |
94a79942 LF |
1583 | |
1584 | struct ether_header { | |
1585 | u8 ether_dhost[ETHER_ADDR_LEN]; | |
1586 | u8 ether_shost[ETHER_ADDR_LEN]; | |
1587 | u16 ether_type; | |
8567829a | 1588 | } __packed; |
94a79942 LF |
1589 | |
1590 | #ifndef ETHERTYPE_PAE | |
1591 | #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ | |
1592 | #endif | |
1593 | #ifndef ETHERTYPE_IP | |
1594 | #define ETHERTYPE_IP 0x0800 /* IP protocol */ | |
1595 | #endif | |
1596 | ||
1597 | ||
3b45eb83 | 1598 | enum erp_t { |
94a79942 LF |
1599 | ERP_NonERPpresent = 0x01, |
1600 | ERP_UseProtection = 0x02, | |
1601 | ERP_BarkerPreambleMode = 0x04, | |
3b45eb83 | 1602 | }; |
94a79942 LF |
1603 | |
1604 | struct rtllib_network { | |
1605 | /* These entries are used to identify a unique network */ | |
1606 | u8 bssid[ETH_ALEN]; | |
1607 | u8 channel; | |
1608 | /* Ensure null-terminated for any debug msgs */ | |
1609 | u8 ssid[IW_ESSID_MAX_SIZE + 1]; | |
1610 | u8 ssid_len; | |
1611 | u8 hidden_ssid[IW_ESSID_MAX_SIZE + 1]; | |
1612 | u8 hidden_ssid_len; | |
1613 | struct rtllib_qos_data qos_data; | |
1614 | ||
1615 | bool bWithAironetIE; | |
1616 | bool bCkipSupported; | |
1617 | bool bCcxRmEnable; | |
1618 | u16 CcxRmState[2]; | |
1619 | bool bMBssidValid; | |
1620 | u8 MBssidMask; | |
1621 | u8 MBssid[6]; | |
1622 | bool bWithCcxVerNum; | |
1623 | u8 BssCcxVerNumber; | |
1624 | /* These are network statistics */ | |
1625 | struct rtllib_rx_stats stats; | |
1626 | u16 capability; | |
1627 | u8 rates[MAX_RATES_LENGTH]; | |
1628 | u8 rates_len; | |
1629 | u8 rates_ex[MAX_RATES_EX_LENGTH]; | |
1630 | u8 rates_ex_len; | |
1631 | unsigned long last_scanned; | |
1632 | u8 mode; | |
1633 | u32 flags; | |
1634 | u32 last_associate; | |
1635 | u32 time_stamp[2]; | |
1636 | u16 beacon_interval; | |
1637 | u16 listen_interval; | |
1638 | u16 atim_window; | |
1639 | u8 erp_value; | |
1640 | u8 wpa_ie[MAX_WPA_IE_LEN]; | |
1641 | size_t wpa_ie_len; | |
1642 | u8 rsn_ie[MAX_WPA_IE_LEN]; | |
1643 | size_t rsn_ie_len; | |
1644 | u8 wzc_ie[MAX_WZC_IE_LEN]; | |
1645 | size_t wzc_ie_len; | |
1646 | ||
8567829a | 1647 | struct rtllib_tim_parameters tim; |
94a79942 LF |
1648 | u8 dtim_period; |
1649 | u8 dtim_data; | |
0dd56506 | 1650 | u64 last_dtim_sta_time; |
94a79942 | 1651 | |
8567829a LF |
1652 | u8 wmm_info; |
1653 | struct rtllib_wmm_ac_param wmm_param[4]; | |
94a79942 | 1654 | u8 Turbo_Enable; |
94a79942 LF |
1655 | u16 CountryIeLen; |
1656 | u8 CountryIeBuf[MAX_IE_LEN]; | |
a15e76ad | 1657 | struct bss_ht bssht; |
94a79942 LF |
1658 | bool broadcom_cap_exist; |
1659 | bool realtek_cap_exit; | |
1660 | bool marvell_cap_exist; | |
1661 | bool ralink_cap_exist; | |
1662 | bool atheros_cap_exist; | |
1663 | bool cisco_cap_exist; | |
1664 | bool airgo_cap_exist; | |
1665 | bool unknown_cap_exist; | |
1666 | bool berp_info_valid; | |
1667 | bool buseprotection; | |
1668 | bool bIsNetgear854T; | |
1669 | u8 SignalStrength; | |
1670 | u8 RSSI; | |
1671 | struct list_head list; | |
1672 | }; | |
1673 | ||
1674 | #if 1 | |
1675 | enum rtllib_state { | |
1676 | ||
1677 | /* the card is not linked at all */ | |
1678 | RTLLIB_NOLINK = 0, | |
1679 | ||
1680 | /* RTLLIB_ASSOCIATING* are for BSS client mode | |
1681 | * the driver shall not perform RX filtering unless | |
1682 | * the state is LINKED. | |
1683 | * The driver shall just check for the state LINKED and | |
1684 | * defaults to NOLINK for ALL the other states (including | |
1685 | * LINKED_SCANNING) | |
1686 | */ | |
1687 | ||
1688 | /* the association procedure will start (wq scheduling)*/ | |
1689 | RTLLIB_ASSOCIATING, | |
1690 | RTLLIB_ASSOCIATING_RETRY, | |
1691 | ||
1692 | /* the association procedure is sending AUTH request*/ | |
1693 | RTLLIB_ASSOCIATING_AUTHENTICATING, | |
1694 | ||
1695 | /* the association procedure has successfully authentcated | |
1696 | * and is sending association request | |
1697 | */ | |
1698 | RTLLIB_ASSOCIATING_AUTHENTICATED, | |
1699 | ||
1700 | /* the link is ok. the card associated to a BSS or linked | |
1701 | * to a ibss cell or acting as an AP and creating the bss | |
1702 | */ | |
1703 | RTLLIB_LINKED, | |
1704 | ||
1705 | /* same as LINKED, but the driver shall apply RX filter | |
1706 | * rules as we are in NO_LINK mode. As the card is still | |
1707 | * logically linked, but it is doing a syncro site survey | |
1708 | * then it will be back to LINKED state. | |
1709 | */ | |
1710 | RTLLIB_LINKED_SCANNING, | |
1711 | }; | |
1712 | #else | |
1713 | enum rtllib_state { | |
8567829a LF |
1714 | RTLLIB_UNINITIALIZED = 0, |
1715 | RTLLIB_INITIALIZED, | |
1716 | RTLLIB_ASSOCIATING, | |
1717 | RTLLIB_ASSOCIATED, | |
1718 | RTLLIB_AUTHENTICATING, | |
1719 | RTLLIB_AUTHENTICATED, | |
1720 | RTLLIB_SHUTDOWN | |
94a79942 LF |
1721 | }; |
1722 | #endif | |
1723 | ||
1724 | #define DEFAULT_MAX_SCAN_AGE (15 * HZ) | |
1725 | #define DEFAULT_FTS 2346 | |
1726 | ||
1727 | #define CFG_RTLLIB_RESERVE_FCS (1<<0) | |
1728 | #define CFG_RTLLIB_COMPUTE_FCS (1<<1) | |
1729 | #define CFG_RTLLIB_RTS (1<<2) | |
1730 | ||
1731 | #define RTLLIB_24GHZ_MIN_CHANNEL 1 | |
1732 | #define RTLLIB_24GHZ_MAX_CHANNEL 14 | |
1733 | #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \ | |
8567829a | 1734 | RTLLIB_24GHZ_MIN_CHANNEL + 1) |
94a79942 LF |
1735 | |
1736 | #define RTLLIB_52GHZ_MIN_CHANNEL 34 | |
1737 | #define RTLLIB_52GHZ_MAX_CHANNEL 165 | |
1738 | #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \ | |
8567829a | 1739 | RTLLIB_52GHZ_MIN_CHANNEL + 1) |
94a79942 | 1740 | #ifndef eqMacAddr |
8567829a LF |
1741 | #define eqMacAddr(a, b) \ |
1742 | (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \ | |
1743 | (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) | |
94a79942 | 1744 | #endif |
0ce60045 | 1745 | struct tx_pending { |
94a79942 LF |
1746 | int frag; |
1747 | struct rtllib_txb *txb; | |
d3b2c172 | 1748 | }; |
94a79942 | 1749 | |
dca0eb1e | 1750 | struct bandwidth_autoswitch { |
94a79942 LF |
1751 | long threshold_20Mhzto40Mhz; |
1752 | long threshold_40Mhzto20Mhz; | |
1753 | bool bforced_tx20Mhz; | |
1754 | bool bautoswitch_enable; | |
d3b2c172 | 1755 | }; |
94a79942 LF |
1756 | |
1757 | ||
1758 | ||
1759 | #define REORDER_WIN_SIZE 128 | |
1760 | #define REORDER_ENTRY_NUM 128 | |
8cba1432 | 1761 | struct rx_reorder_entry { |
94a79942 LF |
1762 | struct list_head List; |
1763 | u16 SeqNum; | |
8567829a | 1764 | struct rtllib_rxb *prxb; |
8cba1432 | 1765 | }; |
3c093c2b | 1766 | enum fsync_state { |
94a79942 LF |
1767 | Default_Fsync, |
1768 | HW_Fsync, | |
1769 | SW_Fsync | |
3c093c2b | 1770 | }; |
94a79942 | 1771 | |
f6e3d4f4 | 1772 | enum rt_ps_mode { |
94a79942 LF |
1773 | eActive, |
1774 | eMaxPs, | |
1775 | eFastPs, | |
1776 | eAutoPs, | |
f6e3d4f4 | 1777 | }; |
94a79942 | 1778 | |
8304cc64 | 1779 | enum ips_callback_function { |
94a79942 LF |
1780 | IPS_CALLBACK_NONE = 0, |
1781 | IPS_CALLBACK_MGNT_LINK_REQUEST = 1, | |
1782 | IPS_CALLBACK_JOIN_REQUEST = 2, | |
8304cc64 | 1783 | }; |
94a79942 | 1784 | |
f6ce577e | 1785 | enum rt_join_action { |
94a79942 LF |
1786 | RT_JOIN_INFRA = 1, |
1787 | RT_JOIN_IBSS = 2, | |
1788 | RT_START_IBSS = 3, | |
1789 | RT_NO_ACTION = 4, | |
f6ce577e | 1790 | }; |
94a79942 | 1791 | |
7152e7ec | 1792 | struct ibss_parms { |
94a79942 | 1793 | u16 atimWin; |
d3b2c172 | 1794 | }; |
94a79942 LF |
1795 | #define MAX_NUM_RATES 264 |
1796 | ||
de7c885a | 1797 | enum rt_rf_power_state { |
94a79942 LF |
1798 | eRfOn, |
1799 | eRfSleep, | |
1800 | eRfOff | |
de7c885a | 1801 | }; |
94a79942 LF |
1802 | |
1803 | #define MAX_SUPPORT_WOL_PATTERN_NUM 8 | |
1804 | ||
1805 | #define MAX_WOL_BIT_MASK_SIZE 16 | |
1806 | #define MAX_WOL_PATTERN_SIZE 128 | |
1807 | ||
d45c88a6 | 1808 | enum wol_pattern_type { |
94a79942 LF |
1809 | eNetBIOS = 0, |
1810 | eIPv4IPv6ARP, | |
1811 | eIPv4IPv6TCPSYN, | |
1812 | eMACIDOnly, | |
1813 | eNoDefined, | |
d45c88a6 | 1814 | }; |
94a79942 | 1815 | |
628c30e8 | 1816 | struct rt_pm_wol_info { |
94a79942 LF |
1817 | u32 PatternId; |
1818 | u32 Mask[4]; | |
1819 | u16 CrcRemainder; | |
1820 | u8 WFMIndex; | |
d45c88a6 | 1821 | enum wol_pattern_type PatternType; |
d3b2c172 | 1822 | }; |
94a79942 | 1823 | |
ca990011 | 1824 | struct rt_pwr_save_ctrl { |
94a79942 LF |
1825 | |
1826 | bool bInactivePs; | |
1827 | bool bIPSModeBackup; | |
1828 | bool bHaltAdapterClkRQ; | |
1829 | bool bSwRfProcessing; | |
de7c885a | 1830 | enum rt_rf_power_state eInactivePowerState; |
edc4b2c5 | 1831 | struct work_struct InactivePsWorkItem; |
94a79942 LF |
1832 | struct timer_list InactivePsTimer; |
1833 | ||
8304cc64 | 1834 | enum ips_callback_function ReturnPoint; |
94a79942 LF |
1835 | |
1836 | bool bTmpBssDesc; | |
f6ce577e | 1837 | enum rt_join_action tmpJoinAction; |
94a79942 LF |
1838 | struct rtllib_network tmpBssDesc; |
1839 | ||
1840 | bool bTmpScanOnly; | |
1841 | bool bTmpActiveScan; | |
1842 | bool bTmpFilterHiddenAP; | |
1843 | bool bTmpUpdateParms; | |
1844 | u8 tmpSsidBuf[33]; | |
8310b6c0 | 1845 | struct octet_string tmpSsid2Scan; |
94a79942 LF |
1846 | bool bTmpSsid2Scan; |
1847 | u8 tmpNetworkType; | |
1848 | u8 tmpChannelNumber; | |
1849 | u16 tmpBcnPeriod; | |
1850 | u8 tmpDtimPeriod; | |
1851 | u16 tmpmCap; | |
8310b6c0 | 1852 | struct octet_string tmpSuppRateSet; |
94a79942 LF |
1853 | u8 tmpSuppRateBuf[MAX_NUM_RATES]; |
1854 | bool bTmpSuppRate; | |
7152e7ec | 1855 | struct ibss_parms tmpIbpm; |
94a79942 LF |
1856 | bool bTmpIbpm; |
1857 | ||
1858 | bool bLeisurePs; | |
1859 | u32 PowerProfile; | |
1860 | u8 LpsIdleCount; | |
1861 | u8 RegMaxLPSAwakeIntvl; | |
1862 | u8 LPSAwakeIntvl; | |
1863 | ||
1864 | u32 CurPsLevel; | |
1865 | u32 RegRfPsLevel; | |
1866 | ||
1867 | bool bFwCtrlLPS; | |
1868 | u8 FWCtrlPSMode; | |
1869 | ||
1870 | bool LinkReqInIPSRFOffPgs; | |
1871 | bool BufConnectinfoBefore; | |
1872 | ||
1873 | ||
1874 | bool bGpioRfSw; | |
1875 | ||
1876 | u8 RegAMDPciASPM; | |
1877 | ||
1878 | u8 oWLANMode; | |
628c30e8 | 1879 | struct rt_pm_wol_info PmWoLPatternInfo[MAX_SUPPORT_WOL_PATTERN_NUM]; |
94a79942 | 1880 | |
d3b2c172 | 1881 | }; |
94a79942 | 1882 | |
9de9f962 LF |
1883 | #define RT_RF_CHANGE_SOURCE u32 |
1884 | ||
94a79942 LF |
1885 | #define RF_CHANGE_BY_SW BIT31 |
1886 | #define RF_CHANGE_BY_HW BIT30 | |
1887 | #define RF_CHANGE_BY_PS BIT29 | |
1888 | #define RF_CHANGE_BY_IPS BIT28 | |
1889 | #define RF_CHANGE_BY_INIT 0 | |
1890 | ||
569e5959 | 1891 | enum country_code_type { |
94a79942 LF |
1892 | COUNTRY_CODE_FCC = 0, |
1893 | COUNTRY_CODE_IC = 1, | |
1894 | COUNTRY_CODE_ETSI = 2, | |
1895 | COUNTRY_CODE_SPAIN = 3, | |
1896 | COUNTRY_CODE_FRANCE = 4, | |
1897 | COUNTRY_CODE_MKK = 5, | |
1898 | COUNTRY_CODE_MKK1 = 6, | |
1899 | COUNTRY_CODE_ISRAEL = 7, | |
1900 | COUNTRY_CODE_TELEC = 8, | |
1901 | COUNTRY_CODE_MIC = 9, | |
1902 | COUNTRY_CODE_GLOBAL_DOMAIN = 10, | |
1903 | COUNTRY_CODE_WORLD_WIDE_13 = 11, | |
1904 | COUNTRY_CODE_TELEC_NETGEAR = 12, | |
1905 | COUNTRY_CODE_MAX | |
569e5959 | 1906 | }; |
94a79942 | 1907 | |
472ba326 | 1908 | enum scan_op_backup_opt { |
8567829a | 1909 | SCAN_OPT_BACKUP = 0, |
94a79942 LF |
1910 | SCAN_OPT_RESTORE, |
1911 | SCAN_OPT_MAX | |
472ba326 | 1912 | }; |
94a79942 | 1913 | |
74082c92 | 1914 | enum fw_cmd_io_type { |
94a79942 LF |
1915 | FW_CMD_DIG_ENABLE = 0, |
1916 | FW_CMD_DIG_DISABLE = 1, | |
1917 | FW_CMD_DIG_HALT = 2, | |
1918 | FW_CMD_DIG_RESUME = 3, | |
1919 | FW_CMD_HIGH_PWR_ENABLE = 4, | |
1920 | FW_CMD_HIGH_PWR_DISABLE = 5, | |
1921 | FW_CMD_RA_RESET = 6, | |
8567829a LF |
1922 | FW_CMD_RA_ACTIVE = 7, |
1923 | FW_CMD_RA_REFRESH_N = 8, | |
1924 | FW_CMD_RA_REFRESH_BG = 9, | |
1925 | FW_CMD_RA_INIT = 10, | |
94a79942 LF |
1926 | FW_CMD_IQK_ENABLE = 11, |
1927 | FW_CMD_TXPWR_TRACK_ENABLE = 12, | |
1928 | FW_CMD_TXPWR_TRACK_DISABLE = 13, | |
1929 | FW_CMD_TXPWR_TRACK_THERMAL = 14, | |
1930 | FW_CMD_PAUSE_DM_BY_SCAN = 15, | |
1931 | FW_CMD_RESUME_DM_BY_SCAN = 16, | |
1932 | FW_CMD_RA_REFRESH_N_COMB = 17, | |
1933 | FW_CMD_RA_REFRESH_BG_COMB = 18, | |
1934 | FW_CMD_ANTENNA_SW_ENABLE = 19, | |
1935 | FW_CMD_ANTENNA_SW_DISABLE = 20, | |
1936 | FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21, | |
1937 | FW_CMD_LPS_ENTER = 22, | |
1938 | FW_CMD_LPS_LEAVE = 23, | |
1939 | FW_CMD_DIG_MODE_SS = 24, | |
1940 | FW_CMD_DIG_MODE_FA = 25, | |
1941 | FW_CMD_ADD_A2_ENTRY = 26, | |
1942 | FW_CMD_CTRL_DM_BY_DRIVER = 27, | |
1943 | FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28, | |
1944 | FW_CMD_PAPE_CONTROL = 29, | |
1945 | FW_CMD_CHAN_SET = 30, | |
74082c92 | 1946 | }; |
94a79942 LF |
1947 | |
1948 | #define RT_MAX_LD_SLOT_NUM 10 | |
0e86753f | 1949 | struct rt_link_detect { |
94a79942 LF |
1950 | |
1951 | u32 NumRecvBcnInPeriod; | |
1952 | u32 NumRecvDataInPeriod; | |
1953 | ||
1954 | u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; | |
1955 | u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; | |
1956 | u16 SlotNum; | |
1957 | u16 SlotIndex; | |
1958 | ||
1959 | u32 NumTxOkInPeriod; | |
1960 | u32 NumRxOkInPeriod; | |
1961 | u32 NumRxUnicastOkInPeriod; | |
1962 | bool bBusyTraffic; | |
1963 | bool bHigherBusyTraffic; | |
1964 | bool bHigherBusyRxTraffic; | |
1965 | u8 IdleCount; | |
1966 | u32 NumTxUnicastOkInPeriod; | |
1967 | u32 LastNumTxUnicast; | |
1968 | u32 LastNumRxUnicast; | |
d3b2c172 | 1969 | }; |
94a79942 | 1970 | |
5ea04480 | 1971 | struct sw_cam_table { |
94a79942 LF |
1972 | |
1973 | u8 macaddr[6]; | |
1974 | bool bused; | |
1975 | u8 key_buf[16]; | |
1976 | u16 key_type; | |
1977 | u8 useDK; | |
1978 | u8 key_index; | |
1979 | ||
d3b2c172 | 1980 | }; |
94a79942 | 1981 | #define TOTAL_CAM_ENTRY 32 |
9be6f10e | 1982 | struct rate_adaptive { |
94a79942 LF |
1983 | u8 rate_adaptive_disabled; |
1984 | u8 ratr_state; | |
1985 | u16 reserve; | |
1986 | ||
1987 | u32 high_rssi_thresh_for_ra; | |
1988 | u32 high2low_rssi_thresh_for_ra; | |
1989 | u8 low2high_rssi_thresh_for_ra40M; | |
1990 | u32 low_rssi_thresh_for_ra40M; | |
1991 | u8 low2high_rssi_thresh_for_ra20M; | |
1992 | u32 low_rssi_thresh_for_ra20M; | |
1993 | u32 upper_rssi_threshold_ratr; | |
1994 | u32 middle_rssi_threshold_ratr; | |
1995 | u32 low_rssi_threshold_ratr; | |
1996 | u32 low_rssi_threshold_ratr_40M; | |
1997 | u32 low_rssi_threshold_ratr_20M; | |
1998 | u8 ping_rssi_enable; | |
1999 | u32 ping_rssi_ratr; | |
2000 | u32 ping_rssi_thresh_for_ra; | |
2001 | u32 last_ratr; | |
2002 | u8 PreRATRState; | |
2003 | ||
9be6f10e | 2004 | }; |
d0df2813 | 2005 | enum ratr_table_mode_8192s { |
94a79942 LF |
2006 | RATR_INX_WIRELESS_NGB = 0, |
2007 | RATR_INX_WIRELESS_NG = 1, | |
2008 | RATR_INX_WIRELESS_NB = 2, | |
2009 | RATR_INX_WIRELESS_N = 3, | |
2010 | RATR_INX_WIRELESS_GB = 4, | |
2011 | RATR_INX_WIRELESS_G = 5, | |
2012 | RATR_INX_WIRELESS_B = 6, | |
2013 | RATR_INX_WIRELESS_MC = 7, | |
2014 | RATR_INX_WIRELESS_A = 8, | |
d0df2813 | 2015 | }; |
94a79942 LF |
2016 | |
2017 | #define NUM_PMKID_CACHE 16 | |
74d0497b | 2018 | struct rt_pmkid_list { |
8567829a LF |
2019 | u8 bUsed; |
2020 | u8 Bssid[6]; | |
2021 | u8 PMKID[16]; | |
2022 | u8 SsidBuf[33]; | |
2023 | u8 *ssid_octet; | |
2024 | u16 ssid_length; | |
74d0497b | 2025 | }; |
94a79942 | 2026 | |
ca394055 | 2027 | struct rt_intel_promisc_mode { |
8567829a LF |
2028 | bool bPromiscuousOn; |
2029 | bool bFilterSourceStationFrame; | |
ca394055 | 2030 | }; |
94a79942 LF |
2031 | |
2032 | ||
2033 | /*************** DRIVER STATUS *****/ | |
2034 | #define STATUS_SCANNING 0 | |
2035 | #define STATUS_SCAN_HW 1 | |
2036 | #define STATUS_SCAN_ABORTING 2 | |
2037 | #define STATUS_SETTING_CHAN 3 | |
2038 | /*************** DRIVER STATUS *****/ | |
2039 | ||
2040 | enum { | |
2041 | NO_USE = 0, | |
2042 | USED = 1, | |
8567829a | 2043 | HW_SEC = 2, |
94a79942 LF |
2044 | SW_SEC = 3, |
2045 | }; | |
2046 | ||
2047 | enum { | |
2048 | LPS_IS_WAKE = 0, | |
2049 | LPS_IS_SLEEP = 1, | |
8567829a | 2050 | LPS_WAIT_NULL_DATA_SEND = 2, |
94a79942 LF |
2051 | }; |
2052 | ||
2053 | struct rtllib_device { | |
2054 | struct pci_dev *pdev; | |
2055 | struct net_device *dev; | |
2056 | struct rtllib_security sec; | |
2057 | ||
2058 | bool disable_mgnt_queue; | |
2059 | ||
2060 | unsigned long status; | |
2061 | short hwscan_ch_bk; | |
b678bd1f | 2062 | enum ht_extchnl_offset chan_offset_bk; |
6e579119 | 2063 | enum ht_channel_width bandwidth_bk; |
94a79942 | 2064 | u8 hwscan_sem_up; |
94a79942 LF |
2065 | u8 CntAfterLink; |
2066 | ||
e93e0f6a | 2067 | enum rt_op_mode OpMode; |
94a79942 LF |
2068 | |
2069 | u8 VersionID; | |
2070 | /* The last AssocReq/Resp IEs */ | |
2071 | u8 *assocreq_ies, *assocresp_ies; | |
2072 | size_t assocreq_ies_len, assocresp_ies_len; | |
2073 | ||
2074 | bool b_customer_lenovo_id; | |
2075 | bool bForcedShowRxRate; | |
2076 | bool bForcedShowRateStill; | |
2077 | u8 SystemQueryDataRateCount; | |
2078 | bool bForcedBgMode; | |
2079 | bool bUseRAMask; | |
2080 | bool b1x1RecvCombine; | |
2081 | u8 RF_Type; | |
2082 | bool b1SSSupport; | |
2083 | ||
2084 | u8 hwsec_active; | |
2085 | bool is_silent_reset; | |
8567829a | 2086 | bool force_mic_error; |
94a79942 LF |
2087 | bool is_roaming; |
2088 | bool ieee_up; | |
2089 | bool cannot_notify; | |
2090 | bool bSupportRemoteWakeUp; | |
f6e3d4f4 | 2091 | enum rt_ps_mode dot11PowerSaveMode; |
94a79942 LF |
2092 | bool actscanning; |
2093 | bool FirstIe_InScan; | |
2094 | bool be_scan_inprogress; | |
2095 | bool beinretry; | |
de7c885a | 2096 | enum rt_rf_power_state eRFPowerState; |
94a79942 LF |
2097 | RT_RF_CHANGE_SOURCE RfOffReason; |
2098 | bool is_set_key; | |
2099 | bool wx_set_enc; | |
7796d93e | 2100 | struct rt_hi_throughput *pHTInfo; |
94a79942 LF |
2101 | spinlock_t bw_spinlock; |
2102 | ||
2103 | spinlock_t reorder_spinlock; | |
2104 | u8 Regdot11HTOperationalRateSet[16]; | |
2105 | u8 Regdot11TxHTOperationalRateSet[16]; | |
2106 | u8 dot11HTOperationalRateSet[16]; | |
2107 | u8 RegHTSuppRateSet[16]; | |
8567829a LF |
2108 | u8 HTCurrentOperaRate; |
2109 | u8 HTHighestOperaRate; | |
2110 | u8 MinSpaceCfg; | |
2111 | u8 MaxMssDensity; | |
94a79942 LF |
2112 | u8 bTxDisableRateFallBack; |
2113 | u8 bTxUseDriverAssingedRate; | |
2114 | u8 bTxEnableFwCalcDur; | |
2115 | atomic_t atm_chnlop; | |
2116 | atomic_t atm_swbw; | |
2117 | ||
2118 | struct list_head Tx_TS_Admit_List; | |
2119 | struct list_head Tx_TS_Pending_List; | |
2120 | struct list_head Tx_TS_Unused_List; | |
60554f2b | 2121 | struct tx_ts_record TxTsRecord[TOTAL_TS_NUM]; |
94a79942 LF |
2122 | struct list_head Rx_TS_Admit_List; |
2123 | struct list_head Rx_TS_Pending_List; | |
2124 | struct list_head Rx_TS_Unused_List; | |
2c47ae28 | 2125 | struct rx_ts_record RxTsRecord[TOTAL_TS_NUM]; |
8cba1432 | 2126 | struct rx_reorder_entry RxReorderEntry[128]; |
94a79942 LF |
2127 | struct list_head RxReorder_Unused_List; |
2128 | u8 ForcedPriority; | |
2129 | ||
2130 | ||
2131 | /* Bookkeeping structures */ | |
2132 | struct net_device_stats stats; | |
2133 | struct rtllib_stats ieee_stats; | |
2134 | struct rtllib_softmac_stats softmac_stats; | |
2135 | ||
2136 | /* Probe / Beacon management */ | |
2137 | struct list_head network_free_list; | |
2138 | struct list_head network_list; | |
94a79942 LF |
2139 | struct rtllib_network *networks; |
2140 | int scans; | |
2141 | int scan_age; | |
2142 | ||
2143 | int iw_mode; /* operating mode (IW_MODE_*) */ | |
2144 | bool bNetPromiscuousMode; | |
ca394055 | 2145 | struct rt_intel_promisc_mode IntelPromiscuousModeInfo; |
94a79942 LF |
2146 | |
2147 | struct iw_spy_data spy_data; | |
2148 | ||
2149 | spinlock_t lock; | |
2150 | spinlock_t wpax_suitlist_lock; | |
2151 | ||
2152 | int tx_headroom; /* Set to size of any additional room needed at front | |
2153 | * of allocated Tx SKBs */ | |
2154 | u32 config; | |
2155 | ||
2156 | /* WEP and other encryption related settings at the device level */ | |
2157 | int open_wep; /* Set to 1 to allow unencrypted frames */ | |
2158 | int auth_mode; | |
2159 | int reset_on_keychange; /* Set to 1 if the HW needs to be reset on | |
2160 | * WEP key changes */ | |
2161 | ||
2162 | /* If the host performs {en,de}cryption, then set to 1 */ | |
2163 | int host_encrypt; | |
2164 | int host_encrypt_msdu; | |
2165 | int host_decrypt; | |
8567829a LF |
2166 | /* host performs multicast decryption */ |
2167 | int host_mc_decrypt; | |
94a79942 | 2168 | |
8567829a LF |
2169 | /* host should strip IV and ICV from protected frames */ |
2170 | /* meaningful only when hardware decryption is being used */ | |
2171 | int host_strip_iv_icv; | |
94a79942 | 2172 | |
8567829a LF |
2173 | int host_open_frag; |
2174 | int host_build_iv; | |
94a79942 LF |
2175 | int ieee802_1x; /* is IEEE 802.1X used */ |
2176 | ||
2177 | /* WPA data */ | |
2178 | bool bHalfNMode; | |
2179 | bool bHalfWirelessN24GMode; | |
2180 | int wpa_enabled; | |
2181 | int drop_unencrypted; | |
2182 | int tkip_countermeasures; | |
2183 | int privacy_invoked; | |
2184 | size_t wpa_ie_len; | |
2185 | u8 *wpa_ie; | |
2186 | size_t wps_ie_len; | |
2187 | u8 *wps_ie; | |
2188 | u8 ap_mac_addr[6]; | |
2189 | u16 pairwise_key_type; | |
2190 | u16 group_key_type; | |
2191 | struct list_head crypt_deinit_list; | |
184f1938 | 2192 | struct rtllib_crypt_data *crypt[NUM_WEP_KEYS]; |
94a79942 LF |
2193 | |
2194 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ | |
5ea04480 | 2195 | struct sw_cam_table swcamtable[TOTAL_CAM_ENTRY]; |
94a79942 | 2196 | struct timer_list crypt_deinit_timer; |
8567829a | 2197 | int crypt_quiesced; |
94a79942 LF |
2198 | |
2199 | int bcrx_sta_key; /* use individual keys to override default keys even | |
2200 | * with RX of broad/multicast frames */ | |
2201 | ||
74d0497b | 2202 | struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; |
94a79942 LF |
2203 | |
2204 | /* Fragmentation structures */ | |
2205 | struct rtllib_frag_entry frag_cache[17][RTLLIB_FRAG_CACHE_LEN]; | |
2206 | unsigned int frag_next_idx[17]; | |
2207 | u16 fts; /* Fragmentation Threshold */ | |
2208 | #define DEFAULT_RTS_THRESHOLD 2346U | |
2209 | #define MIN_RTS_THRESHOLD 1 | |
2210 | #define MAX_RTS_THRESHOLD 2346U | |
8567829a | 2211 | u16 rts; /* RTS threshold */ |
94a79942 | 2212 | |
8567829a LF |
2213 | /* Association info */ |
2214 | u8 bssid[ETH_ALEN]; | |
94a79942 LF |
2215 | |
2216 | /* This stores infos for the current network. | |
2217 | * Either the network we are associated in INFRASTRUCTURE | |
2218 | * or the network that we are creating in MASTER mode. | |
2219 | * ad-hoc is a mixture ;-). | |
2220 | * Note that in infrastructure mode, even when not associated, | |
2221 | * fields bssid and essid may be valid (if wpa_set and essid_set | |
2222 | * are true) as thy carry the value set by the user via iwconfig | |
2223 | */ | |
2224 | struct rtllib_network current_network; | |
2225 | ||
2226 | enum rtllib_state state; | |
2227 | ||
2228 | int short_slot; | |
2229 | int reg_mode; | |
2230 | int mode; /* A, B, G */ | |
2231 | int modulation; /* CCK, OFDM */ | |
2232 | int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ | |
8567829a | 2233 | int abg_true; /* ABG flag */ |
94a79942 LF |
2234 | |
2235 | /* used for forcing the ibss workqueue to terminate | |
2236 | * without wait for the syncro scan to terminate | |
2237 | */ | |
2238 | short sync_scan_hurryup; | |
2239 | u16 scan_watch_dog; | |
8567829a LF |
2240 | int perfect_rssi; |
2241 | int worst_rssi; | |
94a79942 | 2242 | |
8567829a | 2243 | u16 prev_seq_ctl; /* used to drop duplicate frames */ |
94a79942 LF |
2244 | |
2245 | /* map of allowed channels. 0 is dummy */ | |
8567829a | 2246 | void *pDot11dInfo; |
94a79942 | 2247 | bool bGlobalDomain; |
94a79942 LF |
2248 | u8 active_channel_map[MAX_CHANNEL_NUMBER+1]; |
2249 | ||
2250 | u8 IbssStartChnl; | |
2251 | u8 ibss_maxjoin_chal; | |
2252 | ||
2253 | int rate; /* current rate */ | |
2254 | int basic_rate; | |
2255 | u32 currentRate; | |
2256 | ||
2257 | short active_scan; | |
2258 | ||
2259 | /* this contains flags for selectively enable softmac support */ | |
2260 | u16 softmac_features; | |
2261 | ||
2262 | /* if the sequence control field is not filled by HW */ | |
2263 | u16 seq_ctrl[5]; | |
2264 | ||
2265 | /* association procedure transaction sequence number */ | |
2266 | u16 associate_seq; | |
2267 | ||
2268 | /* AID for RTXed association responses */ | |
2269 | u16 assoc_id; | |
2270 | ||
2271 | /* power save mode related*/ | |
2272 | u8 ack_tx_to_ieee; | |
2273 | short ps; | |
2274 | short sta_sleep; | |
2275 | int ps_timeout; | |
2276 | int ps_period; | |
2277 | struct tasklet_struct ps_task; | |
0dd56506 | 2278 | u64 ps_time; |
94a79942 LF |
2279 | bool polling; |
2280 | ||
2281 | short raw_tx; | |
2282 | /* used if IEEE_SOFTMAC_TX_QUEUE is set */ | |
2283 | short queue_stop; | |
2284 | short scanning_continue ; | |
2285 | short proto_started; | |
2286 | short proto_stoppping; | |
2287 | ||
2288 | struct semaphore wx_sem; | |
2289 | struct semaphore scan_sem; | |
2290 | struct semaphore ips_sem; | |
2291 | ||
2292 | spinlock_t mgmt_tx_lock; | |
2293 | spinlock_t beacon_lock; | |
2294 | ||
2295 | short beacon_txing; | |
2296 | ||
2297 | short wap_set; | |
2298 | short ssid_set; | |
2299 | ||
2300 | /* set on initialization */ | |
2301 | u8 qos_support; | |
2302 | unsigned int wmm_acm; | |
2303 | ||
2304 | /* for discarding duplicated packets in IBSS */ | |
2305 | struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE]; | |
2306 | ||
2307 | /* for discarding duplicated packets in BSS */ | |
2308 | u16 last_rxseq_num[17]; /* rx seq previous per-tid */ | |
2309 | u16 last_rxfrag_num[17];/* tx frag previous per-tid */ | |
2310 | unsigned long last_packet_time[17]; | |
2311 | ||
2312 | /* for PS mode */ | |
2313 | unsigned long last_rx_ps_time; | |
2314 | bool bAwakePktSent; | |
2315 | u8 LPSDelayCnt; | |
2316 | ||
2317 | /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ | |
2318 | struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; | |
2319 | int mgmt_queue_head; | |
2320 | int mgmt_queue_tail; | |
2321 | #define RTLLIB_QUEUE_LIMIT 128 | |
2322 | u8 AsocRetryCount; | |
2323 | unsigned int hw_header; | |
2324 | struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE]; | |
2325 | struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE]; | |
2326 | struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE]; | |
2327 | u32 sta_edca_param[4]; | |
2328 | bool aggregation; | |
2329 | bool enable_rx_imm_BA; | |
2330 | bool bibsscoordinator; | |
2331 | ||
2332 | bool bdynamic_txpower_enable; | |
2333 | ||
2334 | bool bCTSToSelfEnable; | |
2335 | u8 CTSToSelfTH; | |
2336 | ||
2337 | u32 fsync_time_interval; | |
2338 | u32 fsync_rate_bitmap; | |
2339 | u8 fsync_rssi_threshold; | |
2340 | bool bfsync_enable; | |
2341 | ||
2342 | u8 fsync_multiple_timeinterval; | |
2343 | u32 fsync_firstdiff_ratethreshold; | |
2344 | u32 fsync_seconddiff_ratethreshold; | |
3c093c2b | 2345 | enum fsync_state fsync_state; |
94a79942 | 2346 | bool bis_any_nonbepkts; |
dca0eb1e | 2347 | struct bandwidth_autoswitch bandwidth_auto_switch; |
94a79942 LF |
2348 | bool FwRWRF; |
2349 | ||
0e86753f | 2350 | struct rt_link_detect LinkDetectInfo; |
94a79942 | 2351 | bool bIsAggregateFrame; |
ca990011 | 2352 | struct rt_pwr_save_ctrl PowerSaveControl; |
94a79942 LF |
2353 | u8 amsdu_in_process; |
2354 | ||
2355 | /* used if IEEE_SOFTMAC_TX_QUEUE is set */ | |
0ce60045 | 2356 | struct tx_pending tx_pending; |
94a79942 LF |
2357 | |
2358 | /* used if IEEE_SOFTMAC_ASSOCIATE is set */ | |
2359 | struct timer_list associate_timer; | |
2360 | ||
2361 | /* used if IEEE_SOFTMAC_BEACONS is set */ | |
2362 | struct timer_list beacon_timer; | |
2363 | u8 need_sw_enc; | |
edc4b2c5 LF |
2364 | struct work_struct associate_complete_wq; |
2365 | struct work_struct ips_leave_wq; | |
2366 | struct delayed_work associate_procedure_wq; | |
2367 | struct delayed_work softmac_scan_wq; | |
2368 | struct delayed_work softmac_hint11d_wq; | |
2369 | struct delayed_work associate_retry_wq; | |
2370 | struct delayed_work start_ibss_wq; | |
2371 | struct delayed_work hw_wakeup_wq; | |
2372 | struct delayed_work hw_sleep_wq; | |
2373 | struct delayed_work link_change_wq; | |
2374 | struct work_struct wx_sync_scan_wq; | |
94a79942 LF |
2375 | |
2376 | struct workqueue_struct *wq; | |
2eed3dee LF |
2377 | union { |
2378 | struct rtllib_rxb *RfdArray[REORDER_WIN_SIZE]; | |
2379 | struct rtllib_rxb *stats_IndicateArray[REORDER_WIN_SIZE]; | |
2380 | struct rtllib_rxb *prxbIndicateArray[REORDER_WIN_SIZE]; | |
2381 | struct { | |
2382 | struct sw_chnl_cmd PreCommonCmd[MAX_PRECMD_CNT]; | |
2383 | struct sw_chnl_cmd PostCommonCmd[MAX_POSTCMD_CNT]; | |
2384 | struct sw_chnl_cmd RfDependCmd[MAX_RFDEPENDCMD_CNT]; | |
2385 | }; | |
2386 | }; | |
94a79942 LF |
2387 | |
2388 | /* Callback functions */ | |
2389 | void (*set_security)(struct net_device *dev, | |
2390 | struct rtllib_security *sec); | |
2391 | ||
2392 | /* Used to TX data frame by using txb structs. | |
2393 | * this is not used if in the softmac_features | |
2394 | * is set the flag IEEE_SOFTMAC_TX_QUEUE | |
2395 | */ | |
2396 | int (*hard_start_xmit)(struct rtllib_txb *txb, | |
2397 | struct net_device *dev); | |
2398 | ||
2399 | int (*reset_port)(struct net_device *dev); | |
8567829a | 2400 | int (*is_queue_full)(struct net_device *dev, int pri); |
94a79942 | 2401 | |
8567829a LF |
2402 | int (*handle_management)(struct net_device *dev, |
2403 | struct rtllib_network *network, u16 type); | |
2404 | int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); | |
94a79942 LF |
2405 | |
2406 | /* Softmac-generated frames (mamagement) are TXed via this | |
2407 | * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is | |
2408 | * not set. As some cards may have different HW queues that | |
2409 | * one might want to use for data and management frames | |
2410 | * the option to have two callbacks might be useful. | |
2411 | * This fucntion can't sleep. | |
2412 | */ | |
2413 | int (*softmac_hard_start_xmit)(struct sk_buff *skb, | |
2414 | struct net_device *dev); | |
2415 | ||
2416 | /* used instead of hard_start_xmit (not softmac_hard_start_xmit) | |
2417 | * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data | |
2418 | * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set | |
2419 | * then also management frames are sent via this callback. | |
2420 | * This function can't sleep. | |
2421 | */ | |
2422 | void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, | |
8567829a | 2423 | struct net_device *dev, int rate); |
94a79942 LF |
2424 | |
2425 | /* stops the HW queue for DATA frames. Useful to avoid | |
2426 | * waste time to TX data frame when we are reassociating | |
2427 | * This function can sleep. | |
2428 | */ | |
2429 | void (*data_hard_stop)(struct net_device *dev); | |
2430 | ||
2431 | /* OK this is complementar to data_poll_hard_stop */ | |
2432 | void (*data_hard_resume)(struct net_device *dev); | |
2433 | ||
2434 | /* ask to the driver to retune the radio . | |
2435 | * This function can sleep. the driver should ensure | |
2436 | * the radio has been swithced before return. | |
2437 | */ | |
8567829a | 2438 | void (*set_chan)(struct net_device *dev, short ch); |
94a79942 LF |
2439 | |
2440 | /* These are not used if the ieee stack takes care of | |
2441 | * scanning (IEEE_SOFTMAC_SCAN feature set). | |
2442 | * In this case only the set_chan is used. | |
2443 | * | |
2444 | * The syncro version is similar to the start_scan but | |
2445 | * does not return until all channels has been scanned. | |
2446 | * this is called in user context and should sleep, | |
2447 | * it is called in a work_queue when swithcing to ad-hoc mode | |
2448 | * or in behalf of iwlist scan when the card is associated | |
2449 | * and root user ask for a scan. | |
2450 | * the fucntion stop_scan should stop both the syncro and | |
2451 | * background scanning and can sleep. | |
2452 | * The fucntion start_scan should initiate the background | |
2453 | * scanning and can't sleep. | |
2454 | */ | |
2455 | void (*scan_syncro)(struct net_device *dev); | |
2456 | void (*start_scan)(struct net_device *dev); | |
2457 | void (*stop_scan)(struct net_device *dev); | |
2458 | ||
2459 | void (*rtllib_start_hw_scan)(struct net_device *dev); | |
2460 | void (*rtllib_stop_hw_scan)(struct net_device *dev); | |
2461 | ||
2462 | /* indicate the driver that the link state is changed | |
2463 | * for example it may indicate the card is associated now. | |
2464 | * Driver might be interested in this to apply RX filter | |
2465 | * rules or simply light the LINK led | |
2466 | */ | |
2467 | void (*link_change)(struct net_device *dev); | |
2468 | ||
2469 | /* these two function indicates to the HW when to start | |
2470 | * and stop to send beacons. This is used when the | |
2471 | * IEEE_SOFTMAC_BEACONS is not set. For now the | |
2472 | * stop_send_bacons is NOT guaranteed to be called only | |
2473 | * after start_send_beacons. | |
2474 | */ | |
8567829a LF |
2475 | void (*start_send_beacons)(struct net_device *dev); |
2476 | void (*stop_send_beacons)(struct net_device *dev); | |
94a79942 LF |
2477 | |
2478 | /* power save mode related */ | |
8567829a LF |
2479 | void (*sta_wake_up)(struct net_device *dev); |
2480 | void (*enter_sleep_state)(struct net_device *dev, u64 time); | |
2481 | short (*ps_is_queue_empty)(struct net_device *dev); | |
2482 | int (*handle_beacon)(struct net_device *dev, | |
2483 | struct rtllib_beacon *beacon, | |
2484 | struct rtllib_network *network); | |
2485 | int (*handle_assoc_response)(struct net_device *dev, | |
2486 | struct rtllib_assoc_response_frame *resp, | |
2487 | struct rtllib_network *network); | |
94a79942 LF |
2488 | |
2489 | ||
2490 | /* check whether Tx hw resouce available */ | |
2491 | short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); | |
2492 | short (*get_nic_desc_num)(struct net_device *dev, int queue_index); | |
8567829a LF |
2493 | void (*SetBWModeHandler)(struct net_device *dev, |
2494 | enum ht_channel_width Bandwidth, | |
2495 | enum ht_extchnl_offset Offset); | |
2496 | bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); | |
2497 | void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); | |
2498 | bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); | |
94a79942 LF |
2499 | u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); |
2500 | void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value); | |
2501 | void (*InitialGainHandler)(struct net_device *dev, u8 Operation); | |
8567829a LF |
2502 | bool (*SetFwCmdHandler)(struct net_device *dev, |
2503 | enum fw_cmd_io_type FwCmdIO); | |
2504 | void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast, | |
2505 | u8 macId, u8 MimoPs, u8 WirelessMode, | |
2506 | u8 bCurTxBW40MHz, u8 rssi_level); | |
2507 | void (*UpdateBeaconInterruptHandler)(struct net_device *dev, | |
2508 | bool start); | |
2509 | void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR, | |
2510 | u32 RemoveMSR); | |
94a79942 | 2511 | u16 (*rtl_11n_user_show_rates)(struct net_device *dev); |
8567829a LF |
2512 | void (*ScanOperationBackupHandler)(struct net_device *dev, |
2513 | u8 Operation); | |
2514 | void (*LedControlHandler)(struct net_device *dev, | |
2515 | enum led_ctl_mode LedAction); | |
2516 | void (*SetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); | |
2517 | void (*GetHwRegHandler)(struct net_device *dev, u8 variable, u8 *val); | |
2518 | ||
2519 | void (*AllowAllDestAddrHandler)(struct net_device *dev, | |
2520 | bool bAllowAllDA, bool WriteIntoReg); | |
2521 | ||
2522 | void (*rtllib_ips_leave_wq) (struct net_device *dev); | |
2523 | void (*rtllib_ips_leave)(struct net_device *dev); | |
94a79942 LF |
2524 | void (*LeisurePSLeave)(struct net_device *dev); |
2525 | void (*rtllib_rfkill_poll)(struct net_device *dev); | |
2526 | ||
2527 | /* This must be the last item so that it points to the data | |
2528 | * allocated beyond this structure by alloc_rtllib */ | |
2529 | u8 priv[0]; | |
2530 | }; | |
2531 | ||
8567829a LF |
2532 | #define IEEE_A (1<<0) |
2533 | #define IEEE_B (1<<1) | |
2534 | #define IEEE_G (1<<2) | |
94a79942 LF |
2535 | #define IEEE_N_24G (1<<4) |
2536 | #define IEEE_N_5G (1<<5) | |
2537 | #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) | |
2538 | ||
2539 | /* Generate a 802.11 header */ | |
2540 | ||
2541 | /* Uses the channel change callback directly | |
2542 | * instead of [start/stop] scan callbacks | |
2543 | */ | |
2544 | #define IEEE_SOFTMAC_SCAN (1<<2) | |
2545 | ||
2546 | /* Perform authentication and association handshake */ | |
2547 | #define IEEE_SOFTMAC_ASSOCIATE (1<<3) | |
2548 | ||
2549 | /* Generate probe requests */ | |
2550 | #define IEEE_SOFTMAC_PROBERQ (1<<4) | |
2551 | ||
2552 | /* Generate respones to probe requests */ | |
2553 | #define IEEE_SOFTMAC_PROBERS (1<<5) | |
2554 | ||
2555 | /* The ieee802.11 stack will manages the netif queue | |
2556 | * wake/stop for the driver, taking care of 802.11 | |
2557 | * fragmentation. See softmac.c for details. */ | |
2558 | #define IEEE_SOFTMAC_TX_QUEUE (1<<7) | |
2559 | ||
2560 | /* Uses only the softmac_data_hard_start_xmit | |
2561 | * even for TX management frames. | |
2562 | */ | |
2563 | #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8) | |
2564 | ||
2565 | /* Generate beacons. The stack will enqueue beacons | |
2566 | * to the card | |
2567 | */ | |
2568 | #define IEEE_SOFTMAC_BEACONS (1<<6) | |
2569 | ||
2570 | ||
2571 | static inline void *rtllib_priv(struct net_device *dev) | |
2572 | { | |
2573 | return ((struct rtllib_device *)netdev_priv(dev))->priv; | |
2574 | } | |
2575 | ||
2576 | extern inline int rtllib_is_empty_essid(const char *essid, int essid_len) | |
2577 | { | |
2578 | /* Single white space is for Linksys APs */ | |
2579 | if (essid_len == 1 && essid[0] == ' ') | |
2580 | return 1; | |
2581 | ||
2582 | /* Otherwise, if the entire essid is 0, we assume it is hidden */ | |
2583 | while (essid_len) { | |
2584 | essid_len--; | |
2585 | if (essid[essid_len] != '\0') | |
2586 | return 0; | |
2587 | } | |
2588 | ||
2589 | return 1; | |
2590 | } | |
2591 | ||
2592 | extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode) | |
2593 | { | |
2594 | /* | |
2595 | * It is possible for both access points and our device to support | |
2596 | * combinations of modes, so as long as there is one valid combination | |
2597 | * of ap/device supported modes, then return success | |
2598 | * | |
2599 | */ | |
2600 | if ((mode & IEEE_A) && | |
2601 | (ieee->modulation & RTLLIB_OFDM_MODULATION) && | |
2602 | (ieee->freq_band & RTLLIB_52GHZ_BAND)) | |
2603 | return 1; | |
2604 | ||
2605 | if ((mode & IEEE_G) && | |
2606 | (ieee->modulation & RTLLIB_OFDM_MODULATION) && | |
2607 | (ieee->freq_band & RTLLIB_24GHZ_BAND)) | |
2608 | return 1; | |
2609 | ||
2610 | if ((mode & IEEE_B) && | |
2611 | (ieee->modulation & RTLLIB_CCK_MODULATION) && | |
2612 | (ieee->freq_band & RTLLIB_24GHZ_BAND)) | |
2613 | return 1; | |
2614 | ||
2615 | return 0; | |
2616 | } | |
2617 | ||
2618 | extern inline int rtllib_get_hdrlen(u16 fc) | |
2619 | { | |
2620 | int hdrlen = RTLLIB_3ADDR_LEN; | |
2621 | ||
2622 | switch (WLAN_FC_GET_TYPE(fc)) { | |
2623 | case RTLLIB_FTYPE_DATA: | |
2624 | if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS)) | |
2625 | hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */ | |
2626 | if (RTLLIB_QOS_HAS_SEQ(fc)) | |
2627 | hdrlen += 2; /* QOS ctrl*/ | |
2628 | break; | |
2629 | case RTLLIB_FTYPE_CTL: | |
2630 | switch (WLAN_FC_GET_STYPE(fc)) { | |
2631 | case RTLLIB_STYPE_CTS: | |
2632 | case RTLLIB_STYPE_ACK: | |
2633 | hdrlen = RTLLIB_1ADDR_LEN; | |
2634 | break; | |
2635 | default: | |
2636 | hdrlen = RTLLIB_2ADDR_LEN; | |
2637 | break; | |
2638 | } | |
2639 | break; | |
2640 | } | |
2641 | ||
2642 | return hdrlen; | |
2643 | } | |
2644 | ||
2645 | static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr) | |
2646 | { | |
8567829a LF |
2647 | switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { |
2648 | case RTLLIB_1ADDR_LEN: | |
2649 | return ((struct rtllib_hdr_1addr *)hdr)->payload; | |
2650 | case RTLLIB_2ADDR_LEN: | |
2651 | return ((struct rtllib_hdr_2addr *)hdr)->payload; | |
2652 | case RTLLIB_3ADDR_LEN: | |
2653 | return ((struct rtllib_hdr_3addr *)hdr)->payload; | |
2654 | case RTLLIB_4ADDR_LEN: | |
2655 | return ((struct rtllib_hdr_4addr *)hdr)->payload; | |
2656 | } | |
2657 | return NULL; | |
94a79942 LF |
2658 | } |
2659 | ||
2660 | static inline int rtllib_is_ofdm_rate(u8 rate) | |
2661 | { | |
8567829a LF |
2662 | switch (rate & ~RTLLIB_BASIC_RATE_MASK) { |
2663 | case RTLLIB_OFDM_RATE_6MB: | |
2664 | case RTLLIB_OFDM_RATE_9MB: | |
2665 | case RTLLIB_OFDM_RATE_12MB: | |
2666 | case RTLLIB_OFDM_RATE_18MB: | |
2667 | case RTLLIB_OFDM_RATE_24MB: | |
2668 | case RTLLIB_OFDM_RATE_36MB: | |
2669 | case RTLLIB_OFDM_RATE_48MB: | |
2670 | case RTLLIB_OFDM_RATE_54MB: | |
2671 | return 1; | |
2672 | } | |
2673 | return 0; | |
94a79942 LF |
2674 | } |
2675 | ||
2676 | static inline int rtllib_is_cck_rate(u8 rate) | |
2677 | { | |
8567829a LF |
2678 | switch (rate & ~RTLLIB_BASIC_RATE_MASK) { |
2679 | case RTLLIB_CCK_RATE_1MB: | |
2680 | case RTLLIB_CCK_RATE_2MB: | |
2681 | case RTLLIB_CCK_RATE_5MB: | |
2682 | case RTLLIB_CCK_RATE_11MB: | |
2683 | return 1; | |
2684 | } | |
2685 | return 0; | |
94a79942 LF |
2686 | } |
2687 | ||
2688 | ||
94a79942 LF |
2689 | /* rtllib.c */ |
2690 | extern void free_rtllib(struct net_device *dev); | |
2691 | extern struct net_device *alloc_rtllib(int sizeof_priv); | |
2692 | ||
2693 | extern int rtllib_set_encryption(struct rtllib_device *ieee); | |
2694 | ||
2695 | /* rtllib_tx.c */ | |
2696 | ||
2697 | extern int rtllib_encrypt_fragment( | |
2698 | struct rtllib_device *ieee, | |
2699 | struct sk_buff *frag, | |
2700 | int hdr_len); | |
2701 | ||
2702 | extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev); | |
2703 | extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev); | |
2704 | extern void rtllib_txb_free(struct rtllib_txb *); | |
2705 | ||
2706 | /* rtllib_rx.c */ | |
2707 | extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb, | |
2708 | struct rtllib_rx_stats *rx_stats); | |
2709 | extern void rtllib_rx_mgt(struct rtllib_device *ieee, | |
2710 | struct sk_buff *skb, | |
2711 | struct rtllib_rx_stats *stats); | |
2712 | extern void rtllib_rx_probe_rq(struct rtllib_device *ieee, | |
8567829a | 2713 | struct sk_buff *skb); |
976d5341 | 2714 | extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel); |
94a79942 LF |
2715 | |
2716 | /* rtllib_wx.c */ | |
2717 | extern int rtllib_wx_get_scan(struct rtllib_device *ieee, | |
2718 | struct iw_request_info *info, | |
2719 | union iwreq_data *wrqu, char *key); | |
2720 | extern int rtllib_wx_set_encode(struct rtllib_device *ieee, | |
2721 | struct iw_request_info *info, | |
2722 | union iwreq_data *wrqu, char *key); | |
2723 | extern int rtllib_wx_get_encode(struct rtllib_device *ieee, | |
2724 | struct iw_request_info *info, | |
2725 | union iwreq_data *wrqu, char *key); | |
2726 | #if WIRELESS_EXT >= 18 | |
2727 | extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee, | |
8567829a LF |
2728 | struct iw_request_info *info, |
2729 | union iwreq_data *wrqu, char *extra); | |
94a79942 | 2730 | extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee, |
8567829a LF |
2731 | struct iw_request_info *info, |
2732 | union iwreq_data *wrqu, char *extra); | |
94a79942 LF |
2733 | #endif |
2734 | extern int rtllib_wx_set_auth(struct rtllib_device *ieee, | |
8567829a LF |
2735 | struct iw_request_info *info, |
2736 | struct iw_param *data, char *extra); | |
94a79942 | 2737 | extern int rtllib_wx_set_mlme(struct rtllib_device *ieee, |
8567829a LF |
2738 | struct iw_request_info *info, |
2739 | union iwreq_data *wrqu, char *extra); | |
94a79942 LF |
2740 | extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len); |
2741 | ||
2742 | /* rtllib_softmac.c */ | |
2743 | extern short rtllib_is_54g(struct rtllib_network *net); | |
6f03053b | 2744 | extern short rtllib_is_shortslot(const struct rtllib_network *net); |
8567829a LF |
2745 | extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee, |
2746 | struct sk_buff *skb, | |
2747 | struct rtllib_rx_stats *rx_stats, u16 type, | |
2748 | u16 stype); | |
2749 | extern void rtllib_softmac_new_net(struct rtllib_device *ieee, | |
2750 | struct rtllib_network *net); | |
94a79942 LF |
2751 | |
2752 | void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); | |
8567829a LF |
2753 | extern void rtllib_softmac_xmit(struct rtllib_txb *txb, |
2754 | struct rtllib_device *ieee); | |
94a79942 LF |
2755 | |
2756 | extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); | |
2757 | extern void notify_wx_assoc_event(struct rtllib_device *ieee); | |
2758 | extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee); | |
2759 | extern void rtllib_start_bss(struct rtllib_device *ieee); | |
2760 | extern void rtllib_start_master_bss(struct rtllib_device *ieee); | |
2761 | extern void rtllib_start_ibss(struct rtllib_device *ieee); | |
2762 | extern void rtllib_softmac_init(struct rtllib_device *ieee); | |
2763 | extern void rtllib_softmac_free(struct rtllib_device *ieee); | |
2764 | extern void rtllib_associate_abort(struct rtllib_device *ieee); | |
2765 | extern void rtllib_disassociate(struct rtllib_device *ieee); | |
2766 | extern void rtllib_stop_scan(struct rtllib_device *ieee); | |
2767 | extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan); | |
2768 | extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee); | |
2769 | extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); | |
2770 | extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee); | |
2771 | extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee); | |
8567829a LF |
2772 | extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, |
2773 | short pwr); | |
94a79942 LF |
2774 | extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl); |
2775 | extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee); | |
2776 | extern void rtllib_check_all_nets(struct rtllib_device *ieee); | |
2777 | extern void rtllib_start_protocol(struct rtllib_device *ieee); | |
2778 | extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown); | |
2779 | ||
8567829a LF |
2780 | extern void rtllib_EnableNetMonitorMode(struct net_device *dev, |
2781 | bool bInitState); | |
2782 | extern void rtllib_DisableNetMonitorMode(struct net_device *dev, | |
2783 | bool bInitState); | |
2784 | extern void rtllib_EnableIntelPromiscuousMode(struct net_device *dev, | |
2785 | bool bInitState); | |
2786 | extern void rtllib_DisableIntelPromiscuousMode(struct net_device *dev, | |
2787 | bool bInitState); | |
94a79942 LF |
2788 | extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh); |
2789 | ||
8567829a LF |
2790 | extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee, |
2791 | u8 mesh_flag, u8 shutdown); | |
2792 | extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee, | |
2793 | u8 mesh_flag); | |
94a79942 LF |
2794 | |
2795 | extern void rtllib_reset_queue(struct rtllib_device *ieee); | |
2796 | extern void rtllib_wake_queue(struct rtllib_device *ieee); | |
2797 | extern void rtllib_stop_queue(struct rtllib_device *ieee); | |
2798 | extern void rtllib_wake_all_queues(struct rtllib_device *ieee); | |
2799 | extern void rtllib_stop_all_queues(struct rtllib_device *ieee); | |
2800 | extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee); | |
2801 | extern void rtllib_start_send_beacons(struct rtllib_device *ieee); | |
2802 | extern void rtllib_stop_send_beacons(struct rtllib_device *ieee); | |
8567829a LF |
2803 | extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, |
2804 | struct iw_point *p, u8 is_mesh); | |
94a79942 LF |
2805 | |
2806 | extern void notify_wx_assoc_event(struct rtllib_device *ieee); | |
2807 | extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success); | |
2808 | ||
8567829a LF |
2809 | extern void softmac_mgmt_xmit(struct sk_buff *skb, |
2810 | struct rtllib_device *ieee); | |
2811 | extern u16 rtllib_query_seqnum(struct rtllib_device *ieee, | |
2812 | struct sk_buff *skb, u8 *dst); | |
94a79942 LF |
2813 | extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee); |
2814 | ||
2815 | /* rtllib_crypt_ccmp&tkip&wep.c */ | |
2816 | extern void rtllib_tkip_null(void); | |
2817 | extern void rtllib_wep_null(void); | |
2818 | extern void rtllib_ccmp_null(void); | |
2819 | ||
2820 | /* rtllib_softmac_wx.c */ | |
2821 | ||
2822 | extern int rtllib_wx_get_wap(struct rtllib_device *ieee, | |
8567829a LF |
2823 | struct iw_request_info *info, |
2824 | union iwreq_data *wrqu, char *ext); | |
94a79942 LF |
2825 | |
2826 | extern int rtllib_wx_set_wap(struct rtllib_device *ieee, | |
8567829a LF |
2827 | struct iw_request_info *info, |
2828 | union iwreq_data *awrq, | |
2829 | char *extra); | |
94a79942 | 2830 | |
8567829a LF |
2831 | extern int rtllib_wx_get_essid(struct rtllib_device *ieee, |
2832 | struct iw_request_info *a, | |
2833 | union iwreq_data *wrqu, char *b); | |
94a79942 LF |
2834 | |
2835 | extern int rtllib_wx_set_rate(struct rtllib_device *ieee, | |
8567829a LF |
2836 | struct iw_request_info *info, |
2837 | union iwreq_data *wrqu, char *extra); | |
94a79942 LF |
2838 | |
2839 | extern int rtllib_wx_get_rate(struct rtllib_device *ieee, | |
8567829a LF |
2840 | struct iw_request_info *info, |
2841 | union iwreq_data *wrqu, char *extra); | |
94a79942 | 2842 | |
8567829a LF |
2843 | extern int rtllib_wx_set_mode(struct rtllib_device *ieee, |
2844 | struct iw_request_info *a, | |
2845 | union iwreq_data *wrqu, char *b); | |
94a79942 | 2846 | |
8567829a LF |
2847 | extern int rtllib_wx_set_scan(struct rtllib_device *ieee, |
2848 | struct iw_request_info *a, | |
2849 | union iwreq_data *wrqu, char *b); | |
94a79942 LF |
2850 | |
2851 | extern int rtllib_wx_set_essid(struct rtllib_device *ieee, | |
2852 | struct iw_request_info *a, | |
2853 | union iwreq_data *wrqu, char *extra); | |
2854 | ||
8567829a LF |
2855 | extern int rtllib_wx_get_mode(struct rtllib_device *ieee, |
2856 | struct iw_request_info *a, | |
2857 | union iwreq_data *wrqu, char *b); | |
94a79942 | 2858 | |
8567829a LF |
2859 | extern int rtllib_wx_set_freq(struct rtllib_device *ieee, |
2860 | struct iw_request_info *a, | |
2861 | union iwreq_data *wrqu, char *b); | |
94a79942 | 2862 | |
8567829a LF |
2863 | extern int rtllib_wx_get_freq(struct rtllib_device *ieee, |
2864 | struct iw_request_info *a, | |
2865 | union iwreq_data *wrqu, char *b); | |
94a79942 LF |
2866 | extern void rtllib_wx_sync_scan_wq(void *data); |
2867 | ||
2868 | extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee, | |
2869 | struct iw_request_info *info, | |
2870 | union iwreq_data *wrqu, char *extra); | |
2871 | ||
2872 | extern int rtllib_wx_get_name(struct rtllib_device *ieee, | |
2873 | struct iw_request_info *info, | |
2874 | union iwreq_data *wrqu, char *extra); | |
2875 | ||
2876 | extern int rtllib_wx_set_power(struct rtllib_device *ieee, | |
2877 | struct iw_request_info *info, | |
2878 | union iwreq_data *wrqu, char *extra); | |
2879 | ||
2880 | extern int rtllib_wx_get_power(struct rtllib_device *ieee, | |
2881 | struct iw_request_info *info, | |
2882 | union iwreq_data *wrqu, char *extra); | |
2883 | ||
2884 | extern int rtllib_wx_set_rts(struct rtllib_device *ieee, | |
2885 | struct iw_request_info *info, | |
2886 | union iwreq_data *wrqu, char *extra); | |
2887 | ||
2888 | extern int rtllib_wx_get_rts(struct rtllib_device *ieee, | |
2889 | struct iw_request_info *info, | |
2890 | union iwreq_data *wrqu, char *extra); | |
2891 | #define MAX_RECEIVE_BUFFER_SIZE 9100 | |
8567829a LF |
2892 | extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); |
2893 | extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); | |
2894 | ||
2895 | void HTSetConnectBwMode(struct rtllib_device *ieee, | |
2896 | enum ht_channel_width Bandwidth, | |
2897 | enum ht_extchnl_offset Offset); | |
2898 | extern void HTUpdateDefaultSetting(struct rtllib_device *ieee); | |
2899 | extern void HTConstructCapabilityElement(struct rtllib_device *ieee, | |
2900 | u8 *posHTCap, u8 *len, | |
2901 | u8 isEncrypt, bool bAssoc); | |
2902 | extern void HTConstructInfoElement(struct rtllib_device *ieee, | |
2903 | u8 *posHTInfo, u8 *len, u8 isEncrypt); | |
2904 | extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee, | |
2905 | u8 *posRT2RTAgg, u8* len); | |
94a79942 | 2906 | extern void HTOnAssocRsp(struct rtllib_device *ieee); |
8567829a | 2907 | extern void HTInitializeHTInfo(struct rtllib_device *ieee); |
a15e76ad | 2908 | extern void HTInitializeBssDesc(struct bss_ht *pBssHT); |
8567829a LF |
2909 | extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee, |
2910 | struct rtllib_network *pNetwork); | |
976d5341 SM |
2911 | extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee, |
2912 | struct rtllib_network *pNetwork); | |
8567829a LF |
2913 | extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet, |
2914 | u8 *pMCSFilter); | |
94a79942 LF |
2915 | extern u8 MCS_FILTER_ALL[]; |
2916 | extern u16 MCS_DATA_RATE[2][2][77] ; | |
8567829a | 2917 | extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame); |
7796d93e | 2918 | extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo); |
8567829a LF |
2919 | extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee); |
2920 | extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); | |
2921 | extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate); | |
2922 | extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate); | |
2923 | extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb); | |
2924 | extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb); | |
2925 | extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb); | |
2926 | extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS, | |
2927 | u8 Policy, u8 bOverwritePending); | |
2928 | extern void TsInitDelBA(struct rtllib_device *ieee, | |
2929 | struct ts_common_info *pTsCommonInfo, | |
2930 | enum tr_select TxRxSelect); | |
94a79942 LF |
2931 | extern void BaSetupTimeOut(unsigned long data); |
2932 | extern void TxBaInactTimeout(unsigned long data); | |
2933 | extern void RxBaInactTimeout(unsigned long data); | |
8567829a | 2934 | extern void ResetBaEntry(struct ba_record *pBA); |
94a79942 | 2935 | extern bool GetTs( |
8567829a LF |
2936 | struct rtllib_device *ieee, |
2937 | struct ts_common_info **ppTS, | |
2938 | u8 *Addr, | |
2939 | u8 TID, | |
2940 | enum tr_select TxRxSelect, | |
2941 | bool bAddNewTs | |
2942 | ); | |
94a79942 | 2943 | extern void TSInitialize(struct rtllib_device *ieee); |
8567829a LF |
2944 | extern void TsStartAddBaProcess(struct rtllib_device *ieee, |
2945 | struct tx_ts_record *pTxTS); | |
2946 | extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr); | |
2947 | extern void RemoveAllTS(struct rtllib_device *ieee); | |
94a79942 LF |
2948 | void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh); |
2949 | ||
2950 | extern const long rtllib_wlan_frequencies[]; | |
2951 | ||
2952 | extern inline void rtllib_increment_scans(struct rtllib_device *ieee) | |
2953 | { | |
2954 | ieee->scans++; | |
2955 | } | |
2956 | ||
2957 | extern inline int rtllib_get_scans(struct rtllib_device *ieee) | |
2958 | { | |
2959 | return ieee->scans; | |
2960 | } | |
2961 | ||
8567829a LF |
2962 | static inline const char *escape_essid(const char *essid, u8 essid_len) |
2963 | { | |
94a79942 LF |
2964 | static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; |
2965 | const char *s = essid; | |
2966 | char *d = escaped; | |
2967 | ||
2968 | if (rtllib_is_empty_essid(essid, essid_len)) { | |
2969 | memcpy(escaped, "<hidden>", sizeof("<hidden>")); | |
2970 | return escaped; | |
2971 | } | |
2972 | ||
2973 | essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE); | |
2974 | while (essid_len--) { | |
2975 | if (*s == '\0') { | |
2976 | *d++ = '\\'; | |
2977 | *d++ = '0'; | |
2978 | s++; | |
2979 | } else { | |
2980 | *d++ = *s++; | |
2981 | } | |
2982 | } | |
2983 | *d = '\0'; | |
2984 | return escaped; | |
2985 | } | |
2986 | ||
8567829a LF |
2987 | #define CONVERT_RATE(_ieee, _MGN_RATE) \ |
2988 | ((_MGN_RATE < MGN_MCS0) ? (_MGN_RATE) : \ | |
2989 | (HTMcsToDataRate(_ieee, (u8)_MGN_RATE))) | |
94a79942 LF |
2990 | |
2991 | /* fun with the built-in rtllib stack... */ | |
2992 | int rtllib_init(void); | |
2993 | void rtllib_exit(void); | |
2994 | int rtllib_crypto_init(void); | |
2995 | void rtllib_crypto_deinit(void); | |
2996 | int rtllib_crypto_tkip_init(void); | |
2997 | void rtllib_crypto_tkip_exit(void); | |
2998 | int rtllib_crypto_ccmp_init(void); | |
2999 | void rtllib_crypto_ccmp_exit(void); | |
3000 | int rtllib_crypto_wep_init(void); | |
3001 | void rtllib_crypto_wep_exit(void); | |
3002 | ||
8567829a LF |
3003 | void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib); |
3004 | void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta, | |
3005 | u8 asRsn); | |
3006 | void rtllib_MgntDisconnectAP(struct rtllib_device *rtllib, u8 asRsn); | |
3007 | bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn); | |
94a79942 LF |
3008 | |
3009 | ||
3010 | /* For the function is more related to hardware setting, it's better to use the | |
3011 | * ieee handler to refer to it. | |
3012 | */ | |
3013 | extern void rtllib_update_active_chan_map(struct rtllib_device *ieee); | |
8567829a LF |
3014 | extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, |
3015 | struct rx_ts_record *pTS); | |
94a79942 LF |
3016 | extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev); |
3017 | extern int rtllib_parse_info_param(struct rtllib_device *ieee, | |
3018 | struct rtllib_info_element *info_element, | |
3019 | u16 length, | |
3020 | struct rtllib_network *network, | |
3021 | struct rtllib_rx_stats *stats); | |
3022 | ||
8567829a LF |
3023 | void rtllib_indicate_packets(struct rtllib_device *ieee, |
3024 | struct rtllib_rxb **prxbIndicateArray, u8 index); | |
3025 | extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS, | |
3026 | u8 *pOperateMCS); | |
3027 | extern void HTUseDefaultSetting(struct rtllib_device *ieee); | |
94a79942 LF |
3028 | #define RT_ASOC_RETRY_LIMIT 5 |
3029 | u8 MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee); | |
3030 | extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p); | |
3031 | #ifndef ENABLE_LOCK_DEBUG | |
3032 | #define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags) | |
3033 | #define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags) | |
3034 | #define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags) | |
3035 | #define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags) | |
3036 | #define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags) | |
3037 | #define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags) | |
3038 | #define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags) | |
3039 | #define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags) | |
3040 | #define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags) | |
3041 | #define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags) | |
3042 | #define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags) | |
3043 | #define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags) | |
3044 | #define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags) | |
3045 | #define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags) | |
3046 | #define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags) | |
3047 | #define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags) | |
3048 | #define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags) | |
3049 | #define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags) | |
3050 | #define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags) | |
3051 | #define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags) | |
3052 | #define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags) | |
3053 | #define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags) | |
3054 | #define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags) | |
3055 | #define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags) | |
3056 | #define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags) | |
3057 | #define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags) | |
3058 | #define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags) | |
3059 | #define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags) | |
3060 | #define SEM_DOWN_IEEE_WX(psem) down(psem) | |
3061 | #define SEM_UP_IEEE_WX(psem) up(psem) | |
3062 | #define SEM_DOWN_IEEE_SCAN(psem) down(psem) | |
3063 | #define SEM_UP_IEEE_SCAN(psem) up(psem) | |
3064 | #define SEM_DOWN_IEEE_IPS(psem) down(psem) | |
3065 | #define SEM_UP_IEEE_IPS(psem) up(psem) | |
3066 | #define SEM_DOWN_PRIV_WX(psem) down(psem) | |
3067 | #define SEM_UP_PRIV_WX(psem) up(psem) | |
3068 | #define SEM_DOWN_PRIV_RF(psem) down(psem) | |
3069 | #define SEM_UP_PRIV_RF(psem) up(psem) | |
3070 | #define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex) | |
3071 | #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex) | |
3072 | #endif | |
3073 | static inline void dump_buf(u8 *buf, u32 len) | |
3074 | { | |
3075 | u32 i; | |
8567829a LF |
3076 | printk(KERN_INFO "-----------------Len %d----------------\n", len); |
3077 | for (i = 0; i < len; i++) | |
94a79942 LF |
3078 | printk("%2.2x-", *(buf+i)); |
3079 | printk("\n"); | |
3080 | } | |
3081 | #endif /* RTLLIB_H */ |