blob: 8df3fb2a619940821ca6da3a6788aa95890535bf [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
Forest Bond92b96792009-06-13 07:38:31 -040038#define MAX_NODE_NUM 64
39#define MAX_BSS_NUM 42
Andres Mored9d1ccb2010-05-26 20:00:36 -030040#define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */
Forest Bond92b96792009-06-13 07:38:31 -040041#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
Forest Bond92b96792009-06-13 07:38:31 -040064#define MAX_WPA_IE_LEN 64
65
Forest Bond92b96792009-06-13 07:38:31 -040066//
67// IEEE 802.11 Structures and definitions
68//
69
70typedef struct tagSERPObject {
Andres Moredfdcc422013-02-12 20:36:28 -050071 bool bERPExist;
Andres Moreb902fbf2013-02-25 20:32:51 -050072 u8 byERP;
Andres Mored9d1ccb2010-05-26 20:00:36 -030073} ERPObject, *PERPObject;
Forest Bond92b96792009-06-13 07:38:31 -040074
Forest Bond92b96792009-06-13 07:38:31 -040075typedef struct tagSRSNCapObject {
Andres Moredfdcc422013-02-12 20:36:28 -050076 bool bRSNCapExist;
Andres More3eaca0d2013-02-25 20:32:52 -050077 u16 wRSNCap;
Andres Mored9d1ccb2010-05-26 20:00:36 -030078} SRSNCapObject, *PSRSNCapObject;
Forest Bond92b96792009-06-13 07:38:31 -040079
80// BSS info(AP)
Forest Bond92b96792009-06-13 07:38:31 -040081typedef struct tagKnownBSS {
82 // BSS info
Andres Moredfdcc422013-02-12 20:36:28 -050083 bool bActive;
Andres Moreb902fbf2013-02-25 20:32:51 -050084 u8 abyBSSID[WLAN_BSSID_LEN];
Andres Morecc856e62010-05-17 21:34:01 -030085 unsigned int uChannel;
Andres Moreb902fbf2013-02-25 20:32:51 -050086 u8 abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
87 u8 abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
Andres Morecc856e62010-05-17 21:34:01 -030088 unsigned int uRSSI;
Andres Moreb902fbf2013-02-25 20:32:51 -050089 u8 bySQ;
Andres More3eaca0d2013-02-25 20:32:52 -050090 u16 wBeaconInterval;
91 u16 wCapInfo;
Andres Moreb902fbf2013-02-25 20:32:51 -050092 u8 abySSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
93 u8 byRxRate;
Forest Bond92b96792009-06-13 07:38:31 -040094
Andres More3eaca0d2013-02-25 20:32:52 -050095// u16 wATIMWindow;
Andres Moreb902fbf2013-02-25 20:32:51 -050096 u8 byRSSIStatCnt;
Andres More213d2e92010-05-17 21:34:00 -030097 signed long ldBmMAX;
98 signed long ldBmAverage[RSSI_STAT_COUNT];
99 signed long ldBmAverRange;
Forest Bond92b96792009-06-13 07:38:31 -0400100 //For any BSSID selection improvment
Andres Moredfdcc422013-02-12 20:36:28 -0500101 bool bSelected;
Forest Bond92b96792009-06-13 07:38:31 -0400102
103 //++ WPA informations
Andres Moredfdcc422013-02-12 20:36:28 -0500104 bool bWPAValid;
Andres Moreb902fbf2013-02-25 20:32:51 -0500105 u8 byGKType;
106 u8 abyPKType[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500107 u16 wPKCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500108 u8 abyAuthType[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500109 u16 wAuthCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500110 u8 byDefaultK_as_PK;
111 u8 byReplayIdx;
Forest Bond92b96792009-06-13 07:38:31 -0400112 //--
113
114 //++ WPA2 informations
Andres Moredfdcc422013-02-12 20:36:28 -0500115 bool bWPA2Valid;
Andres Moreb902fbf2013-02-25 20:32:51 -0500116 u8 byCSSGK;
Andres More3eaca0d2013-02-25 20:32:52 -0500117 u16 wCSSPKCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500118 u8 abyCSSPK[4];
Andres More3eaca0d2013-02-25 20:32:52 -0500119 u16 wAKMSSAuthCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500120 u8 abyAKMSSAuthType[4];
Forest Bond92b96792009-06-13 07:38:31 -0400121
122 //++ wpactl
Andres Moreb902fbf2013-02-25 20:32:51 -0500123 u8 byWPAIE[MAX_WPA_IE_LEN];
124 u8 byRSNIE[MAX_WPA_IE_LEN];
Andres More3eaca0d2013-02-25 20:32:52 -0500125 u16 wWPALen;
126 u16 wRSNLen;
Forest Bond92b96792009-06-13 07:38:31 -0400127
128 // Clear count
Andres Morecc856e62010-05-17 21:34:01 -0300129 unsigned int uClearCount;
Andres Moreb902fbf2013-02-25 20:32:51 -0500130// u8 abyIEs[WLAN_BEACON_FR_MAXLEN];
Andres Morecc856e62010-05-17 21:34:01 -0300131 unsigned int uIELength;
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000132 u64 qwBSSTimestamp;
133 u64 qwLocalTSF;/* local TSF timer */
Forest Bond92b96792009-06-13 07:38:31 -0400134
135 CARD_PHY_TYPE eNetworkTypeInUse;
136
137 ERPObject sERP;
138 SRSNCapObject sRSNCapObj;
Andres Moreb902fbf2013-02-25 20:32:51 -0500139 u8 abyIEs[1024]; // don't move this field !!
Forest Bond92b96792009-06-13 07:38:31 -0400140
Andres Mored9d1ccb2010-05-26 20:00:36 -0300141} __attribute__ ((__packed__))
Jim Lieb193a8232009-08-12 14:54:06 -0700142KnownBSS , *PKnownBSS;
Forest Bond92b96792009-06-13 07:38:31 -0400143
Forest Bond92b96792009-06-13 07:38:31 -0400144typedef enum tagNODE_STATE {
145 NODE_FREE,
146 NODE_AGED,
147 NODE_KNOWN,
148 NODE_AUTH,
149 NODE_ASSOC
150} NODE_STATE, *PNODE_STATE;
151
Forest Bond92b96792009-06-13 07:38:31 -0400152// STA node info
153typedef struct tagKnownNodeDB {
154 // STA info
Andres Moredfdcc422013-02-12 20:36:28 -0500155 bool bActive;
Andres Moreb902fbf2013-02-25 20:32:51 -0500156 u8 abyMACAddr[WLAN_ADDR_LEN];
157 u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
158 u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
Andres More3eaca0d2013-02-25 20:32:52 -0500159 u16 wTxDataRate;
Andres Moredfdcc422013-02-12 20:36:28 -0500160 bool bShortPreamble;
161 bool bERPExist;
162 bool bShortSlotTime;
Andres Morecc856e62010-05-17 21:34:01 -0300163 unsigned int uInActiveCount;
Andres More3eaca0d2013-02-25 20:32:52 -0500164 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;
Andres Moreb902fbf2013-02-25 20:32:51 -0500167 u8 byTopOFDMBasicRate;//Records the highest basic rate in OFDM mode
168 u8 byTopCCKBasicRate; //Records the highest basic rate in CCK mode
Forest Bond92b96792009-06-13 07:38:31 -0400169
170 // For AP mode
171 struct sk_buff_head sTxPSQueue;
Andres More3eaca0d2013-02-25 20:32:52 -0500172 u16 wCapInfo;
173 u16 wListenInterval;
174 u16 wAID;
Forest Bond92b96792009-06-13 07:38:31 -0400175 NODE_STATE eNodeState;
Andres Moredfdcc422013-02-12 20:36:28 -0500176 bool bPSEnable;
177 bool bRxPSPoll;
Andres Moreb902fbf2013-02-25 20:32:51 -0500178 u8 byAuthSequence;
Andres Morecc856e62010-05-17 21:34:01 -0300179 unsigned long ulLastRxJiffer;
Andres Moreb902fbf2013-02-25 20:32:51 -0500180 u8 bySuppRate;
Andres More52a7e642013-02-25 20:32:53 -0500181 u32 dwFlags;
Andres More3eaca0d2013-02-25 20:32:52 -0500182 u16 wEnQueueCnt;
Forest Bond92b96792009-06-13 07:38:31 -0400183
Andres Moredfdcc422013-02-12 20:36:28 -0500184 bool bOnFly;
Andres Morecc856e62010-05-17 21:34:01 -0300185 unsigned long long KeyRSC;
Andres Moreb902fbf2013-02-25 20:32:51 -0500186 u8 byKeyIndex;
Andres More52a7e642013-02-25 20:32:53 -0500187 u32 dwKeyIndex;
Andres Moreb902fbf2013-02-25 20:32:51 -0500188 u8 byCipherSuite;
Andres More52a7e642013-02-25 20:32:53 -0500189 u32 dwTSC47_16;
Andres More3eaca0d2013-02-25 20:32:52 -0500190 u16 wTSC15_0;
Andres Morecc856e62010-05-17 21:34:01 -0300191 unsigned int uWepKeyLength;
Andres Moreb902fbf2013-02-25 20:32:51 -0500192 u8 abyWepKey[WLAN_WEPMAX_KEYLEN];
Forest Bond92b96792009-06-13 07:38:31 -0400193 //
194 // Auto rate fallback vars
Andres Moredfdcc422013-02-12 20:36:28 -0500195 bool bIsInFallback;
Andres Morecc856e62010-05-17 21:34:01 -0300196 unsigned int uAverageRSSI;
197 unsigned int uRateRecoveryTimeout;
198 unsigned int uRatePollTimeout;
199 unsigned int uTxFailures;
200 unsigned int uTxAttempts;
Forest Bond92b96792009-06-13 07:38:31 -0400201
Andres Morecc856e62010-05-17 21:34:01 -0300202 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;
Forest Bond92b96792009-06-13 07:38:31 -0400208
Jim Lieb193a8232009-08-12 14:54:06 -0700209} KnownNodeDB, *PKnownNodeDB;
Forest Bond92b96792009-06-13 07:38:31 -0400210
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000211PKnownBSS BSSpSearchBSSList(struct vnt_private *, u8 *pbyDesireBSSID,
212 u8 *pbyDesireSSID, CARD_PHY_TYPE ePhyType);
Forest Bond92b96792009-06-13 07:38:31 -0400213
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000214PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *, u8 *abyBSSID,
215 PWLAN_IE_SSID pSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400216
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000217void BSSvClearBSSList(struct vnt_private *, int bKeepCurrBSSID);
Forest Bond92b96792009-06-13 07:38:31 -0400218
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000219int BSSbInsertToBSSList(struct vnt_private *,
220 u8 *abyBSSIDAddr,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000221 u64 qwTimestamp,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000222 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);
Forest Bond92b96792009-06-13 07:38:31 -0400236
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000237int BSSbUpdateToBSSList(struct vnt_private *,
Malcolm Priestley7c65fa22012-11-28 21:11:02 +0000238 u64 qwTimestamp,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000239 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);
Forest Bond92b96792009-06-13 07:38:31 -0400255
Andres Moreb902fbf2013-02-25 20:32:51 -0500256int BSSbIsSTAInNodeDB(struct vnt_private *, u8 * abyDstAddr,
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000257 u32 *puNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400258
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000259void BSSvCreateOneNode(struct vnt_private *, u32 *puNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400260
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000261void BSSvUpdateAPNode(struct vnt_private *, u16 *pwCapInfo,
262 PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates);
Forest Bond92b96792009-06-13 07:38:31 -0400263
Malcolm Priestleybd9a6db2013-09-27 16:51:13 +0100264void BSSvSecondCallBack(struct work_struct *work);
Forest Bond92b96792009-06-13 07:38:31 -0400265
Malcolm Priestley51934e72013-12-09 22:30:14 +0000266void BSSvUpdateNodeTxCounter(struct vnt_private *, u8 byTSR, u8 byPktNO);
Forest Bond92b96792009-06-13 07:38:31 -0400267
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000268void BSSvRemoveOneNode(struct vnt_private *, u32 uNodeIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400269
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000270void BSSvAddMulticastNode(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -0400271
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000272void BSSvClearNodeDBTable(struct vnt_private *, u32 uStartIndex);
Forest Bond92b96792009-06-13 07:38:31 -0400273
Malcolm Priestleyd56131d2013-01-17 23:15:22 +0000274void BSSvClearAnyBSSJoinRecord(struct vnt_private *);
Forest Bond92b96792009-06-13 07:38:31 -0400275
Andres Moree7b07d12010-05-01 19:12:26 -0300276#endif /* __BSSDB_H__ */