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