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