import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / connectivity / combo / drv_wlan / mt6628 / wlan / mgmt / sec_fsm.c
1 /*
2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/sec_fsm.c#1 $
3 */
4
5 /*! \file "sec_fsm.c"
6 \brief This is the file implement security check state machine.
7
8 In security module, do the port control check after success join to an AP,
9 and the path to NORMAL TR, the state machine handle these state transition.
10 */
11
12
13
14 /*
15 ** $Log: sec_fsm.c $
16 *
17 * 11 24 2011 wh.su
18 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
19 * Adjust code for DBG and CONFIG_XLOG.
20 *
21 * 11 11 2011 wh.su
22 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
23 * modify the xlog related code.
24 *
25 * 11 10 2011 wh.su
26 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
27 * change the debug module level.
28 *
29 * 11 02 2011 wh.su
30 * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
31 * adding the code for XLOG.
32 *
33 * 03 29 2011 wh.su
34 * [WCXRP00000248] [MT6620 Wi-Fi][FW]Fixed the Klockwork error
35 * fixed the kclocwork error.
36 *
37 * 01 26 2011 yuche.tsai
38 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
39 * .
40 *
41 * 01 25 2011 yuche.tsai
42 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
43 * Fix Compile Error when DBG is disabled.
44 *
45 * 01 25 2011 yuche.tsai
46 * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
47 * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
48 *
49 * 09 29 2010 wh.su
50 * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
51 * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
52 *
53 * 09 24 2010 wh.su
54 * NULL
55 * [WCXRP00005002][MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning.
56 *
57 * 09 03 2010 kevin.huang
58 * NULL
59 * Refine #include sequence and solve recursive/nested #include issue
60 *
61 * 08 20 2010 wh.su
62 * NULL
63 * adding the eapol callback setting.
64 *
65 * 08 19 2010 wh.su
66 * NULL
67 * adding the tx pkt call back handle for countermeasure.
68 *
69 * 07 19 2010 wh.su
70 *
71 * fixed the compilng error at debug mode.
72 *
73 * 07 08 2010 cp.wu
74 *
75 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
76 *
77 * 06 21 2010 wh.su
78 * [WPD00003840][MT6620 5931] Security migration
79 * modify some code for concurrent network.
80 *
81 * 06 19 2010 wh.su
82 * [WPD00003840][MT6620 5931] Security migration
83 * consdier the concurrent network setting.
84 *
85 * 05 28 2010 wh.su
86 * [BORA00000626][MT6620] Refine the remove key flow for WHQL testing
87 * fixed the ad-hoc wpa-none send non-encrypted frame issue.
88 *
89 * 05 24 2010 kevin.huang
90 * [BORA00000794][WIFISYS][New Feature]Power Management Support
91 * Refine authSendAuthFrame() for NULL STA_RECORD_T case and minimum deauth interval.
92 *
93 * 04 24 2010 cm.chang
94 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
95 * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
96 *
97 * 04 13 2010 wh.su
98 * [BORA00000680][MT6620] Support the statistic for Microsoft os query
99 * fixed the Klocwork error and refine the class error message.
100 *
101 * 03 03 2010 wh.su
102 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
103 * move the AIS specific variable for security to AIS specific structure.
104 *
105 * 03 03 2010 wh.su
106 * [BORA00000637][MT6620 Wi-Fi] [Bug] WPA2 pre-authentication timer not correctly initialize
107 * Fixed the pre-authentication timer not correctly init issue, and modify the security related callback function prototype.
108 *
109 * 03 01 2010 wh.su
110 * [BORA00000605][WIFISYS] Phase3 Integration
111 * Refine the variable and parameter for security.
112 *
113 * 01 27 2010 wh.su
114 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
115 * add and fixed some security function.
116 *
117 * 01 13 2010 wh.su
118 * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
119 * fixed the compiling warning
120 *
121 * 12 18 2009 cm.chang
122 * [BORA00000018]Integrate WIFI part into BORA for the 1st time
123 * .
124 *
125 * Dec 7 2009 mtk01088
126 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
127 * refine some code
128 *
129 * Dec 4 2009 mtk01088
130 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
131 * refine the code
132 *
133 * Dec 1 2009 mtk01088
134 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
135 * code refine
136 *
137 * Nov 23 2009 mtk01088
138 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
139 * adjust the function name
140 *
141 * Nov 19 2009 mtk01088
142 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
143 * adjust the state machine, to meet the firmware security design v1.1
144 *
145 * Nov 18 2009 mtk01088
146 * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
147 *
148 **
149 */
150
151 /*******************************************************************************
152 * C O M P I L E R F L A G S
153 ********************************************************************************
154 */
155
156 /*******************************************************************************
157 * E X T E R N A L R E F E R E N C E S
158 ********************************************************************************
159 */
160 #include "precomp.h"
161
162 #if CFG_RSN_MIGRATION
163
164 /*******************************************************************************
165 * C O N S T A N T S
166 ********************************************************************************
167 */
168
169 /*******************************************************************************
170 * D A T A T Y P E S
171 ********************************************************************************
172 */
173
174 /*******************************************************************************
175 * P U B L I C D A T A
176 ********************************************************************************
177 */
178
179 /*******************************************************************************
180 * P R I V A T E D A T A
181 ********************************************************************************
182 */
183 #if DBG
184 /*lint -save -e64 Type mismatch */
185 static PUINT_8 apucDebugSecState[SEC_STATE_NUM] = {
186 (PUINT_8) DISP_STRING("SEC_STATE_INIT"),
187 (PUINT_8) DISP_STRING("SEC_STATE_INITIATOR_PORT_BLOCKED"),
188 (PUINT_8) DISP_STRING("SEC_STATE_RESPONDER_PORT_BLOCKED"),
189 (PUINT_8) DISP_STRING("SEC_STATE_CHECK_OK"),
190 (PUINT_8) DISP_STRING("SEC_STATE_SEND_EAPOL"),
191 (PUINT_8) DISP_STRING("SEC_STATE_SEND_DEAUTH"),
192 (PUINT_8) DISP_STRING("SEC_STATE_COUNTERMEASURE"),
193 };
194
195 /*lint -restore */
196 #endif /* DBG */
197
198 /*******************************************************************************
199 * M A C R O S
200 ********************************************************************************
201 */
202
203 /*******************************************************************************
204 * F U N C T I O N D E C L A R A T I O N S
205 ********************************************************************************
206 */
207
208 /*******************************************************************************
209 * F U N C T I O N S
210 ********************************************************************************
211 */
212
213 /*----------------------------------------------------------------------------*/
214 /*!
215 * \brief This function will do initialization of Security FSM and all variables in
216 * SEC_INFO_T.
217 *
218 * \param[in] prSta Pointer to the STA record
219 *
220 * \return none
221 */
222 /*----------------------------------------------------------------------------*/
223 VOID secFsmInit(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
224 {
225 P_SEC_INFO_T prSecInfo;
226 P_AIS_SPECIFIC_BSS_INFO_T prAisSpecBssInfo;
227
228 ASSERT(prSta);
229
230 prSecInfo = &prSta->rSecInfo;
231
232 #if 1 /* MT6620 */
233 /* At MT5921, is ok, but at MT6620, firmware base ASIC, the firmware */
234 /* will lost these data, thus, driver have to keep the wep material and */
235 /* setting to firmware while awake from D3. */
236 #endif
237
238 prSecInfo->eCurrentState = SEC_STATE_INIT;
239
240 prSecInfo->fg2nd1xSend = FALSE;
241 prSecInfo->fgKeyStored = FALSE;
242
243 if (IS_STA_IN_AIS(prSta)) {
244 prAisSpecBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
245
246 prAisSpecBssInfo->u4RsnaLastMICFailTime = 0;
247 prAisSpecBssInfo->fgCheckEAPoLTxDone = FALSE;
248
249 cnmTimerInitTimer(prAdapter,
250 &prAdapter->rWifiVar.rAisSpecificBssInfo.
251 rRsnaEAPoLReportTimeoutTimer,
252 (PFN_MGMT_TIMEOUT_FUNC) secFsmEventEapolTxTimeout,
253 (UINT_32) prSta);
254
255 cnmTimerInitTimer(prAdapter,
256 &prAdapter->rWifiVar.rAisSpecificBssInfo.rRsnaBlockTrafficTimer,
257 (PFN_MGMT_TIMEOUT_FUNC) secFsmEventEndOfCounterMeasure,
258 (UINT_32) prSta);
259
260 }
261 return;
262 }
263
264
265 /*----------------------------------------------------------------------------*/
266 /*!
267 * \brief This function will do uninitialization of Security FSM and all variables in
268 * SEC_INFO_T.
269 *
270 * \param[in] prSta Pointer to the STA record
271 *
272 * \return none
273 */
274 /*----------------------------------------------------------------------------*/
275 VOID /* whsu:Todo: */
276 secFsmUnInit(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
277 {
278 P_SEC_INFO_T prSecInfo;
279
280 ASSERT(prSta);
281
282 prSecInfo = &prSta->rSecInfo;
283
284 prSecInfo->fg2nd1xSend = FALSE;
285 prSecInfo->fgKeyStored = FALSE;
286
287 /* nicPrivacyRemoveWlanTable(prSta->ucWTEntry); */
288
289 if (IS_STA_IN_AIS(prSta)) {
290 cnmTimerStopTimer(prAdapter,
291 &prAdapter->rWifiVar.rAisSpecificBssInfo.
292 rRsnaEAPoLReportTimeoutTimer);
293 cnmTimerStopTimer(prAdapter,
294 &prAdapter->rWifiVar.rAisSpecificBssInfo.rRsnaBlockTrafficTimer);
295 }
296
297 }
298
299
300 /*----------------------------------------------------------------------------*/
301 /*!
302 * \brief This function will do action part while in STATE transition of
303 * STANDBY to CHECK_OK.
304 *
305 * \param[in] prSta Pointer to the Sta record
306 *
307 * \return - none
308 */
309 /*----------------------------------------------------------------------------*/
310 __KAL_INLINE__ VOID secFsmTrans_INIT_to_CHECK_OK(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
311 {
312 secSetPortBlocked(prAdapter, prSta, FALSE);
313
314 return;
315 }
316
317
318 /*----------------------------------------------------------------------------*/
319 /*!
320 * \brief This function will do action part while in STATE transition of
321 * INIT to INITIATOR_PORT_BLOCKED.
322 *
323 * \param[in] prSta Pointer to the Sta record
324 *
325 * \return - none
326 */
327 /*----------------------------------------------------------------------------*/
328 __KAL_INLINE__ VOID
329 secFsmTrans_INIT_to_INITIATOR_PORT_BLOCKED(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
330 {
331
332 return;
333 }
334
335
336 /*----------------------------------------------------------------------------*/
337 /*!
338 * \brief This function will do action part while in STATE transition of
339 * INIT to RESPONDER_PORT_BLOCKED.
340 *
341 * \param[in] prSta Pointer to the Sta record
342 *
343 * \return - none
344 */
345 /*----------------------------------------------------------------------------*/
346 __KAL_INLINE__ VOID
347 secFsmTrans_INIT_to_RESPONDER_PORT_BLOCKED(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
348 {
349 return;
350 }
351
352
353 /*----------------------------------------------------------------------------*/
354 /*!
355 * \brief This function will do action part while in STATE transition of
356 * INITIATOR_PORT_BLOCKED to CHECK_OK.
357 *
358 * \param[in] prSta Pointer to the Sta record
359 *
360 * \return - none
361 */
362 /*----------------------------------------------------------------------------*/
363 __KAL_INLINE__ VOID
364 secFsmTrans_INITIATOR_PORT_BLOCKED_to_CHECK_OK(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
365 {
366 secSetPortBlocked(prAdapter, prSta, FALSE);
367 return;
368 }
369
370
371 /*----------------------------------------------------------------------------*/
372 /*!
373 * \brief This function will do action part while in STATE transition of
374 * RESPONDER_PORT_BLOCKED to CHECK_OK.
375 *
376 * \param[in] prSta Pointer to the Sta record
377 *
378 * \return - none
379 */
380 /*----------------------------------------------------------------------------*/
381 __KAL_INLINE__ VOID
382 secFsmTrans_RESPONDER_PORT_BLOCKED_to_CHECK_OK(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
383 {
384 secSetPortBlocked(prAdapter, prSta, FALSE);
385 return;
386 }
387
388
389 /*----------------------------------------------------------------------------*/
390 /*!
391 * \brief This function will do action part while in STATE transition of
392 * CHECK_OK to SEND_EAPOL
393 *
394 * \param[in] prSta Pointer to the Sta record
395 *
396 * \return -
397 */
398 /*----------------------------------------------------------------------------*/
399 __KAL_INLINE__ VOID
400 secFsmTrans_CHECK_OK_to_SEND_EAPOL(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
401 {
402
403 P_AIS_SPECIFIC_BSS_INFO_T prAisBssInfo;
404
405 ASSERT(prAdapter);
406
407 ASSERT(prSta);
408
409 prAisBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
410
411 ASSERT(prAisBssInfo);
412
413 if (!IS_STA_IN_AIS(prSta)) {
414 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
415 /* ASSERT(0); */
416 return;
417 }
418
419 prAisBssInfo->fgCheckEAPoLTxDone = TRUE;
420
421 /* cnmTimerStartTimer(prAdapter, */
422 /* &prAisBssInfo->rRsnaEAPoLReportTimeoutTimer, */
423 /* SEC_TO_MSEC(EAPOL_REPORT_SEND_TIMEOUT_INTERVAL_SEC)); */
424
425 return;
426 }
427
428
429 /*----------------------------------------------------------------------------*/
430 /*!
431 * \brief This function will do action part while in STATE transition of
432 * SEND_EAPOL to SEND_DEAUTH.
433 *
434 * \param[in] prSta Pointer to the Sta record
435 *
436 * \return - none
437 */
438 /*----------------------------------------------------------------------------*/
439 __KAL_INLINE__ VOID
440 secFsmTrans_SEND_EAPOL_to_SEND_DEAUTH(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
441 {
442
443 if (!IS_STA_IN_AIS(prSta)) {
444 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
445 /* ASSERT(0); */
446 return;
447 }
448
449 /* Compose deauth frame to AP, a call back function for tx done */
450 if (authSendDeauthFrame(prAdapter,
451 prSta,
452 (P_SW_RFB_T) NULL,
453 REASON_CODE_MIC_FAILURE,
454 (PFN_TX_DONE_HANDLER) secFsmEventDeauthTxDone) !=
455 WLAN_STATUS_SUCCESS) {
456 ASSERT(FALSE);
457 }
458 }
459
460
461 /*----------------------------------------------------------------------------*/
462 /*!
463 * \brief This function will do action part while in STATE transition of
464 * SEND_DEAUTH to COUNTERMEASURE.
465 *
466 * \param[in] prSta Pointer to the Sta record
467 *
468 * \return -
469 */
470 /*----------------------------------------------------------------------------*/
471 __KAL_INLINE__ VOID
472 secFsmTrans_SEND_DEAUTH_to_COUNTERMEASURE(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
473 {
474 ASSERT(prAdapter);
475 ASSERT(prSta);
476
477 if (!IS_STA_IN_AIS(prSta)) {
478 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
479 /* ASSERT(0); */
480 return;
481 }
482 /* Start the 60 sec timer */
483 cnmTimerStartTimer(prAdapter,
484 &prAdapter->rWifiVar.rAisSpecificBssInfo.rRsnaBlockTrafficTimer,
485 SEC_TO_MSEC(COUNTER_MEASURE_TIMEOUT_INTERVAL_SEC));
486 return;
487 }
488
489
490 /*----------------------------------------------------------------------------*/
491 /*!
492 * \brief This function will do action part while in STATE transition of
493 * SEND_DEAUTH to COUNTERMEASURE.
494 *
495 * \param[in] prSta Pointer to the Sta record
496 *
497 * \return -
498 */
499 /*----------------------------------------------------------------------------*/
500 __KAL_INLINE__ VOID
501 secFsmTrans_COUNTERMEASURE_to_INIT(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
502 {
503
504 /* Clear the counter measure flag */
505 return;
506 }
507
508 /*----------------------------------------------------------------------------*/
509 /*!
510 * \brief The Core FSM engine of security module.
511 *
512 * \param[in] prSta Pointer to the Sta record
513 * \param[in] eNextState Enum value of next sec STATE
514 *
515 * \return -
516 */
517 /*----------------------------------------------------------------------------*/
518 VOID secFsmSteps(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta, IN ENUM_SEC_STATE_T eNextState)
519 {
520 P_SEC_INFO_T prSecInfo;
521 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
522
523 ASSERT(prSta);
524
525 prSecInfo = &prSta->rSecInfo;
526 ASSERT(prSecInfo);
527
528 DEBUGFUNC("secFsmSteps");
529 do {
530 /* Do entering Next State */
531 prSecInfo->ePreviousState = prSecInfo->eCurrentState;
532
533 /* Do entering Next State */
534 #if DBG
535 DBGLOG(RSN, STATE, ("\n" MACSTR " TRANSITION: [%s] -> [%s]\n\n",
536 MAC2STR(prSta->aucMacAddr),
537 apucDebugSecState[prSecInfo->eCurrentState],
538 apucDebugSecState[eNextState]));
539 #else
540 DBGLOG(RSN, STATE, ("\n" MACSTR " [%d] TRANSITION: [%d] -> [%d]\n\n",
541 MAC2STR(prSta->aucMacAddr),
542 DBG_RSN_IDX, prSecInfo->eCurrentState, eNextState));
543 #endif
544 prSecInfo->eCurrentState = eNextState;
545
546 fgIsTransition = (BOOLEAN) FALSE;
547 #if 0
548 /* Do tasks of the State that we just entered */
549 switch (prSecInfo->eCurrentState) {
550 case SEC_STATE_INIT:
551 break;
552 case SEC_STATE_INITIATOR_PORT_BLOCKED:
553 break;
554 case SEC_STATE_RESPONDER_PORT_BLOCKED:
555 break;
556 case SEC_STATE_CHECK_OK:
557 break;
558 case SEC_STATE_SEND_EAPOL:
559 break;
560 case SEC_STATE_SEND_DEAUTH:
561 break;
562 case SEC_STATE_COUNTERMEASURE:
563 break;
564 default:
565 ASSERT(0); /* Make sure we have handle all STATEs */
566 break;
567 }
568 #endif
569 }
570 while (fgIsTransition);
571
572 return;
573
574 }
575
576
577 /*----------------------------------------------------------------------------*/
578 /*!
579 * \brief This function will do initialization of Security FSM and all variables in
580 * SEC_INFO_T.
581 *
582 * \param[in] prSta Pointer to the Sta record
583 *
584 * \return none
585 */
586 /*----------------------------------------------------------------------------*/
587 VOID secFsmEventStart(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
588 {
589 P_SEC_INFO_T prSecInfo;
590 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
591 ENUM_SEC_STATE_T eNextState;
592
593 DBGLOG(RSN, TRACE, ("secFsmRunEventStart\n"));
594
595 ASSERT(prSta);
596
597 if (!prSta)
598 return;
599
600 if (!IS_STA_IN_AIS(prSta))
601 return;
602
603 DBGLOG(RSN, TRACE, ("secFsmRunEventStart for sta " MACSTR " network %d\n",
604 MAC2STR(prSta->aucMacAddr), prSta->ucNetTypeIndex));
605
606 prSecInfo = (P_SEC_INFO_T) &prSta->rSecInfo;
607
608 eNextState = prSecInfo->eCurrentState;
609
610 secSetPortBlocked(prAdapter, prSta, TRUE);
611
612 /* prSta->fgTransmitKeyExist = FALSE; */
613 /* whsu:: nicPrivacySetStaDefaultWTIdx(prSta); */
614
615 #if 1 /* Since the 1x and key can set to firmware in order, always enter the check ok state */
616 SEC_STATE_TRANSITION(prAdapter, prSta, INIT, CHECK_OK);
617 #else
618 if (IS_STA_IN_AIS(prSta->eStaType)) {
619 if (secRsnKeyHandshakeEnabled(prAdapter) == TRUE
620 #if CFG_SUPPORT_WAPI
621 || (prAdapter->rWifiVar.rConnSettings.fgWapiMode)
622 #endif
623 ) {
624 prSta->fgTransmitKeyExist = FALSE;
625 /* nicPrivacyInitialize(prSta->ucNetTypeIndex); */
626 SEC_STATE_TRANSITION(prAdapter, prSta, INIT, INITIATOR_PORT_BLOCKED);
627 } else {
628 SEC_STATE_TRANSITION(prAdapter, prSta, INIT, CHECK_OK);
629 }
630 }
631 #if CFG_ENABLE_WIFI_DIRECT || CFG_ENABLE_BT_OVER_WIFI
632 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_BT_OVER_WIFI
633 else if ((prSta->eStaType == STA_TYPE_BOW_CLIENT) || (prSta->eStaType == STA_TYPE_P2P_GC))
634 #elif CFG_ENABLE_WIFI_DIRECT
635 else if (prSta->eStaType == STA_TYPE_P2P_GC)
636 #elif CFG_ENABLE_BT_OVER_WIFI
637 else if (prSta->eStaType == STA_TYPE_BOW_CLIENT)
638 #endif
639 {
640 SEC_STATE_TRANSITION(prAdapter, prSta, INIT, RESPONDER_PORT_BLOCKED);
641 }
642 #endif
643 else {
644 SEC_STATE_TRANSITION(prAdapter, prSta, INIT, INITIATOR_PORT_BLOCKED);
645 }
646 #endif
647 if (prSecInfo->eCurrentState != eNextState) {
648 secFsmSteps(prAdapter, prSta, eNextState);
649 }
650
651 return;
652 } /* secFsmRunEventStart */
653
654
655 /*----------------------------------------------------------------------------*/
656 /*!
657 * \brief This function called by reset procedure to force the sec fsm enter
658 * idle state
659 *
660 * \param[in] ucNetTypeIdx The Specific Network type index
661 * \param[in] prSta Pointer to the Sta record
662 *
663 * \return none
664 */
665 /*----------------------------------------------------------------------------*/
666 VOID secFsmEventAbort(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
667 {
668 P_SEC_INFO_T prSecInfo;
669
670 DBGLOG(RSN, TRACE, ("secFsmEventAbort for sta " MACSTR " network %d\n",
671 MAC2STR(prSta->aucMacAddr), prSta->ucNetTypeIndex));
672
673 ASSERT(prSta);
674
675 if (!prSta)
676 return;
677
678 if (!IS_STA_IN_AIS(prSta))
679 return;
680
681 prSecInfo = (P_SEC_INFO_T) &prSta->rSecInfo;
682
683 prSta->fgTransmitKeyExist = FALSE;
684
685 secSetPortBlocked(prAdapter, prSta, TRUE);
686
687 if (prSecInfo == NULL)
688 return;
689
690 if (IS_STA_IN_AIS(prSta)) {
691
692 prAdapter->rWifiVar.rAisSpecificBssInfo.fgTransmitKeyExist = FALSE;
693
694 if (prSecInfo->eCurrentState == SEC_STATE_SEND_EAPOL) {
695 if (prAdapter->rWifiVar.rAisSpecificBssInfo.fgCheckEAPoLTxDone == FALSE) {
696 DBGLOG(RSN, TRACE, ("EAPOL STATE not match the flag\n"));
697 /* cnmTimerStopTimer(prAdapter, &prAdapter->rWifiVar.rAisSpecificBssInfo.rRsnaEAPoLReportTimeoutTimer); */
698 }
699 }
700 }
701 prSecInfo->eCurrentState = SEC_STATE_INIT;
702 }
703
704
705 /*----------------------------------------------------------------------------*/
706 /*!
707 * \brief This function will indicate an Event of "2nd EAPoL Tx is sending" to Sec FSM.
708 *
709 * \param[in] prSta Pointer to the Sta record
710 *
711 * \return -
712 */
713 /*----------------------------------------------------------------------------*/
714 VOID secFsmEvent2ndEapolTx(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
715 {
716 P_SEC_INFO_T prSecInfo;
717 ENUM_SEC_STATE_T eNextState;
718 /* BOOLEAN fgIsTransition = (BOOLEAN)FALSE; */
719
720 DEBUGFUNC("secFsmRunEvent2ndEapolTx");
721
722 ASSERT(prSta);
723
724 prSecInfo = &prSta->rSecInfo;
725 eNextState = prSecInfo->eCurrentState;
726
727 #if DBG
728 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prSta->aucMacAddr),
729 apucDebugSecState[prSecInfo->eCurrentState]));
730 #else
731 DBGLOG(RSN, TRACE,
732 (MACSTR " Sec state [%d]\n", MAC2STR(prSta->aucMacAddr), prSecInfo->eCurrentState));
733 #endif
734
735 switch (prSecInfo->eCurrentState) {
736 case SEC_STATE_INITIATOR_PORT_BLOCKED:
737 case SEC_STATE_CHECK_OK:
738 prSecInfo->fg2nd1xSend = TRUE;
739 break;
740 default:
741 #if DBG
742 DBGLOG(RSN, WARN,
743 ("Rcv 2nd EAPoL at %s\n", apucDebugSecState[prSecInfo->eCurrentState]));
744 #else
745 DBGLOG(RSN, WARN, ("Rcv 2nd EAPoL at [%d]\n", prSecInfo->eCurrentState));
746 #endif
747 break;
748 }
749
750 if (prSecInfo->eCurrentState != eNextState) {
751 secFsmSteps(prAdapter, prSta, eNextState);
752 }
753
754 return;
755
756 } /* secFsmRunEvent2ndEapolTx */
757
758
759 /*----------------------------------------------------------------------------*/
760 /*!
761 * \brief This function will indicate an Event of "4th EAPoL Tx is Tx done" to Sec FSM.
762 *
763 * \param[in] prSta Pointer to the Sta record
764 *
765 * \return -
766 */
767 /*----------------------------------------------------------------------------*/
768 VOID secFsmEvent4ndEapolTxDone(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
769 {
770 P_SEC_INFO_T prSecInfo;
771 ENUM_SEC_STATE_T eNextState;
772 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
773 P_CMD_802_11_KEY prStoredKey;
774
775 DEBUGFUNC("secFsmRunEvent4ndEapolTx");
776
777 ASSERT(prSta);
778
779 prSecInfo = &prSta->rSecInfo;
780 eNextState = prSecInfo->eCurrentState;
781
782 #if DBG
783 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prSta->aucMacAddr),
784 apucDebugSecState[prSecInfo->eCurrentState]));
785 #else
786 DBGLOG(RSN, TRACE,
787 (MACSTR " Sec state [%d]\n", MAC2STR(prSta->aucMacAddr), prSecInfo->eCurrentState));
788 #endif
789
790 switch (prSecInfo->eCurrentState) {
791 case SEC_STATE_INITIATOR_PORT_BLOCKED:
792 case SEC_STATE_CHECK_OK:
793 prSecInfo->fg2nd1xSend = FALSE;
794 if (prSecInfo->fgKeyStored) {
795 prStoredKey = (P_CMD_802_11_KEY) prSecInfo->aucStoredKey;
796
797 /* prSta = rxmLookupStaRecIndexFromTA(prStoredKey->aucPeerAddr); */
798 /* if (nicPrivacySetKeyEntry(prStoredKey, prSta->ucWTEntry) == FALSE) */
799 /* DBGLOG(RSN, WARN, ("nicPrivacySetKeyEntry() fail,..\n")); */
800
801 /* key update */
802 prSecInfo->fgKeyStored = FALSE;
803 prSta->fgTransmitKeyExist = TRUE;
804 }
805 if (prSecInfo->eCurrentState == SEC_STATE_INITIATOR_PORT_BLOCKED) {
806 SEC_STATE_TRANSITION(prAdapter, prSta, INITIATOR_PORT_BLOCKED, CHECK_OK);
807 }
808 break;
809 default:
810
811 #if DBG
812 DBGLOG(RSN, WARN,
813 ("Rcv thh EAPoL Tx done at %s\n",
814 apucDebugSecState[prSecInfo->eCurrentState]));
815 #else
816 DBGLOG(RSN, WARN, ("Rcv thh EAPoL Tx done at [%d]\n", prSecInfo->eCurrentState));
817 #endif
818 break;
819 }
820
821 if (prSecInfo->eCurrentState != eNextState) {
822 secFsmSteps(prAdapter, prSta, eNextState);
823 }
824
825 return;
826
827 } /* secFsmRunEvent4ndEapolTx */
828
829
830 /*----------------------------------------------------------------------------*/
831 /*!
832 * \brief This function will indicate an Event of "Pairwise key installed" to SEC FSM.
833 *
834 * \param[in] prSta Pointer to the Sta record
835 *
836 * \retval TRUE The key can be installed to HW
837 * \retval FALSE The kay conflict with the current key, abort it
838 */
839 /*----------------------------------------------------------------------------*/
840 BOOLEAN secFsmEventPTKInstalled(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
841 {
842 P_SEC_INFO_T prSecInfo;
843 ENUM_SEC_STATE_T eNextState;
844 BOOLEAN fgStatus = TRUE;
845 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
846
847 ASSERT(prSta);
848
849 prSecInfo = &prSta->rSecInfo;
850 if (prSecInfo == NULL)
851 return TRUE; /* Not PTK */
852
853 #if DBG
854 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prSta->aucMacAddr),
855 apucDebugSecState[prSecInfo->eCurrentState]));
856 #else
857 DBGLOG(RSN, TRACE,
858 (MACSTR " Sec state [%d]\n", MAC2STR(prSta->aucMacAddr), prSecInfo->eCurrentState));
859 #endif
860
861 eNextState = prSecInfo->eCurrentState;
862
863 switch (prSecInfo->eCurrentState) {
864 case SEC_STATE_INIT:
865 /* Legacy wep, wpa-none */
866 break;
867
868 case SEC_STATE_INITIATOR_PORT_BLOCKED:
869 if (prSecInfo->fg2nd1xSend) {
870 } else {
871 SEC_STATE_TRANSITION(prAdapter, prSta, INITIATOR_PORT_BLOCKED, CHECK_OK);
872 }
873 break;
874
875 case SEC_STATE_RESPONDER_PORT_BLOCKED:
876 SEC_STATE_TRANSITION(prAdapter, prSta, RESPONDER_PORT_BLOCKED, CHECK_OK);
877 break;
878
879
880 case SEC_STATE_CHECK_OK:
881 break;
882
883 default:
884 fgStatus = FALSE;
885 break;
886 }
887
888 if (prSecInfo->eCurrentState != eNextState) {
889 secFsmSteps(prAdapter, prSta, eNextState);
890 }
891
892 return fgStatus;
893
894 } /* end of secFsmRunEventPTKInstalled() */
895
896
897 /*----------------------------------------------------------------------------*/
898 /*!
899 * \brief This function will indicate an Event of "Counter Measure" to SEC FSM.
900 *
901 * \param[in] prSta Pointer to the Sta record
902 *
903 * \return -
904 */
905 /*----------------------------------------------------------------------------*/
906 VOID secFsmEventStartCounterMeasure(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prSta)
907 {
908 P_SEC_INFO_T prSecInfo;
909 ENUM_SEC_STATE_T eNextState;
910 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
911
912 DEBUGFUNC("secFsmRunEventStartCounterMeasure");
913
914 ASSERT(prSta);
915
916 if (!IS_STA_IN_AIS(prSta)) {
917 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
918 /* ASSERT(0); */
919 return;
920 }
921
922 prSecInfo = &prSta->rSecInfo;
923
924 eNextState = prSecInfo->eCurrentState;
925
926 #if DBG
927 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prSta->aucMacAddr),
928 apucDebugSecState[prSecInfo->eCurrentState]));
929 #else
930 DBGLOG(RSN, TRACE,
931 (MACSTR " Sec state [%d]\n", MAC2STR(prSta->aucMacAddr), prSecInfo->eCurrentState));
932 #endif
933
934 prAdapter->rWifiVar.rAisSpecificBssInfo.u4RsnaLastMICFailTime = 0;
935
936 switch (prSecInfo->eCurrentState) {
937 case SEC_STATE_CHECK_OK:
938 {
939 prAdapter->rWifiVar.rAisSpecificBssInfo.fgCounterMeasure = TRUE;
940
941 /* <Todo> dls port control */
942 SEC_STATE_TRANSITION(prAdapter, prSta, CHECK_OK, SEND_EAPOL);
943 }
944 break;
945
946 default:
947 break;
948 }
949
950 /* Call arbFsmSteps() when we are going to change ARB STATE */
951 if (prSecInfo->eCurrentState != eNextState) {
952 secFsmSteps(prAdapter, prSta, eNextState);
953 }
954
955 return;
956
957 } /* secFsmRunEventStartCounterMeasure */
958
959
960 /*----------------------------------------------------------------------------*/
961 /*!
962 * \brief This function will indicate an Event of "802.1x EAPoL Tx Done" to Sec FSM.
963 *
964 * \param[in] prSta Pointer to the Sta record
965 *
966 * \return -
967 */
968 /*----------------------------------------------------------------------------*/
969 VOID
970 secFsmEventEapolTxDone(IN P_ADAPTER_T prAdapter,
971 IN P_STA_RECORD_T prStaRec, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
972 {
973 P_SEC_INFO_T prSecInfo;
974 ENUM_SEC_STATE_T eNextState;
975 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
976 P_AIS_SPECIFIC_BSS_INFO_T prAisBssInfo;
977
978 DEBUGFUNC("secFsmRunEventEapolTxDone");
979
980 ASSERT(prStaRec);
981
982 if (rTxDoneStatus != TX_RESULT_SUCCESS) {
983 DBGLOG(RSN, INFO, ("Error EAPoL fram fail to send!!\n"));
984 /* ASSERT(0); */
985 return;
986 }
987
988 if (!IS_STA_IN_AIS(prStaRec)) {
989 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
990 /* ASSERT(0); */
991 return;
992 }
993
994 prAisBssInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
995
996 ASSERT(prAisBssInfo);
997
998 prSecInfo = &prStaRec->rSecInfo;
999 eNextState = prSecInfo->eCurrentState;
1000
1001 #if DBG
1002 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prStaRec->aucMacAddr),
1003 apucDebugSecState[prSecInfo->eCurrentState]));
1004 #else
1005 DBGLOG(RSN, TRACE,
1006 (MACSTR " Sec state [%d]\n", MAC2STR(prStaRec->aucMacAddr),
1007 prSecInfo->eCurrentState));
1008 #endif
1009
1010 switch (prSecInfo->eCurrentState) {
1011 case SEC_STATE_SEND_EAPOL:
1012 if (prAisBssInfo->fgCheckEAPoLTxDone == FALSE) {
1013 ASSERT(0);
1014 }
1015
1016 prAisBssInfo->fgCheckEAPoLTxDone = FALSE;
1017 /* cnmTimerStopTimer(prAdapter, &prAisBssInfo->rRsnaEAPoLReportTimeoutTimer); */
1018
1019 SEC_STATE_TRANSITION(prAdapter, prStaRec, SEND_EAPOL, SEND_DEAUTH);
1020 break;
1021 default:
1022 break;
1023 }
1024
1025 if (prSecInfo->eCurrentState != eNextState) {
1026 secFsmSteps(prAdapter, prStaRec, eNextState);
1027 }
1028
1029 return;
1030
1031 } /* secFsmRunEventEapolTxDone */
1032
1033
1034 /*----------------------------------------------------------------------------*/
1035 /*!
1036 * \brief This function will indicate an Event of "Deauth frame Tx Done" to Sec FSM.
1037 *
1038 * \param[in] pMsduInfo Pointer to the Msdu Info
1039 * \param[in] rStatus The Tx done status
1040 *
1041 * \return -
1042 *
1043 * \note after receive deauth frame, callback function call this
1044 */
1045 /*----------------------------------------------------------------------------*/
1046 VOID
1047 secFsmEventDeauthTxDone(IN P_ADAPTER_T prAdapter,
1048 IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
1049 {
1050 P_STA_RECORD_T prStaRec;
1051 P_SEC_INFO_T prSecInfo;
1052 ENUM_SEC_STATE_T eNextState;
1053 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
1054
1055 DEBUGFUNC("secFsmRunEventDeauthTxDone");
1056
1057 ASSERT(prMsduInfo);
1058
1059 prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
1060
1061 ASSERT(prStaRec);
1062
1063 if (!prStaRec)
1064 return;
1065
1066 if (!IS_STA_IN_AIS(prStaRec)) {
1067 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
1068 /* ASSERT(0); */
1069 return;
1070 }
1071
1072 prSecInfo = (P_SEC_INFO_T) &prStaRec->rSecInfo;
1073
1074 #if DBG
1075 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prStaRec->aucMacAddr),
1076 apucDebugSecState[prSecInfo->eCurrentState]));
1077 #else
1078 DBGLOG(RSN, TRACE,
1079 (MACSTR " Sec state [%d]\n", MAC2STR(prStaRec->aucMacAddr),
1080 prSecInfo->eCurrentState));
1081 #endif
1082
1083 switch (prSecInfo->eCurrentState) {
1084 case SEC_STATE_SEND_DEAUTH:
1085
1086 DBGLOG(RSN, TRACE, ("Set timer %d\n", COUNTER_MEASURE_TIMEOUT_INTERVAL_SEC));
1087
1088 SEC_STATE_TRANSITION(prAdapter, prStaRec, SEND_DEAUTH, COUNTERMEASURE);
1089
1090 break;
1091
1092 default:
1093 ASSERT(0);
1094 break;
1095 }
1096
1097 return;
1098 } /* secFsmRunEventDeauthTxDone */
1099
1100
1101 /*----------------------------------------------------------------------------*/
1102 /*!
1103 * \brief This function will check the eapol error frame fail to send issue.
1104 *
1105 * \param[in] prSta Pointer to the Sta record
1106 *
1107 * \return -
1108 */
1109 /*----------------------------------------------------------------------------*/
1110 VOID secFsmEventEapolTxTimeout(IN P_ADAPTER_T prAdapter, IN UINT_32 u4Parm)
1111 {
1112 P_STA_RECORD_T prStaRec;
1113
1114 DEBUGFUNC("secFsmRunEventEapolTxTimeout");
1115
1116 prStaRec = (P_STA_RECORD_T) u4Parm;
1117
1118 ASSERT(prStaRec);
1119
1120 /* Todo:: How to handle the Eapol Error fail to send case? */
1121 ASSERT(0);
1122
1123 return;
1124
1125 } /* secFsmEventEapolTxTimeout */
1126
1127
1128 /*----------------------------------------------------------------------------*/
1129 /*!
1130 * \brief This function will stop the counterMeasure duration.
1131 *
1132 * \param[in] prSta Pointer to the Sta record
1133 *
1134 * \return -
1135 */
1136 /*----------------------------------------------------------------------------*/
1137 VOID secFsmEventEndOfCounterMeasure(IN P_ADAPTER_T prAdapter, UINT_32 u4Parm)
1138 {
1139 P_STA_RECORD_T prSta;
1140 P_SEC_INFO_T prSecInfo;
1141 ENUM_SEC_STATE_T eNextState;
1142 BOOLEAN fgIsTransition = (BOOLEAN) FALSE;
1143
1144 DEBUGFUNC("secFsmRunEventEndOfCounterMeasure");
1145
1146 prSta = (P_STA_RECORD_T) u4Parm;
1147
1148 ASSERT(prSta);
1149
1150 if (!IS_STA_IN_AIS(prSta)) {
1151 DBGLOG(RSN, INFO, ("Counter Measure should occur at AIS network!!\n"));
1152 /* ASSERT(0); */
1153 return;
1154 }
1155
1156 prSecInfo = &prSta->rSecInfo;
1157 eNextState = prSecInfo->eCurrentState;
1158
1159 #if DBG
1160 DBGLOG(RSN, TRACE, (MACSTR " Sec state %s\n", MAC2STR(prSta->aucMacAddr),
1161 apucDebugSecState[prSecInfo->eCurrentState]));
1162 #else
1163 DBGLOG(RSN, TRACE,
1164 (MACSTR " Sec state [%d]\n", MAC2STR(prSta->aucMacAddr), prSecInfo->eCurrentState));
1165 #endif
1166
1167 switch (prSecInfo->eCurrentState) {
1168 case SEC_STATE_SEND_DEAUTH:
1169 {
1170 prAdapter->rWifiVar.rAisSpecificBssInfo.fgCounterMeasure = FALSE;
1171
1172 SEC_STATE_TRANSITION(prAdapter, prSta, COUNTERMEASURE, INIT);
1173 }
1174 break;
1175
1176 default:
1177 ASSERT(0);
1178 }
1179
1180 /* Call arbFsmSteps() when we are going to change ARB STATE */
1181 if (prSecInfo->eCurrentState != eNextState) {
1182 secFsmSteps(prAdapter, prSta, eNextState);
1183 }
1184
1185 return;
1186 } /* end of secFsmRunEventEndOfCounterMeasure */
1187 #endif