wifi: renew patch drivers/net/wireless
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / combo_mt66xx / mt6628 / wlan / include / mgmt / privacy.h
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/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
11 /*
12 ** $Log: privacy.h $
13  *
14  * 07 24 2010 wh.su
15  * 
16  * .support the Wi-Fi RSN
17  *
18  * 07 08 2010 cp.wu
19  *
20  * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
21  *
22  * 06 21 2010 wh.su
23  * [WPD00003840][MT6620 5931] Security migration
24  * modify some code for concurrent network.
25  *
26  * 06 19 2010 wh.su
27  * [WPD00003840][MT6620 5931] Security migration
28  * consdier the concurrent network setting.
29  *
30  * 06 18 2010 wh.su
31  * [WPD00003840][MT6620 5931] Security migration
32  * migration the security related function from firmware.
33  *
34  * 03 01 2010 wh.su
35  * [BORA00000605][WIFISYS] Phase3 Integration
36  * Refine the variable and parameter for security.
37  *
38  * 02 25 2010 wh.su
39  * [BORA00000626][MT6620] Refine the remove key flow for WHQL testing
40  * For support the WHQL test, do the remove key code refine.
41  *
42  * Dec 10 2009 mtk01088
43  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
44  * change the cmd return type
45  *
46  * Dec 8 2009 mtk01088
47  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
48  * adding the function declaration for auth mode and encryption status setting from build connection command
49  *
50  * Dec 7 2009 mtk01088
51  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
52  * adding the function declaration for wapi
53  *
54  * Dec 7 2009 mtk01088
55  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
56  * adding the tx done callback handle function
57  *
58  * Dec 7 2009 mtk01088
59  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
60  * adding the function declaration for mac header privacy bit setting
61  *
62  * Dec 4 2009 mtk01088
63  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
64  * adding the structure for parsing the EAPoL frame
65  *
66  * Dec 3 2009 mtk01088
67  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
68  * adjust the class error function parameter
69  *
70  * Dec 1 2009 mtk01088
71  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
72  * adding some security function declaration
73  *
74  * Nov 19 2009 mtk01088
75  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
76  * adding the ap selection structure
77  *
78  * Nov 18 2009 mtk01088
79  * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
80  *
81 **
82 */
83
84 #ifndef _PRIVACY_H
85 #define _PRIVACY_H
86
87 /*******************************************************************************
88 *                         C O M P I L E R   F L A G S
89 ********************************************************************************
90 */
91
92 /*******************************************************************************
93 *                    E X T E R N A L   R E F E R E N C E S
94 ********************************************************************************
95 */
96
97 /*******************************************************************************
98 *                              C O N S T A N T S
99 ********************************************************************************
100 */
101 #define MAX_KEY_NUM                             4
102 #define WEP_40_LEN                              5
103 #define WEP_104_LEN                             13
104 #define LEGACY_KEY_MAX_LEN                      16
105 #define CCMP_KEY_LEN                            16
106 #define TKIP_KEY_LEN                            32
107 #define MAX_KEY_LEN                             32
108 #define MIC_RX_KEY_OFFSET                       16
109 #define MIC_TX_KEY_OFFSET                       24
110 #define MIC_KEY_LEN                             8
111
112 #define WEP_KEY_ID_FIELD      BITS(0,29)
113 #define KEY_ID_FIELD          BITS(0,7)
114
115 #define IS_TRANSMIT_KEY       BIT(31)
116 #define IS_UNICAST_KEY        BIT(30)
117 #define IS_AUTHENTICATOR      BIT(28)
118
119 #define CIPHER_SUITE_NONE               0
120 #define CIPHER_SUITE_WEP40              1
121 #define CIPHER_SUITE_TKIP               2
122 #define CIPHER_SUITE_TKIP_WO_MIC        3
123 #define CIPHER_SUITE_CCMP               4
124 #define CIPHER_SUITE_WEP104             5
125 #define CIPHER_SUITE_BIP                6
126 #define CIPHER_SUITE_WEP128             7
127 #define CIPHER_SUITE_WPI                8
128
129 #define WPA_KEY_INFO_KEY_TYPE BIT(3) /* 1 = Pairwise, 0 = Group key */
130 #define WPA_KEY_INFO_MIC      BIT(8)
131 #define WPA_KEY_INFO_SECURE   BIT(9)
132
133 #define MASK_2ND_EAPOL       (WPA_KEY_INFO_KEY_TYPE | WPA_KEY_INFO_MIC)
134
135
136 /*******************************************************************************
137 *                         D A T A   T Y P E S
138 ********************************************************************************
139 */
140
141 typedef struct _IEEE_802_1X_HDR {
142     UINT_8      ucVersion;
143     UINT_8      ucType;
144     UINT_16     u2Length;
145     /* followed by length octets of data */
146 } IEEE_802_1X_HDR, *P_IEEE_802_1X_HDR;
147
148 typedef struct _EAPOL_KEY {
149     UINT_8 ucType;
150     /* Note: key_info, key_length, and key_data_length are unaligned */
151     UINT_8 aucKeyInfo[2]; /* big endian */
152     UINT_8 aucKeyLength[2]; /* big endian */
153     UINT_8 aucReplayCounter[8];
154     UINT_8 aucKeyNonce[16];
155     UINT_8 aucKeyIv[16];
156     UINT_8 aucKeyRsc[8];
157     UINT_8 aucKeyId[8]; /* Reserved in IEEE 802.11i/RSN */
158     UINT_8 aucKeyMic[16];
159     UINT_8 aucKeyDataLength[2]; /* big endian */
160     /* followed by key_data_length bytes of key_data */
161 } EAPOL_KEY, *P_EAPOL_KEY;
162
163 /* WPA2 PMKID candicate structure */
164 typedef struct _PMKID_CANDICATE_T {
165     UINT_8              aucBssid[MAC_ADDR_LEN];
166     UINT_32             u4PreAuthFlags;
167 } PMKID_CANDICATE_T, *P_PMKID_CANDICATE_T;
168
169 #if 0
170 /* WPA2 PMKID cache structure */
171 typedef struct _PMKID_ENTRY_T {
172     PARAM_BSSID_INFO_T  rBssidInfo;
173     BOOLEAN             fgPmkidExist;
174 } PMKID_ENTRY_T, *P_PMKID_ENTRY_T;
175 #endif
176
177 /*******************************************************************************
178 *                            P U B L I C   D A T A
179 ********************************************************************************
180 */
181
182 /*******************************************************************************
183 *                           P R I V A T E   D A T A
184 ********************************************************************************
185 */
186
187 /*******************************************************************************
188 *                                 M A C R O S
189 ********************************************************************************
190 */
191
192 /*******************************************************************************
193 *                  F U N C T I O N   D E C L A R A T I O N S
194 ********************************************************************************
195 */
196
197 VOID
198 secInit(
199     IN P_ADAPTER_T          prAdapter,
200     IN UINT_8               ucNetTypeIdx
201     );
202
203 VOID
204 secSetPortBlocked(
205     IN P_ADAPTER_T          prAdapter,
206     IN P_STA_RECORD_T       prSta,
207     IN BOOLEAN              fgPort
208    );
209
210 BOOL
211 secCheckClassError(
212     IN P_ADAPTER_T          prAdapter,
213     IN P_SW_RFB_T           prSwRfb,
214     IN P_STA_RECORD_T       prStaRec
215     );
216
217 BOOL
218 secTxPortControlCheck(
219     IN P_ADAPTER_T          prAdapter,
220     IN P_MSDU_INFO_T        prMsduInfo,
221     IN P_STA_RECORD_T       prStaRec
222     );
223
224 BOOLEAN
225 secRxPortControlCheck(
226     IN P_ADAPTER_T          prAdapter,
227     IN P_SW_RFB_T           prSWRfb
228     );
229
230 VOID
231 secSetCipherSuite(
232     IN P_ADAPTER_T prAdapter,
233     IN UINT_32     u4CipherSuitesFlags
234     );
235
236 BOOL
237 secProcessEAPOL(
238     IN P_ADAPTER_T          prAdapter,
239     IN P_MSDU_INFO_T        prMsduInfo,
240     IN P_STA_RECORD_T       prStaRec,
241     IN PUINT_8              pucPayload,
242     IN UINT_16              u2PayloadLen
243    );
244
245 VOID
246 secHandleTxDoneCallback(
247     IN P_ADAPTER_T          prAdapter,
248     IN P_MSDU_INFO_T        pMsduInfo,
249     IN P_STA_RECORD_T       prStaRec,
250     IN WLAN_STATUS          rStatus
251     );
252
253 BOOLEAN
254 secIsProtectedFrame (
255     IN P_ADAPTER_T          prAdapter,
256     IN P_MSDU_INFO_T        prMsdu,
257     IN P_STA_RECORD_T       prStaRec
258     );
259
260 VOID
261 secClearPmkid(
262     IN P_ADAPTER_T          prAdapter
263     );
264
265 BOOLEAN
266 secRsnKeyHandshakeEnabled(
267     IN P_ADAPTER_T          prAdapter
268     );
269
270 BOOLEAN
271 secTransmitKeyExist(
272     IN P_ADAPTER_T          prAdapter,
273     IN P_STA_RECORD_T       prSta
274     );
275
276 BOOLEAN
277 secEnabledInAis(
278     IN P_ADAPTER_T          prAdapter
279     );
280
281
282 /*******************************************************************************
283 *                              F U N C T I O N S
284 ********************************************************************************
285 */
286
287 #endif /* _PRIVACY_H */
288