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