rlm.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/rlm.c#2
  3. */
  4. /*! \file "rlm.c"
  5. \brief
  6. */
  7. /*
  8. ** Log: rlm.c
  9. *
  10. * 07 17 2012 yuche.tsai
  11. * NULL
  12. * Compile no error before trial run.
  13. *
  14. * 11 15 2011 cm.chang
  15. * NULL
  16. * Check length HT cap IE about RX associate request frame
  17. *
  18. * 11 10 2011 cm.chang
  19. * NULL
  20. * Modify debug message for XLOG
  21. *
  22. * 11 08 2011 cm.chang
  23. * NULL
  24. * Add RLM and CNM debug message for XLOG
  25. *
  26. * 11 03 2011 cm.chang
  27. * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
  28. * Fix preamble type of STA mode
  29. *
  30. * 10 25 2011 cm.chang
  31. * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
  32. * Not send ERP IE if peer STA is 802.11b-only
  33. *
  34. * 10 11 2011 cm.chang
  35. * [WCXRP00001031] [All Wi-Fi][Driver] Check HT IE length to avoid wrong SCO parameter
  36. * Ignore HT OP IE if its length field is not valid
  37. *
  38. * 09 28 2011 cm.chang
  39. * NULL
  40. * Add length check to reduce possibility to adopt wrong IE
  41. *
  42. * 09 20 2011 cm.chang
  43. * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
  44. * Handle client mode about preamble type and slot time
  45. *
  46. * 09 01 2011 cm.chang
  47. * [WCXRP00000971] [MT6620 Wi-Fi][Driver][FW] Not set Beacon timeout interval when CPTT
  48. * Final channel number only adopts the field from assoc response
  49. *
  50. * 06 10 2011 cm.chang
  51. * [WCXRP00000773] [MT6620 Wi-Fi][Driver] Workaround some AP fill primary channel field with its secondary channel
  52. * If DS IE exists, ignore the primary channel field in HT OP IE
  53. *
  54. * 05 03 2011 cm.chang
  55. * [WCXRP00000691] [MT6620 Wi-Fi][Driver] Workaround about AP's wrong HT capability IE to have wrong channel number
  56. * Fix compiling error
  57. *
  58. * 05 02 2011 cm.chang
  59. * [WCXRP00000691] [MT6620 Wi-Fi][Driver] Workaround about AP's wrong HT capability IE to have wrong channel number
  60. * Refine range of valid channel number
  61. *
  62. * 05 02 2011 cm.chang
  63. * [WCXRP00000691] [MT6620 Wi-Fi][Driver] Workaround about AP's wrong HT capability IE to have wrong channel number
  64. * Check if channel is valided before record ing BSS channel
  65. *
  66. * 04 14 2011 cm.chang
  67. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  68. * .
  69. *
  70. * 04 12 2011 cm.chang
  71. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  72. * .
  73. *
  74. * 03 29 2011 cm.chang
  75. * [WCXRP00000606] [MT6620 Wi-Fi][Driver][FW] Fix klocwork warning
  76. * As CR title
  77. *
  78. * 01 24 2011 cm.chang
  79. * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode
  80. * and stop ampdu timer when sta_rec is freed
  81. * Process received 20/40 coexistence action frame for AP mode
  82. *
  83. * 12 13 2010 cp.wu
  84. * [WCXRP00000260] [MT6620 Wi-Fi][Driver][Firmware] Create V1.1 branch for both firmware and driver
  85. * create branch for Wi-Fi driver v1.1
  86. *
  87. * 12 07 2010 cm.chang
  88. * [WCXRP00000239] MT6620 Wi-Fi][Driver][FW] Merge concurrent branch back to maintrunk
  89. * 1. BSSINFO include RLM parameter
  90. * 2. free all sta records when network is disconnected
  91. *
  92. * 12 07 2010 cm.chang
  93. * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
  94. * 1. Country code is from NVRAM or supplicant
  95. * 2. Change band definition in CMD/EVENT.
  96. *
  97. * 10 15 2010 cm.chang
  98. * [WCXRP00000094] [MT6620 Wi-Fi][Driver] Connect to 2.4GHz AP, Driver crash.
  99. * Add exception handle when no mgmt buffer in free build
  100. *
  101. * 10 08 2010 cm.chang
  102. * NULL
  103. * When 20M only setting, ignore OBSS IE
  104. *
  105. * 09 16 2010 cm.chang
  106. * NULL
  107. * Change conditional compiling options for BOW
  108. *
  109. * 09 10 2010 cm.chang
  110. * NULL
  111. * Always update Beacon content if FW sync OBSS info
  112. *
  113. * 09 03 2010 kevin.huang
  114. * NULL
  115. * Refine #include sequence and solve recursive/nested #include issue
  116. *
  117. * 08 24 2010 cm.chang
  118. * NULL
  119. * Support RLM initail channel of Ad-hoc, P2P and BOW
  120. *
  121. * 08 23 2010 cp.wu
  122. * NULL
  123. * revise constant definitions to be matched with implementation (original cmd-event definition is deprecated)
  124. *
  125. * 08 23 2010 chinghwa.yu
  126. * NULL
  127. * Temporary add rlmUpdateParamByStaForBow() and rlmBssInitForBow().
  128. *
  129. * 08 23 2010 chinghwa.yu
  130. * NULL
  131. * Add CFG_ENABLE_BT_OVER_WIFI.
  132. *
  133. * 08 23 2010 chinghwa.yu
  134. * NULL
  135. * Update for BOW.
  136. *
  137. * 08 20 2010 cm.chang
  138. * NULL
  139. * Migrate RLM code to host from FW
  140. *
  141. * 08 02 2010 yuche.tsai
  142. * NULL
  143. * P2P Group Negotiation Code Check in.
  144. *
  145. * 07 26 2010 yuche.tsai
  146. *
  147. * Fix compile error while enabling WiFi Direct function.
  148. *
  149. * 07 21 2010 yuche.tsai
  150. *
  151. * Add P2P Scan & Scan Result Parsing & Saving.
  152. *
  153. * 07 19 2010 cm.chang
  154. *
  155. * Set RLM parameters and enable CNM channel manager
  156. *
  157. * 07 08 2010 cp.wu
  158. *
  159. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  160. *
  161. * 07 08 2010 cp.wu
  162. * [WPD00003833][MT6620 and MT5931] Driver migration
  163. * take use of RLM module for parsing/generating HT IEs for 11n capability
  164. *
  165. * 07 08 2010 cm.chang
  166. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  167. * Check draft RLM code for HT cap
  168. *
  169. * 06 05 2010 cm.chang
  170. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  171. * Fix channel ID definition in RFB status to primary channel instead of center channel
  172. *
  173. * 06 02 2010 cm.chang
  174. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  175. * Add TX short GI compiling option
  176. *
  177. * 06 02 2010 chinghwa.yu
  178. * [BORA00000563]Add WiFi CoEx BCM module
  179. * Roll back to remove CFG_SUPPORT_BCM_TEST.
  180. *
  181. * 06 01 2010 chinghwa.yu
  182. * [BORA00000563]Add WiFi CoEx BCM module
  183. * Update BCM Test and RW configuration.
  184. *
  185. * 05 31 2010 cm.chang
  186. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  187. * Add some compiling options to control 11n functions
  188. *
  189. * 05 28 2010 cm.chang
  190. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  191. * Set RTS threshold of 2K bytes initially
  192. *
  193. * 05 18 2010 cm.chang
  194. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  195. * Ad-hoc Beacon should not carry HT OP and OBSS IEs
  196. *
  197. * 05 07 2010 cm.chang
  198. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  199. * Process 20/40 coexistence public action frame in AP mode
  200. *
  201. * 05 05 2010 cm.chang
  202. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  203. * First draft support for 20/40M bandwidth for AP mode
  204. *
  205. * 04 24 2010 cm.chang
  206. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  207. * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
  208. *
  209. * 04 22 2010 cm.chang
  210. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  211. * First draft code to support protection in AP mode
  212. *
  213. * 04 13 2010 cm.chang
  214. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  215. * Utilize status of swRfb to know channel number and band
  216. *
  217. * 04 07 2010 cm.chang
  218. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  219. * Different invoking order for WTBL entry of associated AP
  220. *
  221. * 04 07 2010 cm.chang
  222. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  223. * Add virtual test for OBSS scan
  224. *
  225. * 04 02 2010 cm.chang
  226. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  227. * Process Beacon only ready for infra STA now
  228. *
  229. * 03 30 2010 cm.chang
  230. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  231. * Support 2.4G OBSS scan
  232. *
  233. * 03 24 2010 cm.chang
  234. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  235. * Not carry HT cap when being associated with b/g only AP
  236. *
  237. * 03 24 2010 wh.su
  238. * [BORA00000605][WIFISYS] Phase3 Integration
  239. * fixed some WHQL testing error.
  240. *
  241. * 03 15 2010 cm.chang
  242. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  243. * Provide draft measurement and quiet functions
  244. *
  245. * 03 09 2010 cm.chang
  246. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  247. * If bss is not 11n network, zero WTBL HT parameters
  248. *
  249. * 03 03 2010 cm.chang
  250. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  251. * To support CFG_SUPPORT_BCM_STP
  252. *
  253. * 03 02 2010 cm.chang
  254. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  255. * Generate HT IE only depending on own phyTypeSet
  256. *
  257. * 03 02 2010 cm.chang
  258. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  259. * Not fill HT related IE if BssInfo does not include 11n phySet
  260. *
  261. * 03 01 2010 tehuang.liu
  262. * [BORA00000569][WIFISYS] Phase 2 Integration Test
  263. * To store field AMPDU Parameters in STA_REC
  264. *
  265. * 02 26 2010 cm.chang
  266. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  267. * Enable RDG RX, but disable RDG TX for IOT and LongNAV
  268. *
  269. * 02 12 2010 cm.chang
  270. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  271. * Use bss info array for concurrent handle
  272. *
  273. * 02 05 2010 kevin.huang
  274. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  275. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  276. *
  277. * 01 22 2010 cm.chang
  278. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  279. * Support protection and bandwidth switch
  280. *
  281. * 01 07 2010 kevin.huang
  282. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  283. * Modify the parameter of rlmRecAssocRspHtInfo function
  284. *
  285. * 12 18 2009 cm.chang
  286. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  287. * .
  288. *
  289. * Dec 12 2009 mtk01104
  290. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  291. * Fix prBssInfo->ucPrimaryChannel handle for assoc resp
  292. *
  293. * Dec 9 2009 mtk01104
  294. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  295. * Add some function to process HT operation
  296. *
  297. * Nov 28 2009 mtk01104
  298. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  299. * Call rlmStatisticsInit() to handle MIB counters
  300. *
  301. * Nov 18 2009 mtk01104
  302. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  303. *
  304. *
  305. **
  306. */
  307. /*******************************************************************************
  308. * C O M P I L E R F L A G S
  309. ********************************************************************************
  310. */
  311. /*******************************************************************************
  312. * E X T E R N A L R E F E R E N C E S
  313. ********************************************************************************
  314. */
  315. #include "precomp.h"
  316. /*******************************************************************************
  317. * C O N S T A N T S
  318. ********************************************************************************
  319. */
  320. /*******************************************************************************
  321. * D A T A T Y P E S
  322. ********************************************************************************
  323. */
  324. /*******************************************************************************
  325. * P U B L I C D A T A
  326. ********************************************************************************
  327. */
  328. /*******************************************************************************
  329. * P R I V A T E D A T A
  330. ********************************************************************************
  331. */
  332. /*******************************************************************************
  333. * M A C R O S
  334. ********************************************************************************
  335. */
  336. /*******************************************************************************
  337. * F U N C T I O N D E C L A R A T I O N S
  338. ********************************************************************************
  339. */
  340. static VOID rlmFillHtCapIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo);
  341. static VOID rlmFillExtCapIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo);
  342. static VOID rlmFillHtOpIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo);
  343. static UINT_8 rlmRecIeInfoForClient(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, PUINT_8 pucIE, UINT_16 u2IELength);
  344. static BOOLEAN
  345. rlmRecBcnFromNeighborForClient(P_ADAPTER_T prAdapter,
  346. P_BSS_INFO_T prBssInfo, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength);
  347. static BOOLEAN
  348. rlmRecBcnInfoForClient(P_ADAPTER_T prAdapter,
  349. P_BSS_INFO_T prBssInfo, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength);
  350. static VOID rlmBssReset(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo);
  351. /*******************************************************************************
  352. * F U N C T I O N S
  353. ********************************************************************************
  354. */
  355. /*----------------------------------------------------------------------------*/
  356. /*!
  357. * \brief
  358. *
  359. * \param[in]
  360. *
  361. * \return none
  362. */
  363. /*----------------------------------------------------------------------------*/
  364. VOID rlmFsmEventInit(P_ADAPTER_T prAdapter)
  365. {
  366. ASSERT(prAdapter);
  367. /* Note: assume TIMER_T structures are reset to zero or stopped
  368. * before invoking this function.
  369. */
  370. /* Initialize OBSS FSM */
  371. rlmObssInit(prAdapter);
  372. #if CFG_SUPPORT_PWR_LIMIT_COUNTRY
  373. rlmDomainCheckCountryPowerLimitTable(prAdapter);
  374. #endif
  375. }
  376. /*----------------------------------------------------------------------------*/
  377. /*!
  378. * \brief
  379. *
  380. * \param[in]
  381. *
  382. * \return none
  383. */
  384. /*----------------------------------------------------------------------------*/
  385. VOID rlmFsmEventUninit(P_ADAPTER_T prAdapter)
  386. {
  387. P_BSS_INFO_T prBssInfo;
  388. UINT_8 ucNetIdx;
  389. ASSERT(prAdapter);
  390. RLM_NET_FOR_EACH(ucNetIdx) {
  391. prBssInfo = &prAdapter->rWifiVar.arBssInfo[ucNetIdx];
  392. ASSERT(prBssInfo);
  393. /* Note: all RLM timers will also be stopped.
  394. * Now only one OBSS scan timer.
  395. */
  396. rlmBssReset(prAdapter, prBssInfo);
  397. }
  398. }
  399. /*----------------------------------------------------------------------------*/
  400. /*!
  401. * \brief For probe request, association request
  402. *
  403. * \param[in]
  404. *
  405. * \return none
  406. */
  407. /*----------------------------------------------------------------------------*/
  408. VOID rlmReqGenerateHtCapIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  409. {
  410. P_BSS_INFO_T prBssInfo;
  411. P_STA_RECORD_T prStaRec;
  412. ASSERT(prAdapter);
  413. ASSERT(prMsduInfo);
  414. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  415. ASSERT(prBssInfo);
  416. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  417. if ((prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11N) &&
  418. (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N)))
  419. rlmFillHtCapIE(prAdapter, prBssInfo, prMsduInfo);
  420. }
  421. /*----------------------------------------------------------------------------*/
  422. /*!
  423. * \brief For probe request, association request
  424. *
  425. * \param[in]
  426. *
  427. * \return none
  428. */
  429. /*----------------------------------------------------------------------------*/
  430. VOID rlmReqGenerateExtCapIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  431. {
  432. P_BSS_INFO_T prBssInfo;
  433. P_STA_RECORD_T prStaRec;
  434. ASSERT(prAdapter);
  435. ASSERT(prMsduInfo);
  436. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  437. ASSERT(prBssInfo);
  438. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  439. if ((prAdapter->rWifiVar.ucAvailablePhyTypeSet & PHY_TYPE_SET_802_11N) &&
  440. (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N)))
  441. rlmFillExtCapIE(prAdapter, prBssInfo, prMsduInfo);
  442. #if CFG_SUPPORT_HOTSPOT_2_0
  443. else if (prAdapter->prGlueInfo->fgConnectHS20AP == TRUE)
  444. hs20FillExtCapIE(prAdapter, prBssInfo, prMsduInfo);
  445. #endif
  446. }
  447. /*----------------------------------------------------------------------------*/
  448. /*!
  449. * \brief For probe response (GO, IBSS) and association response
  450. *
  451. * \param[in]
  452. *
  453. * \return none
  454. */
  455. /*----------------------------------------------------------------------------*/
  456. VOID rlmRspGenerateHtCapIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  457. {
  458. P_BSS_INFO_T prBssInfo;
  459. P_STA_RECORD_T prStaRec;
  460. ASSERT(prAdapter);
  461. ASSERT(prMsduInfo);
  462. ASSERT(IS_NET_ACTIVE(prAdapter, prMsduInfo->ucNetworkType));
  463. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  464. ASSERT(prBssInfo);
  465. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  466. if (RLM_NET_IS_11N(prBssInfo) && (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N)))
  467. rlmFillHtCapIE(prAdapter, prBssInfo, prMsduInfo);
  468. }
  469. /*----------------------------------------------------------------------------*/
  470. /*!
  471. * \brief For probe response (GO, IBSS) and association response
  472. *
  473. * \param[in]
  474. *
  475. * \return none
  476. */
  477. /*----------------------------------------------------------------------------*/
  478. VOID rlmRspGenerateExtCapIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  479. {
  480. P_BSS_INFO_T prBssInfo;
  481. P_STA_RECORD_T prStaRec;
  482. ASSERT(prAdapter);
  483. ASSERT(prMsduInfo);
  484. ASSERT(IS_NET_ACTIVE(prAdapter, prMsduInfo->ucNetworkType));
  485. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  486. ASSERT(prBssInfo);
  487. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  488. if (RLM_NET_IS_11N(prBssInfo) && (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N)))
  489. rlmFillExtCapIE(prAdapter, prBssInfo, prMsduInfo);
  490. }
  491. /*----------------------------------------------------------------------------*/
  492. /*!
  493. * \brief For probe response (GO, IBSS) and association response
  494. *
  495. * \param[in]
  496. *
  497. * \return none
  498. */
  499. /*----------------------------------------------------------------------------*/
  500. VOID rlmRspGenerateHtOpIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  501. {
  502. P_BSS_INFO_T prBssInfo;
  503. P_STA_RECORD_T prStaRec;
  504. ASSERT(prAdapter);
  505. ASSERT(prMsduInfo);
  506. ASSERT(IS_NET_ACTIVE(prAdapter, prMsduInfo->ucNetworkType));
  507. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  508. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  509. ASSERT(prBssInfo);
  510. if (RLM_NET_IS_11N(prBssInfo) && (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N)))
  511. rlmFillHtOpIE(prAdapter, prBssInfo, prMsduInfo);
  512. }
  513. /*----------------------------------------------------------------------------*/
  514. /*!
  515. * \brief For probe response (GO, IBSS) and association response
  516. *
  517. * \param[in]
  518. *
  519. * \return none
  520. */
  521. /*----------------------------------------------------------------------------*/
  522. VOID rlmRspGenerateErpIE(P_ADAPTER_T prAdapter, P_MSDU_INFO_T prMsduInfo)
  523. {
  524. P_BSS_INFO_T prBssInfo;
  525. P_STA_RECORD_T prStaRec;
  526. P_IE_ERP_T prErpIe;
  527. ASSERT(prAdapter);
  528. ASSERT(prMsduInfo);
  529. ASSERT(IS_NET_ACTIVE(prAdapter, prMsduInfo->ucNetworkType));
  530. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  531. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prMsduInfo->ucNetworkType];
  532. ASSERT(prBssInfo);
  533. if (RLM_NET_IS_11GN(prBssInfo) && prBssInfo->eBand == BAND_2G4 &&
  534. (!prStaRec || (prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11GN))) {
  535. prErpIe = (P_IE_ERP_T)
  536. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength);
  537. /* Add ERP IE */
  538. prErpIe->ucId = ELEM_ID_ERP_INFO;
  539. prErpIe->ucLength = 1;
  540. prErpIe->ucERP = prBssInfo->fgObssErpProtectMode ? ERP_INFO_USE_PROTECTION : 0;
  541. if (prBssInfo->fgErpProtectMode)
  542. prErpIe->ucERP |= (ERP_INFO_NON_ERP_PRESENT | ERP_INFO_USE_PROTECTION);
  543. /* Handle barker preamble */
  544. if (!prBssInfo->fgUseShortPreamble)
  545. prErpIe->ucERP |= ERP_INFO_BARKER_PREAMBLE_MODE;
  546. ASSERT(IE_SIZE(prErpIe) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_ERP));
  547. prMsduInfo->u2FrameLength += IE_SIZE(prErpIe);
  548. }
  549. }
  550. /*----------------------------------------------------------------------------*/
  551. /*!
  552. * \brief
  553. *
  554. * \param[in]
  555. *
  556. * \return none
  557. */
  558. /*----------------------------------------------------------------------------*/
  559. UINT32
  560. rlmFillHtCapIEByParams(BOOLEAN fg40mAllowed,
  561. BOOLEAN fgShortGIDisabled,
  562. UINT_8 u8SupportRxSgi20,
  563. UINT_8 u8SupportRxSgi40,
  564. UINT_8 u8SupportRxGf, UINT_8 u8SupportRxSTBC, ENUM_OP_MODE_T eCurrentOPMode, UINT_8 *pOutBuf)
  565. {
  566. P_IE_HT_CAP_T prHtCap;
  567. P_SUP_MCS_SET_FIELD prSupMcsSet;
  568. ASSERT(pOutBuf);
  569. prHtCap = (P_IE_HT_CAP_T) pOutBuf;
  570. /* Add HT capabilities IE */
  571. prHtCap->ucId = ELEM_ID_HT_CAP;
  572. prHtCap->ucLength = sizeof(IE_HT_CAP_T) - ELEM_HDR_LEN;
  573. prHtCap->u2HtCapInfo = HT_CAP_INFO_DEFAULT_VAL;
  574. if (!fg40mAllowed) {
  575. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH |
  576. HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_DSSS_CCK_IN_40M);
  577. }
  578. if (fgShortGIDisabled)
  579. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M);
  580. if (u8SupportRxSgi20 == 2)
  581. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_20M);
  582. if (u8SupportRxSgi40 == 2)
  583. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_40M);
  584. if (u8SupportRxGf == 2)
  585. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_HT_GF);
  586. if (u8SupportRxSTBC == 2)
  587. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_RX_STBC_1_SS);
  588. prHtCap->ucAmpduParam = AMPDU_PARAM_DEFAULT_VAL;
  589. prSupMcsSet = &prHtCap->rSupMcsSet;
  590. kalMemZero((PVOID)&prSupMcsSet->aucRxMcsBitmask[0], SUP_MCS_RX_BITMASK_OCTET_NUM);
  591. prSupMcsSet->aucRxMcsBitmask[0] = BITS(0, 7);
  592. if (fg40mAllowed)
  593. prSupMcsSet->aucRxMcsBitmask[32 / 8] = BIT(0); /* MCS32 */
  594. prSupMcsSet->u2RxHighestSupportedRate = SUP_MCS_RX_DEFAULT_HIGHEST_RATE;
  595. prSupMcsSet->u4TxRateInfo = SUP_MCS_TX_DEFAULT_VAL;
  596. prHtCap->u2HtExtendedCap = HT_EXT_CAP_DEFAULT_VAL;
  597. if (!fg40mAllowed || eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
  598. prHtCap->u2HtExtendedCap &= ~(HT_EXT_CAP_PCO | HT_EXT_CAP_PCO_TRANS_TIME_NONE);
  599. prHtCap->u4TxBeamformingCap = TX_BEAMFORMING_CAP_DEFAULT_VAL;
  600. prHtCap->ucAselCap = ASEL_CAP_DEFAULT_VAL;
  601. ASSERT(IE_SIZE(prHtCap) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP));
  602. return IE_SIZE(prHtCap);
  603. }
  604. /*----------------------------------------------------------------------------*/
  605. /*!
  606. * \brief
  607. *
  608. * \param[in]
  609. *
  610. * \return none
  611. */
  612. /*----------------------------------------------------------------------------*/
  613. static VOID rlmFillHtCapIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo)
  614. {
  615. P_IE_HT_CAP_T prHtCap;
  616. /* P_SUP_MCS_SET_FIELD prSupMcsSet; */
  617. BOOLEAN fg40mAllowed;
  618. ASSERT(prAdapter);
  619. ASSERT(prBssInfo);
  620. ASSERT(prMsduInfo);
  621. #if 1
  622. if (prMsduInfo->ucNetworkType == NETWORK_TYPE_P2P_INDEX) {
  623. DBGLOG(AIS, WARN, "Assoc:Force P2P BW to 20\n");
  624. prBssInfo->fgAssoc40mBwAllowed = FALSE;
  625. }
  626. #endif
  627. fg40mAllowed = prBssInfo->fgAssoc40mBwAllowed;
  628. prHtCap = (P_IE_HT_CAP_T)
  629. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength);
  630. #if 0
  631. /* Add HT capabilities IE */
  632. prHtCap->ucId = ELEM_ID_HT_CAP;
  633. prHtCap->ucLength = sizeof(IE_HT_CAP_T) - ELEM_HDR_LEN;
  634. prHtCap->u2HtCapInfo = HT_CAP_INFO_DEFAULT_VAL;
  635. if (!fg40mAllowed)
  636. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SUP_CHNL_WIDTH |
  637. HT_CAP_INFO_SHORT_GI_40M | HT_CAP_INFO_DSSS_CCK_IN_40M);
  638. if (prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled)
  639. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_20M | HT_CAP_INFO_SHORT_GI_40M);
  640. if (prAdapter->rWifiVar.u8SupportRxSgi20 == 2)
  641. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_20M);
  642. if (prAdapter->rWifiVar.u8SupportRxSgi40 == 2)
  643. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_SHORT_GI_40M);
  644. if (prAdapter->rWifiVar.u8SupportRxGf == 2)
  645. prHtCap->u2HtCapInfo &= ~(HT_CAP_INFO_HT_GF);
  646. prHtCap->ucAmpduParam = AMPDU_PARAM_DEFAULT_VAL;
  647. prSupMcsSet = &prHtCap->rSupMcsSet;
  648. kalMemZero((PVOID)&prSupMcsSet->aucRxMcsBitmask[0], SUP_MCS_RX_BITMASK_OCTET_NUM);
  649. prSupMcsSet->aucRxMcsBitmask[0] = BITS(0, 7);
  650. if (fg40mAllowed)
  651. prSupMcsSet->aucRxMcsBitmask[32 / 8] = BIT(0); /* MCS32 */
  652. prSupMcsSet->u2RxHighestSupportedRate = SUP_MCS_RX_DEFAULT_HIGHEST_RATE;
  653. prSupMcsSet->u4TxRateInfo = SUP_MCS_TX_DEFAULT_VAL;
  654. prHtCap->u2HtExtendedCap = HT_EXT_CAP_DEFAULT_VAL;
  655. if (!fg40mAllowed || prBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
  656. prHtCap->u2HtExtendedCap &= ~(HT_EXT_CAP_PCO | HT_EXT_CAP_PCO_TRANS_TIME_NONE);
  657. prHtCap->u4TxBeamformingCap = TX_BEAMFORMING_CAP_DEFAULT_VAL;
  658. prHtCap->ucAselCap = ASEL_CAP_DEFAULT_VAL;
  659. ASSERT(IE_SIZE(prHtCap) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP));
  660. prMsduInfo->u2FrameLength += IE_SIZE(prHtCap);
  661. #else
  662. prMsduInfo->u2FrameLength += rlmFillHtCapIEByParams(fg40mAllowed,
  663. prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled,
  664. prAdapter->rWifiVar.u8SupportRxSgi20,
  665. prAdapter->rWifiVar.u8SupportRxSgi40,
  666. prAdapter->rWifiVar.u8SupportRxGf,
  667. prAdapter->rWifiVar.u8SupportRxSTBC,
  668. prBssInfo->eCurrentOPMode, (UINT_8 *) prHtCap);
  669. #endif
  670. }
  671. /*----------------------------------------------------------------------------*/
  672. /*!
  673. * \brief
  674. *
  675. * \param[in]
  676. *
  677. * \return none
  678. */
  679. /*----------------------------------------------------------------------------*/
  680. static VOID rlmFillExtCapIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo)
  681. {
  682. #if CFG_SUPPORT_HOTSPOT_2_0
  683. P_HS20_EXT_CAP_T prHsExtCap;
  684. #else
  685. P_EXT_CAP_T prExtCap;
  686. #endif
  687. BOOLEAN fg40mAllowed;
  688. ASSERT(prAdapter);
  689. ASSERT(prMsduInfo);
  690. fg40mAllowed = prBssInfo->fgAssoc40mBwAllowed;
  691. #if CFG_SUPPORT_HOTSPOT_2_0
  692. prHsExtCap = (P_HS20_EXT_CAP_T)
  693. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength);
  694. prHsExtCap->ucId = ELEM_ID_EXTENDED_CAP;
  695. if (prAdapter->prGlueInfo->fgConnectHS20AP == TRUE)
  696. prHsExtCap->ucLength = ELEM_MAX_LEN_EXT_CAP;
  697. else
  698. prHsExtCap->ucLength = 3 - ELEM_HDR_LEN;
  699. kalMemZero(prHsExtCap->aucCapabilities, sizeof(prHsExtCap->aucCapabilities));
  700. prHsExtCap->aucCapabilities[0] = ELEM_EXT_CAP_DEFAULT_VAL;
  701. if (!fg40mAllowed)
  702. prHsExtCap->aucCapabilities[0] &= ~ELEM_EXT_CAP_20_40_COEXIST_SUPPORT;
  703. if (prBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
  704. prHsExtCap->aucCapabilities[0] &= ~ELEM_EXT_CAP_PSMP_CAP;
  705. if (prAdapter->prGlueInfo->fgConnectHS20AP == TRUE) {
  706. SET_EXT_CAP(prHsExtCap->aucCapabilities, ELEM_MAX_LEN_EXT_CAP, ELEM_EXT_CAP_INTERWORKING_BIT);
  707. /* For R2 WNM-Notification */
  708. SET_EXT_CAP(prHsExtCap->aucCapabilities, ELEM_MAX_LEN_EXT_CAP, ELEM_EXT_CAP_WNM_NOTIFICATION_BIT);
  709. }
  710. ASSERT(IE_SIZE(prHsExtCap) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP));
  711. prMsduInfo->u2FrameLength += IE_SIZE(prHsExtCap);
  712. #else
  713. /* Add Extended Capabilities IE */
  714. prExtCap = (P_EXT_CAP_T)
  715. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength);
  716. prExtCap->ucId = ELEM_ID_EXTENDED_CAP;
  717. prExtCap->ucLength = 3 - ELEM_HDR_LEN;
  718. kalMemZero(prExtCap->aucCapabilities, sizeof(prExtCap->aucCapabilities));
  719. prExtCap->aucCapabilities[0] = ELEM_EXT_CAP_DEFAULT_VAL;
  720. if (!fg40mAllowed)
  721. prExtCap->aucCapabilities[0] &= ~ELEM_EXT_CAP_20_40_COEXIST_SUPPORT;
  722. if (prBssInfo->eCurrentOPMode != OP_MODE_INFRASTRUCTURE)
  723. prExtCap->aucCapabilities[0] &= ~ELEM_EXT_CAP_PSMP_CAP;
  724. ASSERT(IE_SIZE(prExtCap) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP));
  725. prMsduInfo->u2FrameLength += IE_SIZE(prExtCap);
  726. #endif
  727. }
  728. /*----------------------------------------------------------------------------*/
  729. /*!
  730. * \brief
  731. *
  732. * \param[in]
  733. *
  734. * \return none
  735. */
  736. /*----------------------------------------------------------------------------*/
  737. UINT32 rlmFillHtOpIeBody(P_BSS_INFO_T prBssInfo, UINT_8 *pFme)
  738. {
  739. P_IE_HT_OP_T prHtOp;
  740. UINT_16 i;
  741. prHtOp = (P_IE_HT_OP_T) pFme;
  742. /* Add HT operation IE */
  743. prHtOp->ucId = ELEM_ID_HT_OP;
  744. prHtOp->ucLength = sizeof(IE_HT_OP_T) - ELEM_HDR_LEN;
  745. /* RIFS and 20/40 bandwidth operations are included */
  746. prHtOp->ucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  747. prHtOp->ucInfo1 = prBssInfo->ucHtOpInfo1;
  748. /* Decide HT protection mode field */
  749. if (prBssInfo->eHtProtectMode == HT_PROTECT_MODE_NON_HT)
  750. prHtOp->u2Info2 = (UINT_8) HT_PROTECT_MODE_NON_HT;
  751. else if (prBssInfo->eObssHtProtectMode == HT_PROTECT_MODE_NON_MEMBER)
  752. prHtOp->u2Info2 = (UINT_8) HT_PROTECT_MODE_NON_MEMBER;
  753. else {
  754. /* It may be SYS_PROTECT_MODE_NONE or SYS_PROTECT_MODE_20M */
  755. prHtOp->u2Info2 = (UINT_8) prBssInfo->eHtProtectMode;
  756. }
  757. if (prBssInfo->eGfOperationMode != GF_MODE_NORMAL) {
  758. /* It may be GF_MODE_PROTECT or GF_MODE_DISALLOWED
  759. * Note: it will also be set in ad-hoc network
  760. */
  761. prHtOp->u2Info2 |= HT_OP_INFO2_NON_GF_HT_STA_PRESENT;
  762. }
  763. if (0 /* Regulatory class 16 */ &&
  764. prBssInfo->eObssHtProtectMode == HT_PROTECT_MODE_NON_MEMBER) {
  765. /* (TBD) It is HT_PROTECT_MODE_NON_MEMBER, so require protection
  766. * although it is possible to have no protection by spec.
  767. */
  768. prHtOp->u2Info2 |= HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT;
  769. }
  770. prHtOp->u2Info3 = prBssInfo->u2HtOpInfo3; /* To do: handle L-SIG TXOP */
  771. /* No basic MCSx are needed temporarily */
  772. for (i = 0; i < 16; i++)
  773. prHtOp->aucBasicMcsSet[i] = 0;
  774. return sizeof(IE_HT_OP_T);
  775. }
  776. static VOID rlmFillHtOpIE(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, P_MSDU_INFO_T prMsduInfo)
  777. {
  778. /* P_IE_HT_OP_T prHtOp; */
  779. /* UINT_16 i; */
  780. ASSERT(prAdapter);
  781. ASSERT(prBssInfo);
  782. ASSERT(prMsduInfo);
  783. prMsduInfo->u2FrameLength += rlmFillHtOpIeBody(prBssInfo,
  784. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength));
  785. #if 0
  786. prHtOp = (P_IE_HT_OP_T)
  787. (((PUINT_8) prMsduInfo->prPacket) + prMsduInfo->u2FrameLength);
  788. /* Add HT operation IE */
  789. prHtOp->ucId = ELEM_ID_HT_OP;
  790. prHtOp->ucLength = sizeof(IE_HT_OP_T) - ELEM_HDR_LEN;
  791. /* RIFS and 20/40 bandwidth operations are included */
  792. prHtOp->ucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  793. prHtOp->ucInfo1 = prBssInfo->ucHtOpInfo1;
  794. /* Decide HT protection mode field */
  795. if (prBssInfo->eHtProtectMode == HT_PROTECT_MODE_NON_HT)
  796. prHtOp->u2Info2 = (UINT_8) HT_PROTECT_MODE_NON_HT;
  797. else if (prBssInfo->eObssHtProtectMode == HT_PROTECT_MODE_NON_MEMBER)
  798. prHtOp->u2Info2 = (UINT_8) HT_PROTECT_MODE_NON_MEMBER;
  799. else {
  800. /* It may be SYS_PROTECT_MODE_NONE or SYS_PROTECT_MODE_20M */
  801. prHtOp->u2Info2 = (UINT_8) prBssInfo->eHtProtectMode;
  802. }
  803. if (prBssInfo->eGfOperationMode != GF_MODE_NORMAL) {
  804. /* It may be GF_MODE_PROTECT or GF_MODE_DISALLOWED
  805. * Note: it will also be set in ad-hoc network
  806. */
  807. prHtOp->u2Info2 |= HT_OP_INFO2_NON_GF_HT_STA_PRESENT;
  808. }
  809. if (0 /* Regulatory class 16 */ &&
  810. prBssInfo->eObssHtProtectMode == HT_PROTECT_MODE_NON_MEMBER) {
  811. /* (TBD) It is HT_PROTECT_MODE_NON_MEMBER, so require protection
  812. * although it is possible to have no protection by spec.
  813. */
  814. prHtOp->u2Info2 |= HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT;
  815. }
  816. prHtOp->u2Info3 = prBssInfo->u2HtOpInfo3; /* To do: handle L-SIG TXOP */
  817. /* No basic MCSx are needed temporarily */
  818. for (i = 0; i < 16; i++)
  819. prHtOp->aucBasicMcsSet[i] = 0;
  820. ASSERT(IE_SIZE(prHtOp) <= (ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP));
  821. prMsduInfo->u2FrameLength += IE_SIZE(prHtOp);
  822. #endif
  823. }
  824. /*----------------------------------------------------------------------------*/
  825. /*!
  826. * \brief This function should be invoked to update parameters of associated AP.
  827. * (Association response and Beacon)
  828. *
  829. * \param[in]
  830. *
  831. * \return none
  832. */
  833. /*----------------------------------------------------------------------------*/
  834. static UINT_8 rlmRecIeInfoForClient(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo, PUINT_8 pucIE, UINT_16 u2IELength)
  835. {
  836. UINT_16 u2Offset;
  837. P_STA_RECORD_T prStaRec;
  838. P_IE_HT_CAP_T prHtCap;
  839. P_IE_HT_OP_T prHtOp;
  840. P_IE_OBSS_SCAN_PARAM_T prObssScnParam;
  841. UINT_8 ucERP, ucPrimaryChannel;
  842. #if CFG_SUPPORT_QUIET && 0
  843. BOOLEAN fgHasQuietIE = FALSE;
  844. #endif
  845. ASSERT(prAdapter);
  846. ASSERT(prBssInfo);
  847. ASSERT(pucIE);
  848. prStaRec = prBssInfo->prStaRecOfAP;
  849. ASSERT(prStaRec);
  850. if (!prStaRec)
  851. return 0;
  852. prBssInfo->fgUseShortPreamble = prBssInfo->fgIsShortPreambleAllowed;
  853. ucPrimaryChannel = 0;
  854. prObssScnParam = NULL;
  855. /* Note: HT-related members in staRec may not be zero before, so
  856. * if following IE does not exist, they are still not zero.
  857. * These HT-related parameters are valid only when the corresponding
  858. * BssInfo supports 802.11n, i.e., RLM_NET_IS_11N()
  859. */
  860. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  861. switch (IE_ID(pucIE)) {
  862. case ELEM_ID_HT_CAP:
  863. if (!RLM_NET_IS_11N(prBssInfo) || IE_LEN(pucIE) != (sizeof(IE_HT_CAP_T) - 2))
  864. break;
  865. prHtCap = (P_IE_HT_CAP_T) pucIE;
  866. prStaRec->ucMcsSet = prHtCap->rSupMcsSet.aucRxMcsBitmask[0];
  867. prStaRec->fgSupMcs32 = (prHtCap->rSupMcsSet.aucRxMcsBitmask[32 / 8] & BIT(0)) ? TRUE : FALSE;
  868. prStaRec->u2HtCapInfo = prHtCap->u2HtCapInfo;
  869. prStaRec->ucAmpduParam = prHtCap->ucAmpduParam;
  870. prStaRec->u2HtExtendedCap = prHtCap->u2HtExtendedCap;
  871. prStaRec->u4TxBeamformingCap = prHtCap->u4TxBeamformingCap;
  872. prStaRec->ucAselCap = prHtCap->ucAselCap;
  873. break;
  874. case ELEM_ID_HT_OP:
  875. if (!RLM_NET_IS_11N(prBssInfo) || IE_LEN(pucIE) != (sizeof(IE_HT_OP_T) - 2))
  876. break;
  877. prHtOp = (P_IE_HT_OP_T) pucIE;
  878. /* Workaround that some APs fill primary channel field by its
  879. * secondary channel, but its DS IE is correct 20110610
  880. */
  881. if (ucPrimaryChannel == 0)
  882. ucPrimaryChannel = prHtOp->ucPrimaryChannel;
  883. prBssInfo->ucHtOpInfo1 = prHtOp->ucInfo1;
  884. prBssInfo->u2HtOpInfo2 = prHtOp->u2Info2;
  885. prBssInfo->u2HtOpInfo3 = prHtOp->u2Info3;
  886. if (!prBssInfo->fg40mBwAllowed)
  887. prBssInfo->ucHtOpInfo1 &= ~(HT_OP_INFO1_SCO | HT_OP_INFO1_STA_CHNL_WIDTH);
  888. if ((prBssInfo->ucHtOpInfo1 & HT_OP_INFO1_SCO) != CHNL_EXT_RES)
  889. prBssInfo->eBssSCO = (ENUM_CHNL_EXT_T)(prBssInfo->ucHtOpInfo1 & HT_OP_INFO1_SCO);
  890. prBssInfo->eHtProtectMode = (ENUM_HT_PROTECT_MODE_T)
  891. (prBssInfo->u2HtOpInfo2 & HT_OP_INFO2_HT_PROTECTION);
  892. /* To do: process regulatory class 16 */
  893. if ((prBssInfo->u2HtOpInfo2 & HT_OP_INFO2_OBSS_NON_HT_STA_PRESENT)
  894. && 0 /* && regulatory class is 16 */)
  895. prBssInfo->eGfOperationMode = GF_MODE_DISALLOWED;
  896. else if (prBssInfo->u2HtOpInfo2 & HT_OP_INFO2_NON_GF_HT_STA_PRESENT)
  897. prBssInfo->eGfOperationMode = GF_MODE_PROTECT;
  898. else
  899. prBssInfo->eGfOperationMode = GF_MODE_NORMAL;
  900. prBssInfo->eRifsOperationMode =
  901. (prBssInfo->ucHtOpInfo1 & HT_OP_INFO1_RIFS_MODE) ? RIFS_MODE_NORMAL : RIFS_MODE_DISALLOWED;
  902. break;
  903. case ELEM_ID_20_40_BSS_COEXISTENCE:
  904. if (!RLM_NET_IS_11N(prBssInfo))
  905. break;
  906. /* To do: store if scanning exemption grant to BssInfo */
  907. break;
  908. case ELEM_ID_OBSS_SCAN_PARAMS:
  909. if (!RLM_NET_IS_11N(prBssInfo) || IE_LEN(pucIE) != (sizeof(IE_OBSS_SCAN_PARAM_T) - 2))
  910. break;
  911. /* Store OBSS parameters to BssInfo */
  912. prObssScnParam = (P_IE_OBSS_SCAN_PARAM_T) pucIE;
  913. break;
  914. case ELEM_ID_EXTENDED_CAP:
  915. if (!RLM_NET_IS_11N(prBssInfo))
  916. break;
  917. /* To do: store extended capability (PSMP, coexist) to BssInfo */
  918. break;
  919. case ELEM_ID_ERP_INFO:
  920. if (IE_LEN(pucIE) != (sizeof(IE_ERP_T) - 2) || prBssInfo->eBand != BAND_2G4)
  921. break;
  922. ucERP = ERP_INFO_IE(pucIE)->ucERP;
  923. prBssInfo->fgErpProtectMode = (ucERP & ERP_INFO_USE_PROTECTION) ? TRUE : FALSE;
  924. if (ucERP & ERP_INFO_BARKER_PREAMBLE_MODE)
  925. prBssInfo->fgUseShortPreamble = FALSE;
  926. break;
  927. case ELEM_ID_DS_PARAM_SET:
  928. if (IE_LEN(pucIE) == ELEM_MAX_LEN_DS_PARAMETER_SET)
  929. ucPrimaryChannel = DS_PARAM_IE(pucIE)->ucCurrChnl;
  930. break;
  931. #if CFG_SUPPORT_DFS /* Add by Enlai */
  932. case ELEM_ID_CH_SW_ANNOUNCEMENT:
  933. {
  934. rlmProcessChannelSwitchIE(prAdapter, (P_IE_CHANNEL_SWITCH_T) pucIE);
  935. }
  936. break;
  937. #if CFG_SUPPORT_QUIET && 0
  938. /* Note: RRM code should be moved to independent RRM function by
  939. * component design rule. But we attach it to RLM temporarily
  940. */
  941. case ELEM_ID_QUIET:
  942. rrmQuietHandleQuietIE(prBssInfo, (P_IE_QUIET_T) pucIE);
  943. fgHasQuietIE = TRUE;
  944. break;
  945. #endif
  946. #endif
  947. default:
  948. break;
  949. } /* end of switch */
  950. } /* end of IE_FOR_EACH */
  951. /* Some AP will have wrong channel number (255) when running time.
  952. * Check if correct channel number information. 20110501
  953. */
  954. if ((prBssInfo->eBand == BAND_2G4 && ucPrimaryChannel > 14) ||
  955. (prBssInfo->eBand != BAND_2G4 && (ucPrimaryChannel >= 200 || ucPrimaryChannel <= 14)))
  956. ucPrimaryChannel = 0;
  957. #if CFG_SUPPORT_QUIET && 0
  958. if (!fgHasQuietIE)
  959. rrmQuietIeNotExist(prAdapter, prBssInfo);
  960. #endif
  961. /* Check if OBSS scan process will launch */
  962. if (!prAdapter->fgEnOnlineScan || !prObssScnParam ||
  963. !(prStaRec->u2HtCapInfo & HT_CAP_INFO_SUP_CHNL_WIDTH) ||
  964. prBssInfo->eBand != BAND_2G4 || !prBssInfo->fg40mBwAllowed) {
  965. /* Note: it is ok not to stop rObssScanTimer() here */
  966. prBssInfo->u2ObssScanInterval = 0;
  967. } else {
  968. if (prObssScnParam->u2TriggerScanInterval < OBSS_SCAN_MIN_INTERVAL)
  969. prObssScnParam->u2TriggerScanInterval = OBSS_SCAN_MIN_INTERVAL;
  970. if (prBssInfo->u2ObssScanInterval != prObssScnParam->u2TriggerScanInterval) {
  971. prBssInfo->u2ObssScanInterval = prObssScnParam->u2TriggerScanInterval;
  972. /* Start timer to trigger OBSS scanning */
  973. cnmTimerStartTimer(prAdapter, &prBssInfo->rObssScanTimer,
  974. prBssInfo->u2ObssScanInterval * MSEC_PER_SEC);
  975. }
  976. }
  977. return ucPrimaryChannel;
  978. }
  979. /*----------------------------------------------------------------------------*/
  980. /*!
  981. * \brief AIS or P2P GC.
  982. *
  983. * \param[in]
  984. *
  985. * \return none
  986. */
  987. /*----------------------------------------------------------------------------*/
  988. static BOOLEAN
  989. rlmRecBcnFromNeighborForClient(P_ADAPTER_T prAdapter,
  990. P_BSS_INFO_T prBssInfo, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength)
  991. {
  992. UINT_16 u2Offset, i;
  993. UINT_8 ucPriChannel, ucSecChannel;
  994. ENUM_CHNL_EXT_T eSCO;
  995. BOOLEAN fgHtBss, fg20mReq;
  996. if ((prAdapter == NULL)
  997. || (pucIE == NULL)
  998. || (prBssInfo == NULL)
  999. || (prSwRfb == NULL)) {
  1000. ASSERT(FALSE);
  1001. return FALSE;
  1002. }
  1003. /* Record it to channel list to change 20/40 bandwidth */
  1004. ucPriChannel = 0;
  1005. eSCO = CHNL_EXT_SCN;
  1006. fgHtBss = FALSE;
  1007. fg20mReq = FALSE;
  1008. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  1009. switch (IE_ID(pucIE)) {
  1010. case ELEM_ID_HT_CAP:
  1011. {
  1012. P_IE_HT_CAP_T prHtCap;
  1013. if (IE_LEN(pucIE) != (sizeof(IE_HT_CAP_T) - 2))
  1014. break;
  1015. prHtCap = (P_IE_HT_CAP_T) pucIE;
  1016. if (prHtCap->u2HtCapInfo & HT_CAP_INFO_40M_INTOLERANT)
  1017. fg20mReq = TRUE;
  1018. fgHtBss = TRUE;
  1019. break;
  1020. }
  1021. case ELEM_ID_HT_OP:
  1022. {
  1023. P_IE_HT_OP_T prHtOp;
  1024. if (IE_LEN(pucIE) != (sizeof(IE_HT_OP_T) - 2))
  1025. break;
  1026. prHtOp = (P_IE_HT_OP_T) pucIE;
  1027. /* Workaround that some APs fill primary channel field by its
  1028. * secondary channel, but its DS IE is correct 20110610
  1029. */
  1030. if (ucPriChannel == 0)
  1031. ucPriChannel = prHtOp->ucPrimaryChannel;
  1032. if ((prHtOp->ucInfo1 & HT_OP_INFO1_SCO) != CHNL_EXT_RES)
  1033. eSCO = (ENUM_CHNL_EXT_T) (prHtOp->ucInfo1 & HT_OP_INFO1_SCO);
  1034. break;
  1035. }
  1036. case ELEM_ID_20_40_BSS_COEXISTENCE:
  1037. {
  1038. P_IE_20_40_COEXIST_T prCoexist;
  1039. if (IE_LEN(pucIE) != (sizeof(IE_20_40_COEXIST_T) - 2))
  1040. break;
  1041. prCoexist = (P_IE_20_40_COEXIST_T) pucIE;
  1042. if (prCoexist->ucData & BSS_COEXIST_40M_INTOLERANT)
  1043. fg20mReq = TRUE;
  1044. break;
  1045. }
  1046. case ELEM_ID_DS_PARAM_SET:
  1047. if (IE_LEN(pucIE) != (sizeof(IE_DS_PARAM_SET_T) - 2))
  1048. break;
  1049. ucPriChannel = DS_PARAM_IE(pucIE)->ucCurrChnl;
  1050. break;
  1051. default:
  1052. break;
  1053. }
  1054. }
  1055. /* To do: Update channel list and 5G band. All channel lists have the same
  1056. * update procedure. We should give it the entry pointer of desired
  1057. * channel list.
  1058. */
  1059. if (HIF_RX_HDR_GET_RF_BAND(prSwRfb->prHifRxHdr) != BAND_2G4)
  1060. return FALSE;
  1061. if (ucPriChannel == 0 || ucPriChannel > 14)
  1062. ucPriChannel = HIF_RX_HDR_GET_CHNL_NUM(prSwRfb->prHifRxHdr);
  1063. if (fgHtBss) {
  1064. ASSERT(prBssInfo->auc2G_PriChnlList[0] <= CHNL_LIST_SZ_2G);
  1065. for (i = 1; i <= prBssInfo->auc2G_PriChnlList[0] && i <= CHNL_LIST_SZ_2G; i++) {
  1066. if (prBssInfo->auc2G_PriChnlList[i] == ucPriChannel)
  1067. break;
  1068. }
  1069. if ((i > prBssInfo->auc2G_PriChnlList[0]) && (i <= CHNL_LIST_SZ_2G)) {
  1070. prBssInfo->auc2G_PriChnlList[i] = ucPriChannel;
  1071. prBssInfo->auc2G_PriChnlList[0]++;
  1072. }
  1073. /* Update secondary channel */
  1074. if (eSCO != CHNL_EXT_SCN) {
  1075. ucSecChannel = (eSCO == CHNL_EXT_SCA) ? (ucPriChannel + 4) : (ucPriChannel - 4);
  1076. ASSERT(prBssInfo->auc2G_SecChnlList[0] <= CHNL_LIST_SZ_2G);
  1077. for (i = 1; i <= prBssInfo->auc2G_SecChnlList[0] && i <= CHNL_LIST_SZ_2G; i++) {
  1078. if (prBssInfo->auc2G_SecChnlList[i] == ucSecChannel)
  1079. break;
  1080. }
  1081. if ((i > prBssInfo->auc2G_SecChnlList[0]) && (i <= CHNL_LIST_SZ_2G)) {
  1082. prBssInfo->auc2G_SecChnlList[i] = ucSecChannel;
  1083. prBssInfo->auc2G_SecChnlList[0]++;
  1084. }
  1085. }
  1086. /* Update 20M bandwidth request channels */
  1087. if (fg20mReq) {
  1088. ASSERT(prBssInfo->auc2G_20mReqChnlList[0] <= CHNL_LIST_SZ_2G);
  1089. for (i = 1; i <= prBssInfo->auc2G_20mReqChnlList[0] && i <= CHNL_LIST_SZ_2G; i++) {
  1090. if (prBssInfo->auc2G_20mReqChnlList[i] == ucPriChannel)
  1091. break;
  1092. }
  1093. if ((i > prBssInfo->auc2G_20mReqChnlList[0]) && (i <= CHNL_LIST_SZ_2G)) {
  1094. prBssInfo->auc2G_20mReqChnlList[i] = ucPriChannel;
  1095. prBssInfo->auc2G_20mReqChnlList[0]++;
  1096. }
  1097. }
  1098. } else {
  1099. /* Update non-HT channel list */
  1100. ASSERT(prBssInfo->auc2G_NonHtChnlList[0] <= CHNL_LIST_SZ_2G);
  1101. for (i = 1; i <= prBssInfo->auc2G_NonHtChnlList[0] && i <= CHNL_LIST_SZ_2G; i++) {
  1102. if (prBssInfo->auc2G_NonHtChnlList[i] == ucPriChannel)
  1103. break;
  1104. }
  1105. if ((i > prBssInfo->auc2G_NonHtChnlList[0]) && (i <= CHNL_LIST_SZ_2G)) {
  1106. prBssInfo->auc2G_NonHtChnlList[i] = ucPriChannel;
  1107. prBssInfo->auc2G_NonHtChnlList[0]++;
  1108. }
  1109. }
  1110. return FALSE;
  1111. }
  1112. /*----------------------------------------------------------------------------*/
  1113. /*!
  1114. * \brief AIS or P2P GC.
  1115. *
  1116. * \param[in]
  1117. *
  1118. * \return none
  1119. */
  1120. /*----------------------------------------------------------------------------*/
  1121. static BOOLEAN
  1122. rlmRecBcnInfoForClient(P_ADAPTER_T prAdapter,
  1123. P_BSS_INFO_T prBssInfo, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength)
  1124. {
  1125. if ((prAdapter == NULL)
  1126. || (pucIE == NULL)
  1127. || (prBssInfo == NULL)
  1128. || (prSwRfb == NULL)) {
  1129. ASSERT(FALSE);
  1130. return FALSE;
  1131. }
  1132. #if 0 /* SW migration 2010/8/20 */
  1133. /* Note: we shall not update parameters when scanning, otherwise
  1134. * channel and bandwidth will not be correct or asserted failure
  1135. * during scanning.
  1136. * Note: remove channel checking. All received Beacons should be processed
  1137. * if measurement or other actions are executed in adjacent channels
  1138. * and Beacon content checking mechanism is not disabled.
  1139. */
  1140. if (IS_SCAN_ACTIVE()
  1141. /* || prBssInfo->ucPrimaryChannel != CHNL_NUM_BY_SWRFB(prSwRfb) */
  1142. ) {
  1143. return FALSE;
  1144. }
  1145. #endif
  1146. /* Handle change of slot time */
  1147. prBssInfo->u2CapInfo = ((P_WLAN_BEACON_FRAME_T) (prSwRfb->pvHeader))->u2CapInfo;
  1148. prBssInfo->fgUseShortSlotTime = (prBssInfo->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME) ? TRUE : FALSE;
  1149. rlmRecIeInfoForClient(prAdapter, prBssInfo, pucIE, u2IELength);
  1150. return TRUE;
  1151. }
  1152. /*----------------------------------------------------------------------------*/
  1153. /*!
  1154. * \brief
  1155. *
  1156. * \param[in]
  1157. *
  1158. * \return none
  1159. */
  1160. /*----------------------------------------------------------------------------*/
  1161. VOID rlmProcessBcn(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength)
  1162. {
  1163. P_BSS_INFO_T prBssInfo;
  1164. BOOLEAN fgNewParameter;
  1165. UINT_8 ucNetIdx;
  1166. ASSERT(prAdapter);
  1167. ASSERT(prSwRfb);
  1168. ASSERT(pucIE);
  1169. fgNewParameter = FALSE;
  1170. /* When concurrent networks exist, GO shall have the same handle as
  1171. * the other BSS, so the Beacon shall be processed for bandwidth and
  1172. * protection mechanism.
  1173. * Note1: we do not have 2 AP (GO) cases simultaneously now.
  1174. * Note2: If we are GO, concurrent AIS AP should detect it and reflect
  1175. * action in its Beacon, so AIS STA just follows Beacon from AP.
  1176. */
  1177. RLM_NET_FOR_EACH_NO_BOW(ucNetIdx) {
  1178. prBssInfo = &prAdapter->rWifiVar.arBssInfo[ucNetIdx];
  1179. ASSERT(prBssInfo);
  1180. if (IS_BSS_ACTIVE(prBssInfo)) {
  1181. if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE &&
  1182. prBssInfo->eConnectionState == PARAM_MEDIA_STATE_CONNECTED) {
  1183. /* P2P client or AIS infra STA */
  1184. if (EQUAL_MAC_ADDR(prBssInfo->aucBSSID, ((P_WLAN_MAC_MGMT_HEADER_T)
  1185. (prSwRfb->pvHeader))->aucBSSID)) {
  1186. fgNewParameter = rlmRecBcnInfoForClient(prAdapter,
  1187. prBssInfo, prSwRfb, pucIE, u2IELength);
  1188. } else {
  1189. fgNewParameter = rlmRecBcnFromNeighborForClient(prAdapter,
  1190. prBssInfo, prSwRfb, pucIE,
  1191. u2IELength);
  1192. }
  1193. }
  1194. #if CFG_ENABLE_WIFI_DIRECT
  1195. else if (prAdapter->fgIsP2PRegistered &&
  1196. (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT ||
  1197. prBssInfo->eCurrentOPMode == OP_MODE_P2P_DEVICE)) {
  1198. /* AP scan to check if 20/40M bandwidth is permitted */
  1199. rlmRecBcnFromNeighborForClient(prAdapter, prBssInfo, prSwRfb, pucIE, u2IELength);
  1200. }
  1201. #endif
  1202. else if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  1203. /* Do nothing */
  1204. /* To do: Ad-hoc */
  1205. }
  1206. /* Appy new parameters if necessary */
  1207. if (fgNewParameter) {
  1208. DBGLOG(RLM, TRACE, "rlmProcessBcn\n");
  1209. rlmSyncOperationParams(prAdapter, prBssInfo);
  1210. fgNewParameter = FALSE;
  1211. }
  1212. } /* end of IS_BSS_ACTIVE() */
  1213. } /* end of RLM_NET_FOR_EACH_NO_BOW */
  1214. }
  1215. /*----------------------------------------------------------------------------*/
  1216. /*!
  1217. * \brief This function should be invoked after judging successful association.
  1218. *
  1219. * \param[in]
  1220. *
  1221. * \return none
  1222. */
  1223. /*----------------------------------------------------------------------------*/
  1224. VOID rlmProcessAssocRsp(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength)
  1225. {
  1226. P_BSS_INFO_T prBssInfo;
  1227. P_STA_RECORD_T prStaRec;
  1228. UINT_8 ucPriChannel;
  1229. ASSERT(prAdapter);
  1230. ASSERT(prSwRfb);
  1231. ASSERT(pucIE);
  1232. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1233. ASSERT(prStaRec);
  1234. if (!prStaRec)
  1235. return;
  1236. ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  1237. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex];
  1238. ASSERT(prStaRec == prBssInfo->prStaRecOfAP);
  1239. /* To do: the invoked function is used to clear all members. It may be
  1240. * done by center mechanism in invoker.
  1241. */
  1242. rlmBssReset(prAdapter, prBssInfo);
  1243. prBssInfo->fgUseShortSlotTime = (prBssInfo->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME) ? TRUE : FALSE;
  1244. ucPriChannel = rlmRecIeInfoForClient(prAdapter, prBssInfo, pucIE, u2IELength);
  1245. if (ucPriChannel > 0)
  1246. prBssInfo->ucPrimaryChannel = ucPriChannel;
  1247. if (!RLM_NET_IS_11N(prBssInfo) || !(prStaRec->u2HtCapInfo & HT_CAP_INFO_SUP_CHNL_WIDTH))
  1248. prBssInfo->fg40mBwAllowed = FALSE;
  1249. /* Note: Update its capabilities to WTBL by cnmStaRecChangeState(), which
  1250. * shall be invoked afterwards.
  1251. * Update channel, bandwidth and protection mode by nicUpdateBss()
  1252. */
  1253. #if 1
  1254. if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
  1255. DBGLOG(P2P, WARN, "Force P2P BW to 20\n");
  1256. prBssInfo->fgAssoc40mBwAllowed = FALSE;
  1257. }
  1258. #endif
  1259. }
  1260. /*----------------------------------------------------------------------------*/
  1261. /*!
  1262. * \brief This function should be invoked after judging successful association.
  1263. *
  1264. * \param[in]
  1265. *
  1266. * \return none
  1267. */
  1268. /*----------------------------------------------------------------------------*/
  1269. VOID rlmFillSyncCmdParam(P_CMD_SET_BSS_RLM_PARAM_T prCmdBody, P_BSS_INFO_T prBssInfo)
  1270. {
  1271. ASSERT(prCmdBody && prBssInfo);
  1272. if (!prCmdBody || !prBssInfo)
  1273. return;
  1274. prCmdBody->ucNetTypeIndex = prBssInfo->ucNetTypeIndex;
  1275. prCmdBody->ucRfBand = (UINT_8) prBssInfo->eBand;
  1276. prCmdBody->ucPrimaryChannel = prBssInfo->ucPrimaryChannel;
  1277. prCmdBody->ucRfSco = (UINT_8) prBssInfo->eBssSCO;
  1278. prCmdBody->ucErpProtectMode = (UINT_8) prBssInfo->fgErpProtectMode;
  1279. prCmdBody->ucHtProtectMode = (UINT_8) prBssInfo->eHtProtectMode;
  1280. prCmdBody->ucGfOperationMode = (UINT_8) prBssInfo->eGfOperationMode;
  1281. prCmdBody->ucTxRifsMode = (UINT_8) prBssInfo->eRifsOperationMode;
  1282. prCmdBody->u2HtOpInfo3 = prBssInfo->u2HtOpInfo3;
  1283. prCmdBody->u2HtOpInfo2 = prBssInfo->u2HtOpInfo2;
  1284. prCmdBody->ucHtOpInfo1 = prBssInfo->ucHtOpInfo1;
  1285. prCmdBody->ucUseShortPreamble = prBssInfo->fgUseShortPreamble;
  1286. prCmdBody->ucUseShortSlotTime = prBssInfo->fgUseShortSlotTime;
  1287. prCmdBody->ucCheckId = 0x72;
  1288. if (RLM_NET_PARAM_VALID(prBssInfo)) {
  1289. DBGLOG(RLM, INFO, "N=%d b=%d c=%d s=%d e=%d h=%d I=0x%02x l=%d p=%d\n",
  1290. prCmdBody->ucNetTypeIndex, prCmdBody->ucRfBand,
  1291. prCmdBody->ucPrimaryChannel, prCmdBody->ucRfSco,
  1292. prCmdBody->ucErpProtectMode, prCmdBody->ucHtProtectMode,
  1293. prCmdBody->ucHtOpInfo1, prCmdBody->ucUseShortSlotTime,
  1294. prCmdBody->ucUseShortPreamble);
  1295. } else {
  1296. DBGLOG(RLM, TRACE, "N=%d closed\n", prCmdBody->ucNetTypeIndex);
  1297. }
  1298. }
  1299. /*----------------------------------------------------------------------------*/
  1300. /*!
  1301. * \brief This function will operation parameters based on situations of
  1302. * concurrent networks. Channel, bandwidth, protection mode, supported
  1303. * rate will be modified.
  1304. *
  1305. * \param[in]
  1306. *
  1307. * \return none
  1308. */
  1309. /*----------------------------------------------------------------------------*/
  1310. VOID rlmSyncOperationParams(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo)
  1311. {
  1312. P_CMD_SET_BSS_RLM_PARAM_T prCmdBody;
  1313. WLAN_STATUS rStatus;
  1314. ASSERT(prAdapter);
  1315. ASSERT(prBssInfo);
  1316. prCmdBody = (P_CMD_SET_BSS_RLM_PARAM_T)
  1317. cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_BSS_RLM_PARAM_T));
  1318. ASSERT(prCmdBody);
  1319. /* To do: exception handle */
  1320. if (!prCmdBody) {
  1321. DBGLOG(RLM, WARN, "No buf for sync RLM params (Net=%d)\n", prBssInfo->ucNetTypeIndex);
  1322. return;
  1323. }
  1324. rlmFillSyncCmdParam(prCmdBody, prBssInfo);
  1325. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  1326. CMD_ID_SET_BSS_RLM_PARAM, /* ucCID */
  1327. TRUE, /* fgSetQuery */
  1328. FALSE, /* fgNeedResp */
  1329. FALSE, /* fgIsOid */
  1330. NULL, /* pfCmdDoneHandler */
  1331. NULL, /* pfCmdTimeoutHandler */
  1332. sizeof(CMD_SET_BSS_RLM_PARAM_T), /* u4SetQueryInfoLen */
  1333. (PUINT_8) prCmdBody, /* pucInfoBuffer */
  1334. NULL, /* pvSetQueryBuffer */
  1335. 0 /* u4SetQueryBufferLen */
  1336. );
  1337. ASSERT(rStatus == WLAN_STATUS_PENDING);
  1338. cnmMemFree(prAdapter, prCmdBody);
  1339. }
  1340. #if CFG_SUPPORT_AAA
  1341. /*----------------------------------------------------------------------------*/
  1342. /*!
  1343. * \brief This function should be invoked after judging successful association.
  1344. *
  1345. * \param[in]
  1346. *
  1347. * \return none
  1348. */
  1349. /*----------------------------------------------------------------------------*/
  1350. VOID rlmProcessAssocReq(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb, PUINT_8 pucIE, UINT_16 u2IELength)
  1351. {
  1352. P_BSS_INFO_T prBssInfo;
  1353. P_STA_RECORD_T prStaRec;
  1354. UINT_16 u2Offset;
  1355. P_IE_HT_CAP_T prHtCap;
  1356. ASSERT(prAdapter);
  1357. ASSERT(prSwRfb);
  1358. ASSERT(pucIE);
  1359. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1360. ASSERT(prStaRec);
  1361. if (!prStaRec)
  1362. return;
  1363. ASSERT(prStaRec->ucNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  1364. prBssInfo = &prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex];
  1365. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  1366. switch (IE_ID(pucIE)) {
  1367. case ELEM_ID_HT_CAP:
  1368. if (!RLM_NET_IS_11N(prBssInfo) || IE_LEN(pucIE) != (sizeof(IE_HT_CAP_T) - 2))
  1369. break;
  1370. prHtCap = (P_IE_HT_CAP_T) pucIE;
  1371. prStaRec->ucMcsSet = prHtCap->rSupMcsSet.aucRxMcsBitmask[0];
  1372. prStaRec->fgSupMcs32 = (prHtCap->rSupMcsSet.aucRxMcsBitmask[32 / 8] & BIT(0)) ? TRUE : FALSE;
  1373. prStaRec->u2HtCapInfo = prHtCap->u2HtCapInfo;
  1374. prStaRec->ucAmpduParam = prHtCap->ucAmpduParam;
  1375. prStaRec->u2HtExtendedCap = prHtCap->u2HtExtendedCap;
  1376. prStaRec->u4TxBeamformingCap = prHtCap->u4TxBeamformingCap;
  1377. prStaRec->ucAselCap = prHtCap->ucAselCap;
  1378. break;
  1379. default:
  1380. break;
  1381. } /* end of switch */
  1382. } /* end of IE_FOR_EACH */
  1383. }
  1384. #endif /* CFG_SUPPORT_AAA */
  1385. /*----------------------------------------------------------------------------*/
  1386. /*!
  1387. * \brief It is for both STA and AP modes
  1388. *
  1389. * \param[in]
  1390. *
  1391. * \return none
  1392. */
  1393. /*----------------------------------------------------------------------------*/
  1394. VOID rlmBssInitForAPandIbss(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo)
  1395. {
  1396. ASSERT(prAdapter);
  1397. ASSERT(prBssInfo);
  1398. #if CFG_ENABLE_WIFI_DIRECT
  1399. if (prAdapter->fgIsP2PRegistered && prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)
  1400. rlmBssInitForAP(prAdapter, prBssInfo);
  1401. #endif
  1402. }
  1403. /*----------------------------------------------------------------------------*/
  1404. /*!
  1405. * \brief It is for both STA and AP modes
  1406. *
  1407. * \param[in]
  1408. *
  1409. * \return none
  1410. */
  1411. /*----------------------------------------------------------------------------*/
  1412. VOID rlmBssAborted(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo)
  1413. {
  1414. ASSERT(prAdapter);
  1415. ASSERT(prBssInfo);
  1416. rlmBssReset(prAdapter, prBssInfo);
  1417. prBssInfo->fg40mBwAllowed = FALSE;
  1418. prBssInfo->fgAssoc40mBwAllowed = FALSE;
  1419. /* Assume FW state is updated by CMD_ID_SET_BSS_INFO, so
  1420. * the sync CMD is not needed here.
  1421. */
  1422. }
  1423. /*----------------------------------------------------------------------------*/
  1424. /*!
  1425. * \brief All RLM timers will also be stopped.
  1426. *
  1427. * \param[in]
  1428. *
  1429. * \return none
  1430. */
  1431. /*----------------------------------------------------------------------------*/
  1432. static VOID rlmBssReset(P_ADAPTER_T prAdapter, P_BSS_INFO_T prBssInfo)
  1433. {
  1434. ASSERT(prAdapter);
  1435. ASSERT(prBssInfo);
  1436. /* HT related parameters */
  1437. prBssInfo->ucHtOpInfo1 = 0; /* RIFS disabled. 20MHz */
  1438. prBssInfo->u2HtOpInfo2 = 0;
  1439. prBssInfo->u2HtOpInfo3 = 0;
  1440. prBssInfo->eBssSCO = 0;
  1441. prBssInfo->fgErpProtectMode = 0;
  1442. prBssInfo->eHtProtectMode = 0;
  1443. prBssInfo->eGfOperationMode = 0;
  1444. prBssInfo->eRifsOperationMode = 0;
  1445. /* OBSS related parameters */
  1446. prBssInfo->auc2G_20mReqChnlList[0] = 0;
  1447. prBssInfo->auc2G_NonHtChnlList[0] = 0;
  1448. prBssInfo->auc2G_PriChnlList[0] = 0;
  1449. prBssInfo->auc2G_SecChnlList[0] = 0;
  1450. prBssInfo->auc5G_20mReqChnlList[0] = 0;
  1451. prBssInfo->auc5G_NonHtChnlList[0] = 0;
  1452. prBssInfo->auc5G_PriChnlList[0] = 0;
  1453. prBssInfo->auc5G_SecChnlList[0] = 0;
  1454. /* All RLM timers will also be stopped */
  1455. cnmTimerStopTimer(prAdapter, &prBssInfo->rObssScanTimer);
  1456. prBssInfo->u2ObssScanInterval = 0;
  1457. prBssInfo->fgObssErpProtectMode = 0; /* GO only */
  1458. prBssInfo->eObssHtProtectMode = 0; /* GO only */
  1459. prBssInfo->eObssGfOperationMode = 0; /* GO only */
  1460. prBssInfo->fgObssRifsOperationMode = 0; /* GO only */
  1461. prBssInfo->fgObssActionForcedTo20M = 0; /* GO only */
  1462. prBssInfo->fgObssBeaconForcedTo20M = 0; /* GO only */
  1463. }
  1464. #if CFG_SUPPORT_DFS /* Add by Enlai */
  1465. /*----------------------------------------------------------------------------*/
  1466. /*!
  1467. * \brief This function handle spectrum management action frame
  1468. *
  1469. * \param[in]
  1470. *
  1471. * \return none
  1472. */
  1473. /*----------------------------------------------------------------------------*/
  1474. VOID rlmProcessSpecMgtAction(P_ADAPTER_T prAdapter, P_SW_RFB_T prSwRfb)
  1475. {
  1476. P_ACTION_CHANNEL_SWITCH_FRAME prRxFrame;
  1477. ASSERT(prAdapter);
  1478. ASSERT(prSwRfb);
  1479. DBGLOG(RLM, INFO, "[5G DFS]rlmProcessSpecMgtAction \r\n");
  1480. prRxFrame = (P_ACTION_CHANNEL_SWITCH_FRAME) prSwRfb->pvHeader;
  1481. DBGLOG(RLM, INFO, "[5G DFS]prRxFrame->ucAction[%d] \r\n", prRxFrame->ucAction);
  1482. if (prRxFrame->ucAction == ACTION_CHNL_SWITCH)
  1483. rlmProcessChannelSwitchIE(prAdapter, (P_IE_CHANNEL_SWITCH_T) prRxFrame->aucInfoElem);
  1484. }
  1485. /*----------------------------------------------------------------------------*/
  1486. /*!
  1487. * \brief This function process Channel Switch IE
  1488. *
  1489. * \param[in]
  1490. *
  1491. * \return none
  1492. */
  1493. /*----------------------------------------------------------------------------*/
  1494. VOID rlmProcessChannelSwitchIE(P_ADAPTER_T prAdapter, P_IE_CHANNEL_SWITCH_T prChannelSwitchIE)
  1495. {
  1496. P_BSS_INFO_T prAisBssInfo;
  1497. ASSERT(prAdapter);
  1498. ASSERT(prChannelSwitchIE);
  1499. DBGLOG(RLM, INFO, "[5G DFS] rlmProcessChannelSwitchIE \r\n");
  1500. DBGLOG(RLM, INFO, "[5G DFS] ucChannelSwitchMode[%d], ucChannelSwitchCount[%d], ucNewChannelNum[%d] \r\n",
  1501. prChannelSwitchIE->ucChannelSwitchMode,
  1502. prChannelSwitchIE->ucChannelSwitchCount, prChannelSwitchIE->ucNewChannelNum);
  1503. if (prChannelSwitchIE->ucChannelSwitchMode == 1) {
  1504. prAisBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1505. DBGLOG(RLM, INFO, "[5G DFS] switch channel [%d]->[%d] \r\n", prAisBssInfo->ucPrimaryChannel,
  1506. prChannelSwitchIE->ucNewChannelNum);
  1507. prAisBssInfo->ucPrimaryChannel = prChannelSwitchIE->ucNewChannelNum;
  1508. nicUpdateBss(prAdapter, prAisBssInfo->ucNetTypeIndex);
  1509. }
  1510. }
  1511. #endif
  1512. #if (CFG_SUPPORT_TXR_ENC == 1)
  1513. VOID
  1514. rlmTxRateEnhanceConfig(
  1515. P_ADAPTER_T prAdapter
  1516. )
  1517. {
  1518. P_GLUE_INFO_T prGlueInfo;
  1519. WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
  1520. CMD_RLM_INFO_T rTxRInfo;
  1521. UINT_32 u4SetInfoLen = 0;
  1522. /* init */
  1523. prGlueInfo = prAdapter->prGlueInfo;
  1524. /* suggestion from Tsaiyuan.Hsu */
  1525. kalMemZero(&rTxRInfo, sizeof(CMD_RLM_INFO_T));
  1526. rTxRInfo.fgIsErrRatioEnhanceApplied = TRUE;
  1527. rTxRInfo.ucErrRatio2LimitMinRate = 3;
  1528. rTxRInfo.ucMinLegacyRateIdx = 2;
  1529. rTxRInfo.cMinRssiThreshold = -60;
  1530. rTxRInfo.fgIsRtsApplied = TRUE;
  1531. rTxRInfo.ucRecoverTime = 60;
  1532. DBGLOG(RLM, INFO, "Enable tx rate enhance function\n");
  1533. rStatus = kalIoctl(prGlueInfo,
  1534. wlanoidSetTxRateInfo,
  1535. &rTxRInfo,
  1536. sizeof(rTxRInfo),
  1537. TRUE,
  1538. TRUE,
  1539. TRUE,
  1540. FALSE,
  1541. &u4SetInfoLen);
  1542. if (rStatus != WLAN_STATUS_SUCCESS)
  1543. DBGLOG(RLM, WARN, "set tx rate advance info fail 0x%lx\n", rStatus);
  1544. }
  1545. /*----------------------------------------------------------------------------*/
  1546. /*! \brief This routine is called to send a command to TX Auto Rate module.
  1547. *
  1548. * \param[in] prGlueInfo Pointer to the Adapter structure
  1549. * \param[in] prInBuf A pointer to the command string buffer
  1550. * \param[in] u4InBufLen The length of the buffer
  1551. * \param[out] None
  1552. *
  1553. * \retval None
  1554. */
  1555. /*----------------------------------------------------------------------------*/
  1556. VOID
  1557. rlmCmd(P_GLUE_INFO_T prGlueInfo, UINT_8 *prInBuf, UINT_32 u4InBufLen)
  1558. {
  1559. UINT_32 u4Subcmd;
  1560. /* parse TAR sub-command */
  1561. u4Subcmd = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1562. DBGLOG(RLM, INFO, "<tar_cmd> sub command = %u\n", (UINT32)u4Subcmd);
  1563. /* handle different sub-command */
  1564. switch (u4Subcmd) {
  1565. case 0x00: /* configure */
  1566. /* iwpriv wlan0 set_str_cmd 1_0_0_1_3_2_60_1_60 */
  1567. WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
  1568. CMD_RLM_INFO_T rTxRInfo;
  1569. UINT_32 u4SetInfoLen = 0;
  1570. kalMemZero(&rTxRInfo, sizeof(CMD_RLM_INFO_T));
  1571. rTxRInfo.u4Version = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1572. rTxRInfo.fgIsErrRatioEnhanceApplied = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1573. rTxRInfo.ucErrRatio2LimitMinRate = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1574. rTxRInfo.ucMinLegacyRateIdx = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1575. rTxRInfo.cMinRssiThreshold = 0 - CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1576. rTxRInfo.fgIsRtsApplied = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1577. rTxRInfo.ucRecoverTime = CmdStringDecParse(prInBuf, &prInBuf, &u4InBufLen);
  1578. DBGLOG(RLM, INFO, "<tar_cmd> rlmCmd = %u %u %u %u %d %u %u\n",
  1579. rTxRInfo.u4Version,
  1580. rTxRInfo.fgIsErrRatioEnhanceApplied,
  1581. rTxRInfo.ucErrRatio2LimitMinRate,
  1582. rTxRInfo.ucMinLegacyRateIdx,
  1583. rTxRInfo.cMinRssiThreshold,
  1584. rTxRInfo.fgIsRtsApplied,
  1585. rTxRInfo.ucRecoverTime));
  1586. rStatus = kalIoctl(prGlueInfo,
  1587. wlanoidSetTxRateInfo,
  1588. &rTxRInfo,
  1589. sizeof(rTxRInfo),
  1590. TRUE,
  1591. TRUE,
  1592. TRUE,
  1593. FALSE,
  1594. &u4SetInfoLen);
  1595. break;
  1596. default:
  1597. break;
  1598. }
  1599. }
  1600. #endif /* CFG_SUPPORT_TXR_ENC */