xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8821cs/include/wlan_bssdef.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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_PROB_REQ = 1,
225 	BSS_TYPE_BCN = 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 beacon_keys {
261 	u8 ssid[IW_ESSID_MAX_SIZE];
262 	u32 ssid_len;
263 	u8 ch;
264 	u8 bw;
265 	u8 offset;
266 	u8 proto_cap; /* PROTO_CAP_XXX */
267 	u8 rate_set[12];
268 	u8 rate_num;
269 	int encryp_protocol;
270 	int pairwise_cipher;
271 	int group_cipher;
272 	u32 akm;
273 };
274 
275 struct	wlan_network {
276 	_list	list;
277 	int	network_type;	/* refer to ieee80211.h for WIRELESS_11A/B/G */
278 	int	fixed;			/* set to fixed when not to be removed as site-surveying */
279 	systime last_scanned; /* timestamp for the network */
280 	systime last_non_hidden_ssid_ap;
281 #ifdef CONFIG_RTW_MESH
282 #if CONFIG_RTW_MESH_ACNODE_PREVENT
283 	systime acnode_stime;
284 	systime acnode_notify_etime;
285 #endif
286 #endif
287 	int	aid;			/* will only be valid when a BSS is joinned. */
288 	int	join_res;
289 	struct beacon_keys bcn_keys;
290 	bool bcn_keys_valid;
291 	WLAN_BSSID_EX	network; /* must be the last item */
292 };
293 
294 enum VRTL_CARRIER_SENSE {
295 	DISABLE_VCS,
296 	ENABLE_VCS,
297 	AUTO_VCS
298 };
299 
300 enum VCS_TYPE {
301 	NONE_VCS,
302 	RTS_CTS,
303 	CTS_TO_SELF
304 };
305 
306 
307 
308 
309 #define PWR_CAM 0
310 #define PWR_MINPS 1
311 #define PWR_MAXPS 2
312 #define PWR_UAPSD 3
313 #define PWR_VOIP 4
314 
315 
316 enum UAPSD_MAX_SP {
317 	NO_LIMIT,
318 	TWO_MSDU,
319 	FOUR_MSDU,
320 	SIX_MSDU
321 };
322 
323 
324 /* john */
325 #define NUM_PRE_AUTH_KEY 16
326 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
327 
328 #endif /* #ifndef WLAN_BSSDEF_H_ */
329