1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * Modifications for inclusion into the Linux staging tree are
19  * Copyright(c) 2010 Larry Finger. All rights reserved.
20  *
21  * Contact information:
22  * WLAN FAE <wlanfae@realtek.com>
23  * Larry Finger <Larry.Finger@lwfinger.net>
24  *
25  ******************************************************************************/
26 #ifndef __WLAN_BSSDEF_H__
27 #define __WLAN_BSSDEF_H__
28 
29 #define MAX_IE_SZ	768
30 
31 #define NDIS_802_11_LENGTH_SSID         32
32 #define NDIS_802_11_LENGTH_RATES        8
33 #define NDIS_802_11_LENGTH_RATES_EX     16
34 
35 /* Set of 8 data rates*/
36 typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];
37 /* Set of 16 data rates */
38 typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];
39 
40 struct ndis_802_11_ssid {
41 	u32 SsidLength;
42 	u8  Ssid[32];
43 };
44 
45 enum NDIS_802_11_NETWORK_TYPE {
46 	Ndis802_11FH,
47 	Ndis802_11DS,
48 	Ndis802_11OFDM5,
49 	Ndis802_11OFDM24,
50 	Ndis802_11NetworkTypeMax /* not a real type, defined as an upper bound*/
51 };
52 
53 struct NDIS_802_11_CONFIGURATION_FH {
54 	u32 Length;             /* Length of structure */
55 	u32 HopPattern;         /* As defined by 802.11, MSB set */
56 	u32 HopSet;             /* to one if non-802.11 */
57 	u32 DwellTime;          /* units are Kusec */
58 };
59 
60 /*
61 	FW will only save the channel number in DSConfig.
62 	ODI Handler will convert the channel number to freq. number.
63 */
64 struct NDIS_802_11_CONFIGURATION {
65 	u32 Length;             /* Length of structure */
66 	u32 BeaconPeriod;       /* units are Kusec */
67 	u32 ATIMWindow;         /* units are Kusec */
68 	u32 DSConfig;           /* Frequency, units are kHz */
69 	struct NDIS_802_11_CONFIGURATION_FH FHConfig;
70 };
71 
72 enum NDIS_802_11_NETWORK_INFRASTRUCTURE {
73 	Ndis802_11IBSS,
74 	Ndis802_11Infrastructure,
75 	Ndis802_11AutoUnknown,
76 	Ndis802_11InfrastructureMax, /*Not a real value,defined as upper bound*/
77 	Ndis802_11APMode
78 };
79 
80 struct NDIS_802_11_FIXED_IEs {
81 	u8  Timestamp[8];
82 	u16 BeaconInterval;
83 	u16 Capabilities;
84 };
85 
86 /*
87  * Length is the 4 bytes multiples of the sume of
88  * 6 * sizeof (unsigned char) + 2 + sizeof (ndis_802_11_ssid) + sizeof (u32)
89  * + sizeof (s32) + sizeof (NDIS_802_11_NETWORK_TYPE)
90  * + sizeof (struct NDIS_802_11_CONFIGURATION)
91  * + sizeof (NDIS_802_11_RATES_EX) + IELength
92 
93  * Except the IELength, all other fields are fixed length. Therefore, we can
94  * define a macro to present the partial sum.
95  */
96 
97 struct ndis_wlan_bssid_ex {
98 	u32 Length;
99 	unsigned char  MacAddress[6];
100 	u8  Reserved[2];
101 	struct ndis_802_11_ssid  Ssid;
102 	u32 Privacy;
103 	s32 Rssi;
104 	enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
105 	struct NDIS_802_11_CONFIGURATION  Configuration;
106 	enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
107 	NDIS_802_11_RATES_EX  SupportedRates;
108 	u32 IELength;
109 	/*(timestamp, beacon interval, and capability information) */
110 	u8 IEs[MAX_IE_SZ];
111 };
112 
113 enum NDIS_802_11_AUTHENTICATION_MODE {
114 	Ndis802_11AuthModeOpen,
115 	Ndis802_11AuthModeShared,
116 	Ndis802_11AuthModeAutoSwitch,
117 	Ndis802_11AuthModeWPA,
118 	Ndis802_11AuthModeWPAPSK,
119 	Ndis802_11AuthModeWPANone,
120 	Ndis802_11AuthModeMax      /* Not a real mode, defined as upper bound */
121 };
122 
123 enum {
124 	Ndis802_11WEPEnabled,
125 	Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
126 	Ndis802_11WEPDisabled,
127 	Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
128 	Ndis802_11WEPKeyAbsent,
129 	Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
130 	Ndis802_11WEPNotSupported,
131 	Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
132 	Ndis802_11Encryption2Enabled,
133 	Ndis802_11Encryption2KeyAbsent,
134 	Ndis802_11Encryption3Enabled,
135 	Ndis802_11Encryption3KeyAbsent
136 };
137 
138 #define NDIS_802_11_AI_REQFI_CAPABILITIES      1
139 #define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
140 #define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
141 
142 #define NDIS_802_11_AI_RESFI_CAPABILITIES      1
143 #define NDIS_802_11_AI_RESFI_STATUSCODE        2
144 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
145 
146 struct NDIS_802_11_AI_REQFI {
147 	u16 Capabilities;
148 	u16 ListenInterval;
149 	unsigned char CurrentAPAddress[6];
150 };
151 
152 struct NDIS_802_11_AI_RESFI {
153 	u16 Capabilities;
154 	u16 StatusCode;
155 	u16 AssociationId;
156 };
157 
158 struct NDIS_802_11_ASSOCIATION_INFORMATION {
159 	u32 Length;
160 	u16 AvailableRequestFixedIEs;
161 	struct NDIS_802_11_AI_REQFI RequestFixedIEs;
162 	u32 RequestIELength;
163 	u32 OffsetRequestIEs;
164 	u16 AvailableResponseFixedIEs;
165 	struct NDIS_802_11_AI_RESFI ResponseFixedIEs;
166 	u32 ResponseIELength;
167 	u32 OffsetResponseIEs;
168 };
169 
170 /* Key mapping keys require a BSSID*/
171 struct NDIS_802_11_KEY {
172 	u32 Length;			/* Length of this structure */
173 	u32 KeyIndex;
174 	u32 KeyLength;			/* length of key in bytes */
175 	unsigned char BSSID[6];
176 	unsigned long long KeyRSC;
177 	u8  KeyMaterial[32];		/* variable length */
178 };
179 
180 struct NDIS_802_11_REMOVE_KEY {
181 	u32 Length;			/* Length of this structure */
182 	u32 KeyIndex;
183 	unsigned char BSSID[6];
184 };
185 
186 struct NDIS_802_11_WEP {
187 	u32 Length;		  /* Length of this structure */
188 	u32 KeyIndex;		  /* 0 is the per-client key,
189 				   * 1-N are the global keys */
190 	u32 KeyLength;		  /* length of key in bytes */
191 	u8  KeyMaterial[16];      /* variable length depending on above field */
192 };
193 
194 /* mask for authentication/integrity fields */
195 #define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS        0x0f
196 #define NDIS_802_11_AUTH_REQUEST_REAUTH			0x01
197 #define NDIS_802_11_AUTH_REQUEST_KEYUPDATE		0x02
198 #define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR		0x06
199 #define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR		0x0E
200 
201 /* MIC check time, 60 seconds. */
202 #define MIC_CHECK_TIME	60000000
203 
204 #ifndef Ndis802_11APMode
205 #define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
206 #endif
207 
208 struct	wlan_network {
209 	struct list_head list;
210 	int	network_type;	/*refer to ieee80211.h for WIRELESS_11A/B/G */
211 	int	fixed;		/* set to fixed when not to be removed asi
212 				 * site-surveying */
213 	unsigned int	last_scanned; /*timestamp for the network */
214 	int	aid;		/*will only be valid when a BSS is joined. */
215 	int	join_res;
216 	struct ndis_wlan_bssid_ex network; /*must be the last item */
217 };
218 
219 enum VRTL_CARRIER_SENSE {
220 	DISABLE_VCS,
221 	ENABLE_VCS,
222 	AUTO_VCS
223 };
224 
225 enum VCS_TYPE {
226 	NONE_VCS,
227 	RTS_CTS,
228 	CTS_TO_SELF
229 };
230 
231 #define PWR_CAM 0
232 #define PWR_MINPS 1
233 #define PWR_MAXPS 2
234 #define PWR_UAPSD 3
235 #define PWR_VOIP 4
236 
237 enum UAPSD_MAX_SP {
238 	NO_LIMIT,
239 	TWO_MSDU,
240 	FOUR_MSDU,
241 	SIX_MSDU
242 };
243 
244 #define NUM_PRE_AUTH_KEY 16
245 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
246 
247 /*
248  *	WPA2
249  */
250 struct wlan_bssid_ex {
251 	u32 Length;
252 	unsigned char  MacAddress[6];
253 	u8  Reserved[2];
254 	struct ndis_802_11_ssid  Ssid;
255 	u32 Privacy;
256 	s32 Rssi;
257 	enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
258 	struct NDIS_802_11_CONFIGURATION  Configuration;
259 	enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
260 	NDIS_802_11_RATES_EX  SupportedRates;
261 	u32 IELength;
262 	u8  IEs[MAX_IE_SZ];	/* (timestamp, beacon interval, and capability
263 				 * information) */
264 };
265 
266 #endif /* #ifndef WLAN_BSSDEF_H_ */
267 
268