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 #define MAX_IE_SZ 768
11
12 #define NDIS_802_11_LENGTH_SSID 32
13 #define NDIS_802_11_LENGTH_RATES 8
14 #define NDIS_802_11_LENGTH_RATES_EX 16
15
16 #define NDIS_802_11_RSSI long /* in dBm */
17
18 struct ndis_802_11_ssid {
19 u32 ssid_length;
20 u8 ssid[32];
21 };
22
23 enum NDIS_802_11_NETWORK_TYPE {
24 Ndis802_11FH,
25 Ndis802_11DS,
26 Ndis802_11OFDM5,
27 Ndis802_11OFDM24,
28 Ndis802_11NetworkTypeMax /* dummy upper bound */
29 };
30
31 struct ndis_802_11_config_fh {
32 u32 Length; /* Length of structure */
33 u32 HopPattern; /* As defined by 802.11, MSB set */
34 u32 HopSet; /* to one if non-802.11 */
35 u32 DwellTime; /* units are Kusec */
36 };
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 struct ndis_802_11_config {
43 u32 Length; /* Length of structure */
44 u32 BeaconPeriod; /* units are Kusec */
45 u32 ATIMWindow; /* units are Kusec */
46 u32 DSConfig; /* Frequency, units are kHz */
47 struct ndis_802_11_config_fh FHConfig;
48 };
49
50 enum ndis_802_11_network_infra {
51 Ndis802_11IBSS,
52 Ndis802_11Infrastructure,
53 Ndis802_11AutoUnknown,
54 Ndis802_11InfrastructureMax, /* dummy upper bound */
55 Ndis802_11APMode
56 };
57
58 struct ndis_802_11_fixed_ie {
59 u8 Timestamp[8];
60 u16 BeaconInterval;
61 u16 Capabilities;
62 };
63
64 struct ndis_802_11_var_ie {
65 u8 ElementID;
66 u8 Length;
67 u8 data[1];
68 };
69
70 /*
71 * Length is the 4 bytes multiples of the sume of
72 * [ETH_ALEN] + 2 + sizeof (struct ndis_802_11_ssid) + sizeof (u32)
73 * + sizeof (NDIS_802_11_RSSI) + sizeof (enum NDIS_802_11_NETWORK_TYPE)
74 * + sizeof (struct ndis_802_11_config)
75 * + NDIS_802_11_LENGTH_RATES_EX + ie_length
76 *
77 * Except the ie_length, all other fields are fixed length.
78 * Therefore, we can define a macro to represent the partial sum.
79 */
80
81 enum ndis_802_11_auth_mode {
82 Ndis802_11AuthModeOpen,
83 Ndis802_11AuthModeShared,
84 Ndis802_11AuthModeAutoSwitch,
85 Ndis802_11AuthModeWPA,
86 Ndis802_11AuthModeWPAPSK,
87 Ndis802_11AuthModeWPANone,
88 Ndis802_11AuthModeWAPI,
89 Ndis802_11AuthModeMax /* Not a real mode, upper bound */
90 };
91
92 enum ndis_802_11_wep_status {
93 Ndis802_11WEPEnabled,
94 Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
95 Ndis802_11WEPDisabled,
96 Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
97 Ndis802_11WEPKeyAbsent,
98 Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
99 Ndis802_11WEPNotSupported,
100 Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
101 Ndis802_11Encryption2Enabled,
102 Ndis802_11Encryption2KeyAbsent,
103 Ndis802_11Encryption3Enabled,
104 Ndis802_11Encryption3KeyAbsent,
105 Ndis802_11_EncryptionWAPI
106 };
107
108 #define NDIS_802_11_AI_REQFI_CAPABILITIES 1
109 #define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
110 #define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
111
112 #define NDIS_802_11_AI_RESFI_CAPABILITIES 1
113 #define NDIS_802_11_AI_RESFI_STATUSCODE 2
114 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
115
116 enum ndis_802_11_reload_def {
117 Ndis802_11ReloadWEPKeys
118 };
119
120 struct ndis_802_11_wep {
121 u32 Length; /* Length of this structure */
122 u32 KeyIndex; /* 0 is the per-client key,
123 * 1-N are the global keys
124 */
125 u32 KeyLength; /* length of key in bytes */
126 u8 KeyMaterial[16];/* variable len depending on above field */
127 };
128
129 enum ndis_802_11_status_type {
130 Ndis802_11StatusType_Authentication,
131 Ndis802_11StatusType_MediaStreamMode,
132 Ndis802_11StatusType_PMKID_CandidateList,
133 Ndis802_11StatusTypeMax /* not a real type, defined as
134 * an upper bound
135 */
136 };
137
138 /* mask for authentication/integrity fields */
139 #define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
140 #define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
141 #define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
142 #define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
143 #define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
144
145 /* MIC check time, 60 seconds. */
146 #define MIC_CHECK_TIME 60000000
147
148 #ifndef Ndis802_11APMode
149 #define Ndis802_11APMode (Ndis802_11InfrastructureMax + 1)
150 #endif
151
152 struct wlan_phy_info {
153 u8 SignalStrength;/* in percentage) */
154 u8 SignalQuality;/* in percentage) */
155 u8 Optimum_antenna; /* for Antenna diversity */
156 u8 Reserved_0;
157 };
158
159 struct wlan_bcn_info {
160 /* these infor get from rtw_get_encrypt_info when
161 * * translate scan to UI
162 */
163 u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */
164 int group_cipher; /* WPA/WPA2 group cipher */
165 int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */
166 int is_8021x;
167
168 /* bwmode 20/40 and ch_offset UP/LOW */
169 unsigned short ht_cap_info;
170 unsigned char ht_info_infos_0;
171 };
172
173 /* temporally add #pragma pack for structure alignment issue of
174 * struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz()
175 */
176 struct wlan_bssid_ex {
177 u32 Length;
178 unsigned char MacAddress[ETH_ALEN];
179 u8 Reserved[2];/* 0]: IS beacon frame */
180 struct ndis_802_11_ssid ssid;
181 u32 Privacy;
182 NDIS_802_11_RSSI Rssi;/* in dBM,raw data ,get from PHY) */
183 enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
184 struct ndis_802_11_config Configuration;
185 enum ndis_802_11_network_infra InfrastructureMode;
186 unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
187 struct wlan_phy_info PhyInfo;
188 u32 ie_length;
189 u8 ies[MAX_IE_SZ]; /* timestamp, beacon interval, and
190 * capability information)
191 */
192 } __packed;
193
get_wlan_bssid_ex_sz(struct wlan_bssid_ex * bss)194 static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss)
195 {
196 return sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->ie_length;
197 }
198
199 struct wlan_network {
200 struct list_head list;
201 int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */
202 int fixed; /* set fixed when not to be removed
203 * in site-surveying
204 */
205 unsigned long last_scanned; /* timestamp for the network */
206 int aid; /* will only be valid when a BSS is joinned. */
207 int join_res;
208 struct wlan_bssid_ex network; /* must be the last item */
209 struct wlan_bcn_info BcnInfo;
210 };
211
212 enum VRTL_CARRIER_SENSE {
213 DISABLE_VCS,
214 ENABLE_VCS,
215 AUTO_VCS
216 };
217
218 enum VCS_TYPE {
219 NONE_VCS,
220 RTS_CTS,
221 CTS_TO_SELF
222 };
223
224 #define PWR_CAM 0
225 #define PWR_MINPS 1
226 #define PWR_MAXPS 2
227 #define PWR_UAPSD 3
228 #define PWR_VOIP 4
229
230 enum UAPSD_MAX_SP {
231 NO_LIMIT,
232 TWO_MSDU,
233 FOUR_MSDU,
234 SIX_MSDU
235 };
236
237 #define NUM_PRE_AUTH_KEY 16
238 #define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
239
240 #endif /* ifndef WLAN_BSSDEF_H_ */
241