Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6
[linux-2.6] / drivers / staging / vt6655 / wmgr.h
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  *
20  * File: wmgr.h
21  *
22  * Purpose:
23  *
24  * Author: lyndon chen
25  *
26  * Date: Jan 2, 2003
27  *
28  * Functions:
29  *
30  * Revision History:
31  *
32  */
33
34
35 #ifndef __WMGR_H__
36 #define __WMGR_H__
37
38 #if !defined(__TTYPE_H__)
39 #include "ttype.h"
40 #endif
41 #if !defined(__80211MGR_H__)
42 #include "80211mgr.h"
43 #endif
44 #if !defined(__80211HDR_H__)
45 #include "80211hdr.h"
46 #endif
47 #if !defined(__WCMD_H__)
48 #include "wcmd.h"
49 #endif
50 #if !defined(__BSSDB_H__)
51 #include "bssdb.h"
52 #endif
53 #if !defined(__CARD_H__)
54 #include "card.h"
55 #endif
56 #if !defined(__WPA2_H__)
57 #include "wpa2.h"
58 #endif
59 #if !defined(__VNTWIFI_H__)
60 #include "vntwifi.h"
61 #endif
62
63
64
65 /*---------------------  Export Definitions -------------------------*/
66
67
68
69 // Scan time
70 #define PROBE_DELAY                  100  // (us)
71 #define SWITCH_CHANNEL_DELAY         200 // (us)
72 #define WLAN_SCAN_MINITIME           25   // (ms)
73 #define WLAN_SCAN_MAXTIME            100  // (ms)
74 #define TRIVIAL_SYNC_DIFFERENCE      0    // (us)
75 #define DEFAULT_IBSS_BI              100  // (ms)
76
77 #define WCMD_ACTIVE_SCAN_TIME   50 //(ms)
78 #define WCMD_PASSIVE_SCAN_TIME  100 //(ms)
79
80
81 #define DEFAULT_MSDU_LIFETIME           512  // ms
82 #define DEFAULT_MSDU_LIFETIME_RES_64us  8000 // 64us
83
84 #define DEFAULT_MGN_LIFETIME            8    // ms
85 #define DEFAULT_MGN_LIFETIME_RES_64us   125  // 64us
86
87 #define MAKE_BEACON_RESERVED            10  //(us)
88
89
90 #define TIM_MULTICAST_MASK           0x01
91 #define TIM_BITMAPOFFSET_MASK        0xFE
92 #define DEFAULT_DTIM_PERIOD             1
93
94 #define AP_LONG_RETRY_LIMIT             4
95
96 #define DEFAULT_IBSS_CHANNEL            6  //2.4G
97
98
99 /*---------------------  Export Classes  ----------------------------*/
100
101 /*---------------------  Export Variables  --------------------------*/
102
103 /*---------------------  Export Types  ------------------------------*/
104 #define timer_expire(timer,next_tick)   mod_timer(&timer, RUN_AT(next_tick))
105 typedef void (*TimerFunction)(ULONG);
106
107
108 //+++ NDIS related
109
110 typedef UCHAR   NDIS_802_11_MAC_ADDRESS[6];
111 typedef struct _NDIS_802_11_AI_REQFI
112 {
113     USHORT Capabilities;
114     USHORT ListenInterval;
115     NDIS_802_11_MAC_ADDRESS  CurrentAPAddress;
116 } NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
117
118 typedef struct _NDIS_802_11_AI_RESFI
119 {
120     USHORT Capabilities;
121     USHORT StatusCode;
122     USHORT AssociationId;
123 } NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
124
125 typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
126 {
127     ULONG                   Length;
128     USHORT                  AvailableRequestFixedIEs;
129     NDIS_802_11_AI_REQFI    RequestFixedIEs;
130     ULONG                   RequestIELength;
131     ULONG                   OffsetRequestIEs;
132     USHORT                  AvailableResponseFixedIEs;
133     NDIS_802_11_AI_RESFI    ResponseFixedIEs;
134     ULONG                   ResponseIELength;
135     ULONG                   OffsetResponseIEs;
136 } NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
137
138
139
140 typedef struct tagSAssocInfo {
141     NDIS_802_11_ASSOCIATION_INFORMATION     AssocInfo;
142     BYTE                                    abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN];
143     // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION
144     ULONG                                   RequestIELength;
145     BYTE                                    abyReqIEs[WLAN_BEACON_FR_MAXLEN];
146 } SAssocInfo, DEF* PSAssocInfo;
147 //---
148
149
150 /*
151 typedef enum tagWMAC_AUTHENTICATION_MODE {
152
153
154     WMAC_AUTH_OPEN,
155     WMAC_AUTH_SHAREKEY,
156     WMAC_AUTH_AUTO,
157     WMAC_AUTH_WPA,
158     WMAC_AUTH_WPAPSK,
159     WMAC_AUTH_WPANONE,
160     WMAC_AUTH_WPA2,
161     WMAC_AUTH_WPA2PSK,
162     WMAC_AUTH_MAX       // Not a real mode, defined as upper bound
163
164
165 } WMAC_AUTHENTICATION_MODE, *PWMAC_AUTHENTICATION_MODE;
166 */
167
168
169 // Pre-configured Mode (from XP)
170 /*
171 typedef enum tagWMAC_CONFIG_MODE {
172     WMAC_CONFIG_ESS_STA,
173     WMAC_CONFIG_IBSS_STA,
174     WMAC_CONFIG_AUTO,
175     WMAC_CONFIG_AP
176
177 } WMAC_CONFIG_MODE, *PWMAC_CONFIG_MODE;
178 */
179
180 typedef enum tagWMAC_SCAN_TYPE {
181
182     WMAC_SCAN_ACTIVE,
183     WMAC_SCAN_PASSIVE,
184     WMAC_SCAN_HYBRID
185
186 } WMAC_SCAN_TYPE, *PWMAC_SCAN_TYPE;
187
188
189 typedef enum tagWMAC_SCAN_STATE {
190
191     WMAC_NO_SCANNING,
192     WMAC_IS_SCANNING,
193     WMAC_IS_PROBEPENDING
194
195 } WMAC_SCAN_STATE, *PWMAC_SCAN_STATE;
196
197
198
199 // Notes:
200 // Basic Service Set state explained as following:
201 // WMAC_STATE_IDLE          : no BSS is selected (Adhoc or Infra)
202 // WMAC_STATE_STARTED       : no BSS is selected, start own IBSS (Adhoc only)
203 // WMAC_STATE_JOINTED       : BSS is selected and synchronized (Adhoc or Infra)
204 // WMAC_STATE_AUTHPENDING   : Authentication pending (Infra)
205 // WMAC_STATE_AUTH          : Authenticated (Infra)
206 // WMAC_STATE_ASSOCPENDING  : Association pending (Infra)
207 // WMAC_STATE_ASSOC         : Associated (Infra)
208
209 typedef enum tagWMAC_BSS_STATE {
210
211     WMAC_STATE_IDLE,
212     WMAC_STATE_STARTED,
213     WMAC_STATE_JOINTED,
214     WMAC_STATE_AUTHPENDING,
215     WMAC_STATE_AUTH,
216     WMAC_STATE_ASSOCPENDING,
217     WMAC_STATE_ASSOC
218
219 } WMAC_BSS_STATE, *PWMAC_BSS_STATE;
220
221 // WMAC selected running mode
222 typedef enum tagWMAC_CURRENT_MODE {
223
224     WMAC_MODE_STANDBY,
225     WMAC_MODE_ESS_STA,
226     WMAC_MODE_IBSS_STA,
227     WMAC_MODE_ESS_AP
228
229 } WMAC_CURRENT_MODE, *PWMAC_CURRENT_MODE;
230
231 /*
232 typedef enum tagWMAC_POWER_MODE {
233
234     WMAC_POWER_CAM,
235     WMAC_POWER_FAST,
236     WMAC_POWER_MAX
237
238 } WMAC_POWER_MODE, *PWMAC_POWER_MODE;
239 */
240
241
242 // Tx Managment Packet descriptor
243 typedef struct tagSTxMgmtPacket {
244
245     PUWLAN_80211HDR     p80211Header;
246     UINT                cbMPDULen;
247     UINT                cbPayloadLen;
248
249 } STxMgmtPacket, DEF* PSTxMgmtPacket;
250
251
252 // Rx Managment Packet descriptor
253 typedef struct tagSRxMgmtPacket {
254
255     PUWLAN_80211HDR     p80211Header;
256     QWORD               qwLocalTSF;
257     UINT                cbMPDULen;
258     UINT                cbPayloadLen;
259     UINT                uRSSI;
260     BYTE                bySQ;
261     BYTE                byRxRate;
262     BYTE                byRxChannel;
263
264 } SRxMgmtPacket, DEF* PSRxMgmtPacket;
265
266
267
268 typedef struct tagSMgmtObject
269 {
270
271     PVOID                   pAdapter;
272     // MAC address
273     BYTE                    abyMACAddr[WLAN_ADDR_LEN];
274
275     // Configuration Mode
276     WMAC_CONFIG_MODE        eConfigMode; // MAC pre-configed mode
277     CARD_PHY_TYPE           eCurrentPHYMode;
278     CARD_PHY_TYPE           eConfigPHYMode;
279
280
281     // Operation state variables
282     WMAC_CURRENT_MODE       eCurrMode;   // MAC current connection mode
283     WMAC_BSS_STATE          eCurrState;  // MAC current BSS state
284
285     PKnownBSS               pCurrBSS;
286     BYTE                    byCSSGK;
287     BYTE                    byCSSPK;
288
289 //    BYTE                    abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
290 //    BYTE                    abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
291
292     // Current state vars
293     UINT                    uCurrChannel;
294     BYTE                    abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
295     BYTE                    abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
296     BYTE                    abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
297     BYTE                    abyCurrBSSID[WLAN_BSSID_LEN];
298     WORD                    wCurrCapInfo;
299     WORD                    wCurrAID;
300     WORD                    wCurrATIMWindow;
301     WORD                    wCurrBeaconPeriod;
302     BOOL                    bIsDS;
303     BYTE                    byERPContext;
304
305     CMD_STATE               eCommandState;
306     UINT                    uScanChannel;
307
308     // Desire joinning BSS vars
309     BYTE                    abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
310     BYTE                    abyDesireBSSID[WLAN_BSSID_LEN];
311
312     // Adhoc or AP configuration vars
313   //BYTE                    abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
314     WORD                    wIBSSBeaconPeriod;
315     WORD                    wIBSSATIMWindow;
316     UINT                    uIBSSChannel;
317     BYTE                    abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
318     BYTE                    byAPBBType;
319     BYTE                    abyWPAIE[MAX_WPA_IE_LEN];
320     WORD                    wWPAIELen;
321
322     UINT                    uAssocCount;
323     BOOL                    bMoreData;
324
325     // Scan state vars
326     WMAC_SCAN_STATE         eScanState;
327     WMAC_SCAN_TYPE          eScanType;
328     UINT                    uScanStartCh;
329     UINT                    uScanEndCh;
330     WORD                    wScanSteps;
331     UINT                    uScanBSSType;
332     // Desire scannig vars
333     BYTE                    abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
334     BYTE                    abyScanBSSID[WLAN_BSSID_LEN];
335
336     // Privacy
337     WMAC_AUTHENTICATION_MODE eAuthenMode;
338     WMAC_ENCRYPTION_MODE    eEncryptionMode;
339     BOOL                    bShareKeyAlgorithm;
340     BYTE                    abyChallenge[WLAN_CHALLENGE_LEN];
341     BOOL                    bPrivacyInvoked;
342
343     // Received beacon state vars
344     BOOL                    bInTIM;
345     BOOL                    bMulticastTIM;
346     BYTE                    byDTIMCount;
347     BYTE                    byDTIMPeriod;
348
349     // Power saving state vars
350     WMAC_POWER_MODE         ePSMode;
351     WORD                    wListenInterval;
352     WORD                    wCountToWakeUp;
353     BOOL                    bInTIMWake;
354     PBYTE                   pbyPSPacketPool;
355     BYTE                    byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
356     BOOL                    bRxBeaconInTBTTWake;
357     BYTE                    abyPSTxMap[MAX_NODE_NUM + 1];
358
359     // managment command related
360     UINT                    uCmdBusy;
361     UINT                    uCmdHostAPBusy;
362
363     // managment packet pool
364     PBYTE                   pbyMgmtPacketPool;
365     BYTE                    byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
366
367
368     // One second callback timer
369     struct timer_list       sTimerSecondCallback;
370
371     // Temporarily Rx Mgmt Packet Descriptor
372     SRxMgmtPacket           sRxPacket;
373
374     // link list of known bss's (scan results)
375     KnownBSS                sBSSList[MAX_BSS_NUM];
376
377
378
379     // table list of known node
380     // sNodeDBList[0] is reserved for AP under Infra mode
381     // sNodeDBList[0] is reserved for Multicast under adhoc/AP mode
382     KnownNodeDB             sNodeDBTable[MAX_NODE_NUM + 1];
383
384
385
386     // WPA2 PMKID Cache
387     SPMKIDCache             gsPMKIDCache;
388     BOOL                    bRoaming;
389
390     // rate fall back vars
391
392
393
394     // associate info
395     SAssocInfo              sAssocInfo;
396
397
398     // for 802.11h
399     BOOL                    b11hEnable;
400     BOOL                    bSwitchChannel;
401     BYTE                    byNewChannel;
402     PWLAN_IE_MEASURE_REP    pCurrMeasureEIDRep;
403     UINT                    uLengthOfRepEIDs;
404     BYTE                    abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
405     BYTE                    abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
406     BYTE                    abyIECountry[WLAN_A3FR_MAXLEN];
407     BYTE                    abyIBSSDFSOwner[6];
408     BYTE                    byIBSSDFSRecovery;
409
410     struct sk_buff  skb;
411
412 } SMgmtObject, DEF *PSMgmtObject;
413
414
415 /*---------------------  Export Macros ------------------------------*/
416
417
418 /*---------------------  Export Functions  --------------------------*/
419
420
421 void
422 vMgrObjectInit(
423     IN  HANDLE hDeviceContext
424     );
425
426 void
427 vMgrTimerInit(
428     IN  HANDLE hDeviceContext
429     );
430
431 VOID
432 vMgrObjectReset(
433     IN  HANDLE hDeviceContext
434     );
435
436 void
437 vMgrAssocBeginSta(
438     IN  HANDLE hDeviceContext,
439     IN  PSMgmtObject pMgmt,
440     OUT PCMD_STATUS pStatus
441     );
442
443 VOID
444 vMgrReAssocBeginSta(
445     IN  HANDLE hDeviceContext,
446     IN  PSMgmtObject pMgmt,
447     OUT PCMD_STATUS pStatus
448     );
449
450 VOID
451 vMgrDisassocBeginSta(
452     IN  HANDLE hDeviceContext,
453     IN  PSMgmtObject pMgmt,
454     IN  PBYTE  abyDestAddress,
455     IN  WORD    wReason,
456     OUT PCMD_STATUS pStatus
457     );
458
459 VOID
460 vMgrAuthenBeginSta(
461     IN  HANDLE hDeviceContext,
462     IN  PSMgmtObject pMgmt,
463     OUT PCMD_STATUS pStatus
464     );
465
466 VOID
467 vMgrCreateOwnIBSS(
468     IN  HANDLE hDeviceContext,
469     OUT PCMD_STATUS pStatus
470     );
471
472 VOID
473 vMgrJoinBSSBegin(
474     IN  HANDLE hDeviceContext,
475     OUT PCMD_STATUS pStatus
476     );
477
478 VOID
479 vMgrRxManagePacket(
480     IN  HANDLE hDeviceContext,
481     IN  PSMgmtObject pMgmt,
482     IN  PSRxMgmtPacket pRxPacket
483     );
484
485 /*
486 VOID
487 vMgrScanBegin(
488     IN  HANDLE hDeviceContext,
489     OUT PCMD_STATUS pStatus
490     );
491 */
492
493 VOID
494 vMgrDeAuthenBeginSta(
495     IN  HANDLE hDeviceContext,
496     IN  PSMgmtObject  pMgmt,
497     IN  PBYTE   abyDestAddress,
498     IN  WORD    wReason,
499     OUT PCMD_STATUS pStatus
500     );
501
502 BOOL
503 bMgrPrepareBeaconToSend(
504     IN  HANDLE hDeviceContext,
505     IN  PSMgmtObject pMgmt
506     );
507
508
509 BOOL
510 bAdd_PMKID_Candidate (
511     IN HANDLE    hDeviceContext,
512     IN PBYTE          pbyBSSID,
513     IN PSRSNCapObject psRSNCapObj
514     );
515
516 VOID
517 vFlush_PMKID_Candidate (
518     IN HANDLE hDeviceContext
519     );
520
521 #endif // __WMGR_H__