bss.c 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/bss.c#7
  3. */
  4. /*! \file "bss.c"
  5. \brief This file contains the functions for creating BSS(AP)/IBSS(AdHoc).
  6. This file contains the functions for BSS(AP)/IBSS(AdHoc). We may create a BSS/IBSS
  7. network, or merge with exist IBSS network and sending Beacon Frame or reply
  8. the Probe Response Frame for received Probe Request Frame.
  9. */
  10. /*
  11. ** Log: bss.c
  12. **
  13. ** 08 28 2013 yuche.tsai
  14. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  15. ** Bug fix for P2P Device interface scan.
  16. **
  17. ** 08 22 2013 yuche.tsai
  18. ** [BORA00002761] [MT6630][Wi-Fi Direct][Driver] Group Interface formation
  19. ** [BORA00000779] [MT6620] Emulation For TX Code Check In
  20. ** Make P2P group interface formation success.
  21. **
  22. ** 08 13 2013 terry.wu
  23. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  24. ** Remove unused code
  25. **
  26. ** 08 05 2013 terry.wu
  27. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  28. ** 1. Add SW rate definition
  29. ** 2. Add HW default rate selection logic from FW
  30. **
  31. ** 07 12 2013 terry.wu
  32. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  33. ** 1. Update VHT IE composing function
  34. ** 2. disable bow
  35. ** 3. Exchange bss/sta rec update sequence for temp solution
  36. **
  37. ** 03 12 2013 tsaiyuan.hsu
  38. ** [BORA00002222] MT6630 unified MAC RXM
  39. ** remove hif_rx_hdr usage.
  40. **
  41. ** 03 12 2013 terry.wu
  42. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  43. ** Update Tx utility function for management frame
  44. **
  45. ** 03 08 2013 wh.su
  46. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  47. ** Remove non-used compiling flag and code
  48. **
  49. ** 03 08 2013 wh.su
  50. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  51. ** Modify code for security design
  52. **
  53. ** 03 06 2013 wh.su
  54. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  55. ** submit some code related with security.
  56. **
  57. ** 02 19 2013 cp.wu
  58. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  59. ** take use of GET_BSS_INFO_BY_INDEX() and MAX_BSS_INDEX macros
  60. ** for correctly indexing of BSS-INFO pointers
  61. **
  62. ** 02 18 2013 cp.wu
  63. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  64. ** modify bssClearClientList() to bssInitializeClientList()
  65. **
  66. ** 01 28 2013 cm.chang
  67. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  68. ** Sync CMD format
  69. **
  70. ** 01 22 2013 cp.wu
  71. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  72. ** modification for ucBssIndex migration
  73. **
  74. ** 11 06 2012 eason.tsai
  75. ** [BORA00002255] [MT6630 Wi-Fi][Driver] develop
  76. ** .
  77. **
  78. ** 09 17 2012 cm.chang
  79. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  80. ** Duplicate source from MT6620 v2.3 driver branch
  81. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  82. **
  83. ** 09 04 2012 cp.wu
  84. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  85. ** sync for NVRAM warning scan result generation for CFG80211.
  86. **
  87. ** 08 31 2012 chinglan.wang
  88. ** NULL
  89. ** Phone can not connect to AP secured with AES via WAPI in 802.11n Only.
  90. **
  91. ** 07 24 2012 yuche.tsai
  92. ** NULL
  93. ** Bug fix for JB.
  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 14 2012 chinglan.wang
  104. * NULL
  105. * Fix the losing of the HT IE in assoc request..
  106. *
  107. * 06 13 2012 yuche.tsai
  108. * NULL
  109. * Update maintrunk driver.
  110. * Add support for driver compose assoc request frame.
  111. *
  112. * 03 08 2012 yuche.tsai
  113. * NULL
  114. * Fix FW assert when start Hot-Spot.
  115. *
  116. * 03 02 2012 terry.wu
  117. * NULL
  118. * Snc CFG80211 modification for ICS migration from branch 2.2.
  119. *
  120. * 01 20 2012 chinglan.wang
  121. * 03 02 2012 terry.wu
  122. * NULL
  123. * Fix the WPA-PSK TKIP and WPA2-PSK AES security mode bug.
  124. *
  125. * NULL
  126. * Sync CFG80211 modification from branch 2,2.
  127. *
  128. * 01 15 2012 yuche.tsai
  129. * NULL
  130. * Fix wrong basic rate issue.
  131. *
  132. * 01 13 2012 yuche.tsai
  133. * NULL
  134. * WiFi Hot Spot Tethering for ICS ALPHA testing version.
  135. *
  136. * 11 03 2011 cm.chang
  137. * [WCXRP00000997] [MT6620 Wi-Fi][Driver][FW] Handle change of BSS preamble type and slot time
  138. * Always set short slot time to TRUE initially in AP mode
  139. *
  140. * 11 03 2011 wh.su
  141. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  142. * change the DBGLOG for "\n" and "\r\n". LABEL to LOUD for XLOG
  143. *
  144. * 09 14 2011 yuche.tsai
  145. * NULL
  146. * Add P2P IE in assoc response.
  147. *
  148. * 04 18 2011 terry.wu
  149. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  150. * Remove flag CFG_WIFI_DIRECT_MOVED.
  151. *
  152. * 04 12 2011 eddie.chen
  153. * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
  154. * Fix the sta index in processing security frame
  155. * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
  156. * Add debug message.
  157. *
  158. * 04 08 2011 eddie.chen
  159. * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
  160. * Fix for sigma
  161. *
  162. * 03 29 2011 eddie.chen
  163. * [WCXRP00000608] [MT6620 Wi-Fi][DRV] Change wmm parameters in beacon
  164. * Change wmm parameters in beacon.
  165. *
  166. * 03 29 2011 yuche.tsai
  167. * [WCXRP00000607] [Volunteer Patch][MT6620][Driver] Coding Style Fix for klocwork scan.
  168. * Fix klocwork issue.
  169. *
  170. * 03 19 2011 yuche.tsai
  171. * [WCXRP00000581] [Volunteer Patch][MT6620][Driver] P2P IE in Assoc Req Issue
  172. * Make assoc req to append P2P IE if wifi direct is enabled.
  173. *
  174. * 03 11 2011 chinglan.wang
  175. * [WCXRP00000537] [MT6620 Wi-Fi][Driver] Can not connect to 802.11b/g/n mixed AP with WEP security.
  176. * .
  177. *
  178. * 03 03 2011 george.huang
  179. * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
  180. * .
  181. *
  182. * 03 03 2011 george.huang
  183. * [WCXRP00000508] [MT6620 Wi-Fi][Driver] aware of beacon MSDU will be free, after BSS deactivated
  184. * modify to handle if beacon MSDU been released when BSS deactivated
  185. *
  186. * 03 02 2011 wh.su
  187. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  188. * add code to let the beacon and probe response for Auto GO WSC .
  189. *
  190. * 03 02 2011 wh.su
  191. * [WCXRP00000448] [MT6620 Wi-Fi][Driver] Fixed WSC IE not send out at probe request
  192. * Add code to send beacon and probe response WSC IE at Auto GO.
  193. *
  194. * 02 17 2011 eddie.chen
  195. * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
  196. * 1) Chnange GetFrameAction decision when BSS is absent.
  197. * 2) Check channel and resource in processing ProbeRequest
  198. *
  199. * 02 12 2011 yuche.tsai
  200. * [WCXRP00000441] [Volunteer Patch][MT6620][Driver] BoW can not create desired station type when Hot Spot is enabled.
  201. * bss should create station record type according to callers input.
  202. *
  203. * 02 11 2011 terry.wu
  204. * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
  205. * In p2p link function, check networktype before calling p2p function.
  206. *
  207. * 02 11 2011 terry.wu
  208. * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
  209. * Modify p2p link function to avoid assert.
  210. *
  211. * 01 26 2011 cm.chang
  212. * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
  213. * .
  214. *
  215. * 01 25 2011 yuche.tsai
  216. * [WCXRP00000388] [Volunteer Patch][MT6620][Driver/Fw] change Station Type in station record.
  217. * Change Station Type in Station Record, Modify MACRO definition for getting station type & network type index & Role.
  218. *
  219. * 01 25 2011 eddie.chen
  220. * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
  221. * Fix the compile error in windows.
  222. *
  223. * 01 24 2011 eddie.chen
  224. * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
  225. * Add destination decision in AP mode.
  226. *
  227. * 01 24 2011 terry.wu
  228. * [WCXRP00000383] [MT6620 Wi-Fi][Driver] Separate WiFi and P2P driver into two modules
  229. * .Fix typo and missing entry
  230. *
  231. * 12 30 2010 eddie.chen
  232. * [WCXRP00000322] Add WMM IE in beacon,
  233. Add per station flow control when STA is in PS
  234. * Fix prBssInfo->aucCWminLog to prBssInfo->aucCWminLogForBcast
  235. *
  236. * 12 29 2010 eddie.chen
  237. * [WCXRP00000322] Add WMM IE in beacon,
  238. Add per station flow control when STA is in PS
  239. * Add WMM parameter for broadcast.
  240. *
  241. * 12 29 2010 eddie.chen
  242. * [WCXRP00000322] Add WMM IE in beacon,
  243. Add per station flow control when STA is in PS
  244. * 1) PS flow control event
  245. *
  246. * 2) WMM IE in beacon, assoc resp, probe resp
  247. *
  248. * 11 29 2010 cp.wu
  249. *
  250. * update ucRcpi of STA_RECORD_T for AIS when
  251. * 1) Beacons for IBSS merge is received
  252. * 2) Associate Response for a connecting peer is received
  253. *
  254. * 10 18 2010 cp.wu
  255. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  256. * use definition macro to replace hard-coded constant
  257. *
  258. * 10 08 2010 wh.su
  259. * [WCXRP00000085] [MT6620 Wif-Fi] [Driver] update the modified p2p state machine
  260. * update the frog's new p2p state machine.
  261. *
  262. * 09 28 2010 wh.su
  263. * NULL
  264. * [WCXRP00000069][MT6620 Wi-Fi][Driver] Fix some code for phase 1 P2P Demo.
  265. *
  266. * 09 27 2010 chinghwa.yu
  267. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000065] Update BoW design and settings
  268. * Update BCM/BoW design and settings.
  269. *
  270. * 09 16 2010 cm.chang
  271. * NULL
  272. * Change conditional compiling options for BOW
  273. *
  274. * 09 10 2010 cm.chang
  275. * NULL
  276. * Always update Beacon content if FW sync OBSS info
  277. *
  278. * 09 07 2010 wh.su
  279. * NULL
  280. * adding the code for beacon/probe req/ probe rsp wsc ie at p2p.
  281. *
  282. * 09 03 2010 kevin.huang
  283. * NULL
  284. * Refine #include sequence and solve recursive/nested #include issue
  285. *
  286. * 08 31 2010 kevin.huang
  287. * NULL
  288. * Use LINK LIST operation to process SCAN result
  289. *
  290. * 08 30 2010 cp.wu
  291. * NULL
  292. * eliminate klockwork errors
  293. *
  294. * 08 29 2010 yuche.tsai
  295. * NULL
  296. * Finish SLT TX/RX & Rate Changing Support.
  297. *
  298. * 08 24 2010 cm.chang
  299. * NULL
  300. * Support RLM initail channel of Ad-hoc, P2P and BOW
  301. *
  302. * 08 16 2010 yuche.tsai
  303. * NULL
  304. * Before composing Beacon IE, assign network type index for msdu info,
  305. * this information is needed by RLM module while composing some RLM related IE field.
  306. *
  307. * 08 16 2010 cp.wu
  308. * NULL
  309. * Replace CFG_SUPPORT_BOW by CFG_ENABLE_BT_OVER_WIFI.
  310. * There is no CFG_SUPPORT_BOW in driver domain source.
  311. *
  312. * 08 16 2010 kevin.huang
  313. * NULL
  314. * Refine AAA functions
  315. *
  316. * 08 12 2010 kevin.huang
  317. * NULL
  318. * Fix undefined pucDestAddr in bssUpdateBeaconContent()
  319. *
  320. * 08 12 2010 kevin.huang
  321. * NULL
  322. * Refine bssProcessProbeRequest() and bssSendBeaconProbeResponse()
  323. *
  324. * 08 11 2010 cp.wu
  325. * NULL
  326. * 1) do not use in-stack variable for beacon updating. (for MAUI porting)
  327. * 2) extending scanning result to 64 instead of 48
  328. *
  329. * 08 02 2010 yuche.tsai
  330. * NULL
  331. * P2P Group Negotiation Code Check in.
  332. *
  333. * 08 02 2010 george.huang
  334. * NULL
  335. * add WMM-PS test related OID/ CMD handlers
  336. *
  337. * 07 26 2010 yuche.tsai
  338. *
  339. * Add support to RX probe response for P2P.
  340. *
  341. * 07 20 2010 cp.wu
  342. *
  343. * 1) bugfix: do not stop timer for join after switched into normal_tr state, for providing chance for DHCP handshasking
  344. * 2) modify rsnPerformPolicySelection() invoking
  345. *
  346. * 07 19 2010 wh.su
  347. *
  348. * update for security supporting.
  349. *
  350. * 07 19 2010 cp.wu
  351. *
  352. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  353. * when IBSS is being merged-in, send command packet to PM for connected indication
  354. *
  355. * 07 19 2010 cp.wu
  356. *
  357. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  358. * Add Ad-Hoc support to AIS-FSM
  359. *
  360. * 07 14 2010 yarco.yang
  361. *
  362. * 1. Remove CFG_MQM_MIGRATION
  363. * 2. Add CMD_UPDATE_WMM_PARMS command
  364. *
  365. * 07 08 2010 cp.wu
  366. *
  367. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  368. *
  369. * 07 06 2010 george.huang
  370. * [WPD00001556]Basic power managemenet function
  371. * Update arguments for nicUpdateBeaconIETemplate()
  372. *
  373. * 06 29 2010 cp.wu
  374. * [WPD00003833][MT6620 and MT5931] Driver migration
  375. * 1) sync to. CMD/EVENT document v0.03
  376. * 2) simplify DTIM period parsing in scan.c only, bss.c no longer parses it again.
  377. * 3) send command packet to indicate FW-PM after
  378. * a) 1st beacon is received after AIS has connected to an AP
  379. * b) IBSS-ALONE has been created
  380. * c) IBSS-MERGE has occurred
  381. *
  382. * 06 28 2010 cp.wu
  383. * [WPD00003833][MT6620 and MT5931] Driver migration
  384. * send MMPDU in basic rate.
  385. *
  386. * 06 25 2010 george.huang
  387. * [WPD00001556]Basic power managemenet function
  388. * Create beacon update path, with expose bssUpdateBeaconContent()
  389. *
  390. * 06 21 2010 yuche.tsai
  391. * [WPD00003839][MT6620 5931][P2P] Feature migration
  392. * Fix compile error while enable WIFI_DIRECT support.
  393. *
  394. * 06 21 2010 yarco.yang
  395. * [WPD00003837][MT6620]Data Path Refine
  396. * Support CFG_MQM_MIGRATION flag
  397. *
  398. * 06 21 2010 cp.wu
  399. * [WPD00003833][MT6620 and MT5931] Driver migration
  400. * enable RX management frame handling.
  401. *
  402. * 06 21 2010 cp.wu
  403. * [WPD00003833][MT6620 and MT5931] Driver migration
  404. * specify correct value for management frames.
  405. *
  406. * 06 18 2010 cm.chang
  407. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  408. * Provide cnmMgtPktAlloc() and alloc/free function of msg/buf
  409. *
  410. * 06 15 2010 cp.wu
  411. * [WPD00003833][MT6620 and MT5931] Driver migration
  412. * correct when ADHOC support is turned on.
  413. *
  414. * 06 15 2010 cp.wu
  415. * [WPD00003833][MT6620 and MT5931] Driver migration
  416. * add scan.c.
  417. *
  418. * 06 14 2010 cp.wu
  419. * [WPD00003833][MT6620 and MT5931] Driver migration
  420. * add management dispatching function table.
  421. *
  422. * 06 11 2010 cp.wu
  423. * [WPD00003833][MT6620 and MT5931] Driver migration
  424. * auth.c is migrated.
  425. *
  426. * 06 11 2010 cp.wu
  427. * [WPD00003833][MT6620 and MT5931] Driver migration
  428. * fix compilation error when WIFI_DIRECT is turned on
  429. *
  430. * 06 11 2010 cp.wu
  431. * [WPD00003833][MT6620 and MT5931] Driver migration
  432. * add bss.c.
  433. *
  434. * 06 04 2010 george.huang
  435. * [BORA00000678][MT6620]WiFi LP integration
  436. * [PM] Support U-APSD for STA mode
  437. *
  438. * 05 28 2010 kevin.huang
  439. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  440. * Add ClientList handling API - bssClearClientList, bssAddStaRecToClientList
  441. *
  442. * 05 24 2010 kevin.huang
  443. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  444. * Update bssProcessProbeRequest() to avoid redundant SSID IE {0,0} for IOT.
  445. *
  446. * 05 21 2010 kevin.huang
  447. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  448. * Refine txmInitWtblTxRateTable() - set TX initial rate according to AP's operation rate set
  449. *
  450. * 05 18 2010 cm.chang
  451. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  452. * Ad-hoc Beacon should not carry HT OP and OBSS IEs
  453. *
  454. * 05 14 2010 kevin.huang
  455. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  456. * Use TX MGMT Frame API for sending PS NULL frame to avoid the TX Burst Mechanism in TX FW Frame API
  457. *
  458. * 05 14 2010 kevin.huang
  459. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  460. * Separate Beacon and ProbeResp IE array
  461. *
  462. * 05 12 2010 kevin.huang
  463. * [BORA00000794][WIFISYS][New Feature]Power Management Support
  464. * Add Power Management - Legacy PS-POLL support.
  465. *
  466. * 04 28 2010 tehuang.liu
  467. * [BORA00000605][WIFISYS] Phase3 Integration
  468. * Removed the use of compiling flag MQM_WMM_PARSING
  469. *
  470. * 04 27 2010 kevin.huang
  471. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  472. * Add Set Slot Time and Beacon Timeout Support for AdHoc Mode
  473. *
  474. * 04 24 2010 cm.chang
  475. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  476. * g_aprBssInfo[] depends on CFG_SUPPORT_P2P and CFG_SUPPORT_BOW
  477. *
  478. * 04 22 2010 cm.chang
  479. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  480. * First draft code to support protection in AP mode
  481. *
  482. * 04 20 2010 kevin.huang
  483. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  484. * Fix restart Beacon Timeout Func after connection diagnosis
  485. *
  486. * 04 19 2010 kevin.huang
  487. * [BORA00000714][WIFISYS][New Feature]Beacon Timeout Support
  488. * Add Beacon Timeout Support and will send Null frame to diagnose connection
  489. *
  490. * 04 16 2010 wh.su
  491. * [BORA00000680][MT6620] Support the statistic for Microsoft os query
  492. * adding the wpa-none for ibss beacon.
  493. *
  494. * 04 15 2010 wh.su
  495. * [BORA00000680][MT6620] Support the statistic for Microsoft os query
  496. * fixed the protected bit at cap info for ad-hoc.
  497. *
  498. * 03 18 2010 kevin.huang
  499. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  500. * Rename the CFG flags
  501. *
  502. * 03 16 2010 kevin.huang
  503. * [BORA00000663][WIFISYS][New Feature] AdHoc Mode Support
  504. * Add AdHoc Mode
  505. *
  506. * 02 26 2010 kevin.huang
  507. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  508. * Update outgoing beacon's TX data rate
  509. *
  510. * 02 23 2010 kevin.huang
  511. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  512. * Add DTIM count update while TX Beacon
  513. *
  514. * 02 05 2010 kevin.huang
  515. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  516. * Modify code due to define - BAND_24G and specific BSS_INFO_T was changed
  517. *
  518. * 02 05 2010 kevin.huang
  519. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  520. * Revise data structure to share the same BSS_INFO_T for avoiding coding error
  521. *
  522. * 02 04 2010 kevin.huang
  523. * [BORA00000603][WIFISYS] [New Feature] AAA Module Support
  524. * Add AAA Module Support, Revise Net Type to Net Type Index for array lookup
  525. */
  526. /*******************************************************************************
  527. * C O M P I L E R F L A G S
  528. ********************************************************************************
  529. */
  530. /*******************************************************************************
  531. * E X T E R N A L R E F E R E N C E S
  532. ********************************************************************************
  533. */
  534. #include "precomp.h"
  535. /*******************************************************************************
  536. * C O N S T A N T S
  537. ********************************************************************************
  538. */
  539. /*******************************************************************************
  540. * D A T A T Y P E S
  541. ********************************************************************************
  542. */
  543. /*******************************************************************************
  544. * P U B L I C D A T A
  545. ********************************************************************************
  546. */
  547. const PUINT_8 apucNetworkType[NETWORK_TYPE_NUM] = {
  548. (PUINT_8) "AIS",
  549. (PUINT_8) "P2P",
  550. (PUINT_8) "BOW",
  551. (PUINT_8) "MBSS"
  552. };
  553. const PUINT_8 apucNetworkOpMode[] = {
  554. (PUINT_8) "INFRASTRUCTURE",
  555. (PUINT_8) "IBSS",
  556. (PUINT_8) "ACCESS_POINT",
  557. (PUINT_8) "P2P_DEVICE",
  558. (PUINT_8) "BOW"
  559. };
  560. #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
  561. APPEND_VAR_IE_ENTRY_T txBcnIETable[] = {
  562. {(ELEM_HDR_LEN + (RATE_NUM_SW - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE} /* 50 */
  563. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE} /* 42 */
  564. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE} /* 45 */
  565. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE} /* 61 */
  566. #if CFG_ENABLE_WIFI_DIRECT
  567. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE} /* 74 */
  568. #endif
  569. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE} /* 127 */
  570. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE} /* 221 */
  571. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE} /* 221 */
  572. #if CFG_ENABLE_WIFI_DIRECT
  573. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWPAIE} /* 221 */
  574. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE} /* 48 */
  575. #if 0 /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) */
  576. , {0, p2pFuncCalculateExtra_IELenForBeacon, p2pFuncGenerateExtra_IEForBeacon} /* 221 */
  577. #else
  578. , {0, p2pFuncCalculateP2p_IELenForBeacon, p2pFuncGenerateP2p_IEForBeacon} /* 221 */
  579. , {0, p2pFuncCalculateWSC_IELenForBeacon, p2pFuncGenerateWSC_IEForBeacon} /* 221 */
  580. #endif
  581. , {0, p2pFuncCalculateP2P_IE_NoA, p2pFuncGenerateP2P_IE_NoA} /* 221 */
  582. #endif /* CFG_ENABLE_WIFI_DIRECT */
  583. #if CFG_SUPPORT_802_11AC
  584. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_CAP), NULL, rlmRspGenerateVhtCapIE} /*191 */
  585. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_OP), NULL, rlmRspGenerateVhtOpIE} /*192 */
  586. #endif
  587. #if CFG_SUPPORT_MTK_SYNERGY
  588. , {(ELEM_HDR_LEN + ELEM_MIN_LEN_MTK_OUI), NULL, rlmGenerateMTKOuiIE} /* 221 */
  589. #endif
  590. };
  591. APPEND_VAR_IE_ENTRY_T txProbRspIETable[] = {
  592. {(ELEM_HDR_LEN + (RATE_NUM_SW - ELEM_MAX_LEN_SUP_RATES)), NULL, bssGenerateExtSuppRate_IE} /* 50 */
  593. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_ERP), NULL, rlmRspGenerateErpIE} /* 42 */
  594. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_CAP), NULL, rlmRspGenerateHtCapIE} /* 45 */
  595. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_HT_OP), NULL, rlmRspGenerateHtOpIE} /* 61 */
  596. #if CFG_ENABLE_WIFI_DIRECT
  597. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_RSN), NULL, rsnGenerateRSNIE} /* 48 */
  598. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_OBSS_SCAN), NULL, rlmRspGenerateObssScanIE} /* 74 */
  599. #endif
  600. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_EXT_CAP), NULL, rlmRspGenerateExtCapIE} /* 127 */
  601. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WPA), NULL, rsnGenerateWpaNoneIE} /* 221 */
  602. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_WMM_PARAM), NULL, mqmGenerateWmmParamIE} /* 221 */
  603. #if CFG_SUPPORT_802_11AC
  604. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_CAP), NULL, rlmRspGenerateVhtCapIE} /*191 */
  605. , {(ELEM_HDR_LEN + ELEM_MAX_LEN_VHT_OP), NULL, rlmRspGenerateVhtOpIE} /*192 */
  606. #endif
  607. #if CFG_SUPPORT_MTK_SYNERGY
  608. , {(ELEM_HDR_LEN + ELEM_MIN_LEN_MTK_OUI), NULL, rlmGenerateMTKOuiIE} /* 221 */
  609. #endif
  610. };
  611. #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
  612. /*******************************************************************************
  613. * P R I V A T E D A T A
  614. ********************************************************************************
  615. */
  616. /*******************************************************************************
  617. * M A C R O S
  618. ********************************************************************************
  619. */
  620. /*******************************************************************************
  621. * F U N C T I O N D E C L A R A T I O N S
  622. ********************************************************************************
  623. */
  624. /*******************************************************************************
  625. * F U N C T I O N S
  626. ********************************************************************************
  627. */
  628. /*----------------------------------------------------------------------------*/
  629. /* Routines for all Operation Modes */
  630. /*----------------------------------------------------------------------------*/
  631. /*----------------------------------------------------------------------------*/
  632. /*!
  633. * @brief This function will decide PHY type set of STA_RECORD_T by given BSS_DESC_T for
  634. * Infrastructure or AdHoc Mode.
  635. *
  636. * @param[in] prAdapter Pointer to the Adapter structure.
  637. * @param[in] prBssDesc Received Beacon/ProbeResp from this STA
  638. * @param[out] prStaRec StaRec to be decided PHY type set
  639. *
  640. * @retval VOID
  641. */
  642. /*----------------------------------------------------------------------------*/
  643. VOID bssDetermineStaRecPhyTypeSet(IN P_ADAPTER_T prAdapter, IN P_BSS_DESC_T prBssDesc, OUT P_STA_RECORD_T prStaRec)
  644. {
  645. P_WIFI_VAR_T prWifiVar = &prAdapter->rWifiVar;
  646. UINT_8 ucHtOption = FEATURE_ENABLED;
  647. UINT_8 ucVhtOption = FEATURE_ENABLED;
  648. prStaRec->ucPhyTypeSet = prBssDesc->ucPhyTypeSet;
  649. /* Decide AIS PHY type set */
  650. if (prStaRec->eStaType == STA_TYPE_LEGACY_AP) {
  651. if (!((prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_ENABLED) ||
  652. (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_KEY_ABSENT)
  653. || (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION_DISABLED)
  654. || (prAdapter->prGlueInfo->u2WSCAssocInfoIELen)
  655. #if CFG_SUPPORT_WAPI
  656. || (prAdapter->prGlueInfo->u2WapiAssocInfoIESz)
  657. #endif
  658. )) {
  659. DBGLOG(BSS, INFO, "Ignore the HT Bit for TKIP as pairwise cipher configed!\n");
  660. prStaRec->ucPhyTypeSet &= ~(PHY_TYPE_BIT_HT | PHY_TYPE_BIT_VHT);
  661. }
  662. ucHtOption = prWifiVar->ucStaHt;
  663. ucVhtOption = prWifiVar->ucStaVht;
  664. }
  665. /* Decide P2P GC PHY type set */
  666. else if (prStaRec->eStaType == STA_TYPE_P2P_GO) {
  667. ucHtOption = prWifiVar->ucP2pGcHt;
  668. ucVhtOption = prWifiVar->ucP2pGcVht;
  669. }
  670. /* Set HT/VHT capability from Feature Option */
  671. if (IS_FEATURE_DISABLED(ucHtOption))
  672. prStaRec->ucPhyTypeSet &= ~PHY_TYPE_BIT_HT;
  673. else if (IS_FEATURE_FORCE_ENABLED(ucHtOption))
  674. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_HT;
  675. if (IS_FEATURE_DISABLED(ucVhtOption))
  676. prStaRec->ucPhyTypeSet &= ~PHY_TYPE_BIT_VHT;
  677. else if (IS_FEATURE_FORCE_ENABLED(ucVhtOption))
  678. prStaRec->ucPhyTypeSet |= PHY_TYPE_BIT_VHT;
  679. prStaRec->ucDesiredPhyTypeSet = prStaRec->ucPhyTypeSet & prAdapter->rWifiVar.ucAvailablePhyTypeSet;
  680. }
  681. /*----------------------------------------------------------------------------*/
  682. /*!
  683. * @brief This function will decide PHY type set of BSS_INFO for
  684. * AP Mode.
  685. *
  686. * @param[in] prAdapter Pointer to the Adapter structure.
  687. * @param[in] fgIsApMode Legacy AP mode or P2P GO
  688. * @param[out] prBssInfo BssInfo to be decided PHY type set
  689. *
  690. * @retval VOID
  691. */
  692. /*----------------------------------------------------------------------------*/
  693. VOID bssDetermineApBssInfoPhyTypeSet(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgIsPureAp, OUT P_BSS_INFO_T prBssInfo)
  694. {
  695. P_WIFI_VAR_T prWifiVar = &prAdapter->rWifiVar;
  696. UINT_8 ucHtOption = FEATURE_ENABLED;
  697. UINT_8 ucVhtOption = FEATURE_ENABLED;
  698. /* Decide AP mode PHY type set */
  699. if (fgIsPureAp) {
  700. ucHtOption = prWifiVar->ucApHt;
  701. ucVhtOption = prWifiVar->ucApVht;
  702. }
  703. /* Decide P2P GO PHY type set */
  704. else {
  705. ucHtOption = prWifiVar->ucP2pGoHt;
  706. ucVhtOption = prWifiVar->ucP2pGoVht;
  707. }
  708. /* Set HT/VHT capability from Feature Option */
  709. if (IS_FEATURE_DISABLED(ucHtOption))
  710. prBssInfo->ucPhyTypeSet &= ~PHY_TYPE_BIT_HT;
  711. else if (IS_FEATURE_ENABLED(ucHtOption))
  712. prBssInfo->ucPhyTypeSet |= PHY_TYPE_BIT_HT;
  713. if (IS_FEATURE_DISABLED(ucVhtOption)) {
  714. prBssInfo->ucPhyTypeSet &= ~PHY_TYPE_BIT_VHT;
  715. } else if (IS_FEATURE_FORCE_ENABLED(ucVhtOption) ||
  716. (IS_FEATURE_ENABLED(ucVhtOption) && (prBssInfo->eBand == BAND_5G))) {
  717. /* Enable HT capability if VHT is enabled */
  718. prBssInfo->ucPhyTypeSet |= PHY_TYPE_BIT_VHT;
  719. }
  720. prBssInfo->ucPhyTypeSet &= prAdapter->rWifiVar.ucAvailablePhyTypeSet;
  721. }
  722. /*----------------------------------------------------------------------------*/
  723. /*!
  724. * @brief This function will create or reset a STA_RECORD_T by given BSS_DESC_T for
  725. * Infrastructure or AdHoc Mode.
  726. *
  727. * @param[in] prAdapter Pointer to the Adapter structure.
  728. * @param[in] eStaType Assign STA Type for this STA_RECORD_T
  729. * @param[in] eNetTypeIndex Assign Net Type Index for this STA_RECORD_T
  730. * @param[in] prBssDesc Received Beacon/ProbeResp from this STA
  731. *
  732. * @retval Pointer to STA_RECORD_T
  733. */
  734. /*----------------------------------------------------------------------------*/
  735. P_STA_RECORD_T
  736. bssCreateStaRecFromBssDesc(IN P_ADAPTER_T prAdapter,
  737. IN ENUM_STA_TYPE_T eStaType, IN UINT_8 ucBssIndex, IN P_BSS_DESC_T prBssDesc)
  738. {
  739. P_STA_RECORD_T prStaRec;
  740. UINT_8 ucNonHTPhyTypeSet;
  741. P_CONNECTION_SETTINGS_T prConnSettings;
  742. ASSERT(prBssDesc);
  743. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  744. /* 4 <1> Get a valid STA_RECORD_T */
  745. prStaRec = cnmGetStaRecByAddress(prAdapter, ucBssIndex, prBssDesc->aucSrcAddr);
  746. if (!prStaRec) {
  747. prStaRec = cnmStaRecAlloc(prAdapter, eStaType, ucBssIndex, prBssDesc->aucSrcAddr);
  748. if (!prStaRec) {
  749. DBGLOG(BSS, WARN,
  750. "STA_REC entry is full, cannot acquire new entry for [" MACSTR
  751. "]!!\n", MAC2STR(prBssDesc->aucSrcAddr));
  752. ASSERT(FALSE);
  753. return NULL;
  754. }
  755. prStaRec->ucStaState = STA_STATE_1;
  756. prStaRec->ucJoinFailureCount = 0;
  757. /* TODO(Kevin): If this is an old entry, we may also reset the ucJoinFailureCount to 0. */
  758. }
  759. /* 4 <2> Update information from BSS_DESC_T to current P_STA_RECORD_T */
  760. prStaRec->u2CapInfo = prBssDesc->u2CapInfo;
  761. prStaRec->u2OperationalRateSet = prBssDesc->u2OperationalRateSet;
  762. prStaRec->u2BSSBasicRateSet = prBssDesc->u2BSSBasicRateSet;
  763. #if 1
  764. bssDetermineStaRecPhyTypeSet(prAdapter, prBssDesc, prStaRec);
  765. #else
  766. prStaRec->ucPhyTypeSet = prBssDesc->ucPhyTypeSet;
  767. if (IS_STA_IN_AIS(prStaRec)) {
  768. if (!((prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_ENABLED) ||
  769. (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION3_KEY_ABSENT)
  770. || (prAdapter->rWifiVar.rConnSettings.eEncStatus == ENUM_ENCRYPTION_DISABLED)
  771. || (prAdapter->prGlueInfo->u2WSCAssocInfoIELen)
  772. #if CFG_SUPPORT_WAPI
  773. || (prAdapter->prGlueInfo->u2WapiAssocInfoIESz)
  774. #endif
  775. )) {
  776. DBGLOG(BSS, INFO, "Ignore the HT Bit for TKIP as pairwise cipher configed!\n");
  777. prStaRec->ucPhyTypeSet &= ~PHY_TYPE_BIT_HT;
  778. }
  779. }
  780. prStaRec->ucDesiredPhyTypeSet = prStaRec->ucPhyTypeSet & prAdapter->rWifiVar.ucAvailablePhyTypeSet;
  781. #endif
  782. ucNonHTPhyTypeSet = prStaRec->ucDesiredPhyTypeSet & PHY_TYPE_SET_802_11ABG;
  783. /* Check for Target BSS's non HT Phy Types */
  784. if (ucNonHTPhyTypeSet) {
  785. if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_ERP) {
  786. prStaRec->ucNonHTBasicPhyType = PHY_TYPE_ERP_INDEX;
  787. } else if (ucNonHTPhyTypeSet & PHY_TYPE_BIT_OFDM) {
  788. prStaRec->ucNonHTBasicPhyType = PHY_TYPE_OFDM_INDEX;
  789. } else { /* if (ucNonHTPhyTypeSet & PHY_TYPE_HR_DSSS_INDEX) */
  790. prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
  791. }
  792. prStaRec->fgHasBasicPhyType = TRUE;
  793. } else {
  794. /* Use mandatory for 11N only BSS */
  795. ASSERT(prStaRec->ucPhyTypeSet & PHY_TYPE_SET_802_11N);
  796. {
  797. /* TODO(Kevin): which value should we set for 11n ? ERP ? */
  798. prStaRec->ucNonHTBasicPhyType = PHY_TYPE_HR_DSSS_INDEX;
  799. }
  800. prStaRec->fgHasBasicPhyType = FALSE;
  801. }
  802. /* Update non HT Desired Rate Set */
  803. prStaRec->u2DesiredNonHTRateSet = (prStaRec->u2OperationalRateSet & prConnSettings->u2DesiredNonHTRateSet);
  804. /* 4 <3> Update information from BSS_DESC_T to current P_STA_RECORD_T */
  805. if (IS_AP_STA(prStaRec)) {
  806. /* do not need to parse IE for DTIM,
  807. * which have been parsed before inserting into BSS_DESC_T
  808. */
  809. if (prBssDesc->ucDTIMPeriod)
  810. prStaRec->ucDTIMPeriod = prBssDesc->ucDTIMPeriod;
  811. else
  812. prStaRec->ucDTIMPeriod = 0; /* Means that TIM was not parsed. */
  813. }
  814. /* 4 <4> Update default value */
  815. prStaRec->fgDiagnoseConnection = FALSE;
  816. /* 4 <5> Update default value for other Modules */
  817. /* Determine WMM related parameters for STA_REC */
  818. mqmProcessScanResult(prAdapter, prBssDesc, prStaRec);
  819. /* 4 <6> Update Tx Rate */
  820. /* Update default Tx rate */
  821. nicTxUpdateStaRecDefaultRate(prStaRec);
  822. return prStaRec;
  823. } /* end of bssCreateStaRecFromBssDesc() */
  824. /*----------------------------------------------------------------------------*/
  825. /*!
  826. * @brief This function will compose the Null Data frame.
  827. *
  828. * @param[in] prAdapter Pointer to the Adapter structure.
  829. * @param[in] pucBuffer Pointer to the frame buffer.
  830. * @param[in] prStaRec Pointer to the STA_RECORD_T.
  831. *
  832. * @return (none)
  833. */
  834. /*----------------------------------------------------------------------------*/
  835. VOID bssComposeNullFrame(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, IN P_STA_RECORD_T prStaRec)
  836. {
  837. P_WLAN_MAC_HEADER_T prNullFrame;
  838. P_BSS_INFO_T prBssInfo;
  839. UINT_16 u2FrameCtrl;
  840. UINT_8 ucBssIndex;
  841. ASSERT(prStaRec);
  842. ucBssIndex = prStaRec->ucBssIndex;
  843. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  844. ASSERT(pucBuffer);
  845. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  846. ASSERT(prBssInfo);
  847. prNullFrame = (P_WLAN_MAC_HEADER_T) pucBuffer;
  848. /* 4 <1> Decide the Frame Control Field */
  849. u2FrameCtrl = MAC_FRAME_NULL;
  850. if (IS_AP_STA(prStaRec)) {
  851. u2FrameCtrl |= MASK_FC_TO_DS;
  852. if (prStaRec->fgSetPwrMgtBit)
  853. u2FrameCtrl |= MASK_FC_PWR_MGT;
  854. } else if (IS_CLIENT_STA(prStaRec)) {
  855. u2FrameCtrl |= MASK_FC_FROM_DS;
  856. } else if (IS_DLS_STA(prStaRec)) {
  857. /* TODO(Kevin) */
  858. } else {
  859. /* NOTE(Kevin): We won't send Null frame for IBSS */
  860. ASSERT(0);
  861. return;
  862. }
  863. /* 4 <2> Compose the Null frame */
  864. /* Fill the Frame Control field. */
  865. /* WLAN_SET_FIELD_16(&prNullFrame->u2FrameCtrl, u2FrameCtrl); */
  866. prNullFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  867. /* Fill the Address 1 field with Target Peer Address. */
  868. COPY_MAC_ADDR(prNullFrame->aucAddr1, prStaRec->aucMacAddr);
  869. /* Fill the Address 2 field with our MAC Address. */
  870. COPY_MAC_ADDR(prNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
  871. /* Fill the Address 3 field with Target BSSID. */
  872. COPY_MAC_ADDR(prNullFrame->aucAddr3, prBssInfo->aucBSSID);
  873. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  874. prNullFrame->u2SeqCtrl = 0;
  875. return;
  876. } /* end of bssComposeNullFrameHeader() */
  877. /*----------------------------------------------------------------------------*/
  878. /*!
  879. * @brief This function will compose the QoS Null Data frame.
  880. *
  881. * @param[in] prAdapter Pointer to the Adapter structure.
  882. * @param[in] pucBuffer Pointer to the frame buffer.
  883. * @param[in] prStaRec Pointer to the STA_RECORD_T.
  884. * @param[in] ucUP User Priority.
  885. * @param[in] fgSetEOSP Set the EOSP bit.
  886. *
  887. * @return (none)
  888. */
  889. /*----------------------------------------------------------------------------*/
  890. VOID
  891. bssComposeQoSNullFrame(IN P_ADAPTER_T prAdapter,
  892. IN PUINT_8 pucBuffer, IN P_STA_RECORD_T prStaRec, IN UINT_8 ucUP, IN BOOLEAN fgSetEOSP)
  893. {
  894. P_WLAN_MAC_HEADER_QOS_T prQoSNullFrame;
  895. P_BSS_INFO_T prBssInfo;
  896. UINT_16 u2FrameCtrl;
  897. UINT_16 u2QosControl;
  898. UINT_8 ucBssIndex;
  899. ASSERT(prStaRec);
  900. ucBssIndex = prStaRec->ucBssIndex;
  901. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  902. ASSERT(pucBuffer);
  903. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  904. ASSERT(prBssInfo);
  905. prQoSNullFrame = (P_WLAN_MAC_HEADER_QOS_T) pucBuffer;
  906. /* 4 <1> Decide the Frame Control Field */
  907. u2FrameCtrl = MAC_FRAME_QOS_NULL;
  908. if (IS_AP_STA(prStaRec)) {
  909. u2FrameCtrl |= MASK_FC_TO_DS;
  910. if (prStaRec->fgSetPwrMgtBit)
  911. u2FrameCtrl |= MASK_FC_PWR_MGT;
  912. } else if (IS_CLIENT_STA(prStaRec)) {
  913. u2FrameCtrl |= MASK_FC_FROM_DS;
  914. } else if (IS_DLS_STA(prStaRec)) {
  915. /* TODO(Kevin) */
  916. } else {
  917. /* NOTE(Kevin): We won't send QoS Null frame for IBSS */
  918. ASSERT(0);
  919. return;
  920. }
  921. /* 4 <2> Compose the QoS Null frame */
  922. /* Fill the Frame Control field. */
  923. /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2FrameCtrl, u2FrameCtrl); */
  924. prQoSNullFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  925. /* Fill the Address 1 field with Target Peer Address. */
  926. COPY_MAC_ADDR(prQoSNullFrame->aucAddr1, prStaRec->aucMacAddr);
  927. /* Fill the Address 2 field with our MAC Address. */
  928. COPY_MAC_ADDR(prQoSNullFrame->aucAddr2, prBssInfo->aucOwnMacAddr);
  929. /* Fill the Address 3 field with Target BSSID. */
  930. COPY_MAC_ADDR(prQoSNullFrame->aucAddr3, prBssInfo->aucBSSID);
  931. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  932. prQoSNullFrame->u2SeqCtrl = 0;
  933. u2QosControl = (UINT_16) (ucUP & WMM_QC_UP_MASK);
  934. if (fgSetEOSP)
  935. u2QosControl |= WMM_QC_EOSP;
  936. /* WLAN_SET_FIELD_16(&prQoSNullFrame->u2QosCtrl, u2QosControl); */
  937. prQoSNullFrame->u2QosCtrl = u2QosControl; /* NOTE(Kevin): Optimized for ARM */
  938. return;
  939. } /* end of bssComposeQoSNullFrameHeader() */
  940. /*----------------------------------------------------------------------------*/
  941. /*!
  942. * @brief Send the Null Frame
  943. *
  944. * @param[in] prAdapter Pointer to the Adapter structure.
  945. * @param[in] prStaRec Pointer to the STA_RECORD_T
  946. * @param[in] pfTxDoneHandler TX Done call back function
  947. *
  948. * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
  949. * @retval WLAN_STATUS_SUCCESS Succe]ss.
  950. */
  951. /*----------------------------------------------------------------------------*/
  952. WLAN_STATUS
  953. bssSendNullFrame(IN P_ADAPTER_T prAdapter, IN P_STA_RECORD_T prStaRec, IN PFN_TX_DONE_HANDLER pfTxDoneHandler)
  954. {
  955. P_MSDU_INFO_T prMsduInfo;
  956. UINT_16 u2EstimatedFrameLen;
  957. /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
  958. /* Init with MGMT Header Length */
  959. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_LEN;
  960. /* Allocate a MSDU_INFO_T */
  961. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  962. if (prMsduInfo == NULL) {
  963. DBGLOG(BSS, WARN, "No PKT_INFO_T for sending Null Frame.\n");
  964. return WLAN_STATUS_RESOURCES;
  965. }
  966. /* 4 <2> Compose Null frame in MSDU_INfO_T. */
  967. bssComposeNullFrame(prAdapter, (PUINT_8) ((ULONG) prMsduInfo->prPacket + MAC_TX_RESERVED_FIELD), prStaRec);
  968. #if 0
  969. /* 4 <3> Update information of MSDU_INFO_T */
  970. TXM_SET_DATA_PACKET(
  971. /* STA_REC ptr */ prStaRec,
  972. /* MSDU_INFO ptr */ prMsduInfo,
  973. /* MAC HDR ptr */
  974. (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD),
  975. /* MAC HDR length */ WLAN_MAC_HEADER_LEN,
  976. /* PAYLOAD ptr */
  977. (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_LEN),
  978. /* PAYLOAD length */ 0,
  979. /* Network Type Index */ (UINT_8) prStaRec->ucNetTypeIndex,
  980. /* TID */ 0 /* BE: AC1 */ ,
  981. /* Flag 802.11 */ TRUE,
  982. /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
  983. /* Resource TC */ 0 /* Irrelevant */ ,
  984. /* Flag 802.1x */ FALSE,
  985. /* TX-done callback */ pfTxDoneHandler,
  986. /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS,
  987. /* PS Session ID */ 0 /* Irrelevant */ ,
  988. /* Flag fixed rate */ TRUE,
  989. /* Fixed tx rate */
  990. g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode,
  991. /* Fixed-rate retry */
  992. BSS_DEFAULT_CONN_TEST_NULL_FRAME_RETRY_LIMIT,
  993. /* PAL LLH */ 0 /* Irrelevant */ ,
  994. /* ACL SN */ 0 /* Irrelevant */ ,
  995. /* Flag No Ack */ FALSE
  996. );
  997. /* Terminate with a NULL pointer */
  998. NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo, NULL);
  999. /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
  1000. /* Indicate the packet to TXM */
  1001. /* 4 <4> Inform TXM to send this Null frame. */
  1002. txmSendFwDataPackets(prMsduInfo);
  1003. #endif
  1004. TX_SET_MMPDU(prAdapter,
  1005. prMsduInfo,
  1006. prStaRec->ucBssIndex,
  1007. prStaRec->ucIndex, WLAN_MAC_HEADER_LEN, WLAN_MAC_HEADER_LEN, pfTxDoneHandler, MSDU_RATE_MODE_AUTO);
  1008. /* 4 <4> Inform TXM to send this Null frame. */
  1009. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  1010. return WLAN_STATUS_SUCCESS;
  1011. } /* end of bssSendNullFrame() */
  1012. /*----------------------------------------------------------------------------*/
  1013. /*!
  1014. * @brief Send the QoS Null Frame
  1015. *
  1016. * @param[in] prAdapter Pointer to the Adapter structure.
  1017. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1018. * @param[in] pfTxDoneHandler TX Done call back function
  1019. *
  1020. * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
  1021. * @retval WLAN_STATUS_SUCCESS Success.
  1022. */
  1023. /*----------------------------------------------------------------------------*/
  1024. WLAN_STATUS
  1025. bssSendQoSNullFrame(IN P_ADAPTER_T prAdapter,
  1026. IN P_STA_RECORD_T prStaRec, IN UINT_8 ucUP, IN PFN_TX_DONE_HANDLER pfTxDoneHandler)
  1027. {
  1028. P_MSDU_INFO_T prMsduInfo;
  1029. UINT_16 u2EstimatedFrameLen;
  1030. /* 4 <1> Allocate a PKT_INFO_T for Null Frame */
  1031. /* Init with MGMT Header Length */
  1032. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_QOS_LEN;
  1033. /* Allocate a MSDU_INFO_T */
  1034. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  1035. if (prMsduInfo == NULL) {
  1036. DBGLOG(BSS, WARN, "No PKT_INFO_T for sending Null Frame.\n");
  1037. return WLAN_STATUS_RESOURCES;
  1038. }
  1039. /* 4 <2> Compose Null frame in MSDU_INfO_T. */
  1040. bssComposeQoSNullFrame(prAdapter,
  1041. (PUINT_8) ((ULONG) (prMsduInfo->prPacket) + MAC_TX_RESERVED_FIELD),
  1042. prStaRec, ucUP, FALSE);
  1043. #if 0
  1044. /* 4 <3> Update information of MSDU_INFO_T */
  1045. TXM_SET_DATA_PACKET(
  1046. /* STA_REC ptr */ prStaRec,
  1047. /* MSDU_INFO ptr */ prMsduInfo,
  1048. /* MAC HDR ptr */
  1049. (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD),
  1050. /* MAC HDR length */ WLAN_MAC_HEADER_QOS_LEN,
  1051. /* PAYLOAD ptr */
  1052. (prMsduInfo->pucBuffer + MAC_TX_RESERVED_FIELD + WLAN_MAC_HEADER_QOS_LEN),
  1053. /* PAYLOAD length */ 0,
  1054. /* Network Type Index */ (UINT_8) prStaRec->ucNetTypeIndex,
  1055. /* TID */ 0 /* BE: AC1 */ ,
  1056. /* Flag 802.11 */ TRUE,
  1057. /* Pkt arrival time */ 0 /* TODO: Obtain the system time */ ,
  1058. /* Resource TC */ 0 /* Irrelevant */ ,
  1059. /* Flag 802.1x */ FALSE,
  1060. /* TX-done callback */ pfTxDoneHandler,
  1061. /* PS forwarding type */ PS_FORWARDING_TYPE_NON_PS,
  1062. /* PS Session ID */ 0 /* Irrelevant */ ,
  1063. /* Flag fixed rate */ TRUE,
  1064. /* Fixed tx rate */
  1065. g_aprBssInfo[prStaRec->ucNetTypeIndex]->ucHwDefaultFixedRateCode,
  1066. /* Fixed-rate retry */ TXM_DEFAULT_DATA_FRAME_RETRY_LIMIT,
  1067. /* PAL LLH */ 0 /* Irrelevant */ ,
  1068. /* ACL SN */ 0 /* Irrelevant */ ,
  1069. /* Flag No Ack */ FALSE
  1070. );
  1071. /* Terminate with a NULL pointer */
  1072. NIC_HIF_TX_SET_NEXT_MSDU_INFO(prMsduInfo, NULL);
  1073. /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
  1074. /* Indicate the packet to TXM */
  1075. /* 4 <4> Inform TXM to send this Null frame. */
  1076. txmSendFwDataPackets(prMsduInfo);
  1077. #endif
  1078. TX_SET_MMPDU(prAdapter,
  1079. prMsduInfo,
  1080. prStaRec->ucBssIndex,
  1081. prStaRec->ucIndex,
  1082. WLAN_MAC_HEADER_QOS_LEN, WLAN_MAC_HEADER_QOS_LEN, pfTxDoneHandler, MSDU_RATE_MODE_AUTO);
  1083. /* 4 <4> Inform TXM to send this Null frame. */
  1084. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  1085. return WLAN_STATUS_SUCCESS;
  1086. } /* end of bssSendQoSNullFrame() */
  1087. #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
  1088. /*----------------------------------------------------------------------------*/
  1089. /* Routines for both IBSS(AdHoc) and BSS(AP) */
  1090. /*----------------------------------------------------------------------------*/
  1091. /*----------------------------------------------------------------------------*/
  1092. /*!
  1093. * @brief This function is used to generate Information Elements of Extended
  1094. * Support Rate
  1095. *
  1096. * @param[in] prAdapter Pointer to the Adapter structure.
  1097. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  1098. *
  1099. * @return (none)
  1100. */
  1101. /*----------------------------------------------------------------------------*/
  1102. VOID bssGenerateExtSuppRate_IE(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  1103. {
  1104. P_BSS_INFO_T prBssInfo;
  1105. PUINT_8 pucBuffer;
  1106. UINT_8 ucExtSupRatesLen;
  1107. ASSERT(prMsduInfo);
  1108. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prMsduInfo->ucBssIndex);
  1109. ASSERT(prBssInfo);
  1110. pucBuffer = (PUINT_8) ((ULONG) prMsduInfo->prPacket + (ULONG) prMsduInfo->u2FrameLength);
  1111. ASSERT(pucBuffer);
  1112. if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES)
  1113. ucExtSupRatesLen = prBssInfo->ucAllSupportedRatesLen - ELEM_MAX_LEN_SUP_RATES;
  1114. else
  1115. ucExtSupRatesLen = 0;
  1116. /* Fill the Extended Supported Rates element. */
  1117. if (ucExtSupRatesLen) {
  1118. EXT_SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_EXTENDED_SUP_RATES;
  1119. EXT_SUP_RATES_IE(pucBuffer)->ucLength = ucExtSupRatesLen;
  1120. kalMemCopy(EXT_SUP_RATES_IE(pucBuffer)->aucExtSupportedRates,
  1121. &prBssInfo->aucAllSupportedRates[ELEM_MAX_LEN_SUP_RATES], ucExtSupRatesLen);
  1122. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1123. }
  1124. } /* end of bssGenerateExtSuppRate_IE() */
  1125. /*----------------------------------------------------------------------------*/
  1126. /*!
  1127. * @brief This function is used to compose Common Information Elements for Beacon
  1128. * or Probe Response Frame.
  1129. *
  1130. * @param[in] prMsduInfo Pointer to the composed MSDU_INFO_T.
  1131. * @param[in] prBssInfo Pointer to the BSS_INFO_T.
  1132. * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
  1133. *
  1134. * @return (none)
  1135. */
  1136. /*----------------------------------------------------------------------------*/
  1137. VOID
  1138. bssBuildBeaconProbeRespFrameCommonIEs(IN P_MSDU_INFO_T prMsduInfo, IN P_BSS_INFO_T prBssInfo, IN PUINT_8 pucDestAddr)
  1139. {
  1140. PUINT_8 pucBuffer;
  1141. UINT_8 ucSupRatesLen;
  1142. ASSERT(prMsduInfo);
  1143. ASSERT(prBssInfo);
  1144. pucBuffer = (PUINT_8) ((ULONG) prMsduInfo->prPacket + (ULONG) prMsduInfo->u2FrameLength);
  1145. ASSERT(pucBuffer);
  1146. /* Compose the frame body of the Probe Response frame. */
  1147. /* 4 <1> Fill the SSID element. */
  1148. SSID_IE(pucBuffer)->ucId = ELEM_ID_SSID;
  1149. #if 0
  1150. SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
  1151. if (prBssInfo->ucSSIDLen)
  1152. kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
  1153. #else
  1154. if (prBssInfo->eHiddenSsidType == ENUM_HIDDEN_SSID_LEN) {
  1155. if ((!pucDestAddr) && /* For Beacon only. */
  1156. (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)) {
  1157. SSID_IE(pucBuffer)->ucLength = 0;
  1158. } else { /* probe response */
  1159. SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
  1160. if (prBssInfo->ucSSIDLen)
  1161. kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
  1162. }
  1163. } else {
  1164. SSID_IE(pucBuffer)->ucLength = prBssInfo->ucSSIDLen;
  1165. if (prBssInfo->ucSSIDLen)
  1166. kalMemCopy(SSID_IE(pucBuffer)->aucSSID, prBssInfo->aucSSID, prBssInfo->ucSSIDLen);
  1167. }
  1168. #endif
  1169. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1170. pucBuffer += IE_SIZE(pucBuffer);
  1171. /* 4 <2> Fill the Supported Rates element. */
  1172. if (prBssInfo->ucAllSupportedRatesLen > ELEM_MAX_LEN_SUP_RATES)
  1173. ucSupRatesLen = ELEM_MAX_LEN_SUP_RATES;
  1174. else
  1175. ucSupRatesLen = prBssInfo->ucAllSupportedRatesLen;
  1176. if (ucSupRatesLen) {
  1177. SUP_RATES_IE(pucBuffer)->ucId = ELEM_ID_SUP_RATES;
  1178. SUP_RATES_IE(pucBuffer)->ucLength = ucSupRatesLen;
  1179. kalMemCopy(SUP_RATES_IE(pucBuffer)->aucSupportedRates, prBssInfo->aucAllSupportedRates, ucSupRatesLen);
  1180. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1181. pucBuffer += IE_SIZE(pucBuffer);
  1182. }
  1183. /* 4 <3> Fill the DS Parameter Set element. */
  1184. if (prBssInfo->eBand == BAND_2G4) {
  1185. DS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_DS_PARAM_SET;
  1186. DS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_DS_PARAMETER_SET;
  1187. DS_PARAM_IE(pucBuffer)->ucCurrChnl = prBssInfo->ucPrimaryChannel;
  1188. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1189. pucBuffer += IE_SIZE(pucBuffer);
  1190. }
  1191. /* 4 <4> IBSS Parameter Set element, ID: 6 */
  1192. if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  1193. IBSS_PARAM_IE(pucBuffer)->ucId = ELEM_ID_IBSS_PARAM_SET;
  1194. IBSS_PARAM_IE(pucBuffer)->ucLength = ELEM_MAX_LEN_IBSS_PARAMETER_SET;
  1195. WLAN_SET_FIELD_16(&(IBSS_PARAM_IE(pucBuffer)->u2ATIMWindow), prBssInfo->u2ATIMWindow);
  1196. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1197. pucBuffer += IE_SIZE(pucBuffer);
  1198. }
  1199. /* 4 <5> TIM element, ID: 5 */
  1200. if ((!pucDestAddr) && /* For Beacon only. */
  1201. (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)) {
  1202. #if CFG_ENABLE_WIFI_DIRECT
  1203. /*no fgIsP2PRegistered protect */
  1204. if (prBssInfo->eNetworkType == NETWORK_TYPE_P2P) {
  1205. #if 0
  1206. P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
  1207. UINT_8 ucBitmapControl = 0;
  1208. UINT_32 u4N1, u4N2;
  1209. prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
  1210. /* Clear existing value. */
  1211. prP2pSpecificBssInfo->ucBitmapCtrl = 0;
  1212. kalMemZero(prP2pSpecificBssInfo->aucPartialVirtualBitmap,
  1213. sizeof(prP2pSpecificBssInfo->aucPartialVirtualBitmap));
  1214. /* IEEE 802.11 2007 - 7.3.2.6 */
  1215. TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
  1216. TIM_IE(pucBuffer)->ucDTIMCount = prBssInfo->ucDTIMCount;
  1217. TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
  1218. /* Setup DTIM Count for next TBTT. */
  1219. if (prBssInfo->ucDTIMCount == 0)
  1220. /* 3 *** pmQueryBufferedBCAST(); */
  1221. /* 3 *** pmQueryBufferedPSNode(); */
  1222. /* TODO(Kevin): Call PM Module here to loop all STA_RECORD_Ts and it
  1223. * will call bssSetTIMBitmap to toggle the Bitmap.
  1224. */
  1225. /* Set Virtual Bitmap for UCAST */
  1226. /* Find the smallest number. */
  1227. /* Find the largest even number. */
  1228. u4N1 = (prP2pSpecificBssInfo->u2SmallestAID >> 4) << 1;
  1229. u4N2 = prP2pSpecificBssInfo->u2LargestAID >> 3;
  1230. ASSERT(u4N2 >= u4N1);
  1231. kalMemCopy(TIM_IE(pucBuffer)->aucPartialVirtualMap,
  1232. &prP2pSpecificBssInfo->aucPartialVirtualBitmap[u4N1], ((u4N2 - u4N1) + 1));
  1233. /* Set Virtual Bitmap for BMCAST */
  1234. /* BMC bit only indicated when DTIM count == 0. */
  1235. if (prBssInfo->ucDTIMCount == 0)
  1236. ucBitmapControl = prP2pSpecificBssInfo->ucBitmapCtrl;
  1237. TIM_IE(pucBuffer)->ucBitmapControl = ucBitmapControl | (UINT_8) u4N1;
  1238. TIM_IE(pucBuffer)->ucLength = ((u4N2 - u4N1) + 4);
  1239. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1240. #else
  1241. /* IEEE 802.11 2007 - 7.3.2.6 */
  1242. TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
  1243. /* NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only) */
  1244. TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP) /*((u4N2 - u4N1) + 4) */;
  1245. TIM_IE(pucBuffer)->ucDTIMCount = 0 /*prBssInfo->ucDTIMCount */; /* will be overwrite by FW */
  1246. TIM_IE(pucBuffer)->ucDTIMPeriod = prBssInfo->ucDTIMPeriod;
  1247. /* will be overwrite by FW */
  1248. TIM_IE(pucBuffer)->ucBitmapControl = 0 /*ucBitmapControl | (UINT_8)u4N1 */;
  1249. prMsduInfo->u2FrameLength += IE_SIZE(pucBuffer);
  1250. #endif
  1251. } else
  1252. #endif /* CFG_ENABLE_WIFI_DIRECT */
  1253. {
  1254. /* NOTE(Kevin): 1. AIS - Didn't Support AP Mode.
  1255. * 2. BOW - Didn't Support BCAST and PS.
  1256. */
  1257. }
  1258. }
  1259. } /* end of bssBuildBeaconProbeRespFrameCommonIEs() */
  1260. /*----------------------------------------------------------------------------*/
  1261. /*!
  1262. * @brief This function will compose the Beacon/Probe Response frame header and
  1263. * its fixed fields.
  1264. *
  1265. * @param[in] pucBuffer Pointer to the frame buffer.
  1266. * @param[in] pucDestAddr Pointer to the Destination Address, if NULL, means Beacon.
  1267. * @param[in] pucOwnMACAddress Given Our MAC Address.
  1268. * @param[in] pucBSSID Given BSSID of the BSS.
  1269. * @param[in] u2BeaconInterval Given Beacon Interval.
  1270. * @param[in] u2CapInfo Given Capability Info.
  1271. *
  1272. * @return (none)
  1273. */
  1274. /*----------------------------------------------------------------------------*/
  1275. VOID
  1276. bssComposeBeaconProbeRespFrameHeaderAndFF(IN PUINT_8 pucBuffer,
  1277. IN PUINT_8 pucDestAddr,
  1278. IN PUINT_8 pucOwnMACAddress,
  1279. IN PUINT_8 pucBSSID, IN UINT_16 u2BeaconInterval, IN UINT_16 u2CapInfo)
  1280. {
  1281. P_WLAN_BEACON_FRAME_T prBcnProbRspFrame;
  1282. UINT_8 aucBCAddr[] = BC_MAC_ADDR;
  1283. UINT_16 u2FrameCtrl;
  1284. DEBUGFUNC("bssComposeBeaconProbeRespFrameHeaderAndFF");
  1285. /* DBGLOG(INIT, LOUD, ("\n")); */
  1286. ASSERT(pucBuffer);
  1287. ASSERT(pucOwnMACAddress);
  1288. ASSERT(pucBSSID);
  1289. prBcnProbRspFrame = (P_WLAN_BEACON_FRAME_T) pucBuffer;
  1290. /* 4 <1> Compose the frame header of the Beacon /ProbeResp frame. */
  1291. /* Fill the Frame Control field. */
  1292. if (pucDestAddr) {
  1293. u2FrameCtrl = MAC_FRAME_PROBE_RSP;
  1294. } else {
  1295. u2FrameCtrl = MAC_FRAME_BEACON;
  1296. pucDestAddr = aucBCAddr;
  1297. }
  1298. /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2FrameCtrl, u2FrameCtrl); */
  1299. prBcnProbRspFrame->u2FrameCtrl = u2FrameCtrl; /* NOTE(Kevin): Optimized for ARM */
  1300. /* Fill the DA field with BCAST MAC ADDR or TA of ProbeReq. */
  1301. COPY_MAC_ADDR(prBcnProbRspFrame->aucDestAddr, pucDestAddr);
  1302. /* Fill the SA field with our MAC Address. */
  1303. COPY_MAC_ADDR(prBcnProbRspFrame->aucSrcAddr, pucOwnMACAddress);
  1304. /* Fill the BSSID field with current BSSID. */
  1305. COPY_MAC_ADDR(prBcnProbRspFrame->aucBSSID, pucBSSID);
  1306. /* Clear the SEQ/FRAG_NO field(HW won't overide the FRAG_NO, so we need to clear it). */
  1307. prBcnProbRspFrame->u2SeqCtrl = 0;
  1308. /* 4 <2> Compose the frame body's common fixed field part of the Beacon /ProbeResp frame. */
  1309. /* MAC will update TimeStamp field */
  1310. /* Fill the Beacon Interval field. */
  1311. /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2BeaconInterval, u2BeaconInterval); */
  1312. prBcnProbRspFrame->u2BeaconInterval = u2BeaconInterval; /* NOTE(Kevin): Optimized for ARM */
  1313. /* Fill the Capability Information field. */
  1314. /* WLAN_SET_FIELD_16(&prBcnProbRspFrame->u2CapInfo, u2CapInfo); */
  1315. prBcnProbRspFrame->u2CapInfo = u2CapInfo; /* NOTE(Kevin): Optimized for ARM */
  1316. } /* end of bssComposeBeaconProbeRespFrameHeaderAndFF() */
  1317. /*----------------------------------------------------------------------------*/
  1318. /*!
  1319. * @brief Update the Beacon Frame Template to FW for AIS AdHoc and P2P GO.
  1320. *
  1321. * @param[in] prAdapter Pointer to the Adapter structure.
  1322. * @param[in] ucBssIndex Specify which network reply the Probe Response.
  1323. *
  1324. * @retval WLAN_STATUS_SUCCESS Success.
  1325. */
  1326. /*----------------------------------------------------------------------------*/
  1327. WLAN_STATUS bssUpdateBeaconContent(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex)
  1328. {
  1329. P_BSS_INFO_T prBssInfo;
  1330. P_MSDU_INFO_T prMsduInfo;
  1331. P_WLAN_BEACON_FRAME_T prBcnFrame;
  1332. UINT_32 i;
  1333. DEBUGFUNC("bssUpdateBeaconContent");
  1334. DBGLOG(INIT, LOUD, "\n");
  1335. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  1336. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  1337. /* 4 <1> Allocate a PKT_INFO_T for Beacon Frame */
  1338. /* Allocate a MSDU_INFO_T */
  1339. /* For Beacon */
  1340. prMsduInfo = prBssInfo->prBeacon;
  1341. /* beacon prMsduInfo will be NULLify once BSS deactivated, so skip if it is */
  1342. if (prMsduInfo == NULL)
  1343. return WLAN_STATUS_SUCCESS;
  1344. /* 4 <2> Compose header */
  1345. bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
  1346. ((ULONG) (prMsduInfo->prPacket) +
  1347. MAC_TX_RESERVED_FIELD), NULL,
  1348. prBssInfo->aucOwnMacAddr, prBssInfo->aucBSSID,
  1349. prBssInfo->u2BeaconInterval, prBssInfo->u2CapInfo);
  1350. prMsduInfo->u2FrameLength = (WLAN_MAC_MGMT_HEADER_LEN +
  1351. (TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN + CAP_INFO_FIELD_LEN));
  1352. prMsduInfo->ucBssIndex = ucBssIndex;
  1353. /* 4 <3> Compose the frame body's Common IEs of the Beacon frame. */
  1354. bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, NULL);
  1355. /* 4 <4> Compose IEs in MSDU_INFO_T */
  1356. /* Append IE for Beacon */
  1357. for (i = 0; i < sizeof(txBcnIETable) / sizeof(APPEND_VAR_IE_ENTRY_T); i++) {
  1358. if (txBcnIETable[i].pfnAppendIE)
  1359. txBcnIETable[i].pfnAppendIE(prAdapter, prMsduInfo);
  1360. }
  1361. prBcnFrame = (P_WLAN_BEACON_FRAME_T) prMsduInfo->prPacket;
  1362. return nicUpdateBeaconIETemplate(prAdapter,
  1363. IE_UPD_METHOD_UPDATE_ALL,
  1364. ucBssIndex,
  1365. prBssInfo->u2CapInfo,
  1366. (PUINT_8) prBcnFrame->aucInfoElem,
  1367. prMsduInfo->u2FrameLength - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem));
  1368. } /* end of bssUpdateBeaconContent() */
  1369. /*----------------------------------------------------------------------------*/
  1370. /*!
  1371. * @brief Send the Beacon Frame(for BOW) or Probe Response Frame according to the given
  1372. * Destination Address.
  1373. *
  1374. * @param[in] prAdapter Pointer to the Adapter structure.
  1375. * @param[in] ucBssIndex Specify which network reply the Probe Response.
  1376. * @param[in] pucDestAddr Pointer to the Destination Address to reply
  1377. * @param[in] u4ControlFlags Control flags for information on Probe Response.
  1378. *
  1379. * @retval WLAN_STATUS_RESOURCE No available resources to send frame.
  1380. * @retval WLAN_STATUS_SUCCESS Success.
  1381. */
  1382. /*----------------------------------------------------------------------------*/
  1383. WLAN_STATUS
  1384. bssSendBeaconProbeResponse(IN P_ADAPTER_T prAdapter,
  1385. IN UINT_8 ucBssIndex, IN PUINT_8 pucDestAddr, IN UINT_32 u4ControlFlags)
  1386. {
  1387. P_BSS_INFO_T prBssInfo;
  1388. P_MSDU_INFO_T prMsduInfo;
  1389. UINT_16 u2EstimatedFrameLen;
  1390. UINT_16 u2EstimatedFixedIELen;
  1391. UINT_16 u2EstimatedExtraIELen;
  1392. P_APPEND_VAR_IE_ENTRY_T prIeArray = NULL;
  1393. UINT_32 u4IeArraySize = 0;
  1394. UINT_32 i;
  1395. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  1396. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  1397. if (!pucDestAddr) { /* For Beacon */
  1398. prIeArray = &txBcnIETable[0];
  1399. u4IeArraySize = sizeof(txBcnIETable) / sizeof(APPEND_VAR_IE_ENTRY_T);
  1400. } else {
  1401. prIeArray = &txProbRspIETable[0];
  1402. u4IeArraySize = sizeof(txProbRspIETable) / sizeof(APPEND_VAR_IE_ENTRY_T);
  1403. }
  1404. /* 4 <1> Allocate a PKT_INFO_T for Beacon /Probe Response Frame */
  1405. /* Allocate a MSDU_INFO_T */
  1406. /* Init with MGMT Header Length + Length of Fixed Fields + Common IE Fields */
  1407. u2EstimatedFrameLen = MAC_TX_RESERVED_FIELD +
  1408. WLAN_MAC_MGMT_HEADER_LEN +
  1409. TIMESTAMP_FIELD_LEN +
  1410. BEACON_INTERVAL_FIELD_LEN +
  1411. CAP_INFO_FIELD_LEN +
  1412. (ELEM_HDR_LEN + ELEM_MAX_LEN_SSID) +
  1413. (ELEM_HDR_LEN + ELEM_MAX_LEN_SUP_RATES) +
  1414. (ELEM_HDR_LEN + ELEM_MAX_LEN_DS_PARAMETER_SET) +
  1415. (ELEM_HDR_LEN + ELEM_MAX_LEN_IBSS_PARAMETER_SET) + (ELEM_HDR_LEN + (3 + MAX_LEN_TIM_PARTIAL_BMP));
  1416. /* + Extra IE Length */
  1417. u2EstimatedExtraIELen = 0;
  1418. for (i = 0; i < u4IeArraySize; i++) {
  1419. u2EstimatedFixedIELen = prIeArray[i].u2EstimatedFixedIELen;
  1420. if (u2EstimatedFixedIELen) {
  1421. u2EstimatedExtraIELen += u2EstimatedFixedIELen;
  1422. } else {
  1423. ASSERT(prIeArray[i].pfnCalculateVariableIELen);
  1424. u2EstimatedExtraIELen += (UINT_16)
  1425. prIeArray[i].pfnCalculateVariableIELen(prAdapter, ucBssIndex, NULL);
  1426. }
  1427. }
  1428. u2EstimatedFrameLen += u2EstimatedExtraIELen;
  1429. prMsduInfo = cnmMgtPktAlloc(prAdapter, u2EstimatedFrameLen);
  1430. if (prMsduInfo == NULL) {
  1431. DBGLOG(BSS, WARN, "No PKT_INFO_T for sending %s.\n", ((!pucDestAddr) ? "Beacon" : "Probe Response"));
  1432. return WLAN_STATUS_RESOURCES;
  1433. }
  1434. /* 4 <2> Compose Beacon/Probe Response frame header and fixed fields in MSDU_INfO_T. */
  1435. /* Compose Header and Fixed Field */
  1436. #if CFG_ENABLE_WIFI_DIRECT
  1437. if (u4ControlFlags & BSS_PROBE_RESP_USE_P2P_DEV_ADDR) {
  1438. if (prAdapter->fgIsP2PRegistered) {
  1439. bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
  1440. ((ULONG) (prMsduInfo->prPacket)
  1441. + MAC_TX_RESERVED_FIELD),
  1442. pucDestAddr,
  1443. prAdapter->rWifiVar.aucDeviceAddress,
  1444. prAdapter->rWifiVar.aucDeviceAddress,
  1445. DOT11_BEACON_PERIOD_DEFAULT,
  1446. (prBssInfo->u2CapInfo & ~(CAP_INFO_ESS |
  1447. CAP_INFO_IBSS)));
  1448. }
  1449. } else
  1450. #endif /* CFG_ENABLE_WIFI_DIRECT */
  1451. {
  1452. bssComposeBeaconProbeRespFrameHeaderAndFF((PUINT_8)
  1453. ((ULONG) (prMsduInfo->prPacket) +
  1454. MAC_TX_RESERVED_FIELD), pucDestAddr,
  1455. prBssInfo->aucOwnMacAddr,
  1456. prBssInfo->aucBSSID,
  1457. prBssInfo->u2BeaconInterval, prBssInfo->u2CapInfo);
  1458. }
  1459. /* 4 <3> Update information of MSDU_INFO_T */
  1460. TX_SET_MMPDU(prAdapter,
  1461. prMsduInfo,
  1462. ucBssIndex,
  1463. STA_REC_INDEX_BMCAST,
  1464. WLAN_MAC_MGMT_HEADER_LEN,
  1465. (WLAN_MAC_MGMT_HEADER_LEN + TIMESTAMP_FIELD_LEN + BEACON_INTERVAL_FIELD_LEN +
  1466. CAP_INFO_FIELD_LEN), NULL, MSDU_RATE_MODE_AUTO);
  1467. /* 4 <4> Compose the frame body's Common IEs of the Beacon/ProbeResp frame. */
  1468. bssBuildBeaconProbeRespFrameCommonIEs(prMsduInfo, prBssInfo, pucDestAddr);
  1469. /* 4 <5> Compose IEs in MSDU_INFO_T */
  1470. /* Append IE */
  1471. for (i = 0; i < u4IeArraySize; i++) {
  1472. if (prIeArray[i].pfnAppendIE)
  1473. prIeArray[i].pfnAppendIE(prAdapter, prMsduInfo);
  1474. }
  1475. /* TODO(Kevin): Also release the unused tail room of the composed MMPDU */
  1476. /* 4 <6> Inform TXM to send this Beacon /Probe Response frame. */
  1477. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  1478. return WLAN_STATUS_SUCCESS;
  1479. } /* end of bssSendBeaconProbeResponse() */
  1480. /*----------------------------------------------------------------------------*/
  1481. /*!
  1482. * @brief This function will process the Rx Probe Request Frame and then send
  1483. * back the corresponding Probe Response Frame if the specified conditions
  1484. * were matched.
  1485. *
  1486. * @param[in] prAdapter Pointer to the Adapter structure.
  1487. * @param[in] prSwRfb Pointer to SW RFB data structure.
  1488. *
  1489. * @retval WLAN_STATUS_SUCCESS Always return success
  1490. */
  1491. /*----------------------------------------------------------------------------*/
  1492. WLAN_STATUS bssProcessProbeRequest(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1493. {
  1494. P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
  1495. P_BSS_INFO_T prBssInfo;
  1496. UINT_8 ucBssIndex;
  1497. UINT_8 aucBCBSSID[] = BC_BSSID;
  1498. BOOLEAN fgIsBcBssid;
  1499. BOOLEAN fgReplyProbeResp;
  1500. UINT_32 u4CtrlFlagsForProbeResp = 0;
  1501. ENUM_BAND_T eBand;
  1502. UINT_8 ucHwChannelNum;
  1503. ASSERT(prSwRfb);
  1504. /* 4 <1> Parse Probe Req and Get BSSID */
  1505. prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
  1506. if (EQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID))
  1507. fgIsBcBssid = TRUE;
  1508. else
  1509. fgIsBcBssid = FALSE;
  1510. /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
  1511. for (ucBssIndex = 0; ucBssIndex <= P2P_DEV_BSS_INDEX; ucBssIndex++) {
  1512. if ((ucBssIndex >= BSS_INFO_NUM) && (ucBssIndex != P2P_DEV_BSS_INDEX))
  1513. continue;
  1514. if (!IS_NET_ACTIVE(prAdapter, ucBssIndex))
  1515. continue;
  1516. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  1517. if ((!fgIsBcBssid) && UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID))
  1518. continue;
  1519. eBand = HAL_RX_STATUS_GET_RF_BAND(prSwRfb->prRxStatus);
  1520. ucHwChannelNum = HAL_RX_STATUS_GET_CHNL_NUM(prSwRfb->prRxStatus);
  1521. if (prBssInfo->eBand != eBand)
  1522. continue;
  1523. if (prBssInfo->ucPrimaryChannel != ucHwChannelNum)
  1524. continue;
  1525. fgReplyProbeResp = FALSE;
  1526. if (NETWORK_TYPE_AIS == prBssInfo->eNetworkType) {
  1527. #if CFG_SUPPORT_ADHOC
  1528. fgReplyProbeResp = aisValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
  1529. #endif
  1530. }
  1531. #if CFG_ENABLE_WIFI_DIRECT
  1532. else if ((prAdapter->fgIsP2PRegistered) && (NETWORK_TYPE_P2P == prBssInfo->eNetworkType)) {
  1533. fgReplyProbeResp =
  1534. p2pFuncValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp,
  1535. (prBssInfo->ucBssIndex == P2P_DEV_BSS_INDEX),
  1536. (UINT_8) prBssInfo->u4PrivateData);
  1537. }
  1538. #endif
  1539. #if CFG_ENABLE_BT_OVER_WIFI
  1540. else if (NETWORK_TYPE_BOW == prBssInfo->eNetworkType)
  1541. fgReplyProbeResp = bowValidateProbeReq(prAdapter, prSwRfb, &u4CtrlFlagsForProbeResp);
  1542. #endif
  1543. if (fgReplyProbeResp) {
  1544. if (nicTxGetFreeCmdCount(prAdapter) > (CFG_TX_MAX_CMD_PKT_NUM / 2)) {
  1545. /* Resource margin is enough */
  1546. bssSendBeaconProbeResponse(prAdapter, ucBssIndex,
  1547. prMgtHdr->aucSrcAddr, u4CtrlFlagsForProbeResp);
  1548. }
  1549. }
  1550. }
  1551. return WLAN_STATUS_SUCCESS;
  1552. } /* end of bssProcessProbeRequest() */
  1553. #if 0 /* NOTE(Kevin): condition check should move to P2P_FSM.c */
  1554. /*----------------------------------------------------------------------------*/
  1555. /*!
  1556. * @brief This function will process the Rx Probe Request Frame and then send
  1557. * back the corresponding Probe Response Frame if the specified conditions
  1558. * were matched.
  1559. *
  1560. * @param[in] prSwRfb Pointer to SW RFB data structure.
  1561. *
  1562. * @retval WLAN_STATUS_SUCCESS Always return success
  1563. */
  1564. /*----------------------------------------------------------------------------*/
  1565. WLAN_STATUS bssProcessProbeRequest(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1566. {
  1567. P_WLAN_MAC_MGMT_HEADER_T prMgtHdr;
  1568. P_BSS_INFO_T prBssInfo;
  1569. P_IE_SSID_T prIeSsid = (P_IE_SSID_T) NULL;
  1570. P_IE_SUPPORTED_RATE_T prIeSupportedRate = (P_IE_SUPPORTED_RATE_T) NULL;
  1571. P_IE_EXT_SUPPORTED_RATE_T prIeExtSupportedRate = (P_IE_EXT_SUPPORTED_RATE_T) NULL;
  1572. PUINT_8 pucIE;
  1573. UINT_16 u2IELength;
  1574. UINT_16 u2Offset = 0;
  1575. UINT_8 aucBCBSSID[] = BC_BSSID;
  1576. ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex;
  1577. BOOLEAN fgReplyProbeResp;
  1578. #if CFG_ENABLE_WIFI_DIRECT
  1579. BOOLEAN fgP2PTargetDeviceFound;
  1580. UINT_8 aucP2PWildcardSSID[] = P2P_WILDCARD_SSID;
  1581. #endif
  1582. ASSERT(prSwRfb);
  1583. /* 4 <1> Parse Probe Req and Get SSID IE ptr */
  1584. prMgtHdr = (P_WLAN_MAC_MGMT_HEADER_T) prSwRfb->pvHeader;
  1585. u2IELength = prSwRfb->u2PacketLen - prSwRfb->u2HeaderLen;
  1586. pucIE = (PUINT_8) ((UINT_32) prSwRfb->pvHeader + prSwRfb->u2HeaderLen);
  1587. prIeSsid = (P_IE_SSID_T) NULL;
  1588. IE_FOR_EACH(pucIE, u2IELength, u2Offset) {
  1589. switch (IE_ID(pucIE)) {
  1590. case ELEM_ID_SSID:
  1591. if ((!prIeSsid) && (IE_LEN(pucIE) <= ELEM_MAX_LEN_SSID))
  1592. prIeSsid = (P_IE_SSID_T) pucIE;
  1593. break;
  1594. case ELEM_ID_SUP_RATES:
  1595. /* NOTE(Kevin): Buffalo WHR-G54S's supported rate set IE exceed 8.
  1596. * IE_LEN(pucIE) == 12, "1(B), 2(B), 5.5(B), 6(B), 9(B), 11(B),
  1597. * 12(B), 18(B), 24(B), 36(B), 48(B), 54(B)"
  1598. */
  1599. /* if (IE_LEN(pucIE) <= ELEM_MAX_LEN_SUP_RATES) { */
  1600. if (IE_LEN(pucIE) <= RATE_NUM_SW)
  1601. prIeSupportedRate = SUP_RATES_IE(pucIE);
  1602. break;
  1603. case ELEM_ID_EXTENDED_SUP_RATES:
  1604. prIeExtSupportedRate = EXT_SUP_RATES_IE(pucIE);
  1605. break;
  1606. #if CFG_ENABLE_WIFI_DIRECT
  1607. /* TODO: P2P IE & WCS IE parsing for P2P. */
  1608. case ELEM_ID_P2P:
  1609. break;
  1610. #endif
  1611. /* no default */
  1612. }
  1613. } /* end of IE_FOR_EACH */
  1614. /* 4 <2> Check network conditions before reply Probe Response Frame (Consider Concurrent) */
  1615. for (eNetTypeIndex = NETWORK_TYPE_AIS_INDEX; eNetTypeIndex < NETWORK_TYPE_INDEX_NUM; eNetTypeIndex++) {
  1616. if (!IS_NET_ACTIVE(prAdapter, eNetTypeIndex))
  1617. continue;
  1618. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
  1619. if (UNEQUAL_MAC_ADDR(aucBCBSSID, prMgtHdr->aucBSSID) &&
  1620. UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prMgtHdr->aucBSSID)) {
  1621. /* BSSID not Wildcard BSSID. */
  1622. continue;
  1623. }
  1624. fgReplyProbeResp = FALSE;
  1625. if (NETWORK_TYPE_AIS_INDEX == eNetTypeIndex) {
  1626. if (prBssInfo->eCurrentOPMode == OP_MODE_IBSS) {
  1627. /* TODO(Kevin): Check if we are IBSS Master. */
  1628. if (prIeSsid) {
  1629. if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
  1630. EQUAL_SSID(prBssInfo->aucSSID,
  1631. prBssInfo->ucSSIDLen, prIeSsid->aucSSID, prIeSsid->ucLength))
  1632. fgReplyProbeResp = TRUE;
  1633. }
  1634. }
  1635. }
  1636. #if CFG_ENABLE_WIFI_DIRECT
  1637. else if (NETWORK_TYPE_P2P_INDEX == eNetTypeIndex) {
  1638. /* TODO(Kevin): Move following lines to p2p_fsm.c */
  1639. if ((prIeSsid) &&
  1640. ((prIeSsid->ucLength == BC_SSID_LEN) ||
  1641. (EQUAL_SSID(aucP2PWildcardSSID,
  1642. P2P_WILDCARD_SSID_LEN, prIeSsid->aucSSID, prIeSsid->ucLength)))) {
  1643. if (p2pFsmRunEventRxProbeRequestFrame(prAdapter, prSwRfb)) {
  1644. /* Extand channel request time & cancel scan request. */
  1645. P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T) NULL;
  1646. /* TODO: RX probe request may not caused by LISTEN state. */
  1647. /* TODO: It can be GO. */
  1648. /* Generally speaking, cancel a non-exist scan request is fine.
  1649. * We can check P2P FSM here for only LISTEN state.
  1650. */
  1651. P_MSG_SCN_SCAN_CANCEL prScanCancelMsg;
  1652. prP2pFsmInfo = prAdapter->rWifiVar.prP2pFsmInfo;
  1653. /* Abort JOIN process. */
  1654. prScanCancelMsg =
  1655. (P_MSG_SCN_SCAN_CANCEL) cnmMemAlloc(prAdapter,
  1656. RAM_TYPE_MSG,
  1657. sizeof(MSG_SCN_SCAN_CANCEL));
  1658. if (!prScanCancelMsg) {
  1659. ASSERT(0); /* Can't abort SCN FSM */
  1660. continue;
  1661. }
  1662. prScanCancelMsg->rMsgHdr.eMsgId = MID_P2P_SCN_SCAN_CANCEL;
  1663. prScanCancelMsg->ucSeqNum = prP2pFsmInfo->ucSeqNumOfScnMsg;
  1664. prScanCancelMsg->ucNetTypeIndex = (UINT_8) NETWORK_TYPE_P2P_INDEX;
  1665. prScanCancelMsg->fgIsChannelExt = TRUE;
  1666. mboxSendMsg(prAdapter,
  1667. MBOX_ID_0, (P_MSG_HDR_T) prScanCancelMsg, MSG_SEND_METHOD_BUF);
  1668. }
  1669. } else {
  1670. /* 1. Probe Request without SSID.
  1671. * 2. Probe Request with SSID not Wildcard SSID & not P2P Wildcard SSID.
  1672. */
  1673. continue;
  1674. }
  1675. #if 0 /* Frog */
  1676. if (prAdapter->rWifiVar.prP2pFsmInfo->eCurrentState == P2P_STATE_LISTEN) {
  1677. if (prIeSupportedRate || prIeExtSupportedRate) {
  1678. UINT_16 u2OperationalRateSet, u2BSSBasicRateSet;
  1679. BOOLEAN fgIsUnknownBssBasicRate;
  1680. /* Ignore any Basic Bit */
  1681. rateGetRateSetFromIEs(prIeSupportedRate, prIeExtSupportedRate,
  1682. &u2OperationalRateSet,
  1683. &u2BSSBasicRateSet, &fgIsUnknownBssBasicRate);
  1684. if (u2OperationalRateSet & ~RATE_SET_HR_DSSS)
  1685. continue;
  1686. }
  1687. }
  1688. /* TODO: Check channel time before first check point to: */
  1689. /* If Target device is selected:
  1690. * 1. Send XXXX request frame.
  1691. * else
  1692. * 1. Send Probe Response frame.
  1693. */
  1694. if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
  1695. /* TODO(Kevin): During PROVISION state, can we reply Probe Response ? */
  1696. /* TODO(Kevin):
  1697. * If we are GO, accept legacy client --> accept Wildcard SSID
  1698. * If we are in Listen State, accept only P2P Device --> check P2P IE and WPS IE
  1699. */
  1700. if (prIeSsid) {
  1701. UINT_8 aucSSID[] = P2P_WILDCARD_SSID;
  1702. if ((prIeSsid->ucLength == BC_SSID_LEN) || /* WILDCARD SSID */
  1703. EQUAL_SSID(prBssInfo->aucSSID,
  1704. prBssInfo->ucSSIDLen, prIeSsid->aucSSID, prIeSsid->ucLength)
  1705. || EQUAL_SSID(aucSSID, P2P_WILDCARD_SSID_LEN,
  1706. prIeSsid->aucSSID, prIeSsid->ucLength)) {
  1707. fgReplyProbeResp = TRUE;
  1708. }
  1709. }
  1710. /* else if (FALSE) { */
  1711. /* } */
  1712. /* TODO(Kevin): Check P2P IE and WPS IE */
  1713. }
  1714. #endif
  1715. }
  1716. #endif
  1717. else
  1718. ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  1719. if (fgReplyProbeResp)
  1720. bssSendBeaconProbeResponse(prAdapter, eNetTypeIndex, prMgtHdr->aucSrcAddr);
  1721. }
  1722. return WLAN_STATUS_SUCCESS;
  1723. } /* end of bssProcessProbeRequest() */
  1724. #endif
  1725. /*----------------------------------------------------------------------------*/
  1726. /*!
  1727. * @brief This function is used to initialize the client list for AdHoc or AP Mode
  1728. *
  1729. * @param[in] prAdapter Pointer to the Adapter structure.
  1730. * @param[in] prBssInfo Given related BSS_INFO_T.
  1731. *
  1732. * @return (none)
  1733. */
  1734. /*----------------------------------------------------------------------------*/
  1735. VOID bssInitializeClientList(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  1736. {
  1737. P_LINK_T prStaRecOfClientList;
  1738. ASSERT(prBssInfo);
  1739. prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
  1740. if (!LINK_IS_EMPTY(prStaRecOfClientList))
  1741. LINK_INITIALIZE(prStaRecOfClientList);
  1742. DBGLOG(BSS, INFO, "Init BSS[%u] Client List\n", prBssInfo->ucBssIndex);
  1743. bssCheckClientList(prAdapter, prBssInfo);
  1744. } /* end of bssClearClientList() */
  1745. /*----------------------------------------------------------------------------*/
  1746. /*!
  1747. * @brief This function is used to Add a STA_RECORD_T to the client list for AdHoc or AP Mode
  1748. *
  1749. * @param[in] prAdapter Pointer to the Adapter structure.
  1750. * @param[in] prBssInfo Given related BSS_INFO_T.
  1751. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1752. *
  1753. * @return (none)
  1754. */
  1755. /*----------------------------------------------------------------------------*/
  1756. VOID bssAddClient(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN P_STA_RECORD_T prStaRec)
  1757. {
  1758. P_LINK_T prClientList;
  1759. P_STA_RECORD_T prCurrStaRec;
  1760. ASSERT(prBssInfo);
  1761. prClientList = &prBssInfo->rStaRecOfClientList;
  1762. LINK_FOR_EACH_ENTRY(prCurrStaRec, prClientList, rLinkEntry, STA_RECORD_T) {
  1763. if (prCurrStaRec == prStaRec) {
  1764. DBGLOG(BSS, WARN,
  1765. "Current Client List already contains that STA_RECORD_T[" MACSTR "]\n",
  1766. MAC2STR(prStaRec->aucMacAddr));
  1767. return;
  1768. }
  1769. }
  1770. LINK_INSERT_TAIL(prClientList, &prStaRec->rLinkEntry);
  1771. bssCheckClientList(prAdapter, prBssInfo);
  1772. } /* end of bssAddStaRecToClientList() */
  1773. /*----------------------------------------------------------------------------*/
  1774. /*!
  1775. * @brief This function is used to Remove a STA_RECORD_T from the client list for AdHoc or AP Mode
  1776. *
  1777. * @param[in] prAdapter Pointer to the Adapter structure.
  1778. * @param[in] prStaRec Pointer to the STA_RECORD_T
  1779. *
  1780. * @return (none)
  1781. */
  1782. /*----------------------------------------------------------------------------*/
  1783. BOOLEAN bssRemoveClient(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN P_STA_RECORD_T prStaRec)
  1784. {
  1785. P_LINK_T prClientList;
  1786. P_STA_RECORD_T prCurrStaRec;
  1787. ASSERT(prBssInfo);
  1788. prClientList = &prBssInfo->rStaRecOfClientList;
  1789. LINK_FOR_EACH_ENTRY(prCurrStaRec, prClientList, rLinkEntry, STA_RECORD_T) {
  1790. if (prCurrStaRec == prStaRec) {
  1791. LINK_REMOVE_KNOWN_ENTRY(prClientList, &prStaRec->rLinkEntry);
  1792. return TRUE;
  1793. }
  1794. }
  1795. DBGLOG(BSS, INFO, "Current Client List didn't contain that STA_RECORD_T["
  1796. MACSTR "] before removing.\n", MAC2STR(prStaRec->aucMacAddr));
  1797. bssCheckClientList(prAdapter, prBssInfo);
  1798. return FALSE;
  1799. } /* end of bssRemoveStaRecFromClientList() */
  1800. P_STA_RECORD_T bssRemoveClientByMac(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN PUINT_8 pucMac)
  1801. {
  1802. P_LINK_T prClientList;
  1803. P_STA_RECORD_T prCurrStaRec;
  1804. ASSERT(prBssInfo);
  1805. prClientList = &prBssInfo->rStaRecOfClientList;
  1806. LINK_FOR_EACH_ENTRY(prCurrStaRec, prClientList, rLinkEntry, STA_RECORD_T) {
  1807. if (EQUAL_MAC_ADDR(prCurrStaRec->aucMacAddr, pucMac)) {
  1808. LINK_REMOVE_KNOWN_ENTRY(prClientList, &prCurrStaRec->rLinkEntry);
  1809. return prCurrStaRec;
  1810. }
  1811. }
  1812. DBGLOG(BSS, INFO, "Current Client List didn't contain that STA_RECORD_T["
  1813. MACSTR "] before removing.\n", MAC2STR(pucMac));
  1814. bssCheckClientList(prAdapter, prBssInfo);
  1815. return NULL;
  1816. }
  1817. P_STA_RECORD_T bssRemoveHeadClient(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  1818. {
  1819. P_LINK_T prStaRecOfClientList;
  1820. P_STA_RECORD_T prStaRec = NULL;
  1821. ASSERT(prBssInfo);
  1822. prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
  1823. if (!LINK_IS_EMPTY(prStaRecOfClientList))
  1824. LINK_REMOVE_HEAD(prStaRecOfClientList, prStaRec, P_STA_RECORD_T);
  1825. bssCheckClientList(prAdapter, prBssInfo);
  1826. return prStaRec;
  1827. }
  1828. UINT_32 bssGetClientCount(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  1829. {
  1830. return prBssInfo->rStaRecOfClientList.u4NumElem;
  1831. }
  1832. VOID bssDumpClientList(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  1833. {
  1834. P_LINK_T prClientList;
  1835. P_STA_RECORD_T prCurrStaRec;
  1836. UINT_8 ucCount = 0;
  1837. ASSERT(prBssInfo);
  1838. prClientList = &prBssInfo->rStaRecOfClientList;
  1839. DBGLOG(SW4, INFO, "Dump BSS[%u] Client List NUM[%u]\n", prBssInfo->ucBssIndex, prClientList->u4NumElem);
  1840. LINK_FOR_EACH_ENTRY(prCurrStaRec, prClientList, rLinkEntry, STA_RECORD_T) {
  1841. if (!prCurrStaRec) {
  1842. DBGLOG(SW4, INFO, "[%2u] is NULL STA_REC\n", ucCount);
  1843. break;
  1844. }
  1845. DBGLOG(SW4, INFO, "[%2u] STA[%u] [" MACSTR "]\n", ucCount,
  1846. prCurrStaRec->ucIndex, MAC2STR(prCurrStaRec->aucMacAddr));
  1847. ucCount++;
  1848. }
  1849. }
  1850. VOID bssCheckClientList(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  1851. {
  1852. P_LINK_T prClientList;
  1853. P_STA_RECORD_T prCurrStaRec;
  1854. UINT_8 ucCount = 0;
  1855. BOOLEAN fgError = FALSE;
  1856. ASSERT(prBssInfo);
  1857. prClientList = &prBssInfo->rStaRecOfClientList;
  1858. /* Check MAX number */
  1859. if (prClientList->u4NumElem > P2P_MAXIMUM_CLIENT_COUNT) {
  1860. DBGLOG(SW4, INFO, "BSS[%u] Client List NUM[%u] ERR\n",
  1861. prBssInfo->ucBssIndex, prClientList->u4NumElem);
  1862. fgError = TRUE;
  1863. }
  1864. /* Check default list status */
  1865. if (prClientList->u4NumElem == 0) {
  1866. if ((PVOID) prClientList->prNext != (PVOID) prClientList)
  1867. fgError = TRUE;
  1868. if ((PVOID) prClientList->prPrev != (PVOID) prClientList)
  1869. fgError = TRUE;
  1870. if (fgError) {
  1871. DBGLOG(SW4, INFO, "BSS[%u] Client List PTR next/prev[%p/%p] ERR\n",
  1872. prBssInfo->ucBssIndex, prClientList->prNext, prClientList->prPrev);
  1873. }
  1874. }
  1875. /* Traverse list */
  1876. LINK_FOR_EACH_ENTRY(prCurrStaRec, prClientList, rLinkEntry, STA_RECORD_T) {
  1877. if (!prCurrStaRec) {
  1878. fgError = TRUE;
  1879. DBGLOG(SW4, INFO, "BSS[%u] Client List NULL PTR ERR\n", prBssInfo->ucBssIndex);
  1880. break;
  1881. }
  1882. ucCount++;
  1883. }
  1884. /* Check real count and list number */
  1885. if (ucCount != prClientList->u4NumElem) {
  1886. DBGLOG(SW4, INFO, "BSS[%u] Client List NUM[%u] REAL CNT[%u] ERR\n",
  1887. prBssInfo->ucBssIndex, prClientList->u4NumElem, ucCount);
  1888. fgError = TRUE;
  1889. }
  1890. if (fgError)
  1891. bssDumpClientList(prAdapter, prBssInfo);
  1892. }
  1893. #endif /* CFG_SUPPORT_ADHOC || CFG_SUPPORT_AAA */
  1894. #if CFG_SUPPORT_ADHOC
  1895. /*----------------------------------------------------------------------------*/
  1896. /* Routines for IBSS(AdHoc) only */
  1897. /*----------------------------------------------------------------------------*/
  1898. /*----------------------------------------------------------------------------*/
  1899. /*!
  1900. * @brief This function is used to process Beacons from current Ad-Hoc network peers.
  1901. * We also process Beacons from other Ad-Hoc network during SCAN. If it has
  1902. * the same SSID and we'll decide to merge into it if it has a larger TSF.
  1903. *
  1904. * @param[in] prAdapter Pointer to the Adapter structure.
  1905. * @param[in] prBssInfo Pointer to the BSS_INFO_T.
  1906. * @param[in] prBSSDesc Pointer to the BSS Descriptor.
  1907. *
  1908. * @return (none)
  1909. */
  1910. /*----------------------------------------------------------------------------*/
  1911. VOID
  1912. ibssProcessMatchedBeacon(IN P_ADAPTER_T prAdapter,
  1913. IN P_BSS_INFO_T prBssInfo, IN P_BSS_DESC_T prBssDesc, IN UINT_8 ucRCPI)
  1914. {
  1915. P_STA_RECORD_T prStaRec = NULL;
  1916. BOOLEAN fgIsCheckCapability = FALSE;
  1917. BOOLEAN fgIsCheckTSF = FALSE;
  1918. BOOLEAN fgIsGoingMerging = FALSE;
  1919. BOOLEAN fgIsSameBSSID;
  1920. ASSERT(prBssInfo);
  1921. ASSERT(prBssDesc);
  1922. /* 4 <1> Process IBSS Beacon only after we create or merge with other IBSS. */
  1923. if (!prBssInfo->fgIsBeaconActivated)
  1924. return;
  1925. /* 4 <2> Get the STA_RECORD_T of TA. */
  1926. prStaRec = cnmGetStaRecByAddress(prAdapter, prAdapter->prAisBssInfo->ucBssIndex, prBssDesc->aucSrcAddr);
  1927. fgIsSameBSSID = UNEQUAL_MAC_ADDR(prBssInfo->aucBSSID, prBssDesc->aucBSSID) ? FALSE : TRUE;
  1928. /* 4 <3> IBSS Merge Decision Flow for Processing Beacon. */
  1929. if (fgIsSameBSSID) {
  1930. /* Same BSSID:
  1931. * Case I. This is a new TA and it has decide to merged with us.
  1932. * a) If fgIsMerging == FALSE - we will send msg to notify AIS.
  1933. * b) If fgIsMerging == TRUE - already notify AIS.
  1934. * Case II. This is an old TA and we've already merged together.
  1935. */
  1936. if (!prStaRec) {
  1937. /* For Case I - Check this IBSS's capability first before adding this Sta Record. */
  1938. fgIsCheckCapability = TRUE;
  1939. /* If check is passed, then we perform merging with this new IBSS */
  1940. fgIsGoingMerging = TRUE;
  1941. } else {
  1942. ASSERT((prStaRec->ucBssIndex == prAdapter->prAisBssInfo->ucBssIndex) && IS_ADHOC_STA(prStaRec));
  1943. if (prStaRec->ucStaState != STA_STATE_3) {
  1944. if (!prStaRec->fgIsMerging) {
  1945. /* For Case I - */
  1946. /* Check this IBSS's capability first before */
  1947. /* adding this Sta Record. */
  1948. fgIsCheckCapability = TRUE;
  1949. /* If check is passed, then we perform merging with this new IBSS */
  1950. fgIsGoingMerging = TRUE;
  1951. } else {
  1952. /* For Case II - Update rExpirationTime of Sta Record */
  1953. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  1954. }
  1955. } else {
  1956. /* For Case II - Update rExpirationTime of Sta Record */
  1957. GET_CURRENT_SYSTIME(&prStaRec->rUpdateTime);
  1958. }
  1959. }
  1960. } else {
  1961. /* Unequal BSSID:
  1962. * Case III. This is a new TA and we need to compare the TSF and get the winner.
  1963. * Case IV. This is an old TA and it merge into a new IBSS before we do the same thing.
  1964. * We need to compare the TSF to get the winner.
  1965. * Case V. This is an old TA and it restart a new IBSS. We also need to
  1966. * compare the TSF to get the winner.
  1967. */
  1968. /* For Case III, IV & V - We'll always check this new IBSS's capability first
  1969. * before merging into new IBSS.
  1970. */
  1971. fgIsCheckCapability = TRUE;
  1972. /* If check is passed, we need to perform TSF check to decide the major BSSID */
  1973. fgIsCheckTSF = TRUE;
  1974. /* For Case IV & V - We won't update rExpirationTime of Sta Record */
  1975. }
  1976. /* 4 <7> Check this BSS_DESC_T's capability. */
  1977. if (fgIsCheckCapability) {
  1978. BOOLEAN fgIsCapabilityMatched = FALSE;
  1979. do {
  1980. if (!(prBssDesc->ucPhyTypeSet & (prAdapter->rWifiVar.ucAvailablePhyTypeSet))) {
  1981. DBGLOG(BSS, LOUD,
  1982. "IBSS MERGE: Ignore Peer MAC: " MACSTR
  1983. " - Unsupported Phy.\n", MAC2STR(prBssDesc->aucSrcAddr));
  1984. break;
  1985. }
  1986. if (prBssDesc->fgIsUnknownBssBasicRate) {
  1987. DBGLOG(BSS, LOUD,
  1988. "IBSS MERGE: Ignore Peer MAC: " MACSTR
  1989. " - Unknown Basic Rate.\n", MAC2STR(prBssDesc->aucSrcAddr));
  1990. break;
  1991. }
  1992. if (ibssCheckCapabilityForAdHocMode(prAdapter, prBssDesc) == WLAN_STATUS_FAILURE) {
  1993. DBGLOG(BSS, LOUD,
  1994. "IBSS MERGE: Ignore Peer MAC: " MACSTR
  1995. " - Capability is not matched.\n", MAC2STR(prBssDesc->aucSrcAddr));
  1996. break;
  1997. }
  1998. fgIsCapabilityMatched = TRUE;
  1999. } while (FALSE);
  2000. if (!fgIsCapabilityMatched) {
  2001. if (prStaRec) {
  2002. /* For Case II - We merge this STA_RECORD in RX Path.
  2003. * Case IV & V - They change their BSSID after we merge with them.
  2004. */
  2005. DBGLOG(BSS, LOUD,
  2006. "IBSS MERGE: Ignore Peer MAC: " MACSTR
  2007. " - Capability is not matched.\n", MAC2STR(prBssDesc->aucSrcAddr));
  2008. }
  2009. return;
  2010. }
  2011. DBGLOG(BSS, LOUD,
  2012. "IBSS MERGE: Peer MAC: " MACSTR " - Check capability was passed.\n",
  2013. MAC2STR(prBssDesc->aucSrcAddr));
  2014. }
  2015. if (fgIsCheckTSF) {
  2016. #if CFG_SLT_SUPPORT
  2017. fgIsGoingMerging = TRUE;
  2018. #else
  2019. if (prBssDesc->fgIsLargerTSF)
  2020. fgIsGoingMerging = TRUE;
  2021. else
  2022. return;
  2023. #endif
  2024. }
  2025. if (fgIsGoingMerging) {
  2026. P_MSG_AIS_IBSS_PEER_FOUND_T prAisIbssPeerFoundMsg;
  2027. /* 4 <1> We will merge with to this BSS immediately. */
  2028. prBssDesc->fgIsConnecting = TRUE;
  2029. prBssDesc->fgIsConnected = FALSE;
  2030. /* 4 <2> Setup corresponding STA_RECORD_T */
  2031. prStaRec = bssCreateStaRecFromBssDesc(prAdapter,
  2032. STA_TYPE_ADHOC_PEER,
  2033. prAdapter->prAisBssInfo->ucBssIndex, prBssDesc);
  2034. if (!prStaRec) {
  2035. /* no memory ? */
  2036. return;
  2037. }
  2038. prStaRec->fgIsMerging = TRUE;
  2039. /* update RCPI */
  2040. prStaRec->ucRCPI = ucRCPI;
  2041. /* 4 <3> Send Merge Msg to CNM to obtain the channel privilege. */
  2042. prAisIbssPeerFoundMsg = (P_MSG_AIS_IBSS_PEER_FOUND_T)
  2043. cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_AIS_IBSS_PEER_FOUND_T));
  2044. if (!prAisIbssPeerFoundMsg) {
  2045. ASSERT(0); /* Can't send Merge Msg */
  2046. return;
  2047. }
  2048. prAisIbssPeerFoundMsg->rMsgHdr.eMsgId = MID_SCN_AIS_FOUND_IBSS;
  2049. prAisIbssPeerFoundMsg->ucBssIndex = prAdapter->prAisBssInfo->ucBssIndex;
  2050. prAisIbssPeerFoundMsg->prStaRec = prStaRec;
  2051. /* Inform AIS to do STATE TRANSITION
  2052. * For Case I - If AIS in IBSS_ALONE, let it jump to NORMAL_TR after we know the new member.
  2053. * For Case III, IV - Now this new BSSID wins the TSF, follow it.
  2054. */
  2055. if (fgIsSameBSSID) {
  2056. prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
  2057. } else {
  2058. #if CFG_SLT_SUPPORT
  2059. prAisIbssPeerFoundMsg->fgIsMergeIn = TRUE;
  2060. #else
  2061. prAisIbssPeerFoundMsg->fgIsMergeIn = (prBssDesc->fgIsLargerTSF) ? FALSE : TRUE;
  2062. #endif
  2063. }
  2064. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prAisIbssPeerFoundMsg, MSG_SEND_METHOD_BUF);
  2065. }
  2066. } /* end of ibssProcessMatchedBeacon() */
  2067. /*----------------------------------------------------------------------------*/
  2068. /*!
  2069. * @brief This function will check the Capability for Ad-Hoc to decide if we are
  2070. * able to merge with(same capability).
  2071. *
  2072. * @param[in] prBSSDesc Pointer to the BSS Descriptor.
  2073. *
  2074. * @retval WLAN_STATUS_FAILURE Can't pass the check of Capability.
  2075. * @retval WLAN_STATUS_SUCCESS Pass the check of Capability.
  2076. */
  2077. /*----------------------------------------------------------------------------*/
  2078. WLAN_STATUS ibssCheckCapabilityForAdHocMode(IN P_ADAPTER_T prAdapter, IN P_BSS_DESC_T prBssDesc)
  2079. {
  2080. P_CONNECTION_SETTINGS_T prConnSettings;
  2081. WLAN_STATUS rStatus = WLAN_STATUS_FAILURE;
  2082. ASSERT(prBssDesc);
  2083. prConnSettings = &(prAdapter->rWifiVar.rConnSettings);
  2084. do {
  2085. /* 4 <1> Check the BSS Basic Rate Set for current AdHoc Mode */
  2086. if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11B) &&
  2087. (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_HR_DSSS)) {
  2088. break;
  2089. } else if ((prConnSettings->eAdHocMode == AD_HOC_MODE_11A) &&
  2090. (prBssDesc->u2BSSBasicRateSet & ~RATE_SET_OFDM)) {
  2091. break;
  2092. }
  2093. /* 4 <2> Check the Short Slot Time. */
  2094. #if 0 /* Do not check ShortSlotTime until Wi-Fi define such policy */
  2095. if (prConnSettings->eAdHocMode == AD_HOC_MODE_11G) {
  2096. if (((prConnSettings->fgIsShortSlotTimeOptionEnable) &&
  2097. !(prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME)) ||
  2098. (!(prConnSettings->fgIsShortSlotTimeOptionEnable) &&
  2099. (prBssDesc->u2CapInfo & CAP_INFO_SHORT_SLOT_TIME))) {
  2100. break;
  2101. }
  2102. }
  2103. #endif
  2104. /* 4 <3> Check the ATIM window setting. */
  2105. if (prBssDesc->u2ATIMWindow) {
  2106. DBGLOG(BSS, INFO, "AdHoc PS was not supported(ATIM Window: %d)\n", prBssDesc->u2ATIMWindow);
  2107. break;
  2108. }
  2109. /* 4 <4> Check the Security setting. */
  2110. if (!rsnPerformPolicySelection(prAdapter, prBssDesc))
  2111. break;
  2112. rStatus = WLAN_STATUS_SUCCESS;
  2113. } while (FALSE);
  2114. return rStatus;
  2115. } /* end of ibssCheckCapabilityForAdHocMode() */
  2116. /*----------------------------------------------------------------------------*/
  2117. /*!
  2118. * @brief This function will initial the BSS_INFO_T for IBSS Mode.
  2119. *
  2120. * @param[in] prBssInfo Pointer to the BSS_INFO_T.
  2121. *
  2122. * @return (none)
  2123. */
  2124. /*----------------------------------------------------------------------------*/
  2125. VOID ibssInitForAdHoc(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo)
  2126. {
  2127. UINT_8 aucBSSID[MAC_ADDR_LEN];
  2128. PUINT_16 pu2BSSID = (PUINT_16) &aucBSSID[0];
  2129. UINT_32 i;
  2130. ASSERT(prBssInfo);
  2131. ASSERT(prBssInfo->eCurrentOPMode == OP_MODE_IBSS);
  2132. /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  2133. prBssInfo->ucNonHTBasicPhyType = (UINT_8)
  2134. rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
  2135. prBssInfo->u2BSSBasicRateSet = rNonHTAdHocModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
  2136. prBssInfo->u2OperationalRateSet = rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
  2137. rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
  2138. prBssInfo->u2BSSBasicRateSet,
  2139. prBssInfo->aucAllSupportedRates, &prBssInfo->ucAllSupportedRatesLen);
  2140. /* 4 <2> Setup BSSID */
  2141. if (!prBssInfo->fgHoldSameBssidForIBSS) {
  2142. for (i = 0; i < sizeof(aucBSSID) / sizeof(UINT_16); i++)
  2143. pu2BSSID[i] = (UINT_16) (kalRandomNumber() & 0xFFFF);
  2144. aucBSSID[0] &= ~0x01; /* 7.1.3.3.3 - The individual/group bit of the address is set to 0. */
  2145. aucBSSID[0] |= 0x02; /* 7.1.3.3.3 - The universal/local bit of the address is set to 1. */
  2146. COPY_MAC_ADDR(prBssInfo->aucBSSID, aucBSSID);
  2147. }
  2148. /* 4 <3> Setup Capability - Short Preamble */
  2149. if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented &&
  2150. /* Short Preamble Option Enable is TRUE */
  2151. ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) ||
  2152. (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO))) {
  2153. prBssInfo->fgIsShortPreambleAllowed = TRUE;
  2154. prBssInfo->fgUseShortPreamble = TRUE;
  2155. } else {
  2156. prBssInfo->fgIsShortPreambleAllowed = FALSE;
  2157. prBssInfo->fgUseShortPreamble = FALSE;
  2158. }
  2159. /* 4 <4> Setup Capability - Short Slot Time */
  2160. /* 7.3.1.4 For IBSS, the Short Slot Time subfield shall be set to 0. */
  2161. prBssInfo->fgUseShortSlotTime = FALSE; /* Set to FALSE for AdHoc */
  2162. /* 4 <5> Compoase Capability */
  2163. prBssInfo->u2CapInfo = CAP_INFO_IBSS;
  2164. if (prBssInfo->fgIsProtection)
  2165. prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
  2166. if (prBssInfo->fgIsShortPreambleAllowed)
  2167. prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
  2168. if (prBssInfo->fgUseShortSlotTime)
  2169. prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
  2170. /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
  2171. nicTxUpdateBssDefaultRate(prBssInfo);
  2172. } /* end of ibssInitForAdHoc() */
  2173. #endif /* CFG_SUPPORT_ADHOC */
  2174. #if CFG_SUPPORT_AAA
  2175. /*----------------------------------------------------------------------------*/
  2176. /* Routines for BSS(AP) only */
  2177. /*----------------------------------------------------------------------------*/
  2178. /*----------------------------------------------------------------------------*/
  2179. /*!
  2180. * @brief This function will initial the BSS_INFO_T for AP Mode.
  2181. *
  2182. * @param[in] prBssInfo Given related BSS_INFO_T.
  2183. *
  2184. * @return (none)
  2185. */
  2186. /*----------------------------------------------------------------------------*/
  2187. VOID bssInitForAP(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN BOOLEAN fgIsRateUpdate)
  2188. {
  2189. P_AC_QUE_PARMS_T prACQueParms;
  2190. ENUM_WMM_ACI_T eAci;
  2191. UINT_8 auCWminLog2ForBcast[WMM_AC_INDEX_NUM] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
  2192. UINT_8 auCWmaxLog2ForBcast[WMM_AC_INDEX_NUM] = { 10, 10, 4, 3 };
  2193. UINT_8 auAifsForBcast[WMM_AC_INDEX_NUM] = { 3, 7, 2, 2 };
  2194. UINT_8 auTxopForBcast[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
  2195. UINT_8 auCWminLog2[WMM_AC_INDEX_NUM] = { 4 /*BE*/, 4 /*BK*/, 3 /*VO*/, 2 /*VI*/ };
  2196. UINT_8 auCWmaxLog2[WMM_AC_INDEX_NUM] = { 6, 10, 4, 3 };
  2197. UINT_8 auAifs[WMM_AC_INDEX_NUM] = { 3, 7, 1, 1 };
  2198. UINT_8 auTxop[WMM_AC_INDEX_NUM] = { 0, 0, 94, 47 }; /* If the AP is OFDM */
  2199. DEBUGFUNC("bssInitForAP");
  2200. DBGLOG(BSS, LOUD, "\n");
  2201. ASSERT(prBssInfo);
  2202. ASSERT((prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT)
  2203. || (prBssInfo->eCurrentOPMode == OP_MODE_BOW));
  2204. #if 0
  2205. prAdapter->rWifiVar.rConnSettings.fgRxShortGIDisabled = TRUE;
  2206. prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode = CONFIG_BW_20M;
  2207. prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode = CONFIG_BW_20M;
  2208. #endif
  2209. /* 4 <1> Setup PHY Attributes and Basic Rate Set/Operational Rate Set */
  2210. prBssInfo->ucNonHTBasicPhyType = (UINT_8)
  2211. rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].ePhyTypeIndex;
  2212. prBssInfo->u2BSSBasicRateSet = rNonHTApModeAttributes[prBssInfo->ucConfigAdHocAPMode].u2BSSBasicRateSet;
  2213. /* 4 <1.1> Mask CCK 1M For Sco scenario */
  2214. prBssInfo->u2BSSBasicRateSet &= ~RATE_SET_BIT_1M;
  2215. /* prBssInfo->u2OperationalRateSet &= ~RATE_SET_BIT_1M; */
  2216. prBssInfo->u2OperationalRateSet = rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].u2SupportedRateSet;
  2217. /* 4 <1.1> Mask CCK 1M For Sco scenario */
  2218. prBssInfo->u2BSSBasicRateSet &= ~RATE_SET_BIT_1M;
  2219. /* prBssInfo->u2OperationalRateSet &= ~RATE_SET_BIT_1M; */
  2220. if (fgIsRateUpdate) {
  2221. rateGetDataRatesFromRateSet(prBssInfo->u2OperationalRateSet,
  2222. prBssInfo->u2BSSBasicRateSet,
  2223. prBssInfo->aucAllSupportedRates, &prBssInfo->ucAllSupportedRatesLen);
  2224. }
  2225. /* 4 <2> Setup BSSID */
  2226. COPY_MAC_ADDR(prBssInfo->aucBSSID, prBssInfo->aucOwnMacAddr);
  2227. /* 4 <3> Setup Capability - Short Preamble */
  2228. if (rNonHTPhyAttributes[prBssInfo->ucNonHTBasicPhyType].fgIsShortPreambleOptionImplemented &&
  2229. /* Short Preamble Option Enable is TRUE */
  2230. ((prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_SHORT) ||
  2231. (prAdapter->rWifiVar.ePreambleType == PREAMBLE_TYPE_AUTO))) {
  2232. prBssInfo->fgIsShortPreambleAllowed = TRUE;
  2233. prBssInfo->fgUseShortPreamble = TRUE;
  2234. } else {
  2235. prBssInfo->fgIsShortPreambleAllowed = FALSE;
  2236. prBssInfo->fgUseShortPreamble = FALSE;
  2237. }
  2238. /* 4 <4> Setup Capability - Short Slot Time */
  2239. prBssInfo->fgUseShortSlotTime = TRUE;
  2240. /* 4 <5> Compoase Capability */
  2241. prBssInfo->u2CapInfo = CAP_INFO_ESS;
  2242. if (prBssInfo->fgIsProtection)
  2243. prBssInfo->u2CapInfo |= CAP_INFO_PRIVACY;
  2244. if (prBssInfo->fgIsShortPreambleAllowed)
  2245. prBssInfo->u2CapInfo |= CAP_INFO_SHORT_PREAMBLE;
  2246. if (prBssInfo->fgUseShortSlotTime)
  2247. prBssInfo->u2CapInfo |= CAP_INFO_SHORT_SLOT_TIME;
  2248. /* 4 <6> Find Lowest Basic Rate Index for default TX Rate of MMPDU */
  2249. nicTxUpdateBssDefaultRate(prBssInfo);
  2250. /* 4 <7> Fill the EDCA */
  2251. prACQueParms = prBssInfo->arACQueParmsForBcast;
  2252. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  2253. prACQueParms[eAci].ucIsACMSet = FALSE;
  2254. prACQueParms[eAci].u2Aifsn = auAifsForBcast[eAci];
  2255. prACQueParms[eAci].u2CWmin = BIT(auCWminLog2ForBcast[eAci]) - 1;
  2256. prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2ForBcast[eAci]) - 1;
  2257. prACQueParms[eAci].u2TxopLimit = auTxopForBcast[eAci];
  2258. prBssInfo->aucCWminLog2ForBcast[eAci] = auCWminLog2ForBcast[eAci]; /* used to send WMM IE */
  2259. prBssInfo->aucCWmaxLog2ForBcast[eAci] = auCWmaxLog2ForBcast[eAci];
  2260. DBGLOG(BSS, INFO,
  2261. "Bcast: eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
  2262. eAci, prACQueParms[eAci].ucIsACMSet, prACQueParms[eAci].u2Aifsn,
  2263. prACQueParms[eAci].u2CWmin, prACQueParms[eAci].u2CWmax, prACQueParms[eAci].u2TxopLimit);
  2264. }
  2265. prACQueParms = prBssInfo->arACQueParms;
  2266. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  2267. prACQueParms[eAci].ucIsACMSet = FALSE;
  2268. prACQueParms[eAci].u2Aifsn = auAifs[eAci];
  2269. prACQueParms[eAci].u2CWmin = BIT(auCWminLog2[eAci]) - 1;
  2270. prACQueParms[eAci].u2CWmax = BIT(auCWmaxLog2[eAci]) - 1;
  2271. prACQueParms[eAci].u2TxopLimit = auTxop[eAci];
  2272. DBGLOG(BSS, INFO,
  2273. "eAci = %d, ACM = %d, Aifsn = %d, CWmin = %d, CWmax = %d, TxopLimit = %d\n",
  2274. eAci, prACQueParms[eAci].ucIsACMSet, prACQueParms[eAci].u2Aifsn,
  2275. prACQueParms[eAci].u2CWmin, prACQueParms[eAci].u2CWmax, prACQueParms[eAci].u2TxopLimit);
  2276. }
  2277. /* Note: Caller should update the EDCA setting to HW by nicQmUpdateWmmParms() it there is no AIS network */
  2278. /* Note: In E2, only 4 HW queues. The the Edca parameters should be folow by AIS network */
  2279. /* Note: In E3, 8 HW queues. the Wmm parameters should be updated to right queues according to BSS */
  2280. } /* end of bssInitForAP() */
  2281. #if 0
  2282. /*----------------------------------------------------------------------------*/
  2283. /*!
  2284. * @brief Update DTIM Count
  2285. *
  2286. * @param[in] eNetTypeIndex Specify which network to update
  2287. *
  2288. * @return (none)
  2289. */
  2290. /*----------------------------------------------------------------------------*/
  2291. VOID bssUpdateDTIMCount(IN P_ADAPTER_T prAdapter, IN ENUM_NETWORK_TYPE_INDEX_T eNetTypeIndex)
  2292. {
  2293. P_BSS_INFO_T prBssInfo;
  2294. ASSERT(eNetTypeIndex < NETWORK_TYPE_INDEX_NUM);
  2295. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[eNetTypeIndex]);
  2296. if (prBssInfo->eCurrentOPMode == OP_MODE_ACCESS_POINT) {
  2297. /* Setup DTIM Count for next TBTT. */
  2298. if (prBssInfo->ucDTIMCount > 0) {
  2299. prBssInfo->ucDTIMCount--;
  2300. } else {
  2301. ASSERT(prBssInfo->ucDTIMPeriod > 0);
  2302. prBssInfo->ucDTIMCount = prBssInfo->ucDTIMPeriod - 1;
  2303. }
  2304. }
  2305. } /* end of bssUpdateDTIMIE() */
  2306. /*----------------------------------------------------------------------------*/
  2307. /*!
  2308. * @brief This function is used to set the Virtual Bitmap in TIM Information Elements
  2309. *
  2310. * @param[in] prBssInfo Pointer to the BSS_INFO_T.
  2311. * @param[in] u2AssocId The association id to set in Virtual Bitmap.
  2312. *
  2313. * @return (none)
  2314. */
  2315. /*----------------------------------------------------------------------------*/
  2316. VOID bssSetTIMBitmap(IN P_ADAPTER_T prAdapter, IN P_BSS_INFO_T prBssInfo, IN UINT_16 u2AssocId)
  2317. {
  2318. ASSERT(prBssInfo);
  2319. if (prBssInfo->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
  2320. P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo;
  2321. prP2pSpecificBssInfo = &(prAdapter->rWifiVar.rP2pSpecificBssInfo);
  2322. /* Use Association ID == 0 for BMCAST indication */
  2323. if (u2AssocId == 0) {
  2324. prP2pSpecificBssInfo->ucBitmapCtrl |= (UINT_8) BIT(0);
  2325. } else {
  2326. PUINT_8 pucPartialVirtualBitmap;
  2327. UINT_8 ucBitmapToSet;
  2328. pucPartialVirtualBitmap = &prP2pSpecificBssInfo->aucPartialVirtualBitmap[(u2AssocId >> 3)];
  2329. ucBitmapToSet = (UINT_8) BIT((u2AssocId % 8));
  2330. if (*pucPartialVirtualBitmap & ucBitmapToSet) {
  2331. /* The virtual bitmap has been set */
  2332. return;
  2333. }
  2334. *pucPartialVirtualBitmap |= ucBitmapToSet;
  2335. /* Update u2SmallestAID and u2LargestAID */
  2336. if ((u2AssocId < prP2pSpecificBssInfo->u2SmallestAID) ||
  2337. (prP2pSpecificBssInfo->u2SmallestAID == 0)) {
  2338. prP2pSpecificBssInfo->u2SmallestAID = u2AssocId;
  2339. }
  2340. if ((u2AssocId > prP2pSpecificBssInfo->u2LargestAID) ||
  2341. (prP2pSpecificBssInfo->u2LargestAID == 0)) {
  2342. prP2pSpecificBssInfo->u2LargestAID = u2AssocId;
  2343. }
  2344. }
  2345. }
  2346. } /* end of bssSetTIMBitmap() */
  2347. #endif
  2348. #endif /* CFG_SUPPORT_AAA */
  2349. VOID bssCreateStaRecFromAuth(IN P_ADAPTER_T prAdapter)
  2350. {
  2351. }
  2352. VOID bssUpdateStaRecFromAssocReq(IN P_ADAPTER_T prAdapter)
  2353. {
  2354. }
  2355. VOID bssDumpBssInfo(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex)
  2356. {
  2357. P_BSS_INFO_T prBssInfo;
  2358. /* P_LINK_T prStaRecOfClientList = (P_LINK_T) NULL; */
  2359. /* P_STA_RECORD_T prCurrStaRec = (P_STA_RECORD_T) NULL; */
  2360. if (ucBssIndex > MAX_BSS_INDEX) {
  2361. DBGLOG(SW4, INFO, "Invalid BssInfo index[%u], skip dump!\n", ucBssIndex);
  2362. return;
  2363. }
  2364. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  2365. if (!prBssInfo) {
  2366. DBGLOG(SW4, INFO, "Invalid BssInfo index[%u], skip dump!\n", ucBssIndex);
  2367. return;
  2368. }
  2369. DBGLOG(SW4, INFO, "OWNMAC[" MACSTR "] BSSID[" MACSTR "] SSID[%s]\n",
  2370. MAC2STR(prBssInfo->aucOwnMacAddr),
  2371. MAC2STR(prBssInfo->aucBSSID), prBssInfo->aucSSID);
  2372. DBGLOG(SW4, INFO, "BSS IDX[%u] Type[%s] OPMode[%s] ConnState[%u] Absent[%u]\n",
  2373. prBssInfo->ucBssIndex,
  2374. apucNetworkType[prBssInfo->eNetworkType],
  2375. apucNetworkOpMode[prBssInfo->eCurrentOPMode],
  2376. prBssInfo->eConnectionState, prBssInfo->fgIsNetAbsent);
  2377. DBGLOG(SW4, INFO,
  2378. "Channel[%u] Band[%u] SCO[%u] Assoc40mBwAllowed[%u] 40mBwAllowed[%u] MaxBw[%u]\n",
  2379. prBssInfo->ucPrimaryChannel, prBssInfo->eBand, prBssInfo->eBssSCO,
  2380. prBssInfo->fgAssoc40mBwAllowed, prBssInfo->fg40mBwAllowed, cnmGetBssMaxBw(prAdapter,
  2381. prBssInfo->ucBssIndex));
  2382. DBGLOG(SW4, INFO, "QBSS[%u] CapInfo[0x%04x] AID[%u]\n",
  2383. prBssInfo->fgIsQBSS, prBssInfo->u2CapInfo, prBssInfo->u2AssocId);
  2384. DBGLOG(SW4, INFO, "ShortPreamble Allowed[%u] EN[%u], ShortSlotTime[%u]\n",
  2385. prBssInfo->fgIsShortPreambleAllowed,
  2386. prBssInfo->fgUseShortPreamble, prBssInfo->fgUseShortSlotTime);
  2387. DBGLOG(SW4, INFO, "PhyTypeSet: Basic[0x%02x] NonHtBasic[0x%02x]\n",
  2388. prBssInfo->ucPhyTypeSet, prBssInfo->ucNonHTBasicPhyType);
  2389. DBGLOG(SW4, INFO, "RateSet: BssBasic[0x%04x] Operational[0x%04x]\n",
  2390. prBssInfo->u2BSSBasicRateSet, prBssInfo->u2OperationalRateSet);
  2391. DBGLOG(SW4, INFO, "ATIMWindow[%u] DTIM Period[%u] Count[%u]\n",
  2392. prBssInfo->u2ATIMWindow, prBssInfo->ucDTIMPeriod, prBssInfo->ucDTIMCount);
  2393. DBGLOG(SW4, INFO, "HT Operation Info1[0x%02x] Info2[0x%04x] Info3[0x%04x]\n",
  2394. prBssInfo->ucHtOpInfo1, prBssInfo->u2HtOpInfo2, prBssInfo->u2HtOpInfo3);
  2395. DBGLOG(SW4, INFO, "ProtectMode HT[%u] ERP[%u], OperationMode GF[%u] RIFS[%u]\n",
  2396. prBssInfo->eHtProtectMode,
  2397. prBssInfo->fgErpProtectMode, prBssInfo->eGfOperationMode, prBssInfo->eRifsOperationMode);
  2398. DBGLOG(SW4, INFO, "(OBSS) ProtectMode HT[%u] ERP[%u], OperationMode GF[%u] RIFS[%u]\n",
  2399. prBssInfo->eObssHtProtectMode,
  2400. prBssInfo->fgObssErpProtectMode,
  2401. prBssInfo->eObssGfOperationMode, prBssInfo->fgObssRifsOperationMode);
  2402. DBGLOG(SW4, INFO, "======== Dump Connected Client ========\n");
  2403. #if 0
  2404. DBGLOG(SW4, INFO, "NumOfClient[%u]\n", bssGetClientCount(prAdapter, prBssInfo));
  2405. prStaRecOfClientList = &prBssInfo->rStaRecOfClientList;
  2406. LINK_FOR_EACH_ENTRY(prCurrStaRec, prStaRecOfClientList, rLinkEntry, STA_RECORD_T) {
  2407. DBGLOG(SW4, INFO, "STA[%u] [" MACSTR "]\n", prCurrStaRec->ucIndex, MAC2STR(prCurrStaRec->aucMacAddr));
  2408. }
  2409. #else
  2410. bssDumpClientList(prAdapter, prBssInfo);
  2411. #endif
  2412. DBGLOG(SW4, INFO, "============== Dump Done ==============\n");
  2413. }