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