Linux-libre 3.16.85-gnu
[librecmc/linux-libre.git] / drivers / staging / vt6656 / bssdb.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: bssdb.h
21  *
22  * Purpose: Handles the Basic Service Set & Node Database functions
23  *
24  * Author: Lyndon Chen
25  *
26  * Date: July 16, 2002
27  *
28  */
29
30 #ifndef __BSSDB_H__
31 #define __BSSDB_H__
32
33 #include <linux/skbuff.h>
34 #include "80211hdr.h"
35 #include "80211mgr.h"
36 #include "card.h"
37
38 #define MAX_NODE_NUM             64
39 #define MAX_BSS_NUM              42
40 #define LOST_BEACON_COUNT        10   /* 10 sec, XP defined */
41 #define MAX_PS_TX_BUF            32   // sta max power saving tx buf
42 #define ADHOC_LOST_BEACON_COUNT  30   // 30 sec, beacon lost for adhoc only
43 #define MAX_INACTIVE_COUNT       300  // 300 sec, inactive STA node refresh
44
45 #define USE_PROTECT_PERIOD       10   // 10 sec, Use protect mode check period
46 #define ERP_RECOVER_COUNT        30   // 30 sec, ERP support callback check
47 #define BSS_CLEAR_COUNT           1
48
49 #define RSSI_STAT_COUNT          10
50 #define MAX_CHECK_RSSI_COUNT     8
51
52 // STA dwflags
53 #define WLAN_STA_AUTH            BIT0
54 #define WLAN_STA_ASSOC           BIT1
55 #define WLAN_STA_PS              BIT2
56 #define WLAN_STA_TIM             BIT3
57 // permanent; do not remove entry on expiration
58 #define WLAN_STA_PERM            BIT4
59 // If 802.1X is used, this flag is
60 // controlling whether STA is authorized to
61 // send and receive non-IEEE 802.1X frames
62 #define WLAN_STA_AUTHORIZED      BIT5
63
64 #define MAX_WPA_IE_LEN      64
65
66 //
67 // IEEE 802.11 Structures and definitions
68 //
69
70 typedef struct tagSERPObject {
71     bool    bERPExist;
72     u8    byERP;
73 } ERPObject, *PERPObject;
74
75 typedef struct tagSRSNCapObject {
76     bool    bRSNCapExist;
77     u16    wRSNCap;
78 } SRSNCapObject, *PSRSNCapObject;
79
80 // BSS info(AP)
81 typedef struct tagKnownBSS {
82     // BSS info
83     bool            bActive;
84     u8            abyBSSID[WLAN_BSSID_LEN];
85     unsigned int            uChannel;
86     u8            abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
87     u8            abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
88     unsigned int            uRSSI;
89     u8            bySQ;
90     u16            wBeaconInterval;
91     u16            wCapInfo;
92     u8            abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
93     u8            byRxRate;
94
95 //    u16            wATIMWindow;
96     u8            byRSSIStatCnt;
97     signed long            ldBmMAX;
98     signed long            ldBmAverage[RSSI_STAT_COUNT];
99     signed long            ldBmAverRange;
100     //For any BSSID selection improvment
101     bool            bSelected;
102
103     //++ WPA informations
104     bool            bWPAValid;
105     u8            byGKType;
106     u8            abyPKType[4];
107     u16            wPKCount;
108     u8            abyAuthType[4];
109     u16            wAuthCount;
110     u8            byDefaultK_as_PK;
111     u8            byReplayIdx;
112     //--
113
114     //++ WPA2 informations
115     bool            bWPA2Valid;
116     u8            byCSSGK;
117     u16            wCSSPKCount;
118     u8            abyCSSPK[4];
119     u16            wAKMSSAuthCount;
120     u8            abyAKMSSAuthType[4];
121
122     //++  wpactl
123     u8            byWPAIE[MAX_WPA_IE_LEN];
124     u8            byRSNIE[MAX_WPA_IE_LEN];
125     u16            wWPALen;
126     u16            wRSNLen;
127
128     // Clear count
129     unsigned int            uClearCount;
130 //    u8            abyIEs[WLAN_BEACON_FR_MAXLEN];
131     unsigned int            uIELength;
132         u64 qwBSSTimestamp;
133         u64 qwLocalTSF;/* local TSF timer */
134
135     CARD_PHY_TYPE   eNetworkTypeInUse;
136
137     ERPObject       sERP;
138     SRSNCapObject   sRSNCapObj;
139     u8            abyIEs[1024];   // don't move this field !!
140
141 } __attribute__ ((__packed__))
142 KnownBSS , *PKnownBSS;
143
144 typedef enum tagNODE_STATE {
145     NODE_FREE,
146     NODE_AGED,
147     NODE_KNOWN,
148     NODE_AUTH,
149     NODE_ASSOC
150 } NODE_STATE, *PNODE_STATE;
151
152 // STA node info
153 typedef struct tagKnownNodeDB {
154     // STA info
155     bool            bActive;
156     u8            abyMACAddr[WLAN_ADDR_LEN];
157     u8            abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
158     u8            abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
159     u16            wTxDataRate;
160     bool            bShortPreamble;
161     bool            bERPExist;
162     bool            bShortSlotTime;
163     unsigned int            uInActiveCount;
164     u16            wMaxBasicRate;     //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
165     u16            wMaxSuppRate;      //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
166     u16            wSuppRate;
167     u8            byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
168     u8            byTopCCKBasicRate; //Records the highest basic rate in CCK mode
169
170     // For AP mode
171     struct sk_buff_head sTxPSQueue;
172     u16            wCapInfo;
173     u16            wListenInterval;
174     u16            wAID;
175     NODE_STATE      eNodeState;
176     bool            bPSEnable;
177     bool            bRxPSPoll;
178     u8            byAuthSequence;
179     unsigned long           ulLastRxJiffer;
180     u8            bySuppRate;
181     u32           dwFlags;
182     u16            wEnQueueCnt;
183
184     bool            bOnFly;
185     unsigned long long       KeyRSC;
186     u8            byKeyIndex;
187     u32           dwKeyIndex;
188     u8            byCipherSuite;
189     u32           dwTSC47_16;
190     u16            wTSC15_0;
191     unsigned int            uWepKeyLength;
192     u8            abyWepKey[WLAN_WEPMAX_KEYLEN];
193     //
194     // Auto rate fallback vars
195     bool            bIsInFallback;
196     unsigned int            uAverageRSSI;
197     unsigned int            uRateRecoveryTimeout;
198     unsigned int            uRatePollTimeout;
199     unsigned int            uTxFailures;
200     unsigned int            uTxAttempts;
201
202     unsigned int            uTxRetry;
203     unsigned int            uFailureRatio;
204     unsigned int            uRetryRatio;
205     unsigned int            uTxOk[MAX_RATE+1];
206     unsigned int            uTxFail[MAX_RATE+1];
207     unsigned int            uTimeCount;
208
209 } KnownNodeDB, *PKnownNodeDB;
210
211 PKnownBSS BSSpSearchBSSList(struct vnt_private *, u8 *pbyDesireBSSID,
212         u8 *pbyDesireSSID, CARD_PHY_TYPE ePhyType);
213
214 PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *, u8 *abyBSSID,
215         PWLAN_IE_SSID pSSID);
216
217 void BSSvClearBSSList(struct vnt_private *, int bKeepCurrBSSID);
218
219 int BSSbInsertToBSSList(struct vnt_private *,
220                         u8 *abyBSSIDAddr,
221                         u64 qwTimestamp,
222                         u16 wBeaconInterval,
223                         u16 wCapInfo,
224                         u8 byCurrChannel,
225                         PWLAN_IE_SSID pSSID,
226                         PWLAN_IE_SUPP_RATES pSuppRates,
227                         PWLAN_IE_SUPP_RATES pExtSuppRates,
228                         PERPObject psERP,
229                         PWLAN_IE_RSN pRSN,
230                         PWLAN_IE_RSN_EXT pRSNWPA,
231                         PWLAN_IE_COUNTRY pIE_Country,
232                         PWLAN_IE_QUIET pIE_Quiet,
233                         u32 uIELength,
234                         u8 *pbyIEs,
235                         void *pRxPacketContext);
236
237 int BSSbUpdateToBSSList(struct vnt_private *,
238                         u64 qwTimestamp,
239                         u16 wBeaconInterval,
240                         u16 wCapInfo,
241                         u8 byCurrChannel,
242                         int bChannelHit,
243                         PWLAN_IE_SSID pSSID,
244                         PWLAN_IE_SUPP_RATES pSuppRates,
245                         PWLAN_IE_SUPP_RATES pExtSuppRates,
246                         PERPObject psERP,
247                         PWLAN_IE_RSN pRSN,
248                         PWLAN_IE_RSN_EXT pRSNWPA,
249                         PWLAN_IE_COUNTRY pIE_Country,
250                         PWLAN_IE_QUIET pIE_Quiet,
251                         PKnownBSS pBSSList,
252                         u32 uIELength,
253                         u8 *pbyIEs,
254                         void *pRxPacketContext);
255
256 int BSSbIsSTAInNodeDB(struct vnt_private *, u8 * abyDstAddr,
257         u32 *puNodeIndex);
258
259 void BSSvCreateOneNode(struct vnt_private *, u32 *puNodeIndex);
260
261 void BSSvUpdateAPNode(struct vnt_private *, u16 *pwCapInfo,
262         PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates);
263
264 void BSSvSecondCallBack(struct work_struct *work);
265
266 void BSSvUpdateNodeTxCounter(struct vnt_private *, u8 byTSR, u8 byPktNO);
267
268 void BSSvRemoveOneNode(struct vnt_private *, u32 uNodeIndex);
269
270 void BSSvAddMulticastNode(struct vnt_private *);
271
272 void BSSvClearNodeDBTable(struct vnt_private *, u32 uStartIndex);
273
274 void BSSvClearAnyBSSJoinRecord(struct vnt_private *);
275
276 #endif /* __BSSDB_H__ */