nic_rx.c 121 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/nic/nic_rx.c#3
  3. */
  4. /*! \file nic_rx.c
  5. \brief Functions that provide many rx-related functions
  6. This file includes the functions used to process RFB and dispatch RFBs to
  7. the appropriate related rx functions for protocols.
  8. */
  9. /*
  10. ** Log: nic_rx.c
  11. **
  12. ** 08 31 2012 yuche.tsai
  13. ** [ALPS00349585] [6577JB][WiFi direct][KE]Establish p2p connection while both device have connected to AP previously,
  14. ** one device reboots automatically with KE
  15. ** Fix possible KE when concurrent & disconnect.
  16. *
  17. * 07 17 2012 yuche.tsai
  18. * NULL
  19. * Let netdev bring up.
  20. *
  21. * 07 17 2012 yuche.tsai
  22. * NULL
  23. * Compile no error before trial run.
  24. *
  25. * 03 02 2012 terry.wu
  26. * NULL
  27. * Sync CFG80211 modification from branch 2,2.
  28. *
  29. * 02 14 2012 cp.wu
  30. * NULL
  31. * remove another assertion by error message dump
  32. *
  33. * 01 05 2012 tsaiyuan.hsu
  34. * [WCXRP00001157] [MT6620 Wi-Fi][FW][DRV] add timing measurement support for 802.11v
  35. * add timing measurement support for 802.11v.
  36. *
  37. * 11 19 2011 yuche.tsai
  38. * NULL
  39. * Update RSSI for P2P.
  40. *
  41. * 11 18 2011 yuche.tsai
  42. * NULL
  43. * CONFIG P2P support RSSI query, default turned off.
  44. *
  45. * 11 17 2011 tsaiyuan.hsu
  46. * [WCXRP00001115] [MT6620 Wi-Fi][DRV] avoid deactivating staRec when changing state 3 to 3.
  47. * avoid deactivating staRec when changing state from 3 to 3.
  48. *
  49. * 11 11 2011 wh.su
  50. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  51. * modify the xlog related code.
  52. *
  53. * 11 10 2011 eddie.chen
  54. * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
  55. * Modify the QM xlog level and remove LOG_FUNC.
  56. *
  57. * 11 09 2011 eddie.chen
  58. * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
  59. * Add xlog for beacon timeout and sta aging timeout.
  60. *
  61. * 11 08 2011 eddie.chen
  62. * [WCXRP00001096] [MT6620 Wi-Fi][Driver/FW] Enhance the log function (xlog)
  63. * Add xlog function.
  64. *
  65. * 11 07 2011 tsaiyuan.hsu
  66. * [WCXRP00001083] [MT6620 Wi-Fi][DRV]] dump debug counter or frames when debugging is triggered
  67. * add debug counters and periodically dump counters for debugging.
  68. *
  69. * 10 21 2011 eddie.chen
  70. * [WCXRP00001051] [MT6620 Wi-Fi][Driver/Fw] Adjust the STA aging timeout
  71. * Add switch to ignore the STA aging timeout.
  72. *
  73. * 10 12 2011 wh.su
  74. * [WCXRP00001036] [MT6620 Wi-Fi][Driver][FW] Adding the 802.11w code for MFP
  75. * adding the 802.11w related function and define .
  76. *
  77. * 08 26 2011 cp.wu
  78. * [WCXRP00000958] [MT6620 Wi-Fi][Driver] Extend polling timeout from 25ms to 1sec due to RF calibration might took
  79. * up to 600ms
  80. * extend polling RX response timeout period from 25ms to 1000ms.
  81. *
  82. * 08 11 2011 cp.wu
  83. * [WCXRP00000830] [MT6620 Wi-Fi][Firmware] Use MDRDY counter to detect empty channel for shortening scan time
  84. * sparse channel detection:
  85. * driver: collect sparse channel information with scan-done event
  86. *
  87. * 07 28 2011 chinghwa.yu
  88. * [WCXRP00000063] Update BCM CoEx design and settings
  89. * Add BWCS cmd and event.
  90. *
  91. * 07 27 2011 cp.wu
  92. * [WCXRP00000876] [MT5931][Drver] Decide to retain according to currently available RX counter and QUE_MGT used count
  93. * correct comment.
  94. *
  95. * 07 27 2011 cp.wu
  96. * [WCXRP00000876] [MT5931][Drver] Decide to retain according to currently available RX counter and QUE_MGT used count
  97. * take use of QUE_MGT exported function to estimate currently RX buffer usage count.
  98. *
  99. * 07 18 2011 chinghwa.yu
  100. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  101. * Add CMD/Event for RDD and BWCS.
  102. *
  103. * 06 09 2011 tsaiyuan.hsu
  104. * [WCXRP00000760] [MT5931 Wi-Fi][FW] Refine rxmHandleMacRxDone to reduce code size
  105. * move send_auth at rxmHandleMacRxDone in firmware to driver to reduce code size.
  106. *
  107. * 05 11 2011 eddie.chen
  108. * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
  109. * Fix dest type when GO packet copying.
  110. *
  111. * 05 09 2011 eddie.chen
  112. * [WCXRP00000709] [MT6620 Wi-Fi][Driver] Check free number before copying broadcast packet
  113. * Check free number before copying broadcast packet.
  114. *
  115. * 05 05 2011 cp.wu
  116. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  117. * add delay after whole-chip resetting for MT5931 E1 ASIC.
  118. *
  119. * 04 18 2011 terry.wu
  120. * [WCXRP00000660] [MT6620 Wi-Fi][Driver] Remove flag CFG_WIFI_DIRECT_MOVED
  121. * Remove flag CFG_WIFI_DIRECT_MOVED.
  122. *
  123. * 04 12 2011 cm.chang
  124. * [WCXRP00000634] [MT6620 Wi-Fi][Driver][FW] 2nd BSS will not support 40MHz bandwidth for concurrency
  125. * .
  126. *
  127. * 04 08 2011 yuche.tsai
  128. * [WCXRP00000624] [Volunteer Patch][MT6620][Driver] Add device discoverability support for GO.
  129. * Add device discoverability support for GO.
  130. *
  131. * 04 01 2011 tsaiyuan.hsu
  132. * [WCXRP00000615] [MT 6620 Wi-Fi][Driver] Fix klocwork issues
  133. * fix the klocwork issues, 57500, 57501, 57502 and 57503.
  134. *
  135. * 03 19 2011 yuche.tsai
  136. * [WCXRP00000584] [Volunteer Patch][MT6620][Driver] Add beacon timeout support for WiFi Direct.
  137. * Add beacon timeout support for WiFi Direct Network.
  138. *
  139. * 03 18 2011 wh.su
  140. * [WCXRP00000530] [MT6620 Wi-Fi] [Driver] skip doing p2pRunEventAAAComplete after send assoc response Tx Done
  141. * enable the Anti_piracy check at driver .
  142. *
  143. * 03 17 2011 cp.wu
  144. * [WCXRP00000562] [MT6620 Wi-Fi][Driver] I/O buffer pre-allocation to avoid physically continuous memory shortage
  145. * after system running for a long period
  146. * use pre-allocated buffer for storing enhanced interrupt response as well
  147. *
  148. * 03 15 2011 cp.wu
  149. * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically continuous
  150. * memory consumption
  151. * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
  152. * 2. Use common coalescing buffer for both TX/RX directions
  153. *
  154. *
  155. * 03 07 2011 wh.su
  156. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  157. * rename the define to anti_pviracy.
  158. *
  159. * 03 05 2011 wh.su
  160. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  161. * add the code to get the check rsponse and indicate to app.
  162. *
  163. * 03 02 2011 wh.su
  164. * [WCXRP00000506] [MT6620 Wi-Fi][Driver][FW] Add Security check related code
  165. * Add security check code.
  166. *
  167. * 03 02 2011 cp.wu
  168. * [WCXRP00000503] [MT6620 Wi-Fi][Driver] Take RCPI brought by association response as initial RSSI right after
  169. * connection is built.
  170. * use RCPI brought by ASSOC-RESP after connection is built as initial RCPI to avoid using a uninitialized MAC-RX RCPI.
  171. *
  172. * 02 10 2011 yuche.tsai
  173. * [WCXRP00000419] [Volunteer Patch][MT6620/MT5931][Driver] Provide function of disconnect to target station for AAA
  174. * module.
  175. * Remove Station Record after Aging timeout.
  176. *
  177. * 02 10 2011 cp.wu
  178. * [WCXRP00000434] [MT6620 Wi-Fi][Driver] Obsolete unused event packet handlers
  179. * EVENT_ID_CONNECTION_STATUS has been obsoleted and no need to handle.
  180. *
  181. * 02 09 2011 yuche.tsai
  182. * [WCXRP00000431] [Volunteer Patch][MT6620][Driver] Add MLME support for deauthentication under AP(Hot-Spot) mode.
  183. * Add MLME deauthentication support for Hot-Spot mode.
  184. *
  185. * 02 09 2011 eddie.chen
  186. * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
  187. * Adjust variable order.
  188. *
  189. * 02 08 2011 eddie.chen
  190. * [WCXRP00000426] [MT6620 Wi-Fi][FW/Driver] Add STA aging timeout and defualtHwRatein AP mode
  191. * Add event STA agint timeout
  192. *
  193. * 01 27 2011 tsaiyuan.hsu
  194. * [WCXRP00000392] [MT6620 Wi-Fi][Driver] Add Roaming Support
  195. * add roaming fsm
  196. * 1. not support 11r, only use strength of signal to determine roaming.
  197. * 2. not enable CFG_SUPPORT_ROAMING until completion of full test.
  198. * 3. in 6620, adopt work-around to avoid sign extension problem of cck of hw
  199. * 4. assume that change of link quality in smooth way.
  200. *
  201. * 01 26 2011 cm.chang
  202. * [WCXRP00000395] [MT6620 Wi-Fi][Driver][FW] Search STA_REC with additional net type index argument
  203. * .
  204. *
  205. * 01 24 2011 eddie.chen
  206. * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
  207. * Remove comments.
  208. *
  209. * 01 24 2011 eddie.chen
  210. * [WCXRP00000385] [MT6620 Wi-Fi][DRV] Add destination decision for forwarding packets
  211. * Add destination decision in AP mode.
  212. *
  213. * 01 24 2011 cm.chang
  214. * [WCXRP00000384] [MT6620 Wi-Fi][Driver][FW] Handle 20/40 action frame in AP mode and stop ampdu timer when sta_rec
  215. * is freed
  216. * Process received 20/40 coexistence action frame for AP mode
  217. *
  218. * 01 24 2011 cp.wu
  219. * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
  220. * 1. add an extra counter for tracking pending forward frames.
  221. * 2. notify TX service thread as well when there is pending forward frame
  222. * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
  223. *
  224. * 01 12 2011 cp.wu
  225. * [WCXRP00000357] [MT6620 Wi-Fi][Driver][Bluetooth over Wi-Fi] add another net device interface for BT AMP
  226. * implementation of separate BT_OVER_WIFI data path.
  227. *
  228. * 12 29 2010 eddie.chen
  229. * [WCXRP00000322] Add WMM IE in beacon,
  230. Add per station flow control when STA is in PS
  231. * 1) PS flow control event
  232. *
  233. * 2) WMM IE in beacon, assoc resp, probe resp
  234. *
  235. * 12 15 2010 george.huang
  236. * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
  237. * update beacon for NoA
  238. *
  239. * 11 01 2010 cp.wu
  240. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000150] [MT6620 Wi-Fi][Driver]
  241. * Add implementation for querying current TX rate from firmware auto rate module
  242. * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
  243. * 2) Remove CNM CH-RECOVER event handling
  244. * 3) cfg read/write API renamed with kal prefix for unified naming rules.
  245. *
  246. * 10 27 2010 george.huang
  247. * [WCXRP00000127] [MT6620 Wi-Fi][Driver] Add a registry to disable Beacon Timeout function for SQA test by using E1 EVB
  248. * Support registry option for disable beacon lost detection.
  249. *
  250. * 10 20 2010 wh.su
  251. * NULL
  252. * add a cmd to reset the p2p key
  253. *
  254. * 10 20 2010 wh.su
  255. * [WCXRP00000124] [MT6620 Wi-Fi] [Driver] Support the dissolve P2P Group
  256. * Add the code to support disconnect p2p group
  257. *
  258. * 09 29 2010 wh.su
  259. * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
  260. * fixed compilier error.
  261. *
  262. * 09 29 2010 wh.su
  263. * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
  264. * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
  265. *
  266. * 09 23 2010 cp.wu
  267. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  268. * eliminate reference of CFG_RESPONSE_MAX_PKT_SIZE
  269. *
  270. * 09 21 2010 cp.wu
  271. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS
  272. * associated
  273. * release RX packet to packet pool when in RF test mode
  274. *
  275. * 09 21 2010 cp.wu
  276. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with AIS
  277. @ associated
  278. * Do a complete reset with STA-REC null checking for RF test re-entry
  279. *
  280. * 09 08 2010 cp.wu
  281. * NULL
  282. * use static memory pool for storing IEs of scanning result.
  283. *
  284. * 09 07 2010 yuche.tsai
  285. * NULL
  286. * Add a common buffer, store the IE of a P2P device in this common buffer.
  287. *
  288. * 09 03 2010 kevin.huang
  289. * NULL
  290. * Refine #include sequence and solve recursive/nested #include issue
  291. *
  292. * 08 31 2010 kevin.huang
  293. * NULL
  294. * Use LINK LIST operation to process SCAN result
  295. *
  296. * 08 30 2010 cp.wu
  297. * NULL
  298. * eliminate klockwork errors
  299. *
  300. * 08 20 2010 cm.chang
  301. * NULL
  302. * Migrate RLM code to host from FW
  303. *
  304. * 08 20 2010 yuche.tsai
  305. * NULL
  306. * When enable WiFi Direct function, check each packet to tell which interface to indicate.
  307. *
  308. * 08 05 2010 yuche.tsai
  309. * NULL
  310. * Add P2P Device Discovery Function.
  311. *
  312. * 08 03 2010 cp.wu
  313. * NULL
  314. * surpress compilation warning.
  315. *
  316. * 08 03 2010 george.huang
  317. * NULL
  318. * handle event for updating NOA parameters indicated from FW
  319. *
  320. * 08 02 2010 yuche.tsai
  321. * NULL
  322. * Add support API for RX public action frame.
  323. *
  324. * 08 02 2010 jeffrey.chang
  325. * NULL
  326. * 1) modify tx service thread to avoid busy looping
  327. * 2) add spin lock declartion for linux build
  328. *
  329. * 07 30 2010 cp.wu
  330. * NULL
  331. * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
  332. * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
  333. * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
  334. *
  335. * 07 26 2010 yuche.tsai
  336. *
  337. * Update Device Capability Bitmap & Group Capability Bitmap from 16 bits to 8 bits.
  338. *
  339. * 07 24 2010 wh.su
  340. *
  341. * .support the Wi-Fi RSN
  342. *
  343. * 07 23 2010 cp.wu
  344. *
  345. * add AIS-FSM handling for beacon timeout event.
  346. *
  347. * 07 21 2010 yuche.tsai
  348. *
  349. * Add P2P Scan & Scan Result Parsing & Saving.
  350. *
  351. * 07 19 2010 cm.chang
  352. *
  353. * Set RLM parameters and enable CNM channel manager
  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 19 2010 jeffrey.chang
  361. *
  362. * Linux port modification
  363. *
  364. * 07 16 2010 yarco.yang
  365. *
  366. * 1. Support BSS Absence/Presence Event
  367. * 2. Support STA change PS mode Event
  368. * 3. Support BMC forwarding for AP mode.
  369. *
  370. * 07 15 2010 cp.wu
  371. *
  372. * sync. bluetooth-over-Wi-Fi interface to driver interface document v0.2.6.
  373. *
  374. * 07 08 2010 cp.wu
  375. *
  376. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  377. *
  378. * 07 07 2010 cp.wu
  379. * [WPD00003833][MT6620 and MT5931] Driver migration
  380. * fill ucStaRecIdx into SW_RFB_T.
  381. *
  382. * 07 02 2010 cp.wu
  383. * [WPD00003833][MT6620 and MT5931] Driver migration
  384. * 1) for event packet, no need to fill RFB.
  385. * 2) when wlanAdapterStart() failed, no need to initialize state machines
  386. * 3) after Beacon/ProbeResp parsing, corresponding BSS_DESC_T should be marked as IE-parsed
  387. *
  388. * 07 01 2010 cp.wu
  389. * [WPD00003833][MT6620 and MT5931] Driver migration
  390. * implementation of DRV-SCN and related mailbox message handling.
  391. *
  392. * 06 29 2010 yarco.yang
  393. * [WPD00003837][MT6620]Data Path Refine
  394. * replace g_rQM with Adpater->rQM
  395. *
  396. * 06 23 2010 yarco.yang
  397. * [WPD00003837][MT6620]Data Path Refine
  398. * Merge g_arStaRec[] into adapter->arStaRec[]
  399. *
  400. * 06 22 2010 cp.wu
  401. * [WPD00003833][MT6620 and MT5931] Driver migration
  402. * 1) add command warpper for STA-REC/BSS-INFO sync.
  403. * 2) enhance command packet sending procedure for non-oid part
  404. * 3) add command packet definitions for STA-REC/BSS-INFO sync.
  405. *
  406. * 06 21 2010 cp.wu
  407. * [WPD00003833][MT6620 and MT5931] Driver migration
  408. * refine TX-DONE callback.
  409. *
  410. * 06 21 2010 cp.wu
  411. * [WPD00003833][MT6620 and MT5931] Driver migration
  412. * implement TX_DONE callback path.
  413. *
  414. * 06 21 2010 yarco.yang
  415. * [WPD00003837][MT6620]Data Path Refine
  416. * Add TX Done Event handle entry
  417. *
  418. * 06 21 2010 wh.su
  419. * [WPD00003840][MT6620 5931] Security migration
  420. * remove duplicate variable for migration.
  421. *
  422. * 06 15 2010 cp.wu
  423. * [WPD00003833][MT6620 and MT5931] Driver migration
  424. * .
  425. *
  426. * 06 15 2010 cp.wu
  427. * [WPD00003833][MT6620 and MT5931] Driver migration
  428. * .
  429. *
  430. * 06 14 2010 cp.wu
  431. * [WPD00003833][MT6620 and MT5931] Driver migration
  432. * saa_fsm.c is migrated.
  433. *
  434. * 06 14 2010 cp.wu
  435. * [WPD00003833][MT6620 and MT5931] Driver migration
  436. * add management dispatching function table.
  437. *
  438. * 06 11 2010 cp.wu
  439. * [WPD00003833][MT6620 and MT5931] Driver migration
  440. * 1) migrate assoc.c.
  441. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  442. * 3) add configuration options for CNM_MEM and RSN modules
  443. * 4) add data path for management frames
  444. * 5) eliminate rPacketInfo of MSDU_INFO_T
  445. *
  446. * 06 10 2010 cp.wu
  447. * [WPD00003833][MT6620 and MT5931] Driver migration
  448. * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
  449. * 2) when disconnected, indicate nic directly (no event is needed)
  450. *
  451. * 06 08 2010 cp.wu
  452. * [WPD00003833][MT6620 and MT5931] Driver migration
  453. * cnm_timer has been migrated.
  454. *
  455. * 06 07 2010 cp.wu
  456. * [WPD00003833][MT6620 and MT5931] Driver migration
  457. * merge wlan_def.h.
  458. *
  459. * 06 07 2010 cp.wu
  460. * [WPD00003833][MT6620 and MT5931] Driver migration
  461. * sync with MT6620 driver for scan result replacement policy
  462. *
  463. * 06 06 2010 kevin.huang
  464. * [WPD00003832][MT6620 5931] Create driver base
  465. * [MT6620 5931] Create driver base
  466. *
  467. * 05 20 2010 cp.wu
  468. * [WPD00001943]Create WiFi test driver framework on WinXP
  469. * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
  470. * 2) buffer statistics data for 2 seconds
  471. * 3) use default value for adhoc parameters instead of 0
  472. *
  473. * 05 19 2010 cp.wu
  474. * [WPD00001943]Create WiFi test driver framework on WinXP
  475. * 1) do not take timeout mechanism for power mode oids
  476. * 2) retrieve network type from connection status
  477. * 3) after disassciation, set radio state to off
  478. * 4) TCP option over IPv6 is supported
  479. *
  480. * 04 29 2010 wh.su
  481. * [WPD00003816][MT6620 Wi-Fi] Adding the security support
  482. * fixing the PMKID candicate indicate code.
  483. *
  484. * 04 28 2010 cp.wu
  485. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  486. * change prefix for data structure used to communicate with 802.11 PAL
  487. * to avoid ambiguous naming with firmware interface
  488. *
  489. * 04 27 2010 cp.wu
  490. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  491. * basic implementation for EVENT_BT_OVER_WIFI
  492. *
  493. * 04 23 2010 cp.wu
  494. * [WPD00001943]Create WiFi test driver framework on WinXP
  495. * surpress compiler warning
  496. *
  497. * 04 22 2010 jeffrey.chang
  498. * [WPD00003826]Initial import for Linux port
  499. *
  500. * 1) modify rx path code for supporting Wi-Fi direct
  501. * 2) modify config.h since Linux dont need to consider retaining packet
  502. *
  503. * 04 16 2010 cp.wu
  504. * [WPD00001943]Create WiFi test driver framework on WinXP
  505. * treat BUS access failure as kind of card removal.
  506. *
  507. * 04 14 2010 cp.wu
  508. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  509. * nicRxProcessEvent packet doesn't access spin-lock directly from now on.
  510. *
  511. * 04 14 2010 cp.wu
  512. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  513. * do not need to release the spin lock due to it is done inside nicGetPendingCmdInfo()
  514. *
  515. * 04 13 2010 cp.wu
  516. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  517. * add framework for BT-over-Wi-Fi support.
  518. * * * * * * * * * * * * * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
  519. * * * * * * * * * * * * * * * 2) command sequence number is now increased atomically
  520. * * * * * * * * * * * * * * * 3) private data could be hold and taken use for other purpose
  521. *
  522. * 04 12 2010 cp.wu
  523. * [WPD00001943]Create WiFi test driver framework on WinXP
  524. * add channel frequency <-> number conversion
  525. *
  526. * 04 09 2010 jeffrey.chang
  527. * [WPD00003826]Initial import for Linux port
  528. * 1) add spinlock
  529. * 2) add KAPI for handling association info
  530. *
  531. * 04 07 2010 cp.wu
  532. * [WPD00001943]Create WiFi test driver framework on WinXP
  533. * rWlanInfo should be placed at adapter rather than glue due to most operations
  534. * * * * * are done in adapter layer.
  535. *
  536. * 04 07 2010 cp.wu
  537. * [WPD00001943]Create WiFi test driver framework on WinXP
  538. * eliminate direct access to prGlueInfo->eParamMediaStateIndicated from non-glue layer
  539. *
  540. * 04 06 2010 cp.wu
  541. * [WPD00001943]Create WiFi test driver framework on WinXP
  542. * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
  543. *
  544. * 04 01 2010 jeffrey.chang
  545. * [WPD00003826]Initial import for Linux port
  546. * improve Linux supplicant compliance
  547. *
  548. * 03 31 2010 jeffrey.chang
  549. * [WPD00003826]Initial import for Linux port
  550. * fix ioctl which may cause cmdinfo memory leak
  551. *
  552. * 03 30 2010 cp.wu
  553. * [WPD00001943]Create WiFi test driver framework on WinXP
  554. * remove driver-land statistics.
  555. *
  556. * 03 29 2010 jeffrey.chang
  557. * [WPD00003826]Initial import for Linux port
  558. * improve none-glue code portability
  559. *
  560. * 03 28 2010 jeffrey.chang
  561. * [WPD00003826]Initial import for Linux port
  562. * rWlanInfo is modified before data is indicated to OS
  563. *
  564. * 03 28 2010 jeffrey.chang
  565. * [WPD00003826]Initial import for Linux port
  566. * rWlanInfo is modified before data is indicated to OS
  567. *
  568. * 03 26 2010 cp.wu
  569. * [WPD00001943]Create WiFi test driver framework on WinXP
  570. * add a temporary flag for integration with CMD/EVENT v0.9.
  571. *
  572. * 03 25 2010 cp.wu
  573. * [WPD00001943]Create WiFi test driver framework on WinXP
  574. * 1) correct OID_802_11_CONFIGURATION with frequency setting behavior.
  575. * * * the frequency is used for adhoc connection only
  576. * * * 2) update with SD1 v0.9 CMD/EVENT documentation
  577. *
  578. * 03 24 2010 jeffrey.chang
  579. * [WPD00003826]Initial import for Linux port
  580. * initial import for Linux port
  581. *
  582. * 03 24 2010 cp.wu
  583. * [WPD00001943]Create WiFi test driver framework on WinXP
  584. * .
  585. *
  586. * 03 24 2010 cp.wu
  587. * [WPD00001943]Create WiFi test driver framework on WinXP
  588. * generate information for OID_GEN_RCV_OK & OID_GEN_XMIT_OK
  589. * * * *
  590. *
  591. * 03 19 2010 cp.wu
  592. * [WPD00001943]Create WiFi test driver framework on WinXP
  593. * 1) add ACPI D0/D3 state switching support
  594. * * * * * * * * * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX
  595. * response
  596. *
  597. * 03 15 2010 kevin.huang
  598. * [WPD00003820][MT6620 Wi-Fi] Modify the code for meet the WHQL test
  599. * Add event for activate STA_RECORD_T
  600. *
  601. * 03 12 2010 cp.wu
  602. * [WPD00001943]Create WiFi test driver framework on WinXP
  603. * correct fgSetQuery/fgNeedResp check
  604. *
  605. * 03 11 2010 cp.wu
  606. * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
  607. * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
  608. *
  609. * 03 10 2010 cp.wu
  610. * [WPD00001943]Create WiFi test driver framework on WinXP
  611. * code clean: removing unused variables and structure definitions
  612. *
  613. * 03 08 2010 cp.wu
  614. * [WPD00001943]Create WiFi test driver framework on WinXP
  615. * 1) add another spin-lock to protect MsduInfoList due to it might be accessed by different thread.
  616. * * * 2) change own-back acquiring procedure to wait for up to 16.67 seconds
  617. *
  618. * 03 02 2010 cp.wu
  619. * [WPD00001943]Create WiFi test driver framework on WinXP
  620. * 1) the use of prPendingOid revised, all accessing are now protected by spin lock
  621. * * * * 2) ensure wlanReleasePendingOid will clear all command queues
  622. *
  623. * 03 02 2010 cp.wu
  624. * [WPD00001943]Create WiFi test driver framework on WinXP
  625. * add mutex to avoid multiple access to qmTxQueue simultaneously.
  626. *
  627. * 02 26 2010 cp.wu
  628. * [WPD00001943]Create WiFi test driver framework on WinXP
  629. * move EVENT_ID_ASSOC_INFO from nic_rx.c to gl_kal_ndis_51.c
  630. * * 'cause it involves OS dependent data structure handling
  631. *
  632. * 02 25 2010 cp.wu
  633. * [WPD00001943]Create WiFi test driver framework on WinXP
  634. * correct behavior to prevent duplicated RX handling for RX0_DONE and RX1_DONE
  635. *
  636. * 02 24 2010 tehuang.liu
  637. * [WPD00001943]Create WiFi test driver framework on WinXP
  638. * Updated API interfaces for qmHandleEventRxAddBa() and qmHandleEventRxDelBa()
  639. *
  640. * 02 10 2010 cp.wu
  641. * [WPD00001943]Create WiFi test driver framework on WinXP
  642. * implement host-side firmware download logic
  643. *
  644. * 02 10 2010 cp.wu
  645. * [WPD00001943]Create WiFi test driver framework on WinXP
  646. * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
  647. * * * * * 2) firmware image length is now retrieved via NdisFileOpen
  648. * * * * * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
  649. * * * * * 4) nicRxWaitResponse() revised
  650. * * * * * 5) another set of TQ counter default value is added for fw-download state
  651. * * * * * 6) Wi-Fi load address is now retrieved from registry too
  652. *
  653. * 02 09 2010 cp.wu
  654. * [WPD00001943]Create WiFi test driver framework on WinXP
  655. * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
  656. * * * * * * * * 2. follow MSDN defined behavior when associates to another AP
  657. * * * * * * * * 3. for firmware download, packet size could be up to 2048 bytes
  658. *
  659. * 01 27 2010 wh.su
  660. * [WPD00003816][MT6620 Wi-Fi] Adding the security support
  661. * .
  662. *
  663. * 01 22 2010 cp.wu
  664. * [WPD00001943]Create WiFi test driver framework on WinXP
  665. * implement following 802.11 OIDs:
  666. * * * * * * OID_802_11_RSSI,
  667. * * * * * * OID_802_11_RSSI_TRIGGER,
  668. * * * * * * OID_802_11_STATISTICS,
  669. * * * * * * OID_802_11_DISASSOCIATE,
  670. * * * * * * OID_802_11_POWER_MODE
  671. *
  672. * 12 30 2009 cp.wu
  673. * [WPD00001943]Create WiFi test driver framework on WinXP
  674. * 1) According to CMD/EVENT documentation v0.8,
  675. * * * * * * * * * OID_CUSTOM_TEST_RX_STATUS & OID_CUSTOM_TEST_TX_STATUS is no longer used,
  676. * * * * * * * * * and result is retrieved by get ATInfo instead
  677. * * * * * * * * * 2) add 4 counter for recording aggregation statistics
  678. *
  679. * 12 23 2009 cp.wu
  680. * [WPD00001943]Create WiFi test driver framework on WinXP
  681. * add a precheck: if free sw rfb is not enough, do not invoke read transactionu1rwduu`wvpghlqg|fu+rp
  682. *
  683. * 12 22 2009 cp.wu
  684. * [WPD00003809][Bug] Host driver will crash when processing reordered MSDUs
  685. * The root cause is pointer accessing by mistake. After dequeued from reordering-buffer, handling logic should access
  686. * returned pointer instead of pointer which has been passed in before.
  687. ** \main\maintrunk.MT6620WiFiDriver_Prj\58 2009-12-17 13:40:33 GMT mtk02752
  688. ** always update prAdapter->rSDIOCtrl when enhanced response is read by RX
  689. ** \main\maintrunk.MT6620WiFiDriver_Prj\57 2009-12-16 18:01:38 GMT mtk02752
  690. ** if interrupt enhanced response is fetched by RX enhanced response, RX needs to invoke interrupt handlers too
  691. ** \main\maintrunk.MT6620WiFiDriver_Prj\56 2009-12-16 14:16:52 GMT mtk02752
  692. ** \main\maintrunk.MT6620WiFiDriver_Prj\55 2009-12-15 20:03:12 GMT mtk02752
  693. ** ASSERT when RX FreeSwRfb is not enough
  694. ** \main\maintrunk.MT6620WiFiDriver_Prj\54 2009-12-15 17:01:29 GMT mtk02752
  695. ** when CFG_SDIO_RX_ENHANCE is enabled, after enhanced response is read, rx procedure should process
  696. ** 1) TX_DONE_INT 2) D2H INT as well
  697. ** \main\maintrunk.MT6620WiFiDriver_Prj\53 2009-12-14 20:45:28 GMT mtk02752
  698. ** when CFG_SDIO_RX_ENHANCE is set, TC counter must be updated each time RX enhance response is read
  699. **
  700. ** \main\maintrunk.MT6620WiFiDriver_Prj\52 2009-12-14 11:34:16 GMT mtk02752
  701. ** correct a trivial logic issue
  702. ** \main\maintrunk.MT6620WiFiDriver_Prj\51 2009-12-14 10:28:25 GMT mtk02752
  703. ** add a protection to avoid out-of-boundary access
  704. ** \main\maintrunk.MT6620WiFiDriver_Prj\50 2009-12-10 16:55:18 GMT mtk02752
  705. ** code clean
  706. ** \main\maintrunk.MT6620WiFiDriver_Prj\49 2009-12-09 14:06:47 GMT MTK02468
  707. ** Added parsing event packets with EVENT_ID_RX_ADDBA or EVENT_ID_RX_DELBA
  708. ** \main\maintrunk.MT6620WiFiDriver_Prj\48 2009-12-08 17:37:51 GMT mtk02752
  709. ** handle EVENT_ID_TEST_STATUS as well
  710. ** \main\maintrunk.MT6620WiFiDriver_Prj\47 2009-12-04 17:59:11 GMT mtk02752
  711. ** to pass free-build compilation check
  712. ** \main\maintrunk.MT6620WiFiDriver_Prj\46 2009-12-04 12:09:52 GMT mtk02752
  713. ** correct trivial mistake
  714. ** \main\maintrunk.MT6620WiFiDriver_Prj\45 2009-12-04 11:53:37 GMT mtk02752
  715. ** all API should be compilable under SD1_SD3_DATAPATH_INTEGRATION == 0
  716. ** \main\maintrunk.MT6620WiFiDriver_Prj\44 2009-12-03 16:19:48 GMT mtk01461
  717. ** Fix the Connected Event
  718. ** \main\maintrunk.MT6620WiFiDriver_Prj\43 2009-11-30 10:56:18 GMT mtk02752
  719. ** 1st DW of WIFI_EVENT_T is shared with HIF_RX_HEADER_T
  720. ** \main\maintrunk.MT6620WiFiDriver_Prj\42 2009-11-30 10:11:27 GMT mtk02752
  721. ** implement replacement for bss scan result
  722. ** \main\maintrunk.MT6620WiFiDriver_Prj\41 2009-11-27 11:08:05 GMT mtk02752
  723. ** add flush for reset
  724. ** \main\maintrunk.MT6620WiFiDriver_Prj\40 2009-11-26 09:38:59 GMT mtk02752
  725. ** \main\maintrunk.MT6620WiFiDriver_Prj\39 2009-11-26 09:29:40 GMT mtk02752
  726. ** enable packet forwarding path (for AP mode)
  727. ** \main\maintrunk.MT6620WiFiDriver_Prj\38 2009-11-25 21:37:00 GMT mtk02752
  728. ** sync. with EVENT_SCAN_RESULT_T change, and add an assert for checking event size
  729. ** \main\maintrunk.MT6620WiFiDriver_Prj\37 2009-11-25 20:17:41 GMT mtk02752
  730. ** fill HIF_TX_HEADER_T.u2SeqNo
  731. ** \main\maintrunk.MT6620WiFiDriver_Prj\36 2009-11-25 18:18:57 GMT mtk02752
  732. ** buffer scan result to prGlueInfo->rWlanInfo.arScanResult directly.
  733. ** \main\maintrunk.MT6620WiFiDriver_Prj\35 2009-11-24 22:42:45 GMT mtk02752
  734. ** add nicRxAddScanResult() to prepare to handle SCAN_RESULT event (not implemented yet)
  735. ** \main\maintrunk.MT6620WiFiDriver_Prj\34 2009-11-24 20:51:41 GMT mtk02752
  736. ** integrate with SD1's data path API
  737. ** \main\maintrunk.MT6620WiFiDriver_Prj\33 2009-11-24 19:56:17 GMT mtk02752
  738. ** adopt P_HIF_RX_HEADER_T in new path
  739. ** \main\maintrunk.MT6620WiFiDriver_Prj\32 2009-11-23 20:31:21 GMT mtk02752
  740. ** payload to send into pfCmdDoneHandler() will not include WIFI_EVENT_T
  741. ** \main\maintrunk.MT6620WiFiDriver_Prj\31 2009-11-23 17:51:34 GMT mtk02752
  742. ** when event packet corresponding to some pendingOID is received, pendingOID should be cleared
  743. ** \main\maintrunk.MT6620WiFiDriver_Prj\30 2009-11-23 14:46:54 GMT mtk02752
  744. ** implement nicRxProcessEventPacket()
  745. ** \main\maintrunk.MT6620WiFiDriver_Prj\29 2009-11-17 22:40:54 GMT mtk01084
  746. ** \main\maintrunk.MT6620WiFiDriver_Prj\28 2009-11-16 21:48:22 GMT mtk02752
  747. ** add SD1_SD3_DATAPATH_INTEGRATION data path handling
  748. ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-11-16 15:41:18 GMT mtk01084
  749. ** modify the length to be read in emu mode
  750. ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-11-13 17:00:12 GMT mtk02752
  751. ** add blank function for event packet
  752. ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-11-13 13:54:24 GMT mtk01084
  753. ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-11-11 14:41:51 GMT mtk02752
  754. ** fix typo
  755. ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-11-11 14:33:46 GMT mtk02752
  756. ** add protection when there is no packet avilable
  757. ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-11-11 12:33:36 GMT mtk02752
  758. ** add RX1 read path for aggregated/enhanced/normal packet read procedures
  759. ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-11-11 10:36:18 GMT mtk01084
  760. ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-11-04 14:11:08 GMT mtk01084
  761. ** modify lines in RX aggregation
  762. ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-10-30 18:17:23 GMT mtk01084
  763. ** modify RX aggregation handling
  764. ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-10-29 19:56:12 GMT mtk01084
  765. ** modify HAL part
  766. ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-10-23 16:08:34 GMT mtk01084
  767. ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-10-13 21:59:20 GMT mtk01084
  768. ** update for new HW design
  769. ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-10-02 13:59:08 GMT mtk01725
  770. ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-05-21 23:39:05 GMT mtk01461
  771. ** Fix the paste error of RX STATUS in OOB of HIF Loopback CTRL
  772. ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-05-20 12:25:32 GMT mtk01461
  773. ** Fix process of Read Done, and add u4MaxEventBufferLen to nicRxWaitResponse()
  774. ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-05-18 21:13:18 GMT mtk01426
  775. ** Fixed compiler error
  776. ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-05-18 21:05:29 GMT mtk01426
  777. ** Fixed nicRxSDIOAggReceiveRFBs() ASSERT issue
  778. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-28 10:38:43 GMT mtk01461
  779. ** Fix RX STATUS is DW align for SDIO_STATUS_ENHANCE mode and refine nicRxSDIOAggeceiveRFBs() for RX Aggregation
  780. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-22 09:12:17 GMT mtk01461
  781. ** Fix nicRxProcessHIFLoopbackPacket(), the size of HIF CTRL LENGTH field is 1 byte
  782. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-14 15:51:26 GMT mtk01426
  783. ** Update RX OOB Setting
  784. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-04-03 14:58:58 GMT mtk01426
  785. ** Fixed logical error
  786. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-04-01 10:58:31 GMT mtk01461
  787. ** Rename the HIF_PKT_TYPE_DATA
  788. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-23 21:51:18 GMT mtk01461
  789. ** Fix u4HeaderOffset in nicRxProcessHIFLoopbackPacket()
  790. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-18 21:02:58 GMT mtk01426
  791. ** Add CFG_SDIO_RX_ENHANCE and CFG_HIF_LOOPBACK support
  792. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-17 20:20:59 GMT mtk01426
  793. ** Add nicRxWaitResponse function
  794. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 20:26:01 GMT mtk01426
  795. ** Init for develop
  796. **
  797. */
  798. /*******************************************************************************
  799. * C O M P I L E R F L A G S
  800. ********************************************************************************
  801. */
  802. /*******************************************************************************
  803. * E X T E R N A L R E F E R E N C E S
  804. ********************************************************************************
  805. */
  806. #include "precomp.h"
  807. #ifndef LINUX
  808. #include <limits.h>
  809. #else
  810. #include <linux/limits.h>
  811. #endif
  812. #include "gl_os.h"
  813. #include "debug.h"
  814. #include "wlan_lib.h"
  815. #include "gl_wext.h"
  816. #include <linux/can/netlink.h>
  817. #include <net/netlink.h>
  818. #include <net/cfg80211.h>
  819. #include "gl_cfg80211.h"
  820. #include "gl_vendor.h"
  821. /*******************************************************************************
  822. * C O N S T A N T S
  823. ********************************************************************************
  824. */
  825. #define RX_RESPONSE_TIMEOUT (1000)
  826. /*******************************************************************************
  827. * D A T A T Y P E S
  828. ********************************************************************************
  829. */
  830. /*******************************************************************************
  831. * P U B L I C D A T A
  832. ********************************************************************************
  833. */
  834. /*******************************************************************************
  835. * P R I V A T E D A T A
  836. ********************************************************************************
  837. */
  838. #if CFG_MGMT_FRAME_HANDLING
  839. static PROCESS_RX_MGT_FUNCTION apfnProcessRxMgtFrame[MAX_NUM_OF_FC_SUBTYPES] = {
  840. #if CFG_SUPPORT_AAA
  841. aaaFsmRunEventRxAssoc, /* subtype 0000: Association request */
  842. #else
  843. NULL, /* subtype 0000: Association request */
  844. #endif /* CFG_SUPPORT_AAA */
  845. saaFsmRunEventRxAssoc, /* subtype 0001: Association response */
  846. #if CFG_SUPPORT_AAA
  847. aaaFsmRunEventRxAssoc, /* subtype 0010: Reassociation request */
  848. #else
  849. NULL, /* subtype 0010: Reassociation request */
  850. #endif /* CFG_SUPPORT_AAA */
  851. saaFsmRunEventRxAssoc, /* subtype 0011: Reassociation response */
  852. #if (CFG_SUPPORT_ADHOC) || (CFG_SUPPORT_AAA)
  853. bssProcessProbeRequest, /* subtype 0100: Probe request */
  854. #else
  855. NULL, /* subtype 0100: Probe request */
  856. #endif /* CFG_SUPPORT_ADHOC */
  857. scanProcessBeaconAndProbeResp, /* subtype 0101: Probe response */
  858. NULL, /* subtype 0110: reserved */
  859. NULL, /* subtype 0111: reserved */
  860. scanProcessBeaconAndProbeResp, /* subtype 1000: Beacon */
  861. NULL, /* subtype 1001: ATIM */
  862. saaFsmRunEventRxDisassoc, /* subtype 1010: Disassociation */
  863. authCheckRxAuthFrameTransSeq, /* subtype 1011: Authentication */
  864. saaFsmRunEventRxDeauth, /* subtype 1100: Deauthentication */
  865. nicRxProcessActionFrame, /* subtype 1101: Action */
  866. NULL, /* subtype 1110: reserved */
  867. NULL /* subtype 1111: reserved */
  868. };
  869. #endif
  870. /*******************************************************************************
  871. * M A C R O S
  872. ********************************************************************************
  873. */
  874. /*******************************************************************************
  875. * F U N C T I O N D E C L A R A T I O N S
  876. ********************************************************************************
  877. */
  878. /*******************************************************************************
  879. * F U N C T I O N S
  880. ********************************************************************************
  881. */
  882. /*----------------------------------------------------------------------------*/
  883. /*!
  884. * @brief Initialize the RFBs
  885. *
  886. * @param prAdapter Pointer to the Adapter structure.
  887. *
  888. * @return (none)
  889. */
  890. /*----------------------------------------------------------------------------*/
  891. VOID nicRxInitialize(IN P_ADAPTER_T prAdapter)
  892. {
  893. P_RX_CTRL_T prRxCtrl;
  894. PUINT_8 pucMemHandle;
  895. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  896. UINT_32 i;
  897. DEBUGFUNC("nicRxInitialize");
  898. ASSERT(prAdapter);
  899. prRxCtrl = &prAdapter->rRxCtrl;
  900. /* 4 <0> Clear allocated memory. */
  901. kalMemZero((PVOID) prRxCtrl->pucRxCached, prRxCtrl->u4RxCachedSize);
  902. /* 4 <1> Initialize the RFB lists */
  903. QUEUE_INITIALIZE(&prRxCtrl->rFreeSwRfbList);
  904. QUEUE_INITIALIZE(&prRxCtrl->rReceivedRfbList);
  905. QUEUE_INITIALIZE(&prRxCtrl->rIndicatedRfbList);
  906. pucMemHandle = prRxCtrl->pucRxCached;
  907. for (i = CFG_RX_MAX_PKT_NUM; i != 0; i--) {
  908. prSwRfb = (P_SW_RFB_T) pucMemHandle;
  909. nicRxSetupRFB(prAdapter, prSwRfb);
  910. nicRxReturnRFB(prAdapter, prSwRfb);
  911. pucMemHandle += ALIGN_4(sizeof(SW_RFB_T));
  912. }
  913. ASSERT(prRxCtrl->rFreeSwRfbList.u4NumElem == CFG_RX_MAX_PKT_NUM);
  914. /* Check if the memory allocation consist with this initialization function */
  915. ASSERT((ULONG) (pucMemHandle - prRxCtrl->pucRxCached) == prRxCtrl->u4RxCachedSize);
  916. /* 4 <2> Clear all RX counters */
  917. RX_RESET_ALL_CNTS(prRxCtrl);
  918. #if CFG_SDIO_RX_AGG
  919. prRxCtrl->pucRxCoalescingBufPtr = prAdapter->pucCoalescingBufCached;
  920. HAL_CFG_MAX_HIF_RX_LEN_NUM(prAdapter, CFG_SDIO_MAX_RX_AGG_NUM);
  921. #else
  922. HAL_CFG_MAX_HIF_RX_LEN_NUM(prAdapter, 1);
  923. #endif
  924. #if CFG_HIF_STATISTICS
  925. prRxCtrl->u4TotalRxAccessNum = 0;
  926. prRxCtrl->u4TotalRxPacketNum = 0;
  927. #endif
  928. #if CFG_HIF_RX_STARVATION_WARNING
  929. prRxCtrl->u4QueuedCnt = 0;
  930. prRxCtrl->u4DequeuedCnt = 0;
  931. #endif
  932. } /* end of nicRxInitialize() */
  933. /*----------------------------------------------------------------------------*/
  934. /*!
  935. * @brief Uninitialize the RFBs
  936. *
  937. * @param prAdapter Pointer to the Adapter structure.
  938. *
  939. * @return (none)
  940. */
  941. /*----------------------------------------------------------------------------*/
  942. VOID nicRxUninitialize(IN P_ADAPTER_T prAdapter)
  943. {
  944. P_RX_CTRL_T prRxCtrl;
  945. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  946. KAL_SPIN_LOCK_DECLARATION();
  947. ASSERT(prAdapter);
  948. prRxCtrl = &prAdapter->rRxCtrl;
  949. ASSERT(prRxCtrl);
  950. nicRxFlush(prAdapter);
  951. do {
  952. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  953. QUEUE_REMOVE_HEAD(&prRxCtrl->rReceivedRfbList, prSwRfb, P_SW_RFB_T);
  954. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  955. if (prSwRfb) {
  956. if (prSwRfb->pvPacket)
  957. kalPacketFree(prAdapter->prGlueInfo, prSwRfb->pvPacket);
  958. prSwRfb->pvPacket = NULL;
  959. } else {
  960. break;
  961. }
  962. } while (TRUE);
  963. do {
  964. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  965. QUEUE_REMOVE_HEAD(&prRxCtrl->rFreeSwRfbList, prSwRfb, P_SW_RFB_T);
  966. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  967. if (prSwRfb) {
  968. if (prSwRfb->pvPacket)
  969. kalPacketFree(prAdapter->prGlueInfo, prSwRfb->pvPacket);
  970. prSwRfb->pvPacket = NULL;
  971. } else {
  972. break;
  973. }
  974. } while (TRUE);
  975. } /* end of nicRxUninitialize() */
  976. /*----------------------------------------------------------------------------*/
  977. /*!
  978. * @brief Fill RFB
  979. *
  980. * @param prAdapter pointer to the Adapter handler
  981. * @param prSWRfb specify the RFB to receive rx data
  982. *
  983. * @return (none)
  984. *
  985. */
  986. /*----------------------------------------------------------------------------*/
  987. VOID nicRxFillRFB(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  988. {
  989. P_HIF_RX_HEADER_T prHifRxHdr;
  990. UINT_32 u4PktLen = 0;
  991. UINT_32 u4MacHeaderLen;
  992. UINT_32 u4HeaderOffset;
  993. DEBUGFUNC("nicRxFillRFB");
  994. ASSERT(prAdapter);
  995. ASSERT(prSwRfb);
  996. prHifRxHdr = prSwRfb->prHifRxHdr;
  997. ASSERT(prHifRxHdr);
  998. u4PktLen = prHifRxHdr->u2PacketLen;
  999. u4HeaderOffset = (UINT_32) (prHifRxHdr->ucHerderLenOffset & HIF_RX_HDR_HEADER_OFFSET_MASK);
  1000. u4MacHeaderLen = (UINT_32) (prHifRxHdr->ucHerderLenOffset & HIF_RX_HDR_HEADER_LEN)
  1001. >> HIF_RX_HDR_HEADER_LEN_OFFSET;
  1002. /* DBGLOG(RX, TRACE, ("u4HeaderOffset = %d, u4MacHeaderLen = %d\n", */
  1003. /* u4HeaderOffset, u4MacHeaderLen)); */
  1004. prSwRfb->u2HeaderLen = (UINT_16) u4MacHeaderLen;
  1005. prSwRfb->pvHeader = (PUINT_8) prHifRxHdr + HIF_RX_HDR_SIZE + u4HeaderOffset;
  1006. prSwRfb->u2PacketLen = (UINT_16) (u4PktLen - (HIF_RX_HDR_SIZE + u4HeaderOffset));
  1007. /* DBGLOG(RX, TRACE, ("Dump Rx packet, u2PacketLen = %d\n", prSwRfb->u2PacketLen)); */
  1008. /* DBGLOG_MEM8(RX, TRACE, prSwRfb->pvHeader, prSwRfb->u2PacketLen); */
  1009. #if 0
  1010. if (prHifRxHdr->ucReorder & HIF_RX_HDR_80211_HEADER_FORMAT) {
  1011. prSwRfb->u4HifRxHdrFlag |= HIF_RX_HDR_FLAG_802_11_FORMAT;
  1012. DBGLOG(RX, TRACE, "HIF_RX_HDR_FLAG_802_11_FORMAT\n");
  1013. }
  1014. if (prHifRxHdr->ucReorder & HIF_RX_HDR_DO_REORDER) {
  1015. prSwRfb->u4HifRxHdrFlag |= HIF_RX_HDR_FLAG_DO_REORDERING;
  1016. DBGLOG(RX, TRACE, "HIF_RX_HDR_FLAG_DO_REORDERING\n");
  1017. /* Get Seq. No and TID, Wlan Index info */
  1018. if (prHifRxHdr->u2SeqNoTid & HIF_RX_HDR_BAR_FRAME) {
  1019. prSwRfb->u4HifRxHdrFlag |= HIF_RX_HDR_FLAG_BAR_FRAME;
  1020. DBGLOG(RX, TRACE, "HIF_RX_HDR_FLAG_BAR_FRAME\n");
  1021. }
  1022. prSwRfb->u2SSN = prHifRxHdr->u2SeqNoTid & HIF_RX_HDR_SEQ_NO_MASK;
  1023. prSwRfb->ucTid = (UINT_8) ((prHifRxHdr->u2SeqNoTid & HIF_RX_HDR_TID_MASK)
  1024. >> HIF_RX_HDR_TID_OFFSET);
  1025. DBGLOG(RX, TRACE, "u2SSN = %d, ucTid = %d\n", prSwRfb->u2SSN, prSwRfb->ucTid);
  1026. }
  1027. if (prHifRxHdr->ucReorder & HIF_RX_HDR_WDS) {
  1028. prSwRfb->u4HifRxHdrFlag |= HIF_RX_HDR_FLAG_AMP_WDS;
  1029. DBGLOG(RX, TRACE, "HIF_RX_HDR_FLAG_AMP_WDS\n");
  1030. }
  1031. #endif
  1032. }
  1033. #if CFG_TCP_IP_CHKSUM_OFFLOAD || CFG_TCP_IP_CHKSUM_OFFLOAD_NDIS_60
  1034. /*----------------------------------------------------------------------------*/
  1035. /*!
  1036. * @brief Fill checksum status in RFB
  1037. *
  1038. * @param prAdapter pointer to the Adapter handler
  1039. * @param prSWRfb the RFB to receive rx data
  1040. * @param u4TcpUdpIpCksStatus specify the Checksum status
  1041. *
  1042. * @return (none)
  1043. *
  1044. */
  1045. /*----------------------------------------------------------------------------*/
  1046. VOID nicRxFillChksumStatus(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb, IN UINT_32 u4TcpUdpIpCksStatus)
  1047. {
  1048. ASSERT(prAdapter);
  1049. ASSERT(prSwRfb);
  1050. if (prAdapter->u4CSUMFlags != CSUM_NOT_SUPPORTED) {
  1051. if (u4TcpUdpIpCksStatus & RX_CS_TYPE_IPv4) { /* IPv4 packet */
  1052. prSwRfb->aeCSUM[CSUM_TYPE_IPV6] = CSUM_RES_NONE;
  1053. if (u4TcpUdpIpCksStatus & RX_CS_STATUS_IP) { /* IP packet csum failed */
  1054. prSwRfb->aeCSUM[CSUM_TYPE_IPV4] = CSUM_RES_FAILED;
  1055. } else {
  1056. prSwRfb->aeCSUM[CSUM_TYPE_IPV4] = CSUM_RES_SUCCESS;
  1057. }
  1058. if (u4TcpUdpIpCksStatus & RX_CS_TYPE_TCP) { /* TCP packet */
  1059. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_NONE;
  1060. if (u4TcpUdpIpCksStatus & RX_CS_STATUS_TCP) { /* TCP packet csum failed */
  1061. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_FAILED;
  1062. } else {
  1063. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_SUCCESS;
  1064. }
  1065. } else if (u4TcpUdpIpCksStatus & RX_CS_TYPE_UDP) { /* UDP packet */
  1066. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_NONE;
  1067. if (u4TcpUdpIpCksStatus & RX_CS_STATUS_UDP) { /* UDP packet csum failed */
  1068. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_FAILED;
  1069. } else {
  1070. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_SUCCESS;
  1071. }
  1072. } else {
  1073. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_NONE;
  1074. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_NONE;
  1075. }
  1076. } else if (u4TcpUdpIpCksStatus & RX_CS_TYPE_IPv6) { /* IPv6 packet */
  1077. prSwRfb->aeCSUM[CSUM_TYPE_IPV4] = CSUM_RES_NONE;
  1078. prSwRfb->aeCSUM[CSUM_TYPE_IPV6] = CSUM_RES_SUCCESS;
  1079. if (u4TcpUdpIpCksStatus & RX_CS_TYPE_TCP) { /* TCP packet */
  1080. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_NONE;
  1081. if (u4TcpUdpIpCksStatus & RX_CS_STATUS_TCP) { /* TCP packet csum failed */
  1082. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_FAILED;
  1083. } else {
  1084. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_SUCCESS;
  1085. }
  1086. } else if (u4TcpUdpIpCksStatus & RX_CS_TYPE_UDP) { /* UDP packet */
  1087. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_NONE;
  1088. if (u4TcpUdpIpCksStatus & RX_CS_STATUS_UDP) { /* UDP packet csum failed */
  1089. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_FAILED;
  1090. } else {
  1091. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_SUCCESS;
  1092. }
  1093. } else {
  1094. prSwRfb->aeCSUM[CSUM_TYPE_UDP] = CSUM_RES_NONE;
  1095. prSwRfb->aeCSUM[CSUM_TYPE_TCP] = CSUM_RES_NONE;
  1096. }
  1097. } else {
  1098. prSwRfb->aeCSUM[CSUM_TYPE_IPV4] = CSUM_RES_NONE;
  1099. prSwRfb->aeCSUM[CSUM_TYPE_IPV6] = CSUM_RES_NONE;
  1100. }
  1101. }
  1102. }
  1103. #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
  1104. /*----------------------------------------------------------------------------*/
  1105. /*!
  1106. * @brief Process packet doesn't need to do buffer reordering
  1107. *
  1108. * @param prAdapter pointer to the Adapter handler
  1109. * @param prSWRfb the RFB to receive rx data
  1110. *
  1111. * @return (none)
  1112. *
  1113. */
  1114. /*----------------------------------------------------------------------------*/
  1115. VOID nicRxProcessPktWithoutReorder(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1116. {
  1117. P_RX_CTRL_T prRxCtrl;
  1118. P_TX_CTRL_T prTxCtrl;
  1119. BOOLEAN fgIsRetained = FALSE;
  1120. UINT_32 u4CurrentRxBufferCount;
  1121. P_STA_RECORD_T prStaRec = (P_STA_RECORD_T) NULL;
  1122. DEBUGFUNC("nicRxProcessPktWithoutReorder");
  1123. /* DBGLOG(RX, TRACE, ("\n")); */
  1124. ASSERT(prAdapter);
  1125. ASSERT(prSwRfb);
  1126. prRxCtrl = &prAdapter->rRxCtrl;
  1127. ASSERT(prRxCtrl);
  1128. prTxCtrl = &prAdapter->rTxCtrl;
  1129. ASSERT(prTxCtrl);
  1130. u4CurrentRxBufferCount = prRxCtrl->rFreeSwRfbList.u4NumElem;
  1131. /* QM USED = $A, AVAILABLE COUNT = $B, INDICATED TO OS = $C
  1132. * TOTAL = $A + $B + $C
  1133. *
  1134. * Case #1 (Retain)
  1135. * -------------------------------------------------------
  1136. * $A + $B < THRESHOLD := $A + $B + $C < THRESHOLD + $C := $TOTAL - THRESHOLD < $C
  1137. * => $C used too much, retain
  1138. *
  1139. * Case #2 (Non-Retain)
  1140. * -------------------------------------------------------
  1141. * $A + $B > THRESHOLD := $A + $B + $C > THRESHOLD + $C := $TOTAL - THRESHOLD > $C
  1142. * => still available for $C to use
  1143. *
  1144. */
  1145. fgIsRetained = (((u4CurrentRxBufferCount +
  1146. qmGetRxReorderQueuedBufferCount(prAdapter) +
  1147. prTxCtrl->i4PendingFwdFrameCount) < CFG_RX_RETAINED_PKT_THRESHOLD) ? TRUE : FALSE);
  1148. /* DBGLOG(RX, INFO, ("fgIsRetained = %d\n", fgIsRetained)); */
  1149. if (kalProcessRxPacket(prAdapter->prGlueInfo,
  1150. prSwRfb->pvPacket,
  1151. prSwRfb->pvHeader,
  1152. (UINT_32) prSwRfb->u2PacketLen, fgIsRetained, prSwRfb->aeCSUM) != WLAN_STATUS_SUCCESS) {
  1153. DBGLOG(RX, ERROR, "kalProcessRxPacket return value != WLAN_STATUS_SUCCESS\n");
  1154. ASSERT(0);
  1155. nicRxReturnRFB(prAdapter, prSwRfb);
  1156. return;
  1157. }
  1158. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  1159. if (prStaRec) {
  1160. #if CFG_ENABLE_WIFI_DIRECT
  1161. if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX && prAdapter->fgIsP2PRegistered == TRUE)
  1162. GLUE_SET_PKT_FLAG_P2P(prSwRfb->pvPacket);
  1163. #endif
  1164. #if CFG_ENABLE_BT_OVER_WIFI
  1165. if (prStaRec->ucNetTypeIndex == NETWORK_TYPE_BOW_INDEX)
  1166. GLUE_SET_PKT_FLAG_PAL(prSwRfb->pvPacket);
  1167. #endif
  1168. /* record the count to pass to os */
  1169. STATS_RX_PASS2OS_INC(prStaRec, prSwRfb);
  1170. }
  1171. prRxCtrl->apvIndPacket[prRxCtrl->ucNumIndPacket] = prSwRfb->pvPacket;
  1172. prRxCtrl->ucNumIndPacket++;
  1173. if (fgIsRetained) {
  1174. prRxCtrl->apvRetainedPacket[prRxCtrl->ucNumRetainedPacket] = prSwRfb->pvPacket;
  1175. prRxCtrl->ucNumRetainedPacket++;
  1176. /* TODO : error handling of nicRxSetupRFB */
  1177. nicRxSetupRFB(prAdapter, prSwRfb);
  1178. nicRxReturnRFB(prAdapter, prSwRfb);
  1179. } else {
  1180. prSwRfb->pvPacket = NULL;
  1181. nicRxReturnRFB(prAdapter, prSwRfb);
  1182. }
  1183. }
  1184. /*----------------------------------------------------------------------------*/
  1185. /*!
  1186. * @brief Process forwarding data packet
  1187. *
  1188. * @param prAdapter pointer to the Adapter handler
  1189. * @param prSWRfb the RFB to receive rx data
  1190. *
  1191. * @return (none)
  1192. *
  1193. */
  1194. /*----------------------------------------------------------------------------*/
  1195. VOID nicRxProcessForwardPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1196. {
  1197. P_MSDU_INFO_T prMsduInfo, prRetMsduInfoList;
  1198. P_TX_CTRL_T prTxCtrl;
  1199. P_RX_CTRL_T prRxCtrl;
  1200. KAL_SPIN_LOCK_DECLARATION();
  1201. DEBUGFUNC("nicRxProcessForwardPkt");
  1202. ASSERT(prAdapter);
  1203. ASSERT(prSwRfb);
  1204. prTxCtrl = &prAdapter->rTxCtrl;
  1205. prRxCtrl = &prAdapter->rRxCtrl;
  1206. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_MSDU_INFO_LIST);
  1207. QUEUE_REMOVE_HEAD(&prTxCtrl->rFreeMsduInfoList, prMsduInfo, P_MSDU_INFO_T);
  1208. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_MSDU_INFO_LIST);
  1209. if (prMsduInfo && kalProcessRxPacket(prAdapter->prGlueInfo,
  1210. prSwRfb->pvPacket,
  1211. prSwRfb->pvHeader,
  1212. (UINT_32) prSwRfb->u2PacketLen,
  1213. prRxCtrl->rFreeSwRfbList.u4NumElem <
  1214. CFG_RX_RETAINED_PKT_THRESHOLD ? TRUE : FALSE,
  1215. prSwRfb->aeCSUM) == WLAN_STATUS_SUCCESS) {
  1216. prMsduInfo->eSrc = TX_PACKET_FORWARDING;
  1217. /* pack into MSDU_INFO_T */
  1218. nicTxFillMsduInfo(prAdapter, prMsduInfo, (P_NATIVE_PACKET) (prSwRfb->pvPacket));
  1219. /* Overwrite the ucNetworkType */
  1220. prMsduInfo->ucNetworkType = HIF_RX_HDR_GET_NETWORK_IDX(prSwRfb->prHifRxHdr);
  1221. /* release RX buffer (to rIndicatedRfbList) */
  1222. prSwRfb->pvPacket = NULL;
  1223. nicRxReturnRFB(prAdapter, prSwRfb);
  1224. /* increase forward frame counter */
  1225. GLUE_INC_REF_CNT(prTxCtrl->i4PendingFwdFrameCount);
  1226. /* send into TX queue */
  1227. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  1228. prRetMsduInfoList = qmEnqueueTxPackets(prAdapter, prMsduInfo);
  1229. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  1230. if (prRetMsduInfoList != NULL) { /* TX queue refuses queuing the packet */
  1231. nicTxFreeMsduInfoPacket(prAdapter, prRetMsduInfoList);
  1232. nicTxReturnMsduInfo(prAdapter, prRetMsduInfoList);
  1233. }
  1234. /* indicate service thread for sending */
  1235. if (prTxCtrl->i4PendingFwdFrameCount > 0)
  1236. kalSetEvent(prAdapter->prGlueInfo);
  1237. } else /* no TX resource */
  1238. nicRxReturnRFB(prAdapter, prSwRfb);
  1239. }
  1240. /*----------------------------------------------------------------------------*/
  1241. /*!
  1242. * @brief Process broadcast data packet for both host and forwarding
  1243. *
  1244. * @param prAdapter pointer to the Adapter handler
  1245. * @param prSWRfb the RFB to receive rx data
  1246. *
  1247. * @return (none)
  1248. *
  1249. */
  1250. /*----------------------------------------------------------------------------*/
  1251. VOID nicRxProcessGOBroadcastPkt(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  1252. {
  1253. P_SW_RFB_T prSwRfbDuplicated;
  1254. P_TX_CTRL_T prTxCtrl;
  1255. P_RX_CTRL_T prRxCtrl;
  1256. P_HIF_RX_HEADER_T prHifRxHdr;
  1257. KAL_SPIN_LOCK_DECLARATION();
  1258. DEBUGFUNC("nicRxProcessGOBroadcastPkt");
  1259. ASSERT(prAdapter);
  1260. ASSERT(prSwRfb);
  1261. prTxCtrl = &prAdapter->rTxCtrl;
  1262. prRxCtrl = &prAdapter->rRxCtrl;
  1263. prHifRxHdr = prSwRfb->prHifRxHdr;
  1264. ASSERT(prHifRxHdr);
  1265. ASSERT(CFG_NUM_OF_QM_RX_PKT_NUM >= 16);
  1266. if (prRxCtrl->rFreeSwRfbList.u4NumElem
  1267. >= (CFG_RX_MAX_PKT_NUM - (CFG_NUM_OF_QM_RX_PKT_NUM - 16 /* Reserved for others */))) {
  1268. /* 1. Duplicate SW_RFB_T */
  1269. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  1270. QUEUE_REMOVE_HEAD(&prRxCtrl->rFreeSwRfbList, prSwRfbDuplicated, P_SW_RFB_T);
  1271. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  1272. if (prSwRfbDuplicated) {
  1273. kalMemCopy(prSwRfbDuplicated->pucRecvBuff,
  1274. prSwRfb->pucRecvBuff, ALIGN_4(prHifRxHdr->u2PacketLen + HIF_RX_HW_APPENDED_LEN));
  1275. prSwRfbDuplicated->ucPacketType = HIF_RX_PKT_TYPE_DATA;
  1276. prSwRfbDuplicated->ucStaRecIdx = (UINT_8) (prHifRxHdr->ucStaRecIdx);
  1277. nicRxFillRFB(prAdapter, prSwRfbDuplicated);
  1278. /* 2. Modify eDst */
  1279. prSwRfbDuplicated->eDst = RX_PKT_DESTINATION_FORWARD;
  1280. /* 4. Forward */
  1281. nicRxProcessForwardPkt(prAdapter, prSwRfbDuplicated);
  1282. }
  1283. } else {
  1284. DBGLOG(RX, WARN, "Stop to forward BMC packet due to less free Sw Rfb %u\n",
  1285. prRxCtrl->rFreeSwRfbList.u4NumElem);
  1286. }
  1287. /* 3. Indicate to host */
  1288. prSwRfb->eDst = RX_PKT_DESTINATION_HOST;
  1289. nicRxProcessPktWithoutReorder(prAdapter, prSwRfb);
  1290. }
  1291. /*----------------------------------------------------------------------------*/
  1292. /*!
  1293. * @brief Process HIF data packet
  1294. *
  1295. * @param prAdapter pointer to the Adapter handler
  1296. * @param prSWRfb the RFB to receive rx data
  1297. *
  1298. * @return (none)
  1299. *
  1300. */
  1301. /*----------------------------------------------------------------------------*/
  1302. VOID nicRxProcessDataPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  1303. {
  1304. P_RX_CTRL_T prRxCtrl;
  1305. P_SW_RFB_T prRetSwRfb, prNextSwRfb;
  1306. P_HIF_RX_HEADER_T prHifRxHdr;
  1307. P_STA_RECORD_T prStaRec;
  1308. BOOLEAN fIsDummy = FALSE;
  1309. DEBUGFUNC("nicRxProcessDataPacket");
  1310. /* DBGLOG(RX, TRACE, ("\n")); */
  1311. ASSERT(prAdapter);
  1312. ASSERT(prSwRfb);
  1313. prHifRxHdr = prSwRfb->prHifRxHdr;
  1314. prRxCtrl = &prAdapter->rRxCtrl;
  1315. fIsDummy = (prHifRxHdr->u2PacketLen >= 12) ? FALSE : TRUE;
  1316. nicRxFillRFB(prAdapter, prSwRfb);
  1317. #if CFG_TCP_IP_CHKSUM_OFFLOAD || CFG_TCP_IP_CHKSUM_OFFLOAD_NDIS_60
  1318. {
  1319. UINT_32 u4TcpUdpIpCksStatus;
  1320. u4TcpUdpIpCksStatus = *((PUINT_32) ((ULONG) prHifRxHdr + (UINT_32) (ALIGN_4(prHifRxHdr->u2PacketLen))));
  1321. nicRxFillChksumStatus(prAdapter, prSwRfb, u4TcpUdpIpCksStatus);
  1322. }
  1323. #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
  1324. prStaRec = cnmGetStaRecByIndex(prAdapter, prHifRxHdr->ucStaRecIdx);
  1325. if (secCheckClassError(prAdapter, prSwRfb, prStaRec) == TRUE && prAdapter->fgTestMode == FALSE) {
  1326. #if CFG_HIF_RX_STARVATION_WARNING
  1327. prRxCtrl->u4QueuedCnt++;
  1328. #endif
  1329. prRetSwRfb = qmHandleRxPackets(prAdapter, prSwRfb);
  1330. if (prRetSwRfb != NULL) {
  1331. do {
  1332. /* save next first */
  1333. prNextSwRfb = (P_SW_RFB_T) QUEUE_GET_NEXT_ENTRY((P_QUE_ENTRY_T) prRetSwRfb);
  1334. if (fIsDummy == TRUE) {
  1335. nicRxReturnRFB(prAdapter, prRetSwRfb);
  1336. RX_INC_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT);
  1337. DBGLOG(RX, WARN, "Drop Dummy Packets");
  1338. } else {
  1339. switch (prRetSwRfb->eDst) {
  1340. case RX_PKT_DESTINATION_HOST:
  1341. #if ARP_MONITER_ENABLE
  1342. if (IS_STA_IN_AIS(prStaRec))
  1343. qmHandleRxArpPackets(prAdapter, prRetSwRfb);
  1344. #endif
  1345. nicRxProcessPktWithoutReorder(prAdapter, prRetSwRfb);
  1346. break;
  1347. case RX_PKT_DESTINATION_FORWARD:
  1348. nicRxProcessForwardPkt(prAdapter, prRetSwRfb);
  1349. break;
  1350. case RX_PKT_DESTINATION_HOST_WITH_FORWARD:
  1351. nicRxProcessGOBroadcastPkt(prAdapter, prRetSwRfb);
  1352. break;
  1353. case RX_PKT_DESTINATION_NULL:
  1354. nicRxReturnRFB(prAdapter, prRetSwRfb);
  1355. RX_INC_CNT(prRxCtrl, RX_DST_NULL_DROP_COUNT);
  1356. RX_INC_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT);
  1357. break;
  1358. default:
  1359. break;
  1360. }
  1361. }
  1362. #if CFG_HIF_RX_STARVATION_WARNING
  1363. prRxCtrl->u4DequeuedCnt++;
  1364. #endif
  1365. prRetSwRfb = prNextSwRfb;
  1366. } while (prRetSwRfb);
  1367. }
  1368. } else {
  1369. nicRxReturnRFB(prAdapter, prSwRfb);
  1370. RX_INC_CNT(prRxCtrl, RX_CLASS_ERR_DROP_COUNT);
  1371. RX_INC_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT);
  1372. }
  1373. }
  1374. /*----------------------------------------------------------------------------*/
  1375. /*!
  1376. * @brief Process HIF event packet
  1377. *
  1378. * @param prAdapter pointer to the Adapter handler
  1379. * @param prSWRfb the RFB to receive rx data
  1380. *
  1381. * @return (none)
  1382. *
  1383. */
  1384. /*----------------------------------------------------------------------------*/
  1385. UINT_8 nicRxProcessGSCNEvent(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  1386. {
  1387. P_WIFI_EVENT_T prEvent;
  1388. P_GLUE_INFO_T prGlueInfo;
  1389. struct sk_buff *skb;
  1390. struct wiphy *wiphy;
  1391. UINT_32 real_num = 0;
  1392. P_EVENT_GSCAN_SCAN_AVAILABLE_T prEventGscnAvailable;
  1393. P_EVENT_GSCAN_RESULT_T prEventBuffer;
  1394. P_WIFI_GSCAN_RESULT_T prEventGscnResult;
  1395. INT_32 i4Status = -EINVAL;
  1396. struct nlattr *attr;
  1397. UINT_32 scan_id;
  1398. UINT_8 scan_flag;
  1399. P_EVENT_GSCAN_CAPABILITY_T prEventGscnCapbiblity;
  1400. P_EVENT_GSCAN_SCAN_COMPLETE_T prEventGscnScnDone;
  1401. P_WIFI_GSCAN_RESULT_T prEventGscnFullResult;
  1402. P_PARAM_WIFI_GSCAN_RESULT prParamGscnFullResult;
  1403. P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T prEventGscnSignificantChange;
  1404. P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T prEventGscnGeofenceFound;
  1405. P_PARAM_WIFI_GSCAN_RESULT prResults;
  1406. DEBUGFUNC("nicRxProcessGSCNEvent");
  1407. /* DBGLOG(RX, TRACE, ("\n")); */
  1408. DBGLOG(SCN, INFO, "nicRxProcessGSCNEvent\n");
  1409. ASSERT(prAdapter);
  1410. ASSERT(prSwRfb);
  1411. prEvent = (P_WIFI_EVENT_T) prSwRfb->pucRecvBuff;
  1412. prGlueInfo = prAdapter->prGlueInfo;
  1413. /* Push the data to the skb */
  1414. wiphy = priv_to_wiphy(prGlueInfo);
  1415. /* prGlueInfo-> */
  1416. /* Event Handling */
  1417. switch (prEvent->ucEID) {
  1418. case EVENT_ID_GSCAN_SCAN_AVAILABLE:
  1419. {
  1420. DBGLOG(SCN, INFO, "EVENT_ID_GSCAN_SCAN_AVAILABLE\n");
  1421. prEventGscnAvailable = (P_EVENT_GSCAN_SCAN_AVAILABLE_T) (prEvent->aucBuffer);
  1422. memcpy(prEventGscnAvailable, (P_EVENT_GSCAN_SCAN_AVAILABLE_T) (prEvent->aucBuffer),
  1423. sizeof(EVENT_GSCAN_SCAN_AVAILABLE_T));
  1424. mtk_cfg80211_vendor_event_scan_results_available(wiphy, prGlueInfo->prDevHandler->ieee80211_ptr,
  1425. prEventGscnAvailable->u2Num);
  1426. }
  1427. break;
  1428. case EVENT_ID_GSCAN_RESULT:
  1429. {
  1430. DBGLOG(SCN, INFO, "EVENT_ID_GSCAN_RESULT 2\n");
  1431. prEventBuffer = (P_EVENT_GSCAN_RESULT_T) (prEvent->aucBuffer);
  1432. prEventGscnResult = prEventBuffer->rResult;
  1433. /*
  1434. the following event struct should moved to kal and use the kal api to avoid future porting effort
  1435. */
  1436. scan_id = prEventBuffer->u2ScanId;
  1437. scan_flag = prEventBuffer->u2ScanFlags;
  1438. real_num = prEventBuffer->u2NumOfResults;
  1439. DBGLOG(SCN, INFO, "scan_id=%d, scan_flag =%d, real_num=%d\r\n", scan_id, scan_flag, real_num);
  1440. skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(PARAM_WIFI_GSCAN_RESULT) * real_num);
  1441. if (!skb) {
  1442. DBGLOG(RX, TRACE, "%s allocate skb failed:%x\n", __func__, i4Status);
  1443. return -ENOMEM;
  1444. }
  1445. attr = nla_nest_start(skb, GSCAN_ATTRIBUTE_SCAN_RESULTS);
  1446. /*NLA_PUT_U32(skb, GSCAN_ATTRIBUTE_SCAN_ID, scan_id);*/
  1447. {
  1448. unsigned int __tmp = scan_id;
  1449. if (unlikely(nla_put(skb, GSCAN_ATTRIBUTE_SCAN_ID, sizeof(unsigned int), &__tmp) < 0))
  1450. goto nla_put_failure;
  1451. }
  1452. /*NLA_PUT_U8(skb, GSCAN_ATTRIBUTE_SCAN_FLAGS, 1);*/
  1453. {
  1454. unsigned char __tmp = 1;
  1455. if (unlikely(nla_put(skb, GSCAN_ATTRIBUTE_SCAN_FLAGS, sizeof(u8), &__tmp) < 0))
  1456. goto nla_put_failure;
  1457. }
  1458. /*NLA_PUT_U32(skb, GSCAN_ATTRIBUTE_NUM_OF_RESULTS, real_num);*/
  1459. {
  1460. unsigned int __tmp = real_num;
  1461. if (unlikely(nla_put(skb, GSCAN_ATTRIBUTE_NUM_OF_RESULTS,
  1462. sizeof(unsigned int), &__tmp) < 0))
  1463. goto nla_put_failure;
  1464. }
  1465. prResults = (P_PARAM_WIFI_GSCAN_RESULT) prEventGscnResult;
  1466. if (prResults)
  1467. DBGLOG(SCN, INFO, "ssid=%s, rssi=%d, channel=%d \r\n",
  1468. prResults->ssid, prResults->rssi, prResults->channel);
  1469. /*NLA_PUT(skb, GSCAN_ATTRIBUTE_SCAN_RESULTS, sizeof(PARAM_WIFI_GSCAN_RESULT) * real_num,
  1470. prResults);*/
  1471. if (unlikely(nla_put(skb, GSCAN_ATTRIBUTE_SCAN_RESULTS,
  1472. sizeof(PARAM_WIFI_GSCAN_RESULT)*real_num, prResults) < 0))
  1473. goto nla_put_failure;
  1474. DBGLOG(SCN, INFO, "NLA_PUT scan results over\t");
  1475. if (attr)
  1476. nla_nest_end(skb, attr);
  1477. /* report_events=1 */
  1478. /*NLA_PUT_U8(skb, GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE, 1);*/
  1479. {
  1480. unsigned char __tmp = 1;
  1481. if (unlikely(nla_put(skb, GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE,
  1482. sizeof(unsigned int), &__tmp) < 0))
  1483. goto nla_put_failure;
  1484. }
  1485. i4Status = cfg80211_vendor_cmd_reply(skb);
  1486. skb = NULL;
  1487. DBGLOG(SCN, INFO, " i4Status %d\n", i4Status);
  1488. }
  1489. break;
  1490. case EVENT_ID_GSCAN_CAPABILITY:
  1491. {
  1492. DBGLOG(SCN, INFO, "EVENT_ID_GSCAN_CAPABILITY\n");
  1493. prEventGscnCapbiblity = (P_EVENT_GSCAN_CAPABILITY_T) (prEvent->aucBuffer);
  1494. memcpy(prEventGscnCapbiblity, (P_EVENT_GSCAN_CAPABILITY_T) (prEvent->aucBuffer),
  1495. sizeof(EVENT_GSCAN_CAPABILITY_T));
  1496. mtk_cfg80211_vendor_get_gscan_capabilities(wiphy, prGlueInfo->prDevHandler->ieee80211_ptr,
  1497. prEventGscnCapbiblity, sizeof(EVENT_GSCAN_CAPABILITY_T));
  1498. }
  1499. break;
  1500. case EVENT_ID_GSCAN_SCAN_COMPLETE:
  1501. {
  1502. DBGLOG(SCN, INFO, "EVENT_ID_GSCAN_SCAN_COMPLETE\n");
  1503. prEventGscnScnDone = (P_EVENT_GSCAN_SCAN_COMPLETE_T) (prEvent->aucBuffer);
  1504. memcpy(prEventGscnScnDone, (P_EVENT_GSCAN_SCAN_COMPLETE_T) (prEvent->aucBuffer),
  1505. sizeof(EVENT_GSCAN_SCAN_COMPLETE_T));
  1506. mtk_cfg80211_vendor_event_complete_scan(wiphy, prGlueInfo->prDevHandler->ieee80211_ptr,
  1507. prEventGscnScnDone->ucScanState);
  1508. }
  1509. break;
  1510. case EVENT_ID_GSCAN_FULL_RESULT:
  1511. {
  1512. DBGLOG(SCN, INFO, "EVENT_ID_GSCAN_FULL_RESULT\n");
  1513. prEventGscnFullResult = kalMemAlloc(sizeof(WIFI_GSCAN_RESULT_T), VIR_MEM_TYPE);
  1514. if (prEventGscnFullResult)
  1515. memcpy(prEventGscnFullResult, (P_WIFI_GSCAN_RESULT_T) (prEvent->aucBuffer),
  1516. sizeof(WIFI_GSCAN_RESULT_T));
  1517. prParamGscnFullResult = kalMemAlloc(sizeof(PARAM_WIFI_GSCAN_RESULT), VIR_MEM_TYPE);
  1518. if (prEventGscnFullResult && prParamGscnFullResult) {
  1519. kalMemZero(prParamGscnFullResult, sizeof(PARAM_WIFI_GSCAN_RESULT));
  1520. memcpy(prParamGscnFullResult, prEventGscnFullResult, sizeof(WIFI_GSCAN_RESULT_T));
  1521. mtk_cfg80211_vendor_event_full_scan_results(wiphy,
  1522. prGlueInfo->prDevHandler->ieee80211_ptr,
  1523. prParamGscnFullResult,
  1524. sizeof(PARAM_WIFI_GSCAN_RESULT));
  1525. }
  1526. }
  1527. break;
  1528. case EVENT_ID_GSCAN_SIGNIFICANT_CHANGE:
  1529. {
  1530. prEventGscnSignificantChange = (P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T) (prEvent->aucBuffer);
  1531. memcpy(prEventGscnSignificantChange, (P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T) (prEvent->aucBuffer),
  1532. sizeof(EVENT_GSCAN_SIGNIFICANT_CHANGE_T));
  1533. }
  1534. break;
  1535. case EVENT_ID_GSCAN_GEOFENCE_FOUND:
  1536. {
  1537. prEventGscnGeofenceFound = (P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T) (prEvent->aucBuffer);
  1538. memcpy(prEventGscnGeofenceFound, (P_EVENT_GSCAN_SIGNIFICANT_CHANGE_T) (prEvent->aucBuffer),
  1539. sizeof(EVENT_GSCAN_SIGNIFICANT_CHANGE_T));
  1540. }
  1541. break;
  1542. default:
  1543. DBGLOG(SCN, INFO, "not GSCN event ????\n");
  1544. break;
  1545. }
  1546. DBGLOG(SCN, INFO, "Done with GSCN event handling\n");
  1547. return real_num; /* cfg80211_vendor_cmd_reply(skb); */
  1548. nla_put_failure:
  1549. if (skb != NULL)
  1550. kfree_skb(skb);
  1551. DBGLOG(SCN, INFO, "nla_put_failure\n");
  1552. return 0; /* cfg80211_vendor_cmd_reply(skb); */
  1553. }
  1554. /*----------------------------------------------------------------------------*/
  1555. /*!
  1556. * @brief Process HIF event packet
  1557. *
  1558. * @param prAdapter pointer to the Adapter handler
  1559. * @param prSWRfb the RFB to receive rx data
  1560. *
  1561. * @return (none)
  1562. *
  1563. */
  1564. /*----------------------------------------------------------------------------*/
  1565. VOID nicRxProcessEventPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  1566. {
  1567. P_CMD_INFO_T prCmdInfo;
  1568. P_MSDU_INFO_T prMsduInfo;
  1569. P_WIFI_EVENT_T prEvent;
  1570. P_GLUE_INFO_T prGlueInfo;
  1571. /*BOOLEAN fgKeepprSwRfb = FALSE;*/
  1572. DEBUGFUNC("nicRxProcessEventPacket");
  1573. /* DBGLOG(RX, TRACE, ("\n")); */
  1574. ASSERT(prAdapter);
  1575. ASSERT(prSwRfb);
  1576. prEvent = (P_WIFI_EVENT_T) prSwRfb->pucRecvBuff;
  1577. prGlueInfo = prAdapter->prGlueInfo;
  1578. DBGLOG(RX, EVENT, "prEvent->ucEID = 0x%02x\n", prEvent->ucEID);
  1579. /* Event Handling */
  1580. switch (prEvent->ucEID) {
  1581. case EVENT_ID_CMD_RESULT:
  1582. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  1583. if (prCmdInfo != NULL) {
  1584. P_EVENT_CMD_RESULT prCmdResult;
  1585. prCmdResult = (P_EVENT_CMD_RESULT) ((PUINT_8) prEvent + EVENT_HDR_SIZE);
  1586. /* CMD_RESULT should be only in response to Set commands */
  1587. ASSERT(prCmdInfo->fgSetQuery == FALSE || prCmdInfo->fgNeedResp == TRUE);
  1588. if (prCmdResult->ucStatus == 0) { /* success */
  1589. if (prCmdInfo->pfCmdDoneHandler) {
  1590. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  1591. } else if (prCmdInfo->fgIsOid == TRUE) {
  1592. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0,
  1593. WLAN_STATUS_SUCCESS);
  1594. }
  1595. } else if (prCmdResult->ucStatus == 1) { /* reject */
  1596. if (prCmdInfo->fgIsOid == TRUE)
  1597. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0,
  1598. WLAN_STATUS_FAILURE);
  1599. } else if (prCmdResult->ucStatus == 2) { /* unknown CMD */
  1600. if (prCmdInfo->fgIsOid == TRUE)
  1601. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0,
  1602. WLAN_STATUS_NOT_SUPPORTED);
  1603. }
  1604. /* return prCmdInfo */
  1605. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1606. }
  1607. break;
  1608. #if 0
  1609. case EVENT_ID_CONNECTION_STATUS:
  1610. /* OBSELETE */
  1611. {
  1612. P_EVENT_CONNECTION_STATUS prConnectionStatus;
  1613. prConnectionStatus = (P_EVENT_CONNECTION_STATUS) (prEvent->aucBuffer);
  1614. DbgPrint("RX EVENT: EVENT_ID_CONNECTION_STATUS = %d\n", prConnectionStatus->ucMediaStatus);
  1615. if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_DISCONNECTED) {
  1616. /* disconnected */
  1617. if (kalGetMediaStateIndicated(prGlueInfo) != PARAM_MEDIA_STATE_DISCONNECTED) {
  1618. kalIndicateStatusAndComplete(prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  1619. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  1620. }
  1621. } else if (prConnectionStatus->ucMediaStatus == PARAM_MEDIA_STATE_CONNECTED) {
  1622. /* connected */
  1623. prAdapter->rWlanInfo.u4SysTime = kalGetTimeTick();
  1624. /* fill information for association result */
  1625. prAdapter->rWlanInfo.rCurrBssId.rSsid.u4SsidLen = prConnectionStatus->ucSsidLen;
  1626. kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.rSsid.aucSsid,
  1627. prConnectionStatus->aucSsid, prConnectionStatus->ucSsidLen);
  1628. kalMemCopy(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
  1629. prConnectionStatus->aucBssid, MAC_ADDR_LEN);
  1630. /* @FIXME */
  1631. prAdapter->rWlanInfo.rCurrBssId.u4Privacy = prConnectionStatus->ucEncryptStatus;
  1632. prAdapter->rWlanInfo.rCurrBssId.rRssi = 0; /* @FIXME */
  1633. /* @FIXME */
  1634. prAdapter->rWlanInfo.rCurrBssId.eNetworkTypeInUse = PARAM_NETWORK_TYPE_AUTOMODE;
  1635. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4BeaconPeriod
  1636. = prConnectionStatus->u2BeaconPeriod;
  1637. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4ATIMWindow
  1638. = prConnectionStatus->u2ATIMWindow;
  1639. prAdapter->rWlanInfo.rCurrBssId.rConfiguration.u4DSConfig
  1640. = prConnectionStatus->u4FreqInKHz;
  1641. prAdapter->rWlanInfo.ucNetworkType = prConnectionStatus->ucNetworkType;
  1642. switch (prConnectionStatus->ucInfraMode) {
  1643. case 0:
  1644. prAdapter->rWlanInfo.rCurrBssId.eOpMode = NET_TYPE_IBSS;
  1645. break;
  1646. case 1:
  1647. prAdapter->rWlanInfo.rCurrBssId.eOpMode = NET_TYPE_INFRA;
  1648. break;
  1649. case 2:
  1650. default:
  1651. prAdapter->rWlanInfo.rCurrBssId.eOpMode = NET_TYPE_AUTO_SWITCH;
  1652. break;
  1653. }
  1654. /* always indicate to OS according to MSDN (re-association/roaming) */
  1655. kalIndicateStatusAndComplete(prGlueInfo, WLAN_STATUS_MEDIA_CONNECT, NULL, 0);
  1656. }
  1657. }
  1658. break;
  1659. case EVENT_ID_SCAN_RESULT:
  1660. /* OBSELETE */
  1661. break;
  1662. #endif
  1663. case EVENT_ID_RX_ADDBA:
  1664. /* The FW indicates that an RX BA agreement will be established */
  1665. qmHandleEventRxAddBa(prAdapter, prEvent);
  1666. break;
  1667. case EVENT_ID_RX_DELBA:
  1668. /* The FW indicates that an RX BA agreement has been deleted */
  1669. qmHandleEventRxDelBa(prAdapter, prEvent);
  1670. break;
  1671. case EVENT_ID_LINK_QUALITY:
  1672. #if CFG_ENABLE_WIFI_DIRECT && CFG_SUPPORT_P2P_RSSI_QUERY
  1673. if (prEvent->u2PacketLen == EVENT_HDR_SIZE + sizeof(EVENT_LINK_QUALITY_EX)) {
  1674. P_EVENT_LINK_QUALITY_EX prLqEx = (P_EVENT_LINK_QUALITY_EX) (prEvent->aucBuffer);
  1675. if (prLqEx->ucIsLQ0Rdy)
  1676. nicUpdateLinkQuality(prAdapter, NETWORK_TYPE_AIS_INDEX, (P_EVENT_LINK_QUALITY) prLqEx);
  1677. if (prLqEx->ucIsLQ1Rdy)
  1678. nicUpdateLinkQuality(prAdapter, NETWORK_TYPE_P2P_INDEX, (P_EVENT_LINK_QUALITY) prLqEx);
  1679. } else {
  1680. /* For old FW, P2P may invoke link quality query, and make driver flag becone TRUE. */
  1681. DBGLOG(P2P, WARN, "Old FW version, not support P2P RSSI query.\n");
  1682. /* Must not use NETWORK_TYPE_P2P_INDEX, cause the structure is mismatch. */
  1683. nicUpdateLinkQuality(prAdapter, NETWORK_TYPE_AIS_INDEX,
  1684. (P_EVENT_LINK_QUALITY) (prEvent->aucBuffer));
  1685. }
  1686. #else
  1687. nicUpdateLinkQuality(prAdapter, NETWORK_TYPE_AIS_INDEX, (P_EVENT_LINK_QUALITY) (prEvent->aucBuffer));
  1688. #endif
  1689. /* command response handling */
  1690. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  1691. if (prCmdInfo != NULL) {
  1692. if (prCmdInfo->pfCmdDoneHandler)
  1693. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  1694. else if (prCmdInfo->fgIsOid)
  1695. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  1696. /* return prCmdInfo */
  1697. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1698. }
  1699. #ifndef LINUX
  1700. if (prAdapter->rWlanInfo.eRssiTriggerType == ENUM_RSSI_TRIGGER_GREATER &&
  1701. prAdapter->rWlanInfo.rRssiTriggerValue >= (PARAM_RSSI) (prAdapter->rLinkQuality.cRssi)) {
  1702. prAdapter->rWlanInfo.eRssiTriggerType = ENUM_RSSI_TRIGGER_TRIGGERED;
  1703. kalIndicateStatusAndComplete(prGlueInfo,
  1704. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  1705. (PVOID)&(prAdapter->rWlanInfo.rRssiTriggerValue),
  1706. sizeof(PARAM_RSSI));
  1707. } else if (prAdapter->rWlanInfo.eRssiTriggerType == ENUM_RSSI_TRIGGER_LESS
  1708. && prAdapter->rWlanInfo.rRssiTriggerValue <= (PARAM_RSSI) (prAdapter->rLinkQuality.cRssi)) {
  1709. prAdapter->rWlanInfo.eRssiTriggerType = ENUM_RSSI_TRIGGER_TRIGGERED;
  1710. kalIndicateStatusAndComplete(prGlueInfo,
  1711. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  1712. (PVOID)&(prAdapter->rWlanInfo.rRssiTriggerValue),
  1713. sizeof(PARAM_RSSI));
  1714. }
  1715. #endif
  1716. break;
  1717. case EVENT_ID_MIC_ERR_INFO:
  1718. {
  1719. P_EVENT_MIC_ERR_INFO prMicError;
  1720. /* P_PARAM_AUTH_EVENT_T prAuthEvent; */
  1721. P_STA_RECORD_T prStaRec;
  1722. DBGLOG(RSN, EVENT, "EVENT_ID_MIC_ERR_INFO\n");
  1723. prMicError = (P_EVENT_MIC_ERR_INFO) (prEvent->aucBuffer);
  1724. prStaRec = cnmGetStaRecByAddress(prAdapter,
  1725. (UINT_8) NETWORK_TYPE_AIS_INDEX,
  1726. prAdapter->rWlanInfo.rCurrBssId.arMacAddress);
  1727. ASSERT(prStaRec);
  1728. if (prStaRec)
  1729. rsnTkipHandleMICFailure(prAdapter, prStaRec, (BOOLEAN) prMicError->u4Flags);
  1730. else
  1731. DBGLOG(RSN, WARN, "No STA rec!!\n");
  1732. #if 0
  1733. prAuthEvent = (P_PARAM_AUTH_EVENT_T) prAdapter->aucIndicationEventBuffer;
  1734. /* Status type: Authentication Event */
  1735. prAuthEvent->rStatus.eStatusType = ENUM_STATUS_TYPE_AUTHENTICATION;
  1736. /* Authentication request */
  1737. prAuthEvent->arRequest[0].u4Length = sizeof(PARAM_AUTH_REQUEST_T);
  1738. kalMemCopy((PVOID) prAuthEvent->arRequest[0].arBssid,
  1739. (PVOID) prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
  1740. /* whsu:Todo? */PARAM_MAC_ADDR_LEN);
  1741. if (prMicError->u4Flags != 0)
  1742. prAuthEvent->arRequest[0].u4Flags = PARAM_AUTH_REQUEST_GROUP_ERROR;
  1743. else
  1744. prAuthEvent->arRequest[0].u4Flags = PARAM_AUTH_REQUEST_PAIRWISE_ERROR;
  1745. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  1746. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  1747. (PVOID) prAuthEvent,
  1748. sizeof(PARAM_STATUS_INDICATION_T) + sizeof(PARAM_AUTH_REQUEST_T));
  1749. #endif
  1750. }
  1751. break;
  1752. case EVENT_ID_ASSOC_INFO:
  1753. {
  1754. P_EVENT_ASSOC_INFO prAssocInfo;
  1755. prAssocInfo = (P_EVENT_ASSOC_INFO) (prEvent->aucBuffer);
  1756. kalHandleAssocInfo(prAdapter->prGlueInfo, prAssocInfo);
  1757. }
  1758. break;
  1759. case EVENT_ID_802_11_PMKID:
  1760. {
  1761. P_PARAM_AUTH_EVENT_T prAuthEvent;
  1762. PUINT_8 cp;
  1763. UINT_32 u4LenOfUsedBuffer;
  1764. prAuthEvent = (P_PARAM_AUTH_EVENT_T) prAdapter->aucIndicationEventBuffer;
  1765. prAuthEvent->rStatus.eStatusType = ENUM_STATUS_TYPE_CANDIDATE_LIST;
  1766. u4LenOfUsedBuffer = (UINT_32) (prEvent->u2PacketLen - 8);
  1767. prAuthEvent->arRequest[0].u4Length = u4LenOfUsedBuffer;
  1768. cp = (PUINT_8) &prAuthEvent->arRequest[0];
  1769. /* Status type: PMKID Candidatelist Event */
  1770. kalMemCopy(cp, (P_EVENT_PMKID_CANDIDATE_LIST_T) (prEvent->aucBuffer), prEvent->u2PacketLen - 8);
  1771. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  1772. WLAN_STATUS_MEDIA_SPECIFIC_INDICATION,
  1773. (PVOID) prAuthEvent,
  1774. sizeof(PARAM_STATUS_INDICATION_T) + u4LenOfUsedBuffer);
  1775. }
  1776. break;
  1777. #if 0
  1778. case EVENT_ID_ACTIVATE_STA_REC_T:
  1779. {
  1780. P_EVENT_ACTIVATE_STA_REC_T prActivateStaRec;
  1781. prActivateStaRec = (P_EVENT_ACTIVATE_STA_REC_T) (prEvent->aucBuffer);
  1782. DbgPrint("RX EVENT: EVENT_ID_ACTIVATE_STA_REC_T Index:%d, MAC:[%pM]\n",
  1783. prActivateStaRec->ucStaRecIdx, prActivateStaRec->aucMacAddr);
  1784. qmActivateStaRec(prAdapter,
  1785. (UINT_32) prActivateStaRec->ucStaRecIdx,
  1786. ((prActivateStaRec->fgIsQoS) ? TRUE : FALSE),
  1787. prActivateStaRec->ucNetworkTypeIndex,
  1788. ((prActivateStaRec->fgIsAP) ? TRUE : FALSE), prActivateStaRec->aucMacAddr);
  1789. }
  1790. break;
  1791. case EVENT_ID_DEACTIVATE_STA_REC_T:
  1792. {
  1793. P_EVENT_DEACTIVATE_STA_REC_T prDeactivateStaRec;
  1794. prDeactivateStaRec = (P_EVENT_DEACTIVATE_STA_REC_T) (prEvent->aucBuffer);
  1795. DbgPrint("RX EVENT: EVENT_ID_DEACTIVATE_STA_REC_T Index:%d, MAC:[%pM]\n",
  1796. prDeactivateStaRec->ucStaRecIdx, prActivateStaRec->aucMacAddr);
  1797. qmDeactivateStaRec(prAdapter, prDeactivateStaRec->ucStaRecIdx);
  1798. }
  1799. break;
  1800. #endif
  1801. case EVENT_ID_SCAN_DONE:
  1802. scnEventScanDone(prAdapter, (P_EVENT_SCAN_DONE) (prEvent->aucBuffer));
  1803. break;
  1804. case EVENT_ID_TX_DONE_STATUS:
  1805. STATS_TX_PKT_DONE_INFO_DISPLAY(prAdapter, prEvent->aucBuffer);
  1806. break;
  1807. case EVENT_ID_TX_DONE:
  1808. {
  1809. P_EVENT_TX_DONE_T prTxDone;
  1810. prTxDone = (P_EVENT_TX_DONE_T) (prEvent->aucBuffer);
  1811. if (prTxDone->ucStatus)
  1812. DBGLOG(RX, INFO, "EVENT_ID_TX_DONE PacketSeq:%u ucStatus: %u SN: %u\n",
  1813. prTxDone->ucPacketSeq, prTxDone->ucStatus, prTxDone->u2SequenceNumber);
  1814. /* call related TX Done Handler */
  1815. prMsduInfo = nicGetPendingTxMsduInfo(prAdapter, prTxDone->ucPacketSeq);
  1816. #if CFG_SUPPORT_802_11V_TIMING_MEASUREMENT
  1817. DBGLOG(RX, TRACE, "EVENT_ID_TX_DONE u4TimeStamp = %x u2AirDelay = %x\n",
  1818. prTxDone->au4Reserved1, prTxDone->au4Reserved2);
  1819. wnmReportTimingMeas(prAdapter, prMsduInfo->ucStaRecIndex,
  1820. prTxDone->au4Reserved1, prTxDone->au4Reserved1 + prTxDone->au4Reserved2);
  1821. #endif
  1822. if (prMsduInfo) {
  1823. prMsduInfo->pfTxDoneHandler(prAdapter, prMsduInfo,
  1824. (ENUM_TX_RESULT_CODE_T) (prTxDone->ucStatus));
  1825. cnmMgtPktFree(prAdapter, prMsduInfo);
  1826. }
  1827. }
  1828. break;
  1829. case EVENT_ID_SLEEPY_NOTIFY:
  1830. {
  1831. P_EVENT_SLEEPY_NOTIFY prEventSleepyNotify;
  1832. prEventSleepyNotify = (P_EVENT_SLEEPY_NOTIFY) (prEvent->aucBuffer);
  1833. /* DBGLOG(RX, INFO, ("ucSleepyState = %d\n", prEventSleepyNotify->ucSleepyState)); */
  1834. prAdapter->fgWiFiInSleepyState = (BOOLEAN) (prEventSleepyNotify->ucSleepyState);
  1835. }
  1836. break;
  1837. case EVENT_ID_BT_OVER_WIFI:
  1838. #if CFG_ENABLE_BT_OVER_WIFI
  1839. {
  1840. UINT_8 aucTmp[sizeof(AMPC_EVENT) + sizeof(BOW_LINK_DISCONNECTED)];
  1841. P_EVENT_BT_OVER_WIFI prEventBtOverWifi;
  1842. P_AMPC_EVENT prBowEvent;
  1843. P_BOW_LINK_CONNECTED prBowLinkConnected;
  1844. P_BOW_LINK_DISCONNECTED prBowLinkDisconnected;
  1845. prEventBtOverWifi = (P_EVENT_BT_OVER_WIFI) (prEvent->aucBuffer);
  1846. /* construct event header */
  1847. prBowEvent = (P_AMPC_EVENT) aucTmp;
  1848. if (prEventBtOverWifi->ucLinkStatus == 0) {
  1849. /* Connection */
  1850. prBowEvent->rHeader.ucEventId = BOW_EVENT_ID_LINK_CONNECTED;
  1851. prBowEvent->rHeader.ucSeqNumber = 0;
  1852. prBowEvent->rHeader.u2PayloadLength = sizeof(BOW_LINK_CONNECTED);
  1853. /* fill event body */
  1854. prBowLinkConnected = (P_BOW_LINK_CONNECTED) (prBowEvent->aucPayload);
  1855. prBowLinkConnected->rChannel.ucChannelNum = prEventBtOverWifi->ucSelectedChannel;
  1856. kalMemZero(prBowLinkConnected->aucPeerAddress, MAC_ADDR_LEN); /* @FIXME */
  1857. kalIndicateBOWEvent(prAdapter->prGlueInfo, prBowEvent);
  1858. } else {
  1859. /* Disconnection */
  1860. prBowEvent->rHeader.ucEventId = BOW_EVENT_ID_LINK_DISCONNECTED;
  1861. prBowEvent->rHeader.ucSeqNumber = 0;
  1862. prBowEvent->rHeader.u2PayloadLength = sizeof(BOW_LINK_DISCONNECTED);
  1863. /* fill event body */
  1864. prBowLinkDisconnected = (P_BOW_LINK_DISCONNECTED) (prBowEvent->aucPayload);
  1865. prBowLinkDisconnected->ucReason = 0; /* @FIXME */
  1866. kalMemZero(prBowLinkDisconnected->aucPeerAddress, MAC_ADDR_LEN); /* @FIXME */
  1867. kalIndicateBOWEvent(prAdapter->prGlueInfo, prBowEvent);
  1868. }
  1869. }
  1870. break;
  1871. #endif
  1872. case EVENT_ID_STATISTICS:
  1873. /* buffer statistics for further query */
  1874. prAdapter->fgIsStatValid = TRUE;
  1875. prAdapter->rStatUpdateTime = kalGetTimeTick();
  1876. kalMemCopy(&prAdapter->rStatStruct, prEvent->aucBuffer, sizeof(EVENT_STATISTICS));
  1877. /* command response handling */
  1878. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  1879. if (prCmdInfo != NULL) {
  1880. if (prCmdInfo->pfCmdDoneHandler)
  1881. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  1882. else if (prCmdInfo->fgIsOid)
  1883. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  1884. /* return prCmdInfo */
  1885. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1886. }
  1887. break;
  1888. case EVENT_ID_CH_PRIVILEGE:
  1889. cnmChMngrHandleChEvent(prAdapter, prEvent);
  1890. break;
  1891. case EVENT_ID_BSS_ABSENCE_PRESENCE:
  1892. qmHandleEventBssAbsencePresence(prAdapter, prEvent);
  1893. break;
  1894. case EVENT_ID_STA_CHANGE_PS_MODE:
  1895. qmHandleEventStaChangePsMode(prAdapter, prEvent);
  1896. break;
  1897. #if CFG_ENABLE_WIFI_DIRECT
  1898. case EVENT_ID_STA_UPDATE_FREE_QUOTA:
  1899. qmHandleEventStaUpdateFreeQuota(prAdapter, prEvent);
  1900. break;
  1901. #endif
  1902. case EVENT_ID_BSS_BEACON_TIMEOUT:
  1903. if (prAdapter->fgDisBcnLostDetection == FALSE) {
  1904. P_EVENT_BSS_BEACON_TIMEOUT_T prEventBssBeaconTimeout;
  1905. prEventBssBeaconTimeout = (P_EVENT_BSS_BEACON_TIMEOUT_T) (prEvent->aucBuffer);
  1906. DBGLOG(RX, INFO, "Beacon Timeout Reason = %u\n", prEventBssBeaconTimeout->ucReason);
  1907. if (prEventBssBeaconTimeout->ucNetTypeIndex == NETWORK_TYPE_AIS_INDEX) {
  1908. /* Request stats report before beacon timeout */
  1909. P_BSS_INFO_T prBssInfo;
  1910. P_STA_RECORD_T prStaRec;
  1911. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[NETWORK_TYPE_AIS_INDEX]);
  1912. if (prBssInfo) {
  1913. prStaRec = cnmGetStaRecByAddress(prAdapter,
  1914. NETWORK_TYPE_AIS_INDEX,
  1915. prBssInfo->aucBSSID);
  1916. if (prStaRec)
  1917. STATS_ENV_REPORT_DETECT(prAdapter, prStaRec->ucIndex);
  1918. }
  1919. aisBssBeaconTimeout(prAdapter);
  1920. }
  1921. #if CFG_ENABLE_WIFI_DIRECT
  1922. else if ((prAdapter->fgIsP2PRegistered) &&
  1923. (prEventBssBeaconTimeout->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX))
  1924. p2pFsmRunEventBeaconTimeout(prAdapter);
  1925. #endif
  1926. else {
  1927. DBGLOG(RX, ERROR, "EVENT_ID_BSS_BEACON_TIMEOUT: (ucNetTypeIdx = %d)\n",
  1928. prEventBssBeaconTimeout->ucNetTypeIndex);
  1929. }
  1930. }
  1931. break;
  1932. case EVENT_ID_UPDATE_NOA_PARAMS:
  1933. #if CFG_ENABLE_WIFI_DIRECT
  1934. if (prAdapter->fgIsP2PRegistered) {
  1935. P_EVENT_UPDATE_NOA_PARAMS_T prEventUpdateNoaParam;
  1936. prEventUpdateNoaParam = (P_EVENT_UPDATE_NOA_PARAMS_T) (prEvent->aucBuffer);
  1937. if (prEventUpdateNoaParam->ucNetTypeIndex == NETWORK_TYPE_P2P_INDEX) {
  1938. p2pProcessEvent_UpdateNOAParam(prAdapter,
  1939. prEventUpdateNoaParam->ucNetTypeIndex,
  1940. prEventUpdateNoaParam);
  1941. } else {
  1942. ASSERT(0);
  1943. }
  1944. }
  1945. #else
  1946. ASSERT(0);
  1947. #endif
  1948. break;
  1949. case EVENT_ID_STA_AGING_TIMEOUT:
  1950. #if CFG_ENABLE_WIFI_DIRECT
  1951. {
  1952. if (prAdapter->fgDisStaAgingTimeoutDetection == FALSE) {
  1953. P_EVENT_STA_AGING_TIMEOUT_T prEventStaAgingTimeout;
  1954. P_STA_RECORD_T prStaRec;
  1955. P_BSS_INFO_T prBssInfo = (P_BSS_INFO_T) NULL;
  1956. prEventStaAgingTimeout = (P_EVENT_STA_AGING_TIMEOUT_T) (prEvent->aucBuffer);
  1957. prStaRec = cnmGetStaRecByIndex(prAdapter, prEventStaAgingTimeout->ucStaRecIdx);
  1958. if (prStaRec == NULL)
  1959. break;
  1960. DBGLOG(RX, INFO, "EVENT_ID_STA_AGING_TIMEOUT %u %pM\n",
  1961. prEventStaAgingTimeout->ucStaRecIdx,
  1962. prStaRec->aucMacAddr);
  1963. prBssInfo = &(prAdapter->rWifiVar.arBssInfo[prStaRec->ucNetTypeIndex]);
  1964. bssRemoveStaRecFromClientList(prAdapter, prBssInfo, prStaRec);
  1965. /* Call False Auth */
  1966. if (prAdapter->fgIsP2PRegistered)
  1967. p2pFuncDisconnect(prAdapter, prStaRec, TRUE, REASON_CODE_DISASSOC_INACTIVITY);
  1968. }
  1969. /* gDisStaAgingTimeoutDetection */
  1970. }
  1971. #endif
  1972. break;
  1973. case EVENT_ID_AP_OBSS_STATUS:
  1974. #if CFG_ENABLE_WIFI_DIRECT
  1975. if (prAdapter->fgIsP2PRegistered)
  1976. rlmHandleObssStatusEventPkt(prAdapter, (P_EVENT_AP_OBSS_STATUS_T) prEvent->aucBuffer);
  1977. #endif
  1978. break;
  1979. case EVENT_ID_ROAMING_STATUS:
  1980. #if CFG_SUPPORT_ROAMING
  1981. {
  1982. P_ROAMING_PARAM_T prParam;
  1983. prParam = (P_ROAMING_PARAM_T) (prEvent->aucBuffer);
  1984. roamingFsmProcessEvent(prAdapter, prParam);
  1985. }
  1986. #endif /* CFG_SUPPORT_ROAMING */
  1987. break;
  1988. case EVENT_ID_SEND_DEAUTH:
  1989. {
  1990. P_WLAN_MAC_HEADER_T prWlanMacHeader;
  1991. P_STA_RECORD_T prStaRec;
  1992. prWlanMacHeader = (P_WLAN_MAC_HEADER_T) &prEvent->aucBuffer[0];
  1993. DBGLOG(RSN, INFO, "nicRx: aucAddr1: %pM, nicRx: aucAddr2: %pM\n",
  1994. prWlanMacHeader->aucAddr1, prWlanMacHeader->aucAddr2);
  1995. prStaRec = cnmGetStaRecByAddress(prAdapter, NETWORK_TYPE_AIS_INDEX, prWlanMacHeader->aucAddr2);
  1996. if (prStaRec != NULL && prStaRec->ucStaState == STA_STATE_3) {
  1997. DBGLOG(RSN, WARN, "Ignore Deauth for Rx Class 3 error!\n");
  1998. } else {
  1999. /* receive packets without StaRec */
  2000. prSwRfb->pvHeader = (P_WLAN_MAC_HEADER_T) &prEvent->aucBuffer[0];
  2001. if (WLAN_STATUS_SUCCESS == authSendDeauthFrame(prAdapter,
  2002. NULL,
  2003. prSwRfb,
  2004. REASON_CODE_CLASS_3_ERR,
  2005. (PFN_TX_DONE_HANDLER) NULL))
  2006. DBGLOG(RSN, INFO, "Send Deauth for Rx Class3 Error\n");
  2007. else
  2008. DBGLOG(RSN, WARN, "failed to send deauth for Rx class3 error\n");
  2009. }
  2010. }
  2011. break;
  2012. #if CFG_SUPPORT_RDD_TEST_MODE
  2013. case EVENT_ID_UPDATE_RDD_STATUS:
  2014. {
  2015. P_EVENT_RDD_STATUS_T prEventRddStatus;
  2016. prEventRddStatus = (P_EVENT_RDD_STATUS_T) (prEvent->aucBuffer);
  2017. prAdapter->ucRddStatus = prEventRddStatus->ucRddStatus;
  2018. }
  2019. break;
  2020. #endif
  2021. #if CFG_SUPPORT_BCM && CFG_SUPPORT_BCM_BWCS
  2022. case EVENT_ID_UPDATE_BWCS_STATUS:
  2023. {
  2024. P_PTA_IPC_T prEventBwcsStatus;
  2025. prEventBwcsStatus = (P_PTA_IPC_T) (prEvent->aucBuffer);
  2026. #if CFG_SUPPORT_BCM_BWCS_DEBUG
  2027. DBGLOG(RSN, INFO,
  2028. "BCM BWCS Event: %02x%02x%02x%02x\n",
  2029. prEventBwcsStatus->u.aucBTPParams[0], prEventBwcsStatus->u.aucBTPParams[1],
  2030. prEventBwcsStatus->u.aucBTPParams[2], prEventBwcsStatus->u.aucBTPParams[3]);
  2031. DBGLOG(RSN, INFO,
  2032. "BCM BWCS Event: BTPParams[0]:%02x, BTPParams[1]:%02x, BTPParams[2]:%02x, BTPParams[3]:%02x\n",
  2033. prEventBwcsStatus->u.aucBTPParams[0], prEventBwcsStatus->u.aucBTPParams[1],
  2034. prEventBwcsStatus->u.aucBTPParams[2], prEventBwcsStatus->u.aucBTPParams[3]);
  2035. #endif
  2036. kalIndicateStatusAndComplete(prAdapter->prGlueInfo,
  2037. WLAN_STATUS_BWCS_UPDATE,
  2038. (PVOID) prEventBwcsStatus, sizeof(PTA_IPC_T));
  2039. }
  2040. break;
  2041. case EVENT_ID_UPDATE_BCM_DEBUG:
  2042. {
  2043. P_PTA_IPC_T prEventBwcsStatus;
  2044. prEventBwcsStatus = (P_PTA_IPC_T) (prEvent->aucBuffer);
  2045. #if CFG_SUPPORT_BCM_BWCS_DEBUG
  2046. DBGLOG(RSN, INFO,
  2047. "BCM FW status: %02x%02x%02x%02x\n",
  2048. prEventBwcsStatus->u.aucBTPParams[0], prEventBwcsStatus->u.aucBTPParams[1],
  2049. prEventBwcsStatus->u.aucBTPParams[2], prEventBwcsStatus->u.aucBTPParams[3]);
  2050. DBGLOG(RSN, INFO,
  2051. "BCM FW status: BTPParams[0]:%02x, BTPParams[1]:%02x, BTPParams[2]:%02x, BTPParams[3]:%02x\n",
  2052. prEventBwcsStatus->u.aucBTPParams[0], prEventBwcsStatus->u.aucBTPParams[1],
  2053. prEventBwcsStatus->u.aucBTPParams[2], prEventBwcsStatus->u.aucBTPParams[3];
  2054. #endif
  2055. }
  2056. break;
  2057. #endif
  2058. case EVENT_ID_DEBUG_CODE: /* only for debug */
  2059. {
  2060. UINT_32 u4CodeId;
  2061. DBGLOG(RSN, INFO, "[wlan-fw] function sequence: ");
  2062. for (u4CodeId = 0; u4CodeId < 1000; u4CodeId++)
  2063. DBGLOG(RSN, INFO, "%d ", prEvent->aucBuffer[u4CodeId]);
  2064. DBGLOG(RSN, INFO, "\n\n");
  2065. }
  2066. break;
  2067. case EVENT_ID_RFTEST_READY:
  2068. /* command response handling */
  2069. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  2070. if (prCmdInfo != NULL) {
  2071. if (prCmdInfo->pfCmdDoneHandler)
  2072. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  2073. else if (prCmdInfo->fgIsOid)
  2074. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  2075. /* return prCmdInfo */
  2076. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2077. }
  2078. break;
  2079. case EVENT_ID_GSCAN_SCAN_AVAILABLE:
  2080. case EVENT_ID_GSCAN_CAPABILITY:
  2081. case EVENT_ID_GSCAN_SCAN_COMPLETE:
  2082. case EVENT_ID_GSCAN_FULL_RESULT:
  2083. case EVENT_ID_GSCAN_SIGNIFICANT_CHANGE:
  2084. case EVENT_ID_GSCAN_GEOFENCE_FOUND:
  2085. nicRxProcessGSCNEvent(prAdapter, prSwRfb);
  2086. break;
  2087. case EVENT_ID_GSCAN_RESULT:
  2088. {
  2089. UINT_8 realnum = 0;
  2090. DBGLOG(SCN, TRACE, "nicRxProcessGSCNEvent ----->\n");
  2091. realnum = nicRxProcessGSCNEvent(prAdapter, prSwRfb);
  2092. DBGLOG(SCN, TRACE, "nicRxProcessGSCNEvent <-----\n");
  2093. #if 0 /* workaround for FW events cnt mis-match with the actual reqirements from wifi_hal */
  2094. if (g_GetResultsCmdCnt == 0) {
  2095. DBGLOG(SCN, INFO,
  2096. "FW report events more than the wifi_hal asked number, buffer the results\n");
  2097. UINT_8 i = 0;
  2098. for (i = 0; i < MAX_BUFFERED_GSCN_RESULTS; i++) {
  2099. #if 1
  2100. if (!g_arGscanResultsIndicateNumber[i]) {
  2101. DBGLOG(SCN, INFO,
  2102. "found available index %d to insert results number %d into buffer\r\n",
  2103. i, realnum);
  2104. g_arGscnResultsTempBuffer[i] = prSwRfb;
  2105. g_arGscanResultsIndicateNumber[i] = realnum;
  2106. g_GetResultsBufferedCnt++;
  2107. fgKeepprSwRfb = TRUE;
  2108. DBGLOG(SCN, INFO, "results buffered in index[%d] \r\n", i);
  2109. break;
  2110. }
  2111. #endif
  2112. }
  2113. if (i == MAX_BUFFERED_GSCN_RESULTS)
  2114. DBGLOG(SCN, INFO,
  2115. "Gscn results buffer is full(all valid), no space to buffer result\r\n");
  2116. } else if (g_GetResultsCmdCnt > 0) {
  2117. DBGLOG(SCN, INFO, "FW report events match the wifi_hal asked number\n");
  2118. g_GetResultsCmdCnt--;
  2119. } else
  2120. DBGLOG(SCN, INFO, "g_GetResultsCmdCnt < 0 ??? unexpected case\n");
  2121. #endif
  2122. /* end of workaround */
  2123. }
  2124. break;
  2125. case EVENT_ID_NLO_DONE:
  2126. prAdapter->rWifiVar.rScanInfo.fgPscnOnnning = FALSE;
  2127. DBGLOG(INIT, INFO, "EVENT_ID_NLO_DONE\n");
  2128. scnEventNloDone(prAdapter, (P_EVENT_NLO_DONE_T) (prEvent->aucBuffer));
  2129. break;
  2130. #if CFG_SUPPORT_BATCH_SCAN
  2131. case EVENT_ID_BATCH_RESULT:
  2132. DBGLOG(SCN, TRACE, "Got EVENT_ID_BATCH_RESULT");
  2133. /* command response handling */
  2134. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  2135. if (prCmdInfo != NULL) {
  2136. if (prCmdInfo->pfCmdDoneHandler)
  2137. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  2138. else if (prCmdInfo->fgIsOid)
  2139. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  2140. /* return prCmdInfo */
  2141. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2142. }
  2143. break;
  2144. #endif /* CFG_SUPPORT_BATCH_SCAN */
  2145. #if (CFG_SUPPORT_TDLS == 1)
  2146. case EVENT_ID_TDLS:
  2147. TdlsexEventHandle(prAdapter->prGlueInfo,
  2148. (UINT8 *) prEvent->aucBuffer, (UINT32) (prEvent->u2PacketLen - 8));
  2149. break;
  2150. #endif /* CFG_SUPPORT_TDLS */
  2151. #if (CFG_SUPPORT_STATISTICS == 1)
  2152. case EVENT_ID_STATS_ENV:
  2153. statsEventHandle(prAdapter->prGlueInfo,
  2154. (UINT8 *) prEvent->aucBuffer, (UINT32) (prEvent->u2PacketLen - 8));
  2155. break;
  2156. #endif /* CFG_SUPPORT_STATISTICS */
  2157. case EVENT_ID_FW_LOG_ENV:
  2158. {
  2159. P_EVENT_FW_LOG_T prEventLog;
  2160. prEventLog = (P_EVENT_FW_LOG_T) (prEvent->aucBuffer);
  2161. DBGLOG(RX, EVENT, "[F-L]%s\n", prEventLog->log);
  2162. }
  2163. break;
  2164. default:
  2165. prCmdInfo = nicGetPendingCmdInfo(prAdapter, prEvent->ucSeqNum);
  2166. if (prCmdInfo != NULL) {
  2167. if (prCmdInfo->pfCmdDoneHandler)
  2168. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prEvent->aucBuffer);
  2169. else if (prCmdInfo->fgIsOid)
  2170. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery, 0, WLAN_STATUS_SUCCESS);
  2171. /* return prCmdInfo */
  2172. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2173. }
  2174. break;
  2175. }
  2176. nicRxReturnRFB(prAdapter, prSwRfb);
  2177. }
  2178. /*----------------------------------------------------------------------------*/
  2179. /*!
  2180. * @brief nicRxProcessMgmtPacket is used to dispatch management frames
  2181. * to corresponding modules
  2182. *
  2183. * @param prAdapter Pointer to the Adapter structure.
  2184. * @param prSWRfb the RFB to receive rx data
  2185. *
  2186. * @return (none)
  2187. */
  2188. /*----------------------------------------------------------------------------*/
  2189. VOID nicRxProcessMgmtPacket(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  2190. {
  2191. UINT_8 ucSubtype;
  2192. #if CFG_SUPPORT_802_11W
  2193. BOOLEAN fgMfgDrop = FALSE;
  2194. #endif
  2195. ASSERT(prAdapter);
  2196. ASSERT(prSwRfb);
  2197. nicRxFillRFB(prAdapter, prSwRfb);
  2198. ucSubtype = (*(PUINT_8) (prSwRfb->pvHeader) & MASK_FC_SUBTYPE) >> OFFSET_OF_FC_SUBTYPE;
  2199. #if 0 /* CFG_RX_PKTS_DUMP */
  2200. {
  2201. P_HIF_RX_HEADER_T prHifRxHdr;
  2202. UINT_16 u2TxFrameCtrl;
  2203. prHifRxHdr = prSwRfb->prHifRxHdr;
  2204. u2TxFrameCtrl = (*(PUINT_8) (prSwRfb->pvHeader) & MASK_FRAME_TYPE);
  2205. /* if (prAdapter->rRxCtrl.u4RxPktsDumpTypeMask & BIT(HIF_RX_PKT_TYPE_MANAGEMENT)) { */
  2206. /* if (u2TxFrameCtrl == MAC_FRAME_BEACON || */
  2207. /* u2TxFrameCtrl == MAC_FRAME_PROBE_RSP) { */
  2208. DBGLOG(RX, INFO, "QM RX MGT: net %u sta idx %u wlan idx %u ssn %u ptype %u subtype %u 11 %u\n",
  2209. (UINT_32) HIF_RX_HDR_GET_NETWORK_IDX(prHifRxHdr), prHifRxHdr->ucStaRecIdx,
  2210. prSwRfb->ucWlanIdx, (UINT_32) HIF_RX_HDR_GET_SN(prHifRxHdr),/* The new SN of the frame */
  2211. prSwRfb->ucPacketType, ucSubtype, HIF_RX_HDR_GET_80211_FLAG(prHifRxHdr));
  2212. /* DBGLOG_MEM8(SW4, TRACE, (PUINT_8)prSwRfb->pvHeader, prSwRfb->u2PacketLen); */
  2213. /* } */
  2214. /* } */
  2215. }
  2216. #endif
  2217. if ((prAdapter->fgTestMode == FALSE) && (prAdapter->prGlueInfo->fgIsRegistered == TRUE)) {
  2218. #if CFG_MGMT_FRAME_HANDLING
  2219. #if CFG_SUPPORT_802_11W
  2220. fgMfgDrop = rsnCheckRxMgmt(prAdapter, prSwRfb, ucSubtype);
  2221. if (fgMfgDrop) {
  2222. #if DBG
  2223. LOG_FUNC("QM RX MGT: Drop Unprotected Mgmt frame!!!\n");
  2224. #endif
  2225. nicRxReturnRFB(prAdapter, prSwRfb);
  2226. RX_INC_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT);
  2227. return;
  2228. }
  2229. #endif
  2230. if (apfnProcessRxMgtFrame[ucSubtype]) {
  2231. switch (apfnProcessRxMgtFrame[ucSubtype] (prAdapter, prSwRfb)) {
  2232. case WLAN_STATUS_PENDING:
  2233. return;
  2234. case WLAN_STATUS_SUCCESS:
  2235. case WLAN_STATUS_FAILURE:
  2236. break;
  2237. default:
  2238. DBGLOG(RX, WARN,
  2239. "Unexpected MMPDU(0x%02X) returned with abnormal status\n", ucSubtype);
  2240. break;
  2241. }
  2242. }
  2243. #endif
  2244. }
  2245. nicRxReturnRFB(prAdapter, prSwRfb);
  2246. }
  2247. #if CFG_SUPPORT_WAKEUP_REASON_DEBUG
  2248. static VOID nicRxCheckWakeupReason(P_SW_RFB_T prSwRfb)
  2249. {
  2250. PUINT_8 pvHeader = NULL;
  2251. P_HIF_RX_HEADER_T prHifRxHdr;
  2252. UINT_16 u2PktLen = 0;
  2253. UINT_32 u4HeaderOffset;
  2254. if (!prSwRfb)
  2255. return;
  2256. prHifRxHdr = prSwRfb->prHifRxHdr;
  2257. if (!prHifRxHdr)
  2258. return;
  2259. switch (prSwRfb->ucPacketType) {
  2260. case HIF_RX_PKT_TYPE_DATA:
  2261. {
  2262. UINT_16 u2Temp = 0;
  2263. if (HIF_RX_HDR_GET_BAR_FLAG(prHifRxHdr)) {
  2264. DBGLOG(RX, INFO, "BAR frame[SSN:%d, TID:%d] wakeup host\n",
  2265. (UINT_16)HIF_RX_HDR_GET_SN(prHifRxHdr), (UINT_8)HIF_RX_HDR_GET_TID(prHifRxHdr));
  2266. break;
  2267. }
  2268. u4HeaderOffset = (UINT_32)(prHifRxHdr->ucHerderLenOffset & HIF_RX_HDR_HEADER_OFFSET_MASK);
  2269. pvHeader = (PUINT_8)prHifRxHdr + HIF_RX_HDR_SIZE + u4HeaderOffset;
  2270. u2PktLen = (UINT_16)(prHifRxHdr->u2PacketLen - (HIF_RX_HDR_SIZE + u4HeaderOffset));
  2271. if (!pvHeader) {
  2272. DBGLOG(RX, ERROR, "data packet but pvHeader is NULL!\n");
  2273. break;
  2274. }
  2275. u2Temp = (pvHeader[ETH_TYPE_LEN_OFFSET] << 8) | (pvHeader[ETH_TYPE_LEN_OFFSET + 1]);
  2276. switch (u2Temp) {
  2277. case ETH_P_IPV4:
  2278. u2Temp = *(UINT_16 *) &pvHeader[ETH_HLEN + 4];
  2279. DBGLOG(RX, INFO, "IP Packet from:%d.%d.%d.%d, IP ID 0x%04x wakeup host\n",
  2280. pvHeader[ETH_HLEN + 12], pvHeader[ETH_HLEN + 13],
  2281. pvHeader[ETH_HLEN + 14], pvHeader[ETH_HLEN + 15], u2Temp);
  2282. break;
  2283. case ETH_P_1X:
  2284. case ETH_P_PRE_1X:
  2285. #if CFG_SUPPORT_WAPI
  2286. case ETH_WPI_1X:
  2287. #endif
  2288. case ETH_P_AARP:
  2289. case ETH_P_IPV6:
  2290. case ETH_P_IPX:
  2291. case 0x8100: /* VLAN */
  2292. case 0x890d: /* TDLS */
  2293. DBGLOG(RX, INFO, "Data Packet, EthType 0x%04x wakeup host\n", u2Temp);
  2294. break;
  2295. default:
  2296. DBGLOG(RX, WARN, "maybe abnormal data packet, EthType 0x%04x wakeup host, dump it\n",
  2297. u2Temp);
  2298. DBGLOG_MEM8(RX, INFO, pvHeader, u2PktLen > 50 ? 50:u2PacketLen);
  2299. break;
  2300. }
  2301. break;
  2302. }
  2303. case HIF_RX_PKT_TYPE_EVENT:
  2304. {
  2305. P_WIFI_EVENT_T prEvent = (P_WIFI_EVENT_T) prSwRfb->pucRecvBuff;
  2306. DBGLOG(RX, INFO, "Event 0x%02x wakeup host\n", prEvent->ucEID);
  2307. break;
  2308. }
  2309. case HIF_RX_PKT_TYPE_MANAGEMENT:
  2310. {
  2311. UINT_8 ucSubtype;
  2312. P_WLAN_MAC_MGMT_HEADER_T prWlanMgmtHeader;
  2313. u4HeaderOffset = (UINT_32)(prHifRxHdr->ucHerderLenOffset & HIF_RX_HDR_HEADER_OFFSET_MASK);
  2314. pvHeader = (PUINT_8)prHifRxHdr + HIF_RX_HDR_SIZE + u4HeaderOffset;
  2315. if (!pvHeader) {
  2316. DBGLOG(RX, ERROR, "Mgmt Frame but pvHeader is NULL!\n");
  2317. break;
  2318. }
  2319. prWlanMgmtHeader = (P_WLAN_MAC_MGMT_HEADER_T)pvHeader;
  2320. ucSubtype = (prWlanMgmtHeader->u2FrameCtrl & MASK_FC_SUBTYPE) >>
  2321. OFFSET_OF_FC_SUBTYPE;
  2322. DBGLOG(RX, INFO, "MGMT frame subtype: %d SeqCtrl %d wakeup host\n",
  2323. ucSubtype, prWlanMgmtHeader->u2SeqCtrl);
  2324. break;
  2325. }
  2326. default:
  2327. DBGLOG(RX, WARN, "Unknown Packet %d wakeup host\n", prSwRfb->ucPacketType);
  2328. break;
  2329. }
  2330. }
  2331. #endif
  2332. /*----------------------------------------------------------------------------*/
  2333. /*!
  2334. * @brief nicProcessRFBs is used to process RFBs in the rReceivedRFBList queue.
  2335. *
  2336. * @param prAdapter Pointer to the Adapter structure.
  2337. *
  2338. * @return (none)
  2339. */
  2340. /*----------------------------------------------------------------------------*/
  2341. VOID nicRxProcessRFBs(IN P_ADAPTER_T prAdapter)
  2342. {
  2343. P_RX_CTRL_T prRxCtrl;
  2344. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  2345. KAL_SPIN_LOCK_DECLARATION();
  2346. DEBUGFUNC("nicRxProcessRFBs");
  2347. ASSERT(prAdapter);
  2348. prRxCtrl = &prAdapter->rRxCtrl;
  2349. ASSERT(prRxCtrl);
  2350. prRxCtrl->ucNumIndPacket = 0;
  2351. prRxCtrl->ucNumRetainedPacket = 0;
  2352. do {
  2353. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2354. QUEUE_REMOVE_HEAD(&prRxCtrl->rReceivedRfbList, prSwRfb, P_SW_RFB_T);
  2355. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2356. if (prSwRfb) {
  2357. #if CFG_SUPPORT_WAKEUP_REASON_DEBUG
  2358. if (kalIsWakeupByWlan(prAdapter))
  2359. nicRxCheckWakeupReason(prSwRfb);
  2360. #endif
  2361. switch (prSwRfb->ucPacketType) {
  2362. case HIF_RX_PKT_TYPE_DATA:
  2363. nicRxProcessDataPacket(prAdapter, prSwRfb);
  2364. break;
  2365. case HIF_RX_PKT_TYPE_EVENT:
  2366. nicRxProcessEventPacket(prAdapter, prSwRfb);
  2367. break;
  2368. case HIF_RX_PKT_TYPE_TX_LOOPBACK:
  2369. #if (CONF_HIF_LOOPBACK_AUTO == 1)
  2370. {
  2371. kalDevLoopbkRxHandle(prAdapter, prSwRfb);
  2372. nicRxReturnRFB(prAdapter, prSwRfb);
  2373. }
  2374. #else
  2375. DBGLOG(RX, ERROR, "ucPacketType = %d\n", prSwRfb->ucPacketType);
  2376. #endif /* CONF_HIF_LOOPBACK_AUTO */
  2377. break;
  2378. case HIF_RX_PKT_TYPE_MANAGEMENT:
  2379. nicRxProcessMgmtPacket(prAdapter, prSwRfb);
  2380. break;
  2381. default:
  2382. RX_INC_CNT(prRxCtrl, RX_TYPE_ERR_DROP_COUNT);
  2383. RX_INC_CNT(prRxCtrl, RX_DROP_TOTAL_COUNT);
  2384. DBGLOG(RX, ERROR, "ucPacketType = %d\n", prSwRfb->ucPacketType);
  2385. nicRxReturnRFB(prAdapter, prSwRfb); /* need to free it */
  2386. break;
  2387. }
  2388. } else {
  2389. break;
  2390. }
  2391. } while (TRUE);
  2392. if (prRxCtrl->ucNumIndPacket > 0) {
  2393. RX_ADD_CNT(prRxCtrl, RX_DATA_INDICATION_COUNT, prRxCtrl->ucNumIndPacket);
  2394. RX_ADD_CNT(prRxCtrl, RX_DATA_RETAINED_COUNT, prRxCtrl->ucNumRetainedPacket);
  2395. /* DBGLOG(RX, INFO, ("%d packets indicated, Retained cnt = %d\n", */
  2396. /* prRxCtrl->ucNumIndPacket, prRxCtrl->ucNumRetainedPacket)); */
  2397. #if CFG_NATIVE_802_11
  2398. kalRxIndicatePkts(prAdapter->prGlueInfo, (UINT_32) prRxCtrl->ucNumIndPacket,
  2399. (UINT_32) prRxCtrl->ucNumRetainedPacket);
  2400. #else
  2401. kalRxIndicatePkts(prAdapter->prGlueInfo, prRxCtrl->apvIndPacket, (UINT_32) prRxCtrl->ucNumIndPacket);
  2402. #endif
  2403. }
  2404. } /* end of nicRxProcessRFBs() */
  2405. #if !CFG_SDIO_INTR_ENHANCE
  2406. /*----------------------------------------------------------------------------*/
  2407. /*!
  2408. * @brief Read the rx data from data port and setup RFB
  2409. *
  2410. * @param prAdapter pointer to the Adapter handler
  2411. * @param prSWRfb the RFB to receive rx data
  2412. *
  2413. * @retval WLAN_STATUS_SUCCESS: SUCCESS
  2414. * @retval WLAN_STATUS_FAILURE: FAILURE
  2415. *
  2416. */
  2417. /*----------------------------------------------------------------------------*/
  2418. WLAN_STATUS nicRxReadBuffer(IN P_ADAPTER_T prAdapter, IN OUT P_SW_RFB_T prSwRfb)
  2419. {
  2420. P_RX_CTRL_T prRxCtrl;
  2421. PUINT_8 pucBuf;
  2422. P_HIF_RX_HEADER_T prHifRxHdr;
  2423. UINT_32 u4PktLen = 0, u4ReadBytes;
  2424. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  2425. BOOLEAN fgResult = TRUE;
  2426. UINT_32 u4RegValue;
  2427. UINT_32 rxNum;
  2428. DEBUGFUNC("nicRxReadBuffer");
  2429. ASSERT(prAdapter);
  2430. ASSERT(prSwRfb);
  2431. prRxCtrl = &prAdapter->rRxCtrl;
  2432. ASSERT(prRxCtrl);
  2433. pucBuf = prSwRfb->pucRecvBuff;
  2434. prHifRxHdr = prSwRfb->prHifRxHdr;
  2435. ASSERT(pucBuf);
  2436. DBGLOG(RX, TRACE, "pucBuf= 0x%x, prHifRxHdr= 0x%x\n", pucBuf, prHifRxHdr);
  2437. do {
  2438. /* Read the RFB DW length and packet length */
  2439. HAL_MCR_RD(prAdapter, MCR_WRPLR, &u4RegValue);
  2440. if (!fgResult) {
  2441. DBGLOG(RX, ERROR, "Read RX Packet Lentgh Error\n");
  2442. return WLAN_STATUS_FAILURE;
  2443. }
  2444. /* 20091021 move the line to get the HIF RX header (for RX0/1) */
  2445. if (u4RegValue == 0) {
  2446. DBGLOG(RX, ERROR, "No RX packet\n");
  2447. return WLAN_STATUS_FAILURE;
  2448. }
  2449. u4PktLen = u4RegValue & BITS(0, 15);
  2450. if (u4PktLen != 0) {
  2451. rxNum = 0;
  2452. } else {
  2453. rxNum = 1;
  2454. u4PktLen = (u4RegValue & BITS(16, 31)) >> 16;
  2455. }
  2456. DBGLOG(RX, TRACE, "RX%d: u4PktLen = %d\n", rxNum, u4PktLen);
  2457. /* 4 <4> Read Entire RFB and packet, include HW appended DW (Checksum Status) */
  2458. u4ReadBytes = ALIGN_4(u4PktLen) + 4;
  2459. HAL_READ_RX_PORT(prAdapter, rxNum, u4ReadBytes, pucBuf, CFG_RX_MAX_PKT_SIZE);
  2460. /* 20091021 move the line to get the HIF RX header */
  2461. /* u4PktLen = (UINT_32)prHifRxHdr->u2PacketLen; */
  2462. if (u4PktLen != (UINT_32) prHifRxHdr->u2PacketLen) {
  2463. DBGLOG(RX, ERROR, "Read u4PktLen = %d, prHifRxHdr->u2PacketLen: %d\n",
  2464. u4PktLen, prHifRxHdr->u2PacketLen);
  2465. #if DBG
  2466. dumpMemory8((PUINT_8) prHifRxHdr,
  2467. (prHifRxHdr->u2PacketLen > 4096) ? 4096 : prHifRxHdr->u2PacketLen);
  2468. #endif
  2469. ASSERT(0);
  2470. }
  2471. /* u4PktLen is byte unit, not inlude HW appended DW */
  2472. prSwRfb->ucPacketType = (UINT_8) (prHifRxHdr->u2PacketType & HIF_RX_HDR_PACKET_TYPE_MASK);
  2473. DBGLOG(RX, TRACE, "ucPacketType = %d\n", prSwRfb->ucPacketType);
  2474. prSwRfb->ucStaRecIdx = (UINT_8) (prHifRxHdr->ucStaRecIdx);
  2475. /* fgResult will be updated in MACRO */
  2476. if (!fgResult)
  2477. return WLAN_STATUS_FAILURE;
  2478. DBGLOG(RX, TRACE, "Dump RX buffer, length = 0x%x\n", u4ReadBytes);
  2479. DBGLOG_MEM8(RX, TRACE, pucBuf, u4ReadBytes);
  2480. } while (FALSE);
  2481. return u4Status;
  2482. }
  2483. /*----------------------------------------------------------------------------*/
  2484. /*!
  2485. * @brief Read frames from the data port, fill RFB
  2486. * and put each frame into the rReceivedRFBList queue.
  2487. *
  2488. * @param prAdapter Pointer to the Adapter structure.
  2489. *
  2490. * @return (none)
  2491. */
  2492. /*----------------------------------------------------------------------------*/
  2493. VOID nicRxReceiveRFBs(IN P_ADAPTER_T prAdapter)
  2494. {
  2495. P_RX_CTRL_T prRxCtrl;
  2496. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  2497. P_HIF_RX_HEADER_T prHifRxHdr;
  2498. UINT_32 u4HwAppendDW;
  2499. KAL_SPIN_LOCK_DECLARATION();
  2500. DEBUGFUNC("nicRxReceiveRFBs");
  2501. ASSERT(prAdapter);
  2502. prRxCtrl = &prAdapter->rRxCtrl;
  2503. ASSERT(prRxCtrl);
  2504. do {
  2505. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2506. QUEUE_REMOVE_HEAD(&prRxCtrl->rFreeSwRfbList, prSwRfb, P_SW_RFB_T);
  2507. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2508. if (!prSwRfb) {
  2509. DBGLOG(RX, TRACE, "No More RFB\n");
  2510. break;
  2511. }
  2512. /* need to consider */
  2513. if (nicRxReadBuffer(prAdapter, prSwRfb) == WLAN_STATUS_FAILURE) {
  2514. DBGLOG(RX, TRACE, "halRxFillRFB failed\n");
  2515. nicRxReturnRFB(prAdapter, prSwRfb);
  2516. break;
  2517. }
  2518. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2519. QUEUE_INSERT_TAIL(&prRxCtrl->rReceivedRfbList, &prSwRfb->rQueEntry);
  2520. RX_INC_CNT(prRxCtrl, RX_MPDU_TOTAL_COUNT);
  2521. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2522. prHifRxHdr = prSwRfb->prHifRxHdr;
  2523. u4HwAppendDW = *((PUINT_32) ((ULONG) prHifRxHdr + (UINT_32) (ALIGN_4(prHifRxHdr->u2PacketLen))));
  2524. DBGLOG(RX, TRACE, "u4HwAppendDW = 0x%x\n", u4HwAppendDW);
  2525. DBGLOG(RX, TRACE, "u2PacketLen = 0x%x\n", prHifRxHdr->u2PacketLen);
  2526. } while (FALSE); /* while (RX_STATUS_TEST_MORE_FLAG(u4HwAppendDW)); */
  2527. return;
  2528. } /* end of nicReceiveRFBs() */
  2529. #else
  2530. /*----------------------------------------------------------------------------*/
  2531. /*!
  2532. * @brief Read frames from the data port, fill RFB
  2533. * and put each frame into the rReceivedRFBList queue.
  2534. *
  2535. * @param prAdapter Pointer to the Adapter structure.
  2536. * @param u4DataPort Specify which port to read
  2537. * @param u2RxLength Specify to the the rx packet length in Byte.
  2538. * @param prSwRfb the RFB to receive rx data.
  2539. *
  2540. * @return (none)
  2541. */
  2542. /*----------------------------------------------------------------------------*/
  2543. WLAN_STATUS
  2544. nicRxEnhanceReadBuffer(IN P_ADAPTER_T prAdapter,
  2545. IN UINT_32 u4DataPort, IN UINT_16 u2RxLength, IN OUT P_SW_RFB_T prSwRfb)
  2546. {
  2547. P_RX_CTRL_T prRxCtrl;
  2548. PUINT_8 pucBuf;
  2549. P_HIF_RX_HEADER_T prHifRxHdr;
  2550. UINT_32 u4PktLen = 0;
  2551. WLAN_STATUS u4Status = WLAN_STATUS_FAILURE;
  2552. BOOLEAN fgResult = TRUE;
  2553. DEBUGFUNC("nicRxEnhanceReadBuffer");
  2554. ASSERT(prAdapter);
  2555. ASSERT(prSwRfb);
  2556. prRxCtrl = &prAdapter->rRxCtrl;
  2557. ASSERT(prRxCtrl);
  2558. pucBuf = prSwRfb->pucRecvBuff;
  2559. ASSERT(pucBuf);
  2560. prHifRxHdr = prSwRfb->prHifRxHdr;
  2561. ASSERT(prHifRxHdr);
  2562. /* DBGLOG(RX, TRACE, ("u2RxLength = %d\n", u2RxLength)); */
  2563. do {
  2564. /* 4 <1> Read RFB frame from MCR_WRDR0, include HW appended DW */
  2565. HAL_READ_RX_PORT(prAdapter,
  2566. u4DataPort, ALIGN_4(u2RxLength + HIF_RX_HW_APPENDED_LEN), pucBuf, CFG_RX_MAX_PKT_SIZE);
  2567. if (!fgResult) {
  2568. DBGLOG(RX, ERROR, "Read RX Packet Lentgh Error\n");
  2569. break;
  2570. }
  2571. u4PktLen = (UINT_32) (prHifRxHdr->u2PacketLen);
  2572. /* DBGLOG(RX, TRACE, ("u4PktLen = %d\n", u4PktLen)); */
  2573. prSwRfb->ucPacketType = (UINT_8) (prHifRxHdr->u2PacketType & HIF_RX_HDR_PACKET_TYPE_MASK);
  2574. /* DBGLOG(RX, TRACE, ("ucPacketType = %d\n", prSwRfb->ucPacketType)); */
  2575. prSwRfb->ucStaRecIdx = (UINT_8) (prHifRxHdr->ucStaRecIdx);
  2576. /* 4 <2> if the RFB dw size or packet size is zero */
  2577. if (u4PktLen == 0) {
  2578. DBGLOG(RX, ERROR, "Packet Length = %u\n", u4PktLen);
  2579. ASSERT(0);
  2580. break;
  2581. }
  2582. /* 4 <3> if the packet is too large or too small */
  2583. if (u4PktLen > CFG_RX_MAX_PKT_SIZE) {
  2584. DBGLOG(RX, TRACE, "Read RX Packet Lentgh Error (%u)\n", u4PktLen);
  2585. ASSERT(0);
  2586. break;
  2587. }
  2588. u4Status = WLAN_STATUS_SUCCESS;
  2589. } while (FALSE);
  2590. DBGLOG_MEM8(RX, TRACE, pucBuf, ALIGN_4(u2RxLength + HIF_RX_HW_APPENDED_LEN));
  2591. return u4Status;
  2592. }
  2593. /*----------------------------------------------------------------------------*/
  2594. /*!
  2595. * @brief Read frames from the data port for SDIO
  2596. * I/F, fill RFB and put each frame into the rReceivedRFBList queue.
  2597. *
  2598. * @param prAdapter Pointer to the Adapter structure.
  2599. *
  2600. * @return (none)
  2601. */
  2602. /*----------------------------------------------------------------------------*/
  2603. VOID nicRxSDIOReceiveRFBs(IN P_ADAPTER_T prAdapter)
  2604. {
  2605. P_SDIO_CTRL_T prSDIOCtrl;
  2606. P_RX_CTRL_T prRxCtrl;
  2607. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  2608. UINT_32 i, rxNum;
  2609. UINT_16 u2RxPktNum, u2RxLength = 0, u2Tmp = 0;
  2610. KAL_SPIN_LOCK_DECLARATION();
  2611. DEBUGFUNC("nicRxSDIOReceiveRFBs");
  2612. ASSERT(prAdapter);
  2613. prSDIOCtrl = prAdapter->prSDIOCtrl;
  2614. ASSERT(prSDIOCtrl);
  2615. prRxCtrl = &prAdapter->rRxCtrl;
  2616. ASSERT(prRxCtrl);
  2617. for (rxNum = 0; rxNum < 2; rxNum++) {
  2618. u2RxPktNum =
  2619. (rxNum == 0 ? prSDIOCtrl->rRxInfo.u.u2NumValidRx0Len : prSDIOCtrl->rRxInfo.u.u2NumValidRx1Len);
  2620. if (u2RxPktNum == 0)
  2621. continue;
  2622. for (i = 0; i < u2RxPktNum; i++) {
  2623. if (rxNum == 0) {
  2624. /* HAL_READ_RX_LENGTH */
  2625. HAL_READ_RX_LENGTH(prAdapter, &u2RxLength, &u2Tmp);
  2626. } else if (rxNum == 1) {
  2627. /* HAL_READ_RX_LENGTH */
  2628. HAL_READ_RX_LENGTH(prAdapter, &u2Tmp, &u2RxLength);
  2629. }
  2630. if (!u2RxLength)
  2631. break;
  2632. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2633. QUEUE_REMOVE_HEAD(&prRxCtrl->rFreeSwRfbList, prSwRfb, P_SW_RFB_T);
  2634. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2635. if (!prSwRfb) {
  2636. DBGLOG(RX, TRACE, "No More RFB\n");
  2637. break;
  2638. }
  2639. ASSERT(prSwRfb);
  2640. if (nicRxEnhanceReadBuffer(prAdapter, rxNum, u2RxLength, prSwRfb) == WLAN_STATUS_FAILURE) {
  2641. DBGLOG(RX, TRACE, "nicRxEnhanceRxReadBuffer failed\n");
  2642. nicRxReturnRFB(prAdapter, prSwRfb);
  2643. break;
  2644. }
  2645. /* prSDIOCtrl->au4RxLength[i] = 0; */
  2646. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2647. QUEUE_INSERT_TAIL(&prRxCtrl->rReceivedRfbList, &prSwRfb->rQueEntry);
  2648. RX_INC_CNT(prRxCtrl, RX_MPDU_TOTAL_COUNT);
  2649. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2650. }
  2651. }
  2652. prSDIOCtrl->rRxInfo.u.u2NumValidRx0Len = 0;
  2653. prSDIOCtrl->rRxInfo.u.u2NumValidRx1Len = 0;
  2654. } /* end of nicRxSDIOReceiveRFBs() */
  2655. #endif /* CFG_SDIO_INTR_ENHANCE */
  2656. #if CFG_SDIO_RX_AGG
  2657. /*----------------------------------------------------------------------------*/
  2658. /*!
  2659. * @brief Read frames from the data port for SDIO with Rx aggregation enabled
  2660. * I/F, fill RFB and put each frame into the rReceivedRFBList queue.
  2661. *
  2662. * @param prAdapter Pointer to the Adapter structure.
  2663. *
  2664. * @return (none)
  2665. */
  2666. /*----------------------------------------------------------------------------*/
  2667. VOID nicRxSDIOAggReceiveRFBs(IN P_ADAPTER_T prAdapter)
  2668. {
  2669. P_ENHANCE_MODE_DATA_STRUCT_T prEnhDataStr;
  2670. P_RX_CTRL_T prRxCtrl;
  2671. P_SDIO_CTRL_T prSDIOCtrl;
  2672. P_SW_RFB_T prSwRfb = (P_SW_RFB_T) NULL;
  2673. UINT_32 u4RxLength;
  2674. UINT_32 i, rxNum;
  2675. UINT_32 u4RxAggCount = 0, u4RxAggLength = 0;
  2676. UINT_32 u4RxAvailAggLen, u4CurrAvailFreeRfbCnt;
  2677. PUINT_8 pucSrcAddr;
  2678. P_HIF_RX_HEADER_T prHifRxHdr;
  2679. BOOLEAN fgResult = TRUE;
  2680. BOOLEAN fgIsRxEnhanceMode;
  2681. UINT_16 u2RxPktNum;
  2682. #if CFG_SDIO_RX_ENHANCE
  2683. UINT_32 u4MaxLoopCount = CFG_MAX_RX_ENHANCE_LOOP_COUNT;
  2684. #endif
  2685. KAL_SPIN_LOCK_DECLARATION();
  2686. DEBUGFUNC("nicRxSDIOAggReceiveRFBs");
  2687. ASSERT(prAdapter);
  2688. prEnhDataStr = prAdapter->prSDIOCtrl;
  2689. prRxCtrl = &prAdapter->rRxCtrl;
  2690. prSDIOCtrl = prAdapter->prSDIOCtrl;
  2691. #if CFG_SDIO_RX_ENHANCE
  2692. fgIsRxEnhanceMode = TRUE;
  2693. #else
  2694. fgIsRxEnhanceMode = FALSE;
  2695. #endif
  2696. do {
  2697. #if CFG_SDIO_RX_ENHANCE
  2698. /* to limit maximum loop for RX */
  2699. u4MaxLoopCount--;
  2700. if (u4MaxLoopCount == 0)
  2701. break;
  2702. #endif
  2703. if (prEnhDataStr->rRxInfo.u.u2NumValidRx0Len == 0 && prEnhDataStr->rRxInfo.u.u2NumValidRx1Len == 0)
  2704. break;
  2705. for (rxNum = 0; rxNum < 2; rxNum++) {
  2706. u2RxPktNum =
  2707. (rxNum ==
  2708. 0 ? prEnhDataStr->rRxInfo.u.u2NumValidRx0Len : prEnhDataStr->rRxInfo.u.u2NumValidRx1Len);
  2709. /* if this assertion happened, it is most likely a F/W bug */
  2710. ASSERT(u2RxPktNum <= 16);
  2711. if (u2RxPktNum > 16)
  2712. continue;
  2713. if (u2RxPktNum == 0)
  2714. continue;
  2715. #if CFG_HIF_STATISTICS
  2716. prRxCtrl->u4TotalRxAccessNum++;
  2717. prRxCtrl->u4TotalRxPacketNum += u2RxPktNum;
  2718. #endif
  2719. u4CurrAvailFreeRfbCnt = prRxCtrl->rFreeSwRfbList.u4NumElem;
  2720. /* if SwRfb is not enough, abort reading this time */
  2721. if (u4CurrAvailFreeRfbCnt < u2RxPktNum) {
  2722. #if CFG_HIF_RX_STARVATION_WARNING
  2723. DbgPrint("FreeRfb is not enough: %d available, need %d\n", u4CurrAvailFreeRfbCnt,
  2724. u2RxPktNum);
  2725. DbgPrint("Queued Count: %d / Dequeud Count: %d\n", prRxCtrl->u4QueuedCnt,
  2726. prRxCtrl->u4DequeuedCnt);
  2727. #endif
  2728. continue;
  2729. }
  2730. #if CFG_SDIO_RX_ENHANCE
  2731. u4RxAvailAggLen =
  2732. CFG_RX_COALESCING_BUFFER_SIZE - (sizeof(ENHANCE_MODE_DATA_STRUCT_T) +
  2733. 4 /* extra HW padding */);
  2734. #else
  2735. u4RxAvailAggLen = CFG_RX_COALESCING_BUFFER_SIZE;
  2736. #endif
  2737. u4RxAggCount = 0;
  2738. for (i = 0; i < u2RxPktNum; i++) {
  2739. u4RxLength = (rxNum == 0 ?
  2740. (UINT_32) prEnhDataStr->rRxInfo.u.au2Rx0Len[i] :
  2741. (UINT_32) prEnhDataStr->rRxInfo.u.au2Rx1Len[i]);
  2742. if (!u4RxLength) {
  2743. ASSERT(0);
  2744. break;
  2745. }
  2746. if (ALIGN_4(u4RxLength + HIF_RX_HW_APPENDED_LEN) < u4RxAvailAggLen) {
  2747. if (u4RxAggCount < u4CurrAvailFreeRfbCnt) {
  2748. u4RxAvailAggLen -= ALIGN_4(u4RxLength + HIF_RX_HW_APPENDED_LEN);
  2749. u4RxAggCount++;
  2750. } else {
  2751. /* no FreeSwRfb for rx packet */
  2752. ASSERT(0);
  2753. break;
  2754. }
  2755. } else {
  2756. /* CFG_RX_COALESCING_BUFFER_SIZE is not large enough */
  2757. ASSERT(0);
  2758. break;
  2759. }
  2760. }
  2761. u4RxAggLength = (CFG_RX_COALESCING_BUFFER_SIZE - u4RxAvailAggLen);
  2762. /* DBGLOG(RX, INFO, ("u4RxAggCount = %d, u4RxAggLength = %d\n", */
  2763. /* u4RxAggCount, u4RxAggLength)); */
  2764. HAL_READ_RX_PORT(prAdapter,
  2765. rxNum,
  2766. u4RxAggLength, prRxCtrl->pucRxCoalescingBufPtr, CFG_RX_COALESCING_BUFFER_SIZE);
  2767. if (!fgResult) {
  2768. DBGLOG(RX, ERROR, "Read RX Agg Packet Error\n");
  2769. continue;
  2770. }
  2771. pucSrcAddr = prRxCtrl->pucRxCoalescingBufPtr;
  2772. for (i = 0; i < u4RxAggCount; i++) {
  2773. UINT_16 u2PktLength;
  2774. u2PktLength = (rxNum == 0 ?
  2775. prEnhDataStr->rRxInfo.u.au2Rx0Len[i] :
  2776. prEnhDataStr->rRxInfo.u.au2Rx1Len[i]);
  2777. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2778. QUEUE_REMOVE_HEAD(&prRxCtrl->rFreeSwRfbList, prSwRfb, P_SW_RFB_T);
  2779. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2780. ASSERT(prSwRfb);
  2781. kalMemCopy(prSwRfb->pucRecvBuff, pucSrcAddr,
  2782. ALIGN_4(u2PktLength + HIF_RX_HW_APPENDED_LEN));
  2783. /* record the rx time */
  2784. STATS_RX_ARRIVE_TIME_RECORD(prSwRfb); /* ms */
  2785. prHifRxHdr = prSwRfb->prHifRxHdr;
  2786. ASSERT(prHifRxHdr);
  2787. prSwRfb->ucPacketType =
  2788. (UINT_8) (prHifRxHdr->u2PacketType & HIF_RX_HDR_PACKET_TYPE_MASK);
  2789. /* DBGLOG(RX, TRACE, ("ucPacketType = %d\n", prSwRfb->ucPacketType)); */
  2790. prSwRfb->ucStaRecIdx = (UINT_8) (prHifRxHdr->ucStaRecIdx);
  2791. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2792. QUEUE_INSERT_TAIL(&prRxCtrl->rReceivedRfbList, &prSwRfb->rQueEntry);
  2793. RX_INC_CNT(prRxCtrl, RX_MPDU_TOTAL_COUNT);
  2794. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2795. pucSrcAddr += ALIGN_4(u2PktLength + HIF_RX_HW_APPENDED_LEN);
  2796. /* prEnhDataStr->au4RxLength[i] = 0; */
  2797. }
  2798. #if CFG_SDIO_RX_ENHANCE
  2799. kalMemCopy(prAdapter->prSDIOCtrl, (pucSrcAddr + 4), sizeof(ENHANCE_MODE_DATA_STRUCT_T));
  2800. /* do the same thing what nicSDIOReadIntStatus() does */
  2801. if ((prSDIOCtrl->u4WHISR & WHISR_TX_DONE_INT) == 0 &&
  2802. (prSDIOCtrl->rTxInfo.au4WTSR[0] | prSDIOCtrl->rTxInfo.au4WTSR[1])) {
  2803. prSDIOCtrl->u4WHISR |= WHISR_TX_DONE_INT;
  2804. }
  2805. if ((prSDIOCtrl->u4WHISR & BIT(31)) == 0 &&
  2806. HAL_GET_MAILBOX_READ_CLEAR(prAdapter) == TRUE &&
  2807. (prSDIOCtrl->u4RcvMailbox0 != 0 || prSDIOCtrl->u4RcvMailbox1 != 0)) {
  2808. prSDIOCtrl->u4WHISR |= BIT(31);
  2809. }
  2810. /* dispatch to interrupt handler with RX bits masked */
  2811. nicProcessIST_impl(prAdapter,
  2812. prSDIOCtrl->u4WHISR & (~(WHISR_RX0_DONE_INT | WHISR_RX1_DONE_INT)));
  2813. #endif
  2814. }
  2815. #if !CFG_SDIO_RX_ENHANCE
  2816. prEnhDataStr->rRxInfo.u.u2NumValidRx0Len = 0;
  2817. prEnhDataStr->rRxInfo.u.u2NumValidRx1Len = 0;
  2818. #endif
  2819. } while ((prEnhDataStr->rRxInfo.u.u2NumValidRx0Len || prEnhDataStr->rRxInfo.u.u2NumValidRx1Len)
  2820. && fgIsRxEnhanceMode);
  2821. }
  2822. #endif /* CFG_SDIO_RX_AGG */
  2823. /*----------------------------------------------------------------------------*/
  2824. /*!
  2825. * @brief Setup a RFB and allocate the os packet to the RFB
  2826. *
  2827. * @param prAdapter Pointer to the Adapter structure.
  2828. * @param prSwRfb Pointer to the RFB
  2829. *
  2830. * @retval WLAN_STATUS_SUCCESS
  2831. * @retval WLAN_STATUS_RESOURCES
  2832. */
  2833. /*----------------------------------------------------------------------------*/
  2834. WLAN_STATUS nicRxSetupRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  2835. {
  2836. PVOID pvPacket;
  2837. PUINT_8 pucRecvBuff;
  2838. ASSERT(prAdapter);
  2839. ASSERT(prSwRfb);
  2840. if (!prSwRfb->pvPacket) {
  2841. kalMemZero(prSwRfb, sizeof(SW_RFB_T));
  2842. pvPacket = kalPacketAlloc(prAdapter->prGlueInfo, CFG_RX_MAX_PKT_SIZE, &pucRecvBuff);
  2843. if (pvPacket == NULL)
  2844. return WLAN_STATUS_RESOURCES;
  2845. prSwRfb->pvPacket = pvPacket;
  2846. prSwRfb->pucRecvBuff = (PVOID) pucRecvBuff;
  2847. } else {
  2848. kalMemZero(((PUINT_8) prSwRfb + OFFSET_OF(SW_RFB_T, prHifRxHdr)),
  2849. (sizeof(SW_RFB_T) - OFFSET_OF(SW_RFB_T, prHifRxHdr)));
  2850. }
  2851. prSwRfb->prHifRxHdr = (P_HIF_RX_HEADER_T) (prSwRfb->pucRecvBuff);
  2852. return WLAN_STATUS_SUCCESS;
  2853. } /* end of nicRxSetupRFB() */
  2854. /*----------------------------------------------------------------------------*/
  2855. /*!
  2856. * @brief This routine is called to put a RFB back onto the "RFB with Buffer" list
  2857. * or "RFB without buffer" list according to pvPacket.
  2858. *
  2859. * @param prAdapter Pointer to the Adapter structure.
  2860. * @param prSwRfb Pointer to the RFB
  2861. *
  2862. * @return (none)
  2863. */
  2864. /*----------------------------------------------------------------------------*/
  2865. VOID nicRxReturnRFB(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  2866. {
  2867. P_RX_CTRL_T prRxCtrl;
  2868. P_QUE_ENTRY_T prQueEntry;
  2869. KAL_SPIN_LOCK_DECLARATION();
  2870. ASSERT(prAdapter);
  2871. ASSERT(prSwRfb);
  2872. prRxCtrl = &prAdapter->rRxCtrl;
  2873. prQueEntry = &prSwRfb->rQueEntry;
  2874. ASSERT(prQueEntry);
  2875. /* The processing on this RFB is done, so put it back on the tail of
  2876. our list */
  2877. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2878. if (prSwRfb->pvPacket) {
  2879. /* QUEUE_INSERT_TAIL */
  2880. QUEUE_INSERT_TAIL(&prRxCtrl->rFreeSwRfbList, prQueEntry);
  2881. } else {
  2882. /* QUEUE_INSERT_TAIL */
  2883. QUEUE_INSERT_TAIL(&prRxCtrl->rIndicatedRfbList, prQueEntry);
  2884. }
  2885. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_QUE);
  2886. } /* end of nicRxReturnRFB() */
  2887. /*----------------------------------------------------------------------------*/
  2888. /*!
  2889. * @brief Process rx interrupt. When the rx
  2890. * Interrupt is asserted, it means there are frames in queue.
  2891. *
  2892. * @param prAdapter Pointer to the Adapter structure.
  2893. *
  2894. * @return (none)
  2895. */
  2896. /*----------------------------------------------------------------------------*/
  2897. VOID nicProcessRxInterrupt(IN P_ADAPTER_T prAdapter)
  2898. {
  2899. ASSERT(prAdapter);
  2900. #if CFG_SDIO_INTR_ENHANCE
  2901. #if CFG_SDIO_RX_AGG
  2902. nicRxSDIOAggReceiveRFBs(prAdapter);
  2903. #else
  2904. nicRxSDIOReceiveRFBs(prAdapter);
  2905. #endif
  2906. #else
  2907. nicRxReceiveRFBs(prAdapter);
  2908. #endif /* CFG_SDIO_INTR_ENHANCE */
  2909. nicRxProcessRFBs(prAdapter);
  2910. return;
  2911. } /* end of nicProcessRxInterrupt() */
  2912. #if CFG_TCP_IP_CHKSUM_OFFLOAD
  2913. /*----------------------------------------------------------------------------*/
  2914. /*!
  2915. * @brief Used to update IP/TCP/UDP checksum statistics of RX Module.
  2916. *
  2917. * @param prAdapter Pointer to the Adapter structure.
  2918. * @param aeCSUM The array of checksum result.
  2919. *
  2920. * @return (none)
  2921. */
  2922. /*----------------------------------------------------------------------------*/
  2923. VOID nicRxUpdateCSUMStatistics(IN P_ADAPTER_T prAdapter, IN const ENUM_CSUM_RESULT_T aeCSUM[])
  2924. {
  2925. P_RX_CTRL_T prRxCtrl;
  2926. ASSERT(prAdapter);
  2927. ASSERT(aeCSUM);
  2928. prRxCtrl = &prAdapter->rRxCtrl;
  2929. ASSERT(prRxCtrl);
  2930. if ((aeCSUM[CSUM_TYPE_IPV4] == CSUM_RES_SUCCESS) ||
  2931. (aeCSUM[CSUM_TYPE_IPV6] == CSUM_RES_SUCCESS)) {
  2932. RX_INC_CNT(prRxCtrl, RX_CSUM_IP_SUCCESS_COUNT);
  2933. } else if ((aeCSUM[CSUM_TYPE_IPV4] == CSUM_RES_FAILED) || (aeCSUM[CSUM_TYPE_IPV6] == CSUM_RES_FAILED)) {
  2934. RX_INC_CNT(prRxCtrl, RX_CSUM_IP_FAILED_COUNT);
  2935. } else if ((aeCSUM[CSUM_TYPE_IPV4] == CSUM_RES_NONE) && (aeCSUM[CSUM_TYPE_IPV6] == CSUM_RES_NONE)) {
  2936. RX_INC_CNT(prRxCtrl, RX_CSUM_UNKNOWN_L3_PKT_COUNT);
  2937. } else {
  2938. ASSERT(0);
  2939. }
  2940. if (aeCSUM[CSUM_TYPE_TCP] == CSUM_RES_SUCCESS) {
  2941. /* count success num */
  2942. RX_INC_CNT(prRxCtrl, RX_CSUM_TCP_SUCCESS_COUNT);
  2943. } else if (aeCSUM[CSUM_TYPE_TCP] == CSUM_RES_FAILED) {
  2944. RX_INC_CNT(prRxCtrl, RX_CSUM_TCP_FAILED_COUNT);
  2945. } else if (aeCSUM[CSUM_TYPE_UDP] == CSUM_RES_SUCCESS) {
  2946. RX_INC_CNT(prRxCtrl, RX_CSUM_UDP_SUCCESS_COUNT);
  2947. } else if (aeCSUM[CSUM_TYPE_UDP] == CSUM_RES_FAILED) {
  2948. RX_INC_CNT(prRxCtrl, RX_CSUM_UDP_FAILED_COUNT);
  2949. } else if ((aeCSUM[CSUM_TYPE_UDP] == CSUM_RES_NONE) && (aeCSUM[CSUM_TYPE_TCP] == CSUM_RES_NONE)) {
  2950. RX_INC_CNT(prRxCtrl, RX_CSUM_UNKNOWN_L4_PKT_COUNT);
  2951. } else {
  2952. ASSERT(0);
  2953. }
  2954. } /* end of nicRxUpdateCSUMStatistics() */
  2955. #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
  2956. /*----------------------------------------------------------------------------*/
  2957. /*!
  2958. * @brief This function is used to query current status of RX Module.
  2959. *
  2960. * @param prAdapter Pointer to the Adapter structure.
  2961. * @param pucBuffer Pointer to the message buffer.
  2962. * @param pu4Count Pointer to the buffer of message length count.
  2963. *
  2964. * @return (none)
  2965. */
  2966. /*----------------------------------------------------------------------------*/
  2967. VOID nicRxQueryStatus(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count)
  2968. {
  2969. P_RX_CTRL_T prRxCtrl;
  2970. PUINT_8 pucCurrBuf = pucBuffer;
  2971. ASSERT(prAdapter);
  2972. prRxCtrl = &prAdapter->rRxCtrl;
  2973. ASSERT(prRxCtrl);
  2974. /* if (pucBuffer) {} */ /* For Windows, we'll print directly instead of sprintf() */
  2975. ASSERT(pu4Count);
  2976. SPRINTF(pucCurrBuf, ("\n\nRX CTRL STATUS:"));
  2977. SPRINTF(pucCurrBuf, ("\n==============="));
  2978. SPRINTF(pucCurrBuf, ("\nFREE RFB w/i BUF LIST :%9u", prRxCtrl->rFreeSwRfbList.u4NumElem));
  2979. SPRINTF(pucCurrBuf, ("\nFREE RFB w/o BUF LIST :%9u", prRxCtrl->rIndicatedRfbList.u4NumElem));
  2980. SPRINTF(pucCurrBuf, ("\nRECEIVED RFB LIST :%9u", prRxCtrl->rReceivedRfbList.u4NumElem));
  2981. SPRINTF(pucCurrBuf, ("\n\n"));
  2982. /* *pu4Count = (UINT_32)((UINT_32)pucCurrBuf - (UINT_32)pucBuffer); */
  2983. } /* end of nicRxQueryStatus() */
  2984. /*----------------------------------------------------------------------------*/
  2985. /*!
  2986. * @brief Clear RX related counters
  2987. *
  2988. * @param prAdapter Pointer of Adapter Data Structure
  2989. *
  2990. * @return - (none)
  2991. */
  2992. /*----------------------------------------------------------------------------*/
  2993. VOID nicRxClearStatistics(IN P_ADAPTER_T prAdapter)
  2994. {
  2995. P_RX_CTRL_T prRxCtrl;
  2996. ASSERT(prAdapter);
  2997. prRxCtrl = &prAdapter->rRxCtrl;
  2998. ASSERT(prRxCtrl);
  2999. RX_RESET_ALL_CNTS(prRxCtrl);
  3000. }
  3001. /*----------------------------------------------------------------------------*/
  3002. /*!
  3003. * @brief This function is used to query current statistics of RX Module.
  3004. *
  3005. * @param prAdapter Pointer to the Adapter structure.
  3006. * @param pucBuffer Pointer to the message buffer.
  3007. * @param pu4Count Pointer to the buffer of message length count.
  3008. *
  3009. * @return (none)
  3010. */
  3011. /*----------------------------------------------------------------------------*/
  3012. VOID nicRxQueryStatistics(IN P_ADAPTER_T prAdapter, IN PUINT_8 pucBuffer, OUT PUINT_32 pu4Count)
  3013. {
  3014. P_RX_CTRL_T prRxCtrl;
  3015. PUINT_8 pucCurrBuf = pucBuffer;
  3016. ASSERT(prAdapter);
  3017. prRxCtrl = &prAdapter->rRxCtrl;
  3018. ASSERT(prRxCtrl);
  3019. /* if (pucBuffer) {} */ /* For Windows, we'll print directly instead of sprintf() */
  3020. ASSERT(pu4Count);
  3021. #define SPRINTF_RX_COUNTER(eCounter) \
  3022. SPRINTF(pucCurrBuf, ("%-30s : %u\n", #eCounter, (UINT_32)prRxCtrl->au8Statistics[eCounter]))
  3023. SPRINTF_RX_COUNTER(RX_MPDU_TOTAL_COUNT);
  3024. SPRINTF_RX_COUNTER(RX_SIZE_ERR_DROP_COUNT);
  3025. SPRINTF_RX_COUNTER(RX_DATA_INDICATION_COUNT);
  3026. SPRINTF_RX_COUNTER(RX_DATA_RETURNED_COUNT);
  3027. SPRINTF_RX_COUNTER(RX_DATA_RETAINED_COUNT);
  3028. #if CFG_TCP_IP_CHKSUM_OFFLOAD || CFG_TCP_IP_CHKSUM_OFFLOAD_NDIS_60
  3029. SPRINTF_RX_COUNTER(RX_CSUM_TCP_FAILED_COUNT);
  3030. SPRINTF_RX_COUNTER(RX_CSUM_UDP_FAILED_COUNT);
  3031. SPRINTF_RX_COUNTER(RX_CSUM_IP_FAILED_COUNT);
  3032. SPRINTF_RX_COUNTER(RX_CSUM_TCP_SUCCESS_COUNT);
  3033. SPRINTF_RX_COUNTER(RX_CSUM_UDP_SUCCESS_COUNT);
  3034. SPRINTF_RX_COUNTER(RX_CSUM_IP_SUCCESS_COUNT);
  3035. SPRINTF_RX_COUNTER(RX_CSUM_UNKNOWN_L4_PKT_COUNT);
  3036. SPRINTF_RX_COUNTER(RX_CSUM_UNKNOWN_L3_PKT_COUNT);
  3037. SPRINTF_RX_COUNTER(RX_IP_V6_PKT_CCOUNT);
  3038. #endif
  3039. /* *pu4Count = (UINT_32)(pucCurrBuf - pucBuffer); */
  3040. nicRxClearStatistics(prAdapter);
  3041. }
  3042. /*----------------------------------------------------------------------------*/
  3043. /*!
  3044. * @brief Read the Response data from data port
  3045. *
  3046. * @param prAdapter pointer to the Adapter handler
  3047. * @param pucRspBuffer pointer to the Response buffer
  3048. *
  3049. * @retval WLAN_STATUS_SUCCESS: Response packet has been read
  3050. * @retval WLAN_STATUS_FAILURE: Read Response packet timeout or error occurred
  3051. *
  3052. */
  3053. /*----------------------------------------------------------------------------*/
  3054. WLAN_STATUS
  3055. nicRxWaitResponse(IN P_ADAPTER_T prAdapter,
  3056. IN UINT_8 ucPortIdx, OUT PUINT_8 pucRspBuffer, IN UINT_32 u4MaxRespBufferLen, OUT PUINT_32 pu4Length)
  3057. {
  3058. UINT_32 u4Value = 0, u4PktLen = 0;
  3059. UINT_32 i = 0;
  3060. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  3061. BOOLEAN fgResult = TRUE;
  3062. UINT_32 u4Time, u4Current;
  3063. DEBUGFUNC("nicRxWaitResponse");
  3064. ASSERT(prAdapter);
  3065. ASSERT(pucRspBuffer);
  3066. ASSERT(ucPortIdx < 2);
  3067. u4Time = kalGetTimeTick();
  3068. do {
  3069. /* Read the packet length */
  3070. HAL_MCR_RD(prAdapter, MCR_WRPLR, &u4Value);
  3071. if (!fgResult) {
  3072. DBGLOG(RX, ERROR, "Read Response Packet Error\n");
  3073. return WLAN_STATUS_FAILURE;
  3074. }
  3075. if (ucPortIdx == 0)
  3076. u4PktLen = u4Value & 0xFFFF;
  3077. else
  3078. u4PktLen = (u4Value >> 16) & 0xFFFF;
  3079. /* DBGLOG(RX, TRACE, ("i = %d, u4PktLen = %d\n", i, u4PktLen)); */
  3080. if (u4PktLen == 0) {
  3081. /* timeout exceeding check */
  3082. u4Current = kalGetTimeTick();
  3083. if ((u4Current > u4Time) && ((u4Current - u4Time) > RX_RESPONSE_TIMEOUT)) {
  3084. DBGLOG(RX, ERROR, "RX_RESPONSE_TIMEOUT1 %u %d %u\n", u4PktLen, i, u4Current);
  3085. return WLAN_STATUS_FAILURE;
  3086. } else if (u4Current < u4Time && ((u4Current + (0xFFFFFFFF - u4Time)) > RX_RESPONSE_TIMEOUT)) {
  3087. DBGLOG(RX, ERROR, "RX_RESPONSE_TIMEOUT2 %u %d %u\n", u4PktLen, i, u4Current);
  3088. return WLAN_STATUS_FAILURE;
  3089. }
  3090. /* Response packet is not ready */
  3091. kalUdelay(50);
  3092. i++;
  3093. continue;
  3094. }
  3095. if (u4PktLen > u4MaxRespBufferLen) {
  3096. /*
  3097. TO: buffer is not enough but we still need to read all data from HIF to avoid
  3098. HIF crazy.
  3099. */
  3100. DBGLOG(RX, ERROR,
  3101. "Not enough Event Buffer: required length = 0x%x, available buffer length = %d\n",
  3102. u4PktLen, u4MaxRespBufferLen);
  3103. DBGLOG(RX, ERROR, "i = %d, u4PktLen = %u\n", i, u4PktLen);
  3104. return WLAN_STATUS_FAILURE;
  3105. }
  3106. HAL_PORT_RD(prAdapter,
  3107. ucPortIdx == 0 ? MCR_WRDR0 : MCR_WRDR1, u4PktLen, pucRspBuffer, u4MaxRespBufferLen);
  3108. /* fgResult will be updated in MACRO */
  3109. if (!fgResult) {
  3110. DBGLOG(RX, ERROR, "Read Response Packet Error\n");
  3111. return WLAN_STATUS_FAILURE;
  3112. }
  3113. DBGLOG(RX, TRACE, "Dump Response buffer, length = 0x%x\n", u4PktLen);
  3114. DBGLOG_MEM8(RX, TRACE, pucRspBuffer, u4PktLen);
  3115. *pu4Length = u4PktLen;
  3116. break;
  3117. } while (TRUE);
  3118. return u4Status;
  3119. }
  3120. /*----------------------------------------------------------------------------*/
  3121. /*!
  3122. * @brief Set filter to enable Promiscuous Mode
  3123. *
  3124. * @param prAdapter Pointer to the Adapter structure.
  3125. *
  3126. * @return (none)
  3127. */
  3128. /*----------------------------------------------------------------------------*/
  3129. VOID nicRxEnablePromiscuousMode(IN P_ADAPTER_T prAdapter)
  3130. {
  3131. ASSERT(prAdapter);
  3132. } /* end of nicRxEnablePromiscuousMode() */
  3133. /*----------------------------------------------------------------------------*/
  3134. /*!
  3135. * @brief Set filter to disable Promiscuous Mode
  3136. *
  3137. * @param prAdapter Pointer to the Adapter structure.
  3138. *
  3139. * @return (none)
  3140. */
  3141. /*----------------------------------------------------------------------------*/
  3142. VOID nicRxDisablePromiscuousMode(IN P_ADAPTER_T prAdapter)
  3143. {
  3144. ASSERT(prAdapter);
  3145. } /* end of nicRxDisablePromiscuousMode() */
  3146. /*----------------------------------------------------------------------------*/
  3147. /*!
  3148. * @brief this function flushes all packets queued in reordering module
  3149. *
  3150. * @param prAdapter Pointer to the Adapter structure.
  3151. *
  3152. * @retval WLAN_STATUS_SUCCESS Flushed successfully
  3153. */
  3154. /*----------------------------------------------------------------------------*/
  3155. WLAN_STATUS nicRxFlush(IN P_ADAPTER_T prAdapter)
  3156. {
  3157. P_SW_RFB_T prSwRfb;
  3158. ASSERT(prAdapter);
  3159. prSwRfb = qmFlushRxQueues(prAdapter);
  3160. if (prSwRfb != NULL) {
  3161. do {
  3162. P_SW_RFB_T prNextSwRfb;
  3163. /* save next first */
  3164. prNextSwRfb = (P_SW_RFB_T) QUEUE_GET_NEXT_ENTRY((P_QUE_ENTRY_T) prSwRfb);
  3165. /* free */
  3166. nicRxReturnRFB(prAdapter, prSwRfb);
  3167. prSwRfb = prNextSwRfb;
  3168. } while (prSwRfb);
  3169. }
  3170. return WLAN_STATUS_SUCCESS;
  3171. }
  3172. /*----------------------------------------------------------------------------*/
  3173. /*!
  3174. * @brief
  3175. *
  3176. * @param
  3177. *
  3178. * @retval
  3179. */
  3180. /*----------------------------------------------------------------------------*/
  3181. WLAN_STATUS nicRxProcessActionFrame(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  3182. {
  3183. P_WLAN_ACTION_FRAME prActFrame;
  3184. ASSERT(prAdapter);
  3185. ASSERT(prSwRfb);
  3186. if (prSwRfb->u2PacketLen < sizeof(WLAN_ACTION_FRAME) - 1)
  3187. return WLAN_STATUS_INVALID_PACKET;
  3188. prActFrame = (P_WLAN_ACTION_FRAME) prSwRfb->pvHeader;
  3189. DBGLOG(RX, INFO, "Category %u\n", prActFrame->ucCategory);
  3190. switch (prActFrame->ucCategory) {
  3191. case CATEGORY_PUBLIC_ACTION:
  3192. if (HIF_RX_HDR_GET_NETWORK_IDX(prSwRfb->prHifRxHdr) == NETWORK_TYPE_AIS_INDEX)
  3193. aisFuncValidateRxActionFrame(prAdapter, prSwRfb);
  3194. #if CFG_ENABLE_WIFI_DIRECT
  3195. else if (prAdapter->fgIsP2PRegistered) {
  3196. rlmProcessPublicAction(prAdapter, prSwRfb);
  3197. p2pFuncValidateRxActionFrame(prAdapter, prSwRfb);
  3198. }
  3199. #endif
  3200. break;
  3201. case CATEGORY_HT_ACTION:
  3202. #if CFG_ENABLE_WIFI_DIRECT
  3203. if (prAdapter->fgIsP2PRegistered)
  3204. rlmProcessHtAction(prAdapter, prSwRfb);
  3205. #endif
  3206. break;
  3207. case CATEGORY_VENDOR_SPECIFIC_ACTION:
  3208. #if CFG_ENABLE_WIFI_DIRECT
  3209. if (prAdapter->fgIsP2PRegistered)
  3210. p2pFuncValidateRxActionFrame(prAdapter, prSwRfb);
  3211. #endif
  3212. break;
  3213. #if CFG_SUPPORT_802_11W
  3214. case CATEGORY_SA_QUERT_ACTION:
  3215. {
  3216. P_HIF_RX_HEADER_T prHifRxHdr;
  3217. prHifRxHdr = prSwRfb->prHifRxHdr;
  3218. if ((HIF_RX_HDR_GET_NETWORK_IDX(prHifRxHdr) == NETWORK_TYPE_AIS_INDEX)
  3219. && prAdapter->rWifiVar.rAisSpecificBssInfo.fgMgmtProtection /* Use MFP */) {
  3220. if (!(prHifRxHdr->ucReserved & CONTROL_FLAG_UC_MGMT_NO_ENC)) {
  3221. /* MFP test plan 5.3.3.4 */
  3222. rsnSaQueryAction(prAdapter, prSwRfb);
  3223. } else {
  3224. DBGLOG(RSN, TRACE, "Un-Protected SA Query, do nothing\n");
  3225. }
  3226. }
  3227. }
  3228. break;
  3229. #endif
  3230. #if CFG_SUPPORT_802_11V
  3231. case CATEGORY_WNM_ACTION:
  3232. {
  3233. wnmWNMAction(prAdapter, prSwRfb);
  3234. }
  3235. break;
  3236. #endif
  3237. #if CFG_SUPPORT_DFS /* Add by Enlai */
  3238. case CATEGORY_SPEC_MGT:
  3239. {
  3240. if (prAdapter->fgEnable5GBand == TRUE)
  3241. rlmProcessSpecMgtAction(prAdapter, prSwRfb);
  3242. }
  3243. break;
  3244. #endif
  3245. #if (CFG_SUPPORT_TDLS == 1)
  3246. case 12: /* shall not be here */
  3247. /*
  3248. A received TDLS Action frame with the Type field set to Management shall
  3249. be discarded. Note that the TDLS Discovery Response frame is not a TDLS
  3250. frame but a Public Action frame.
  3251. */
  3252. break;
  3253. #endif /* CFG_SUPPORT_TDLS */
  3254. default:
  3255. break;
  3256. } /* end of switch case */
  3257. return WLAN_STATUS_SUCCESS;
  3258. }