blob: 8b28ef6bd98fa2585995eb184982d7a7b5514860 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
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
Forest Bond92b96792009-06-13 07:38:31 -040033#include <linux/skbuff.h>
Forest Bond92b96792009-06-13 07:38:31 -040034#include "80211hdr.h"
Forest Bond92b96792009-06-13 07:38:31 -040035#include "80211mgr.h"
Forest Bond92b96792009-06-13 07:38:31 -040036#include "card.h"
Forest Bond92b96792009-06-13 07:38:31 -040037#include "mib.h"
Forest Bond92b96792009-06-13 07:38:31 -040038
Forest Bond92b96792009-06-13 07:38:31 -040039#define MAX_NODE_NUM 64
40#define MAX_BSS_NUM 42
Andres Mored9d1ccb2010-05-26 20:00:36 -030041#define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */
Forest Bond92b96792009-06-13 07:38:31 -040042#define MAX_PS_TX_BUF 32 // sta max power saving tx buf
43#define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only
44#define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh
45
46#define USE_PROTECT_PERIOD 10 // 10 sec, Use protect mode check period
47#define ERP_RECOVER_COUNT 30 // 30 sec, ERP support callback check
48#define BSS_CLEAR_COUNT 1
49
50#define RSSI_STAT_COUNT 10
51#define MAX_CHECK_RSSI_COUNT 8
52
53// STA dwflags
54#define WLAN_STA_AUTH BIT0
55#define WLAN_STA_ASSOC BIT1
56#define WLAN_STA_PS BIT2
57#define WLAN_STA_TIM BIT3
58// permanent; do not remove entry on expiration
59#define WLAN_STA_PERM BIT4
60// If 802.1X is used, this flag is
61// controlling whether STA is authorized to
62// send and receive non-IEEE 802.1X frames
63#define WLAN_STA_AUTHORIZED BIT5
64
Forest Bond92b96792009-06-13 07:38:31 -040065#define MAX_WPA_IE_LEN 64
66
Forest Bond92b96792009-06-13 07:38:31 -040067//
68// IEEE 802.11 Structures and definitions
69//
70
71typedef struct tagSERPObject {
Andres Moredfdcc422013-02-12 20:36:28 -050072 bool bERPExist;
Andres Moreb902fbf2013-02-25 20:32:51 -050073 u8 byERP;
Andres Mored9d1ccb2010-05-26 20:00:36 -030074} ERPObject, *PERPObject;
Forest Bond92b96792009-06-13 07:38:31 -040075
Forest Bond92b96792009-06-13 07:38:31 -040076typedef struct tagSRSNCapObject {
Andres Moredfdcc422013-02-12 20:36:28 -050077 bool bRSNCapExist;
Andres More3eaca0d2013-02-25 20:32:52 -050078 u16 wRSNCap;
Andres Mored9d1ccb2010-05-26 20:00:36 -030079} SRSNCapObject, *PSRSNCapObject;
Forest Bond92b96792009-06-13 07:38:31 -040080
81// BSS info(AP)
Forest Bond92b96792009-06-13 07:38:31 -040082typedef struct tagKnownBSS {
83 // BSS info
Andres Moredfdcc422013-02-12 20:36:28 -050084 bool bActive;
Andres Moreb902fbf2013-02-25 20:32:51 -050085 u8 abyBSSID[WLAN_BSSID_LEN];
Andres Morecc856e62010-05-17 21:34:01 -030086 unsigned int uChannel;
Andres Moreb902fbf2013-02-25 20:32:51 -050087 u8 abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
88 u8 abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
Andres Morecc856e62010-05-17 21:34:01 -030089 unsigned int uRSSI;
Andres Moreb902fbf2013-02-25 20:32:51 -050090 u8 bySQ;
Andres More3eaca0d2013-02-25 20:32:52 -050091 u16 wBeaconInterval;
92 u16 wCapInfo;
Andres Moreb902fbf2013-02-25 20:32:51 -050093 u8 abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
94 u8 byRxRate;
Forest Bond92b96792009-06-13 07:38:31 -040095
Andres More3eaca0d2013-02-25 20:32:52 -050096// u16 wATIMWindow;
Andres Moreb902fbf2013-02-25 20:32:51 -050097 u8 byRSSIStatCnt;
Andres More213d2e92010-05-17 21:34:00 -030098 signed long ldBmMAX;
99 signed long ldBmAverage[RSSI_STAT_COUNT];
100 signed long ldBmAverRange;
Forest Bond92b96792009-06-13 07:38:31 -0400101 //For any BSSID selection improvment
Andres Moredfdcc422013-02-12 20:36:28 -0500102 bool bSelected;
Forest Bond92b96792009-06-13 07:38:31 -0400103
104 //++ WPA informations
Andres Moredfdcc422013-02-12 20:36:28 -0500105 bool bWPAValid;
Andres Moreb902fbf2013-02-25 20:32:51 -0500106 u8 byGKType;
107 u8 abyPKType[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500108 u16 wPKCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500109 u8 abyAuthType[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500110 u16 wAuthCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500111 u8 byDefaultK_as_PK;
112 u8 byReplayIdx;
Forest Bond92b96792009-06-13 07:38:31 -0400113 //--
114
115 //++ WPA2 informations
Andres Moredfdcc422013-02-12 20:36:28 -0500116 bool bWPA2Valid;
Andres Moreb902fbf2013-02-25 20:32:51 -0500117 u8 byCSSGK;
Andres More3eaca0d2013-02-25 20:32:52 -0500118 u16 wCSSPKCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500119 u8 abyCSSPK[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500120 u16 wAKMSSAuthCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500121 u8 abyAKMSSAuthType[4];
Forest Bond92b96792009-06-13 07:38:31 -0400122
123 //++ wpactl
Andres Moreb902fbf2013-02-25 20:32:51 -0500124 u8 byWPAIE[MAX_WPA_IE_LEN];
125 u8 byRSNIE[MAX_WPA_IE_LEN];
Andres More3eaca0d2013-02-25 20:32:52 -0500126 u16 wWPALen;
127 u16 wRSNLen;
Forest Bond92b96792009-06-13 07:38:31 -0400128
129 // Clear count
Andres Morecc856e62010-05-17 21:34:01 -0300130 unsigned int uClearCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500131// u8 abyIEs[WLAN_BEACON_FR_MAXLEN];
Andres Morecc856e62010-05-17 21:34:01 -0300132 unsigned int uIELength;
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000133 u64 qwBSSTimestamp;
134 u64 qwLocalTSF;/* local TSF timer */
Forest Bond92b96792009-06-13 07:38:31 -0400135
136 CARD_PHY_TYPE eNetworkTypeInUse;
137
138 ERPObject sERP;
139 SRSNCapObject sRSNCapObj;
Andres Moreb902fbf2013-02-25 20:32:51 -0500140 u8 abyIEs[1024]; // don't move this field !!
Forest Bond92b96792009-06-13 07:38:31 -0400141
Andres Mored9d1ccb2010-05-26 20:00:36 -0300142} __attribute__ ((__packed__))
Jim Lieb193a8232009-08-12 14:54:06 -0700143KnownBSS , *PKnownBSS;
Forest Bond92b96792009-06-13 07:38:31 -0400144
Forest Bond92b96792009-06-13 07:38:31 -0400145typedef enum tagNODE_STATE {
146 NODE_FREE,
147 NODE_AGED,
148 NODE_KNOWN,
149 NODE_AUTH,
150 NODE_ASSOC
151} NODE_STATE, *PNODE_STATE;
152
Forest Bond92b96792009-06-13 07:38:31 -0400153// STA node info
154typedef struct tagKnownNodeDB {
155 // STA info
Andres Moredfdcc422013-02-12 20:36:28 -0500156 bool bActive;
Andres Moreb902fbf2013-02-25 20:32:51 -0500157 u8 abyMACAddr[WLAN_ADDR_LEN];
158 u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
159 u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
Andres More3eaca0d2013-02-25 20:32:52 -0500160 u16 wTxDataRate;
Andres Moredfdcc422013-02-12 20:36:28 -0500161 bool bShortPreamble;
162 bool bERPExist;
163 bool bShortSlotTime;
Andres Morecc856e62010-05-17 21:34:01 -0300164 unsigned int uInActiveCount;
Andres More3eaca0d2013-02-25 20:32:52 -0500165 u16 wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp.
166 u16 wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon.
167 u16 wSuppRate;
Andres Moreb902fbf2013-02-25 20:32:51 -0500168 u8 byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
169 u8 byTopCCKBasicRate; //Records the highest basic rate in CCK mode
Forest Bond92b96792009-06-13 07:38:31 -0400170
171 // For AP mode
172 struct sk_buff_head sTxPSQueue;
Andres More3eaca0d2013-02-25 20:32:52 -0500173 u16 wCapInfo;
174 u16 wListenInterval;
175 u16 wAID;
Forest Bond92b96792009-06-13 07:38:31 -0400176 NODE_STATE eNodeState;
Andres Moredfdcc422013-02-12 20:36:28 -0500177 bool bPSEnable;
178 bool bRxPSPoll;
Andres Moreb902fbf2013-02-25 20:32:51 -0500179 u8 byAuthSequence;
Andres Morecc856e62010-05-17 21:34:01 -0300180 unsigned long ulLastRxJiffer;
Andres Moreb902fbf2013-02-25 20:32:51 -0500181 u8 bySuppRate;
Andres More52a7e642013-02-25 20:32:53 -0500182 u32 dwFlags;
Andres More3eaca0d2013-02-25 20:32:52 -0500183 u16 wEnQueueCnt;
Forest Bond92b96792009-06-13 07:38:31 -0400184
Andres Moredfdcc422013-02-12 20:36:28 -0500185 bool bOnFly;
Andres Morecc856e62010-05-17 21:34:01 -0300186 unsigned long long KeyRSC;
Andres Moreb902fbf2013-02-25 20:32:51 -0500187 u8 byKeyIndex;
Andres More52a7e642013-02-25 20:32:53 -0500188 u32 dwKeyIndex;
Andres Moreb902fbf2013-02-25 20:32:51 -0500189 u8 byCipherSuite;
Andres More52a7e642013-02-25 20:32:53 -0500190 u32 dwTSC47_16;
Andres More3eaca0d2013-02-25 20:32:52 -0500191 u16 wTSC15_0;
Andres Morecc856e62010-05-17 21:34:01 -0300192 unsigned int uWepKeyLength;
Andres Moreb902fbf2013-02-25 20:32:51 -0500193 u8 abyWepKey[WLAN_WEPMAX_KEYLEN];
Forest Bond92b96792009-06-13 07:38:31 -0400194 //
195 // Auto rate fallback vars
Andres Moredfdcc422013-02-12 20:36:28 -0500196 bool bIsInFallback;
Andres Morecc856e62010-05-17 21:34:01 -0300197 unsigned int uAverageRSSI;
198 unsigned int uRateRecoveryTimeout;
199 unsigned int uRatePollTimeout;
200 unsigned int uTxFailures;
201 unsigned int uTxAttempts;
Forest Bond92b96792009-06-13 07:38:31 -0400202
Andres Morecc856e62010-05-17 21:34:01 -0300203 unsigned int uTxRetry;
204 unsigned int uFailureRatio;
205 unsigned int uRetryRatio;
206 unsigned int uTxOk[MAX_RATE+1];
207 unsigned int uTxFail[MAX_RATE+1];
208 unsigned int uTimeCount;
Forest Bond92b96792009-06-13 07:38:31 -0400209
Jim Lieb193a8232009-08-12 14:54:06 -0700210} KnownNodeDB, *PKnownNodeDB;
Forest Bond92b96792009-06-13 07:38:31 -0400211
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000212PKnownBSS BSSpSearchBSSList(struct vnt_private *, u8 *pbyDesireBSSID,
213 u8 *pbyDesireSSID, CARD_PHY_TYPE ePhyType);
Forest Bond92b96792009-06-13 07:38:31 -0400214
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000215PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *, u8 *abyBSSID,
216 PWLAN_IE_SSID pSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400217
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000218void BSSvClearBSSList(struct vnt_private *, int bKeepCurrBSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400219
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000220int BSSbInsertToBSSList(struct vnt_private *,
221 u8 *abyBSSIDAddr,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000222 u64 qwTimestamp,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000223 u16 wBeaconInterval,
224 u16 wCapInfo,
225 u8 byCurrChannel,
226 PWLAN_IE_SSID pSSID,
227 PWLAN_IE_SUPP_RATES pSuppRates,
228 PWLAN_IE_SUPP_RATES pExtSuppRates,
229 PERPObject psERP,
230 PWLAN_IE_RSN pRSN,
231 PWLAN_IE_RSN_EXT pRSNWPA,
232 PWLAN_IE_COUNTRY pIE_Country,
233 PWLAN_IE_QUIET pIE_Quiet,
234 u32 uIELength,
235 u8 *pbyIEs,
236 void *pRxPacketContext);
Forest Bond92b96792009-06-13 07:38:31 -0400237
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000238int BSSbUpdateToBSSList(struct vnt_private *,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000239 u64 qwTimestamp,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000240 u16 wBeaconInterval,
241 u16 wCapInfo,
242 u8 byCurrChannel,
243 int bChannelHit,
244 PWLAN_IE_SSID pSSID,
245 PWLAN_IE_SUPP_RATES pSuppRates,
246 PWLAN_IE_SUPP_RATES pExtSuppRates,
247 PERPObject psERP,
248 PWLAN_IE_RSN pRSN,
249 PWLAN_IE_RSN_EXT pRSNWPA,
250 PWLAN_IE_COUNTRY pIE_Country,
251 PWLAN_IE_QUIET pIE_Quiet,
252 PKnownBSS pBSSList,
253 u32 uIELength,
254 u8 *pbyIEs,
255 void *pRxPacketContext);
Forest Bond92b96792009-06-13 07:38:31 -0400256
Andres Moreb902fbf2013-02-25 20:32:51 -0500257int BSSbIsSTAInNodeDB(struct vnt_private *, u8 * abyDstAddr,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000258 u32 *puNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400259
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000260void BSSvCreateOneNode(struct vnt_private *, u32 *puNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400261
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000262void BSSvUpdateAPNode(struct vnt_private *, u16 *pwCapInfo,
263 PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates);
Forest Bond92b96792009-06-13 07:38:31 -0400264
Malcolm Priestleybd9a6db2013-09-27 16:51:13 +0100265void BSSvSecondCallBack(struct work_struct *work);
Forest Bond92b96792009-06-13 07:38:31 -0400266
Malcolm Priestley51934e72013-12-09 22:30:14 +0000267void BSSvUpdateNodeTxCounter(struct vnt_private *, u8 byTSR, u8 byPktNO);
Forest Bond92b96792009-06-13 07:38:31 -0400268
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000269void BSSvRemoveOneNode(struct vnt_private *, u32 uNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400270
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000271void BSSvAddMulticastNode(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -0400272
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000273void BSSvClearNodeDBTable(struct vnt_private *, u32 uStartIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400274
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000275void BSSvClearAnyBSSJoinRecord(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -0400276
Andres Moree7b07d12010-05-01 19:12:26 -0300277#endif /* __BSSDB_H__ */