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