cnm.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/cnm.c#2
  3. */
  4. /*! \file "cnm.c"
  5. \brief Module of Concurrent Network Management
  6. Module of Concurrent Network Management
  7. */
  8. /*
  9. ** Log: cnm.c
  10. *
  11. * 07 17 2012 yuche.tsai
  12. * NULL
  13. * Compile no error before trial run.
  14. *
  15. * 11 15 2011 cm.chang
  16. * NULL
  17. * Fix possible wrong message when P2P is unregistered
  18. *
  19. * 11 14 2011 yuche.tsai
  20. * [WCXRP00001107] [Volunteer Patch][Driver] Large Network Type index assert in FW issue.
  21. * Fix large network type index assert in FW issue.
  22. *
  23. * 11 10 2011 cm.chang
  24. * NULL
  25. * Modify debug message for XLOG
  26. *
  27. * 11 08 2011 cm.chang
  28. * NULL
  29. * Add RLM and CNM debug message for XLOG
  30. *
  31. * 11 01 2011 cm.chang
  32. * [WCXRP00001077] [All Wi-Fi][Driver] Fix wrong preferred channel for AP and BOW
  33. * Only check AIS channel for P2P and BOW
  34. *
  35. * 10 25 2011 cm.chang
  36. * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
  37. * Extension channel of some 5G AP will not follow regulation requirement
  38. *
  39. * 09 30 2011 cm.chang
  40. * [WCXRP00001020] [MT6620 Wi-Fi][Driver] Handle secondary channel offset of AP in 5GHz band
  41. * .
  42. *
  43. * 09 01 2011 cm.chang
  44. * [WCXRP00000937] [MT6620 Wi-Fi][Driver][FW] cnm.c line #848 assert when doing monkey test
  45. * Print message only in Linux platform for monkey testing
  46. *
  47. * 06 23 2011 cp.wu
  48. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  49. * change parameter name from PeerAddr to BSSID
  50. *
  51. * 06 20 2011 cp.wu
  52. * [WCXRP00000798] [MT6620 Wi-Fi][Firmware] Follow-ups for WAPI frequency offset workaround in firmware SCN module
  53. * 1. specify target's BSSID when requesting channel privilege.
  54. * 2. pass BSSID information to firmware domain
  55. *
  56. * 06 01 2011 cm.chang
  57. * [WCXRP00000756] [MT6620 Wi-Fi][Driver] 1. AIS follow channel of BOW 2. Provide legal channel function
  58. * Limit AIS to fixed channel same with BOW
  59. *
  60. * 04 12 2011 cm.chang
  61. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  62. * .
  63. *
  64. * 03 10 2011 cm.chang
  65. * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
  66. * Check if P2P network index is Tethering AP
  67. *
  68. * 03 10 2011 cm.chang
  69. * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
  70. * Add some functions to let AIS/Tethering or AIS/BOW be the same channel
  71. *
  72. * 02 17 2011 cm.chang
  73. * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
  74. * When P2P registried, invoke BOW deactivate function
  75. *
  76. * 01 12 2011 cm.chang
  77. * [WCXRP00000358] [MT6620 Wi-Fi][Driver] Provide concurrent information for each module
  78. * Provide function to decide if BSS can be activated or not
  79. *
  80. * 12 07 2010 cm.chang
  81. * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
  82. * 1. BSSINFO include RLM parameter
  83. * 2. free all sta records when network is disconnected
  84. *
  85. * 12 07 2010 cm.chang
  86. * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
  87. * 1. Country code is from NVRAM or supplicant
  88. * 2. Change band definition in CMD/EVENT.
  89. *
  90. * 11 08 2010 cm.chang
  91. * [WCXRP00000169] [MT6620 Wi-Fi][Driver][FW] Remove unused CNM recover message ID
  92. * Remove CNM channel reover message ID
  93. *
  94. * 10 13 2010 cm.chang
  95. * [WCXRP00000094] [MT6620 Wi-Fi][Driver] Connect to 2.4GHz AP, Driver crash.
  96. * Add exception handle when cmd buffer is not available
  97. *
  98. * 08 24 2010 cm.chang
  99. * NULL
  100. * Support RLM initail channel of Ad-hoc, P2P and BOW
  101. *
  102. * 07 19 2010 wh.su
  103. *
  104. * update for security supporting.
  105. *
  106. * 07 19 2010 cm.chang
  107. *
  108. * Set RLM parameters and enable CNM channel manager
  109. *
  110. * 07 08 2010 cp.wu
  111. *
  112. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  113. *
  114. * 07 08 2010 cm.chang
  115. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  116. * Rename MID_MNY_CNM_CH_RELEASE to MID_MNY_CNM_CH_ABORT
  117. *
  118. * 07 01 2010 cm.chang
  119. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  120. * Fix wrong message ID for channel grant to requester
  121. *
  122. * 07 01 2010 cm.chang
  123. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  124. * Modify CNM message handler for new flow
  125. *
  126. * 06 07 2010 cm.chang
  127. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  128. * Set 20/40M bandwidth of AP HT OP before association process
  129. *
  130. * 05 31 2010 yarco.yang
  131. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  132. * Add RX TSF Log Feature and ADDBA Rsp with DECLINE handling
  133. *
  134. * 05 21 2010 yarco.yang
  135. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  136. * Support TCP/UDP/IP Checksum offload feature
  137. *
  138. * 05 12 2010 kevin.huang
  139. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  140. * Add Power Management - Legacy PS-POLL support.
  141. *
  142. * 05 05 2010 cm.chang
  143. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  144. * Add a new function to send abort message
  145. *
  146. * 04 27 2010 cm.chang
  147. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  148. * BMC mac address shall be ignored in basic config command
  149. *
  150. * 04 24 2010 cm.chang
  151. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  152. * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
  153. *
  154. * 04 22 2010 cm.chang
  155. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  156. * Support change of MAC address by host command
  157. *
  158. * 04 16 2010 wh.su
  159. * [BORA00000680][MT6620] Support the statistic for Micxxsoft os query
  160. * adding the wpa-none for ibss beacon.
  161. *
  162. * 04 07 2010 cm.chang
  163. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  164. * Fix bug for OBSS scan
  165. *
  166. * 03 30 2010 cm.chang
  167. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  168. * Support 2.4G OBSS scan
  169. *
  170. * 03 16 2010 kevin.huang
  171. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  172. * Add AdHoc Mode
  173. *
  174. * 03 10 2010 kevin.huang
  175. * [BORA00000654][WIFISYS][New Feature] CNM Module - Ch Manager Support
  176. *
  177. * * * * * * * * * * Add Channel Manager for arbitration of JOIN and SCAN Req
  178. *
  179. * 02 25 2010 wh.su
  180. * [BORA00000605][WIFISYS] Phase3 Integration
  181. * use the Rx0 dor event indicate.
  182. *
  183. * 02 08 2010 cm.chang
  184. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  185. * Support partial part about cmd basic configuration
  186. *
  187. * Dec 10 2009 mtk01104
  188. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  189. * Remove conditional compiling FPGA_V5
  190. *
  191. * Nov 18 2009 mtk01104
  192. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  193. * Add function cnmFsmEventInit()
  194. *
  195. * Nov 2 2009 mtk01104
  196. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  197. *
  198. **
  199. */
  200. /*******************************************************************************
  201. * C O M P I L E R F L A G S
  202. ********************************************************************************
  203. */
  204. /*******************************************************************************
  205. * E X T E R N A L R E F E R E N C E S
  206. ********************************************************************************
  207. */
  208. #include "precomp.h"
  209. /*******************************************************************************
  210. * C O N S T A N T S
  211. ********************************************************************************
  212. */
  213. /*******************************************************************************
  214. * D A T A T Y P E S
  215. ********************************************************************************
  216. */
  217. /*******************************************************************************
  218. * P U B L I C D A T A
  219. ********************************************************************************
  220. */
  221. /*******************************************************************************
  222. * P R I V A T E D A T A
  223. ********************************************************************************
  224. */
  225. /*******************************************************************************
  226. * M A C R O S
  227. ********************************************************************************
  228. */
  229. /*******************************************************************************
  230. * F U N C T I O N D E C L A R A T I O N S
  231. ********************************************************************************
  232. */
  233. /*******************************************************************************
  234. * F U N C T I O N S
  235. ********************************************************************************
  236. */
  237. /*----------------------------------------------------------------------------*/
  238. /*!
  239. * @brief This function is used to initialize variables in CNM_INFO_T.
  240. *
  241. * @param (none)
  242. *
  243. * @return (none)
  244. */
  245. /*----------------------------------------------------------------------------*/
  246. VOID cnmInit(P_ADAPTER_T prAdapter)
  247. {
  248. } /* end of cnmInit() */
  249. /*----------------------------------------------------------------------------*/
  250. /*!
  251. * @brief This function is used to initialize variables in CNM_INFO_T.
  252. *
  253. * @param (none)
  254. *
  255. * @return (none)
  256. */
  257. /*----------------------------------------------------------------------------*/
  258. VOID cnmUninit(P_ADAPTER_T prAdapter)
  259. {
  260. } /* end of cnmUninit() */
  261. /*----------------------------------------------------------------------------*/
  262. /*!
  263. * @brief Before handle the message from other module, it need to obtain
  264. * the Channel privilege from Channel Manager
  265. *
  266. * @param[in] prMsgHdr The message need to be handled.
  267. *
  268. * @return (none)
  269. */
  270. /*----------------------------------------------------------------------------*/
  271. VOID cnmChMngrRequestPrivilege(P_ADAPTER_T prAdapter, P_MSG_HDR_T prMsgHdr)
  272. {
  273. P_MSG_CH_REQ_T prMsgChReq;
  274. P_CMD_CH_PRIVILEGE_T prCmdBody;
  275. WLAN_STATUS rStatus;
  276. ASSERT(prAdapter);
  277. ASSERT(prMsgHdr);
  278. prMsgChReq = (P_MSG_CH_REQ_T) prMsgHdr;
  279. prCmdBody = (P_CMD_CH_PRIVILEGE_T)
  280. cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_CH_PRIVILEGE_T));
  281. ASSERT(prCmdBody);
  282. /* To do: exception handle */
  283. if (!prCmdBody) {
  284. DBGLOG(CNM, ERROR, "ChReq: fail to get buf (net=%d, token=%d)\n",
  285. prMsgChReq->ucNetTypeIndex, prMsgChReq->ucTokenID);
  286. cnmMemFree(prAdapter, prMsgHdr);
  287. return;
  288. }
  289. DBGLOG(CNM, INFO, "ChReq net=%d token=%d b=%d c=%d s=%d\n",
  290. prMsgChReq->ucNetTypeIndex, prMsgChReq->ucTokenID,
  291. prMsgChReq->eRfBand, prMsgChReq->ucPrimaryChannel, prMsgChReq->eRfSco);
  292. prCmdBody->ucNetTypeIndex = prMsgChReq->ucNetTypeIndex;
  293. prCmdBody->ucTokenID = prMsgChReq->ucTokenID;
  294. prCmdBody->ucAction = CMD_CH_ACTION_REQ; /* Request */
  295. prCmdBody->ucPrimaryChannel = prMsgChReq->ucPrimaryChannel;
  296. prCmdBody->ucRfSco = (UINT_8) prMsgChReq->eRfSco;
  297. prCmdBody->ucRfBand = (UINT_8) prMsgChReq->eRfBand;
  298. prCmdBody->ucReqType = (UINT_8) prMsgChReq->eReqType;
  299. prCmdBody->ucReserved = 0;
  300. prCmdBody->u4MaxInterval = prMsgChReq->u4MaxInterval;
  301. COPY_MAC_ADDR(prCmdBody->aucBSSID, prMsgChReq->aucBSSID);
  302. ASSERT(prCmdBody->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  303. /* For monkey testing 20110901 */
  304. if (prCmdBody->ucNetTypeIndex >= NETWORK_TYPE_INDEX_NUM)
  305. DBGLOG(CNM, ERROR, "CNM: ChReq with wrong netIdx=%d\n\n", prCmdBody->ucNetTypeIndex);
  306. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  307. CMD_ID_CH_PRIVILEGE, /* ucCID */
  308. TRUE, /* fgSetQuery */
  309. FALSE, /* fgNeedResp */
  310. FALSE, /* fgIsOid */
  311. NULL, /* pfCmdDoneHandler */
  312. NULL, /* pfCmdTimeoutHandler */
  313. sizeof(CMD_CH_PRIVILEGE_T), /* u4SetQueryInfoLen */
  314. (PUINT_8) prCmdBody, /* pucInfoBuffer */
  315. NULL, /* pvSetQueryBuffer */
  316. 0 /* u4SetQueryBufferLen */
  317. );
  318. ASSERT(rStatus == WLAN_STATUS_PENDING);
  319. cnmMemFree(prAdapter, prCmdBody);
  320. cnmMemFree(prAdapter, prMsgHdr);
  321. } /* end of cnmChMngrRequestPrivilege() */
  322. /*----------------------------------------------------------------------------*/
  323. /*!
  324. * @brief Before deliver the message to other module, it need to release
  325. * the Channel privilege to Channel Manager.
  326. *
  327. * @param[in] prMsgHdr The message need to be delivered
  328. *
  329. * @return (none)
  330. */
  331. /*----------------------------------------------------------------------------*/
  332. VOID cnmChMngrAbortPrivilege(P_ADAPTER_T prAdapter, P_MSG_HDR_T prMsgHdr)
  333. {
  334. P_MSG_CH_ABORT_T prMsgChAbort;
  335. P_CMD_CH_PRIVILEGE_T prCmdBody;
  336. WLAN_STATUS rStatus;
  337. ASSERT(prAdapter);
  338. ASSERT(prMsgHdr);
  339. prMsgChAbort = (P_MSG_CH_ABORT_T) prMsgHdr;
  340. prCmdBody = (P_CMD_CH_PRIVILEGE_T)
  341. cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_CH_PRIVILEGE_T));
  342. ASSERT(prCmdBody);
  343. /* To do: exception handle */
  344. if (!prCmdBody) {
  345. DBGLOG(CNM, ERROR, "ChAbort: fail to get buf (net=%d, token=%d)\n",
  346. prMsgChAbort->ucNetTypeIndex, prMsgChAbort->ucTokenID);
  347. cnmMemFree(prAdapter, prMsgHdr);
  348. return;
  349. }
  350. DBGLOG(CNM, INFO, "ChAbort net=%d token=%d\n", prMsgChAbort->ucNetTypeIndex, prMsgChAbort->ucTokenID);
  351. prCmdBody->ucNetTypeIndex = prMsgChAbort->ucNetTypeIndex;
  352. prCmdBody->ucTokenID = prMsgChAbort->ucTokenID;
  353. prCmdBody->ucAction = CMD_CH_ACTION_ABORT; /* Abort */
  354. ASSERT(prCmdBody->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  355. /* For monkey testing 20110901 */
  356. if (prCmdBody->ucNetTypeIndex >= NETWORK_TYPE_INDEX_NUM)
  357. DBGLOG(CNM, ERROR, "CNM: ChAbort with wrong netIdx=%d\n\n", prCmdBody->ucNetTypeIndex);
  358. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  359. CMD_ID_CH_PRIVILEGE, /* ucCID */
  360. TRUE, /* fgSetQuery */
  361. FALSE, /* fgNeedResp */
  362. FALSE, /* fgIsOid */
  363. NULL, /* pfCmdDoneHandler */
  364. NULL, /* pfCmdTimeoutHandler */
  365. sizeof(CMD_CH_PRIVILEGE_T), /* u4SetQueryInfoLen */
  366. (PUINT_8) prCmdBody, /* pucInfoBuffer */
  367. NULL, /* pvSetQueryBuffer */
  368. 0 /* u4SetQueryBufferLen */
  369. );
  370. ASSERT(rStatus == WLAN_STATUS_PENDING);
  371. cnmMemFree(prAdapter, prCmdBody);
  372. cnmMemFree(prAdapter, prMsgHdr);
  373. } /* end of cnmChMngrAbortPrivilege() */
  374. /*----------------------------------------------------------------------------*/
  375. /*!
  376. * @brief
  377. *
  378. * @param (none)
  379. *
  380. * @return (none)
  381. */
  382. /*----------------------------------------------------------------------------*/
  383. VOID cnmChMngrHandleChEvent(P_ADAPTER_T prAdapter, P_WIFI_EVENT_T prEvent)
  384. {
  385. P_EVENT_CH_PRIVILEGE_T prEventBody;
  386. P_MSG_CH_GRANT_T prChResp;
  387. ASSERT(prAdapter);
  388. ASSERT(prEvent);
  389. prEventBody = (P_EVENT_CH_PRIVILEGE_T) (prEvent->aucBuffer);
  390. prChResp = (P_MSG_CH_GRANT_T)
  391. cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_CH_GRANT_T));
  392. ASSERT(prChResp);
  393. /* To do: exception handle */
  394. if (!prChResp) {
  395. DBGLOG(CNM, ERROR, "ChGrant: fail to get buf (net=%d, token=%d)\n",
  396. prEventBody->ucNetTypeIndex, prEventBody->ucTokenID);
  397. return;
  398. }
  399. DBGLOG(CNM, INFO, "ChGrant net=%d token=%d ch=%d sco=%d\n",
  400. prEventBody->ucNetTypeIndex, prEventBody->ucTokenID,
  401. prEventBody->ucPrimaryChannel, prEventBody->ucRfSco);
  402. ASSERT(prEventBody->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  403. ASSERT(prEventBody->ucStatus == EVENT_CH_STATUS_GRANT);
  404. /* Decide message ID based on network and response status */
  405. if (prEventBody->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX)
  406. prChResp->rMsgHdr.eMsgId = MID_CNM_AIS_CH_GRANT;
  407. #if CFG_ENABLE_WIFI_DIRECT
  408. else if ((prAdapter->fgIsP2PRegistered) && (prEventBody->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX))
  409. prChResp->rMsgHdr.eMsgId = MID_CNM_P2P_CH_GRANT;
  410. #endif
  411. #if CFG_ENABLE_BT_OVER_WIFI
  412. else if (prEventBody->ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX)
  413. prChResp->rMsgHdr.eMsgId = MID_CNM_BOW_CH_GRANT;
  414. #endif
  415. else {
  416. cnmMemFree(prAdapter, prChResp);
  417. return;
  418. }
  419. prChResp->ucNetTypeIndex = prEventBody->ucNetTypeIndex;
  420. prChResp->ucTokenID = prEventBody->ucTokenID;
  421. prChResp->ucPrimaryChannel = prEventBody->ucPrimaryChannel;
  422. prChResp->eRfSco = (ENUM_CHNL_EXT_T) prEventBody->ucRfSco;
  423. prChResp->eRfBand = (ENUM_BAND_T) prEventBody->ucRfBand;
  424. prChResp->eReqType = (ENUM_CH_REQ_TYPE_T) prEventBody->ucReqType;
  425. prChResp->u4GrantInterval = prEventBody->u4GrantInterval;
  426. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prChResp, MSG_SEND_METHOD_BUF);
  427. }
  428. /*----------------------------------------------------------------------------*/
  429. /*!
  430. * @brief This function is invoked for P2P or BOW networks
  431. *
  432. * @param (none)
  433. *
  434. * @return TRUE: suggest to adopt the returned preferred channel
  435. * FALSE: No suggestion. Caller should adopt its preference
  436. */
  437. /*----------------------------------------------------------------------------*/
  438. BOOLEAN
  439. cnmPreferredChannel(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel, P_ENUM_CHNL_EXT_T prBssSCO)
  440. {
  441. P_BSS_INFO_T prBssInfo;
  442. ASSERT(prAdapter);
  443. ASSERT(prBand);
  444. ASSERT(pucPrimaryChannel);
  445. ASSERT(prBssSCO);
  446. prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  447. if (RLM_NET_PARAM_VALID(prBssInfo)) {
  448. *prBand = prBssInfo->eBand;
  449. *pucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  450. *prBssSCO = prBssInfo->eBssSCO;
  451. return TRUE;
  452. }
  453. return FALSE;
  454. }
  455. /*----------------------------------------------------------------------------*/
  456. /*!
  457. * @brief
  458. *
  459. * @param (none)
  460. *
  461. * @return TRUE: available channel is limited to return value
  462. * FALSE: no limited
  463. */
  464. /*----------------------------------------------------------------------------*/
  465. BOOLEAN cnmAisInfraChannelFixed(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel)
  466. {
  467. #if CFG_ENABLE_WIFI_DIRECT || (CFG_ENABLE_BT_OVER_WIFI && CFG_BOW_LIMIT_AIS_CHNL)
  468. P_BSS_INFO_T prBssInfo;
  469. #endif
  470. #if CFG_ENABLE_WIFI_DIRECT
  471. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX) && p2pFuncIsAPMode(prAdapter->rWifiVar.prP2pFsmInfo)) {
  472. ASSERT(prAdapter->fgIsP2PRegistered);
  473. prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_P2P_INDEX];
  474. *prBand = prBssInfo->eBand;
  475. *pucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  476. return TRUE;
  477. }
  478. #endif
  479. #if CFG_ENABLE_BT_OVER_WIFI && CFG_BOW_LIMIT_AIS_CHNL
  480. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_BOW_INDEX)) {
  481. prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX];
  482. *prBand = prBssInfo->eBand;
  483. *pucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  484. return TRUE;
  485. }
  486. #endif
  487. return FALSE;
  488. }
  489. #if CFG_P2P_LEGACY_COEX_REVISE
  490. BOOLEAN cnmAisDetectP2PChannel(P_ADAPTER_T prAdapter, P_ENUM_BAND_T prBand, PUINT_8 pucPrimaryChannel)
  491. {
  492. P_WIFI_VAR_T prWifiVar = &prAdapter->rWifiVar;
  493. P_BSS_INFO_T prP2PBssInfo = &prWifiVar->arBssInfo[NETWORK_TYPE_P2P_INDEX];
  494. #if CFG_ENABLE_WIFI_DIRECT
  495. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX) &&
  496. (prP2PBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED ||
  497. (prP2PBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT && prP2PBssInfo->eIntendOPMode == OP_MODE_NUM))) {
  498. *prBand = prP2PBssInfo->eBand;
  499. *pucPrimaryChannel = prP2PBssInfo->ucPrimaryChannel;
  500. #if CFG_SUPPORT_MCC
  501. if (nicFreq2ChannelNum(prWifiVar->rConnSettings.u4FreqInKHz * 1000) != *pucPrimaryChannel) {
  502. DBGLOG(CNM, INFO, "p2p is running on Channel %d, but supplicant try to run as MCC\n",
  503. *pucPrimaryChannel);
  504. return FALSE;
  505. }
  506. #endif
  507. DBGLOG(CNM, INFO, "p2p is running on Channel %d, supplicant try to run as SCC\n",
  508. *pucPrimaryChannel);
  509. return TRUE;
  510. }
  511. #endif
  512. return FALSE;
  513. }
  514. #endif
  515. /*----------------------------------------------------------------------------*/
  516. /*!
  517. * @brief
  518. *
  519. * @param (none)
  520. *
  521. * @return (none)
  522. */
  523. /*----------------------------------------------------------------------------*/
  524. VOID cnmAisInfraConnectNotify(P_ADAPTER_T prAdapter)
  525. {
  526. #if CFG_ENABLE_BT_OVER_WIFI
  527. P_BSS_INFO_T prAisBssInfo, prBowBssInfo;
  528. prAisBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  529. prBowBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_BOW_INDEX];
  530. if (RLM_NET_PARAM_VALID(prAisBssInfo) && RLM_NET_PARAM_VALID(prBowBssInfo)) {
  531. if (prAisBssInfo->eBand != prBowBssInfo->eBand ||
  532. prAisBssInfo->ucPrimaryChannel != prBowBssInfo->ucPrimaryChannel) {
  533. /* Notify BOW to do deactivation */
  534. bowNotifyAllLinkDisconnected(prAdapter);
  535. }
  536. }
  537. #endif
  538. }
  539. /*----------------------------------------------------------------------------*/
  540. /*!
  541. * @brief
  542. *
  543. * @param (none)
  544. *
  545. * @return TRUE: permitted
  546. * FALSE: Not permitted
  547. */
  548. /*----------------------------------------------------------------------------*/
  549. BOOLEAN cnmAisIbssIsPermitted(P_ADAPTER_T prAdapter)
  550. {
  551. #if CFG_ENABLE_WIFI_DIRECT
  552. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX))
  553. return FALSE;
  554. #endif
  555. #if CFG_ENABLE_BT_OVER_WIFI
  556. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_BOW_INDEX))
  557. return FALSE;
  558. #endif
  559. return TRUE;
  560. }
  561. /*----------------------------------------------------------------------------*/
  562. /*!
  563. * @brief
  564. *
  565. * @param (none)
  566. *
  567. * @return TRUE: permitted
  568. * FALSE: Not permitted
  569. */
  570. /*----------------------------------------------------------------------------*/
  571. BOOLEAN cnmP2PIsPermitted(P_ADAPTER_T prAdapter)
  572. {
  573. P_BSS_INFO_T prBssInfo;
  574. prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  575. if (IS_BSS_ACTIVE(prBssInfo) && prBssInfo->eCurrentOPMode == OP_MODE_IBSS)
  576. return FALSE;
  577. #if CFG_ENABLE_BT_OVER_WIFI
  578. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_BOW_INDEX)) {
  579. /* Notify BOW to do deactivation */
  580. bowNotifyAllLinkDisconnected(prAdapter);
  581. }
  582. #endif
  583. return TRUE;
  584. }
  585. /*----------------------------------------------------------------------------*/
  586. /*!
  587. * @brief
  588. *
  589. * @param (none)
  590. *
  591. * @return TRUE: permitted
  592. * FALSE: Not permitted
  593. */
  594. /*----------------------------------------------------------------------------*/
  595. BOOLEAN cnmBowIsPermitted(P_ADAPTER_T prAdapter)
  596. {
  597. P_BSS_INFO_T prBssInfo;
  598. prBssInfo = &prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX];
  599. if (IS_BSS_ACTIVE(prBssInfo) && prBssInfo->eCurrentOPMode == OP_MODE_IBSS)
  600. return FALSE;
  601. #if CFG_ENABLE_WIFI_DIRECT
  602. if (IS_NET_ACTIVE(prAdapter, NETWORK_TYPE_P2P_INDEX))
  603. return FALSE;
  604. #endif
  605. return TRUE;
  606. }
  607. /*----------------------------------------------------------------------------*/
  608. /*!
  609. * @brief
  610. *
  611. * @param (none)
  612. *
  613. * @return TRUE: permitted
  614. * FALSE: Not permitted
  615. */
  616. /*----------------------------------------------------------------------------*/
  617. BOOLEAN cnmBss40mBwPermitted(P_ADAPTER_T prAdapter, ENUM_NETWORK_TYPE_INDEX_T eNetTypeIdx)
  618. {
  619. P_BSS_INFO_T prBssInfo;
  620. UINT_8 i;
  621. P_BSS_DESC_T prBssDesc = NULL;
  622. /* Note: To support real-time decision instead of current activated-time,
  623. * the STA roaming case shall be considered about synchronization
  624. * problem. Another variable fgAssoc40mBwAllowed is added to
  625. * represent HT capability when association
  626. */
  627. for (i = 0; i < NETWORK_TYPE_INDEX_NUM; i++) {
  628. if (i != (UINT_8) eNetTypeIdx) {
  629. prBssInfo = &prAdapter->rWifiVar.arBssInfo[i];
  630. if (IS_BSS_ACTIVE(prBssInfo) && (prBssInfo->fg40mBwAllowed || prBssInfo->fgAssoc40mBwAllowed))
  631. return FALSE;
  632. }
  633. }
  634. if (eNetTypeIdx == NETWORK_TYPE_AIS_INDEX)
  635. prBssDesc = prAdapter->rWifiVar.rAisFsmInfo.prTargetBssDesc;
  636. else if ((eNetTypeIdx == NETWORK_TYPE_P2P_INDEX) && (prAdapter->rWifiVar.prP2pFsmInfo))
  637. prBssDesc = prAdapter->rWifiVar.prP2pFsmInfo->prTargetBss;
  638. if (prBssDesc) {
  639. #if (CFG_FORCE_USE_20BW == 1)
  640. if (prBssDesc->eBand == BAND_2G4)
  641. return FALSE;
  642. #endif
  643. if (prBssDesc->eSco == CHNL_EXT_SCN)
  644. return FALSE;
  645. }
  646. return TRUE;
  647. }