add MTK-combo-module,continue with commit 17f39ed917874e77e80411f33faba1b7ee8138c8
[firefly-linux-kernel-4.4.55.git] / drivers / mtk_wcn_combo / drv_wlan / wlan / include / mgmt / privacy.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_2/include/mgmt/privacy.h#1 $
3 */
4
5 /*! \file   privacy.h
6     \brief This file contains the function declaration for privacy.c.
7 */
8
9 /*******************************************************************************
10 * Copyright (c) 2007 MediaTek Inc.
11 *
12 * All rights reserved. Copying, compilation, modification, distribution
13 * or any other use whatsoever of this material is strictly prohibited
14 * except in accordance with a Software License Agreement with
15 * MediaTek Inc.
16 ********************************************************************************
17 */
18
19 /*******************************************************************************
20 * LEGAL DISCLAIMER
21 *
22 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
23 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
24 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
25 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
26 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
28 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
29 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
30 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
31 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
32 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
33 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
34 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
35 *
36 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
37 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
38 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
39 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
40 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
41 *
42 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
43 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
44 * OF LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
45 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
46 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
47 * (ICC).
48 ********************************************************************************
49 */
50
51 /*
52 ** $Log: privacy.h $
53  *
54  * 03 18 2011 cp.wu
55  * [WCXRP00000577] [MT6620 Wi-Fi][Driver][FW] Create V2.0 branch for firmware and driver
56  * create V2.0 driver release based on label "MT6620_WIFI_DRIVER_V2_0_110318_1600" from main trunk
57  *
58  * 07 24 2010 wh.su
59  * 
60  * .support the Wi-Fi RSN
61  *
62  * 07 08 2010 cp.wu
63  *
64  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
65  *
66  * 06 21 2010 wh.su
67  * [WPD00003840][MT6620 5931] Security migration
68  * modify some code for concurrent network.
69  *
70  * 06 19 2010 wh.su
71  * [WPD00003840][MT6620 5931] Security migration
72  * consdier the concurrent network setting.
73  *
74  * 06 18 2010 wh.su
75  * [WPD00003840][MT6620 5931] Security migration
76  * migration the security related function from firmware.
77  *
78  * 03 01 2010 wh.su
79  * [BORA00000605][WIFISYS] Phase3 Integration
80  * Refine the variable and parameter for security.
81  *
82  * 02 25 2010 wh.su
83  * [BORA00000626][MT6620] Refine the remove key flow for WHQL testing
84  * For support the WHQL test, do the remove key code refine.
85  *
86  * Dec 10 2009 mtk01088
87  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
88  * change the cmd return type
89  *
90  * Dec 8 2009 mtk01088
91  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
92  * adding the function declaration for auth mode and encryption status setting from build connection command
93  *
94  * Dec 7 2009 mtk01088
95  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
96  * adding the function declaration for wapi
97  *
98  * Dec 7 2009 mtk01088
99  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
100  * adding the tx done callback handle function
101  *
102  * Dec 7 2009 mtk01088
103  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
104  * adding the function declaration for mac header privacy bit setting
105  *
106  * Dec 4 2009 mtk01088
107  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
108  * adding the structure for parsing the EAPoL frame
109  *
110  * Dec 3 2009 mtk01088
111  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
112  * adjust the class error function parameter
113  *
114  * Dec 1 2009 mtk01088
115  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
116  * adding some security function declaration
117  *
118  * Nov 19 2009 mtk01088
119  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
120  * adding the ap selection structure
121  *
122  * Nov 18 2009 mtk01088
123  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
124  *
125 **
126 */
127
128 #ifndef _PRIVACY_H
129 #define _PRIVACY_H
130
131 /*******************************************************************************
132 *                         C O M P I L E R   F L A G S
133 ********************************************************************************
134 */
135
136 /*******************************************************************************
137 *                    E X T E R N A L   R E F E R E N C E S
138 ********************************************************************************
139 */
140
141 /*******************************************************************************
142 *                              C O N S T A N T S
143 ********************************************************************************
144 */
145 #define MAX_KEY_NUM                             4
146 #define WEP_40_LEN                              5
147 #define WEP_104_LEN                             13
148 #define LEGACY_KEY_MAX_LEN                      16
149 #define CCMP_KEY_LEN                            16
150 #define TKIP_KEY_LEN                            32
151 #define MAX_KEY_LEN                             32
152 #define MIC_RX_KEY_OFFSET                       16
153 #define MIC_TX_KEY_OFFSET                       24
154 #define MIC_KEY_LEN                             8
155
156 #define WEP_KEY_ID_FIELD      BITS(0,29)
157 #define KEY_ID_FIELD          BITS(0,7)
158
159 #define IS_TRANSMIT_KEY       BIT(31)
160 #define IS_UNICAST_KEY        BIT(30)
161 #define IS_AUTHENTICATOR      BIT(28)
162
163 #define CIPHER_SUITE_NONE               0
164 #define CIPHER_SUITE_WEP40              1
165 #define CIPHER_SUITE_TKIP               2
166 #define CIPHER_SUITE_TKIP_WO_MIC        3
167 #define CIPHER_SUITE_CCMP               4
168 #define CIPHER_SUITE_WEP104             5
169 #define CIPHER_SUITE_BIP                6
170 #define CIPHER_SUITE_WEP128             7
171 #define CIPHER_SUITE_WPI                8
172
173 #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */
174 #define WPA_KEY_INFO_MIC      BIT(8)
175 #define WPA_KEY_INFO_SECURE   BIT(9)
176
177 #define MASK_2ND_EAPOL       (WPA_KEY_INFO_KEY_TYPE | WPA_KEY_INFO_MIC)
178
179
180 /*******************************************************************************
181 *                         D A T A   T Y P E S
182 ********************************************************************************
183 */
184
185 typedef struct _IEEE_802_1X_HDR {
186     UINT_8      ucVersion;
187     UINT_8      ucType;
188     UINT_16     u2Length;
189     /* followed by length octets of data */
190 } IEEE_802_1X_HDR, *P_IEEE_802_1X_HDR;
191
192 typedef struct _EAPOL_KEY {
193     UINT_8 ucType;
194     /* Note: key_info, key_length, and key_data_length are unaligned */
195     UINT_8 aucKeyInfo[2]; /* big endian */
196     UINT_8 aucKeyLength[2]; /* big endian */
197     UINT_8 aucReplayCounter[8];
198     UINT_8 aucKeyNonce[16];
199     UINT_8 aucKeyIv[16];
200     UINT_8 aucKeyRsc[8];
201     UINT_8 aucKeyId[8]; /* Reserved in IEEE 802.11i/RSN */
202     UINT_8 aucKeyMic[16];
203     UINT_8 aucKeyDataLength[2]; /* big endian */
204     /* followed by key_data_length bytes of key_data */
205 } EAPOL_KEY, *P_EAPOL_KEY;
206
207 /* WPA2 PMKID candicate structure */
208 typedef struct _PMKID_CANDICATE_T {
209     UINT_8              aucBssid[MAC_ADDR_LEN];
210     UINT_32             u4PreAuthFlags;
211 } PMKID_CANDICATE_T, *P_PMKID_CANDICATE_T;
212
213 #if 0
214 /* WPA2 PMKID cache structure */
215 typedef struct _PMKID_ENTRY_T {
216     PARAM_BSSID_INFO_T  rBssidInfo;
217     BOOLEAN             fgPmkidExist;
218 } PMKID_ENTRY_T, *P_PMKID_ENTRY_T;
219 #endif
220
221 /*******************************************************************************
222 *                            P U B L I C   D A T A
223 ********************************************************************************
224 */
225
226 /*******************************************************************************
227 *                           P R I V A T E   D A T A
228 ********************************************************************************
229 */
230
231 /*******************************************************************************
232 *                                 M A C R O S
233 ********************************************************************************
234 */
235
236 /*******************************************************************************
237 *                  F U N C T I O N   D E C L A R A T I O N S
238 ********************************************************************************
239 */
240
241 VOID
242 secInit(
243     IN P_ADAPTER_T          prAdapter,
244     IN UINT_8               ucNetTypeIdx
245     );
246
247 VOID
248 secSetPortBlocked(
249     IN P_ADAPTER_T          prAdapter,
250     IN P_STA_RECORD_T       prSta,
251     IN BOOLEAN              fgPort
252    );
253
254 BOOL
255 secCheckClassError(
256     IN P_ADAPTER_T          prAdapter,
257     IN P_SW_RFB_T           prSwRfb,
258     IN P_STA_RECORD_T       prStaRec
259     );
260
261 BOOL
262 secTxPortControlCheck(
263     IN P_ADAPTER_T          prAdapter,
264     IN P_MSDU_INFO_T        prMsduInfo,
265     IN P_STA_RECORD_T       prStaRec
266     );
267
268 BOOLEAN
269 secRxPortControlCheck(
270     IN P_ADAPTER_T          prAdapter,
271     IN P_SW_RFB_T           prSWRfb
272     );
273
274 VOID
275 secSetCipherSuite(
276     IN P_ADAPTER_T prAdapter,
277     IN UINT_32     u4CipherSuitesFlags
278     );
279
280 BOOL
281 secProcessEAPOL(
282     IN P_ADAPTER_T          prAdapter,
283     IN P_MSDU_INFO_T        prMsduInfo,
284     IN P_STA_RECORD_T       prStaRec,
285     IN PUINT_8              pucPayload,
286     IN UINT_16              u2PayloadLen
287    );
288
289 VOID
290 secHandleTxDoneCallback(
291     IN P_ADAPTER_T          prAdapter,
292     IN P_MSDU_INFO_T        pMsduInfo,
293     IN P_STA_RECORD_T       prStaRec,
294     IN WLAN_STATUS          rStatus
295     );
296
297 BOOLEAN
298 secIsProtectedFrame (
299     IN P_ADAPTER_T          prAdapter,
300     IN P_MSDU_INFO_T        prMsdu,
301     IN P_STA_RECORD_T       prStaRec
302     );
303
304 VOID
305 secClearPmkid(
306     IN P_ADAPTER_T          prAdapter
307     );
308
309 BOOLEAN
310 secRsnKeyHandshakeEnabled(
311     IN P_ADAPTER_T          prAdapter
312     );
313
314 BOOLEAN
315 secTransmitKeyExist(
316     IN P_ADAPTER_T          prAdapter,
317     IN P_STA_RECORD_T       prSta
318     );
319
320 BOOLEAN
321 secEnabledInAis(
322     IN P_ADAPTER_T          prAdapter
323     );
324
325
326 /*******************************************************************************
327 *                              F U N C T I O N S
328 ********************************************************************************
329 */
330
331 #endif /* _PRIVACY_H */
332