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