1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2019 Realtek Corporation.
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 *****************************************************************************/
15 #ifndef __WLAN_BSSDEF_H__
16 #define __WLAN_BSSDEF_H__
17
18
19 #define MAX_IE_SZ 768
20
21
22 #ifdef PLATFORM_LINUX
23
24 #define NDIS_802_11_LENGTH_SSID 32
25 #define NDIS_802_11_LENGTH_RATES 8
26 #define NDIS_802_11_LENGTH_RATES_EX 16
27
28 typedef unsigned char NDIS_802_11_MAC_ADDRESS[ETH_ALEN];
29 typedef long NDIS_802_11_RSSI; /* in dBm */
30 typedef unsigned char NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; /* Set of 8 data rates */
31 typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; /* Set of 16 data rates */
32
33 typedef struct _NDIS_802_11_SSID {
34 u32 SsidLength;
35 u8 Ssid[32];
36 } NDIS_802_11_SSID, *PNDIS_802_11_SSID;
37
38 /*
39 FW will only save the channel number in DSConfig.
40 ODI Handler will convert the channel number to freq. number.
41 */
42 typedef struct _NDIS_802_11_CONFIGURATION {
43 u32 Length; /* Length of structure */
44 u32 BeaconPeriod; /* units are Kusec */
45 u32 ATIMWindow; /* units are Kusec */
46 u32 DSConfig; /* channel number */
47 } NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
48
49 typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
50 Ndis802_11IBSS,
51 Ndis802_11Infrastructure,
52 Ndis802_11AutoUnknown,
53 Ndis802_11InfrastructureMax, /* Not a real value, defined as upper bound */
54 Ndis802_11APMode,
55 Ndis802_11Monitor,
56 Ndis802_11_mesh,
57 } NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
58
59 typedef struct _NDIS_802_11_FIXED_IEs {
60 u8 Timestamp[8];
61 u16 BeaconInterval;
62 u16 Capabilities;
63 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
64
65 typedef struct _NDIS_802_11_VARIABLE_IEs {
66 u8 ElementID;
67 u8 Length;
68 u8 data[1];
69 } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
70
71 typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
72 Ndis802_11AuthModeOpen,
73 Ndis802_11AuthModeShared,
74 Ndis802_11AuthModeAutoSwitch,
75 Ndis802_11AuthModeWPA,
76 Ndis802_11AuthModeWPAPSK,
77 Ndis802_11AuthModeWPANone,
78 Ndis802_11AuthModeWAPI,
79 Ndis802_11AuthModeMax /* Not a real mode, defined as upper bound */
80 } NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
81
82 typedef enum _NDIS_802_11_WEP_STATUS {
83 Ndis802_11WEPEnabled,
84 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
85 Ndis802_11WEPDisabled,
86 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
87 Ndis802_11WEPKeyAbsent,
88 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
89 Ndis802_11WEPNotSupported,
90 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
91 Ndis802_11Encryption2Enabled,
92 Ndis802_11Encryption2KeyAbsent,
93 Ndis802_11Encryption3Enabled,
94 Ndis802_11Encryption3KeyAbsent,
95 Ndis802_11_EncrypteionWAPI
96 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
97 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
98
99 typedef struct _NDIS_802_11_WEP {
100 u32 Length; /* Length of this structure */
101 u32 KeyIndex; /* 0 is the per-client key, 1-N are the global keys */
102 u32 KeyLength; /* length of key in bytes */
103 u8 KeyMaterial[16];/* variable length depending on above field */
104 } NDIS_802_11_WEP, *PNDIS_802_11_WEP;
105
106 #endif /* end of #ifdef PLATFORM_LINUX */
107
108 #ifdef PLATFORM_FREEBSD
109
110 #define NDIS_802_11_LENGTH_SSID 32
111 #define NDIS_802_11_LENGTH_RATES 8
112 #define NDIS_802_11_LENGTH_RATES_EX 16
113
114 typedef unsigned char NDIS_802_11_MAC_ADDRESS[ETH_ALEN];
115 typedef long NDIS_802_11_RSSI; /* in dBm */
116 typedef unsigned char NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; /* Set of 8 data rates */
117 typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; /* Set of 16 data rates */
118
119
120 typedef struct _NDIS_802_11_SSID {
121 u32 SsidLength;
122 u8 Ssid[32];
123 } NDIS_802_11_SSID, *PNDIS_802_11_SSID;
124
125 /*
126 FW will only save the channel number in DSConfig.
127 ODI Handler will convert the channel number to freq. number.
128 */
129 typedef struct _NDIS_802_11_CONFIGURATION {
130 u32 Length; /* Length of structure */
131 u32 BeaconPeriod; /* units are Kusec */
132 u32 ATIMWindow; /* units are Kusec */
133 u32 DSConfig; /* channel number */
134 } NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
135
136 typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE {
137 Ndis802_11IBSS,
138 Ndis802_11Infrastructure,
139 Ndis802_11AutoUnknown,
140 Ndis802_11InfrastructureMax, /* Not a real value, defined as upper bound */
141 Ndis802_11APMode
142 } NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
143
144 typedef struct _NDIS_802_11_FIXED_IEs {
145 u8 Timestamp[8];
146 u16 BeaconInterval;
147 u16 Capabilities;
148 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
149
150 typedef struct _NDIS_802_11_VARIABLE_IEs {
151 u8 ElementID;
152 u8 Length;
153 u8 data[1];
154 } NDIS_802_11_VARIABLE_IEs, *PNDIS_802_11_VARIABLE_IEs;
155
156 typedef enum _NDIS_802_11_AUTHENTICATION_MODE {
157 Ndis802_11AuthModeOpen,
158 Ndis802_11AuthModeShared,
159 Ndis802_11AuthModeAutoSwitch,
160 Ndis802_11AuthModeWPA,
161 Ndis802_11AuthModeWPAPSK,
162 Ndis802_11AuthModeWPANone,
163 Ndis802_11AuthModeMax /* Not a real mode, defined as upper bound */
164 } NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
165
166 typedef enum _NDIS_802_11_WEP_STATUS {
167 Ndis802_11WEPEnabled,
168 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
169 Ndis802_11WEPDisabled,
170 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
171 Ndis802_11WEPKeyAbsent,
172 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
173 Ndis802_11WEPNotSupported,
174 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
175 Ndis802_11Encryption2Enabled,
176 Ndis802_11Encryption2KeyAbsent,
177 Ndis802_11Encryption3Enabled,
178 Ndis802_11Encryption3KeyAbsent
179 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
180 NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
181
182
183 typedef struct _NDIS_802_11_WEP {
184 u32 Length; /* Length of this structure */
185 u32 KeyIndex; /* 0 is the per-client key, 1-N are the global keys */
186 u32 KeyLength; /* length of key in bytes */
187 u8 KeyMaterial[16];/* variable length depending on above field */
188 } NDIS_802_11_WEP, *PNDIS_802_11_WEP;
189
190 #endif /* PLATFORM_FREEBSD */
191
192 #ifndef Ndis802_11APMode
193 #define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
194 #endif
195
196 /*RTW_WKARD_CORE_RSSI_V1 - GEORGIA MUST REFINE*/
197 typedef struct _WLAN_PHY_INFO {
198 u8 SignalStrength;/* (in percentage) */
199 u8 SignalQuality;/* (in percentage) */
200 s8 rssi; /*dbm*/
201 u8 Optimum_antenna; /* for Antenna diversity */
202 u8 is_cck_rate; /* 1:cck_rate */
203 s8 rx_snr[4];
204 #ifdef CONFIG_RTW_80211K
205 u32 free_cnt; /* freerun counter */
206 u8 rm_en_cap[5];
207 #endif
208 } WLAN_PHY_INFO, *PWLAN_PHY_INFO;
209
210 typedef struct _WLAN_BCN_INFO {
211 /* these infor get from rtw_get_encrypt_info when
212 * * translate scan to UI */
213 u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
214 int group_cipher; /* WPA/WPA2 group cipher */
215 int pairwise_cipher;/* //WPA/WPA2/WEP pairwise cipher */
216 int is_8021x;
217
218 /* bwmode 20/40 and ch_offset UP/LOW */
219 unsigned short ht_cap_info;
220 unsigned char ht_info_infos_0;
221 } WLAN_BCN_INFO, *PWLAN_BCN_INFO;
222
223 enum bss_type {
224 BSS_TYPE_UNDEF,
225 BSS_TYPE_BCN = 1,
226 BSS_TYPE_PROB_REQ = 2,
227 BSS_TYPE_PROB_RSP = 3,
228 };
229
230 /* temporally add #pragma pack for structure alignment issue of
231 * WLAN_BSSID_EX and get_WLAN_BSSID_EX_sz()
232 */
233 typedef struct _WLAN_BSSID_EX {
234 u32 Length;
235 NDIS_802_11_MAC_ADDRESS MacAddress;
236 u8 Reserved[2];/* [0]: IS beacon frame , bss_type*/
237 NDIS_802_11_SSID Ssid;
238 NDIS_802_11_SSID mesh_id;
239 u32 Privacy;
240 NDIS_802_11_CONFIGURATION Configuration;
241 NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
242 NDIS_802_11_RATES_EX SupportedRates;
243 WLAN_PHY_INFO PhyInfo;
244 #ifdef CONFIG_STA_MULTIPLE_BSSID
245 u8 is_mbssid;
246 u8 mbssid_index;
247 #endif
248 u32 IELength;
249 u8 IEs[MAX_IE_SZ]; /* (timestamp, beacon interval, and capability information) */
250 }
251 __attribute__((packed)) WLAN_BSSID_EX, *PWLAN_BSSID_EX;
252
253 #define BSS_EX_IES(bss_ex) ((bss_ex)->IEs)
254 #define BSS_EX_IES_LEN(bss_ex) ((bss_ex)->IELength)
255 #define BSS_EX_FIXED_IE_OFFSET(bss_ex) ((bss_ex)->Reserved[0] == BSS_TYPE_PROB_REQ ? 0 : 12)
256 #define BSS_EX_TLV_IES(bss_ex) (BSS_EX_IES((bss_ex)) + BSS_EX_FIXED_IE_OFFSET((bss_ex)))
257 #define BSS_EX_TLV_IES_LEN(bss_ex) (BSS_EX_IES_LEN((bss_ex)) - BSS_EX_FIXED_IE_OFFSET((bss_ex)))
258
get_WLAN_BSSID_EX_sz(WLAN_BSSID_EX * bss)259 __inline static uint get_WLAN_BSSID_EX_sz(WLAN_BSSID_EX *bss)
260 {
261 return sizeof(WLAN_BSSID_EX) - MAX_IE_SZ + bss->IELength;
262 }
263
264 struct wlan_network {
265 _list list;
266 int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */
267 int fixed; /* set to fixed when not to be removed as site-surveying */
268 systime last_scanned; /* timestamp for the network */
269 #ifdef CONFIG_RTW_MESH
270 #if CONFIG_RTW_MESH_ACNODE_PREVENT
271 systime acnode_stime;
272 systime acnode_notify_etime;
273 #endif
274 #endif
275 int aid; /* will only be valid when a BSS is joinned. */
276 int join_res;
277 WLAN_BSSID_EX network; /* must be the last item */
278 };
279
280 enum VRTL_CARRIER_SENSE {
281 DISABLE_VCS,
282 ENABLE_VCS,
283 AUTO_VCS
284 };
285
286 enum VCS_TYPE {
287 NONE_VCS,
288 RTS_CTS,
289 CTS_TO_SELF
290 };
291
292
293
294
295 #define PWR_CAM 0
296 #define PWR_MINPS 1
297 #define PWR_MAXPS 2
298 #define PWR_UAPSD 3
299 #define PWR_VOIP 4
300
301
302 enum UAPSD_MAX_SP {
303 NO_LIMIT,
304 TWO_MSDU,
305 FOUR_MSDU,
306 SIX_MSDU
307 };
308
309
310 /* john */
311 #define NUM_PRE_AUTH_KEY 16
312 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
313
314 #endif /* #ifndef WLAN_BSSDEF_H_ */
315