aaa_fsm.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/aaa_fsm.c#3 $
  3. */
  4. /*! \file "aaa_fsm.c"
  5. \brief This file defines the FSM for AAA MODULE.
  6. This file defines the FSM for AAA MODULE.
  7. */
  8. /*
  9. ** Log: aaa_fsm.c $
  10. **
  11. ** 10 08 2013 yuche.tsai
  12. ** [ALPS01065606] [Volunteer Patch][MT6630][Wi-Fi Direct][Driver] MT6630 Wi-Fi Direct Driver Patch
  13. ** Update Wi-Fi Direct Source.
  14. **
  15. ** 08 27 2013 yuche.tsai
  16. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  17. ** Fix possible ASSERT error under Hot-Spot mode.
  18. **
  19. ** 08 22 2013 yuche.tsai
  20. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  21. ** Fix Wi-Fi Direct Bug.
  22. **
  23. ** 07 30 2013 yuche.tsai
  24. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  25. ** Temp fix Hot-spot data path issue.
  26. **
  27. ** 07 30 2013 yuche.tsai
  28. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  29. ** Driver update for Hot-Spot mode.
  30. **
  31. ** 03 29 2013 cp.wu
  32. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  33. ** 1. remove unused HIF definitions
  34. ** 2. enable NDIS 5.1 build success
  35. **
  36. ** 03 29 2013 wh.su
  37. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  38. ** Do more sta record free mechanism check
  39. ** remove non-used code
  40. **
  41. ** 03 28 2013 wh.su
  42. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  43. ** remove the sta_record at some condition:
  44. ** 1. No reply auth
  45. ** 2. auth fail
  46. **
  47. ** 03 12 2013 tsaiyuan.hsu
  48. ** [BORA00002222] MT6630 unified MAC RXM
  49. ** remove hif_rx_hdr usage.
  50. **
  51. ** 03 12 2013 tsaiyuan.hsu
  52. ** [BORA00002222] MT6630 unified MAC RXM
  53. ** add rx data and management processing.
  54. **
  55. ** 02 27 2013 yuche.tsai
  56. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  57. ** Add aaa_fsm.c, p2p_ie.c, fix compile warning & error.
  58. **
  59. ** 02 27 2013 yuche.tsai
  60. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  61. ** Add new code, fix compile warning.
  62. **
  63. ** 02 19 2013 cp.wu
  64. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  65. ** take use of GET_BSS_INFO_BY_INDEX() and MAX_BSS_INDEX macros
  66. ** for correctly indexing of BSS-INFO pointers
  67. **
  68. ** 01 22 2013 cp.wu
  69. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  70. ** modification for ucBssIndex migration
  71. **
  72. ** 09 17 2012 cm.chang
  73. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  74. ** Duplicate source from MT6620 v2.3 driver branch
  75. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  76. **
  77. ** 08 24 2012 yuche.tsai
  78. ** [WCXRP00001119] [Volunteer Patch][WiFi Direct][Driver] Connection Policy Set for WFD SIGMA test
  79. ** Bug fix for Assoc Req rx check len.
  80. *
  81. * 07 17 2012 yuche.tsai
  82. * NULL
  83. * Compile no error before trial run.
  84. *
  85. * 06 13 2012 yuche.tsai
  86. * NULL
  87. * Update maintrunk driver.
  88. * Add support for driver compose assoc request frame.
  89. *
  90. * 03 02 2012 terry.wu
  91. * NULL
  92. * Sync CFG80211 modification from branch 2,2.
  93. *
  94. * 02 22 2012 yuche.tsai
  95. * NULL
  96. * Solve sigma test 5.1.3 issue, assoc response should have P2P IE.
  97. *
  98. * 12 02 2011 yuche.tsai
  99. * NULL
  100. * Resolve inorder issue under AP mode.
  101. *
  102. * data frame may TX before assoc response frame.
  103. *
  104. * 11 18 2011 yuche.tsai
  105. * NULL
  106. * CONFIG P2P support RSSI query, default turned off.
  107. *
  108. * 06 17 2011 terry.wu
  109. * NULL
  110. * Add BoW 11N support.
  111. *
  112. * 06 02 2011 eddie.chen
  113. * [WCXRP00000759] [MT6620 Wi-Fi][DRV] Update RCPI in AAA
  114. * Update RCPI when receiving Assoc request.
  115. *
  116. * 04 21 2011 terry.wu
  117. * [WCXRP00000674] [MT6620 Wi-Fi][Driver] Refine AAA authSendAuthFrame
  118. * Add network type parameter to authSendAuthFrame.
  119. *
  120. * 04 15 2011 chinghwa.yu
  121. * [WCXRP00000065] Update BoW design and settings
  122. * Add BOW short range mode.
  123. *
  124. * 04 09 2011 chinghwa.yu
  125. * [WCXRP00000065] Update BoW design and settings
  126. * Change Link connection event procedure and change skb length check to 1512 bytes.
  127. *
  128. * 03 09 2011 wh.su
  129. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  130. * Skip to call p2pRunEventAAAComplete to avoid indicate STA connect twice.
  131. *
  132. * 03 04 2011 terry.wu
  133. * [WCXRP00000515] [MT6620 Wi-Fi][Driver] Surpress compiler warning which is identified by GNU compiler collection
  134. * Remove unused variable.
  135. *
  136. * 02 16 2011 yuche.tsai
  137. * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
  138. * Add more check after RX assoc frame under Hot-Spot mode.
  139. *
  140. * 02 09 2011 yuche.tsai
  141. * [WCXRP00000429] [Volunteer Patch][MT6620][Driver] Hot Spot Client Limit Issue
  142. * Fix Client Limit Issue.
  143. *
  144. * 01 25 2011 yuche.tsai
  145. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  146. * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
  147. *
  148. * 01 15 2011 puff.wen
  149. * NULL
  150. * [On behalf of Frog] Add CFG_ENABLE_WIFI_DIRECT to p2pRunEventAAAComplete
  151. *
  152. * 01 14 2011 yuche.tsai
  153. * [WCXRP00000352] [Volunteer Patch][MT6620][Driver] P2P Statsion Record Client List Issue
  154. * Modify AAA flow according to CM's comment.
  155. *
  156. * 09 03 2010 kevin.huang
  157. * NULL
  158. * Refine #include sequence and solve recursive/nested #include issue
  159. *
  160. * 08 29 2010 yuche.tsai
  161. * NULL
  162. * Fix Compile warning, type cast from UINT_32 to UINT_16.
  163. *
  164. * 08 26 2010 yuche.tsai
  165. * NULL
  166. * In P2P AT GO test mode under WinXP, we would not indicate connected event to host.
  167. *
  168. * 08 24 2010 cm.chang
  169. * NULL
  170. * Support RLM initail channel of Ad-hoc, P2P and BOW
  171. *
  172. * 08 23 2010 chinghwa.yu
  173. * NULL
  174. * Update for BOW.
  175. *
  176. * 08 20 2010 kevin.huang
  177. * NULL
  178. * Modify AAA Module for changing STA STATE 3 at p2p/bowRunEventAAAComplete()
  179. *
  180. * 08 17 2010 yuche.tsai
  181. * NULL
  182. * Fix bug while enabling P2P GO.
  183. *
  184. * 08 16 2010 kevin.huang
  185. * NULL
  186. * Refine AAA functions
  187. *
  188. * 07 08 2010 cp.wu
  189. *
  190. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  191. *
  192. * 06 21 2010 cp.wu
  193. * [WPD00003833][MT6620 and MT5931] Driver migration
  194. * refine TX-DONE callback.
  195. *
  196. * 06 21 2010 yuche.tsai
  197. * [WPD00003839][MT6620 5931][P2P] Feature migration
  198. * modify due to P2P functino call prototype change.
  199. *
  200. * 06 17 2010 yuche.tsai
  201. * [WPD00003839][MT6620 5931][P2P] Feature migration
  202. * First draft for migration P2P FSM from FW to Driver.
  203. *
  204. * 04 02 2010 kevin.huang
  205. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  206. * Modify CFG flags
  207. *
  208. * 02 26 2010 kevin.huang
  209. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  210. * add support of Driver STA_RECORD_T activation
  211. *
  212. * 02 04 2010 kevin.huang
  213. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  214. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  215. */
  216. /*******************************************************************************
  217. * C O M P I L E R F L A G S
  218. ********************************************************************************
  219. */
  220. /*******************************************************************************
  221. * E X T E R N A L R E F E R E N C E S
  222. ********************************************************************************
  223. */
  224. #include "precomp.h"
  225. /*******************************************************************************
  226. * C O N S T A N T S
  227. ********************************************************************************
  228. */
  229. /*******************************************************************************
  230. * D A T A T Y P E S
  231. ********************************************************************************
  232. */
  233. /*******************************************************************************
  234. * P U B L I C D A T A
  235. ********************************************************************************
  236. */
  237. /*******************************************************************************
  238. * P R I V A T E D A T A
  239. ********************************************************************************
  240. */
  241. /*******************************************************************************
  242. * M A C R O S
  243. ********************************************************************************
  244. */
  245. /*******************************************************************************
  246. * F U N C T I O N D E C L A R A T I O N S
  247. ********************************************************************************
  248. */
  249. /*******************************************************************************
  250. * F U N C T I O N S
  251. ********************************************************************************
  252. */
  253. #if 0
  254. /*----------------------------------------------------------------------------*/
  255. /*!
  256. * @brief This function will send Event to AIS/BOW/P2P
  257. *
  258. * @param[in] rJoinStatus To indicate JOIN success or failure.
  259. * @param[in] prStaRec Pointer to the STA_RECORD_T
  260. * @param[in] prSwRfb Pointer to the SW_RFB_T
  261. * @return none
  262. */
  263. /*----------------------------------------------------------------------------*/
  264. WLAN_STATUS aaaFsmSendEventJoinComplete(WLAN_STATUS rJoinStatus, P_STA_RECORD_T prStaRec, P_SW_RFB_T prSwRfb)
  265. {
  266. P_MSG_SAA_JOIN_COMP_T prJoinCompMsg;
  267. ASSERT(prStaRec);
  268. prJoinCompMsg = cnmMemAlloc(RAM_TYPE_TCM, sizeof(MSG_SAA_JOIN_COMP_T));
  269. if (!prJoinCompMsg)
  270. return WLAN_STATUS_RESOURCES;
  271. if (IS_STA_IN_AIS(prStaRec))
  272. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_AIS_JOIN_COMPLETE;
  273. else if (IS_STA_IN_P2P(prStaRec))
  274. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_P2P_JOIN_COMPLETE;
  275. else if (IS_STA_IN_BOW(prStaRec))
  276. prJoinCompMsg->rMsgHdr.eMsgId = MID_SAA_BOW_JOIN_COMPLETE;
  277. else
  278. ASSERT(0);
  279. prJoinCompMsg->rJoinStatus = rJoinStatus;
  280. prJoinCompMsg->prStaRec = prStaRec;
  281. prJoinCompMsg->prSwRfb = prSwRfb;
  282. mboxSendMsg(MBOX_ID_0, (P_MSG_HDR_T) prJoinCompMsg, MSG_SEND_METHOD_BUF);
  283. return WLAN_STATUS_SUCCESS;
  284. } /* end of saaFsmSendEventJoinComplete() */
  285. /*----------------------------------------------------------------------------*/
  286. /*!
  287. * @brief This function will handle the Start Event to AAA FSM.
  288. *
  289. * @param[in] prMsgHdr Message of Join Request for a particular STA.
  290. *
  291. * @return none
  292. */
  293. /*----------------------------------------------------------------------------*/
  294. VOID aaaFsmRunEventStart(IN P_MSG_HDR_T prMsgHdr)
  295. {
  296. P_MSG_SAA_JOIN_REQ_T prJoinReqMsg;
  297. P_STA_RECORD_T prStaRec;
  298. P_AIS_BSS_INFO_T prAisBssInfo;
  299. ASSERT(prMsgHdr);
  300. prJoinReqMsg = (P_MSG_SAA_JOIN_REQ_T) prMsgHdr;
  301. prStaRec = prJoinReqMsg->prStaRec;
  302. ASSERT(prStaRec);
  303. DBGLOG(SAA, LOUD, "EVENT-START: Trigger SAA FSM\n");
  304. cnmMemFree(prMsgHdr);
  305. /* 4 <1> Validation of SAA Start Event */
  306. if (!IS_AP_STA(prStaRec->eStaType)) {
  307. DBGLOG(SAA, ERROR, "EVENT-START: STA Type - %d was not supported.\n", prStaRec->eStaType);
  308. /* Ignore the return value because don't care the prSwRfb */
  309. saaFsmSendEventJoinComplete(WLAN_STATUS_FAILURE, prStaRec, NULL);
  310. return;
  311. }
  312. /* 4 <2> The previous JOIN process is not completed ? */
  313. if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
  314. DBGLOG(SAA, ERROR, "EVENT-START: Reentry of SAA Module.\n");
  315. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  316. }
  317. /* 4 <3> Reset Status Code and Time */
  318. /* Update Station Record - Status/Reason Code */
  319. prStaRec->u2StatusCode = STATUS_CODE_SUCCESSFUL;
  320. /* Update the record join time. */
  321. GET_CURRENT_SYSTIME(&prStaRec->rLastJoinTime);
  322. prStaRec->ucTxAuthAssocRetryCount = 0;
  323. if (prStaRec->prChallengeText) {
  324. cnmMemFree(prStaRec->prChallengeText);
  325. prStaRec->prChallengeText = (P_IE_CHALLENGE_TEXT_T) NULL;
  326. }
  327. cnmTimerStopTimer(&prStaRec->rTxReqDoneOrRxRespTimer);
  328. prStaRec->ucStaState = STA_STATE_1;
  329. /* Trigger SAA MODULE */
  330. saaFsmSteps(prStaRec, SAA_STATE_SEND_AUTH1, (P_SW_RFB_T) NULL);
  331. } /* end of saaFsmRunEventStart() */
  332. #endif
  333. #if CFG_SUPPORT_AAA
  334. /*----------------------------------------------------------------------------*/
  335. /*!
  336. * @brief This function will process the Rx Auth Request Frame and then
  337. * trigger AAA FSM.
  338. *
  339. * @param[in] prAdapter Pointer to the Adapter structure.
  340. * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
  341. *
  342. * @return (none)
  343. */
  344. /*----------------------------------------------------------------------------*/
  345. VOID aaaFsmRunEventRxAuth(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  346. {
  347. P_BSS_INFO_T prBssInfo = (P_BSS_INFO_T) NULL;
  348. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  349. UINT_16 u2StatusCode;
  350. BOOLEAN fgReplyAuth = FALSE;
  351. P_WLAN_AUTH_FRAME_T prAuthFrame = (P_WLAN_AUTH_FRAME_T) NULL;
  352. ASSERT(prAdapter);
  353. do {
  354. prAuthFrame = (P_WLAN_AUTH_FRAME_T) prSwRfb->pvHeader;
  355. #if CFG_ENABLE_WIFI_DIRECT
  356. prBssInfo = p2pFuncBSSIDFindBssInfo(prAdapter, prAuthFrame->aucBSSID);
  357. /* 4 <1> Check P2P network conditions */
  358. if (prBssInfo && prAdapter->fgIsP2PRegistered) {
  359. if (prBssInfo->fgIsNetActive) {
  360. /* 4 <1.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  361. if (WLAN_STATUS_SUCCESS ==
  362. authProcessRxAuth1Frame(prAdapter,
  363. prSwRfb,
  364. prBssInfo->aucBSSID,
  365. AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
  366. AUTH_TRANSACTION_SEQ_1, &u2StatusCode)) {
  367. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  368. /* 4 <1.2> Validate Auth Frame for Network Specific Conditions */
  369. fgReplyAuth = p2pFuncValidateAuth(prAdapter,
  370. prBssInfo,
  371. prSwRfb, &prStaRec, &u2StatusCode);
  372. } else {
  373. fgReplyAuth = TRUE;
  374. }
  375. break;
  376. }
  377. }
  378. }
  379. #endif /* CFG_ENABLE_WIFI_DIRECT */
  380. /* 4 <2> Check BOW network conditions */
  381. #if CFG_ENABLE_BT_OVER_WIFI
  382. {
  383. P_BOW_FSM_INFO_T prBowFsmInfo = (P_BOW_FSM_INFO_T) NULL;
  384. prBowFsmInfo = &(prAdapter->rWifiVar.rBowFsmInfo);
  385. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prBowFsmInfo->ucBssIndex);
  386. if ((prBssInfo->fgIsNetActive) && (OP_MODE_BOW == prBssInfo->eCurrentOPMode)) {
  387. /* 4 <2.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  388. /* Check if for this BSSID */
  389. if (WLAN_STATUS_SUCCESS ==
  390. authProcessRxAuth1Frame(prAdapter,
  391. prSwRfb,
  392. prBssInfo->aucBSSID,
  393. AUTH_ALGORITHM_NUM_OPEN_SYSTEM,
  394. AUTH_TRANSACTION_SEQ_1, &u2StatusCode)) {
  395. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  396. /* 4 <2.2> Validate Auth Frame for Network Specific Conditions */
  397. fgReplyAuth =
  398. bowValidateAuth(prAdapter, prSwRfb, &prStaRec, &u2StatusCode);
  399. } else {
  400. fgReplyAuth = TRUE;
  401. }
  402. /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
  403. break;
  404. }
  405. }
  406. }
  407. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  408. return;
  409. } while (FALSE);
  410. if (prStaRec) {
  411. /* update RCPI */
  412. ASSERT(prSwRfb->prRxStatusGroup3);
  413. prStaRec->ucRCPI = (UINT_8) HAL_RX_STATUS_GET_RCPI(prSwRfb->prRxStatusGroup3);
  414. }
  415. /* 4 <3> Update STA_RECORD_T and reply Auth_2(Response to Auth_1) Frame */
  416. if (fgReplyAuth) {
  417. if (prStaRec) {
  418. if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
  419. if (prStaRec->eAuthAssocState != AA_STATE_IDLE) {
  420. DBGLOG(AAA, WARN,
  421. "Previous AuthAssocState (%d) != IDLE.\n", prStaRec->eAuthAssocState);
  422. }
  423. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  424. } else {
  425. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  426. /* NOTE(Kevin): Change to STATE_1 */
  427. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  428. }
  429. /* Update the record join time. */
  430. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  431. /* Update Station Record - Status/Reason Code */
  432. prStaRec->u2StatusCode = u2StatusCode;
  433. prStaRec->ucAuthAlgNum = AUTH_ALGORITHM_NUM_OPEN_SYSTEM;
  434. } else {
  435. /* NOTE(Kevin): We should have STA_RECORD_T if the status code was successful */
  436. ASSERT(!(u2StatusCode == STATUS_CODE_SUCCESSFUL));
  437. }
  438. /* NOTE: Ignore the return status for AAA */
  439. /* 4 <4> Reply Auth */
  440. authSendAuthFrame(prAdapter,
  441. prStaRec, prBssInfo->ucBssIndex, prSwRfb, AUTH_TRANSACTION_SEQ_2, u2StatusCode);
  442. } else if (prStaRec)
  443. cnmStaRecFree(prAdapter, prStaRec);
  444. } /* end of aaaFsmRunEventRxAuth() */
  445. /*----------------------------------------------------------------------------*/
  446. /*!
  447. * @brief This function will process the Rx (Re)Association Request Frame and then
  448. * trigger AAA FSM.
  449. *
  450. * @param[in] prAdapter Pointer to the Adapter structure.
  451. * @param[in] prSwRfb Pointer to the SW_RFB_T structure.
  452. *
  453. * @retval WLAN_STATUS_SUCCESS Always return success
  454. */
  455. /*----------------------------------------------------------------------------*/
  456. WLAN_STATUS aaaFsmRunEventRxAssoc(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  457. {
  458. P_BSS_INFO_T prBssInfo;
  459. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  460. UINT_16 u2StatusCode = STATUS_CODE_RESERVED;
  461. BOOLEAN fgReplyAssocResp = FALSE;
  462. ASSERT(prAdapter);
  463. do {
  464. /* 4 <1> Check if we have the STA_RECORD_T for incoming Assoc Req */
  465. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  466. /* We should have the corresponding Sta Record. */
  467. if ((!prStaRec) || (!prStaRec->fgIsInUse)) {
  468. /* Not to reply association response with failure code due to lack of STA_REC */
  469. break;
  470. }
  471. if (!IS_CLIENT_STA(prStaRec))
  472. break;
  473. if (prStaRec->ucStaState == STA_STATE_3) {
  474. /* Do Reassocation */
  475. } else if ((prStaRec->ucStaState == STA_STATE_2) &&
  476. (prStaRec->eAuthAssocState == AAA_STATE_SEND_AUTH2)) {
  477. /* Normal case */
  478. } else {
  479. DBGLOG(AAA, WARN, "Previous AuthAssocState (%d) != SEND_AUTH2.\n", prStaRec->eAuthAssocState);
  480. /* Maybe Auth Response TX fail, but actually it success. */
  481. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  482. }
  483. /* update RCPI */
  484. ASSERT(prSwRfb->prRxStatusGroup3);
  485. prStaRec->ucRCPI = (UINT_8) HAL_RX_STATUS_GET_RCPI(prSwRfb->prRxStatusGroup3);
  486. /* 4 <2> Check P2P network conditions */
  487. #if CFG_ENABLE_WIFI_DIRECT
  488. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
  489. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  490. if (prBssInfo->fgIsNetActive) {
  491. /* 4 <2.1> Validate Assoc Req Frame and get Status Code */
  492. /* Check if for this BSSID */
  493. if (WLAN_STATUS_SUCCESS ==
  494. assocProcessRxAssocReqFrame(prAdapter, prSwRfb, &u2StatusCode)) {
  495. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  496. /* 4 <2.2> Validate Assoc Req Frame for Network Specific Conditions */
  497. fgReplyAssocResp =
  498. p2pFuncValidateAssocReq(prAdapter, prSwRfb,
  499. (PUINT_16)&u2StatusCode);
  500. } else {
  501. fgReplyAssocResp = TRUE;
  502. }
  503. break;
  504. }
  505. }
  506. }
  507. #endif /* CFG_ENABLE_WIFI_DIRECT */
  508. /* 4 <3> Check BOW network conditions */
  509. #if CFG_ENABLE_BT_OVER_WIFI
  510. if (IS_STA_BOW_TYPE(prStaRec)) {
  511. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  512. if ((prBssInfo->fgIsNetActive) && (OP_MODE_BOW == prBssInfo->eCurrentOPMode)) {
  513. /* 4 <3.1> Validate Auth Frame by Auth Algorithm/Transation Seq */
  514. /* Check if for this BSSID */
  515. if (WLAN_STATUS_SUCCESS ==
  516. assocProcessRxAssocReqFrame(prAdapter, prSwRfb, &u2StatusCode)) {
  517. if (STATUS_CODE_SUCCESSFUL == u2StatusCode) {
  518. /* 4 <3.2> Validate Auth Frame for Network Specific Conditions */
  519. fgReplyAssocResp =
  520. bowValidateAssocReq(prAdapter, prSwRfb, &u2StatusCode);
  521. } else {
  522. fgReplyAssocResp = TRUE;
  523. }
  524. /* TODO(Kevin): Allocate a STA_RECORD_T for new client */
  525. break;
  526. }
  527. }
  528. }
  529. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  530. return WLAN_STATUS_SUCCESS; /* To release the SW_RFB_T */
  531. } while (FALSE);
  532. /* 4 <4> Update STA_RECORD_T and reply Assoc Resp Frame */
  533. if (fgReplyAssocResp) {
  534. UINT_16 u2IELength;
  535. PUINT_8 pucIE;
  536. if ((((P_WLAN_ASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->u2FrameCtrl & MASK_FRAME_TYPE) ==
  537. MAC_FRAME_REASSOC_REQ) {
  538. u2IELength = prSwRfb->u2PacketLen -
  539. (UINT_16) OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]);
  540. pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->aucInfoElem;
  541. } else {
  542. u2IELength = prSwRfb->u2PacketLen - (UINT_16) OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]);
  543. pucIE = ((P_WLAN_ASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->aucInfoElem;
  544. }
  545. rlmProcessAssocReq(prAdapter, prSwRfb, pucIE, u2IELength);
  546. /* 4 <4.1> Assign Association ID */
  547. if (u2StatusCode == STATUS_CODE_SUCCESSFUL) {
  548. #if CFG_ENABLE_WIFI_DIRECT
  549. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
  550. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  551. if (p2pRoleFsmRunEventAAAComplete(prAdapter, prStaRec, prBssInfo) ==
  552. WLAN_STATUS_SUCCESS) {
  553. prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
  554. /* prStaRec->eAuthAssocState = AA_STATE_IDLE; */
  555. /* NOTE(Kevin): for TX done */
  556. prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2;
  557. /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
  558. /* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3); */
  559. } else {
  560. /* Client List FULL. */
  561. u2StatusCode = STATUS_CODE_REQ_DECLINED;
  562. prStaRec->u2AssocId = 0; /* Invalid Association ID */
  563. /* If(Re)association fail,remove sta record and use class error to handle sta */
  564. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  565. /* NOTE(Kevin): Better to change state here, not at TX Done */
  566. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  567. }
  568. }
  569. #endif
  570. #if CFG_ENABLE_BT_OVER_WIFI
  571. if ((IS_STA_BOW_TYPE(prStaRec))) {
  572. /* if (bowRunEventAAAComplete(prAdapter, prStaRec) == WLAN_STATUS_SUCCESS) { */
  573. prStaRec->u2AssocId = bssAssignAssocID(prStaRec);
  574. prStaRec->eAuthAssocState = AAA_STATE_SEND_ASSOC2; /* NOTE(Kevin): for TX done */
  575. /* NOTE(Kevin): Method A: Change to STATE_3 before handle TX Done */
  576. /* cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_3); */
  577. }
  578. #endif
  579. } else {
  580. prStaRec->u2AssocId = 0; /* Invalid Association ID */
  581. /* If (Re)association fail, remove sta record and use class error to handle sta */
  582. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  583. /* NOTE(Kevin): Better to change state here, not at TX Done */
  584. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  585. }
  586. /* Update the record join time. */
  587. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  588. /* Update Station Record - Status/Reason Code */
  589. prStaRec->u2StatusCode = u2StatusCode;
  590. /* NOTE: Ignore the return status for AAA */
  591. /* 4 <4.2> Reply Assoc Resp */
  592. assocSendReAssocRespFrame(prAdapter, prStaRec);
  593. }
  594. return WLAN_STATUS_SUCCESS;
  595. } /* end of aaaFsmRunEventRxAssoc() */
  596. /*----------------------------------------------------------------------------*/
  597. /*!
  598. * @brief This function will handle TxDone(Auth2/AssocReq) Event of AAA FSM.
  599. *
  600. * @param[in] prAdapter Pointer to the Adapter structure.
  601. * @param[in] prMsduInfo Pointer to the MSDU_INFO_T.
  602. * @param[in] rTxDoneStatus Return TX status of the Auth1/Auth3/AssocReq frame.
  603. *
  604. * @retval WLAN_STATUS_SUCCESS
  605. */
  606. /*----------------------------------------------------------------------------*/
  607. WLAN_STATUS
  608. aaaFsmRunEventTxDone(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  609. {
  610. P_STA_RECORD_T prStaRec;
  611. P_BSS_INFO_T prBssInfo;
  612. ASSERT(prAdapter);
  613. ASSERT(prMsduInfo);
  614. DBGLOG(AAA, LOUD, "EVENT-TX DONE: Current Time = %ld\n", kalGetTimeTick());
  615. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  616. if ((!prStaRec) || (!prStaRec->fgIsInUse))
  617. return WLAN_STATUS_SUCCESS; /* For the case of replying ERROR STATUS CODE */
  618. ASSERT(prStaRec->ucBssIndex <= MAX_BSS_INDEX);
  619. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  620. /* Trigger statistics log if Auth/Assoc Tx failed */
  621. if (rTxDoneStatus != TX_RESULT_SUCCESS)
  622. wlanTriggerStatsLog(prAdapter, prAdapter->rWifiVar.u4StatsLogDuration);
  623. switch (prStaRec->eAuthAssocState) {
  624. case AAA_STATE_SEND_AUTH2:
  625. {
  626. /* Strictly check the outgoing frame is matched with current AA STATE */
  627. if (authCheckTxAuthFrame(prAdapter, prMsduInfo, AUTH_TRANSACTION_SEQ_2) != WLAN_STATUS_SUCCESS)
  628. break;
  629. if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
  630. if (TX_RESULT_SUCCESS == rTxDoneStatus) {
  631. /* NOTE(Kevin): Change to STATE_2 at TX Done */
  632. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  633. } else {
  634. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  635. /* NOTE(Kevin): Change to STATE_1 */
  636. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_1);
  637. #if CFG_ENABLE_WIFI_DIRECT
  638. if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P)
  639. p2pRoleFsmRunEventAAATxFail(prAdapter, prStaRec, prBssInfo);
  640. #endif /* CFG_ENABLE_WIFI_DIRECT */
  641. #if CFG_ENABLE_BT_OVER_WIFI
  642. if (IS_STA_BOW_TYPE(prStaRec))
  643. bowRunEventAAATxFail(prAdapter, prStaRec);
  644. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  645. }
  646. }
  647. /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
  648. }
  649. break;
  650. case AAA_STATE_SEND_ASSOC2:
  651. {
  652. /* Strictly check the outgoing frame is matched with current SAA STATE */
  653. if (assocCheckTxReAssocRespFrame(prAdapter, prMsduInfo) != WLAN_STATUS_SUCCESS)
  654. break;
  655. if (STATUS_CODE_SUCCESSFUL == prStaRec->u2StatusCode) {
  656. if (TX_RESULT_SUCCESS == rTxDoneStatus) {
  657. prStaRec->eAuthAssocState = AA_STATE_IDLE;
  658. /* NOTE(Kevin): Change to STATE_3 at TX Done */
  659. #if CFG_ENABLE_WIFI_DIRECT
  660. if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P)
  661. p2pRoleFsmRunEventAAASuccess(prAdapter, prStaRec, prBssInfo);
  662. #endif /* CFG_ENABLE_WIFI_DIRECT */
  663. #if CFG_ENABLE_BT_OVER_WIFI
  664. if (IS_STA_BOW_TYPE(prStaRec))
  665. bowRunEventAAAComplete(prAdapter, prStaRec);
  666. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  667. } else {
  668. prStaRec->eAuthAssocState = AAA_STATE_SEND_AUTH2;
  669. /* NOTE(Kevin): Change to STATE_2 */
  670. cnmStaRecChangeState(prAdapter, prStaRec, STA_STATE_2);
  671. #if CFG_ENABLE_WIFI_DIRECT
  672. if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P)
  673. p2pRoleFsmRunEventAAATxFail(prAdapter, prStaRec, prBssInfo);
  674. #endif /* CFG_ENABLE_WIFI_DIRECT */
  675. #if CFG_ENABLE_BT_OVER_WIFI
  676. if (IS_STA_BOW_TYPE(prStaRec))
  677. bowRunEventAAATxFail(prAdapter, prStaRec);
  678. #endif /* CFG_ENABLE_BT_OVER_WIFI */
  679. }
  680. }
  681. /* NOTE(Kevin): Ignore the TX Done Event of Auth Frame with Error Status Code */
  682. }
  683. break;
  684. case AA_STATE_IDLE:
  685. /* 2013-08-27 frog: Do nothing.
  686. * Somtimes we may send Assoc Resp twice. (Rx Assoc Req before the first Assoc TX Done)
  687. * The AssocState is changed to IDLE after first TX done.
  688. * Free station record when IDLE is seriously wrong.
  689. */
  690. /* /cnmStaRecFree(prAdapter, prStaRec); */
  691. default:
  692. break; /* Ignore other cases */
  693. }
  694. return WLAN_STATUS_SUCCESS;
  695. } /* end of aaaFsmRunEventTxDone() */
  696. #endif /* CFG_SUPPORT_AAA */
  697. #if 0 /* TODO(Kevin): for abort event, just reset the STA_RECORD_T. */
  698. /*----------------------------------------------------------------------------*/
  699. /*!
  700. * \brief This function will send ABORT Event to JOIN FSM.
  701. *
  702. * \param[in] prAdapter Pointer to the Adapter structure.
  703. *
  704. * \return none
  705. */
  706. /*----------------------------------------------------------------------------*/
  707. VOID saaFsmRunEventAbort(IN P_MSG_HDR_T prMsgHdr)
  708. {
  709. P_JOIN_INFO_T prJoinInfo;
  710. P_STA_RECORD_T prStaRec;
  711. DEBUGFUNC("joinFsmRunEventAbort");
  712. ASSERT(prAdapter);
  713. prJoinInfo = &prAdapter->rJoinInfo;
  714. DBGLOG(JOIN, EVENT, "JOIN EVENT: ABORT\n");
  715. /* NOTE(Kevin): when reach here, the ARB_STATE should be in ARB_STATE_JOIN. */
  716. ASSERT(prJoinInfo->prBssDesc);
  717. /* 4 <1> Update Flags and Elements of JOIN Module. */
  718. /* Reset Send Auth/(Re)Assoc Frame Count */
  719. prJoinInfo->ucTxAuthAssocRetryCount = 0;
  720. /* Cancel all JOIN relative Timer */
  721. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rTxRequestTimer);
  722. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rRxResponseTimer);
  723. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rJoinTimer);
  724. /* 4 <2> Update the associated STA_RECORD_T during JOIN. */
  725. /* Get a Station Record if possible, TA == BSSID for AP */
  726. prStaRec = staRecGetStaRecordByAddr(prAdapter, prJoinInfo->prBssDesc->aucBSSID);
  727. if (prStaRec)
  728. prStaRec->ucStaState = STA_STATE_1; /* Update Station Record - Class 1 Flag */
  729. #if DBG
  730. else
  731. ASSERT(0); /* Shouldn't happened, because we already add this STA_RECORD_T at JOIN_STATE_INIT */
  732. #endif /* DBG */
  733. /* 4 <3> Pull back to IDLE. */
  734. joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
  735. /* 4 <4> If we are in Roaming, recover the settings of previous BSS. */
  736. /* NOTE: JOIN FAIL -
  737. * Restore original setting from current BSS_INFO_T.
  738. */
  739. if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED)
  740. joinAdoptParametersFromCurrentBss(prAdapter);
  741. } /* end of joinFsmRunEventAbort() */
  742. #endif
  743. /* TODO(Kevin): following code will be modified and move to AIS FSM */
  744. #if 0
  745. /*----------------------------------------------------------------------------*/
  746. /*!
  747. * \brief This function will send Join Timeout Event to JOIN FSM.
  748. *
  749. * \param[in] prAdapter Pointer to the Adapter structure.
  750. *
  751. * \retval WLAN_STATUS_FAILURE Fail because of Join Timeout
  752. */
  753. /*----------------------------------------------------------------------------*/
  754. WLAN_STATUS joinFsmRunEventJoinTimeOut(IN P_ADAPTER_T prAdapter)
  755. {
  756. P_JOIN_INFO_T prJoinInfo;
  757. P_STA_RECORD_T prStaRec;
  758. DEBUGFUNC("joinFsmRunEventJoinTimeOut");
  759. ASSERT(prAdapter);
  760. prJoinInfo = &prAdapter->rJoinInfo;
  761. DBGLOG(JOIN, EVENT, "JOIN EVENT: JOIN TIMEOUT\n");
  762. /* Get a Station Record if possible, TA == BSSID for AP */
  763. prStaRec = staRecGetStaRecordByAddr(prAdapter, prJoinInfo->prBssDesc->aucBSSID);
  764. /* We have renew this Sta Record when in JOIN_STATE_INIT */
  765. ASSERT(prStaRec);
  766. /* Record the Status Code of Authentication Request */
  767. prStaRec->u2StatusCode = STATUS_CODE_JOIN_TIMEOUT;
  768. /* Increase Failure Count */
  769. prStaRec->ucJoinFailureCount++;
  770. /* Reset Send Auth/(Re)Assoc Frame Count */
  771. prJoinInfo->ucTxAuthAssocRetryCount = 0;
  772. /* Cancel other JOIN relative Timer */
  773. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rTxRequestTimer);
  774. ARB_CANCEL_TIMER(prAdapter, prJoinInfo->rRxResponseTimer);
  775. /* Restore original setting from current BSS_INFO_T */
  776. if (prAdapter->eConnectionState == MEDIA_STATE_CONNECTED)
  777. joinAdoptParametersFromCurrentBss(prAdapter);
  778. /* Pull back to IDLE */
  779. joinFsmSteps(prAdapter, JOIN_STATE_IDLE);
  780. return WLAN_STATUS_FAILURE;
  781. } /* end of joinFsmRunEventJoinTimeOut() */
  782. /*----------------------------------------------------------------------------*/
  783. /*!
  784. * \brief This function will adopt the parameters from Peer BSS.
  785. *
  786. * \param[in] prAdapter Pointer to the Adapter structure.
  787. *
  788. * \return (none)
  789. */
  790. /*----------------------------------------------------------------------------*/
  791. VOID joinAdoptParametersFromPeerBss(IN P_ADAPTER_T prAdapter)
  792. {
  793. P_JOIN_INFO_T prJoinInfo;
  794. P_BSS_DESC_T prBssDesc;
  795. DEBUGFUNC("joinAdoptParametersFromPeerBss");
  796. ASSERT(prAdapter);
  797. prJoinInfo = &prAdapter->rJoinInfo;
  798. prBssDesc = prJoinInfo->prBssDesc;
  799. /* 4 <1> Adopt Peer BSS' PHY TYPE */
  800. prAdapter->eCurrentPhyType = prBssDesc->ePhyType;
  801. DBGLOG(JOIN, INFO, "Target BSS[%s]'s PhyType = %s\n",
  802. prBssDesc->aucSSID, (prBssDesc->ePhyType == PHY_TYPE_ERP_INDEX) ? "ERP" : "HR_DSSS");
  803. /* 4 <2> Adopt Peer BSS' Frequency(Band/Channel) */
  804. DBGLOG(JOIN, INFO, "Target BSS's Channel = %d, Band = %d\n", prBssDesc->ucChannelNum, prBssDesc->eBand);
  805. nicSwitchChannel(prAdapter, prBssDesc->eBand, prBssDesc->ucChannelNum, 10);
  806. prJoinInfo->fgIsParameterAdopted = TRUE;
  807. } /* end of joinAdoptParametersFromPeerBss() */
  808. /*----------------------------------------------------------------------------*/
  809. /*!
  810. * \brief This function will adopt the parameters from current associated BSS.
  811. *
  812. * \param[in] prAdapter Pointer to the Adapter structure.
  813. *
  814. * \return (none)
  815. */
  816. /*----------------------------------------------------------------------------*/
  817. VOID joinAdoptParametersFromCurrentBss(IN P_ADAPTER_T prAdapter)
  818. {
  819. /* P_JOIN_INFO_T prJoinInfo = &prAdapter->rJoinInfo; */
  820. P_BSS_INFO_T prBssInfo;
  821. ASSERT(prAdapter);
  822. prBssInfo = &prAdapter->rBssInfo;
  823. /* 4 <1> Adopt current BSS' PHY TYPE */
  824. prAdapter->eCurrentPhyType = prBssInfo->ePhyType;
  825. /* 4 <2> Adopt current BSS' Frequency(Band/Channel) */
  826. DBGLOG(JOIN, INFO, "Current BSS's Channel = %d, Band = %d\n", prBssInfo->ucChnl, prBssInfo->eBand);
  827. nicSwitchChannel(prAdapter, prBssInfo->eBand, prBssInfo->ucChnl, 10);
  828. } /* end of joinAdoptParametersFromCurrentBss() */
  829. /*----------------------------------------------------------------------------*/
  830. /*!
  831. * \brief This function will update all the SW variables and HW MCR registers after
  832. * the association with target BSS.
  833. *
  834. * \param[in] prAdapter Pointer to the Adapter structure.
  835. *
  836. * \return (none)
  837. */
  838. /*----------------------------------------------------------------------------*/
  839. VOID joinComplete(IN P_ADAPTER_T prAdapter)
  840. {
  841. P_JOIN_INFO_T prJoinInfo;
  842. P_BSS_DESC_T prBssDesc;
  843. P_PEER_BSS_INFO_T prPeerBssInfo;
  844. P_BSS_INFO_T prBssInfo;
  845. P_CONNECTION_SETTINGS_T prConnSettings;
  846. P_STA_RECORD_T prStaRec;
  847. P_TX_CTRL_T prTxCtrl;
  848. #if CFG_SUPPORT_802_11D
  849. P_IE_COUNTRY_T prIECountry;
  850. #endif
  851. DEBUGFUNC("joinComplete");
  852. ASSERT(prAdapter);
  853. prJoinInfo = &prAdapter->rJoinInfo;
  854. prBssDesc = prJoinInfo->prBssDesc;
  855. prPeerBssInfo = &prAdapter->rPeerBssInfo;
  856. prBssInfo = &prAdapter->rBssInfo;
  857. prConnSettings = &prAdapter->rConnSettings;
  858. prTxCtrl = &prAdapter->rTxCtrl;
  859. /* 4 <1> Update Connecting & Connected Flag of BSS_DESC_T. */
  860. /* Remove previous AP's Connection Flags if have */
  861. scanRemoveConnectionFlagOfBssDescByBssid(prAdapter, prBssInfo->aucBSSID);
  862. prBssDesc->fgIsConnected = TRUE; /* Mask as Connected */
  863. if (prBssDesc->fgIsHiddenSSID) {
  864. /* NOTE(Kevin): This is for the case of Passive Scan and the target BSS didn't
  865. * broadcast SSID on its Beacon Frame.
  866. */
  867. COPY_SSID(prBssDesc->aucSSID,
  868. prBssDesc->ucSSIDLen, prAdapter->rConnSettings.aucSSID, prAdapter->rConnSettings.ucSSIDLen);
  869. if (prBssDesc->ucSSIDLen)
  870. prBssDesc->fgIsHiddenSSID = FALSE;
  871. #if DBG
  872. else
  873. ASSERT(0);
  874. #endif /* DBG */
  875. DBGLOG(JOIN, INFO, "Hidden SSID! - Update SSID : %s\n", prBssDesc->aucSSID);
  876. }
  877. /* 4 <2> Update BSS_INFO_T from BSS_DESC_T */
  878. /* 4 <2.A> PHY Type */
  879. prBssInfo->ePhyType = prBssDesc->ePhyType;
  880. /* 4 <2.B> BSS Type */
  881. prBssInfo->eBSSType = BSS_TYPE_INFRASTRUCTURE;
  882. /* 4 <2.C> BSSID */
  883. COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID);
  884. DBGLOG(JOIN, INFO, "JOIN to BSSID: [" MACSTR "]\n", MAC2STR(prBssDesc->aucBSSID));
  885. /* 4 <2.D> SSID */
  886. COPY_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen, prBssDesc->aucSSID, prBssDesc->ucSSIDLen);
  887. /* 4 <2.E> Channel / Band information. */
  888. prBssInfo->eBand = prBssDesc->eBand;
  889. prBssInfo->ucChnl = prBssDesc->ucChannelNum;
  890. /* 4 <2.F> RSN/WPA information. */
  891. secFsmRunEventStart(prAdapter);
  892. prBssInfo->u4RsnSelectedPairwiseCipher = prBssDesc->u4RsnSelectedPairwiseCipher;
  893. prBssInfo->u4RsnSelectedGroupCipher = prBssDesc->u4RsnSelectedGroupCipher;
  894. prBssInfo->u4RsnSelectedAKMSuite = prBssDesc->u4RsnSelectedAKMSuite;
  895. if (secRsnKeyHandshakeEnabled())
  896. prBssInfo->fgIsWPAorWPA2Enabled = TRUE;
  897. else
  898. prBssInfo->fgIsWPAorWPA2Enabled = FALSE;
  899. /* 4 <2.G> Beacon interval. */
  900. prBssInfo->u2BeaconInterval = prBssDesc->u2BeaconInterval;
  901. /* 4 <2.H> DTIM period. */
  902. prBssInfo->ucDtimPeriod = prBssDesc->ucDTIMPeriod;
  903. /* 4 <2.I> ERP Information */
  904. if ((prBssInfo->ePhyType == PHY_TYPE_ERP_INDEX) && /* Our BSS's PHY_TYPE is ERP now. */
  905. (prBssDesc->fgIsERPPresent)) {
  906. prBssInfo->fgIsERPPresent = TRUE;
  907. prBssInfo->ucERP = prBssDesc->ucERP; /* Save the ERP for later check */
  908. } else {
  909. /* Some AP, may send ProbeResp without ERP IE. Thus prBssDesc->fgIsERPPresent is FALSE. */
  910. prBssInfo->fgIsERPPresent = FALSE;
  911. prBssInfo->ucERP = 0;
  912. }
  913. #if CFG_SUPPORT_802_11D
  914. /* 4 <2.J> Country inforamtion of the associated AP */
  915. if (prConnSettings->fgMultiDomainCapabilityEnabled) {
  916. DOMAIN_INFO_ENTRY rDomainInfo;
  917. if (domainGetDomainInfoByScanResult(prAdapter, &rDomainInfo)) {
  918. if (prBssDesc->prIECountry) {
  919. prIECountry = prBssDesc->prIECountry;
  920. domainParseCountryInfoElem(prIECountry, &prBssInfo->rDomainInfo);
  921. /* use the domain get from the BSS info */
  922. prBssInfo->fgIsCountryInfoPresent = TRUE;
  923. nicSetupOpChnlList(prAdapter, prBssInfo->rDomainInfo.u2CountryCode, FALSE);
  924. } else {
  925. /* use the domain get from the scan result */
  926. prBssInfo->fgIsCountryInfoPresent = TRUE;
  927. nicSetupOpChnlList(prAdapter, rDomainInfo.u2CountryCode, FALSE);
  928. }
  929. }
  930. }
  931. #endif
  932. /* 4 <2.K> Signal Power of the associated AP */
  933. prBssInfo->rRcpi = prBssDesc->rRcpi;
  934. prBssInfo->rRssi = RCPI_TO_dBm(prBssInfo->rRcpi);
  935. GET_CURRENT_SYSTIME(&prBssInfo->rRssiLastUpdateTime);
  936. /* 4 <2.L> Capability Field of the associated AP */
  937. prBssInfo->u2CapInfo = prBssDesc->u2CapInfo;
  938. DBGLOG(JOIN, INFO,
  939. "prBssInfo-> fgIsERPPresent = %d, ucERP = %02x, rRcpi = %d, rRssi = %ld\n",
  940. prBssInfo->fgIsERPPresent, prBssInfo->ucERP, prBssInfo->rRcpi, prBssInfo->rRssi);
  941. /* 4 <3> Update BSS_INFO_T from PEER_BSS_INFO_T & NIC RATE FUNC */
  942. /* 4 <3.A> Association ID */
  943. prBssInfo->u2AssocId = prPeerBssInfo->u2AssocId;
  944. /* 4 <3.B> WMM Information */
  945. if (prAdapter->fgIsEnableWMM && (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_SUPPORT_WMM)) {
  946. prBssInfo->fgIsWmmAssoc = TRUE;
  947. prTxCtrl->rTxQForVoipAccess = TXQ_AC3;
  948. qosWmmInfoInit(&prBssInfo->rWmmInfo, (prBssInfo->ePhyType == PHY_TYPE_HR_DSSS_INDEX) ? TRUE : FALSE);
  949. if (prPeerBssInfo->rWmmInfo.ucWmmFlag & WMM_FLAG_AC_PARAM_PRESENT) {
  950. kalMemCopy(&prBssInfo->rWmmInfo, &prPeerBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
  951. } else {
  952. kalMemCopy(&prBssInfo->rWmmInfo,
  953. &prPeerBssInfo->rWmmInfo,
  954. sizeof(WMM_INFO_T) - sizeof(prPeerBssInfo->rWmmInfo.arWmmAcParams));
  955. }
  956. } else {
  957. prBssInfo->fgIsWmmAssoc = FALSE;
  958. prTxCtrl->rTxQForVoipAccess = TXQ_AC1;
  959. kalMemZero(&prBssInfo->rWmmInfo, sizeof(WMM_INFO_T));
  960. }
  961. /* 4 <3.C> Operational Rate Set & BSS Basic Rate Set */
  962. prBssInfo->u2OperationalRateSet = prPeerBssInfo->u2OperationalRateSet;
  963. prBssInfo->u2BSSBasicRateSet = prPeerBssInfo->u2BSSBasicRateSet;
  964. /* 4 <3.D> Short Preamble */
  965. if (prBssInfo->fgIsERPPresent) {
  966. /* NOTE(Kevin 2007/12/24): Truth Table.
  967. * Short Preamble Bit in
  968. * <AssocReq> <AssocResp w/i ERP> <BARKER(Long)> Final Driver Setting(Short)
  969. * TRUE FALSE FALSE FALSE(shouldn't have such case,
  970. * use the AssocResp)
  971. * TRUE FALSE TRUE FALSE
  972. * FALSE FALSE FALSE FALSE(shouldn't have such case,
  973. * use the AssocResp)
  974. * FALSE FALSE TRUE FALSE
  975. * TRUE TRUE FALSE TRUE(follow ERP)
  976. * TRUE TRUE TRUE FALSE(follow ERP)
  977. * FALSE TRUE FALSE FALSE(shouldn't have such case,
  978. * and we should set to FALSE)
  979. * FALSE TRUE TRUE FALSE(we should set to FALSE)
  980. */
  981. if ((prPeerBssInfo->fgIsShortPreambleAllowed) &&
  982. ((prConnSettings->ePreambleType == PREAMBLE_TYPE_SHORT) ||
  983. /* Short Preamble Option Enable is TRUE */
  984. ((prConnSettings->ePreambleType == PREAMBLE_TYPE_AUTO)
  985. && (prBssDesc->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) {
  986. prBssInfo->fgIsShortPreambleAllowed = TRUE;
  987. if (prBssInfo->ucERP & ERP_INFO_BARKER_PREAMBLE_MODE)
  988. prBssInfo->fgUseShortPreamble = FALSE;
  989. else
  990. prBssInfo->fgUseShortPreamble = TRUE;
  991. } else {
  992. prBssInfo->fgIsShortPreambleAllowed = FALSE;
  993. prBssInfo->fgUseShortPreamble = FALSE;
  994. }
  995. } else {
  996. /* NOTE(Kevin 2007/12/24): Truth Table.
  997. * Short Preamble Bit in
  998. * <AssocReq> <AssocResp w/o ERP> Final Driver Setting(Short)
  999. * TRUE FALSE FALSE
  1000. * FALSE FALSE FALSE
  1001. * TRUE TRUE TRUE
  1002. * FALSE TRUE(status success) TRUE
  1003. * --> Honor the result of prPeerBssInfo.
  1004. */
  1005. prBssInfo->fgIsShortPreambleAllowed = prBssInfo->fgUseShortPreamble =
  1006. prPeerBssInfo->fgIsShortPreambleAllowed;
  1007. }
  1008. DBGLOG(JOIN, INFO,
  1009. "prBssInfo->fgIsShortPreambleAllowed = %d, prBssInfo->fgUseShortPreamble = %d\n",
  1010. prBssInfo->fgIsShortPreambleAllowed, prBssInfo->fgUseShortPreamble);
  1011. /* 4 <3.E> Short Slot Time */
  1012. prBssInfo->fgUseShortSlotTime = prPeerBssInfo->fgUseShortSlotTime; /* AP support Short Slot Time */
  1013. DBGLOG(JOIN, INFO, "prBssInfo->fgUseShortSlotTime = %d\n", prBssInfo->fgUseShortSlotTime);
  1014. nicSetSlotTime(prAdapter,
  1015. prBssInfo->ePhyType,
  1016. ((prConnSettings->fgIsShortSlotTimeOptionEnable &&
  1017. prBssInfo->fgUseShortSlotTime) ? TRUE : FALSE));
  1018. /* 4 <3.F> Update Tx Rate for Control Frame */
  1019. bssUpdateTxRateForControlFrame(prAdapter);
  1020. /* 4 <3.G> Save the available Auth Types during Roaming (Design for Fast BSS Transition). */
  1021. /* if (prAdapter->fgIsEnableRoaming) *//* NOTE(Kevin): Always prepare info for roaming */
  1022. {
  1023. if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_OPEN_SYSTEM)
  1024. prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_OPEN_SYSTEM;
  1025. else if (prJoinInfo->ucCurrAuthAlgNum == AUTH_ALGORITHM_NUM_SHARED_KEY)
  1026. prJoinInfo->ucRoamingAuthTypes |= AUTH_TYPE_SHARED_KEY;
  1027. prBssInfo->ucRoamingAuthTypes = prJoinInfo->ucRoamingAuthTypes;
  1028. /* Set the stable time of the associated BSS. We won't do roaming decision
  1029. * during the stable time.
  1030. */
  1031. SET_EXPIRATION_TIME(prBssInfo->rRoamingStableExpirationTime,
  1032. SEC_TO_SYSTIME(ROAMING_STABLE_TIMEOUT_SEC));
  1033. }
  1034. /* 4 <3.H> Update Parameter for TX Fragmentation Threshold */
  1035. #if CFG_TX_FRAGMENT
  1036. txFragInfoUpdate(prAdapter);
  1037. #endif /* CFG_TX_FRAGMENT */
  1038. /* 4 <4> Update STA_RECORD_T */
  1039. /* Get a Station Record if possible */
  1040. prStaRec = staRecGetStaRecordByAddr(prAdapter, prBssDesc->aucBSSID);
  1041. if (prStaRec) {
  1042. UINT_16 u2OperationalRateSet, u2DesiredRateSet;
  1043. /* 4 <4.A> Desired Rate Set */
  1044. u2OperationalRateSet = (rPhyAttributes[prBssInfo->ePhyType].u2SupportedRateSet &
  1045. prBssInfo->u2OperationalRateSet);
  1046. u2DesiredRateSet = (u2OperationalRateSet & prConnSettings->u2DesiredRateSet);
  1047. if (u2DesiredRateSet) {
  1048. prStaRec->u2DesiredRateSet = u2DesiredRateSet;
  1049. } else {
  1050. /* For Error Handling - The Desired Rate Set is not covered in Operational Rate Set. */
  1051. prStaRec->u2DesiredRateSet = u2OperationalRateSet;
  1052. }
  1053. /* Try to set the best initial rate for this entry */
  1054. if (!rateGetBestInitialRateIndex(prStaRec->u2DesiredRateSet,
  1055. prStaRec->rRcpi, &prStaRec->ucCurrRate1Index)) {
  1056. if (!rateGetLowestRateIndexFromRateSet(prStaRec->u2DesiredRateSet, &prStaRec->ucCurrRate1Index))
  1057. ASSERT(0);
  1058. }
  1059. DBGLOG(JOIN, INFO, "prStaRec->ucCurrRate1Index = %d\n", prStaRec->ucCurrRate1Index);
  1060. /* 4 <4.B> Preamble Mode */
  1061. prStaRec->fgIsShortPreambleOptionEnable = prBssInfo->fgUseShortPreamble;
  1062. /* 4 <4.C> QoS Flag */
  1063. prStaRec->fgIsQoS = prBssInfo->fgIsWmmAssoc;
  1064. }
  1065. #if DBG
  1066. else
  1067. ASSERT(0);
  1068. #endif /* DBG */
  1069. /* 4 <5> Update NIC */
  1070. /* 4 <5.A> Update BSSID & Operation Mode */
  1071. nicSetupBSS(prAdapter, prBssInfo);
  1072. /* 4 <5.B> Update WLAN Table. */
  1073. if (nicSetHwBySta(prAdapter, prStaRec) == FALSE)
  1074. ASSERT(FALSE);
  1075. /* 4 <5.C> Update Desired Rate Set for BT. */
  1076. #if CFG_TX_FRAGMENT
  1077. if (prConnSettings->fgIsEnableTxAutoFragmentForBT)
  1078. txRateSetInitForBT(prAdapter, prStaRec);
  1079. #endif /* CFG_TX_FRAGMENT */
  1080. /* 4 <5.D> TX AC Parameter and TX/RX Queue Control */
  1081. if (prBssInfo->fgIsWmmAssoc) {
  1082. #if CFG_TX_AGGREGATE_HW_FIFO
  1083. nicTxAggregateTXQ(prAdapter, FALSE);
  1084. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1085. qosUpdateWMMParametersAndAssignAllowedACI(prAdapter, &prBssInfo->rWmmInfo);
  1086. } else {
  1087. #if CFG_TX_AGGREGATE_HW_FIFO
  1088. nicTxAggregateTXQ(prAdapter, TRUE);
  1089. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1090. nicTxNonQoSAssignDefaultAdmittedTXQ(prAdapter);
  1091. nicTxNonQoSUpdateTXQParameters(prAdapter, prBssInfo->ePhyType);
  1092. }
  1093. #if CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN
  1094. {
  1095. prTxCtrl->fgBlockTxDuringJoin = FALSE;
  1096. #if !CFG_TX_AGGREGATE_HW_FIFO /* TX FIFO AGGREGATE already do flush once */
  1097. nicTxFlushStopQueues(prAdapter, (UINT_8) TXQ_DATA_MASK, (UINT_8) NULL);
  1098. #endif /* CFG_TX_AGGREGATE_HW_FIFO */
  1099. nicTxRetransmitOfSendWaitQue(prAdapter);
  1100. if (prTxCtrl->fgIsPacketInOsSendQueue)
  1101. nicTxRetransmitOfOsSendQue(prAdapter);
  1102. #if CFG_SDIO_TX_ENHANCE
  1103. halTxLeftClusteredMpdu(prAdapter);
  1104. #endif /* CFG_SDIO_TX_ENHANCE */
  1105. }
  1106. #endif /* CFG_TX_STOP_WRITE_TX_FIFO_UNTIL_JOIN */
  1107. /* 4 <6> Setup CONNECTION flag. */
  1108. prAdapter->eConnectionState = MEDIA_STATE_CONNECTED;
  1109. prAdapter->eConnectionStateIndicated = MEDIA_STATE_CONNECTED;
  1110. if (prJoinInfo->fgIsReAssoc)
  1111. prAdapter->fgBypassPortCtrlForRoaming = TRUE;
  1112. else
  1113. prAdapter->fgBypassPortCtrlForRoaming = FALSE;
  1114. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_CONNECT, (PVOID) NULL, 0);
  1115. } /* end of joinComplete() */
  1116. #endif