assoc.c 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/assoc.c#5
  3. */
  4. /*! \file "assoc.c"
  5. \brief This file includes the association-related functions.
  6. This file includes the association-related functions.
  7. */
  8. /*\
  9. ** Log: assoc.c
  10. **
  11. ** 08 30 2013 yuche.tsai
  12. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  13. ** Fix Wi-Fi Direct Tx Probe Request Channel Bug.
  14. **
  15. ** 08 13 2013 terry.wu
  16. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  17. ** Remove unused code
  18. **
  19. ** 08 05 2013 terry.wu
  20. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  21. ** 1. Add SW rate definition
  22. ** 2. Add HW default rate selection logic from FW
  23. **
  24. ** 07 30 2013 yuche.tsai
  25. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  26. ** Driver update for Hot-Spot mode.
  27. **
  28. ** 07 23 2013 wh.su
  29. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  30. ** Sync the latest jb2.mp 11w code as draft version
  31. ** Not the CM bit for avoid wapi 1x drop at re-key
  32. **
  33. ** 07 12 2013 terry.wu
  34. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  35. ** 1. Update VHT IE composing function
  36. ** 2. disable bow
  37. ** 3. Exchange bss/sta rec update sequence for temp solution
  38. **
  39. ** 03 12 2013 tsaiyuan.hsu
  40. ** [BORA00002222] MT6630 unified MAC RXM
  41. ** remove hif_rx_hdr usage.
  42. **
  43. ** 03 12 2013 terry.wu
  44. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  45. ** Update Tx utility function for management frame
  46. **
  47. ** 03 08 2013 wh.su
  48. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  49. ** Remove non-used compiling flag and code
  50. **
  51. ** 03 06 2013 wh.su
  52. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  53. ** submit some code related with security.
  54. **
  55. ** 02 19 2013 cp.wu
  56. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  57. ** take use of GET_BSS_INFO_BY_INDEX() and MAX_BSS_INDEX macros
  58. ** for correctly indexing of BSS-INFO pointers
  59. **
  60. ** 02 19 2013 cp.wu
  61. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  62. ** correct typo and fix for compilation pass
  63. **
  64. ** 02 19 2013 cp.wu
  65. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  66. ** enable AIS related management modules building under Android/Linux
  67. **
  68. ** 01 22 2013 cp.wu
  69. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  70. ** modification for ucBssIndex migration
  71. **
  72. ** 01 07 2013 terry.wu
  73. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  74. ** <saved by Perforce>
  75. ** Fix reassoc req issue
  76. **
  77. ** 11 06 2012 eason.tsai
  78. ** [BORA00002255] [MT6630 Wi-Fi][Driver] develop
  79. ** .
  80. **
  81. ** 09 17 2012 cm.chang
  82. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  83. ** Duplicate source from MT6620 v2.3 driver branch
  84. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  85. **
  86. ** 08 08 2012 wh.su
  87. ** [WCXRP00001262] [MT6620 Wi-Fi][Driver] Fixed the update assoc info pkt length issue
  88. ** fixed the assoc request update ie length.
  89. **
  90. ** 07 27 2012 yuche.tsai
  91. ** NULL
  92. ** Fix wifi direct connection issue.
  93. ** Assoc Req no P2P IE.
  94. *
  95. * 07 17 2012 yuche.tsai
  96. * NULL
  97. * Let netdev bring up.
  98. *
  99. * 07 17 2012 yuche.tsai
  100. * NULL
  101. * Compile no error before trial run.
  102. *
  103. * 06 13 2012 yuche.tsai
  104. * NULL
  105. * Update maintrunk driver.
  106. * Add support for driver compose assoc request frame.
  107. *
  108. * 06 08 2012 cp.wu
  109. * [WCXRP00001245] [MT6620 Wi-Fi][Driver][Firmware] NPS Software Development
  110. * add a pair of brace for compilation success.
  111. *
  112. * 06 04 2012 cp.wu
  113. * [WCXRP00001245] [MT6620 Wi-Fi][Driver][Firmware] NPS Software Development
  114. *
  115. *
  116. * 03 14 2012 wh.su
  117. * [WCXRP00001173] [MT6620 Wi-Fi][Driver] Adding the ICS Tethering WPA2-PSK supporting
  118. * Add code from 2.2
  119. *
  120. * 03 09 2012 terry.wu
  121. * NULL
  122. * Fix build error.
  123. *
  124. * 03 02 2012 terry.wu
  125. * NULL
  126. * Sync CFG80211 modification from branch 2,2.
  127. *
  128. * 01 16 2012 yuche.tsai
  129. * NULL
  130. * Update Driver for wifi driect gc join IE update issue.
  131. *
  132. * 11 10 2011 wh.su
  133. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  134. * change the debug module level.
  135. *
  136. * 10 25 2011 cm.chang
  137. * [WCXRP00001058] [All Wi-Fi][Driver] Fix sta_rec's phyTypeSet and OBSS scan in AP mode
  138. * Fix PhyTypeSet in STA_REC in AP mode
  139. *
  140. * 10 12 2011 wh.su
  141. * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
  142. * adding the 802.11w related function and define .
  143. *
  144. * 09 19 2011 yuche.tsai
  145. * NULL
  146. * Fix KE when enable hot-spot & any one client connect to this hot-spot.
  147. *
  148. * 09 14 2011 yuche.tsai
  149. * NULL
  150. * Add P2P IE in assoc response.
  151. *
  152. * 07 15 2011 terry.wu
  153. * [WCXRP00000855] [MT6620 Wi-Fi] [Driver] Workaround for Kingnet 710 AP wrong AID assignment
  154. * Update workaround for Kingnet AP.
  155. *
  156. * 07 15 2011 terry.wu
  157. * [WCXRP00000855] [MT6620 Wi-Fi] [Driver] Workaround for Kingnet 710 AP wrong AID assignment
  158. * Workaround for Kingnet 710 AP wrong AID assignment.
  159. *
  160. * 05 02 2011 eddie.chen
  161. *
  162. * Check STA when rx assoc.
  163. *
  164. * 04 18 2011 terry.wu
  165. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  166. * Remove flag CFG_WIFI_DIRECT_MOVED.
  167. *
  168. * 03 19 2011 yuche.tsai
  169. * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
  170. * Make assoc req to append P2P IE if wifi direct is enabled.
  171. *
  172. * 03 17 2011 chinglan.wang
  173. * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
  174. * .
  175. *
  176. * 03 16 2011 wh.su
  177. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  178. * enable the protected while at P2P start GO, and skip some security check .
  179. *
  180. * 03 14 2011 wh.su
  181. *
  182. * Modify file for avoid assert at BOW receive a assoc response frame but no p2p function.
  183. *
  184. * 03 08 2011 terry.wu
  185. * [WCXRP00000524] [MT6620 Wi-Fi][Driver] Fix p2p assoc request containing wrong IE format
  186. * Fix p2p assoc request containing wrong IE format.
  187. *
  188. * 03 02 2011 wh.su
  189. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  190. * add code to let the beacon and probe response for Auto GO WSC .
  191. *
  192. * 02 15 2011 yuche.tsai
  193. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  194. * Fix RX disassoc issue under Hot-spot mode.
  195. *
  196. * 02 09 2011 wh.su
  197. * [WCXRP00000432] [MT6620 Wi-Fi][Driver] Add STA privacy check at hotspot mode
  198. * adding the code for check STA privacy bit at AP mode, .
  199. *
  200. * 02 08 2011 eddie.chen
  201. * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
  202. * Add event STA agint timeout
  203. *
  204. * 01 25 2011 yuche.tsai
  205. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  206. * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
  207. *
  208. * 01 12 2011 yuche.tsai
  209. *
  210. * Update Phy Type Set. When legacy client is connected, it can use 11b rate,
  211. * but if the P2P device is connected, 11b rate is not allowed.
  212. *
  213. * 01 11 2011 yuche.tsai
  214. *
  215. * Update Desired Non-HT Rate Set.
  216. *
  217. * 12 30 2010 eddie.chen
  218. * [WCXRP00000322] Add WMM IE in beacon,
  219. Add per station flow control when STA is in PS
  220. * Recover the code that was coverwritted..
  221. *
  222. * 12 29 2010 eddie.chen
  223. * [WCXRP00000322] Add WMM IE in beacon,
  224. Add per station flow control when STA is in PS
  225. * 1) PS flow control event
  226. *
  227. * 2) WMM IE in beacon, assoc resp, probe resp
  228. *
  229. * 11 04 2010 wh.su
  230. * [WCXRP00000164] [MT6620 Wi-Fi][Driver] Support the p2p random SSID
  231. * adding the p2p random ssid support.
  232. *
  233. * 10 18 2010 cp.wu
  234. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  235. * use definition macro to replace hard-coded constant
  236. *
  237. * 09 28 2010 wh.su
  238. * NULL
  239. * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
  240. *
  241. * 09 27 2010 chinghwa.yu
  242. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
  243. * Update BCM/BoW design and settings.
  244. *
  245. * 09 16 2010 cm.chang
  246. * NULL
  247. * Change conditional compiling options for BOW
  248. *
  249. * 09 03 2010 kevin.huang
  250. * NULL
  251. * Refine #include sequence and solve recursive/nested #include issue
  252. *
  253. * 09 01 2010 wh.su
  254. * NULL
  255. * adding the wapi support for integration test.
  256. *
  257. * 08 30 2010 cp.wu
  258. * NULL
  259. * eliminate klockwork errors
  260. *
  261. * 08 16 2010 yuche.tsai
  262. * NULL
  263. * Add SSID IE in assoc req frame which is sent by P2P GC.
  264. *
  265. * 08 16 2010 kevin.huang
  266. * NULL
  267. * Refine AAA functions
  268. *
  269. * 08 03 2010 cp.wu
  270. * NULL
  271. * surpress compilation warning.
  272. *
  273. * 07 20 2010 wh.su
  274. *
  275. * adding the wapi code.
  276. *
  277. * 07 09 2010 yarco.yang
  278. *
  279. * [MT6620 and MT5931] SW Migration: Add ADDBA support
  280. *
  281. * 07 08 2010 cp.wu
  282. *
  283. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  284. *
  285. * 07 08 2010 cp.wu
  286. * [WPD00003833][MT6620 and MT5931] Driver migration
  287. * take use of RLM module for parsing/generating HT IEs for 11n capability
  288. *
  289. * 07 01 2010 cp.wu
  290. * [WPD00003833][MT6620 and MT5931] Driver migration
  291. * comment out RSN IE generation by CFG_RSN_MIGRATION compilation flag.
  292. *
  293. * 06 28 2010 cp.wu
  294. * [WPD00003833][MT6620 and MT5931] Driver migration
  295. * send MMPDU in basic rate.
  296. *
  297. * 06 21 2010 cp.wu
  298. * [WPD00003833][MT6620 and MT5931] Driver migration
  299. * add scan_fsm into building.
  300. *
  301. * 06 21 2010 cp.wu
  302. * [WPD00003833][MT6620 and MT5931] Driver migration
  303. * specify correct value for management frames.
  304. *
  305. * 06 18 2010 cm.chang
  306. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  307. * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
  308. *
  309. * 06 18 2010 wh.su
  310. * [WPD00003840][MT6620 5931] Security migration
  311. * migration from MT6620 firmware.
  312. *
  313. * 06 15 2010 cp.wu
  314. * [WPD00003833][MT6620 and MT5931] Driver migration
  315. * revised.
  316. *
  317. * 06 14 2010 cp.wu
  318. * [WPD00003833][MT6620 and MT5931] Driver migration
  319. * add management dispatching function table.
  320. *
  321. * 06 11 2010 cp.wu
  322. * [WPD00003833][MT6620 and MT5931] Driver migration
  323. * auth.c is migrated.
  324. *
  325. * 06 11 2010 cp.wu
  326. * [WPD00003833][MT6620 and MT5931] Driver migration
  327. * 1) migrate assoc.c.
  328. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  329. * 3) add configuration options for CNM_MEM and RSN modules
  330. * 4) add data path for management frames
  331. * 5) eliminate rPacketInfo of MSDU_INFO_T
  332. *
  333. * 05 24 2010 kevin.huang
  334. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  335. * Update assocProcessRxAssocReqFrame() to avoid redundant SSID IE {0,0} for IOT.
  336. *
  337. * 05 14 2010 kevin.huang
  338. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  339. * Fix compile warning - macro > 10 line, initial value of an array
  340. *
  341. * 04 24 2010 cm.chang
  342. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  343. * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
  344. *
  345. * 04 22 2010 cm.chang
  346. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  347. * First draft code to support protection in AP mode
  348. *
  349. * 04 19 2010 kevin.huang
  350. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  351. * Add Beacon Timeout Support
  352. * * * * * * * * and will send Null frame to diagnose connection
  353. *
  354. * 04 16 2010 wh.su
  355. * [BORA00000680][MT6620] Support the statistic for Microsoft os query
  356. * adding the wpa-none for ibss beacon.
  357. *
  358. * 03 25 2010 cm.chang
  359. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  360. * Remove compiling warning
  361. *
  362. * 03 24 2010 cm.chang
  363. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  364. * Not carry HT cap when being associated with b/g only AP
  365. *
  366. * 02 04 2010 kevin.huang
  367. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  368. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  369. *
  370. * 01 28 2010 wh.su
  371. * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
  372. * fixed the compiling warning.u1rwduu`wvpghlqg|rm+vp
  373. *
  374. * 01 27 2010 wh.su
  375. * [BORA00000476][Wi-Fi][firmware] Add the security module initialize code
  376. * add and fixed some security function.
  377. *
  378. * 01 11 2010 kevin.huang
  379. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  380. * Add Deauth and Disassoc Handler
  381. *
  382. * 01 07 2010 kevin.huang
  383. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  384. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  385. * Update Assoc ID for PS
  386. *
  387. * 01 04 2010 tehuang.liu
  388. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  389. * For working out the first connection Chariot-verified version
  390. *
  391. * 12 18 2009 cm.chang
  392. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  393. * .
  394. *
  395. * Dec 12 2009 mtk01104
  396. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  397. * Use new constant definition ELEM_MAX_LEN_EXT_CAP
  398. *
  399. * Dec 9 2009 mtk01104
  400. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  401. * Modify assoc req IE talbe for HT cap IE
  402. *
  403. * Dec 7 2009 mtk01461
  404. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  405. * update the assocComposeReAssocReqFrameHeader() and fix the u2EstimatedFrameLen in assocSendReAssocReqFrame()
  406. *
  407. * Dec 7 2009 mtk01088
  408. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  409. * remove some space line
  410. *
  411. * Dec 7 2009 mtk01088
  412. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  413. * adding the sending disassoc frame function
  414. *
  415. * Dec 4 2009 mtk01088
  416. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  417. * adding the txassocReq IE table, adding for WPA/RSN
  418. *
  419. * Dec 3 2009 mtk01461
  420. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  421. * Fix eNetType not init in send AssocReq function
  422. *
  423. * Dec 3 2009 mtk01461
  424. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  425. * Integrate the send Assoc with TXM
  426. *
  427. * Dec 1 2009 mtk01088
  428. * [BORA00000476] [Wi-Fi][firmware] Add the security module initialize code
  429. * adding the code to indicate the assoc request and assoc response (now disable)
  430. *
  431. * Nov 24 2009 mtk01461
  432. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  433. * Remove unused variables
  434. *
  435. * Nov 23 2009 mtk01461
  436. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  437. *
  438. */
  439. /*******************************************************************************
  440. * C O M P I L E R F L A G S
  441. ********************************************************************************
  442. */
  443. /*******************************************************************************
  444. * E X T E R N A L R E F E R E N C E S
  445. ********************************************************************************
  446. */
  447. #include "precomp.h"
  448. /*******************************************************************************
  449. * C O N S T A N T S
  450. ********************************************************************************
  451. */
  452. /*******************************************************************************
  453. * D A T A T Y P E S
  454. ********************************************************************************
  455. */
  456. /*******************************************************************************
  457. * P U B L I C D A T A
  458. ********************************************************************************
  459. */
  460. APPEND_VAR_IE_ENTRY_T txAssocReqIETable[] = {
  461. {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmReqGenerateHtCapIE}
  462. , /* 45 */
  463. #if CFG_SUPPORT_WPS2
  464. {(ELEM_HDR_LEN + ELEM_MAX_LEN_WSC), NULL, rsnGenerateWSCIE}
  465. , /* 221 */
  466. #endif
  467. #if CFG_SUPPORT_WAPI
  468. {(ELEM_HDR_LEN + ELEM_MAX_LEN_WAPI), NULL, wapiGenerateWAPIIE}
  469. , /* 68 */
  470. #endif
  471. #if CFG_SUPPORT_PASSPOINT
  472. {(ELEM_HDR_LEN + ELEM_MAX_LEN_INTERWORKING), NULL, hs20GenerateInterworkingIE}
  473. , /* 107 */
  474. {(ELEM_HDR_LEN + ELEM_MAX_LEN_ROAMING_CONSORTIUM), NULL, hs20GenerateRoamingConsortiumIE}
  475. , /* 111 */
  476. {(ELEM_HDR_LEN + ELEM_MAX_LEN_HS20_INDICATION), NULL, hs20GenerateHS20IE}
  477. , /* 221 */
  478. #endif /* CFG_SUPPORT_PASSPOINT */
  479. {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWPAIE}
  480. , /* 221 */
  481. {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmReqGenerateExtCapIE}
  482. , /* 127 */
  483. {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_INFO), NULL, mqmGenerateWmmInfoIE}
  484. , /* 221 */
  485. {(ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE}
  486. , /* 48 */
  487. #if CFG_SUPPORT_802_11AC
  488. {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_CAP), NULL, rlmReqGenerateVhtCapIE}
  489. , /*191 */
  490. #endif
  491. #if CFG_SUPPORT_MTK_SYNERGY
  492. {(ELEM_HDR_LEN + ELEM_MIN_LEN_MTK_OUI), NULL, rlmGenerateMTKOuiIE} /* 221 */
  493. #endif
  494. };
  495. #if CFG_SUPPORT_AAA
  496. VERIFY_IE_ENTRY_T rxAssocReqIETable[] = {
  497. {ELEM_ID_RESERVED, NULL} /* 255 */
  498. };
  499. APPEND_VAR_IE_ENTRY_T txAssocRespIETable[] = {
  500. {(ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE}
  501. , /* 42 */
  502. {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE}
  503. , /* 45 */
  504. {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE}
  505. , /* 61 */
  506. #if CFG_ENABLE_WIFI_DIRECT
  507. {(ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE}
  508. , /* 74 */
  509. {(0), p2pFuncCalculateP2p_IELenForAssocRsp, p2pFuncGenerateP2p_IEForAssocRsp}
  510. , /* 221 */
  511. #if (CFG_SUPPORT_WFD)
  512. {(0), wfdFuncCalculateWfdIELenForAssocRsp, wfdFuncGenerateWfdIEForAssocRsp}
  513. , /* 221 */
  514. #endif
  515. #endif
  516. {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE}
  517. , /* 127 */
  518. #if CFG_SUPPORT_802_11AC
  519. {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_CAP), NULL, rlmRspGenerateVhtCapIE}
  520. , /*191 */
  521. {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_OP), NULL, rlmRspGenerateVhtOpIE}
  522. , /*192 */
  523. #endif
  524. {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE}
  525. , /* 221 */
  526. {(ELEM_HDR_LEN + ELEM_MAX_LEN_ASSOC_RSP_WSC_IE), NULL, rsnGenerateWSCIEForAssocRsp}
  527. , /* 221 */
  528. #if CFG_SUPPORT_MTK_SYNERGY
  529. {(ELEM_HDR_LEN + ELEM_MIN_LEN_MTK_OUI), NULL, rlmGenerateMTKOuiIE} /* 221 */
  530. #endif
  531. };
  532. #endif /* CFG_SUPPORT_AAA */
  533. /*******************************************************************************
  534. * P R I V A T E D A T A
  535. ********************************************************************************
  536. */
  537. /*******************************************************************************
  538. * M A C R O S
  539. ********************************************************************************
  540. */
  541. /*******************************************************************************
  542. * F U N C T I O N D E C L A R A T I O N S
  543. ********************************************************************************
  544. */
  545. /*******************************************************************************
  546. * F U N C T I O N S
  547. ********************************************************************************
  548. */
  549. /*----------------------------------------------------------------------------*/
  550. /*!
  551. * @brief This function is used to compose the Capability Info Field.
  552. *
  553. * @param[in] prStaRec Pointer to the STA_RECORD_T
  554. *
  555. * @retval Capability Info Field
  556. */
  557. /*----------------------------------------------------------------------------*/
  558. UINT_16 assocBuildCapabilityInfo(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  559. {
  560. UINT_32 u4NonHTPhyType;
  561. UINT_16 u2CapInfo;
  562. ASSERT(prStaRec);
  563. /* Set up our requested capabilities. */
  564. u2CapInfo = CAP_INFO_ESS;
  565. u2CapInfo |= CAP_CF_STA_NOT_POLLABLE;
  566. if (prStaRec->u2CapInfo & CAP_INFO_PRIVACY)
  567. u2CapInfo |= CAP_INFO_PRIVACY;
  568. /* 7.3.1.4 */
  569. if (prStaRec->fgHasBasicPhyType) {
  570. u4NonHTPhyType = prStaRec->ucNonHTBasicPhyType;
  571. if ((rNonHTPhyAttributes[u4NonHTPhyType].fgIsShortPreambleOptionImplemented) &&
  572. /* Short Preamble Option Enable is TRUE */
  573. ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) ||
  574. ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO) &&
  575. (prStaRec->u2CapInfo & CAP_INFO_SHORT_PREAMBLE)))) {
  576. /* Case I: Implemented == TRUE and Short Preamble Option Enable == TRUE.
  577. * Case II: Implemented == TRUE and Short Preamble == AUTO (depends on
  578. * BSS_DESC_T's capability)
  579. */
  580. u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
  581. }
  582. if (rNonHTPhyAttributes[u4NonHTPhyType].fgIsShortSlotTimeOptionImplemented &&
  583. prAdapter->rWifiVar.fgIsShortSlotTimeOptionEnable) {
  584. u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
  585. }
  586. }
  587. DBGLOG(SAA, LOUD, "ASSOC REQ: Compose Capability = 0x%04x for Target BSS [" MACSTR "].\n",
  588. u2CapInfo, MAC2STR(prStaRec->aucMacAddr));
  589. return u2CapInfo;
  590. } /* end of assocBuildCapabilityInfo() */
  591. /*----------------------------------------------------------------------------*/
  592. /*!
  593. * @brief This function is used to compose Common Information Elements for Association
  594. * Request Frame.
  595. *
  596. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  597. *
  598. * @return (none)
  599. */
  600. /*----------------------------------------------------------------------------*/
  601. __KAL_INLINE__ VOID assocBuildReAssocReqFrameCommonIEs(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  602. {
  603. P_CONNECTION_SETTINGS_T prConnSettings;
  604. P_STA_RECORD_T prStaRec;
  605. PUINT_8 pucBuffer;
  606. UINT_16 u2SupportedRateSet;
  607. UINT_8 aucAllSupportedRates[RATE_NUM_SW] = { 0 };
  608. UINT_8 ucAllSupportedRatesLen;
  609. UINT_8 ucSupRatesLen;
  610. UINT_8 ucExtSupRatesLen;
  611. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  612. ASSERT(prMsduInfo);
  613. ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
  614. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  615. ASSERT(prStaRec);
  616. if (!prStaRec)
  617. return;
  618. pucBuffer = (PUINT_8) ((ULONG) prMsduInfo->prPacket + (ULONG) prMsduInfo->u2FrameLength);
  619. ASSERT(pucBuffer);
  620. if (IS_STA_IN_AIS(prStaRec)) {
  621. /* Fill the SSID element. */
  622. SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
  623. /* NOTE(Kevin): We copy the SSID from CONNECTION_SETTINGS for the case of
  624. * Passive Scan and the target BSS didn't broadcast SSID on its Beacon Frame.
  625. */
  626. COPY_SSID(SSID_IE(pucBuffer)->aucSSID,
  627. SSID_IE(pucBuffer)->ucLength, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  628. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  629. pucBuffer += IE_SIZE(pucBuffer);
  630. }
  631. #if CFG_ENABLE_WIFI_DIRECT
  632. else if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec)))
  633. pucBuffer = p2pBuildReAssocReqFrameCommonIEs(prAdapter, prMsduInfo, pucBuffer);
  634. #endif
  635. #if CFG_ENABLE_BT_OVER_WIFI
  636. else if (IS_STA_BOW_TYPE(prStaRec)) {
  637. SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
  638. /* NOTE(Kevin): We copy the SSID from CONNECTION_SETTINGS for the case of
  639. * Passive Scan and the target BSS didn't broadcast SSID on its Beacon Frame.
  640. */
  641. COPY_SSID(SSID_IE(pucBuffer)->aucSSID,
  642. SSID_IE(pucBuffer)->ucLength, prConnSettings->aucSSID, prConnSettings->ucSSIDLen);
  643. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  644. pucBuffer += IE_SIZE(pucBuffer);
  645. }
  646. #endif
  647. /* NOTE(Kevin 2008/12/19): 16.3.6.3 MLME-ASSOCIATE.indication -
  648. * SupportedRates - The set of data rates that are supported by the STA
  649. * that is requesting association.
  650. * Original(Portable Driver): Only send the Rates that we'll support.
  651. * New: Send the Phy Rates if the result of following & operation == NULL.
  652. */
  653. /* rateGetDataRatesFromRateSet((prBssDesc->u2OperationalRateSet & */
  654. /* rPhyAttributes[prBssDesc->ePhyType].u2SupportedRateSet), */
  655. if (prStaRec->fgHasBasicPhyType) {
  656. UINT_32 u4NonHTPhyType;
  657. u4NonHTPhyType = prStaRec->ucNonHTBasicPhyType;
  658. u2SupportedRateSet = (prStaRec->u2OperationalRateSet &
  659. rNonHTPhyAttributes[u4NonHTPhyType].u2SupportedRateSet);
  660. ASSERT(u2SupportedRateSet);
  661. if (!u2SupportedRateSet)
  662. u2SupportedRateSet = rNonHTPhyAttributes[u4NonHTPhyType].u2SupportedRateSet;
  663. /* TODO(Kevin): For P2P, we shouldn't send support rate set which contains 11b rate */
  664. rateGetDataRatesFromRateSet(u2SupportedRateSet, 0, aucAllSupportedRates, &ucAllSupportedRatesLen);
  665. ucSupRatesLen = ((ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) ?
  666. ELEM_MAX_LEN_SUP_RATES : ucAllSupportedRatesLen);
  667. ucExtSupRatesLen = ucAllSupportedRatesLen - ucSupRatesLen;
  668. /* Fill the Supported Rates element. */
  669. if (ucSupRatesLen) {
  670. SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
  671. SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
  672. kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates, aucAllSupportedRates, ucSupRatesLen);
  673. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  674. pucBuffer += IE_SIZE(pucBuffer);
  675. }
  676. /* Fill the Extended Supported Rates element. */
  677. if (ucExtSupRatesLen) {
  678. EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
  679. EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
  680. kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
  681. &aucAllSupportedRates[ucSupRatesLen], ucExtSupRatesLen);
  682. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  683. pucBuffer += IE_SIZE(pucBuffer);
  684. }
  685. }
  686. } /* end of assocBuildReAssocReqFrameCommonIEs() */
  687. /*----------------------------------------------------------------------------*/
  688. /*!
  689. * @brief This function will compose the (Re)Association Request frame header and
  690. * its fixed fields
  691. *
  692. * @param[in] prStaRec Pointer to the STA_RECORD_T
  693. * @param[in] pucBuffer Pointer to the frame buffer.
  694. * @param[in] aucMACAddress Given Our MAC Address.
  695. * @param[in out] pu2PayloadLen Return the length of the composed fixed fields
  696. *
  697. * @return (none)
  698. */
  699. /*----------------------------------------------------------------------------*/
  700. __KAL_INLINE__ VOID
  701. assocComposeReAssocReqFrameHeaderAndFF(IN P_ADAPTER_T prAdapter,
  702. IN P_STA_RECORD_T prStaRec,
  703. IN PUINT_8 pucBuffer, IN UINT_8 aucMACAddress[], IN OUT PUINT_16 pu2PayloadLen)
  704. {
  705. P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
  706. BOOLEAN fgIsReAssoc;
  707. UINT_16 u2FrameCtrl;
  708. UINT_16 u2CapInfo;
  709. UINT_16 u2ListenInterval;
  710. ASSERT(prStaRec);
  711. ASSERT(pucBuffer);
  712. ASSERT(aucMACAddress);
  713. ASSERT(pu2PayloadLen);
  714. prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T) pucBuffer;
  715. fgIsReAssoc = prStaRec->fgIsReAssoc;
  716. /* 4 <1> Compose the frame header of the (Re)Association Request frame. */
  717. /* Fill the Frame Control field. */
  718. if (fgIsReAssoc)
  719. u2FrameCtrl = MAC_FRAME_REASSOC_REQ;
  720. else
  721. u2FrameCtrl = MAC_FRAME_ASSOC_REQ;
  722. WLAN_SET_FIELD_16(&prAssocFrame->u2FrameCtrl, u2FrameCtrl);
  723. /* Fill the DA field with Target BSSID. */
  724. COPY_MAC_ADDR(prAssocFrame->aucDestAddr, prStaRec->aucMacAddr);
  725. /* Fill the SA field with our MAC Address. */
  726. COPY_MAC_ADDR(prAssocFrame->aucSrcAddr, aucMACAddress);
  727. /* Fill the BSSID field with Target BSSID. */
  728. COPY_MAC_ADDR(prAssocFrame->aucBSSID, prStaRec->aucMacAddr);
  729. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  730. prAssocFrame->u2SeqCtrl = 0;
  731. /* 4 <2> Compose the frame body's common fixed field part of the (Re)Association Request frame. */
  732. u2CapInfo = assocBuildCapabilityInfo(prAdapter, prStaRec);
  733. /* Fill the Capability Information field. */
  734. WLAN_SET_FIELD_16(&prAssocFrame->u2CapInfo, u2CapInfo);
  735. /* Calculate the listen interval for the maximum power mode. Currently, we
  736. set it to the value 2 times DTIM period. */
  737. if (prStaRec->ucDTIMPeriod) {
  738. u2ListenInterval = prStaRec->ucDTIMPeriod * DEFAULT_LISTEN_INTERVAL_BY_DTIM_PERIOD;
  739. } else {
  740. DBGLOG(SAA, TRACE, "Use default listen interval\n");
  741. u2ListenInterval = DEFAULT_LISTEN_INTERVAL;
  742. }
  743. prStaRec->u2ListenInterval = u2ListenInterval;
  744. /* Fill the Listen Interval field. */
  745. WLAN_SET_FIELD_16(&prAssocFrame->u2ListenInterval, u2ListenInterval);
  746. /* 4 <3> Compose the Current AP Address field for ReAssociation Request frame. */
  747. /* Fill the Current AP Address field. */
  748. if (prStaRec->fgIsReAssoc) {
  749. if (IS_STA_IN_AIS(prStaRec)) {
  750. P_BSS_INFO_T prAisBssInfo = prAdapter->prAisBssInfo;
  751. P_WLAN_REASSOC_REQ_FRAME_T prReAssocFrame = (P_WLAN_REASSOC_REQ_FRAME_T) prAssocFrame;
  752. COPY_MAC_ADDR(prReAssocFrame->aucCurrentAPAddr, prAisBssInfo->aucBSSID);
  753. } else {
  754. ASSERT(0); /* We don't support ReAssociation for other network */
  755. }
  756. *pu2PayloadLen = (CAP_INFO_FIELD_LEN + LISTEN_INTERVAL_FIELD_LEN + CURR_AP_ADDR_FIELD_LEN);
  757. } else {
  758. *pu2PayloadLen = (CAP_INFO_FIELD_LEN + LISTEN_INTERVAL_FIELD_LEN);
  759. }
  760. } /* end of assocComposeReAssocReqFrame() */
  761. /*----------------------------------------------------------------------------*/
  762. /*!
  763. * @brief This function will send the (Re)Association Request frame
  764. *
  765. * @param[in] prStaRec Pointer to the STA_RECORD_T
  766. *
  767. * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
  768. * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
  769. */
  770. /*----------------------------------------------------------------------------*/
  771. WLAN_STATUS assocSendReAssocReqFrame(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  772. {
  773. P_MSDU_INFO_T prMsduInfo;
  774. P_BSS_INFO_T prBssInfo;
  775. UINT_16 u2PayloadLen;
  776. UINT_16 u2EstimatedFrameLen;
  777. UINT_16 u2EstimatedExtraIELen;
  778. BOOLEAN fgIsReAssoc;
  779. UINT_32 i;
  780. ASSERT(prStaRec);
  781. /* 4 <1> Allocate a PKT_INFO_T for Authentication Frame */
  782. fgIsReAssoc = prStaRec->fgIsReAssoc;
  783. /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Length */
  784. if (fgIsReAssoc) {
  785. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD +
  786. WLAN_MAC_MGMT_HEADER_LEN +
  787. CAP_INFO_FIELD_LEN +
  788. LISTEN_INTERVAL_FIELD_LEN +
  789. CURR_AP_ADDR_FIELD_LEN +
  790. (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) +
  791. (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + (ELEM_HDR_LEN + (RATE_NUM_SW - ELEM_MAX_LEN_SUP_RATES));
  792. } else {
  793. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD +
  794. WLAN_MAC_MGMT_HEADER_LEN +
  795. CAP_INFO_FIELD_LEN +
  796. LISTEN_INTERVAL_FIELD_LEN +
  797. (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) +
  798. (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + (ELEM_HDR_LEN + (RATE_NUM_SW - ELEM_MAX_LEN_SUP_RATES));
  799. }
  800. /* + Extra IE Length */
  801. u2EstimatedExtraIELen = 0;
  802. #if CFG_ENABLE_WIFI_DIRECT_CFG_80211 && CFG_ENABLE_WIFI_DIRECT
  803. if (IS_STA_IN_P2P(prStaRec)) {
  804. if ((prAdapter->fgIsP2PRegistered)) {
  805. u2EstimatedExtraIELen = p2pCalculate_IEForAssocReq(prAdapter, prStaRec->ucBssIndex, prStaRec);
  806. } else {
  807. DBGLOG(P2P, TRACE, "Function Linker Lost.\n");
  808. ASSERT(FALSE);
  809. }
  810. } else {
  811. for (i = 0; i < sizeof(txAssocReqIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  812. if (txAssocReqIETable[i].u2EstimatedFixedIELen != 0) {
  813. u2EstimatedExtraIELen += txAssocReqIETable[i].u2EstimatedFixedIELen;
  814. } else {
  815. u2EstimatedExtraIELen +=
  816. (UINT_16) txAssocReqIETable[i].pfnCalculateVariableIELen(prAdapter,
  817. prStaRec->ucBssIndex,
  818. prStaRec);
  819. }
  820. }
  821. }
  822. #else
  823. for (i = 0; i < sizeof(txAssocReqIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  824. if (txAssocReqIETable[i].u2EstimatedFixedIELen != 0) {
  825. u2EstimatedExtraIELen += txAssocReqIETable[i].u2EstimatedFixedIELen;
  826. } else {
  827. u2EstimatedExtraIELen +=
  828. (UINT_16) txAssocReqIETable[i].pfnCalculateVariableIELen(prAdapter,
  829. prStaRec->ucBssIndex, prStaRec);
  830. }
  831. }
  832. #endif
  833. ASSERT(prStaRec->ucBssIndex <= MAX_BSS_INDEX);
  834. u2EstimatedFrameLen += u2EstimatedExtraIELen;
  835. /* Allocate a MSDU_INFO_T */
  836. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  837. if (prMsduInfo == NULL) {
  838. DBGLOG(SAA, WARN, "No PKT_INFO_T for sending (Re)Assoc Request.\n");
  839. return WLAN_STATUS_RESOURCES;
  840. }
  841. /* 4 <2> Compose (Re)Association Request frame header and fixed fields in MSDU_INfO_T. */
  842. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  843. /* Compose Header and Fixed Field */
  844. assocComposeReAssocReqFrameHeaderAndFF(prAdapter,
  845. prStaRec,
  846. (PUINT_8) ((ULONG) (prMsduInfo->prPacket) +
  847. MAC_TX_RESERVED_FIELD),
  848. prBssInfo->aucOwnMacAddr, &u2PayloadLen);
  849. /* 4 <3> Update information of MSDU_INFO_T */
  850. TX_SET_MMPDU(prAdapter,
  851. prMsduInfo,
  852. prStaRec->ucBssIndex,
  853. prStaRec->ucIndex,
  854. WLAN_MAC_MGMT_HEADER_LEN,
  855. WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen, saaFsmRunEventTxDone, MSDU_RATE_MODE_AUTO);
  856. /* 4 <4> Compose the frame body's IEs of the (Re)Association Request frame. */
  857. assocBuildReAssocReqFrameCommonIEs(prAdapter, prMsduInfo);
  858. /* 4 <5> Compose IEs in MSDU_INFO_T */
  859. #if CFG_ENABLE_WIFI_DIRECT_CFG_80211 && CFG_ENABLE_WIFI_DIRECT
  860. if (IS_STA_IN_P2P(prStaRec)) {
  861. if ((prAdapter->fgIsP2PRegistered)) {
  862. p2pGenerate_IEForAssocReq(prAdapter, prMsduInfo);
  863. } else {
  864. DBGLOG(P2P, TRACE, "Function Linker Lost.\n");
  865. ASSERT(FALSE);
  866. }
  867. } else {
  868. /* Append IE */
  869. for (i = 0; i < sizeof(txAssocReqIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  870. if (txAssocReqIETable[i].pfnAppendIE)
  871. txAssocReqIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
  872. }
  873. }
  874. #else
  875. /* Append IE */
  876. for (i = 0; i < sizeof(txAssocReqIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  877. if (txAssocReqIETable[i].pfnAppendIE)
  878. txAssocReqIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
  879. }
  880. #endif
  881. /* 4 <6> Update the (Re)association request information */
  882. if (IS_STA_IN_AIS(prStaRec)) {
  883. P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
  884. prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T) ((ULONG) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
  885. kalUpdateReAssocReqInfo(prAdapter->prGlueInfo,
  886. (PUINT_8) &prAssocFrame->u2CapInfo,
  887. prMsduInfo->u2FrameLength - offsetof(WLAN_ASSOC_REQ_FRAME_T,
  888. u2CapInfo), fgIsReAssoc);
  889. }
  890. #if CFG_ENABLE_WIFI_DIRECT
  891. if ((prAdapter->fgIsP2PRegistered) && (IS_STA_IN_P2P(prStaRec))) {
  892. P_WLAN_ASSOC_REQ_FRAME_T prAssocFrame;
  893. prAssocFrame = (P_WLAN_ASSOC_REQ_FRAME_T) ((ULONG) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
  894. kalP2PUpdateAssocInfo(prAdapter->prGlueInfo,
  895. (PUINT_8) &prAssocFrame->u2CapInfo,
  896. prMsduInfo->u2FrameLength - offsetof(WLAN_ASSOC_REQ_FRAME_T,
  897. u2CapInfo), fgIsReAssoc);
  898. }
  899. #endif
  900. /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
  901. nicTxConfigPktControlFlag(prMsduInfo, MSDU_CONTROL_FLAG_FORCE_TX, TRUE);
  902. /* 4 <6> Enqueue the frame to send this (Re)Association request frame. */
  903. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  904. return WLAN_STATUS_SUCCESS;
  905. } /* end of assocSendReAssocReqFrame() */
  906. /*----------------------------------------------------------------------------*/
  907. /*!
  908. * @brief This function will strictly check the TX (Re)Association Request frame for
  909. * SAA event handling.
  910. *
  911. * @param[in] prMsduInfo Pointer of MSDU_INFO_T
  912. *
  913. * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
  914. * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
  915. */
  916. /*----------------------------------------------------------------------------*/
  917. WLAN_STATUS assocCheckTxReAssocReqFrame(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  918. {
  919. P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame;
  920. P_STA_RECORD_T prStaRec;
  921. UINT_16 u2TxFrameCtrl;
  922. ASSERT(prMsduInfo);
  923. ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
  924. prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T) (prMsduInfo->prPacket);
  925. ASSERT(prAssocReqFrame);
  926. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  927. ASSERT(prStaRec);
  928. if (!prStaRec)
  929. return WLAN_STATUS_INVALID_PACKET;
  930. /* WLAN_GET_FIELD_16(&prAssocReqFrame->u2FrameCtrl, &u2TxFrameCtrl) */
  931. u2TxFrameCtrl = prAssocReqFrame->u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  932. u2TxFrameCtrl &= MASK_FRAME_TYPE;
  933. if (prStaRec->fgIsReAssoc) {
  934. if (u2TxFrameCtrl != MAC_FRAME_REASSOC_REQ)
  935. return WLAN_STATUS_FAILURE;
  936. } else {
  937. if (u2TxFrameCtrl != MAC_FRAME_ASSOC_REQ)
  938. return WLAN_STATUS_FAILURE;
  939. }
  940. return WLAN_STATUS_SUCCESS;
  941. } /* end of assocCheckTxReAssocReqFrame() */
  942. /*----------------------------------------------------------------------------*/
  943. /*!
  944. * @brief This function will strictly check the TX (Re)Association Response frame for
  945. * AAA event handling.
  946. *
  947. * @param[in] prMsduInfo Pointer of MSDU_INFO_T
  948. *
  949. * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
  950. * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
  951. */
  952. /*----------------------------------------------------------------------------*/
  953. WLAN_STATUS assocCheckTxReAssocRespFrame(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  954. {
  955. P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
  956. P_STA_RECORD_T prStaRec;
  957. UINT_16 u2TxFrameCtrl;
  958. ASSERT(prMsduInfo);
  959. ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
  960. prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) (prMsduInfo->prPacket);
  961. ASSERT(prAssocRspFrame);
  962. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  963. ASSERT(prStaRec);
  964. if (!prStaRec)
  965. return WLAN_STATUS_INVALID_PACKET;
  966. /* WLAN_GET_FIELD_16(&prAssocFrame->u2FrameCtrl, &u2TxFrameCtrl) */
  967. u2TxFrameCtrl = prAssocRspFrame->u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  968. u2TxFrameCtrl &= MASK_FRAME_TYPE;
  969. if (prStaRec->fgIsReAssoc) {
  970. if (u2TxFrameCtrl != MAC_FRAME_REASSOC_RSP)
  971. return WLAN_STATUS_FAILURE;
  972. } else {
  973. if (u2TxFrameCtrl != MAC_FRAME_ASSOC_RSP)
  974. return WLAN_STATUS_FAILURE;
  975. }
  976. return WLAN_STATUS_SUCCESS;
  977. } /* end of assocCheckTxReAssocRespFrame() */
  978. /*----------------------------------------------------------------------------*/
  979. /*!
  980. * @brief This function will validate the incoming (Re)Association Frame and take out
  981. * the status code.
  982. *
  983. * @param[in] prSwRfb Pointer to SW RFB data structure.
  984. * @param[out] pu2StatusCode Pointer to store the Status Code from Authentication.
  985. *
  986. * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
  987. * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
  988. */
  989. /*----------------------------------------------------------------------------*/
  990. WLAN_STATUS
  991. assocCheckRxReAssocRspFrameStatus(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT PUINT_16 pu2StatusCode)
  992. {
  993. P_STA_RECORD_T prStaRec;
  994. P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
  995. UINT_16 u2RxFrameCtrl;
  996. UINT_16 u2RxCapInfo;
  997. UINT_16 u2RxStatusCode;
  998. UINT_16 u2RxAssocId;
  999. ASSERT(prSwRfb);
  1000. ASSERT(pu2StatusCode);
  1001. if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) < (CAP_INFO_FIELD_LEN +
  1002. STATUS_CODE_FIELD_LEN + AID_FIELD_LEN)) {
  1003. ASSERT(0);
  1004. return WLAN_STATUS_FAILURE;
  1005. }
  1006. DBGLOG(SAA, LOUD, "prSwRfb->u2PayloadLength = %d\n", prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen);
  1007. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1008. ASSERT(prStaRec);
  1009. if (!prStaRec)
  1010. return WLAN_STATUS_INVALID_PACKET;
  1011. /* 4 <1> locate the (Re)Association Resp Frame. */
  1012. prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) prSwRfb->pvHeader;
  1013. /* 4 <2> Parse the Header of (Re)Association Resp Frame. */
  1014. /* WLAN_GET_FIELD_16(&prAssocRspFrame->u2FrameCtrl, &u2RxFrameCtrl); */
  1015. u2RxFrameCtrl = prAssocRspFrame->u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  1016. u2RxFrameCtrl &= MASK_FRAME_TYPE;
  1017. if (prStaRec->fgIsReAssoc) {
  1018. if (u2RxFrameCtrl != MAC_FRAME_REASSOC_RSP)
  1019. return WLAN_STATUS_FAILURE;
  1020. } else {
  1021. if (u2RxFrameCtrl != MAC_FRAME_ASSOC_RSP)
  1022. return WLAN_STATUS_FAILURE;
  1023. }
  1024. /* 4 <3> Parse the Fixed Fields of (Re)Association Resp Frame Body. */
  1025. /* WLAN_GET_FIELD_16(&prAssocRspFrame->u2CapInfo, &u2RxCapInfo); */
  1026. u2RxCapInfo = prAssocRspFrame->u2CapInfo; /* NOTE(Kevin): Optimized for ARM */
  1027. /* WLAN_GET_FIELD_16(&prAssocRspFrame->u2StatusCode, &u2RxStatusCode); */
  1028. u2RxStatusCode = prAssocRspFrame->u2StatusCode; /* NOTE(Kevin): Optimized for ARM */
  1029. /* 4 <4> Check CAP_INFO */
  1030. /* NOTE(Kevin): CM suggest to add MGMT workaround for those APs didn't check
  1031. * the CAP Privacy Bit to overcome a corner case that the Privacy Bit
  1032. * of our SCAN result didn't consist with AP's Association Resp.
  1033. */
  1034. if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
  1035. #if CFG_SUPPORT_WAPI
  1036. if (prAdapter->rWifiVar.rConnSettings.fgWapiMode) {
  1037. /* WAPI AP allow the customer use WZC to join mode, the privacy bit is 0 */
  1038. /* even at WAI & WAPI_PSK mode, but the assoc respose set the privacy bit set 1 */
  1039. DBGLOG(SEC, TRACE, "Workaround the WAPI AP allow the customer to use WZC to join\n");
  1040. } else
  1041. #endif
  1042. #if CFG_ENABLE_WIFI_DIRECT
  1043. if (prAdapter->fgIsP2PRegistered && 1) {
  1044. /* Todo:: Fixed this */
  1045. } else
  1046. #endif
  1047. {
  1048. }
  1049. #if CFG_STRICT_CHECK_CAPINFO_PRIVACY
  1050. if ((prStaRec->u2CapInfo & CAP_INFO_PRIVACY) ^ (u2RxCapInfo & CAP_INFO_PRIVACY))
  1051. u2RxStatusCode = STATUS_CODE_CAP_NOT_SUPPORTED;
  1052. #endif
  1053. }
  1054. if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
  1055. /* Update the information in the structure used to query and set
  1056. OID_802_11_ASSOCIATION_INFORMATION. */
  1057. kalUpdateReAssocRspInfo(prAdapter->prGlueInfo,
  1058. (PUINT_8)&prAssocRspFrame->u2CapInfo, (UINT_32) (prSwRfb->u2PacketLen));
  1059. }
  1060. /* 4 <5> Update CAP_INFO and ASSOC_ID */
  1061. if (u2RxStatusCode == STATUS_CODE_SUCCESSFUL) {
  1062. prStaRec->u2CapInfo = u2RxCapInfo;
  1063. /* WLAN_GET_FIELD_16(&prAssocRspFrame->u2AssocId, &u2RxAssocId); */
  1064. u2RxAssocId = prAssocRspFrame->u2AssocId; /* NOTE(Kevin): Optimized for ARM */
  1065. /* 20110715 Workaround for Kingnet 710 AP (Realtek 8186)
  1066. * This AP raises the bit 6&7 not bit 14&15 in AID field.
  1067. * It cause wrong AID assignment.
  1068. * For AID = 2
  1069. * Normal case: 0xC002(1100 0000 0000 0010) => 2
  1070. * Kingnet 710: 0x00C2(0000 0000 1100 0010) => 194
  1071. * workaround: mask bit 6&7 for this AP
  1072. */
  1073. if ((u2RxAssocId & BIT(6)) && (u2RxAssocId & BIT(7)) && !(u2RxAssocId & BITS(8, 15))) {
  1074. prStaRec->u2AssocId = u2RxAssocId & ~BITS(6, 7);
  1075. } else {
  1076. prStaRec->u2AssocId = u2RxAssocId & ~AID_MSB;
  1077. #if CFG_SUPPORT_802_11W
  1078. if (prStaRec->eStaType == STA_TYPE_LEGACY_AP) {
  1079. P_AIS_SPECIFIC_BSS_INFO_T prBssSpecInfo;
  1080. prBssSpecInfo = &prAdapter->rWifiVar.rAisSpecificBssInfo;
  1081. ASSERT(prBssSpecInfo);
  1082. prBssSpecInfo->ucSaQueryTimedOut = 0;
  1083. }
  1084. #endif
  1085. }
  1086. }
  1087. #if CFG_SUPPORT_802_11W
  1088. if (u2RxStatusCode == STATUS_CODE_AUTH_ALGORITHM_NOT_SUPPORTED) {
  1089. DBGLOG(SAA, INFO, "AP rejected due the authentication algorithm not support\n");
  1090. } else if (u2RxStatusCode == STATUS_CODE_ASSOC_REJECTED_TEMPORARILY) {
  1091. PUINT_8 pucIE, pucTime;
  1092. UINT_16 u2IELength;
  1093. UINT_16 u2Offset = 0;
  1094. u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
  1095. pucIE = (PUINT_8) ((ULONG) prSwRfb->pvHeader + prSwRfb->u2HeaderLen);
  1096. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  1097. if (ELEM_ID_TIMEOUT_INTERVAL == IE_ID(pucIE) && IE_LEN(pucIE) == 5) {
  1098. pucTime = ((P_IE_HDR_T) pucIE)->aucInfo;
  1099. if (pucTime[0] == ACTION_SA_TIMEOUT_ASSOC_COMEBACK) {
  1100. UINT_32 tu;
  1101. WLAN_GET_FIELD_32(pucTime + 1, &tu);
  1102. DBGLOG(SAA, INFO,
  1103. "AP rejected association temporarily;comeback duration %u TU (%u ms)\n",
  1104. tu, TU_TO_MSEC(tu));
  1105. if (tu > TX_ASSOCIATION_RETRY_TIMEOUT_TU) {
  1106. DBGLOG(SAA, INFO, "Update timer based on comeback duration\n");
  1107. /* ieee80211_reschedule_timer(wpa_s, ms); */
  1108. }
  1109. }
  1110. break;
  1111. }
  1112. } /* end of IE_FOR_EACH */
  1113. }
  1114. #endif
  1115. *pu2StatusCode = u2RxStatusCode;
  1116. return WLAN_STATUS_SUCCESS;
  1117. } /* end of assocCheckRxReAssocRspFrameStatus() */
  1118. /*----------------------------------------------------------------------------*/
  1119. /*!
  1120. * \brief This function will compose the Disassociation frame
  1121. *
  1122. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1123. * @param[in] pucBuffer Pointer to the frame buffer.
  1124. * @param[in] aucMACAddress Given Our MAC Address.
  1125. * @param[in] u2ReasonCode The reason code of disassociation
  1126. *
  1127. * \return (none)
  1128. */
  1129. /*----------------------------------------------------------------------------*/
  1130. __KAL_INLINE__ VOID
  1131. assocComposeDisassocFrame(IN P_STA_RECORD_T prStaRec,
  1132. IN PUINT_8 pucBuffer, IN UINT_8 aucMACAddress[], IN UINT_16 u2ReasonCode)
  1133. {
  1134. P_WLAN_DISASSOC_FRAME_T prDisAssocFrame;
  1135. UINT_16 u2FrameCtrl;
  1136. ASSERT(pucBuffer);
  1137. ASSERT(pucBuffer);
  1138. ASSERT(aucMACAddress);
  1139. prDisAssocFrame = (P_WLAN_DISASSOC_FRAME_T) pucBuffer;
  1140. /* 4 <1> Compose the frame header of the DisAssociation frame. */
  1141. /* Fill the Frame Control field. */
  1142. u2FrameCtrl = MAC_FRAME_DISASSOC;
  1143. WLAN_SET_FIELD_16(&prDisAssocFrame->u2FrameCtrl, u2FrameCtrl);
  1144. /* Fill the DA field with Target BSSID. */
  1145. COPY_MAC_ADDR(prDisAssocFrame->aucDestAddr, prStaRec->aucMacAddr);
  1146. /* Fill the SA field with our MAC Address. */
  1147. COPY_MAC_ADDR(prDisAssocFrame->aucSrcAddr, aucMACAddress);
  1148. /* Fill the BSSID field with Target BSSID. */
  1149. COPY_MAC_ADDR(prDisAssocFrame->aucBSSID, prStaRec->aucMacAddr);
  1150. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  1151. prDisAssocFrame->u2SeqCtrl = 0;
  1152. /* 4 <2> Compose the frame body's fixed field part of the Disassociation frame. */
  1153. /* Fill the Reason Code field. */
  1154. WLAN_SET_FIELD_16(&prDisAssocFrame->u2ReasonCode, u2ReasonCode);
  1155. } /* end of assocComposeDisassocFrame() */
  1156. /*----------------------------------------------------------------------------*/
  1157. /*!
  1158. * @brief This function will send the Disassociation frame
  1159. *
  1160. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1161. * @param[in] u2ReasonCode The reason code of disassociation
  1162. *
  1163. * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
  1164. * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
  1165. */
  1166. /*----------------------------------------------------------------------------*/
  1167. WLAN_STATUS assocSendDisAssocFrame(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN UINT_16 u2ReasonCode)
  1168. {
  1169. PUINT_8 pucMacAddress;
  1170. P_MSDU_INFO_T prMsduInfo;
  1171. UINT_16 u2PayloadLen;
  1172. UINT_16 u2EstimatedFrameLen;
  1173. /* UINT_32 u4Status = WLAN_STATUS_SUCCESS; */
  1174. ASSERT(prStaRec);
  1175. ASSERT(prStaRec->ucBssIndex <= MAX_BSS_INDEX);
  1176. /* 4 <1> Allocate a PKT_INFO_T for Disassociation Frame */
  1177. /* Init with MGMT Header Length + Length of Fixed Fields + IE Length */
  1178. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_MGMT_HEADER_LEN + REASON_CODE_FIELD_LEN;
  1179. /* Allocate a MSDU_INFO_T */
  1180. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  1181. if (prMsduInfo == NULL) {
  1182. DBGLOG(SAA, WARN, "No PKT_INFO_T for sending DisAssoc.\n");
  1183. return WLAN_STATUS_RESOURCES;
  1184. }
  1185. /* 4 <2> Compose Disassociation frame header and fixed fields in MSDU_INfO_T. */
  1186. pucMacAddress = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex)->aucOwnMacAddr;
  1187. /* Compose Header and Fixed Field */
  1188. assocComposeDisassocFrame(prStaRec,
  1189. (PUINT_8) ((ULONG) (prMsduInfo->prPacket) +
  1190. MAC_TX_RESERVED_FIELD), pucMacAddress, u2ReasonCode);
  1191. #if CFG_SUPPORT_802_11W
  1192. if (rsnCheckBipKeyInstalled(prAdapter, prStaRec)) {
  1193. P_WLAN_DISASSOC_FRAME_T prDisassocFrame;
  1194. prDisassocFrame = (P_WLAN_DISASSOC_FRAME_T) ((ULONG) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD);
  1195. prDisassocFrame->u2FrameCtrl |= MASK_FC_PROTECTED_FRAME;
  1196. }
  1197. #endif
  1198. u2PayloadLen = REASON_CODE_FIELD_LEN;
  1199. /* 4 <3> Update information of MSDU_INFO_T */
  1200. TX_SET_MMPDU(prAdapter,
  1201. prMsduInfo,
  1202. prStaRec->ucBssIndex,
  1203. prStaRec->ucIndex,
  1204. WLAN_MAC_MGMT_HEADER_LEN, WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen, NULL, MSDU_RATE_MODE_AUTO);
  1205. #if CFG_SUPPORT_802_11W
  1206. if (rsnCheckBipKeyInstalled(prAdapter, prStaRec)) {
  1207. /* DBGLOG(RSN, TRACE, ("Set MSDU_OPT_PROTECTED_FRAME\n")); */
  1208. nicTxConfigPktOption(prMsduInfo, MSDU_OPT_PROTECTED_FRAME, TRUE);
  1209. }
  1210. #endif
  1211. /* 4 <4> Enqueue the frame to send this (Re)Association request frame. */
  1212. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  1213. return WLAN_STATUS_SUCCESS;
  1214. } /* end of assocSendDisAssocFrame() */
  1215. /*----------------------------------------------------------------------------*/
  1216. /*!
  1217. * @brief This function will parse and process the incoming Disassociation frame
  1218. * if the given BSSID is matched.
  1219. *
  1220. * @param[in] prSwRfb Pointer to SW RFB data structure.
  1221. * @param[in] aucBSSID Given BSSID
  1222. * @param[out] pu2ReasonCode Pointer to store the Reason Code from Deauthentication.
  1223. *
  1224. * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
  1225. * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
  1226. */
  1227. /*----------------------------------------------------------------------------*/
  1228. WLAN_STATUS
  1229. assocProcessRxDisassocFrame(IN P_ADAPTER_T prAdapter,
  1230. IN P_SW_RFB_T prSwRfb, IN UINT_8 aucBSSID[], OUT PUINT_16 pu2ReasonCode)
  1231. {
  1232. P_WLAN_DISASSOC_FRAME_T prDisassocFrame;
  1233. UINT_16 u2RxReasonCode;
  1234. ASSERT(prSwRfb);
  1235. ASSERT(aucBSSID);
  1236. ASSERT(pu2ReasonCode);
  1237. /* 4 <1> locate the Disassociation Frame. */
  1238. prDisassocFrame = (P_WLAN_DISASSOC_FRAME_T) prSwRfb->pvHeader;
  1239. /* 4 <2> Parse the Header of Disassociation Frame. */
  1240. if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) < REASON_CODE_FIELD_LEN) {
  1241. ASSERT(0);
  1242. return WLAN_STATUS_FAILURE;
  1243. }
  1244. /* Check if this Disassoc Frame is coming from Target BSSID */
  1245. if (UNEQUAL_MAC_ADDR(prDisassocFrame->aucBSSID, aucBSSID)) {
  1246. DBGLOG(SAA, LOUD, "Ignore Disassoc Frame from other BSS [" MACSTR "]\n",
  1247. MAC2STR(prDisassocFrame->aucSrcAddr));
  1248. return WLAN_STATUS_FAILURE;
  1249. }
  1250. /* 4 <3> Parse the Fixed Fields of Deauthentication Frame Body. */
  1251. WLAN_GET_FIELD_16(&prDisassocFrame->u2ReasonCode, &u2RxReasonCode);
  1252. *pu2ReasonCode = u2RxReasonCode;
  1253. return WLAN_STATUS_SUCCESS;
  1254. } /* end of assocProcessRxDisassocFrame() */
  1255. #if CFG_SUPPORT_AAA
  1256. /*----------------------------------------------------------------------------*/
  1257. /*!
  1258. * @brief This function will parse and process the incoming Association Req frame
  1259. * and return a Status Code.
  1260. *
  1261. * @param[in] prAdapter Pointer to the Adapter structure.
  1262. * @param[in] prSwRfb Pointer to SW RFB data structure.
  1263. * @param[out] pu2StatusCode Pointer to store the Status Code for carried in Association Response.
  1264. *
  1265. * @retval WLAN_STATUS_FAILURE This is not the frame we should handle at current state.
  1266. * @retval WLAN_STATUS_SUCCESS This is the frame we should handle.
  1267. */
  1268. /*----------------------------------------------------------------------------*/
  1269. WLAN_STATUS assocProcessRxAssocReqFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb, OUT PUINT_16 pu2StatusCode)
  1270. {
  1271. P_WLAN_ASSOC_REQ_FRAME_T prAssocReqFrame;
  1272. P_STA_RECORD_T prStaRec;
  1273. P_BSS_INFO_T prBssInfo;
  1274. P_IE_SSID_T prIeSsid = (P_IE_SSID_T) NULL;
  1275. P_RSN_INFO_ELEM_T prIeRsn = (P_RSN_INFO_ELEM_T) NULL;
  1276. P_IE_SUPPORTED_RATE_T prIeSupportedRate = (P_IE_SUPPORTED_RATE_T) NULL;
  1277. P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate = (P_IE_EXT_SUPPORTED_RATE_T) NULL;
  1278. PUINT_8 pucIE, pucIEStart;
  1279. UINT_16 u2IELength;
  1280. UINT_16 u2Offset = 0;
  1281. UINT_16 u2StatusCode = STATUS_CODE_SUCCESSFUL;
  1282. UINT_16 u2RxFrameCtrl;
  1283. UINT_16 u2BSSBasicRateSet;
  1284. UINT_8 ucFixedFieldLength;
  1285. BOOLEAN fgIsUnknownBssBasicRate;
  1286. UINT_32 i;
  1287. ASSERT(prAdapter);
  1288. ASSERT(prSwRfb);
  1289. ASSERT(pu2StatusCode);
  1290. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1291. if (prStaRec == NULL)
  1292. return WLAN_STATUS_FAILURE;
  1293. /* 4 <1> locate the Association Req Frame. */
  1294. prAssocReqFrame = (P_WLAN_ASSOC_REQ_FRAME_T) prSwRfb->pvHeader;
  1295. /* WLAN_GET_FIELD_16(&prAssocReqFrame->u2FrameCtrl, &u2RxFrameCtrl); */
  1296. u2RxFrameCtrl = prAssocReqFrame->u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  1297. u2RxFrameCtrl &= MASK_FRAME_TYPE;
  1298. /* 4 <2> Parse the Header of Association Req Frame. */
  1299. if (MAC_FRAME_REASSOC_REQ == u2RxFrameCtrl)
  1300. ucFixedFieldLength = CAP_INFO_FIELD_LEN + LISTEN_INTERVAL_FIELD_LEN + CURR_AP_ADDR_FIELD_LEN;
  1301. else
  1302. ucFixedFieldLength = CAP_INFO_FIELD_LEN + LISTEN_INTERVAL_FIELD_LEN;
  1303. if ((prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) <= ucFixedFieldLength) {
  1304. /* Length of this (re)association req is invalid, ignore it */
  1305. return WLAN_STATUS_FAILURE;
  1306. }
  1307. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  1308. /* Check if this Disassoc Frame is coming from Target BSSID */
  1309. if (UNEQUAL_MAC_ADDR(prAssocReqFrame->aucBSSID, prBssInfo->aucBSSID))
  1310. return WLAN_STATUS_FAILURE; /* Just Ignore this MMPDU */
  1311. if (MAC_FRAME_REASSOC_REQ == u2RxFrameCtrl) {
  1312. prStaRec->fgIsReAssoc = TRUE;
  1313. u2IELength = (prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) -
  1314. (UINT_16) (OFFSET_OF(WLAN_REASSOC_REQ_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN);
  1315. pucIEStart = pucIE = ((P_WLAN_REASSOC_REQ_FRAME_T) (prSwRfb->pvHeader))->aucInfoElem;
  1316. } else {
  1317. prStaRec->fgIsReAssoc = FALSE;
  1318. u2IELength = (prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen) -
  1319. (UINT_16) (OFFSET_OF(WLAN_ASSOC_REQ_FRAME_T, aucInfoElem[0]) - WLAN_MAC_MGMT_HEADER_LEN);
  1320. pucIEStart = pucIE = prAssocReqFrame->aucInfoElem;
  1321. }
  1322. /* 4 <3> Parse the Fixed Fields of Assoc Req Frame Body. */
  1323. prStaRec->u2CapInfo = prAssocReqFrame->u2CapInfo;
  1324. #if 0 /* CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK */
  1325. if (prAdapter->fgIsP2PRegistered && IS_STA_P2P_TYPE(prStaRec)) {
  1326. if (((prStaRec->u2CapInfo & CAP_INFO_PRIVACY) && !kalP2PGetCipher(prAdapter->prGlueInfo))) {
  1327. u2StatusCode = STATUS_CODE_CAP_NOT_SUPPORTED;
  1328. DBGLOG(RSN, TRACE, "STA Assoc req privacy bit check fail\n");
  1329. return WLAN_STATUS_SUCCESS;
  1330. }
  1331. }
  1332. #endif
  1333. prStaRec->u2ListenInterval = prAssocReqFrame->u2ListenInterval;
  1334. prStaRec->ucPhyTypeSet = 0;
  1335. /* Might be legacy client or p2p gc. */
  1336. prStaRec->eStaType = STA_TYPE_LEGACY_CLIENT;
  1337. /* 4 <4> Parse the IE of Assoc Req Frame Body. */
  1338. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  1339. switch (IE_ID(pucIE)) {
  1340. case ELEM_ID_SSID:
  1341. if ((!prIeSsid) && /* NOTE(Kevin): Get SSID once */
  1342. (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID)) {
  1343. prIeSsid = (P_IE_SSID_T) pucIE;
  1344. }
  1345. break;
  1346. case ELEM_ID_SUP_RATES:
  1347. if ((!prIeSupportedRate) && (IE_LEN(pucIE) <= RATE_NUM_SW))
  1348. prIeSupportedRate = SUP_RATES_IE(pucIE);
  1349. break;
  1350. case ELEM_ID_EXTENDED_SUP_RATES:
  1351. if (!prIeExtSupportedRate)
  1352. prIeExtSupportedRate = EXT_SUP_RATES_IE(pucIE);
  1353. break;
  1354. case ELEM_ID_HT_CAP:
  1355. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HT;
  1356. break;
  1357. case ELEM_ID_VHT_CAP:
  1358. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_VHT;
  1359. break;
  1360. case ELEM_ID_RSN:
  1361. #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK
  1362. if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
  1363. prIeRsn = RSN_IE(pucIE);
  1364. rsnParserCheckForRSNCCMPPSK(prAdapter, prIeRsn, &u2StatusCode);
  1365. if (u2StatusCode != STATUS_CODE_SUCCESSFUL) {
  1366. *pu2StatusCode = u2StatusCode;
  1367. return WLAN_STATUS_SUCCESS;
  1368. }
  1369. }
  1370. #endif
  1371. break;
  1372. case ELEM_ID_VENDOR:
  1373. #if CFG_ENABLE_WIFI_DIRECT
  1374. {
  1375. if ((prAdapter->fgIsP2PRegistered)) {
  1376. UINT_8 ucOuiType = 0;
  1377. p2pFuncParseCheckForP2PInfoElem(prAdapter, pucIE, &ucOuiType);
  1378. if (ucOuiType == VENDOR_OUI_TYPE_P2P) {
  1379. DBGLOG(P2P, TRACE, "Target Client is a P2P group client\n");
  1380. prStaRec->eStaType = STA_TYPE_P2P_GC;
  1381. }
  1382. }
  1383. }
  1384. #endif
  1385. break;
  1386. default:
  1387. for (i = 0; i < (sizeof(rxAssocReqIETable) / sizeof(VERIFY_IE_ENTRY_T)); i++) {
  1388. if (((IE_ID(pucIE)) == rxAssocReqIETable[i].ucElemID) &&
  1389. (rxAssocReqIETable[i].pfnVarifyIE != NULL)) {
  1390. rxAssocReqIETable[i].pfnVarifyIE(prAdapter, prSwRfb,
  1391. (P_IE_HDR_T) pucIE, &u2StatusCode);
  1392. if (u2StatusCode != STATUS_CODE_SUCCESSFUL) {
  1393. *pu2StatusCode = u2StatusCode;
  1394. return WLAN_STATUS_SUCCESS;
  1395. }
  1396. }
  1397. }
  1398. break;
  1399. }
  1400. } /* end of IE_FOR_EACH */
  1401. /* parsing for WMM related information (2010/12/21) */
  1402. mqmProcessAssocReq(prAdapter, prSwRfb, pucIEStart, u2IELength);
  1403. do {
  1404. if (prIeSsid) {
  1405. if (UNEQUAL_SSID(prBssInfo->aucSSID, prBssInfo->ucSSIDLen,
  1406. prIeSsid->aucSSID, prIeSsid->ucLength)) {
  1407. u2StatusCode = STATUS_CODE_UNSPECIFIED_FAILURE;
  1408. break;
  1409. }
  1410. } else {
  1411. u2StatusCode = STATUS_CODE_UNSPECIFIED_FAILURE;
  1412. break;
  1413. }
  1414. prStaRec->u2OperationalRateSet = 0;
  1415. prStaRec->u2BSSBasicRateSet = 0;
  1416. if (prIeSupportedRate || prIeExtSupportedRate) {
  1417. /* Ignore any Basic Bit */
  1418. rateGetRateSetFromIEs(prIeSupportedRate, prIeExtSupportedRate,
  1419. &prStaRec->u2OperationalRateSet, &u2BSSBasicRateSet,
  1420. &fgIsUnknownBssBasicRate);
  1421. if ((prBssInfo->u2BSSBasicRateSet & prStaRec->u2OperationalRateSet) !=
  1422. prBssInfo->u2BSSBasicRateSet) {
  1423. u2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
  1424. break;
  1425. }
  1426. /* Accpet the Sta, update BSSBasicRateSet from Bss */
  1427. prStaRec->u2BSSBasicRateSet = prBssInfo->u2BSSBasicRateSet;
  1428. prStaRec->u2DesiredNonHTRateSet = (prStaRec->u2OperationalRateSet & RATE_SET_ALL_ABG);
  1429. if (BAND_2G4 == HAL_RX_STATUS_GET_RF_BAND(prSwRfb->prRxStatus)) {
  1430. #if 0 /* Marked by CMC 20111024 */
  1431. /* check if support 11n */
  1432. if (!(u2BSSBasicRateSet & RATE_SET_BIT_HT_PHY)) {
  1433. if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM)
  1434. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_ERP;
  1435. if ((!(u2BSSBasicRateSet & RATE_SET_OFDM)) &&
  1436. (prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS)) {
  1437. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HR_DSSS;
  1438. }
  1439. }
  1440. #else
  1441. if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM)
  1442. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_ERP;
  1443. if (prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS)
  1444. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HR_DSSS;
  1445. #endif
  1446. } else { /* (BAND_5G == prBssDesc->eBande) */
  1447. #if 0 /* Marked by CMC 20111024 */
  1448. if (!(u2BSSBasicRateSet & RATE_SET_BIT_HT_PHY))
  1449. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_OFDM;
  1450. ASSERT((prStaRec->u2OperationalRateSet & RATE_SET_HR_DSSS) == 0);
  1451. #else
  1452. if (prStaRec->u2OperationalRateSet & RATE_SET_OFDM)
  1453. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_OFDM;
  1454. #endif
  1455. }
  1456. /* Update default Tx rate */
  1457. nicTxUpdateStaRecDefaultRate(prStaRec);
  1458. } else {
  1459. ASSERT(0);
  1460. u2StatusCode = STATUS_CODE_ASSOC_DENIED_RATE_NOT_SUPPORTED;
  1461. break;
  1462. }
  1463. #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_HOTSPOT_PRIVACY_CHECK
  1464. if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
  1465. if (prIeRsn) {
  1466. if (!kalP2PGetCipher(prAdapter->prGlueInfo)) {
  1467. u2StatusCode = STATUS_CODE_CIPHER_SUITE_REJECTED;
  1468. break;
  1469. }
  1470. } else {
  1471. /* prStaRec->rSecInfo.fgAllowOnly1x = FALSE; */
  1472. /* if (kalP2PGetCipher(prAdapter->prGlueInfo)) { */
  1473. /* Only Allow 1x */
  1474. /* prStaRec->rSecInfo.fgAllowOnly1x = TRUE; */
  1475. /* break; */
  1476. /* } */
  1477. }
  1478. }
  1479. #endif
  1480. } while (FALSE);
  1481. #if CFG_ENABLE_WIFI_DIRECT
  1482. if (prAdapter->fgIsP2PRegistered && IS_STA_IN_P2P(prStaRec)) {
  1483. #if 1 /* ICS */
  1484. {
  1485. PUINT_8 cp = (PUINT_8) &prAssocReqFrame->u2CapInfo;
  1486. if (prStaRec->fgIsReAssoc)
  1487. cp += 10;
  1488. else
  1489. cp += 4;
  1490. if (prStaRec->pucAssocReqIe) {
  1491. kalMemFree(prStaRec->pucAssocReqIe, VIR_MEM_TYPE, prStaRec->u2AssocReqIeLen);
  1492. prStaRec->pucAssocReqIe = NULL;
  1493. }
  1494. prStaRec->u2AssocReqIeLen = u2IELength;
  1495. if (u2IELength) {
  1496. prStaRec->pucAssocReqIe = kalMemAlloc(u2IELength, VIR_MEM_TYPE);
  1497. if (prStaRec->pucAssocReqIe == NULL) {
  1498. DBGLOG(AIS, WARN, "allocate memory for (Re)assocReqIe fail!\n");
  1499. *pu2StatusCode = STATUS_CODE_INVALID_INFO_ELEMENT;
  1500. return WLAN_STATUS_FAILURE;
  1501. }
  1502. kalMemCopy(prStaRec->pucAssocReqIe, cp, u2IELength);
  1503. }
  1504. }
  1505. #endif
  1506. kalP2PUpdateAssocInfo(prAdapter->prGlueInfo, (PUINT_8) &prAssocReqFrame->u2CapInfo,
  1507. u2IELength + (prStaRec->fgIsReAssoc ? 10 : 4), prStaRec->fgIsReAssoc);
  1508. }
  1509. #endif
  1510. *pu2StatusCode = u2StatusCode;
  1511. return WLAN_STATUS_SUCCESS;
  1512. } /* end of assocProcessRxAssocReqFrame() */
  1513. /*----------------------------------------------------------------------------*/
  1514. /*!
  1515. * @brief This function is used to compose Common Information Elements for Association
  1516. * Response Frame.
  1517. *
  1518. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  1519. * @param[in] prBssInfo Pointer to the BSS_INFO_T.
  1520. *
  1521. * @return (none)
  1522. */
  1523. /*----------------------------------------------------------------------------*/
  1524. __KAL_INLINE__ VOID
  1525. assocBuildReAssocRespFrameCommonIEs(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN P_BSS_INFO_T prBssInfo)
  1526. {
  1527. PUINT_8 pucBuffer;
  1528. P_STA_RECORD_T prStaRec;
  1529. UINT_8 ucSupRatesLen;
  1530. UINT_8 ucExtSupRatesLen;
  1531. ASSERT(prMsduInfo);
  1532. ASSERT(prMsduInfo->eSrc == TX_PACKET_MGMT);
  1533. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  1534. ASSERT(prStaRec);
  1535. pucBuffer = (PUINT_8) ((ULONG) prMsduInfo->prPacket + (ULONG) prMsduInfo->u2FrameLength);
  1536. ASSERT(pucBuffer);
  1537. if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES) {
  1538. ucSupRatesLen = ELEM_MAX_LEN_SUP_RATES;
  1539. ucExtSupRatesLen = prBssInfo->ucAllSupportedRatesLen - ELEM_MAX_LEN_SUP_RATES;
  1540. } else {
  1541. ucSupRatesLen = prBssInfo->ucAllSupportedRatesLen;
  1542. ucExtSupRatesLen = 0;
  1543. }
  1544. /* Fill the Supported Rates element. */
  1545. if (ucSupRatesLen) {
  1546. SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
  1547. SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
  1548. kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates, prBssInfo->aucAllSupportedRates, ucSupRatesLen);
  1549. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1550. pucBuffer += IE_SIZE(pucBuffer);
  1551. }
  1552. /* Fill the Extended Supported Rates element. */
  1553. if (ucExtSupRatesLen) {
  1554. EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
  1555. EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
  1556. kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
  1557. &prBssInfo->aucAllSupportedRates[ucSupRatesLen], ucExtSupRatesLen);
  1558. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1559. }
  1560. } /* end of assocBuildReAssocRespFrameCommonIEs() */
  1561. /*----------------------------------------------------------------------------*/
  1562. /*!
  1563. * @brief This function will compose the (Re)Association Response frame
  1564. *
  1565. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1566. * @param[in] pucBuffer Pointer to the frame buffer.
  1567. * @param[in] aucBssid Given BSSID.
  1568. * @param[in] u2CapInfo Capability Field of current BSS.
  1569. * @param[in out] pu2PayloadLen Return the length of the composed fixed fields
  1570. *
  1571. * @return (none)
  1572. */
  1573. /*----------------------------------------------------------------------------*/
  1574. __KAL_INLINE__ VOID
  1575. assocComposeReAssocRespFrameHeaderAndFF(IN P_STA_RECORD_T prStaRec,
  1576. IN PUINT_8 pucBuffer,
  1577. IN UINT_8 aucBSSID[], IN UINT_16 u2CapInfo, IN OUT PUINT_16 pu2PayloadLen)
  1578. {
  1579. P_WLAN_ASSOC_RSP_FRAME_T prAssocRspFrame;
  1580. BOOLEAN fgIsReAssoc;
  1581. UINT_16 u2FrameCtrl;
  1582. ASSERT(prStaRec);
  1583. ASSERT(pucBuffer);
  1584. ASSERT(aucBSSID);
  1585. ASSERT(pu2PayloadLen);
  1586. prAssocRspFrame = (P_WLAN_ASSOC_RSP_FRAME_T) pucBuffer;
  1587. fgIsReAssoc = prStaRec->fgIsReAssoc;
  1588. /* 4 <1> Compose the frame header of the (Re)Association Request frame. */
  1589. /* Fill the Frame Control field. */
  1590. if (fgIsReAssoc)
  1591. u2FrameCtrl = MAC_FRAME_REASSOC_RSP;
  1592. else
  1593. u2FrameCtrl = MAC_FRAME_ASSOC_RSP;
  1594. /* WLAN_SET_FIELD_16(&prAssocFrame->u2FrameCtrl, u2FrameCtrl); */
  1595. prAssocRspFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  1596. /* Fill the DA field with Target MAC Address. */
  1597. COPY_MAC_ADDR(prAssocRspFrame->aucDestAddr, prStaRec->aucMacAddr);
  1598. /* Fill the SA field with current BSSID. */
  1599. COPY_MAC_ADDR(prAssocRspFrame->aucSrcAddr, aucBSSID);
  1600. /* Fill the BSSID field with current BSSID. */
  1601. COPY_MAC_ADDR(prAssocRspFrame->aucBSSID, aucBSSID);
  1602. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  1603. prAssocRspFrame->u2SeqCtrl = 0;
  1604. /* 4 <2> Compose the frame body's common fixed field part of the (Re)Association Request frame. */
  1605. /* Fill the Capability Information field. */
  1606. /* WLAN_SET_FIELD_16(&prAssocFrame->u2CapInfo, u2CapInfo); */
  1607. prAssocRspFrame->u2CapInfo = u2CapInfo; /* NOTE(Kevin): Optimized for ARM */
  1608. /* WLAN_SET_FIELD_16(&prAssocFrame->u2StatusCode, prStaRec->u2StatusCode); */
  1609. prAssocRspFrame->u2StatusCode = prStaRec->u2StatusCode; /* NOTE(Kevin): Optimized for ARM */
  1610. /* WLAN_SET_FIELD_16(&prAssocFrame->u2AssocId, ((prStaRec->u2AssocId & AID_MASK) | AID_MSB)); */
  1611. /* NOTE(Kevin): Optimized for ARM */
  1612. prAssocRspFrame->u2AssocId = ((prStaRec->u2AssocId & AID_MASK) | AID_MSB);
  1613. *pu2PayloadLen = (CAP_INFO_FIELD_LEN + STATUS_CODE_FIELD_LEN + AID_FIELD_LEN);
  1614. } /* end of assocComposeReAssocRespFrameHeaderAndFF() */
  1615. /*----------------------------------------------------------------------------*/
  1616. /*!
  1617. * @brief This function will send the (Re)Association Resp frame
  1618. *
  1619. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1620. *
  1621. * @retval WLAN_STATUS_RESOURCES No available resource for frame composing.
  1622. * @retval WLAN_STATUS_SUCCESS Successfully send frame to TX Module
  1623. */
  1624. /*----------------------------------------------------------------------------*/
  1625. WLAN_STATUS assocSendReAssocRespFrame(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec)
  1626. {
  1627. P_BSS_INFO_T prBssInfo;
  1628. P_MSDU_INFO_T prMsduInfo;
  1629. UINT_16 u2PayloadLen;
  1630. UINT_16 u2EstimatedFrameLen;
  1631. UINT_16 u2EstimatedExtraIELen;
  1632. BOOLEAN fgIsReAssoc;
  1633. UINT_32 i;
  1634. ASSERT(prStaRec);
  1635. ASSERT(prStaRec->ucBssIndex <= MAX_BSS_INDEX);
  1636. /* 4 <1> Allocate a PKT_INFO_T for Authentication Frame */
  1637. fgIsReAssoc = prStaRec->fgIsReAssoc;
  1638. /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Length */
  1639. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD +
  1640. WLAN_MAC_MGMT_HEADER_LEN +
  1641. CAP_INFO_FIELD_LEN +
  1642. STATUS_CODE_FIELD_LEN +
  1643. AID_FIELD_LEN +
  1644. (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) + (ELEM_HDR_LEN + (RATE_NUM_SW - ELEM_MAX_LEN_SUP_RATES));
  1645. /* + Extra IE Length */
  1646. u2EstimatedExtraIELen = 0;
  1647. for (i = 0; i < sizeof(txAssocRespIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  1648. if (txAssocRespIETable[i].u2EstimatedFixedIELen != 0) {
  1649. u2EstimatedExtraIELen += txAssocRespIETable[i].u2EstimatedFixedIELen;
  1650. } else if (txAssocRespIETable[i].pfnCalculateVariableIELen != NULL) {
  1651. u2EstimatedExtraIELen +=
  1652. (UINT_16) txAssocRespIETable[i].pfnCalculateVariableIELen(prAdapter,
  1653. prStaRec->ucBssIndex, prStaRec);
  1654. }
  1655. }
  1656. u2EstimatedFrameLen += u2EstimatedExtraIELen;
  1657. /* Allocate a MSDU_INFO_T */
  1658. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  1659. if (prMsduInfo == NULL) {
  1660. DBGLOG(AAA, WARN, "No PKT_INFO_T for sending (Re)Assoc Response.\n");
  1661. return WLAN_STATUS_RESOURCES;
  1662. }
  1663. /* 4 <2> Compose (Re)Association Request frame header and fixed fields in MSDU_INfO_T. */
  1664. ASSERT(prStaRec->ucBssIndex != prAdapter->prAisBssInfo->ucBssIndex);
  1665. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  1666. /* Compose Header and Fixed Field */
  1667. assocComposeReAssocRespFrameHeaderAndFF(prStaRec,
  1668. (PUINT_8) ((ULONG) (prMsduInfo->prPacket) +
  1669. MAC_TX_RESERVED_FIELD),
  1670. prBssInfo->aucBSSID, prBssInfo->u2CapInfo, &u2PayloadLen);
  1671. /* 4 <3> Update information of MSDU_INFO_T */
  1672. TX_SET_MMPDU(prAdapter,
  1673. prMsduInfo,
  1674. prStaRec->ucBssIndex,
  1675. prStaRec->ucIndex,
  1676. WLAN_MAC_MGMT_HEADER_LEN,
  1677. WLAN_MAC_MGMT_HEADER_LEN + u2PayloadLen, aaaFsmRunEventTxDone, MSDU_RATE_MODE_AUTO);
  1678. /* 4 <4> Compose the frame body's IEs of the (Re)Association Request frame. */
  1679. assocBuildReAssocRespFrameCommonIEs(prAdapter, prMsduInfo, prBssInfo);
  1680. /* 4 <5> Compose IEs in MSDU_INFO_T */
  1681. /* Append IE */
  1682. for (i = 0; i < sizeof(txAssocRespIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  1683. if (txAssocRespIETable[i].pfnAppendIE)
  1684. txAssocRespIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
  1685. }
  1686. #if CFG_SUPPORT_WFD
  1687. /* TODO put WFD IE in assoc resp if driver will send assoc resp */
  1688. #endif
  1689. /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
  1690. nicTxConfigPktControlFlag(prMsduInfo, MSDU_CONTROL_FLAG_FORCE_TX, TRUE);
  1691. /* 4 <6> Enqueue the frame to send this (Re)Association request frame. */
  1692. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  1693. return WLAN_STATUS_SUCCESS;
  1694. } /* end of assocSendReAssocRespFrame() */
  1695. #endif /* CFG_SUPPORT_AAA */