xref: /linux/drivers/staging/rtl8723bs/include/wlan_bssdef.h (revision 816e181560e230ea7d0bbb54db82200921e87547)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #ifndef __WLAN_BSSDEF_H__
8 #define __WLAN_BSSDEF_H__
9 
10 
11 #define MAX_IE_SZ	768
12 
13 
14 #define NDIS_802_11_LENGTH_SSID         32
15 #define NDIS_802_11_LENGTH_RATES        8
16 #define NDIS_802_11_LENGTH_RATES_EX     16
17 
18 typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        /*  Set of 8 data rates */
19 typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  /*  Set of 16 data rates */
20 
21 struct ndis_802_11_ssid {
22 	u32  ssid_length;
23 	u8  ssid[32];
24 };
25 
26 enum ndis_802_11_network_type {
27 	Ndis802_11FH,
28 	Ndis802_11DS,
29 	Ndis802_11OFDM5,
30 	Ndis802_11OFDM24,
31 	Ndis802_11NetworkTypeMax    /*  not a real type, defined as an upper bound */
32 };
33 
34 /*
35 	FW will only save the channel number in DSConfig.
36 	ODI Handler will convert the channel number to freq. number.
37 */
38 struct ndis_802_11_conf {
39 	u32 length;             /*  Length of structure */
40 	u32 beacon_period;       /*  units are Kusec */
41 	u32 atim_window;         /*  units are Kusec */
42 	u32 ds_config;           /*  Frequency, units are kHz */
43 };
44 
45 enum ndis_802_11_network_infrastructure {
46 	Ndis802_11IBSS,
47 	Ndis802_11Infrastructure,
48 	Ndis802_11AutoUnknown,
49 	Ndis802_11InfrastructureMax,     /*  Not a real value, defined as upper bound */
50 	Ndis802_11APMode,
51 };
52 
53 struct ndis_802_11_fix_ie {
54 	u8  time_stamp[8];
55 	u16  beacon_interval;
56 	u16  capabilities;
57 };
58 
59 struct ndis_80211_var_ie {
60 	u8  element_id;
61 	u8  length;
62 	u8  data[];
63 };
64 
65 /* Length is the 4 bytes multiples of the sum of
66  * ETH_ALEN + 2 +
67  * sizeof (struct ndis_802_11_ssid) + sizeof (u32) +
68  * sizeof (long) + sizeof (enum ndis_802_11_network_type) +
69  * sizeof (struct ndis_802_11_conf) + sizeof (NDIS_802_11_RATES_EX) + ie_length
70  *
71  * Except for ie_length, all other fields are fixed length. Therefore, we can
72  * define a macro to present the partial sum.
73  */
74 enum ndis_802_11_authentication_mode {
75 	Ndis802_11AuthModeOpen,
76 	Ndis802_11AuthModeShared,
77 	Ndis802_11AuthModeAutoSwitch,
78 	Ndis802_11AuthModeWPA,
79 	Ndis802_11AuthModeWPAPSK,
80 	Ndis802_11AuthModeWPANone,
81 	Ndis802_11AuthModeWAPI,
82 	Ndis802_11AuthModeMax   /*  Not a real mode, defined as upper bound */
83 };
84 
85 enum {
86 	Ndis802_11WEPEnabled,
87 	Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
88 	Ndis802_11WEPDisabled,
89 	Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
90 	Ndis802_11WEPKeyAbsent,
91 	Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
92 	Ndis802_11WEPNotSupported,
93 	Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
94 	Ndis802_11Encryption2Enabled,
95 	Ndis802_11Encryption2KeyAbsent,
96 	Ndis802_11Encryption3Enabled,
97 	Ndis802_11Encryption3KeyAbsent,
98 	Ndis802_11_EncrypteionWAPI
99 };
100 
101 #define NDIS_802_11_AI_REQFI_CAPABILITIES      1
102 #define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
103 #define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
104 
105 #define NDIS_802_11_AI_RESFI_CAPABILITIES      1
106 #define NDIS_802_11_AI_RESFI_STATUSCODE        2
107 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
108 
109 /*  Key mapping keys require a BSSID */
110 
111 struct ndis_802_11_wep {
112 	u32 length;        /*  Length of this structure */
113 	u32 key_index;      /*  0 is the per-client key, 1-N are the global keys */
114 	u32 key_length;     /*  length of key in bytes */
115 	u8 key_material[16];/*  variable length depending on above field */
116 };
117 
118 /*  mask for authentication/integrity fields */
119 #define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS        0x0f
120 #define NDIS_802_11_AUTH_REQUEST_REAUTH			0x01
121 #define NDIS_802_11_AUTH_REQUEST_KEYUPDATE		0x02
122 #define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR		0x06
123 #define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR		0x0E
124 
125 /*  MIC check time, 60 seconds. */
126 #define MIC_CHECK_TIME	60000000
127 
128 #ifndef Ndis802_11APMode
129 #define Ndis802_11APMode (Ndis802_11InfrastructureMax + 1)
130 #endif
131 
132 struct wlan_phy_info {
133 	u8 signal_strength;/* in percentage) */
134 	u8 signal_quality;/* in percentage) */
135 	u8 optimum_antenna;  /* for Antenna diversity */
136 	u8 reserved_0;
137 };
138 
139 struct wlan_bcn_info {
140 	/* these infor get from rtw_get_encrypt_info when
141 	 * * translate scan to UI */
142 	u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
143 	int group_cipher; /* WPA/WPA2 group cipher */
144 	int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */
145 	int is_8021x;
146 
147 	/* bwmode 20/40 and ch_offset UP/LOW */
148 	unsigned short	ht_cap_info;
149 	unsigned char ht_info_infos_0;
150 };
151 
152 /* temporally add #pragma pack for structure alignment issue of
153 *   struct wlan_bssid_ex and get_wlan_bssid_ex_sz()
154 */
155 struct wlan_bssid_ex {
156 	u32  length;
157 	u8 mac_address[ETH_ALEN];
158 	u8  reserved[2];/* 0]: IS beacon frame */
159 	struct ndis_802_11_ssid  ssid;
160 	u32  privacy;
161 	long  rssi;/* in dBM, raw data , get from PHY) */
162 	enum ndis_802_11_network_type  network_type_in_use;
163 	struct ndis_802_11_conf  configuration;
164 	enum ndis_802_11_network_infrastructure  infrastructure_mode;
165 	NDIS_802_11_RATES_EX  supported_rates;
166 	struct wlan_phy_info phy_info;
167 	u32  ie_length;
168 	u8  ies[MAX_IE_SZ];	/* timestamp, beacon interval, and capability information) */
169 } __packed;
170 
171 static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss)
172 {
173 	return (sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->ie_length);
174 }
175 
176 struct	wlan_network {
177 	struct list_head	list;
178 	int	network_type;	/* refer to ieee80211.h for WIRELESS_11A/B/G */
179 	int	fixed;			/*  set to fixed when not to be removed as site-surveying */
180 	unsigned long	last_scanned; /* timestamp for the network */
181 	int	aid;			/* will only be valid when a BSS is joinned. */
182 	int	join_res;
183 	struct wlan_bssid_ex	network; /* must be the last item */
184 	struct wlan_bcn_info	bcn_info;
185 };
186 
187 enum {
188 	DISABLE_VCS,
189 	ENABLE_VCS,
190 	AUTO_VCS
191 };
192 
193 enum {
194 	NONE_VCS,
195 	RTS_CTS,
196 	CTS_TO_SELF
197 };
198 
199 #define PWR_CAM 0
200 #define PWR_MINPS 1
201 #define PWR_MAXPS 2
202 #define PWR_UAPSD 3
203 #define PWR_VOIP 4
204 
205 enum {
206 	NO_LIMIT,
207 	TWO_MSDU,
208 	FOUR_MSDU,
209 	SIX_MSDU
210 };
211 
212 #define NUM_PRE_AUTH_KEY 16
213 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
214 
215 #endif /* ifndef WLAN_BSSDEF_H_ */
216