]>
Commit | Line | Data |
---|---|---|
92b96797 FB |
1 | /* |
2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | * | |
19 | * File: device.h | |
20 | * | |
21 | * Purpose: MAC Data structure | |
22 | * | |
23 | * Author: Tevin Chen | |
24 | * | |
25 | * Date: Mar 17, 1997 | |
26 | * | |
27 | */ | |
28 | ||
29 | #ifndef __DEVICE_H__ | |
30 | #define __DEVICE_H__ | |
31 | ||
92b96797 | 32 | #include <linux/module.h> |
92b96797 | 33 | #include <linux/kernel.h> |
92b96797 | 34 | #include <linux/slab.h> |
11d404cb MP |
35 | #include <linux/delay.h> |
36 | #include <linux/device.h> | |
37 | #include <linux/firmware.h> | |
38 | #include <linux/etherdevice.h> | |
39 | #include <linux/suspend.h> | |
92b96797 | 40 | #include <linux/if_arp.h> |
11d404cb MP |
41 | #include <linux/wireless.h> |
42 | #include <net/iw_handler.h> | |
43 | #include <net/cfg80211.h> | |
44 | #include <linux/timer.h> | |
92b96797 | 45 | #include <linux/usb.h> |
f0fde117 | 46 | #include <linux/crc32.h> |
63b9907f | 47 | #include <net/mac80211.h> |
11d404cb | 48 | |
92b96797 FB |
49 | #ifdef SIOCETHTOOL |
50 | #define DEVICE_ETHTOOL_IOCTL_SUPPORT | |
51 | #include <linux/ethtool.h> | |
52 | #else | |
53 | #undef DEVICE_ETHTOOL_IOCTL_SUPPORT | |
54 | #endif | |
92b96797 | 55 | |
4aeaf153 MP |
56 | #define MAX_RATE 12 |
57 | ||
d3e23951 AM |
58 | /* |
59 | * device specific | |
60 | */ | |
92b96797 | 61 | |
92b96797 | 62 | #include "80211hdr.h" |
92b96797 | 63 | #include "tether.h" |
92b96797 | 64 | #include "wmgr.h" |
92b96797 | 65 | #include "wcmd.h" |
92b96797 | 66 | #include "rc4.h" |
92b96797 | 67 | #include "desc.h" |
92b96797 | 68 | #include "key.h" |
92b96797 | 69 | #include "card.h" |
92b96797 | 70 | |
5008c456 | 71 | #define VNT_USB_VENDOR_ID 0x160a |
92b96797 FB |
72 | #define VNT_USB_PRODUCT_ID 0x3184 |
73 | ||
4aeaf153 MP |
74 | #define DEVICE_NAME "vt6656" |
75 | #define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver" | |
76 | ||
77 | #define DEVICE_VERSION "1.19_12" | |
78 | ||
79 | #define CONFIG_PATH "/etc/vntconfiguration.dat" | |
80 | ||
81 | #define MAX_UINTS 8 | |
82 | #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} | |
83 | ||
92b96797 FB |
84 | #define DUPLICATE_RX_CACHE_LENGTH 5 |
85 | ||
92b96797 FB |
86 | #define AUTO_FB_NONE 0 |
87 | #define AUTO_FB_0 1 | |
88 | #define AUTO_FB_1 2 | |
89 | ||
90 | #define FB_RATE0 0 | |
91 | #define FB_RATE1 1 | |
92 | ||
d3e23951 | 93 | /* Antenna Mode */ |
92b96797 FB |
94 | #define ANT_A 0 |
95 | #define ANT_B 1 | |
96 | #define ANT_DIVERSITY 2 | |
97 | #define ANT_RXD_TXA 3 | |
98 | #define ANT_RXD_TXB 4 | |
99 | #define ANT_UNKNOWN 0xFF | |
100 | #define ANT_TXA 0 | |
101 | #define ANT_TXB 1 | |
102 | #define ANT_RXA 2 | |
103 | #define ANT_RXB 3 | |
104 | ||
92b96797 FB |
105 | #define BB_VGA_LEVEL 4 |
106 | #define BB_VGA_CHANGE_THRESHOLD 3 | |
107 | ||
15baf4ff MP |
108 | #define EEP_MAX_CONTEXT_SIZE 256 |
109 | ||
110 | /* Contents in the EEPROM */ | |
111 | #define EEP_OFS_PAR 0x0 | |
112 | #define EEP_OFS_ANTENNA 0x17 | |
113 | #define EEP_OFS_RADIOCTL 0x18 | |
114 | #define EEP_OFS_RFTYPE 0x1b | |
115 | #define EEP_OFS_MINCHANNEL 0x1c | |
116 | #define EEP_OFS_MAXCHANNEL 0x1d | |
117 | #define EEP_OFS_SIGNATURE 0x1e | |
118 | #define EEP_OFS_ZONETYPE 0x1f | |
119 | #define EEP_OFS_RFTABLE 0x20 | |
120 | #define EEP_OFS_PWR_CCK 0x20 | |
121 | #define EEP_OFS_SETPT_CCK 0x21 | |
122 | #define EEP_OFS_PWR_OFDMG 0x23 | |
123 | ||
124 | #define EEP_OFS_CALIB_TX_IQ 0x24 | |
125 | #define EEP_OFS_CALIB_TX_DC 0x25 | |
126 | #define EEP_OFS_CALIB_RX_IQ 0x26 | |
127 | ||
128 | #define EEP_OFS_MAJOR_VER 0x2e | |
129 | #define EEP_OFS_MINOR_VER 0x2f | |
130 | ||
131 | #define EEP_OFS_CCK_PWR_TBL 0x30 | |
132 | #define EEP_OFS_OFDM_PWR_TBL 0x40 | |
133 | #define EEP_OFS_OFDMA_PWR_TBL 0x50 | |
134 | ||
135 | /* Bits in EEP_OFS_ANTENNA */ | |
136 | #define EEP_ANTENNA_MAIN 0x1 | |
137 | #define EEP_ANTENNA_AUX 0x2 | |
138 | #define EEP_ANTINV 0x4 | |
139 | ||
140 | /* Bits in EEP_OFS_RADIOCTL */ | |
141 | #define EEP_RADIOCTL_ENABLE 0x80 | |
142 | ||
60f8ce8d MP |
143 | /* control commands */ |
144 | #define MESSAGE_TYPE_READ 0x1 | |
145 | #define MESSAGE_TYPE_WRITE 0x0 | |
146 | #define MESSAGE_TYPE_LOCK_OR 0x2 | |
147 | #define MESSAGE_TYPE_LOCK_AND 0x3 | |
148 | #define MESSAGE_TYPE_WRITE_MASK 0x4 | |
149 | #define MESSAGE_TYPE_CARDINIT 0x5 | |
150 | #define MESSAGE_TYPE_INIT_RSP 0x6 | |
151 | #define MESSAGE_TYPE_MACSHUTDOWN 0x7 | |
152 | #define MESSAGE_TYPE_SETKEY 0x8 | |
153 | #define MESSAGE_TYPE_CLRKEYENTRY 0x9 | |
154 | #define MESSAGE_TYPE_WRITE_MISCFF 0xa | |
155 | #define MESSAGE_TYPE_SET_ANTMD 0xb | |
156 | #define MESSAGE_TYPE_SELECT_CHANNLE 0xc | |
157 | #define MESSAGE_TYPE_SET_TSFTBTT 0xd | |
158 | #define MESSAGE_TYPE_SET_SSTIFS 0xe | |
159 | #define MESSAGE_TYPE_CHANGE_BBTYPE 0xf | |
160 | #define MESSAGE_TYPE_DISABLE_PS 0x10 | |
161 | #define MESSAGE_TYPE_WRITE_IFRF 0x11 | |
162 | ||
163 | /* command read/write(index) */ | |
164 | #define MESSAGE_REQUEST_MEM 0x1 | |
165 | #define MESSAGE_REQUEST_BBREG 0x2 | |
166 | #define MESSAGE_REQUEST_MACREG 0x3 | |
167 | #define MESSAGE_REQUEST_EEPROM 0x4 | |
168 | #define MESSAGE_REQUEST_TSF 0x5 | |
169 | #define MESSAGE_REQUEST_TBTT 0x6 | |
170 | #define MESSAGE_REQUEST_BBAGC 0x7 | |
171 | #define MESSAGE_REQUEST_VERSION 0x8 | |
172 | #define MESSAGE_REQUEST_RF_INIT 0x9 | |
173 | #define MESSAGE_REQUEST_RF_INIT2 0xa | |
174 | #define MESSAGE_REQUEST_RF_CH0 0xb | |
175 | #define MESSAGE_REQUEST_RF_CH1 0xc | |
176 | #define MESSAGE_REQUEST_RF_CH2 0xd | |
177 | ||
178 | /* USB registers */ | |
179 | #define USB_REG4 0x604 | |
180 | ||
92b96797 FB |
181 | #ifndef RUN_AT |
182 | #define RUN_AT(x) (jiffies+(x)) | |
183 | #endif | |
184 | ||
92b96797 FB |
185 | #define PRIVATE_Message 0 |
186 | ||
d9d1ccb5 AM |
187 | #define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } |
188 | #define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); } | |
92b96797 FB |
189 | |
190 | typedef enum __device_msg_level { | |
d9d1ccb5 AM |
191 | MSG_LEVEL_ERR = 0, /* Errors causing abnormal operation */ |
192 | MSG_LEVEL_NOTICE = 1, /* Errors needing user notification */ | |
193 | MSG_LEVEL_INFO = 2, /* Normal message. */ | |
194 | MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */ | |
195 | MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */ | |
92b96797 FB |
196 | } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL; |
197 | ||
302433da MP |
198 | #define DEVICE_INIT_COLD 0x0 /* cold init */ |
199 | #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */ | |
200 | #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */ | |
92b96797 | 201 | |
60f8ce8d MP |
202 | /* Device init */ |
203 | struct vnt_cmd_card_init { | |
204 | u8 init_class; | |
205 | u8 exist_sw_net_addr; | |
206 | u8 sw_net_addr[6]; | |
207 | u8 short_retry_limit; | |
208 | u8 long_retry_limit; | |
209 | }; | |
210 | ||
211 | struct vnt_rsp_card_init { | |
212 | u8 status; | |
213 | u8 net_addr[6]; | |
214 | u8 rf_type; | |
215 | u8 min_channel; | |
216 | u8 max_channel; | |
217 | }; | |
218 | ||
d3e23951 | 219 | /* USB */ |
92b96797 | 220 | |
d3e23951 AM |
221 | /* |
222 | * Enum of context types for SendPacket | |
223 | */ | |
1450ba62 MP |
224 | enum { |
225 | CONTEXT_DATA_PACKET = 1, | |
226 | CONTEXT_MGMT_PACKET | |
227 | }; | |
92b96797 | 228 | |
d3e23951 | 229 | /* RCB (Receive Control Block) */ |
115cac2e | 230 | struct vnt_rcb { |
dd0a774f MP |
231 | void *Next; |
232 | signed long Ref; | |
233 | void *pDevice; | |
234 | struct urb *pUrb; | |
235 | struct vnt_rx_mgmt sMngPacket; | |
236 | struct sk_buff *skb; | |
237 | int bBoolInUse; | |
115cac2e | 238 | }; |
92b96797 | 239 | |
d3e23951 | 240 | /* used to track bulk out irps */ |
dcdf1d03 | 241 | struct vnt_usb_send_context { |
30a05b39 MP |
242 | void *priv; |
243 | struct sk_buff *skb; | |
244 | struct urb *urb; | |
1622c8fc | 245 | struct ieee80211_hdr *hdr; |
30a05b39 | 246 | unsigned int buf_len; |
1622c8fc | 247 | u16 tx_hdr_size; |
1450ba62 | 248 | u8 type; |
30a05b39 MP |
249 | bool in_use; |
250 | unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; | |
dcdf1d03 | 251 | }; |
92b96797 | 252 | |
51934e7f MP |
253 | /* tx packet info for rxtx */ |
254 | struct vnt_tx_pkt_info { | |
255 | u16 fifo_ctl; | |
256 | u8 dest_addr[ETH_ALEN]; | |
257 | }; | |
258 | ||
213d2e93 AM |
259 | /* structure got from configuration file as user-desired default settings */ |
260 | typedef struct _DEFAULT_CONFIG { | |
261 | signed int ZoneType; | |
262 | signed int eConfigMode; | |
263 | signed int eAuthenMode; /* open/wep/wpa */ | |
264 | signed int bShareKeyAlgorithm; /* open-open/{open,wep}-sharekey */ | |
265 | signed int keyidx; /* wepkey index */ | |
266 | signed int eEncryptionStatus; | |
267 | } DEFAULT_CONFIG, *PDEFAULT_CONFIG; | |
92b96797 | 268 | |
d3e23951 AM |
269 | /* |
270 | * Structure to keep track of USB interrupt packets | |
271 | */ | |
f764e00d MP |
272 | struct vnt_interrupt_buffer { |
273 | u8 *data_buf; | |
274 | bool in_use; | |
275 | }; | |
92b96797 | 276 | |
d3e23951 | 277 | /*++ NDIS related */ |
92b96797 | 278 | |
92b96797 | 279 | typedef enum __DEVICE_NDIS_STATUS { |
d9d1ccb5 | 280 | STATUS_SUCCESS = 0, |
92b96797 FB |
281 | STATUS_FAILURE, |
282 | STATUS_RESOURCES, | |
283 | STATUS_PENDING, | |
284 | } DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS; | |
285 | ||
92b96797 FB |
286 | #define MAX_BSSIDINFO_4_PMKID 16 |
287 | #define MAX_PMKIDLIST 5 | |
d3e23951 | 288 | /* flags for PMKID Candidate list structure */ |
92b96797 FB |
289 | #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 |
290 | ||
d3e23951 | 291 | /* PMKID Structures */ |
cc856e61 | 292 | typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; |
92b96797 | 293 | |
92b96797 FB |
294 | typedef enum _NDIS_802_11_WEP_STATUS |
295 | { | |
296 | Ndis802_11WEPEnabled, | |
297 | Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, | |
298 | Ndis802_11WEPDisabled, | |
299 | Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, | |
300 | Ndis802_11WEPKeyAbsent, | |
301 | Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, | |
302 | Ndis802_11WEPNotSupported, | |
303 | Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, | |
304 | Ndis802_11Encryption2Enabled, | |
305 | Ndis802_11Encryption2KeyAbsent, | |
306 | Ndis802_11Encryption3Enabled, | |
307 | Ndis802_11Encryption3KeyAbsent | |
308 | } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS, | |
309 | NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS; | |
310 | ||
92b96797 FB |
311 | typedef enum _NDIS_802_11_STATUS_TYPE |
312 | { | |
d3e23951 AM |
313 | Ndis802_11StatusType_Authentication, |
314 | Ndis802_11StatusType_MediaStreamMode, | |
315 | Ndis802_11StatusType_PMKID_CandidateList, | |
316 | Ndis802_11StatusTypeMax, /* not a real type, defined as upper bound */ | |
92b96797 FB |
317 | } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE; |
318 | ||
d3e23951 | 319 | /* added new types for PMKID Candidate lists */ |
92b96797 FB |
320 | typedef struct _PMKID_CANDIDATE { |
321 | NDIS_802_11_MAC_ADDRESS BSSID; | |
cc856e61 | 322 | unsigned long Flags; |
92b96797 FB |
323 | } PMKID_CANDIDATE, *PPMKID_CANDIDATE; |
324 | ||
92b96797 FB |
325 | typedef struct _BSSID_INFO |
326 | { | |
327 | NDIS_802_11_MAC_ADDRESS BSSID; | |
328 | NDIS_802_11_PMKID_VALUE PMKID; | |
329 | } BSSID_INFO, *PBSSID_INFO; | |
330 | ||
331 | typedef struct tagSPMKID { | |
cc856e61 AM |
332 | unsigned long Length; |
333 | unsigned long BSSIDInfoCount; | |
92b96797 FB |
334 | BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID]; |
335 | } SPMKID, *PSPMKID; | |
336 | ||
337 | typedef struct tagSPMKIDCandidateEvent { | |
338 | NDIS_802_11_STATUS_TYPE StatusType; | |
cc856e61 AM |
339 | unsigned long Version; /* Version of the structure */ |
340 | unsigned long NumCandidates; /* No. of pmkid candidates */ | |
92b96797 | 341 | PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST]; |
193a823c | 342 | } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; |
92b96797 | 343 | |
d3e23951 | 344 | /* The receive duplicate detection cache entry */ |
92b96797 | 345 | typedef struct tagSCacheEntry{ |
9046db51 MP |
346 | __le16 wFmSequence; |
347 | u8 abyAddr2[ETH_ALEN]; | |
348 | __le16 wFrameCtl; | |
92b96797 FB |
349 | } SCacheEntry, *PSCacheEntry; |
350 | ||
351 | typedef struct tagSCache{ | |
352 | /* The receive cache is updated circularly. The next entry to be written is | |
353 | * indexed by the "InPtr". | |
d3e23951 | 354 | */ |
cc856e61 | 355 | unsigned int uInPtr; /* Place to use next */ |
92b96797 FB |
356 | SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; |
357 | } SCache, *PSCache; | |
358 | ||
359 | #define CB_MAX_RX_FRAG 64 | |
d3e23951 AM |
360 | /* |
361 | * DeFragment Control Block, used for collecting fragments prior to reassembly | |
362 | */ | |
92b96797 FB |
363 | typedef struct tagSDeFragControlBlock |
364 | { | |
3eaca0d2 AM |
365 | u16 wSequence; |
366 | u16 wFragNum; | |
b902fbfe | 367 | u8 abyAddr2[ETH_ALEN]; |
cc856e61 | 368 | unsigned int uLifetime; |
92b96797 | 369 | struct sk_buff* skb; |
b902fbfe | 370 | u8 * pbyRxBuffer; |
cc856e61 | 371 | unsigned int cbFrameLength; |
dfdcc425 | 372 | bool bInUse; |
193a823c | 373 | } SDeFragControlBlock, *PSDeFragControlBlock; |
92b96797 | 374 | |
d3e23951 | 375 | /* flags for options */ |
92b96797 | 376 | #define DEVICE_FLAGS_UNPLUG 0x00000001UL |
92b96797 | 377 | |
d3e23951 | 378 | /* flags for driver status */ |
92b96797 | 379 | #define DEVICE_FLAGS_OPENED 0x00010000UL |
92b96797 | 380 | |
92b96797 | 381 | typedef struct __device_opt { |
d3e23951 AM |
382 | int nRxDescs0; /* number of RX descriptors 0 */ |
383 | int nTxDescs0; /* number of TX descriptors 0, 1, 2, 3 */ | |
384 | int rts_thresh; /* RTS threshold */ | |
92b96797 FB |
385 | int frag_thresh; |
386 | int OpMode; | |
387 | int data_rate; | |
388 | int channel_num; | |
389 | int short_retry; | |
390 | int long_retry; | |
391 | int bbp_type; | |
659770d4 | 392 | u32 flags; |
92b96797 FB |
393 | } OPTIONS, *POPTIONS; |
394 | ||
14c5ef57 | 395 | struct vnt_private { |
63b9907f MP |
396 | /* mac80211 */ |
397 | struct ieee80211_hw *hw; | |
61462ab3 MP |
398 | /* netdev */ |
399 | struct usb_device *usb; | |
400 | struct net_device *dev; | |
401 | struct net_device_stats stats; | |
92b96797 | 402 | |
61462ab3 | 403 | OPTIONS sOpts; |
92b96797 | 404 | |
81d720d3 | 405 | struct work_struct read_work_item; |
a21fc2f5 | 406 | struct work_struct rx_mng_work_item; |
31d5bbf3 | 407 | |
63b9907f MP |
408 | u64 tsf_time; |
409 | u8 rx_rate; | |
410 | ||
61462ab3 MP |
411 | u32 rx_buf_sz; |
412 | int multicast_limit; | |
413 | u8 byRxMode; | |
92b96797 | 414 | |
61462ab3 | 415 | spinlock_t lock; |
c91b1869 | 416 | struct mutex usb_lock; |
92b96797 | 417 | |
61462ab3 | 418 | u32 rx_bytes; |
92b96797 | 419 | |
61462ab3 MP |
420 | u32 flags; |
421 | unsigned long Flags; | |
92b96797 | 422 | |
61462ab3 | 423 | SCache sDupRxCache; |
92b96797 | 424 | |
61462ab3 MP |
425 | SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; |
426 | u32 cbDFCB; | |
427 | u32 cbFreeDFCB; | |
428 | u32 uCurrentDFCBIdx; | |
92b96797 | 429 | |
61462ab3 | 430 | /* USB */ |
61462ab3 | 431 | struct urb *pInterruptURB; |
61462ab3 | 432 | u32 int_interval; |
92b96797 | 433 | |
61462ab3 | 434 | /* Variables to track resources for the BULK In Pipe */ |
115cac2e MP |
435 | struct vnt_rcb *pRCBMem; |
436 | struct vnt_rcb *apRCB[CB_MAX_RX_DESC]; | |
61462ab3 | 437 | u32 cbRD; |
115cac2e MP |
438 | struct vnt_rcb *FirstRecvFreeList; |
439 | struct vnt_rcb *LastRecvFreeList; | |
61462ab3 | 440 | u32 NumRecvFreeList; |
115cac2e MP |
441 | struct vnt_rcb *FirstRecvMngList; |
442 | struct vnt_rcb *LastRecvMngList; | |
61462ab3 MP |
443 | u32 NumRecvMngList; |
444 | int bIsRxWorkItemQueued; | |
445 | int bIsRxMngWorkItemQueued; | |
cc856e61 | 446 | unsigned long ulRcvRefCount; /* packets that have not returned back */ |
92b96797 | 447 | |
61462ab3 | 448 | /* Variables to track resources for the BULK Out Pipe */ |
dcdf1d03 | 449 | struct vnt_usb_send_context *apTD[CB_MAX_TX_DESC]; |
61462ab3 | 450 | u32 cbTD; |
51934e7f | 451 | struct vnt_tx_pkt_info pkt_info[16]; |
92b96797 | 452 | |
61462ab3 | 453 | /* Variables to track resources for the Interrupt In Pipe */ |
f764e00d | 454 | struct vnt_interrupt_buffer int_buf; |
92b96797 | 455 | |
61462ab3 MP |
456 | /* default config from file by user setting */ |
457 | DEFAULT_CONFIG config_file; | |
92b96797 | 458 | |
61462ab3 MP |
459 | /* Version control */ |
460 | u16 wFirmwareVersion; | |
461 | u8 byLocalID; | |
462 | u8 byRFType; | |
463 | u8 byBBRxConf; | |
92b96797 | 464 | |
61462ab3 MP |
465 | u8 byZoneType; |
466 | int bZoneRegExist; | |
92b96797 | 467 | |
61462ab3 | 468 | u8 byOriginalZonetype; |
92b96797 | 469 | |
61462ab3 | 470 | int bLinkPass; /* link status: OK or fail */ |
748bf69c MP |
471 | struct vnt_cmd_card_init init_command; |
472 | struct vnt_rsp_card_init init_response; | |
61462ab3 MP |
473 | u8 abyCurrentNetAddr[ETH_ALEN]; |
474 | u8 abyPermanentNetAddr[ETH_ALEN]; | |
92b96797 | 475 | |
61462ab3 | 476 | int bExistSWNetAddr; |
92b96797 | 477 | |
61462ab3 | 478 | /* Maintain statistical debug info. */ |
61462ab3 MP |
479 | unsigned long SendContextsInUse; |
480 | unsigned long RcvBuffersInUse; | |
92b96797 | 481 | |
14c5ef57 | 482 | /* 802.11 management */ |
4f4a89c9 | 483 | struct vnt_manager vnt_mgmt; |
92b96797 | 484 | |
7c65fa2a | 485 | u64 qwCurrTSF; |
61462ab3 MP |
486 | u32 cbBulkInMax; |
487 | int bPSRxBeacon; | |
488 | ||
489 | /* 802.11 MAC specific */ | |
490 | u32 uCurrRSSI; | |
491 | u8 byCurrSQ; | |
492 | ||
493 | /* Antenna Diversity */ | |
494 | int bTxRxAntInv; | |
495 | u32 dwRxAntennaSel; | |
496 | u32 dwTxAntennaSel; | |
497 | u8 byAntennaCount; | |
498 | u8 byRxAntennaMode; | |
499 | u8 byTxAntennaMode; | |
500 | u8 byRadioCtl; | |
501 | u8 bHWRadioOff; | |
502 | ||
cc856e61 | 503 | /* IFS & Cw */ |
61462ab3 MP |
504 | u32 uSIFS; /* Current SIFS */ |
505 | u32 uDIFS; /* Current DIFS */ | |
506 | u32 uEIFS; /* Current EIFS */ | |
507 | u32 uSlot; /* Current SlotTime */ | |
508 | u32 uCwMin; /* Current CwMin */ | |
509 | u32 uCwMax; /* CwMax is fixed on 1023 */ | |
510 | ||
511 | /* PHY parameter */ | |
512 | u8 bySIFS; | |
513 | u8 byDIFS; | |
514 | u8 byEIFS; | |
515 | u8 bySlot; | |
516 | u8 byCWMaxMin; | |
517 | ||
518 | /* Rate */ | |
a9052bc9 | 519 | u8 byBBType; /* 0: 11A, 1:11B, 2:11G */ |
bf1c820f | 520 | u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */ |
61462ab3 | 521 | u16 wBasicRate; |
61462ab3 MP |
522 | u8 byTopOFDMBasicRate; |
523 | u8 byTopCCKBasicRate; | |
524 | ||
61462ab3 MP |
525 | u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */ |
526 | ||
527 | u8 byMinChannel; | |
528 | u8 byMaxChannel; | |
529 | u32 uConnectionRate; | |
530 | ||
531 | u8 byPreambleType; | |
532 | u8 byShortPreamble; | |
533 | /* CARD_PHY_TYPE */ | |
534 | u8 eConfigPHYMode; | |
535 | ||
536 | /* For RF Power table */ | |
537 | u8 byCCKPwr; | |
538 | u8 byOFDMPwrG; | |
539 | u8 byOFDMPwrA; | |
540 | u8 byCurPwr; | |
541 | u8 abyCCKPwrTbl[14]; | |
542 | u8 abyOFDMPwrTbl[14]; | |
543 | u8 abyOFDMAPwrTbl[42]; | |
544 | ||
545 | u16 wCurrentRate; | |
f84cdf65 MP |
546 | u16 tx_rate_fb0; |
547 | u16 tx_rate_fb1; | |
548 | ||
61462ab3 MP |
549 | u16 wRTSThreshold; |
550 | u16 wFragmentationThreshold; | |
551 | u8 byShortRetryLimit; | |
552 | u8 byLongRetryLimit; | |
a0ad2776 MP |
553 | |
554 | enum nl80211_iftype op_mode; | |
555 | ||
61462ab3 MP |
556 | int bBSSIDFilter; |
557 | u16 wMaxTransmitMSDULifetime; | |
558 | u8 abyBSSID[ETH_ALEN]; | |
559 | u8 abyDesireBSSID[ETH_ALEN]; | |
560 | ||
61462ab3 MP |
561 | u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ |
562 | ||
61462ab3 | 563 | int bEncryptionEnable; |
61462ab3 MP |
564 | int bShortSlotTime; |
565 | int bProtectMode; | |
566 | int bNonERPPresent; | |
567 | int bBarkerPreambleMd; | |
568 | ||
569 | u8 byERPFlag; | |
570 | u16 wUseProtectCntDown; | |
571 | ||
572 | int bRadioControlOff; | |
573 | int bRadioOff; | |
574 | ||
575 | /* Power save */ | |
576 | int bEnablePSMode; | |
577 | u16 wListenInterval; | |
578 | int bPWBitOn; | |
579 | WMAC_POWER_MODE ePSMode; | |
580 | unsigned long ulPSModeWaitTx; | |
581 | int bPSModeTxBurst; | |
582 | ||
583 | /* Beacon releated */ | |
584 | u16 wSeqCounter; | |
585 | int bBeaconBufReady; | |
586 | int bBeaconSent; | |
587 | int bFixRate; | |
588 | u8 byCurrentCh; | |
61462ab3 MP |
589 | |
590 | CMD_STATE eCommandState; | |
591 | ||
592 | CMD_CODE eCommand; | |
593 | int bBeaconTx; | |
594 | u8 byScanBBType; | |
595 | ||
596 | int bStopBeacon; | |
597 | int bStopDataPkt; | |
598 | int bStopTx0Pkt; | |
599 | u32 uAutoReConnectTime; | |
600 | u32 uIsroamingTime; | |
601 | ||
602 | /* 802.11 counter */ | |
603 | ||
604 | CMD_ITEM eCmdQueue[CMD_Q_SIZE]; | |
605 | u32 uCmdDequeueIdx; | |
606 | u32 uCmdEnqueueIdx; | |
607 | u32 cbFreeCmdQueue; | |
608 | int bCmdRunning; | |
609 | int bCmdClear; | |
610 | int bNeedRadioOFF; | |
611 | ||
612 | int bEnableRoaming; | |
613 | int bIsRoaming; | |
614 | int bFastRoaming; | |
615 | u8 bSameBSSMaxNum; | |
616 | u8 bSameBSSCurNum; | |
617 | int bRoaming; | |
618 | int b11hEable; | |
61462ab3 MP |
619 | |
620 | /* Encryption */ | |
621 | NDIS_802_11_WEP_STATUS eEncryptionStatus; | |
622 | int bTransmitKey; | |
623 | NDIS_802_11_WEP_STATUS eOldEncryptionStatus; | |
624 | SKeyManagement sKey; | |
625 | u32 dwIVCounter; | |
626 | ||
61462ab3 MP |
627 | RC4Ext SBox; |
628 | u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3]; | |
629 | u8 byKeyIndex; | |
630 | ||
61462ab3 MP |
631 | u32 uKeyLength; |
632 | u8 abyKey[WLAN_WEP232_KEYLEN]; | |
633 | ||
634 | /* for AP mode */ | |
635 | u32 uAssocCount; | |
636 | int bMoreData; | |
637 | ||
638 | /* QoS */ | |
639 | int bGrpAckPolicy; | |
640 | ||
61462ab3 MP |
641 | u8 byAutoFBCtrl; |
642 | ||
643 | int bTxMICFail; | |
644 | int bRxMICFail; | |
645 | ||
61462ab3 | 646 | /* For Update BaseBand VGA Gain Offset */ |
61462ab3 MP |
647 | u32 uBBVGADiffCount; |
648 | u8 byBBVGANew; | |
649 | u8 byBBVGACurrent; | |
650 | u8 abyBBVGA[BB_VGA_LEVEL]; | |
651 | signed long ldBmThreshold[BB_VGA_LEVEL]; | |
652 | ||
653 | u8 byBBPreEDRSSI; | |
654 | u8 byBBPreEDIndex; | |
655 | ||
61462ab3 | 656 | int bRadioCmd; |
61462ab3 | 657 | |
61462ab3 | 658 | /* command timer */ |
94488a7e | 659 | struct delayed_work run_command_work; |
bd9a6dba MP |
660 | /* One second callback */ |
661 | struct delayed_work second_callback_work; | |
92b96797 | 662 | |
60cc2747 MP |
663 | u8 tx_data_time_out; |
664 | bool tx_trigger; | |
61462ab3 MP |
665 | int fWPA_Authened; /*is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */ |
666 | u8 byReAssocCount; | |
667 | u8 byLinkWaitCount; | |
92b96797 | 668 | |
ceb8c5da AM |
669 | struct ethhdr sTxEthHeader; |
670 | struct ethhdr sRxEthHeader; | |
61462ab3 MP |
671 | u8 abyBroadcastAddr[ETH_ALEN]; |
672 | u8 abySNAP_RFC1042[ETH_ALEN]; | |
673 | u8 abySNAP_Bridgetunnel[ETH_ALEN]; | |
92b96797 | 674 | |
61462ab3 MP |
675 | /* Pre-Authentication & PMK cache */ |
676 | SPMKID gsPMKID; | |
677 | SPMKIDCandidateEvent gsPMKIDCandidate; | |
92b96797 | 678 | |
61462ab3 MP |
679 | /* for 802.11h */ |
680 | int b11hEnable; | |
92b96797 | 681 | |
61462ab3 MP |
682 | int bChannelSwitch; |
683 | u8 byNewChannel; | |
684 | u8 byChannelSwitchCount; | |
92b96797 | 685 | |
61462ab3 MP |
686 | /* WPA supplicant daemon */ |
687 | int bWPADEVUp; | |
688 | int bwextstep0; | |
689 | int bwextstep1; | |
690 | int bwextstep2; | |
691 | int bwextstep3; | |
692 | int bWPASuppWextEnabled; | |
92b96797 | 693 | |
61462ab3 | 694 | u32 uChannel; |
92b96797 | 695 | |
61462ab3 | 696 | struct iw_statistics wstats; /* wireless stats */ |
92b96797 | 697 | |
61462ab3 | 698 | int bCommit; |
92b96797 | 699 | |
14c5ef57 | 700 | }; |
92b96797 | 701 | |
92b96797 FB |
702 | #define EnqueueRCB(_Head, _Tail, _RCB) \ |
703 | { \ | |
704 | if (!_Head) { \ | |
705 | _Head = _RCB; \ | |
706 | } \ | |
707 | else { \ | |
708 | _Tail->Next = _RCB; \ | |
709 | } \ | |
710 | _RCB->Next = NULL; \ | |
711 | _Tail = _RCB; \ | |
712 | } | |
713 | ||
714 | #define DequeueRCB(Head, Tail) \ | |
715 | { \ | |
115cac2e | 716 | struct vnt_rcb *RCB = Head; \ |
92b96797 FB |
717 | if (!RCB->Next) { \ |
718 | Tail = NULL; \ | |
719 | } \ | |
720 | Head = RCB->Next; \ | |
721 | } | |
722 | ||
92b96797 FB |
723 | #define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \ |
724 | if ((uVar) >= ((uModulo) - 1)) \ | |
725 | (uVar) = 0; \ | |
726 | else \ | |
727 | (uVar)++; \ | |
728 | } | |
729 | ||
92b96797 | 730 | #define fMP_DISCONNECTED 0x00000002 |
92b96797 FB |
731 | #define fMP_POST_READS 0x00000100 |
732 | #define fMP_POST_WRITES 0x00000200 | |
92b96797 | 733 | |
92b96797 FB |
734 | #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) |
735 | #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) | |
92b96797 FB |
736 | #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F)) |
737 | ||
d4f376dd | 738 | #define MP_IS_READY(_M) (((_M)->Flags & fMP_DISCONNECTED) == 0) |
92b96797 | 739 | |
dd0a774f | 740 | int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF); |
edd20e96 | 741 | void vnt_configure_filter(struct vnt_private *); |
92b96797 FB |
742 | |
743 | #endif |