wlan_lib.c 236 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383
  1. /*! \file wlan_lib.c
  2. \brief Internal driver stack will export the required procedures here for GLUE Layer.
  3. This file contains all routines which are exported from MediaTek 802.11 Wireless
  4. LAN driver stack to GLUE Layer.
  5. */
  6. /*
  7. ** Log: wlan_lib.c
  8. **
  9. ** 04 02 2014 eason.tsai
  10. ** [ALPS01070904] [Need Patch] [Volunteer Patch]
  11. ** revise apusd as enable
  12. **
  13. ** 01 15 2014 eason.tsai
  14. ** [ALPS01070904] [Need Patch] [Volunteer Patch][MT6630][Driver]MT6630 Wi-Fi Patch
  15. ** Merging
  16. **
  17. ** //ALPS_SW/DEV/ALPS.JB2.MT6630.DEV/alps/mediatek/kernel/drivers/combo/drv_wlan/mt6630/wlan/...
  18. **
  19. ** to //ALPS_SW/TRUNK/KK/alps/mediatek/kernel/drivers/combo/drv_wlan/mt6630/wlan/...
  20. **
  21. ** 10 09 2013 eason.tsai
  22. ** [ALPS01070904] [Need Patch] [Volunteer Patch][MT6630][Driver]MT6630 Wi-Fi Patch
  23. ** turn off nvram power
  24. **
  25. ** 08 09 2013 cp.wu
  26. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  27. ** 1. integrate scheduled scan functionality
  28. ** 2. condition compilation for linux-3.4 & linux-3.8 compatibility
  29. ** 3. correct CMD queue access to reduce lock scope
  30. **
  31. ** 08 09 2013 terry.wu
  32. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  33. ** 1. Add new input parameter, Tx done status, for wlanReleaseCommand()
  34. **
  35. ** 08 05 2013 cp.wu
  36. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  37. ** for windows build success
  38. **
  39. ** 07 31 2013 terry.wu
  40. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  41. ** 1. Fix NetDev binding issue
  42. **
  43. ** 07 30 2013 yuche.tsai
  44. ** [BORA00002398] [MT6630][Volunteer Patch] P2P Driver Re-Design for Multiple BSS support
  45. ** Temp fix Hot-spot data path issue.
  46. **
  47. ** 07 28 2013 eddie.chen
  48. ** [BORA00002450] [WIFISYS][MT6630] New design for mt6630
  49. ** Save the compileflag and featureflag
  50. **
  51. ** 07 26 2013 terry.wu
  52. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  53. ** 1. Set NoACK to BMC packet
  54. ** 2. Add kalGetEthAddr function for Tx frame
  55. ** 3. Update RxIndicatePackets
  56. **
  57. ** 07 26 2013 terry.wu
  58. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  59. ** 1. Reduce extra Tx frame header parsing
  60. ** 2. Add TX port control
  61. ** 3. Add net interface to BSS binding
  62. **
  63. ** 07 04 2013 terry.wu
  64. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  65. ** Update Tx path for 1x packet
  66. **
  67. ** 07 04 2013 terry.wu
  68. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  69. ** Update for 1st Connection.
  70. **
  71. ** 06 27 2013 terry.wu
  72. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  73. ** Refine management frame Tx function
  74. **
  75. ** 06 19 2013 cp.wu
  76. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  77. ** update MAC address handling logic
  78. **
  79. ** 06 18 2013 cp.wu
  80. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  81. ** use RX port #0 instead of #1 for communicating with Wi-Fi download agent
  82. **
  83. ** 06 18 2013 cm.chang
  84. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  85. ** Get MAC address by NIC_CAPABILITY command
  86. **
  87. ** 03 12 2013 tsaiyuan.hsu
  88. ** [BORA00002222] MT6630 unified MAC RXM
  89. ** remove hif_rx_hdr usage.
  90. **
  91. ** 03 12 2013 terry.wu
  92. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  93. ** Update Tx utility function for management frame
  94. **
  95. ** 03 06 2013 wh.su
  96. ** [BORA00002446] [MT6630] [Wi-Fi] [Driver] Update the security function code
  97. ** submit some code related with security.
  98. **
  99. ** 02 19 2013 cp.wu
  100. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  101. ** take use of GET_BSS_INFO_BY_INDEX() and MAX_BSS_INDEX macros
  102. ** for correctly indexing of BSS-INFO pointers
  103. **
  104. ** 02 06 2013 cp.wu
  105. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  106. ** add reset option for firmware download configuration
  107. **
  108. ** 02 05 2013 cp.wu
  109. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  110. ** 1. change to use long format (FT=1) for initial command
  111. ** 2. fix a typo
  112. **
  113. ** 02 01 2013 cp.wu
  114. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  115. ** 1. eliminate MT5931/MT6620/MT6628 logic
  116. ** 2. add firmware download control sequence
  117. **
  118. ** 01 24 2013 cm.chang
  119. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  120. ** Mark some code segment for compiling error
  121. **
  122. ** 01 22 2013 cp.wu
  123. ** [BORA00002253] [MT6630 Wi-Fi][Driver][Firmware] Add NLO and timeout mechanism to SCN module
  124. ** modification for ucBssIndex migration
  125. **
  126. ** 01 21 2013 cm.chang
  127. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  128. ** 1. Create rP2pDevInfo structure
  129. ** 2. Support 80/160 MHz channel bandwidth for channel privilege
  130. **
  131. ** 01 21 2013 terry.wu
  132. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  133. ** Update TX path based on new ucBssIndex modifications.
  134. **
  135. ** 01 17 2013 cm.chang
  136. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  137. ** Use ucBssIndex to replace eNetworkTypeIndex
  138. **
  139. ** 01 15 2013 terry.wu
  140. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  141. ** Update Tx done resource release mechanism.
  142. **
  143. ** 12 18 2012 terry.wu
  144. ** [BORA00002207] [MT6630 Wi-Fi] TXM & MQM Implementation
  145. ** Page count resource management.
  146. **
  147. ** 11 01 2012 cp.wu
  148. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  149. ** update to MT6630 CMD/EVENT definitions.
  150. **
  151. ** 10 25 2012 cp.wu
  152. ** [BORA00002227] [MT6630 Wi-Fi][Driver] Update for Makefile and HIFSYS modifications
  153. ** sync with MT6630 HIFSYS update.
  154. **
  155. ** 09 17 2012 cm.chang
  156. ** [BORA00002149] [MT6630 Wi-Fi] Initial software development
  157. ** Duplicate source from MT6620 v2.3 driver branch
  158. ** (Davinci label: MT6620_WIFI_Driver_V2_3_120913_1942_As_MT6630_Base)
  159. **
  160. ** 09 04 2012 cp.wu
  161. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  162. ** sync for NVRAM warning scan result generation for CFG80211.
  163. **
  164. ** 08 24 2012 cp.wu
  165. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  166. ** .
  167. **
  168. ** 08 24 2012 cp.wu
  169. ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
  170. ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
  171. **
  172. ** 08 15 2012 eason.tsai
  173. ** NULL
  174. ** fix build warning.
  175. *
  176. * 07 13 2012 cp.wu
  177. * [WCXRP00001259] [MT6620 Wi-Fi][Driver][Firmware] Send a signal to firmware for termination
  178. * after SDIO error has happened
  179. * [driver domain] add force reset by host-to-device interrupt mechanism
  180. *
  181. * 06 11 2012 cp.wu
  182. * [WCXRP00001252] [MT6620 Wi-Fi][Driver] Add debug message while encountering firmware response timeout
  183. * output message while timeout event occurs
  184. *
  185. * 06 11 2012 eason.tsai
  186. * NULL
  187. * change from binay to hex code
  188. *
  189. * 06 08 2012 eason.tsai
  190. * NULL
  191. * Nvram context covert from 6620 to 6628 for old 6620 meta tool
  192. *
  193. * 05 11 2012 cp.wu
  194. * [WCXRP00001237] [MT6620 Wi-Fi][Driver] Show MAC address and MAC address source for ACS's convenience
  195. * show MAC address & source while initiliazation
  196. *
  197. * 03 29 2012 eason.tsai
  198. * [WCXRP00001216] [MT6628 Wi-Fi][Driver]add conditional define
  199. * add conditional define.
  200. *
  201. * 03 04 2012 eason.tsai
  202. * NULL
  203. * modify the cal fail report code.
  204. *
  205. * 03 02 2012 terry.wu
  206. * NULL
  207. * Sync CFG80211 modification from branch 2,2.
  208. *
  209. * 01 16 2012 cp.wu
  210. * [WCXRP00001169] [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band
  211. * configuration with corresponding network configuration correct scan result removing policy.
  212. *
  213. * 01 16 2012 cp.wu
  214. * [MT6620 Wi-Fi][Driver] API and behavior modification for preferred band configuration with
  215. * corresponding network configuration add wlanSetPreferBandByNetwork() for glue layer to invoke
  216. * for setting preferred band configuration corresponding to network type.
  217. *
  218. * 01 05 2012 wh.su
  219. * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
  220. * Adding the related ioctl / wlan oid function to set the Tx power cfg.
  221. *
  222. * 11 28 2011 cp.wu
  223. * [WCXRP00001125] [MT6620 Wi-Fi][Firmware] Strengthen Wi-Fi power off sequence to have a clearroom environment
  224. * when returining to ROM code
  225. * 1. Due to firmware now stops HIF DMA for powering off, do not try to receive any packet from firmware
  226. * 2. Take use of prAdapter->fgIsEnterD3ReqIssued for tracking whether it is powering off or not
  227. *
  228. * 11 14 2011 cm.chang
  229. * [WCXRP00001104] [All Wi-Fi][FW] Show init process by HW mail-box register
  230. * Show FW initial ID when timeout to wait for ready bit
  231. *
  232. * 11 11 2011 wh.su
  233. * [WCXRP00001078] [MT6620 Wi-Fi][Driver] Adding the mediatek log improment support : XLOG
  234. * modify the xlog related code.
  235. *
  236. * 10 18 2011 cp.wu
  237. * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
  238. * when powering off, always clear pending interrupts, then wait for RDY to be de-asserted
  239. *
  240. * 10 14 2011 cp.wu
  241. * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
  242. * shorten the packet length for firmware download if no more than 2048 bytes.
  243. *
  244. * 10 03 2011 cp.wu
  245. * [WCXRP00001022] [MT6628 Driver][Firmware Download] Add multi section independent download functionality
  246. * add firmware download path in divided scatters.
  247. *
  248. * 10 03 2011 cp.wu
  249. * [MT6628 Driver][Firmware Download] Add multi section independent download functionality
  250. * add firmware downloading aggregated path.
  251. *
  252. * 09 30 2011 cm.chang
  253. * [WCXRP00001020] [MT6620 Wi-Fi][Driver] Handle secondary channel offset of AP in 5GHz band
  254. * .
  255. *
  256. * 09 20 2011 cp.wu
  257. * [WCXRP00000994] [MT6620 Wi-Fi][Driver] dump message for bus error and reset bus error flag while re-initialized
  258. * 1. always show error message for SDIO bus errors.
  259. * 2. reset bus error flag when re-initialization
  260. *
  261. * 08 26 2011 cm.chang
  262. * [WCXRP00000952] [MT5931 Wi-Fi][FW] Handshake with BWCS before DPD/TX power calibration
  263. * Fix compiling error for WinXP MT5931 driver
  264. *
  265. * 08 25 2011 chinghwa.yu
  266. * [WCXRP00000063] Update BCM CoEx design and settings
  267. * Add BWCS Sync ready for WinXP.
  268. *
  269. * 08 25 2011 chinghwa.yu
  270. * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  271. * Add DFS switch.
  272. *
  273. * 08 24 2011 chinghwa.yu
  274. * [WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  275. * Update RDD test mode cases.
  276. *
  277. * 08 19 2011 cp.wu
  278. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  279. * escape from normal path if any error is occurred.
  280. *
  281. * 08 15 2011 cp.wu
  282. * [WCXRP00000851] [MT6628 Wi-Fi][Driver] Add HIFSYS related definition to driver source tree
  283. * reuse firmware download logic of MT6620 for MT6628.
  284. *
  285. * 08 15 2011 cp.wu
  286. * [WCXRP00000913] [MT6620 Wi-Fi] create repository of source code dedicated for MT6620 E6 ASIC
  287. * support to load different firmware image for E3/E4/E5 and E6 ASIC on win32 platforms.
  288. *
  289. * 08 02 2011 yuche.tsai
  290. * [WCXRP00000896] [Volunteer Patch][WiFi Direct][Driver] GO with multiple client, TX deauth to a
  291. * disconnecting device issue.
  292. * Fix GO send deauth frame issue.
  293. *
  294. * 07 22 2011 jeffrey.chang
  295. * [WCXRP00000864] [MT5931] Add command to adjust OSC stable time
  296. * modify driver to set OSC stable time after f/w download
  297. *
  298. * 07 18 2011 chinghwa.yu
  299. * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
  300. * Add CMD/Event for RDD and BWCS.
  301. *
  302. * 06 24 2011 cp.wu
  303. * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
  304. * if there is no valid address in chip, generate a new one from driver domain instead of firmware domain
  305. * due to sufficient randomness
  306. *
  307. * 06 23 2011 cp.wu
  308. * [WCXRP00000812] [MT6620 Wi-Fi][Driver] not show NVRAM when there is no valid MAC address in NVRAM content
  309. * check with firmware for valid MAC address.
  310. *
  311. * 06 20 2011 cp.wu
  312. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  313. * disable whole-chip resetting mechanism due to the need of further ECO to work as expected.
  314. *
  315. * 05 31 2011 cp.wu
  316. * [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
  317. * changed to use non-zero checking for valid bit in NVRAM content
  318. *
  319. * 05 27 2011 cp.wu
  320. * [WCXRP00000749] [MT6620 Wi-Fi][Driver] Add band edge tx power control to Wi-Fi NVRAM
  321. * invoke CMD_ID_SET_EDGE_TXPWR_LIMIT when there is valid data exist in NVRAM content.
  322. *
  323. * 05 18 2011 cp.wu
  324. * [WCXRP00000734] [MT6620 Wi-Fi][Driver] Pass PHY_PARAM in NVRAM to firmware domain
  325. * pass PHY_PARAM in NVRAM from driver to firmware.
  326. *
  327. * 05 11 2011 cp.wu
  328. * [WCXRP00000718] [MT6620 Wi-Fi] modify the behavior of setting tx power
  329. * correct assertion.
  330. *
  331. * 05 11 2011 cp.wu
  332. * [WCXRP00000718] [MT6620 Wi-Fi] modify the behavior of setting tx power
  333. * ACPI APIs migrate to wlan_lib.c for glue layer to invoke.
  334. *
  335. * 05 11 2011 cm.chang
  336. * [WCXRP00000717] [MT5931 Wi-Fi][Driver] Handle wrong NVRAM content about AP bandwidth setting
  337. * .
  338. *
  339. * 05 05 2011 cp.wu
  340. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  341. * change delay from 100ms to 120ms upon DE's suggestion.
  342. *
  343. * 05 05 2011 cp.wu
  344. * [WCXRP00000702] [MT5931][Driver] Modify initialization sequence for E1 ASIC
  345. * add delay after whole-chip resetting for MT5931 E1 ASIC.
  346. *
  347. * 04 22 2011 cp.wu
  348. * [WCXRP00000598] [MT6620 Wi-Fi][Driver] Implementation of interface for communicating with user space
  349. * process for RESET_START and RESET_END events skip power-off handshaking when RESET indication is received.
  350. *
  351. * 04 22 2011 george.huang
  352. * [WCXRP00000621] [MT6620 Wi-Fi][Driver] Support P2P supplicant to set power mode
  353. * .
  354. *
  355. * 04 18 2011 cp.wu
  356. * [WCXRP00000636] [WHQL][MT5931 Driver] 2c_PMHibernate (hang on 2h)
  357. * 1) add API for glue layer to query ACPI state
  358. * 2) Windows glue should not access to hardware after switched into D3 state
  359. *
  360. * 04 15 2011 cp.wu
  361. * [WCXRP00000654] [MT6620 Wi-Fi][Driver] Add loop termination criterion for wlanAdapterStop().
  362. * add loop termination criteria for wlanAdapterStop().
  363. *
  364. * 04 12 2011 eddie.chen
  365. * [WCXRP00000617] [MT6620 Wi-Fi][DRV/FW] Fix for sigma
  366. * Fix the sta index in processing security frame
  367. * Simple flow control for TC4 to avoid mgt frames for PS STA to occupy the TC4
  368. * Add debug message.
  369. *
  370. * 04 12 2011 cp.wu
  371. * [WCXRP00000631] [MT6620 Wi-Fi][Driver] Add an API for QM to retrieve current TC counter value and processing
  372. * frame dropping cases for TC4 path
  373. * 1. add nicTxGetResource() API for QM to make decisions.
  374. * 2. if management frames is decided by QM for dropping, the call back is invoked to indicate such a case.
  375. *
  376. * 04 06 2011 cp.wu
  377. * [WCXRP00000616] [MT6620 Wi-Fi][Driver] Free memory to pool and kernel in case any unexpected failure
  378. * happend inside wlanAdapterStart invoke nicReleaseAdapterMemory() as failure handling in case
  379. * wlanAdapterStart() failed unexpectedly
  380. *
  381. * 03 29 2011 wh.su
  382. * [WCXRP00000248] [MT6620 Wi-Fi][FW]Fixed the Klockwork error
  383. * fixed the kclocwork error.
  384. *
  385. * 03 15 2011 cp.wu
  386. * [WCXRP00000559] [MT6620 Wi-Fi][Driver] Combine TX/RX DMA buffers into a single one to reduce physically
  387. * continuous memory consumption
  388. * 1. deprecate CFG_HANDLE_IST_IN_SDIO_CALLBACK
  389. * 2. Use common coalescing buffer for both TX/RX directions
  390. *
  391. *
  392. * 03 10 2011 cp.wu
  393. * [WCXRP00000532] [MT6620 Wi-Fi][Driver] Migrate NVRAM configuration procedures from MT6620 E2 to MT6620 E3
  394. * deprecate configuration used by MT6620 E2
  395. *
  396. * 03 07 2011 terry.wu
  397. * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
  398. * Toggle non-standard debug messages to comments.
  399. *
  400. * 02 25 2011 cp.wu
  401. * [WCXRP00000496] [MT5931][Driver] Apply host-triggered chip reset before initializing firmware download procedures
  402. * apply host-triggered chip reset mechanism before initializing firmware download procedures.
  403. *
  404. * 02 17 2011 eddie.chen
  405. * [WCXRP00000458] [MT6620 Wi-Fi][Driver] BOW Concurrent - ProbeResp was exist in other channel
  406. * 1) Chnange GetFrameAction decision when BSS is absent.
  407. * 2) Check channel and resource in processing ProbeRequest
  408. *
  409. * 02 16 2011 cm.chang
  410. * [WCXRP00000447] [MT6620 Wi-Fi][FW] Support new NVRAM update mechanism
  411. * .
  412. *
  413. * 02 01 2011 george.huang
  414. * [WCXRP00000333] [MT5931][FW] support SRAM power control drivers
  415. * init variable for CTIA.
  416. *
  417. * 01 27 2011 george.huang
  418. * [WCXRP00000355] [MT6620 Wi-Fi] Set WMM-PS related setting with qualifying AP capability
  419. * Support current measure mode, assigned by registry (XP only).
  420. *
  421. * 01 24 2011 cp.wu
  422. * [WCXRP00000382] [MT6620 Wi-Fi][Driver] Track forwarding packet number with notifying tx thread for serving
  423. * 1. add an extra counter for tracking pending forward frames.
  424. * 2. notify TX service thread as well when there is pending forward frame
  425. * 3. correct build errors leaded by introduction of Wi-Fi direct separation module
  426. *
  427. * 01 12 2011 cm.chang
  428. * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
  429. * User-defined bandwidth is for 2.4G and 5G individually
  430. *
  431. * 01 10 2011 cp.wu
  432. * [WCXRP00000351] [MT6620 Wi-Fi][Driver] remove from scanning result in OID handling layer when the
  433. * corresponding BSS is disconnected due to beacon timeout remove from scanning result when the BSS
  434. * is disconnected due to beacon timeout.
  435. *
  436. * 01 04 2011 cp.wu
  437. * [WCXRP00000338] [MT6620 Wi-Fi][Driver] Separate kalMemAlloc into kmalloc and vmalloc implementations to
  438. * ease physically continuous memory demands separate kalMemAlloc() into virtually-continuous
  439. * and physically-continuous type to ease slab system pressure
  440. *
  441. * 12 31 2010 cp.wu
  442. * [WCXRP00000327] [MT6620 Wi-Fi][Driver] Improve HEC WHQA 6972 workaround coverage in driver side
  443. * while being unloaded, clear all pending interrupt then set LP-own to firmware
  444. *
  445. * 12 31 2010 cp.wu
  446. * [WCXRP00000335] [MT6620 Wi-Fi][Driver] change to use milliseconds sleep instead of delay
  447. * to avoid blocking to system scheduling change to use msleep() and shorten waiting interval
  448. * to reduce blocking to other task while Wi-Fi driver is being loaded
  449. *
  450. * 12 28 2010 cp.wu
  451. * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
  452. * report EEPROM used flag via NIC_CAPABILITY
  453. *
  454. * 12 28 2010 cp.wu
  455. * [WCXRP00000269] [MT6620 Wi-Fi][Driver][Firmware] Prepare for v1.1 branch release
  456. * integrate with 'EEPROM used' flag for reporting correct capability to Engineer Mode/META and other tools
  457. *
  458. * 12 22 2010 eddie.chen
  459. * [WCXRP00000218] [MT6620 Wi-Fi][Driver] Add auto rate window control in registry
  460. * Remove controling auto rate from initial setting. The initial setting is defined by FW code.
  461. *
  462. * 12 15 2010 cp.wu
  463. * NULL
  464. * sync. with ALPS code by enabling interrupt just before leaving wlanAdapterStart()
  465. *
  466. * 12 08 2010 yuche.tsai
  467. * [WCXRP00000245] [MT6620][Driver] Invitation & Provision Discovery Feature Check-in
  468. * Change Param name for invitation connection.
  469. *
  470. * 12 07 2010 cm.chang
  471. * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
  472. * 1. Country code is from NVRAM or supplicant
  473. * 2. Change band definition in CMD/EVENT.
  474. *
  475. * 11 03 2010 cp.wu
  476. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  477. * 1) use 8 buffers for MT5931 which is equipped with less memory
  478. * 2) modify MT5931 debug level to TRACE when download is successful
  479. *
  480. * 11 02 2010 cp.wu
  481. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  482. * for MT5931, adapter initialization is done *after* firmware is downloaded.
  483. *
  484. * 11 02 2010 cp.wu
  485. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  486. * correct MT5931 firmware download procedure:
  487. * MT5931 will download firmware first then acquire LP-OWN
  488. *
  489. * 11 02 2010 cp.wu
  490. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  491. * 1) update MT5931 firmware encryption tool. (using 64-bytes unit)
  492. * 2) update MT5931 firmware download procedure
  493. *
  494. * 11 01 2010 cp.wu
  495. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version
  496. * Check[WCXRP00000150] [MT6620 Wi-Fi][Driver] Add implementation for querying
  497. * current TX rate from firmware auto rate module
  498. * 1) Query link speed (TX rate) from firmware directly with buffering mechanism to reduce overhead
  499. * 2) Remove CNM CH-RECOVER event handling
  500. * 3) cfg read/write API renamed with kal prefix for unified naming rules.
  501. *
  502. * 11 01 2010 yarco.yang
  503. * [WCXRP00000149] [MT6620 WI-Fi][Driver]Fine tune performance on MT6516 platform
  504. * Add code to run WlanIST in SDIO callback.
  505. *
  506. * 10 27 2010 george.huang
  507. * [WCXRP00000127] [MT6620 Wi-Fi][Driver] Add a registry to disable Beacon Timeout function
  508. * for SQA test by using E1 EVB
  509. * Support registry option for disable beacon lost detection.
  510. *
  511. * 10 26 2010 cp.wu
  512. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version
  513. * Check[WCXRP00000137] [MT6620 Wi-Fi] [FW] Support NIC capability query command
  514. * 1) update NVRAM content template to ver 1.02
  515. * 2) add compile option for querying NIC capability (default: off)
  516. * 3) modify AIS 5GHz support to run-time option, which could be turned on by registry or NVRAM setting
  517. * 4) correct auto-rate compiler error under linux (treat warning as error)
  518. * 5) simplify usage of NVRAM and REG_INFO_T
  519. * 6) add version checking between driver and firmware
  520. *
  521. * 10 26 2010 eddie.chen
  522. * [WCXRP00000134] [MT6620 Wi-Fi][Driver] Add a registry to enable auto rate for SQA test by using E1 EVB
  523. * Add auto rate parameter in registry.
  524. *
  525. * 10 25 2010 cp.wu
  526. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
  527. * add option for enable/disable TX PWR gain adjustment (default: off)
  528. *
  529. * 10 18 2010 cp.wu
  530. * [WCXRP00000117] [MT6620 Wi-Fi][Driver] Add logic for suspending driver when MT6620 is not responding anymore
  531. * 1. when wlanAdapterStop() failed to send POWER CTRL command to firmware, do not poll for ready bit dis-assertion
  532. * 2. shorten polling count for shorter response time
  533. * 3. if bad I/O operation is detected during TX resource polling, then further operation is aborted as well
  534. *
  535. * 10 18 2010 cp.wu
  536. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version
  537. * Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
  538. * complete implementation of Android NVRAM access
  539. *
  540. * 10 15 2010 cp.wu
  541. * [WCXRP00000103] [MT6620 Wi-Fi][Driver] Driver crashed when using WZC to connect to AP#B with connection with AP#A
  542. * bugfix: always reset pointer to IEbuf to zero when keeping scanning result for the connected AP
  543. *
  544. * 10 08 2010 cp.wu
  545. * [WCXRP00000084] [MT6620 Wi-Fi][Driver][FW] Add fixed rate support for distance test
  546. * adding fixed rate support for distance test. (from registry setting)
  547. *
  548. * 10 07 2010 cp.wu
  549. * [WCXRP00000083] [MT5931][Driver][FW] Add necessary logic for MT5931 first connection
  550. * add firmware download for MT5931.
  551. *
  552. * 10 06 2010 cp.wu
  553. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  554. * divide a single function into 2 part to surpress a weird compiler warning from gcc-4.4.0
  555. *
  556. * 10 06 2010 cp.wu
  557. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  558. * code reorganization to improve isolation between GLUE and CORE layers.
  559. *
  560. * 10 05 2010 cp.wu
  561. * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
  562. * load manufacture data when CFG_SUPPORT_NVRAM is set to 1
  563. *
  564. * 10 04 2010 cp.wu
  565. * [WCXRP00000077] [MT6620 Wi-Fi][Driver][FW] Eliminate use of ENUM_NETWORK_TYPE_T and replaced
  566. * by ENUM_NETWORK_TYPE_INDEX_T only
  567. * remove ENUM_NETWORK_TYPE_T definitions
  568. *
  569. * 09 29 2010 wh.su
  570. * [WCXRP00000072] [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue
  571. * [MT6620 Wi-Fi][Driver] Fix TKIP Counter Measure EAPoL callback register issue.
  572. *
  573. * 09 24 2010 cp.wu
  574. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  575. * eliminate unused variables which lead gcc to argue
  576. *
  577. * 09 24 2010 cp.wu
  578. * [WCXRP00000057] [MT6620 Wi-Fi][Driver] Modify online scan to a run-time switchable feature
  579. * Modify online scan as a run-time adjustable option (for Windows, in registry)
  580. *
  581. * 09 23 2010 cp.wu
  582. * [WCXRP00000051] [MT6620 Wi-Fi][Driver] WHQL test fail in MAC address changed item
  583. * use firmware reported mac address right after wlanAdapterStart() as permanent address
  584. *
  585. * 09 23 2010 cp.wu
  586. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  587. * eliminate reference of CFG_RESPONSE_MAX_PKT_SIZE
  588. *
  589. * 09 21 2010 cp.wu
  590. * [WCXRP00000053] [MT6620 Wi-Fi][Driver] Reset incomplete and might leads to BSOD when entering RF test with
  591. * AIS associated
  592. * Do a complete reset with STA-REC null checking for RF test re-entry
  593. *
  594. * 09 21 2010 kevin.huang
  595. * [WCXRP00000052] [MT6620 Wi-Fi][Driver] Eliminate Linux Compile Warning
  596. * Eliminate Linux Compile Warning
  597. *
  598. * 09 13 2010 cp.wu
  599. * NULL
  600. * acquire & release power control in oid handing wrapper.
  601. *
  602. * 09 09 2010 cp.wu
  603. * NULL
  604. * move IE to buffer head when the IE pointer is not pointed at head.
  605. *
  606. * 09 08 2010 cp.wu
  607. * NULL
  608. * use static memory pool for storing IEs of scanning result.
  609. *
  610. * 09 01 2010 cp.wu
  611. * NULL
  612. * HIFSYS Clock Source Workaround
  613. *
  614. * 09 01 2010 wh.su
  615. * NULL
  616. * adding the wapi support for integration test.
  617. *
  618. * 09 01 2010 cp.wu
  619. * NULL
  620. * move HIF CR initialization from where after sdioSetupCardFeature() to wlanAdapterStart()
  621. *
  622. * 08 30 2010 cp.wu
  623. * NULL
  624. * eliminate klockwork errors
  625. *
  626. * 08 26 2010 yuche.tsai
  627. * NULL
  628. * Add AT GO test configure mode under WinXP.
  629. * Please enable 1. CFG_ENABLE_WIFI_DIRECT, 2. CFG_TEST_WIFI_DIRECT_GO, 3. CFG_SUPPORT_AAA
  630. *
  631. * 08 25 2010 george.huang
  632. * NULL
  633. * update OID/ registry control path for PM related settings
  634. *
  635. * 08 24 2010 cp.wu
  636. * NULL
  637. * 1) initialize variable for enabling short premable/short time slot.
  638. * 2) add compile option for disabling online scan
  639. *
  640. * 08 13 2010 cp.wu
  641. * NULL
  642. * correction issue: desired phy type not initialized as ABGN mode.
  643. *
  644. * 08 12 2010 cp.wu
  645. * NULL
  646. * [AIS-FSM] honor registry setting for adhoc running mode. (A/B/G)
  647. *
  648. * 08 10 2010 cm.chang
  649. * NULL
  650. * Support EEPROM read/write in RF test mode
  651. *
  652. * 08 03 2010 cp.wu
  653. * NULL
  654. * surpress compilation warning.
  655. *
  656. * 08 03 2010 cp.wu
  657. * NULL
  658. * Centralize mgmt/system service procedures into independent calls.
  659. *
  660. * 07 30 2010 cp.wu
  661. * NULL
  662. * 1) BoW wrapper: use definitions instead of hard-coded constant for error code
  663. * 2) AIS-FSM: eliminate use of desired RF parameters, use prTargetBssDesc instead
  664. * 3) add handling for RX_PKT_DESTINATION_HOST_WITH_FORWARD for GO-broadcast frames
  665. *
  666. * 07 29 2010 cp.wu
  667. * NULL
  668. * eliminate u4FreqInKHz usage, combined into rConnections.ucAdHoc*
  669. *
  670. * 07 28 2010 cp.wu
  671. * NULL
  672. * 1) eliminate redundant variable eOPMode in prAdapter->rWlanInfo
  673. * 2) change nicMediaStateChange() API prototype
  674. *
  675. * 07 21 2010 cp.wu
  676. *
  677. * 1) change BG_SCAN to ONLINE_SCAN for consistent term
  678. * 2) only clear scanning result when scan is permitted to do
  679. *
  680. * 07 19 2010 cm.chang
  681. *
  682. * Set RLM parameters and enable CNM channel manager
  683. *
  684. * 07 19 2010 jeffrey.chang
  685. *
  686. * Linux port modification
  687. *
  688. * 07 13 2010 cp.wu
  689. *
  690. * [WPD00003833] [MT6620 and MT5931] Driver migration.
  691. * Reduce unnecessary type casting
  692. *
  693. * 07 13 2010 cp.wu
  694. *
  695. * use multiple queues to keep 1x/MMPDU/CMD's strict order even when there is incoming 1x frames.
  696. *
  697. * 07 13 2010 cp.wu
  698. *
  699. * 1) MMPDUs are now sent to MT6620 by CMD queue for keeping strict order of 1X/MMPDU/CMD packets
  700. * 2) integrate with qmGetFrameAction() for deciding which MMPDU/1X could pass checking for sending
  701. * 2) enhance CMD_INFO_T descriptor number from 10 to 32 to avoid descriptor underflow under concurrent
  702. * network operation
  703. *
  704. * 07 08 2010 cp.wu
  705. *
  706. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  707. *
  708. * 07 05 2010 cp.wu
  709. * [WPD00003833][MT6620 and MT5931] Driver migration
  710. * 1) ignore RSN checking when RSN is not turned on.
  711. * 2) set STA-REC deactivation callback as NULL
  712. * 3) add variable initialization API based on PHY configuration
  713. *
  714. * 07 02 2010 cp.wu
  715. * [WPD00003833][MT6620 and MT5931] Driver migration
  716. * 1) for event packet, no need to fill RFB.
  717. * 2) when wlanAdapterStart() failed, no need to initialize state machines
  718. * 3) after Beacon/ProbeResp parsing, corresponding BSS_DESC_T should be marked as IE-parsed
  719. *
  720. * 07 01 2010 cm.chang
  721. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  722. * Support sync command of STA_REC
  723. *
  724. * 07 01 2010 cp.wu
  725. * [WPD00003833][MT6620 and MT5931] Driver migration
  726. * add scan uninitialization procedure
  727. *
  728. * 06 25 2010 cp.wu
  729. * [WPD00003833][MT6620 and MT5931] Driver migration
  730. * add API in que_mgt to retrieve sta-rec index for security frames.
  731. *
  732. * 06 24 2010 cp.wu
  733. * [WPD00003833][MT6620 and MT5931] Driver migration
  734. * 802.1x and bluetooth-over-Wi-Fi security frames are now delievered to firmware via command path instead of data path.
  735. *
  736. * 06 23 2010 yarco.yang
  737. * [WPD00003837][MT6620]Data Path Refine
  738. * Merge g_arStaRec[] into adapter->arStaRec[]
  739. *
  740. * 06 21 2010 cp.wu
  741. * [WPD00003833][MT6620 and MT5931] Driver migration
  742. * initialize mbox & ais_fsm in wlanAdapterStart()
  743. *
  744. * 06 21 2010 cp.wu
  745. * [WPD00003833][MT6620 and MT5931] Driver migration
  746. * change MAC address updating logic.
  747. *
  748. * 06 21 2010 cp.wu
  749. * [WPD00003833][MT6620 and MT5931] Driver migration
  750. * simplify timer usage.
  751. *
  752. * 06 11 2010 cp.wu
  753. * [WPD00003833][MT6620 and MT5931] Driver migration
  754. * 1) migrate assoc.c.
  755. * 2) add ucTxSeqNum for tracking frames which needs TX-DONE awareness
  756. * 3) add configuration options for CNM_MEM and RSN modules
  757. * 4) add data path for management frames
  758. * 5) eliminate rPacketInfo of MSDU_INFO_T
  759. *
  760. * 06 10 2010 cp.wu
  761. * [WPD00003833][MT6620 and MT5931] Driver migration
  762. * 1) eliminate CFG_CMD_EVENT_VERSION_0_9
  763. * 2) when disconnected, indicate nic directly (no event is needed)
  764. *
  765. * 06 08 2010 cp.wu
  766. * [WPD00003833][MT6620 and MT5931] Driver migration
  767. * cnm_timer has been migrated.
  768. *
  769. * 06 06 2010 kevin.huang
  770. * [WPD00003832][MT6620 5931] Create driver base
  771. * [MT6620 5931] Create driver base
  772. *
  773. * 05 28 2010 cp.wu
  774. * [WPD00001943]Create WiFi test driver framework on WinXP
  775. * disable interrupt then send power control command packet.
  776. *
  777. * 05 24 2010 cp.wu
  778. * [WPD00001943]Create WiFi test driver framework on WinXP
  779. * 1) when stopping adapter, wait til RDY bit has been cleaerd.
  780. * 2) set TASK_OFFLOAD as driver-core OIDs
  781. *
  782. * 05 20 2010 cp.wu
  783. * [WPD00001943]Create WiFi test driver framework on WinXP
  784. * 1) integrate OID_GEN_NETWORK_LAYER_ADDRESSES with CMD_ID_SET_IP_ADDRESS
  785. * 2) buffer statistics data for 2 seconds
  786. * 3) use default value for adhoc parameters instead of 0
  787. *
  788. * 05 19 2010 cp.wu
  789. * [WPD00001943]Create WiFi test driver framework on WinXP
  790. * 1) do not take timeout mechanism for power mode oids
  791. * 2) retrieve network type from connection status
  792. * 3) after disassciation, set radio state to off
  793. * 4) TCP option over IPv6 is supported
  794. *
  795. * 05 17 2010 cp.wu
  796. * [WPD00001943]Create WiFi test driver framework on WinXP
  797. * add CFG_STARTUP_DEBUG for debugging starting up issue.
  798. *
  799. * 05 17 2010 cp.wu
  800. * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
  801. * 1) add timeout handler mechanism for pending command packets
  802. * 2) add p2p add/removal key
  803. *
  804. * 04 23 2010 cp.wu
  805. * [WPD00001943]Create WiFi test driver framework on WinXP
  806. * surpress compiler warning
  807. *
  808. * 04 20 2010 cp.wu
  809. * [WPD00001943]Create WiFi test driver framework on WinXP
  810. * roll-back to rev.60.
  811. *
  812. * 04 20 2010 cp.wu
  813. * [WPD00001943]Create WiFi test driver framework on WinXP
  814. * 1) remove redundant firmware image unloading
  815. * 2) use compile-time macros to separate logic related to accquiring own
  816. *
  817. * 04 16 2010 cp.wu
  818. * [WPD00001943]Create WiFi test driver framework on WinXP
  819. * treat BUS access failure as kind of card removal.
  820. *
  821. * 04 14 2010 cp.wu
  822. * [WPD00001943]Create WiFi test driver framework on WinXP
  823. * always set fw-own before driver is unloaded.
  824. *
  825. * 04 13 2010 cp.wu
  826. * [WPD00003823][MT6620 Wi-Fi] Add Bluetooth-over-Wi-Fi support
  827. * add framework for BT-over-Wi-Fi support.
  828. * * * 1) prPendingCmdInfo is replaced by queue for multiple handler capability
  829. * * * 2) command sequence number is now increased atomically
  830. * * * 3) private data could be hold and taken use for other purpose
  831. *
  832. * 04 07 2010 cp.wu
  833. * [WPD00001943]Create WiFi test driver framework on WinXP
  834. * finish non-glue layer access to glue variables
  835. *
  836. * 04 07 2010 cp.wu
  837. * [WPD00001943]Create WiFi test driver framework on WinXP
  838. * rWlanInfo should be placed at adapter rather than glue due to most operations
  839. * are done in adapter layer.
  840. *
  841. * 04 06 2010 cp.wu
  842. * [WPD00001943]Create WiFi test driver framework on WinXP
  843. * ePowerCtrl is not necessary as a glue variable.
  844. *
  845. * 04 06 2010 jeffrey.chang
  846. * [WPD00003826]Initial import for Linux port
  847. * add timeout check in the kalOidComplete
  848. *
  849. * 04 06 2010 jeffrey.chang
  850. * [WPD00003826]Initial import for Linux port
  851. * improve none-glue code portability
  852. *
  853. * 04 06 2010 jeffrey.chang
  854. * [WPD00003826]Initial import for Linux port
  855. * improve none-glue code portability
  856. *
  857. * 04 06 2010 cp.wu
  858. * [WPD00001943]Create WiFi test driver framework on WinXP
  859. * code refine: fgTestMode should be at adapter rather than glue due to the device/fw is also involved
  860. *
  861. * 04 06 2010 cp.wu
  862. * [WPD00001943]Create WiFi test driver framework on WinXP
  863. * eliminate direct access for prGlueInfo->fgIsCardRemoved in non-glue layer
  864. *
  865. * 04 06 2010 cp.wu
  866. * [WPD00001943]Create WiFi test driver framework on WinXP
  867. * 1) for some OID, never do timeout expiration
  868. * 2) add 2 kal API for later integration
  869. *
  870. * 04 06 2010 cp.wu
  871. * [WPD00001943]Create WiFi test driver framework on WinXP
  872. * 1) eliminate unused definitions
  873. * 2) ready bit will be polled for limited iteration
  874. *
  875. * 04 06 2010 jeffrey.chang
  876. * [WPD00003826]Initial import for Linux port
  877. * kalOidComplete is not necessary in linux
  878. *
  879. * 04 01 2010 cp.wu
  880. * [WPD00001943]Create WiFi test driver framework on WinXP
  881. * change to use pass-in prRegInfo instead of accessing prGlueInfo directly
  882. *
  883. * 04 01 2010 cp.wu
  884. * [WPD00001943]Create WiFi test driver framework on WinXP
  885. * change to use WIFI_TCM_ALWAYS_ON as firmware image
  886. *
  887. * 04 01 2010 cp.wu
  888. * [WPD00001943]Create WiFi test driver framework on WinXP
  889. * .
  890. *
  891. * 03 31 2010 wh.su
  892. * [WPD00003816][MT6620 Wi-Fi] Adding the security support
  893. * modify the wapi related code for new driver's design.
  894. *
  895. * 03 30 2010 jeffrey.chang
  896. * [WPD00003826]Initial import for Linux port
  897. * adding none-glue code portability
  898. *
  899. * 03 30 2010 jeffrey.chang
  900. * [WPD00003826]Initial import for Linux port
  901. * adding non-glue code portability
  902. *
  903. * 03 29 2010 jeffrey.chang
  904. * [WPD00003826]Initial import for Linux port
  905. * improve non-glue code portability
  906. *
  907. * 03 25 2010 cp.wu
  908. * [WPD00001943]Create WiFi test driver framework on WinXP
  909. * firmware download load address & start address are now configured from config.h
  910. * due to the different configurations on FPGA and ASIC
  911. *
  912. * 03 24 2010 jeffrey.chang
  913. * [WPD00003826]Initial import for Linux port
  914. * [WPD00003826] Initial import for Linux port
  915. * initial import for Linux port
  916. *
  917. * 03 24 2010 jeffrey.chang
  918. * [WPD00003826]Initial import for Linux port
  919. * initial import for Linux port
  920. *
  921. * 03 22 2010 cp.wu
  922. * [WPD00001943]Create WiFi test driver framework on WinXP
  923. * only send CMD_NIC_POWER_CTRL in wlanAdapterStop() when card is not removed and is not in D3 state
  924. *
  925. * 03 22 2010 cp.wu
  926. * [WPD00001943]Create WiFi test driver framework on WinXP
  927. * always send CMD_NIC_POWER_CTRL packet when nic is being halted
  928. *
  929. * 03 19 2010 cp.wu
  930. * [WPD00001943]Create WiFi test driver framework on WinXP
  931. * 1) add ACPI D0/D3 state switching support
  932. * 2) use more formal way to handle interrupt when the status is retrieved from enhanced RX response
  933. *
  934. * 03 12 2010 cp.wu
  935. * [WPD00001943]Create WiFi test driver framework on WinXP
  936. * add two option for ACK and ENCRYPTION for firmware download
  937. *
  938. * 03 11 2010 cp.wu
  939. * [WPD00003821][BUG] Host driver stops processing RX packets from HIF RX0
  940. * add RX starvation warning debug message controlled by CFG_HIF_RX_STARVATION_WARNING
  941. *
  942. * 03 08 2010 cp.wu
  943. * [WPD00001943]Create WiFi test driver framework on WinXP
  944. * 1) add another spin-lock to protect MsduInfoList due to it might be accessed by different thread.
  945. * 2) change own-back acquiring procedure to wait for up to 16.67 seconds
  946. *
  947. * 03 03 2010 cp.wu
  948. * [WPD00001943]Create WiFi test driver framework on WinXP
  949. * when starting adapter, read local adminsitrated address from registry and send to firmware via CMD_BASIC_CONFIG.
  950. *
  951. * 03 02 2010 cp.wu
  952. * [WPD00001943]Create WiFi test driver framework on WinXP
  953. * 1) the use of prPendingOid revised, all accessing are now protected by spin lock
  954. * 2) ensure wlanReleasePendingOid will clear all command queues
  955. *
  956. * 03 02 2010 cp.wu
  957. * [WPD00001943]Create WiFi test driver framework on WinXP
  958. * add mutex to avoid multiple access to qmTxQueue simultaneously.
  959. *
  960. * 03 01 2010 cp.wu
  961. * [WPD00001943]Create WiFi test driver framework on WinXP
  962. * add command/event definitions for initial states
  963. *
  964. * 02 24 2010 tehuang.liu
  965. * [WPD00001943]Create WiFi test driver framework on WinXP
  966. * Added code for QM_TEST_MODE
  967. *
  968. * 02 24 2010 cp.wu
  969. * [WPD00001943]Create WiFi test driver framework on WinXP
  970. * correct function name ..
  971. *
  972. * 02 24 2010 cp.wu
  973. * [WPD00001943]Create WiFi test driver framework on WinXP
  974. * separate wlanProcesQueuePacket() into 2 APIs upon request
  975. *
  976. * 02 23 2010 cp.wu
  977. * [WPD00001943]Create WiFi test driver framework on WinXP
  978. * add new API: wlanProcessQueuedPackets()
  979. *
  980. * 02 11 2010 cp.wu
  981. * [WPD00001943]Create WiFi test driver framework on WinXP
  982. * correct wlanAdapterStart
  983. *
  984. * 02 11 2010 cp.wu
  985. * [WPD00001943]Create WiFi test driver framework on WinXP
  986. * 1. add logic for firmware download
  987. * 2. firmware image filename and start/load address are now retrieved from registry
  988. *
  989. * 02 10 2010 cp.wu
  990. * [WPD00001943]Create WiFi test driver framework on WinXP
  991. * implement host-side firmware download logic
  992. *
  993. * 02 10 2010 cp.wu
  994. * [WPD00001943]Create WiFi test driver framework on WinXP
  995. * 1) remove unused function in nic_rx.c [which has been handled in que_mgt.c]
  996. * 2) firmware image length is now retrieved via NdisFileOpen
  997. * 3) firmware image is not structured by (P_IMG_SEC_HDR_T) anymore
  998. * 4) nicRxWaitResponse() revised
  999. * 5) another set of TQ counter default value is added for fw-download state
  1000. * 6) Wi-Fi load address is now retrieved from registry too
  1001. *
  1002. * 02 09 2010 cp.wu
  1003. * [WPD00001943]Create WiFi test driver framework on WinXP
  1004. * 1. Permanent and current MAC address are now retrieved by CMD/EVENT packets instead of hard-coded address
  1005. * 2. follow MSDN defined behavior when associates to another AP
  1006. * 3. for firmware download, packet size could be up to 2048 bytes
  1007. *
  1008. * 02 08 2010 cp.wu
  1009. * [WPD00001943]Create WiFi test driver framework on WinXP
  1010. * prepare for implementing fw download logic
  1011. *
  1012. * 02 03 2010 cp.wu
  1013. * [WPD00001943]Create WiFi test driver framework on WinXP
  1014. * wlanoidSetFrequency is now implemented by RF test command.
  1015. *
  1016. * 02 03 2010 cp.wu
  1017. * [WPD00001943]Create WiFi test driver framework on WinXP
  1018. * QueryRssi is no longer w/o hardware access, it is now implemented by command/event handling loop
  1019. *
  1020. * 02 03 2010 cp.wu
  1021. * [WPD00001943]Create WiFi test driver framework on WinXP
  1022. * 1. clear prPendingCmdInfo properly
  1023. * 2. while allocating memory for cmdinfo, no need to add extra 4 bytes.
  1024. *
  1025. * 01 28 2010 cp.wu
  1026. * [WPD00001943]Create WiFi test driver framework on WinXP
  1027. * allow MCR read/write OIDs in RF test mode
  1028. *
  1029. * 01 27 2010 cp.wu
  1030. * [WPD00001943]Create WiFi test driver framework on WinXP
  1031. * 1) implement timeout mechanism when OID is pending for longer than 1 second
  1032. * 2) allow OID_802_11_CONFIGURATION to be executed when RF test mode is turned on
  1033. *
  1034. * 01 27 2010 cp.wu
  1035. * [WPD00001943]Create WiFi test driver framework on WinXP
  1036. * 1. eliminate improper variable in rHifInfo
  1037. * 2. block TX/ordinary OID when RF test mode is engaged
  1038. * 3. wait until firmware finish operation when entering into and leaving from RF test mode
  1039. * 4. correct some HAL implementation
  1040. *
  1041. * 01 26 2010 cp.wu
  1042. * [WPD00001943]Create WiFi test driver framework on WinXP
  1043. * Under WinXP with SDIO, use prGlueInfo->rHifInfo.pvInformationBuffer instead of prGlueInfo->pvInformationBuffer
  1044. ** \main\maintrunk.MT6620WiFiDriver_Prj\36 2009-12-10 16:54:36 GMT mtk02752
  1045. ** code clean
  1046. ** \main\maintrunk.MT6620WiFiDriver_Prj\35 2009-12-09 20:04:59 GMT mtk02752
  1047. ** only report as connected when CFG_HIF_EMULATION_TEST is set to 1
  1048. ** \main\maintrunk.MT6620WiFiDriver_Prj\34 2009-12-08 17:39:41 GMT mtk02752
  1049. ** wlanoidRftestQueryAutoTest could be executed without touching hardware
  1050. ** \main\maintrunk.MT6620WiFiDriver_Prj\33 2009-12-03 16:10:26 GMT mtk01461
  1051. ** Add debug message
  1052. ** \main\maintrunk.MT6620WiFiDriver_Prj\32 2009-12-02 22:05:33 GMT mtk02752
  1053. ** kalOidComplete() will decrease i4OidPendingCount
  1054. ** \main\maintrunk.MT6620WiFiDriver_Prj\31 2009-12-01 23:02:36 GMT mtk02752
  1055. ** remove unnecessary spinlock
  1056. ** \main\maintrunk.MT6620WiFiDriver_Prj\30 2009-12-01 22:50:38 GMT mtk02752
  1057. ** use TC4 for command, maintein i4OidPendingCount
  1058. ** \main\maintrunk.MT6620WiFiDriver_Prj\29 2009-11-27 12:45:34 GMT mtk02752
  1059. ** prCmdInfo should be freed when invoking wlanReleasePendingOid() to clear pending oid
  1060. ** \main\maintrunk.MT6620WiFiDriver_Prj\28 2009-11-24 19:55:51 GMT mtk02752
  1061. ** wlanSendPacket & wlanRetransmitOfPendingFrames is only used in old data path
  1062. ** \main\maintrunk.MT6620WiFiDriver_Prj\27 2009-11-23 17:59:55 GMT mtk02752
  1063. ** clear prPendingOID inside wlanSendCommand() when the OID didn't need to be replied.
  1064. ** \main\maintrunk.MT6620WiFiDriver_Prj\26 2009-11-23 14:45:29 GMT mtk02752
  1065. ** add another version of wlanSendCommand() for command-sending only without blocking for response
  1066. ** \main\maintrunk.MT6620WiFiDriver_Prj\25 2009-11-17 22:40:44 GMT mtk01084
  1067. ** \main\maintrunk.MT6620WiFiDriver_Prj\24 2009-11-11 10:14:56 GMT mtk01084
  1068. ** modify place to invoke wlanIst
  1069. ** \main\maintrunk.MT6620WiFiDriver_Prj\23 2009-10-30 18:17:07 GMT mtk01084
  1070. ** fix compiler warning
  1071. ** \main\maintrunk.MT6620WiFiDriver_Prj\22 2009-10-29 19:46:15 GMT mtk01084
  1072. ** invoke interrupt process routine
  1073. ** \main\maintrunk.MT6620WiFiDriver_Prj\21 2009-10-13 21:58:24 GMT mtk01084
  1074. ** modify for new HW architecture
  1075. ** \main\maintrunk.MT6620WiFiDriver_Prj\20 2009-09-09 17:26:01 GMT mtk01084
  1076. ** \main\maintrunk.MT6620WiFiDriver_Prj\19 2009-05-20 12:21:27 GMT mtk01461
  1077. ** Add SeqNum check when process Event Packet
  1078. ** \main\maintrunk.MT6620WiFiDriver_Prj\18 2009-05-19 10:38:44 GMT mtk01461
  1079. ** Add wlanReleasePendingOid() for mpReset() if there is a pending OID and no available TX resource to send it.
  1080. ** \main\maintrunk.MT6620WiFiDriver_Prj\17 2009-04-29 15:41:34 GMT mtk01461
  1081. ** Add handle of EVENT of CMD Result in wlanSendCommand()
  1082. ** \main\maintrunk.MT6620WiFiDriver_Prj\16 2009-04-22 09:11:23 GMT mtk01461
  1083. ** Fix wlanSendCommand() for Driver Domain CR
  1084. ** \main\maintrunk.MT6620WiFiDriver_Prj\15 2009-04-21 09:33:56 GMT mtk01461
  1085. ** Update wlanSendCommand() for Driver Domain Response and handle Event Packet,
  1086. ** wlanQuery/SetInformation() for enqueue CMD_INFO_T
  1087. ** \main\maintrunk.MT6620WiFiDriver_Prj\14 2009-04-17 20:00:08 GMT mtk01461
  1088. ** Update wlanImageSectionDownload for optimized CMD process
  1089. ** \main\maintrunk.MT6620WiFiDriver_Prj\13 2009-04-14 20:50:51 GMT mtk01426
  1090. ** Fixed compile error
  1091. ** \main\maintrunk.MT6620WiFiDriver_Prj\12 2009-04-13 16:38:40 GMT mtk01084
  1092. ** add wifi start function
  1093. ** \main\maintrunk.MT6620WiFiDriver_Prj\11 2009-04-13 14:26:44 GMT mtk01084
  1094. ** modify a parameter about FW download length
  1095. ** \main\maintrunk.MT6620WiFiDriver_Prj\10 2009-04-10 21:53:42 GMT mtk01461
  1096. ** Update wlanSendCommand()
  1097. ** \main\maintrunk.MT6620WiFiDriver_Prj\9 2009-04-08 16:51:04 GMT mtk01084
  1098. ** Update for the image download part
  1099. ** \main\maintrunk.MT6620WiFiDriver_Prj\8 2009-04-01 10:32:47 GMT mtk01461
  1100. ** Add wlanSendLeftClusteredFrames() for SDIO_TX_ENHANCE
  1101. ** \main\maintrunk.MT6620WiFiDriver_Prj\7 2009-03-23 21:44:13 GMT mtk01461
  1102. ** Refine TC assignment for WmmAssoc flag
  1103. ** \main\maintrunk.MT6620WiFiDriver_Prj\6 2009-03-23 16:51:57 GMT mtk01084
  1104. ** modify the input argument of caller to RECLAIM_POWER_CONTROL_TO_PM()
  1105. ** \main\maintrunk.MT6620WiFiDriver_Prj\5 2009-03-23 00:27:13 GMT mtk01461
  1106. ** Add reference code of FW Image Download
  1107. ** \main\maintrunk.MT6620WiFiDriver_Prj\4 2009-03-19 18:32:37 GMT mtk01084
  1108. ** update for basic power management functions
  1109. ** \main\maintrunk.MT6620WiFiDriver_Prj\3 2009-03-16 09:09:08 GMT mtk01461
  1110. ** Update TX PATH API
  1111. ** \main\maintrunk.MT6620WiFiDriver_Prj\2 2009-03-10 16:28:45 GMT mtk01426
  1112. ** Init develop
  1113. **
  1114. */
  1115. /*******************************************************************************
  1116. * C O M P I L E R F L A G S
  1117. ********************************************************************************
  1118. */
  1119. /*******************************************************************************
  1120. * E X T E R N A L R E F E R E N C E S
  1121. ********************************************************************************
  1122. */
  1123. #include "precomp.h"
  1124. #include "mgmt/ais_fsm.h"
  1125. /*******************************************************************************
  1126. * C O N S T A N T S
  1127. ********************************************************************************
  1128. */
  1129. /* 6.1.1.2 Interpretation of priority parameter in MAC service primitives */
  1130. /* Static convert the Priority Parameter/TID(User Priority/TS Identifier) to Traffic Class */
  1131. const UINT_8 aucPriorityParam2TC[] = {
  1132. TC1_INDEX,
  1133. TC0_INDEX,
  1134. TC0_INDEX,
  1135. TC1_INDEX,
  1136. TC2_INDEX,
  1137. TC2_INDEX,
  1138. TC3_INDEX,
  1139. TC3_INDEX
  1140. };
  1141. /*******************************************************************************
  1142. * D A T A T Y P E S
  1143. ********************************************************************************
  1144. */
  1145. typedef struct _CODE_MAPPING_T {
  1146. UINT_32 u4RegisterValue;
  1147. INT_32 u4TxpowerOffset;
  1148. } CODE_MAPPING_T, *P_CODE_MAPPING_T;
  1149. /*******************************************************************************
  1150. * P U B L I C D A T A
  1151. ********************************************************************************
  1152. */
  1153. BOOLEAN fgIsBusAccessFailed = FALSE;
  1154. /*******************************************************************************
  1155. * P R I V A T E D A T A
  1156. ********************************************************************************
  1157. */
  1158. /*******************************************************************************
  1159. * M A C R O S
  1160. ********************************************************************************
  1161. */
  1162. #define SIGNED_EXTEND(n, _sValue) \
  1163. (((_sValue) & BIT((n)-1)) ? ((_sValue) | BITS(n, 31)) : \
  1164. ((_sValue) & ~BITS(n, 31)))
  1165. /* TODO: Check */
  1166. /* OID set handlers without the need to access HW register */
  1167. PFN_OID_HANDLER_FUNC apfnOidSetHandlerWOHwAccess[] = {
  1168. wlanoidSetChannel,
  1169. wlanoidSetBeaconInterval,
  1170. wlanoidSetAtimWindow,
  1171. wlanoidSetFrequency,
  1172. };
  1173. /* TODO: Check */
  1174. /* OID query handlers without the need to access HW register */
  1175. PFN_OID_HANDLER_FUNC apfnOidQueryHandlerWOHwAccess[] = {
  1176. wlanoidQueryBssid,
  1177. wlanoidQuerySsid,
  1178. wlanoidQueryInfrastructureMode,
  1179. wlanoidQueryAuthMode,
  1180. wlanoidQueryEncryptionStatus,
  1181. wlanoidQueryPmkid,
  1182. wlanoidQueryNetworkTypeInUse,
  1183. wlanoidQueryBssidList,
  1184. wlanoidQueryAcpiDevicePowerState,
  1185. wlanoidQuerySupportedRates,
  1186. wlanoidQueryDesiredRates,
  1187. wlanoidQuery802dot11PowerSaveProfile,
  1188. wlanoidQueryBeaconInterval,
  1189. wlanoidQueryAtimWindow,
  1190. wlanoidQueryFrequency,
  1191. };
  1192. /* OID set handlers allowed in RF test mode */
  1193. PFN_OID_HANDLER_FUNC apfnOidSetHandlerAllowedInRFTest[] = {
  1194. wlanoidRftestSetTestMode,
  1195. wlanoidRftestSetAbortTestMode,
  1196. wlanoidRftestSetAutoTest,
  1197. wlanoidSetMcrWrite,
  1198. wlanoidSetEepromWrite
  1199. };
  1200. /* OID query handlers allowed in RF test mode */
  1201. PFN_OID_HANDLER_FUNC apfnOidQueryHandlerAllowedInRFTest[] = {
  1202. wlanoidRftestQueryAutoTest,
  1203. wlanoidQueryMcrRead,
  1204. wlanoidQueryEepromRead
  1205. }
  1206. ;
  1207. PFN_OID_HANDLER_FUNC apfnOidWOTimeoutCheck[] = {
  1208. wlanoidRftestSetTestMode,
  1209. wlanoidRftestSetAbortTestMode,
  1210. wlanoidSetAcpiDevicePowerState,
  1211. };
  1212. /*******************************************************************************
  1213. * M A C R O S
  1214. ********************************************************************************
  1215. */
  1216. /*******************************************************************************
  1217. * F U N C T I O N D E C L A R A T I O N S
  1218. ********************************************************************************
  1219. */
  1220. static WLAN_STATUS
  1221. wlanImageSectionDownloadStage(IN P_ADAPTER_T prAdapter,
  1222. IN PVOID pvFwImageMapFile, IN UINT_32 index, IN UINT_32 u4FwImageFileLength,
  1223. IN BOOLEAN fgValidHead, IN UINT_32 u4FwLoadAddr);
  1224. /*******************************************************************************
  1225. * F U N C T I O N S
  1226. ********************************************************************************
  1227. */
  1228. /*----------------------------------------------------------------------------*/
  1229. /*!
  1230. * \brief This is a private routine, which is used to check if HW access is needed
  1231. * for the OID query/ set handlers.
  1232. *
  1233. * \param[IN] pfnOidHandler Pointer to the OID handler.
  1234. * \param[IN] fgSetInfo It is a Set information handler.
  1235. *
  1236. * \retval TRUE This function needs HW access
  1237. * \retval FALSE This function does not need HW access
  1238. */
  1239. /*----------------------------------------------------------------------------*/
  1240. BOOLEAN wlanIsHandlerNeedHwAccess(IN PFN_OID_HANDLER_FUNC pfnOidHandler, IN BOOLEAN fgSetInfo)
  1241. {
  1242. PFN_OID_HANDLER_FUNC *apfnOidHandlerWOHwAccess;
  1243. UINT_32 i;
  1244. UINT_32 u4NumOfElem;
  1245. if (fgSetInfo) {
  1246. apfnOidHandlerWOHwAccess = apfnOidSetHandlerWOHwAccess;
  1247. u4NumOfElem = sizeof(apfnOidSetHandlerWOHwAccess) / sizeof(PFN_OID_HANDLER_FUNC);
  1248. } else {
  1249. apfnOidHandlerWOHwAccess = apfnOidQueryHandlerWOHwAccess;
  1250. u4NumOfElem = sizeof(apfnOidQueryHandlerWOHwAccess) / sizeof(PFN_OID_HANDLER_FUNC);
  1251. }
  1252. for (i = 0; i < u4NumOfElem; i++) {
  1253. if (apfnOidHandlerWOHwAccess[i] == pfnOidHandler)
  1254. return FALSE;
  1255. }
  1256. return TRUE;
  1257. } /* wlanIsHandlerNeedHwAccess */
  1258. /*----------------------------------------------------------------------------*/
  1259. /*!
  1260. * \brief This routine is called to set flag for later handling card
  1261. * ejected event.
  1262. *
  1263. * \param[in] prAdapter Pointer to the Adapter structure.
  1264. *
  1265. * \return (none)
  1266. *
  1267. * \note When surprised removal happens, Glue layer should invoke this
  1268. * function to notify WPDD not to do any hw access.
  1269. */
  1270. /*----------------------------------------------------------------------------*/
  1271. VOID wlanCardEjected(IN P_ADAPTER_T prAdapter)
  1272. {
  1273. DEBUGFUNC("wlanCardEjected");
  1274. /* INITLOG(("\n")); */
  1275. ASSERT(prAdapter);
  1276. /* mark that the card is being ejected, NDIS will shut us down soon */
  1277. nicTxRelease(prAdapter, FALSE);
  1278. } /* wlanCardEjected */
  1279. /*----------------------------------------------------------------------------*/
  1280. /*!
  1281. * \brief Create adapter object
  1282. *
  1283. * \param prAdapter This routine is call to allocate the driver software objects.
  1284. * If fails, return NULL.
  1285. * \retval NULL If it fails, NULL is returned.
  1286. * \retval NOT NULL If the adapter was initialized successfully.
  1287. */
  1288. /*----------------------------------------------------------------------------*/
  1289. P_ADAPTER_T wlanAdapterCreate(IN P_GLUE_INFO_T prGlueInfo)
  1290. {
  1291. P_ADAPTER_T prAdpater = (P_ADAPTER_T) NULL;
  1292. DEBUGFUNC("wlanAdapterCreate");
  1293. do {
  1294. prAdpater = (P_ADAPTER_T) kalMemAlloc(sizeof(ADAPTER_T), VIR_MEM_TYPE);
  1295. if (!prAdpater) {
  1296. DBGLOG(INIT, ERROR, "Allocate ADAPTER memory ==> FAILED\n");
  1297. break;
  1298. }
  1299. #if QM_TEST_MODE
  1300. g_rQM.prAdapter = prAdpater;
  1301. #endif
  1302. kalMemZero(prAdpater, sizeof(ADAPTER_T));
  1303. prAdpater->prGlueInfo = prGlueInfo;
  1304. } while (FALSE);
  1305. return prAdpater;
  1306. } /* wlanAdapterCreate */
  1307. /*----------------------------------------------------------------------------*/
  1308. /*!
  1309. * \brief Destroy adapter object
  1310. *
  1311. * \param prAdapter This routine is call to destroy the driver software objects.
  1312. * If fails, return NULL.
  1313. * \return (none)
  1314. */
  1315. /*----------------------------------------------------------------------------*/
  1316. VOID wlanAdapterDestroy(IN P_ADAPTER_T prAdapter)
  1317. {
  1318. if (!prAdapter)
  1319. return;
  1320. kalMemFree(prAdapter, VIR_MEM_TYPE, sizeof(ADAPTER_T));
  1321. }
  1322. /*----------------------------------------------------------------------------*/
  1323. /*!
  1324. * \brief Initialize the adapter. The sequence is
  1325. * 1. Disable interrupt
  1326. * 2. Read adapter configuration from EEPROM and registry, verify chip ID.
  1327. * 3. Create NIC Tx/Rx resource.
  1328. * 4. Initialize the chip
  1329. * 5. Initialize the protocol
  1330. * 6. Enable Interrupt
  1331. *
  1332. * \param prAdapter Pointer of Adapter Data Structure
  1333. *
  1334. * \retval WLAN_STATUS_SUCCESS: Success
  1335. * \retval WLAN_STATUS_FAILURE: Failed
  1336. */
  1337. /*----------------------------------------------------------------------------*/
  1338. WLAN_STATUS
  1339. wlanAdapterStart(IN P_ADAPTER_T prAdapter,
  1340. IN P_REG_INFO_T prRegInfo, IN PVOID pvFwImageMapFile, IN UINT_32 u4FwImageFileLength)
  1341. {
  1342. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  1343. UINT_32 i, u4Value = 0;
  1344. UINT_32 u4WHISR = 0;
  1345. UINT_16 au2TxCount[16];
  1346. #if CFG_ENABLE_FW_DOWNLOAD
  1347. UINT_32 u4FwLoadAddr;
  1348. #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
  1349. P_FIRMWARE_DIVIDED_DOWNLOAD_T prFwHead;
  1350. BOOLEAN fgValidHead;
  1351. const UINT_32 u4CRCOffset = offsetof(FIRMWARE_DIVIDED_DOWNLOAD_T, u4NumOfEntries);
  1352. #endif
  1353. #endif
  1354. ASSERT(prAdapter);
  1355. DEBUGFUNC("wlanAdapterStart");
  1356. /* 4 <0> Reset variables in ADAPTER_T */
  1357. /* prAdapter->fgIsFwOwn = TRUE; */
  1358. prAdapter->fgIsEnterD3ReqIssued = FALSE;
  1359. prAdapter->u4OwnFailedCount = 0;
  1360. prAdapter->u4OwnFailedLogCount = 0;
  1361. QUEUE_INITIALIZE(&(prAdapter->rPendingCmdQueue));
  1362. #if CFG_SUPPORT_MULTITHREAD
  1363. QUEUE_INITIALIZE(&prAdapter->rTxCmdQueue);
  1364. QUEUE_INITIALIZE(&prAdapter->rTxCmdDoneQueue);
  1365. QUEUE_INITIALIZE(&prAdapter->rTxP0Queue);
  1366. QUEUE_INITIALIZE(&prAdapter->rTxP1Queue);
  1367. QUEUE_INITIALIZE(&prAdapter->rRxQueue);
  1368. #endif
  1369. /* Initialize rWlanInfo */
  1370. kalMemSet(&(prAdapter->rWlanInfo), 0, sizeof(WLAN_INFO_T));
  1371. /* Initialize aprBssInfo[].
  1372. * Important: index shall be same when mapping between aprBssInfo[]
  1373. * and arBssInfoPool[]. rP2pDevInfo is indexed to final one.
  1374. */
  1375. for (i = 0; i < BSS_INFO_NUM; i++)
  1376. prAdapter->aprBssInfo[i] = &prAdapter->rWifiVar.arBssInfoPool[i];
  1377. prAdapter->aprBssInfo[P2P_DEV_BSS_INDEX] = &prAdapter->rWifiVar.rP2pDevInfo;
  1378. /* 4 <0.1> reset fgIsBusAccessFailed */
  1379. fgIsBusAccessFailed = FALSE;
  1380. do {
  1381. u4Status = nicAllocateAdapterMemory(prAdapter);
  1382. if (u4Status != WLAN_STATUS_SUCCESS) {
  1383. DBGLOG(INIT, ERROR, "nicAllocateAdapterMemory Error!\n");
  1384. u4Status = WLAN_STATUS_FAILURE;
  1385. break;
  1386. }
  1387. prAdapter->u4OsPacketFilter = PARAM_PACKET_FILTER_SUPPORTED;
  1388. #if defined(MT6630)
  1389. DBGLOG(INIT, TRACE, "wlanAdapterStart(): Acquiring LP-OWN\n");
  1390. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  1391. DBGLOG(INIT, TRACE, "wlanAdapterStart(): Acquiring LP-OWN-end\n");
  1392. #if !CFG_ENABLE_FULL_PM
  1393. nicpmSetDriverOwn(prAdapter);
  1394. #endif
  1395. if (prAdapter->fgIsFwOwn == TRUE) {
  1396. DBGLOG(INIT, ERROR, "nicpmSetDriverOwn() failed!\n");
  1397. u4Status = WLAN_STATUS_FAILURE;
  1398. break;
  1399. }
  1400. /* 4 <1> Initialize the Adapter */
  1401. u4Status = nicInitializeAdapter(prAdapter);
  1402. if (u4Status != WLAN_STATUS_SUCCESS) {
  1403. DBGLOG(INIT, ERROR, "nicInitializeAdapter failed!\n");
  1404. u4Status = WLAN_STATUS_FAILURE;
  1405. break;
  1406. }
  1407. #endif
  1408. /* 4 <2.1> Initialize System Service (MGMT Memory pool and STA_REC) */
  1409. nicInitSystemService(prAdapter);
  1410. /* 4 <2.2> Initialize Feature Options */
  1411. wlanInitFeatureOption(prAdapter);
  1412. #if CFG_SUPPORT_MTK_SYNERGY
  1413. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE) {
  1414. if (prRegInfo->prNvramSettings->u2FeatureReserved & BIT(MTK_FEATURE_2G_256QAM_DISABLED))
  1415. prAdapter->rWifiVar.aucMtkFeature[0] &= ~(MTK_SYNERGY_CAP_SUPPORT_24G_MCS89);
  1416. }
  1417. #endif
  1418. /* 4 <2.3> Overwrite debug level settings */
  1419. wlanCfgSetDebugLevel(prAdapter);
  1420. /* 4 <3> Initialize Tx */
  1421. nicTxInitialize(prAdapter);
  1422. wlanDefTxPowerCfg(prAdapter);
  1423. /* 4 <4> Initialize Rx */
  1424. nicRxInitialize(prAdapter);
  1425. #if CFG_ENABLE_FW_DOWNLOAD
  1426. #if defined(MT6630)
  1427. if (pvFwImageMapFile) {
  1428. /* 1. disable interrupt, download is done by polling mode only */
  1429. nicDisableInterrupt(prAdapter);
  1430. /* 2. Initialize Tx Resource to fw download state */
  1431. nicTxInitResetResource(prAdapter);
  1432. /* 3. FW download here */
  1433. u4FwLoadAddr = prRegInfo->u4LoadAddress;
  1434. DBGLOG(INIT, INFO, "FW download Start\n");
  1435. #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
  1436. /* 3a. parse file header for decision of divided firmware download or not */
  1437. prFwHead = (P_FIRMWARE_DIVIDED_DOWNLOAD_T) pvFwImageMapFile;
  1438. if (prFwHead->u4Signature == MTK_WIFI_SIGNATURE &&
  1439. prFwHead->u4CRC == wlanCRC32((PUINT_8) pvFwImageMapFile + u4CRCOffset,
  1440. u4FwImageFileLength - u4CRCOffset)) {
  1441. fgValidHead = TRUE;
  1442. } else {
  1443. fgValidHead = FALSE;
  1444. }
  1445. /* 3b. engage divided firmware downloading */
  1446. if (fgValidHead == TRUE) {
  1447. for (i = 0; i < prFwHead->u4NumOfEntries; i++) {
  1448. u4Status = wlanImageSectionDownloadStage(prAdapter,
  1449. pvFwImageMapFile, i,
  1450. u4FwImageFileLength, TRUE,
  1451. u4FwLoadAddr);
  1452. if (u4Status == WLAN_STATUS_FAILURE)
  1453. break;
  1454. }
  1455. } else
  1456. #endif
  1457. {
  1458. u4Status = wlanImageSectionDownloadStage(prAdapter,
  1459. pvFwImageMapFile, 0, u4FwImageFileLength,
  1460. FALSE, u4FwLoadAddr);
  1461. if (u4Status == WLAN_STATUS_FAILURE)
  1462. break;
  1463. }
  1464. /* escape to top */
  1465. if (u4Status != WLAN_STATUS_SUCCESS)
  1466. break;
  1467. #if !CFG_ENABLE_FW_DOWNLOAD_ACK
  1468. /* Send INIT_CMD_ID_QUERY_PENDING_ERROR command and wait for response */
  1469. if (wlanImageQueryStatus(prAdapter) != WLAN_STATUS_SUCCESS) {
  1470. DBGLOG(INIT, ERROR, "Firmware download failed!\n");
  1471. u4Status = WLAN_STATUS_FAILURE;
  1472. break;
  1473. }
  1474. #endif
  1475. } else {
  1476. DBGLOG(INIT, ERROR, "No Firmware found!\n");
  1477. u4Status = WLAN_STATUS_FAILURE;
  1478. break;
  1479. }
  1480. DBGLOG(INIT, INFO, "FW download End\n");
  1481. /* 4. send Wi-Fi Start command */
  1482. #if CFG_OVERRIDE_FW_START_ADDRESS
  1483. wlanConfigWifiFunc(prAdapter, TRUE, prRegInfo->u4StartAddress);
  1484. #else
  1485. wlanConfigWifiFunc(prAdapter, FALSE, 0);
  1486. #endif
  1487. #endif
  1488. #endif
  1489. DBGLOG(INIT, TRACE, "wlanAdapterStart(): Waiting for Ready bit..\n");
  1490. /* 4 <5> check Wi-Fi FW asserts ready bit */
  1491. i = 0;
  1492. while (1) {
  1493. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  1494. if (u4Value & WCIR_WLAN_READY) {
  1495. DBGLOG(INIT, INFO, "Ready bit asserted\n");
  1496. break;
  1497. } else if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  1498. u4Status = WLAN_STATUS_FAILURE;
  1499. break;
  1500. } else if (i >= CFG_RESPONSE_POLLING_TIMEOUT) {
  1501. UINT_32 u4MailBox0;
  1502. nicGetMailbox(prAdapter, 0, &u4MailBox0);
  1503. DBGLOG(INIT, ERROR, "Waiting for Ready bit: Timeout, ID=%d\n",
  1504. (u4MailBox0 & 0x0000FFFF));
  1505. u4Status = WLAN_STATUS_FAILURE;
  1506. break;
  1507. }
  1508. i++;
  1509. kalMsleep(10);
  1510. }
  1511. if (u4Status == WLAN_STATUS_SUCCESS) {
  1512. /* 1. reset interrupt status */
  1513. HAL_READ_INTR_STATUS(prAdapter, 4, (PUINT_8)&u4WHISR);
  1514. if (HAL_IS_TX_DONE_INTR(u4WHISR))
  1515. HAL_READ_TX_RELEASED_COUNT(prAdapter, au2TxCount);
  1516. /* 2. query & reset TX Resource for normal operation */
  1517. wlanQueryNicResourceInformation(prAdapter);
  1518. #if (CFG_SUPPORT_NIC_CAPABILITY == 1)
  1519. /* 3. query for NIC capability */
  1520. wlanQueryNicCapability(prAdapter);
  1521. #endif
  1522. /* 4. update basic configuration */
  1523. wlanUpdateBasicConfig(prAdapter);
  1524. /* 5. Override network address */
  1525. wlanUpdateNetworkAddress(prAdapter);
  1526. /* 6. Apply Network Address */
  1527. nicApplyNetworkAddress(prAdapter);
  1528. /* 7. indicate disconnection as default status */
  1529. kalIndicateStatusAndComplete(prAdapter->prGlueInfo, WLAN_STATUS_MEDIA_DISCONNECT, NULL, 0);
  1530. }
  1531. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  1532. if (u4Status != WLAN_STATUS_SUCCESS)
  1533. break;
  1534. /* OID timeout timer initialize */
  1535. cnmTimerInitTimer(prAdapter,
  1536. &prAdapter->rOidTimeoutTimer,
  1537. (PFN_MGMT_TIMEOUT_FUNC) wlanReleasePendingOid, (ULONG) NULL);
  1538. prAdapter->ucOidTimeoutCount = 0;
  1539. prAdapter->fgIsChipNoAck = FALSE;
  1540. /* Return Indicated Rfb list timer */
  1541. cnmTimerInitTimer(prAdapter,
  1542. &prAdapter->rPacketDelaySetupTimer,
  1543. (PFN_MGMT_TIMEOUT_FUNC) wlanReturnPacketDelaySetupTimeout, (ULONG) NULL);
  1544. /* Power state initialization */
  1545. prAdapter->fgWiFiInSleepyState = FALSE;
  1546. prAdapter->rAcpiState = ACPI_STATE_D0;
  1547. /* Online scan option */
  1548. if (prRegInfo->fgDisOnlineScan == 0)
  1549. prAdapter->fgEnOnlineScan = TRUE;
  1550. else
  1551. prAdapter->fgEnOnlineScan = FALSE;
  1552. /* Beacon lost detection option */
  1553. if (prRegInfo->fgDisBcnLostDetection != 0)
  1554. prAdapter->fgDisBcnLostDetection = TRUE;
  1555. /* Load compile time constant */
  1556. prAdapter->rWlanInfo.u2BeaconPeriod = CFG_INIT_ADHOC_BEACON_INTERVAL;
  1557. prAdapter->rWlanInfo.u2AtimWindow = CFG_INIT_ADHOC_ATIM_WINDOW;
  1558. #if 1 /* set PM parameters */
  1559. prAdapter->fgEnArpFilter = prRegInfo->fgEnArpFilter;
  1560. prAdapter->u4PsCurrentMeasureEn = prRegInfo->u4PsCurrentMeasureEn;
  1561. prAdapter->u4UapsdAcBmp = prRegInfo->u4UapsdAcBmp;
  1562. prAdapter->u4MaxSpLen = prRegInfo->u4MaxSpLen;
  1563. DBGLOG(INIT, TRACE, "[1] fgEnArpFilter:0x%x, u4UapsdAcBmp:0x%x, u4MaxSpLen:0x%x",
  1564. prAdapter->fgEnArpFilter, prAdapter->u4UapsdAcBmp, prAdapter->u4MaxSpLen);
  1565. prAdapter->fgEnCtiaPowerMode = FALSE;
  1566. #endif
  1567. /* MGMT Initialization */
  1568. nicInitMGMT(prAdapter, prRegInfo);
  1569. /* Enable WZC Disassociation */
  1570. prAdapter->rWifiVar.fgSupportWZCDisassociation = TRUE;
  1571. /* Apply Rate Setting */
  1572. if ((ENUM_REGISTRY_FIXED_RATE_T) (prRegInfo->u4FixedRate) < FIXED_RATE_NUM)
  1573. prAdapter->rWifiVar.eRateSetting = (ENUM_REGISTRY_FIXED_RATE_T) (prRegInfo->u4FixedRate);
  1574. else
  1575. prAdapter->rWifiVar.eRateSetting = FIXED_RATE_NONE;
  1576. if (prAdapter->rWifiVar.eRateSetting == FIXED_RATE_NONE) {
  1577. /* Enable Auto (Long/Short) Preamble */
  1578. prAdapter->rWifiVar.ePreambleType = PREAMBLE_TYPE_AUTO;
  1579. } else if ((prAdapter->rWifiVar.eRateSetting >= FIXED_RATE_MCS0_20M_400NS &&
  1580. prAdapter->rWifiVar.eRateSetting <= FIXED_RATE_MCS7_20M_400NS)
  1581. || (prAdapter->rWifiVar.eRateSetting >= FIXED_RATE_MCS0_40M_400NS &&
  1582. prAdapter->rWifiVar.eRateSetting <= FIXED_RATE_MCS32_400NS)) {
  1583. /* Force Short Preamble */
  1584. prAdapter->rWifiVar.ePreambleType = PREAMBLE_TYPE_SHORT;
  1585. } else {
  1586. /* Force Long Preamble */
  1587. prAdapter->rWifiVar.ePreambleType = PREAMBLE_TYPE_LONG;
  1588. }
  1589. /* Disable Hidden SSID Join */
  1590. prAdapter->rWifiVar.fgEnableJoinToHiddenSSID = FALSE;
  1591. /* Enable Short Slot Time */
  1592. prAdapter->rWifiVar.fgIsShortSlotTimeOptionEnable = TRUE;
  1593. /* configure available PHY type set */
  1594. nicSetAvailablePhyTypeSet(prAdapter);
  1595. #if 0 /* Marked for MT6630 */
  1596. #if 1 /* set PM parameters */
  1597. {
  1598. #if CFG_SUPPORT_PWR_MGT
  1599. prAdapter->u4PowerMode = prRegInfo->u4PowerMode;
  1600. #if CFG_ENABLE_WIFI_DIRECT
  1601. prAdapter->rWlanInfo.arPowerSaveMode[NETWORK_TYPE_P2P_INDEX].ucNetTypeIndex =
  1602. NETWORK_TYPE_P2P_INDEX;
  1603. prAdapter->rWlanInfo.arPowerSaveMode[NETWORK_TYPE_P2P_INDEX].ucPsProfile = ENUM_PSP_FAST_SWITCH;
  1604. #endif
  1605. #else
  1606. prAdapter->u4PowerMode = ENUM_PSP_CONTINUOUS_ACTIVE;
  1607. #endif
  1608. nicConfigPowerSaveProfile(prAdapter,
  1609. prAdapter->prAisBssInfo->ucBssIndex, prAdapter->u4PowerMode, FALSE);
  1610. }
  1611. #endif
  1612. #endif
  1613. #if CFG_SUPPORT_NVRAM
  1614. /* load manufacture data */
  1615. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == TRUE)
  1616. wlanLoadManufactureData(prAdapter, prRegInfo);
  1617. else
  1618. DBGLOG(INIT, WARN, "%s: load manufacture data fail\n", __func__);
  1619. #endif
  1620. #if 0
  1621. /* Update Auto rate parameters in FW */
  1622. nicRlmArUpdateParms(prAdapter,
  1623. prRegInfo->u4ArSysParam0,
  1624. prRegInfo->u4ArSysParam1, prRegInfo->u4ArSysParam2, prRegInfo->u4ArSysParam3);
  1625. #endif
  1626. } while (FALSE);
  1627. if (u4Status == WLAN_STATUS_SUCCESS) {
  1628. /* restore to hardware default */
  1629. HAL_SET_INTR_STATUS_READ_CLEAR(prAdapter);
  1630. HAL_SET_MAILBOX_READ_CLEAR(prAdapter, FALSE);
  1631. /* Enable interrupt */
  1632. nicEnableInterrupt(prAdapter);
  1633. } else {
  1634. /* release allocated memory */
  1635. nicReleaseAdapterMemory(prAdapter);
  1636. }
  1637. return u4Status;
  1638. } /* wlanAdapterStart */
  1639. /* Code Refactoring for AOSP */
  1640. static WLAN_STATUS
  1641. wlanImageSectionDownloadStage(IN P_ADAPTER_T prAdapter,
  1642. IN PVOID pvFwImageMapFile, IN UINT_32 index, IN UINT_32 u4FwImageFileLength,
  1643. IN BOOLEAN fgValidHead, IN UINT_32 u4FwLoadAddr)
  1644. {
  1645. #if CFG_ENABLE_FW_DOWNLOAD
  1646. UINT_32 u4ImgSecSize;
  1647. #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
  1648. UINT_32 j;
  1649. P_FIRMWARE_DIVIDED_DOWNLOAD_T prFwHead;
  1650. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  1651. #endif
  1652. #endif
  1653. #if CFG_ENABLE_FW_DOWNLOAD
  1654. #if defined(MT6630)
  1655. #if CFG_ENABLE_FW_DIVIDED_DOWNLOAD
  1656. /* 3a. parse file header for decision of divided firmware download or not */
  1657. prFwHead = (P_FIRMWARE_DIVIDED_DOWNLOAD_T) pvFwImageMapFile;
  1658. do {
  1659. if (fgValidHead == TRUE) {
  1660. if (wlanImageSectionConfig(prAdapter,
  1661. prFwHead->arSection[index].u4DestAddr,
  1662. prFwHead->arSection[index].u4Length,
  1663. index == 0 ? TRUE : FALSE) != WLAN_STATUS_SUCCESS) {
  1664. DBGLOG(INIT, ERROR, "Firmware download configuration failed!\n");
  1665. u4Status = WLAN_STATUS_FAILURE;
  1666. break;
  1667. }
  1668. for (j = 0; j < prFwHead->arSection[index].u4Length; j += CMD_PKT_SIZE_FOR_IMAGE) {
  1669. if (j + CMD_PKT_SIZE_FOR_IMAGE < prFwHead->arSection[index].u4Length)
  1670. u4ImgSecSize = CMD_PKT_SIZE_FOR_IMAGE;
  1671. else
  1672. u4ImgSecSize = prFwHead->arSection[index].u4Length - j;
  1673. if (wlanImageSectionDownload(prAdapter, u4ImgSecSize, (PUINT_8)
  1674. pvFwImageMapFile
  1675. +
  1676. prFwHead->arSection[index].u4Offset + j) !=
  1677. WLAN_STATUS_SUCCESS) {
  1678. DBGLOG(INIT, ERROR, "Firmware scatter download failed!\n");
  1679. u4Status = WLAN_STATUS_FAILURE;
  1680. break;
  1681. }
  1682. }
  1683. /* escape from loop if any pending error occurs */
  1684. if (u4Status == WLAN_STATUS_FAILURE)
  1685. break;
  1686. } else {
  1687. if (wlanImageSectionConfig(prAdapter,
  1688. u4FwLoadAddr, u4FwImageFileLength, TRUE) != WLAN_STATUS_SUCCESS) {
  1689. DBGLOG(INIT, ERROR, "Firmware download configuration failed!\n");
  1690. u4Status = WLAN_STATUS_FAILURE;
  1691. } else {
  1692. for (j = 0; j < u4FwImageFileLength; j += CMD_PKT_SIZE_FOR_IMAGE) {
  1693. if (j + CMD_PKT_SIZE_FOR_IMAGE < u4FwImageFileLength)
  1694. u4ImgSecSize = CMD_PKT_SIZE_FOR_IMAGE;
  1695. else
  1696. u4ImgSecSize = u4FwImageFileLength - j;
  1697. if (wlanImageSectionDownload(prAdapter,
  1698. u4ImgSecSize,
  1699. (PUINT_8) pvFwImageMapFile + j) !=
  1700. WLAN_STATUS_SUCCESS) {
  1701. DBGLOG(INIT, ERROR, "Firmware scatter download failed!\n");
  1702. u4Status = WLAN_STATUS_FAILURE;
  1703. break;
  1704. }
  1705. }
  1706. }
  1707. }
  1708. } while (0);
  1709. return u4Status;
  1710. #endif
  1711. #endif
  1712. #endif
  1713. }
  1714. /*----------------------------------------------------------------------------*/
  1715. /*!
  1716. * \brief Uninitialize the adapter
  1717. *
  1718. * \param prAdapter Pointer of Adapter Data Structure
  1719. *
  1720. * \retval WLAN_STATUS_SUCCESS: Success
  1721. * \retval WLAN_STATUS_FAILURE: Failed
  1722. */
  1723. /*----------------------------------------------------------------------------*/
  1724. WLAN_STATUS wlanAdapterStop(IN P_ADAPTER_T prAdapter)
  1725. {
  1726. UINT_32 i, u4Value = 0;
  1727. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  1728. ASSERT(prAdapter);
  1729. /* Release all CMD/MGMT/SEC frame in command queue */
  1730. kalClearCommandQueue(prAdapter->prGlueInfo);
  1731. #if CFG_SUPPORT_MULTITHREAD
  1732. /* Flush all items in queues for multi-thread */
  1733. wlanClearTxCommandQueue(prAdapter);
  1734. wlanClearTxCommandDoneQueue(prAdapter);
  1735. wlanClearDataQueue(prAdapter);
  1736. wlanClearRxToOsQueue(prAdapter);
  1737. #endif
  1738. if (prAdapter->rAcpiState == ACPI_STATE_D0 &&
  1739. !wlanIsChipNoAck(prAdapter) && !kalIsCardRemoved(prAdapter->prGlueInfo)) {
  1740. /* 0. Disable interrupt, this can be done without Driver own */
  1741. nicDisableInterrupt(prAdapter);
  1742. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  1743. /* 1. Set CMD to FW to tell WIFI to stop (enter power off state) */
  1744. if (prAdapter->fgIsFwOwn == FALSE && wlanSendNicPowerCtrlCmd(prAdapter, 1) == WLAN_STATUS_SUCCESS) {
  1745. /* 2. Clear pending interrupt */
  1746. i = 0;
  1747. while (i < CFG_IST_LOOP_COUNT && nicProcessIST(prAdapter) != WLAN_STATUS_NOT_INDICATING) {
  1748. i++;
  1749. };
  1750. /* 3. Wait til RDY bit has been cleaerd */
  1751. i = 0;
  1752. while (1) {
  1753. HAL_MCR_RD(prAdapter, MCR_WCIR, &u4Value);
  1754. if ((u4Value & WCIR_WLAN_READY) == 0)
  1755. break;
  1756. else if (kalIsCardRemoved(prAdapter->prGlueInfo)
  1757. || fgIsBusAccessFailed || (i >= CFG_RESPONSE_POLLING_TIMEOUT)) {
  1758. DBGLOG(INIT, WARN,
  1759. "%s: Failure to get RDY bit cleared! CardRemoved[%u] BusFailed[%u] Timeout[%u]",
  1760. __func__,
  1761. kalIsCardRemoved(prAdapter->prGlueInfo), fgIsBusAccessFailed, i);
  1762. break;
  1763. }
  1764. i++;
  1765. kalMsleep(1);
  1766. }
  1767. }
  1768. /* 4. Set Onwership to F/W */
  1769. nicpmSetFWOwn(prAdapter, FALSE);
  1770. #if CFG_FORCE_RESET_UNDER_BUS_ERROR
  1771. if (HAL_TEST_FLAG(prAdapter, ADAPTER_FLAG_HW_ERR) == TRUE) {
  1772. /* force acquire firmware own */
  1773. kalDevRegWrite(prAdapter->prGlueInfo, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_CLR);
  1774. /* delay for 10ms */
  1775. kalMdelay(10);
  1776. /* force firmware reset via software interrupt */
  1777. kalDevRegWrite(prAdapter->prGlueInfo, MCR_WSICR, WSICR_H2D_SW_INT_SET);
  1778. /* force release firmware own */
  1779. kalDevRegWrite(prAdapter->prGlueInfo, MCR_WHLPCR, WHLPCR_FW_OWN_REQ_SET);
  1780. }
  1781. #endif
  1782. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  1783. }
  1784. nicRxUninitialize(prAdapter);
  1785. nicTxRelease(prAdapter, FALSE);
  1786. /* MGMT - unitialization */
  1787. nicUninitMGMT(prAdapter);
  1788. /* System Service Uninitialization */
  1789. nicUninitSystemService(prAdapter);
  1790. nicReleaseAdapterMemory(prAdapter);
  1791. #if defined(_HIF_SPI)
  1792. /* Note: restore the SPI Mode Select from 32 bit to default */
  1793. nicRestoreSpiDefMode(prAdapter);
  1794. #endif
  1795. return u4Status;
  1796. } /* wlanAdapterStop */
  1797. /*----------------------------------------------------------------------------*/
  1798. /*!
  1799. * \brief This function is called by ISR (interrupt).
  1800. *
  1801. * \param prAdapter Pointer of Adapter Data Structure
  1802. *
  1803. * \retval TRUE: NIC's interrupt
  1804. * \retval FALSE: Not NIC's interrupt
  1805. */
  1806. /*----------------------------------------------------------------------------*/
  1807. BOOL wlanISR(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgGlobalIntrCtrl)
  1808. {
  1809. ASSERT(prAdapter);
  1810. if (fgGlobalIntrCtrl) {
  1811. nicDisableInterrupt(prAdapter);
  1812. /* wlanIST(prAdapter); */
  1813. }
  1814. return TRUE;
  1815. }
  1816. /*----------------------------------------------------------------------------*/
  1817. /*!
  1818. * \brief This function is called by IST (task_let).
  1819. *
  1820. * \param prAdapter Pointer of Adapter Data Structure
  1821. *
  1822. * \return (none)
  1823. */
  1824. /*----------------------------------------------------------------------------*/
  1825. VOID wlanIST(IN P_ADAPTER_T prAdapter)
  1826. {
  1827. ASSERT(prAdapter);
  1828. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  1829. nicProcessIST(prAdapter);
  1830. if (KAL_WAKE_LOCK_ACTIVE(prAdapter, &prAdapter->prGlueInfo->rIntrWakeLock))
  1831. KAL_WAKE_UNLOCK(prAdapter, &prAdapter->prGlueInfo->rIntrWakeLock);
  1832. nicEnableInterrupt(prAdapter);
  1833. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  1834. }
  1835. /*----------------------------------------------------------------------------*/
  1836. /*!
  1837. * \brief This function will check command queue to find out if any could be dequeued
  1838. * and/or send to HIF to MT6620
  1839. *
  1840. * \param prAdapter Pointer of Adapter Data Structure
  1841. * \param prCmdQue Pointer of Command Queue (in Glue Layer)
  1842. *
  1843. * \retval WLAN_STATUS_SUCCESS
  1844. */
  1845. /*----------------------------------------------------------------------------*/
  1846. WLAN_STATUS wlanProcessCommandQueue(IN P_ADAPTER_T prAdapter, IN P_QUE_T prCmdQue)
  1847. {
  1848. WLAN_STATUS rStatus;
  1849. QUE_T rTempCmdQue, rMergeCmdQue, rStandInCmdQue;
  1850. P_QUE_T prTempCmdQue, prMergeCmdQue, prStandInCmdQue;
  1851. P_QUE_ENTRY_T prQueueEntry;
  1852. P_CMD_INFO_T prCmdInfo;
  1853. P_MSDU_INFO_T prMsduInfo;
  1854. ENUM_FRAME_ACTION_T eFrameAction = FRAME_ACTION_DROP_PKT;
  1855. KAL_SPIN_LOCK_DECLARATION();
  1856. ASSERT(prAdapter);
  1857. ASSERT(prCmdQue);
  1858. prTempCmdQue = &rTempCmdQue;
  1859. prMergeCmdQue = &rMergeCmdQue;
  1860. prStandInCmdQue = &rStandInCmdQue;
  1861. QUEUE_INITIALIZE(prTempCmdQue);
  1862. QUEUE_INITIALIZE(prMergeCmdQue);
  1863. QUEUE_INITIALIZE(prStandInCmdQue);
  1864. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  1865. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_QUE);
  1866. QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
  1867. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_QUE);
  1868. /* 4 <2> Dequeue from head and check it is able to be sent */
  1869. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  1870. while (prQueueEntry) {
  1871. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  1872. switch (prCmdInfo->eCmdType) {
  1873. case COMMAND_TYPE_GENERAL_IOCTL:
  1874. case COMMAND_TYPE_NETWORK_IOCTL:
  1875. /* command packet will be always sent */
  1876. eFrameAction = FRAME_ACTION_TX_PKT;
  1877. break;
  1878. case COMMAND_TYPE_SECURITY_FRAME:
  1879. /* inquire with QM */
  1880. eFrameAction = qmGetFrameAction(prAdapter, prCmdInfo->ucBssIndex,
  1881. prCmdInfo->ucStaRecIndex, NULL, FRAME_TYPE_802_1X,
  1882. prCmdInfo->u2InfoBufLen);
  1883. break;
  1884. case COMMAND_TYPE_MANAGEMENT_FRAME:
  1885. /* inquire with QM */
  1886. prMsduInfo = prCmdInfo->prMsduInfo;
  1887. eFrameAction = qmGetFrameAction(prAdapter, prMsduInfo->ucBssIndex,
  1888. prMsduInfo->ucStaRecIndex, prMsduInfo, FRAME_TYPE_MMPDU,
  1889. prMsduInfo->u2FrameLength);
  1890. break;
  1891. default:
  1892. ASSERT(0);
  1893. break;
  1894. }
  1895. /* 4 <3> handling upon dequeue result */
  1896. if (eFrameAction == FRAME_ACTION_DROP_PKT) {
  1897. DBGLOG(INIT, INFO, "DROP CMD TYPE[%u] ID[0x%02X] SEQ[%u]\n",
  1898. prCmdInfo->eCmdType, prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum);
  1899. wlanReleaseCommand(prAdapter, prCmdInfo, TX_RESULT_DROPPED_IN_DRIVER);
  1900. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1901. } else if (eFrameAction == FRAME_ACTION_QUEUE_PKT) {
  1902. DBGLOG(INIT, TRACE, "QUE back CMD TYPE[%u] ID[0x%02X] SEQ[%u]\n",
  1903. prCmdInfo->eCmdType, prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum);
  1904. QUEUE_INSERT_TAIL(prMergeCmdQue, prQueueEntry);
  1905. } else if (eFrameAction == FRAME_ACTION_TX_PKT) {
  1906. /* 4 <4> Send the command */
  1907. #if CFG_SUPPORT_MULTITHREAD
  1908. rStatus = wlanSendCommandMthread(prAdapter, prCmdInfo);
  1909. if (rStatus == WLAN_STATUS_RESOURCES) {
  1910. /* no more TC4 resource for further transmission */
  1911. DBGLOG(INIT, WARN, "NO Res CMD TYPE[%u] ID[0x%02X] SEQ[%u]\n",
  1912. prCmdInfo->eCmdType, prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum);
  1913. QUEUE_INSERT_TAIL(prMergeCmdQue, prQueueEntry);
  1914. break;
  1915. } else if (rStatus != WLAN_STATUS_SUCCESS && rStatus != WLAN_STATUS_PENDING) {
  1916. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  1917. if (prCmdInfo->fgIsOid)
  1918. kalOidComplete(prAdapter->prGlueInfo, prCmdInfo->fgSetQuery,
  1919. prCmdInfo->u4SetInfoLen, rStatus);
  1920. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1921. DBGLOG(TX, WARN, "TX CMD Status[%u], TYPE[%u] ID[0x%02X] SEQ[%u]\n", rStatus,
  1922. prCmdInfo->eCmdType, prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum);
  1923. }
  1924. #else
  1925. rStatus = wlanSendCommand(prAdapter, prCmdInfo);
  1926. if (rStatus == WLAN_STATUS_RESOURCES) {
  1927. /* no more TC4 resource for further transmission */
  1928. DBGLOG(TX, WARN, "NO Resource for CMD TYPE[%u] ID[0x%02X] SEQ[%u]\n",
  1929. prCmdInfo->eCmdType, prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum);
  1930. QUEUE_INSERT_TAIL(prMergeCmdQue, prQueueEntry);
  1931. break;
  1932. } else if (rStatus == WLAN_STATUS_PENDING) {
  1933. /* command packet which needs further handling upon response */
  1934. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  1935. QUEUE_INSERT_TAIL(&(prAdapter->rPendingCmdQueue), prQueueEntry);
  1936. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  1937. } else {
  1938. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  1939. if (rStatus == WLAN_STATUS_SUCCESS) {
  1940. if (prCmdInfo->pfCmdDoneHandler) {
  1941. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo,
  1942. prCmdInfo->pucInfoBuffer);
  1943. }
  1944. } else {
  1945. if (prCmdInfo->fgIsOid) {
  1946. kalOidComplete(prAdapter->prGlueInfo,
  1947. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, rStatus);
  1948. }
  1949. }
  1950. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  1951. }
  1952. #endif
  1953. } else {
  1954. ASSERT(0);
  1955. }
  1956. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  1957. }
  1958. /* 4 <3> Merge back to original queue */
  1959. /* 4 <3.1> Merge prMergeCmdQue & prTempCmdQue */
  1960. QUEUE_CONCATENATE_QUEUES(prMergeCmdQue, prTempCmdQue);
  1961. /* 4 <3.2> Move prCmdQue to prStandInQue, due to prCmdQue might differ due to incoming 802.1X frames */
  1962. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_QUE);
  1963. QUEUE_MOVE_ALL(prStandInCmdQue, prCmdQue);
  1964. /* 4 <3.3> concatenate prStandInQue to prMergeCmdQue */
  1965. QUEUE_CONCATENATE_QUEUES(prMergeCmdQue, prStandInCmdQue);
  1966. /* 4 <3.4> then move prMergeCmdQue to prCmdQue */
  1967. QUEUE_MOVE_ALL(prCmdQue, prMergeCmdQue);
  1968. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_QUE);
  1969. #if CFG_SUPPORT_MULTITHREAD
  1970. kalSetTxCmdEvent2Hif(prAdapter->prGlueInfo);
  1971. #endif
  1972. return WLAN_STATUS_SUCCESS;
  1973. } /* end of wlanProcessCommandQueue() */
  1974. /*----------------------------------------------------------------------------*/
  1975. /*!
  1976. * \brief This function will take CMD_INFO_T which carry some informantion of
  1977. * incoming OID and notify the NIC_TX to send CMD.
  1978. *
  1979. * \param prAdapter Pointer of Adapter Data Structure
  1980. * \param prCmdInfo Pointer of P_CMD_INFO_T
  1981. *
  1982. * \retval WLAN_STATUS_SUCCESS : CMD was written to HIF and be freed(CMD Done) immediately.
  1983. * \retval WLAN_STATUS_RESOURCE : No resource for current command, need to wait for previous
  1984. * frame finishing their transmission.
  1985. * \retval WLAN_STATUS_FAILURE : Get failure while access HIF or been rejected.
  1986. */
  1987. /*----------------------------------------------------------------------------*/
  1988. WLAN_STATUS wlanSendCommand(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  1989. {
  1990. P_TX_CTRL_T prTxCtrl;
  1991. UINT_8 ucTC; /* "Traffic Class" SW(Driver) resource classification */
  1992. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  1993. ASSERT(prAdapter);
  1994. ASSERT(prCmdInfo);
  1995. prTxCtrl = &prAdapter->rTxCtrl;
  1996. do {
  1997. /* <0> card removal check */
  1998. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  1999. rStatus = WLAN_STATUS_FAILURE;
  2000. break;
  2001. }
  2002. /* <1> Normal case of sending CMD Packet */
  2003. if (!prCmdInfo->fgDriverDomainMCR) {
  2004. /* <1.1> Assign Traffic Class(TC) */
  2005. ucTC = nicTxGetCmdResourceType(prCmdInfo);
  2006. /* <1.2> Check if pending packet or resource was exhausted */
  2007. rStatus = nicTxAcquireResource(prAdapter, ucTC, nicTxGetCmdPageCount(prCmdInfo));
  2008. if (rStatus == WLAN_STATUS_RESOURCES) {
  2009. DBGLOG(INIT, INFO, "NO Resource:%d\n", ucTC);
  2010. break;
  2011. }
  2012. /* <1.3> Forward CMD_INFO_T to NIC Layer */
  2013. rStatus = nicTxCmd(prAdapter, prCmdInfo, ucTC);
  2014. /* <1.4> Set Pending in response to Query Command/Need Response */
  2015. if (rStatus == WLAN_STATUS_SUCCESS) {
  2016. if ((!prCmdInfo->fgSetQuery) || (prCmdInfo->fgNeedResp))
  2017. rStatus = WLAN_STATUS_PENDING;
  2018. }
  2019. }
  2020. /* <2> Special case for access Driver Domain MCR */
  2021. else {
  2022. P_CMD_ACCESS_REG prCmdAccessReg;
  2023. prCmdAccessReg = (P_CMD_ACCESS_REG) (prCmdInfo->pucInfoBuffer + CMD_HDR_SIZE);
  2024. if (prCmdInfo->fgSetQuery) {
  2025. /* address is in DWORD unit */
  2026. HAL_MCR_WR(prAdapter, (prCmdAccessReg->u4Address & BITS(2, 31)),
  2027. prCmdAccessReg->u4Data);
  2028. } else {
  2029. P_CMD_ACCESS_REG prEventAccessReg;
  2030. UINT_32 u4Address;
  2031. u4Address = prCmdAccessReg->u4Address;
  2032. prEventAccessReg = (P_CMD_ACCESS_REG) prCmdInfo->pucInfoBuffer;
  2033. prEventAccessReg->u4Address = u4Address;
  2034. /* address is in DWORD unit */
  2035. HAL_MCR_RD(prAdapter, prEventAccessReg->u4Address & BITS(2, 31),
  2036. &prEventAccessReg->u4Data);
  2037. }
  2038. }
  2039. } while (FALSE);
  2040. return rStatus;
  2041. } /* end of wlanSendCommand() */
  2042. #if CFG_SUPPORT_MULTITHREAD
  2043. /*----------------------------------------------------------------------------*/
  2044. /*!
  2045. * \brief This function will take CMD_INFO_T which carry some information of
  2046. * incoming OID and notify the NIC_TX to send CMD.
  2047. *
  2048. * \param prAdapter Pointer of Adapter Data Structure
  2049. * \param prCmdInfo Pointer of P_CMD_INFO_T
  2050. *
  2051. * \retval WLAN_STATUS_SUCCESS : CMD was written to HIF and be freed(CMD Done) immediately.
  2052. * \retval WLAN_STATUS_RESOURCE : No resource for current command, need to wait for previous
  2053. * frame finishing their transmission.
  2054. * \retval WLAN_STATUS_FAILURE : Get failure while access HIF or been rejected.
  2055. */
  2056. /*----------------------------------------------------------------------------*/
  2057. WLAN_STATUS wlanSendCommandMthread(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  2058. {
  2059. P_TX_CTRL_T prTxCtrl;
  2060. UINT_8 ucTC; /* "Traffic Class" SW(Driver) resource classification */
  2061. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  2062. QUE_T rTempCmdQue;
  2063. P_QUE_T prTempCmdQue;
  2064. KAL_SPIN_LOCK_DECLARATION();
  2065. ASSERT(prAdapter);
  2066. ASSERT(prCmdInfo);
  2067. prTxCtrl = &prAdapter->rTxCtrl;
  2068. prTempCmdQue = &rTempCmdQue;
  2069. QUEUE_INITIALIZE(prTempCmdQue);
  2070. do {
  2071. /* <0> card removal check */
  2072. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  2073. rStatus = WLAN_STATUS_FAILURE;
  2074. break;
  2075. }
  2076. /* <1> Normal case of sending CMD Packet */
  2077. if (!prCmdInfo->fgDriverDomainMCR) {
  2078. /* <1.1> Assign Traffic Class(TC) */
  2079. ucTC = nicTxGetCmdResourceType(prCmdInfo);
  2080. /* <1.2> Check if pending packet or resource was exhausted */
  2081. rStatus = nicTxAcquireResource(prAdapter, ucTC, nicTxGetCmdPageCount(prCmdInfo));
  2082. if (rStatus == WLAN_STATUS_RESOURCES) {
  2083. #if 0
  2084. DBGLOG(INIT, WARN, "%s: NO Resource for CMD TYPE[%u] ID[0x%02X] SEQ[%u] TC[%u]\n",
  2085. __func__,
  2086. prCmdInfo->eCmdType,
  2087. prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum, ucTC);
  2088. #endif
  2089. break;
  2090. }
  2091. /* Process to pending command queue firest */
  2092. if ((!prCmdInfo->fgSetQuery) || (prCmdInfo->fgNeedResp)) {
  2093. /* command packet which needs further handling upon response */
  2094. /*
  2095. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2096. QUEUE_INSERT_TAIL(&(prAdapter->rPendingCmdQueue), (P_QUE_ENTRY_T)prCmdInfo);
  2097. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2098. */
  2099. }
  2100. QUEUE_INSERT_TAIL(prTempCmdQue, (P_QUE_ENTRY_T) prCmdInfo);
  2101. /* <1.4> Set Pending in response to Query Command/Need Response */
  2102. if (rStatus == WLAN_STATUS_SUCCESS) {
  2103. if ((!prCmdInfo->fgSetQuery) ||
  2104. (prCmdInfo->fgNeedResp) || (prCmdInfo->eCmdType == COMMAND_TYPE_SECURITY_FRAME)) {
  2105. rStatus = WLAN_STATUS_PENDING;
  2106. }
  2107. }
  2108. }
  2109. /* <2> Special case for access Driver Domain MCR */
  2110. else {
  2111. QUEUE_INSERT_TAIL(prTempCmdQue, (P_QUE_ENTRY_T) prCmdInfo);
  2112. rStatus = WLAN_STATUS_PENDING;
  2113. }
  2114. } while (FALSE);
  2115. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2116. QUEUE_CONCATENATE_QUEUES(&(prAdapter->rTxCmdQueue), prTempCmdQue);
  2117. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2118. return rStatus;
  2119. } /* end of wlanSendCommandMthread() */
  2120. WLAN_STATUS wlanTxCmdMthread(IN P_ADAPTER_T prAdapter)
  2121. {
  2122. QUE_T rTempCmdQue;
  2123. P_QUE_T prTempCmdQue;
  2124. QUE_T rTempCmdDoneQue;
  2125. P_QUE_T prTempCmdDoneQue;
  2126. P_QUE_ENTRY_T prQueueEntry;
  2127. P_CMD_INFO_T prCmdInfo;
  2128. P_CMD_ACCESS_REG prCmdAccessReg;
  2129. P_CMD_ACCESS_REG prEventAccessReg;
  2130. UINT_32 u4Address;
  2131. UINT_32 u4TxDoneQueueSize;
  2132. KAL_SPIN_LOCK_DECLARATION();
  2133. ASSERT(prAdapter);
  2134. prTempCmdQue = &rTempCmdQue;
  2135. QUEUE_INITIALIZE(prTempCmdQue);
  2136. prTempCmdDoneQue = &rTempCmdDoneQue;
  2137. QUEUE_INITIALIZE(prTempCmdDoneQue);
  2138. KAL_ACQUIRE_MUTEX(prAdapter, MUTEX_TX_CMD_CLEAR);
  2139. /* TX Command Queue */
  2140. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  2141. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2142. QUEUE_MOVE_ALL(prTempCmdQue, &prAdapter->rTxCmdQueue);
  2143. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2144. /* 4 <2> Dequeue from head and check it is able to be sent */
  2145. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2146. while (prQueueEntry) {
  2147. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2148. if (!prCmdInfo->fgDriverDomainMCR) {
  2149. nicTxCmd(prAdapter, prCmdInfo, TC4_INDEX);
  2150. if ((!prCmdInfo->fgSetQuery) || (prCmdInfo->fgNeedResp)) {
  2151. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2152. QUEUE_INSERT_TAIL(&(prAdapter->rPendingCmdQueue), (P_QUE_ENTRY_T) prCmdInfo);
  2153. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2154. } else {
  2155. QUEUE_INSERT_TAIL(prTempCmdDoneQue, prQueueEntry);
  2156. }
  2157. /* DBGLOG(INIT, INFO,
  2158. * ("==> TX CMD QID: %d (Q:%d)\n", prCmdInfo->ucCID, prTempCmdQue->u4NumElem)); */
  2159. } else {
  2160. prCmdAccessReg = (P_CMD_ACCESS_REG) (prCmdInfo->pucInfoBuffer + CMD_HDR_SIZE);
  2161. if (prCmdInfo->fgSetQuery) {
  2162. /* address is in DWORD unit */
  2163. HAL_MCR_WR(prAdapter, (prCmdAccessReg->u4Address & BITS(2, 31)),
  2164. prCmdAccessReg->u4Data);
  2165. } else {
  2166. u4Address = prCmdAccessReg->u4Address;
  2167. prEventAccessReg = (P_CMD_ACCESS_REG) prCmdInfo->pucInfoBuffer;
  2168. prEventAccessReg->u4Address = u4Address;
  2169. /* address is in DWORD unit */
  2170. HAL_MCR_RD(prAdapter, prEventAccessReg->u4Address & BITS(2, 31),
  2171. &prEventAccessReg->u4Data);
  2172. }
  2173. QUEUE_INSERT_TAIL(prTempCmdDoneQue, prQueueEntry);
  2174. }
  2175. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2176. }
  2177. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2178. QUEUE_CONCATENATE_QUEUES(&prAdapter->rTxCmdDoneQueue, prTempCmdDoneQue);
  2179. u4TxDoneQueueSize = prAdapter->rTxCmdDoneQueue.u4NumElem;
  2180. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2181. KAL_RELEASE_MUTEX(prAdapter, MUTEX_TX_CMD_CLEAR);
  2182. if (u4TxDoneQueueSize > 0) {
  2183. /* call tx thread to work */
  2184. set_bit(GLUE_FLAG_TX_CMD_DONE_BIT, &prAdapter->prGlueInfo->ulFlag);
  2185. wake_up_interruptible(&prAdapter->prGlueInfo->waitq);
  2186. }
  2187. return WLAN_STATUS_SUCCESS;
  2188. }
  2189. WLAN_STATUS wlanTxCmdDoneMthread(IN P_ADAPTER_T prAdapter)
  2190. {
  2191. QUE_T rTempCmdQue;
  2192. P_QUE_T prTempCmdQue;
  2193. P_QUE_ENTRY_T prQueueEntry;
  2194. P_CMD_INFO_T prCmdInfo;
  2195. KAL_SPIN_LOCK_DECLARATION();
  2196. ASSERT(prAdapter);
  2197. prTempCmdQue = &rTempCmdQue;
  2198. QUEUE_INITIALIZE(prTempCmdQue);
  2199. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  2200. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2201. QUEUE_MOVE_ALL(prTempCmdQue, &prAdapter->rTxCmdDoneQueue);
  2202. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2203. /* 4 <2> Dequeue from head and check it is able to be sent */
  2204. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2205. while (prQueueEntry) {
  2206. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2207. if (prCmdInfo->pfCmdDoneHandler)
  2208. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prCmdInfo->pucInfoBuffer);
  2209. /* Not pending cmd, free it after TX succeed! */
  2210. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2211. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2212. }
  2213. return WLAN_STATUS_SUCCESS;
  2214. }
  2215. /*----------------------------------------------------------------------------*/
  2216. /*!
  2217. * \brief This routine is used to clear all commands in TX command queue
  2218. * \param prAdapter Pointer of Adapter Data Structure
  2219. *
  2220. * \retval none
  2221. */
  2222. /*----------------------------------------------------------------------------*/
  2223. VOID wlanClearTxCommandQueue(IN P_ADAPTER_T prAdapter)
  2224. {
  2225. QUE_T rTempCmdQue;
  2226. P_QUE_T prTempCmdQue = &rTempCmdQue;
  2227. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2228. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  2229. KAL_SPIN_LOCK_DECLARATION();
  2230. QUEUE_INITIALIZE(prTempCmdQue);
  2231. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2232. QUEUE_MOVE_ALL(prTempCmdQue, &prAdapter->rTxCmdQueue);
  2233. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2234. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2235. while (prQueueEntry) {
  2236. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2237. if (prCmdInfo->pfCmdTimeoutHandler)
  2238. prCmdInfo->pfCmdTimeoutHandler(prAdapter, prCmdInfo);
  2239. else
  2240. wlanReleaseCommand(prAdapter, prCmdInfo, TX_RESULT_QUEUE_CLEARANCE);
  2241. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2242. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2243. }
  2244. }
  2245. /*----------------------------------------------------------------------------*/
  2246. /*!
  2247. * \brief This routine is used to clear OID commands in TX command queue
  2248. * \param prAdapter Pointer of Adapter Data Structure
  2249. *
  2250. * \retval none
  2251. */
  2252. /*----------------------------------------------------------------------------*/
  2253. VOID wlanClearTxOidCommand(IN P_ADAPTER_T prAdapter)
  2254. {
  2255. QUE_T rTempCmdQue;
  2256. P_QUE_T prTempCmdQue = &rTempCmdQue;
  2257. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2258. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  2259. KAL_SPIN_LOCK_DECLARATION();
  2260. QUEUE_INITIALIZE(prTempCmdQue);
  2261. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2262. QUEUE_MOVE_ALL(prTempCmdQue, &prAdapter->rTxCmdQueue);
  2263. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2264. while (prQueueEntry) {
  2265. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2266. if (prCmdInfo->fgIsOid) {
  2267. if (prCmdInfo->pfCmdTimeoutHandler)
  2268. prCmdInfo->pfCmdTimeoutHandler(prAdapter, prCmdInfo);
  2269. else
  2270. wlanReleaseCommand(prAdapter, prCmdInfo, TX_RESULT_QUEUE_CLEARANCE);
  2271. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2272. } else {
  2273. QUEUE_INSERT_TAIL(&prAdapter->rTxCmdQueue, prQueueEntry);
  2274. }
  2275. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2276. }
  2277. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_QUE);
  2278. }
  2279. /*----------------------------------------------------------------------------*/
  2280. /*!
  2281. * \brief This routine is used to clear all commands in TX command done queue
  2282. * \param prAdapter Pointer of Adapter Data Structure
  2283. *
  2284. * \retval none
  2285. */
  2286. /*----------------------------------------------------------------------------*/
  2287. VOID wlanClearTxCommandDoneQueue(IN P_ADAPTER_T prAdapter)
  2288. {
  2289. QUE_T rTempCmdDoneQue;
  2290. P_QUE_T prTempCmdDoneQue = &rTempCmdDoneQue;
  2291. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2292. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  2293. KAL_SPIN_LOCK_DECLARATION();
  2294. QUEUE_INITIALIZE(prTempCmdDoneQue);
  2295. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  2296. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2297. QUEUE_MOVE_ALL(prTempCmdDoneQue, &prAdapter->rTxCmdDoneQueue);
  2298. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_CMD_DONE_QUE);
  2299. /* 4 <2> Dequeue from head and check it is able to be sent */
  2300. QUEUE_REMOVE_HEAD(prTempCmdDoneQue, prQueueEntry, P_QUE_ENTRY_T);
  2301. while (prQueueEntry) {
  2302. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2303. if (prCmdInfo->pfCmdDoneHandler)
  2304. prCmdInfo->pfCmdDoneHandler(prAdapter, prCmdInfo, prCmdInfo->pucInfoBuffer);
  2305. /* Not pending cmd, free it after TX succeed! */
  2306. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2307. QUEUE_REMOVE_HEAD(prTempCmdDoneQue, prQueueEntry, P_QUE_ENTRY_T);
  2308. }
  2309. }
  2310. /*----------------------------------------------------------------------------*/
  2311. /*!
  2312. * \brief This routine is used to clear all buffer in port 0/1 queue
  2313. * \param prAdapter Pointer of Adapter Data Structure
  2314. *
  2315. * \retval none
  2316. */
  2317. /*----------------------------------------------------------------------------*/
  2318. VOID wlanClearDataQueue(IN P_ADAPTER_T prAdapter)
  2319. {
  2320. QUE_T qDataPort0, qDataPort1;
  2321. P_QUE_T prDataPort0, prDataPort1;
  2322. KAL_SPIN_LOCK_DECLARATION();
  2323. prDataPort0 = &qDataPort0;
  2324. prDataPort1 = &qDataPort1;
  2325. QUEUE_INITIALIZE(prDataPort0);
  2326. QUEUE_INITIALIZE(prDataPort1);
  2327. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  2328. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_PORT_QUE);
  2329. QUEUE_MOVE_ALL(prDataPort0, &prAdapter->rTxP0Queue);
  2330. QUEUE_MOVE_ALL(prDataPort1, &prAdapter->rTxP1Queue);
  2331. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_TX_PORT_QUE);
  2332. /* 4 <2> Return sk buffer */
  2333. nicTxReturnMsduInfo(prAdapter, (P_MSDU_INFO_T) QUEUE_GET_HEAD(prDataPort0));
  2334. nicTxReturnMsduInfo(prAdapter, (P_MSDU_INFO_T) QUEUE_GET_HEAD(prDataPort1));
  2335. }
  2336. /*----------------------------------------------------------------------------*/
  2337. /*!
  2338. * \brief This routine is used to clear all buffer in port 0/1 queue
  2339. * \param prAdapter Pointer of Adapter Data Structure
  2340. *
  2341. * \retval none
  2342. */
  2343. /*----------------------------------------------------------------------------*/
  2344. VOID wlanClearRxToOsQueue(IN P_ADAPTER_T prAdapter)
  2345. {
  2346. QUE_T rTempRxQue;
  2347. P_QUE_T prTempRxQue = &rTempRxQue;
  2348. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2349. KAL_SPIN_LOCK_DECLARATION();
  2350. QUEUE_INITIALIZE(prTempRxQue);
  2351. /* 4 <1> Move whole list of CMD_INFO to temp queue */
  2352. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_TO_OS_QUE);
  2353. QUEUE_MOVE_ALL(prTempRxQue, &prAdapter->rRxQueue);
  2354. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_TO_OS_QUE);
  2355. /* 4 <2> Remove all skbuf */
  2356. QUEUE_REMOVE_HEAD(prTempRxQue, prQueueEntry, P_QUE_ENTRY_T);
  2357. while (prQueueEntry) {
  2358. kalRxIndicateOnePkt(prAdapter->prGlueInfo, (PVOID) GLUE_GET_PKT_DESCRIPTOR(prQueueEntry));
  2359. QUEUE_REMOVE_HEAD(prTempRxQue, prQueueEntry, P_QUE_ENTRY_T);
  2360. }
  2361. }
  2362. #endif
  2363. /*----------------------------------------------------------------------------*/
  2364. /*!
  2365. * \brief This function will release thd CMD_INFO upon its attribution
  2366. *
  2367. * \param prAdapter Pointer of Adapter Data Structure
  2368. * \param prCmdInfo Pointer of CMD_INFO_T
  2369. * \param rTxDoneStatus Tx done status
  2370. *
  2371. * \return (none)
  2372. */
  2373. /*----------------------------------------------------------------------------*/
  2374. VOID wlanReleaseCommand(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  2375. {
  2376. P_TX_CTRL_T prTxCtrl;
  2377. P_MSDU_INFO_T prMsduInfo;
  2378. ASSERT(prAdapter);
  2379. ASSERT(prCmdInfo);
  2380. prTxCtrl = &prAdapter->rTxCtrl;
  2381. switch (prCmdInfo->eCmdType) {
  2382. case COMMAND_TYPE_GENERAL_IOCTL:
  2383. case COMMAND_TYPE_NETWORK_IOCTL:
  2384. DBGLOG(INIT, INFO, "Free CMD: BSS[%u] ID[0x%x] SeqNum[%u] OID[%u]\n",
  2385. prCmdInfo->ucBssIndex,
  2386. prCmdInfo->ucCID, prCmdInfo->ucCmdSeqNum, prCmdInfo->fgIsOid);
  2387. if (prCmdInfo->fgIsOid) {
  2388. kalOidComplete(prAdapter->prGlueInfo,
  2389. prCmdInfo->fgSetQuery, prCmdInfo->u4SetInfoLen, WLAN_STATUS_FAILURE);
  2390. }
  2391. break;
  2392. case COMMAND_TYPE_SECURITY_FRAME:
  2393. case COMMAND_TYPE_MANAGEMENT_FRAME:
  2394. prMsduInfo = prCmdInfo->prMsduInfo;
  2395. if (prCmdInfo->eCmdType == COMMAND_TYPE_SECURITY_FRAME) {
  2396. kalSecurityFrameSendComplete(prAdapter->prGlueInfo, prCmdInfo->prPacket, WLAN_STATUS_FAILURE);
  2397. /* Avoid skb multiple free */
  2398. prMsduInfo->prPacket = NULL;
  2399. }
  2400. DBGLOG(INIT, INFO,
  2401. "Free %s Frame: BSS[%u] WIDX:PID[%u:%u] SEQ[%u] STA[%u] RSP[%u] CMDSeq[%u]\n",
  2402. prCmdInfo->eCmdType == COMMAND_TYPE_SECURITY_FRAME ? "SEC" : "MGMT",
  2403. prMsduInfo->ucBssIndex,
  2404. prMsduInfo->ucWlanIndex,
  2405. prMsduInfo->ucPID,
  2406. prMsduInfo->ucTxSeqNum,
  2407. prMsduInfo->ucStaRecIndex,
  2408. prMsduInfo->pfTxDoneHandler ? TRUE : FALSE, prCmdInfo->ucCmdSeqNum);
  2409. /* invoke callbacks */
  2410. if (prMsduInfo->pfTxDoneHandler != NULL)
  2411. prMsduInfo->pfTxDoneHandler(prAdapter, prMsduInfo, rTxDoneStatus);
  2412. GLUE_DEC_REF_CNT(prTxCtrl->i4TxMgmtPendingNum);
  2413. cnmMgtPktFree(prAdapter, prMsduInfo);
  2414. break;
  2415. default:
  2416. ASSERT(0);
  2417. break;
  2418. }
  2419. } /* end of wlanReleaseCommand() */
  2420. /*----------------------------------------------------------------------------*/
  2421. /*!
  2422. * \brief This function will search the CMD Queue to look for the pending OID and
  2423. * compelete it immediately when system request a reset.
  2424. *
  2425. * \param prAdapter ointer of Adapter Data Structure
  2426. *
  2427. * \return (none)
  2428. */
  2429. /*----------------------------------------------------------------------------*/
  2430. VOID wlanReleasePendingOid(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr)
  2431. {
  2432. P_QUE_T prCmdQue;
  2433. QUE_T rTempCmdQue;
  2434. P_QUE_T prTempCmdQue = &rTempCmdQue;
  2435. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2436. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  2437. KAL_SPIN_LOCK_DECLARATION();
  2438. DEBUGFUNC("wlanReleasePendingOid");
  2439. ASSERT(prAdapter);
  2440. if (prAdapter->prGlueInfo->ulFlag & GLUE_FLAG_HALT) {
  2441. DBGLOG(INIT, INFO, "tx_thread stopped! Releasing pending OIDs ..\n");
  2442. } else {
  2443. DBGLOG(INIT, ERROR, "OID Timeout! Releasing pending OIDs ..\n");
  2444. prAdapter->ucOidTimeoutCount++;
  2445. if (prAdapter->ucOidTimeoutCount >= WLAN_OID_NO_ACK_THRESHOLD) {
  2446. if (!prAdapter->fgIsChipNoAck) {
  2447. DBGLOG(INIT, WARN,
  2448. "No response from chip for %u times, set NoAck flag!\n",
  2449. prAdapter->ucOidTimeoutCount);
  2450. }
  2451. prAdapter->fgIsChipNoAck = TRUE;
  2452. }
  2453. }
  2454. do {
  2455. #if CFG_SUPPORT_MULTITHREAD
  2456. KAL_ACQUIRE_MUTEX(prAdapter, MUTEX_TX_CMD_CLEAR);
  2457. #endif
  2458. /* 1: Clear Pending OID in prAdapter->rPendingCmdQueue */
  2459. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2460. prCmdQue = &prAdapter->rPendingCmdQueue;
  2461. QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
  2462. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2463. while (prQueueEntry) {
  2464. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2465. if (prCmdInfo->fgIsOid) {
  2466. if (prCmdInfo->pfCmdTimeoutHandler) {
  2467. prCmdInfo->pfCmdTimeoutHandler(prAdapter, prCmdInfo);
  2468. } else {
  2469. kalOidComplete(prAdapter->prGlueInfo,
  2470. prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  2471. }
  2472. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2473. } else {
  2474. QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
  2475. }
  2476. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2477. }
  2478. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2479. #if CFG_SUPPORT_MULTITHREAD
  2480. /* Clear pending OID in tx_thread to hif_thread command queue */
  2481. wlanClearTxOidCommand(prAdapter);
  2482. #endif
  2483. /* 2: Clear pending OID in glue layer command queue */
  2484. kalOidCmdClearance(prAdapter->prGlueInfo);
  2485. /* 3: Clear pending OID queued in pvOidEntry with REQ_FLAG_OID set */
  2486. kalOidClearance(prAdapter->prGlueInfo);
  2487. #if CFG_SUPPORT_MULTITHREAD
  2488. KAL_RELEASE_MUTEX(prAdapter, MUTEX_TX_CMD_CLEAR);
  2489. #endif
  2490. } while (FALSE);
  2491. }
  2492. /*----------------------------------------------------------------------------*/
  2493. /*!
  2494. * \brief This function will search the CMD Queue to look for the pending CMD/OID for specific
  2495. * NETWORK TYPE and compelete it immediately when system request a reset.
  2496. *
  2497. * \param prAdapter ointer of Adapter Data Structure
  2498. *
  2499. * \return (none)
  2500. */
  2501. /*----------------------------------------------------------------------------*/
  2502. VOID wlanReleasePendingCMDbyBssIdx(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex)
  2503. {
  2504. P_QUE_T prCmdQue;
  2505. QUE_T rTempCmdQue;
  2506. P_QUE_T prTempCmdQue = &rTempCmdQue;
  2507. P_QUE_ENTRY_T prQueueEntry = (P_QUE_ENTRY_T) NULL;
  2508. P_CMD_INFO_T prCmdInfo = (P_CMD_INFO_T) NULL;
  2509. KAL_SPIN_LOCK_DECLARATION();
  2510. ASSERT(prAdapter);
  2511. do {
  2512. /* 1: Clear Pending OID in prAdapter->rPendingCmdQueue */
  2513. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2514. prCmdQue = &prAdapter->rPendingCmdQueue;
  2515. QUEUE_MOVE_ALL(prTempCmdQue, prCmdQue);
  2516. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2517. while (prQueueEntry) {
  2518. prCmdInfo = (P_CMD_INFO_T) prQueueEntry;
  2519. DBGLOG(P2P, TRACE, "Pending CMD for BSS:%d\n", prCmdInfo->ucBssIndex);
  2520. if (prCmdInfo->ucBssIndex == ucBssIndex) {
  2521. if (prCmdInfo->pfCmdTimeoutHandler) {
  2522. prCmdInfo->pfCmdTimeoutHandler(prAdapter, prCmdInfo);
  2523. } else if (prCmdInfo->fgIsOid) {
  2524. kalOidComplete(prAdapter->prGlueInfo,
  2525. prCmdInfo->fgSetQuery, 0, WLAN_STATUS_FAILURE);
  2526. }
  2527. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2528. } else {
  2529. QUEUE_INSERT_TAIL(prCmdQue, prQueueEntry);
  2530. }
  2531. QUEUE_REMOVE_HEAD(prTempCmdQue, prQueueEntry, P_QUE_ENTRY_T);
  2532. }
  2533. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_CMD_PENDING);
  2534. } while (FALSE);
  2535. } /* wlanReleasePendingCMDbyBssIdx */
  2536. /*----------------------------------------------------------------------------*/
  2537. /*!
  2538. * \brief Return the indicated packet buffer and reallocate one to the RFB
  2539. *
  2540. * \param prAdapter Pointer of Adapter Data Structure
  2541. * \param pvPacket Pointer of returned packet
  2542. *
  2543. * \retval WLAN_STATUS_SUCCESS: Success
  2544. * \retval WLAN_STATUS_FAILURE: Failed
  2545. */
  2546. /*----------------------------------------------------------------------------*/
  2547. VOID wlanReturnPacketDelaySetupTimeout(IN P_ADAPTER_T prAdapter, IN ULONG ulParamPtr)
  2548. {
  2549. P_RX_CTRL_T prRxCtrl;
  2550. P_SW_RFB_T prSwRfb = NULL;
  2551. WLAN_STATUS status = WLAN_STATUS_SUCCESS;
  2552. P_QUE_T prQueList;
  2553. KAL_SPIN_LOCK_DECLARATION();
  2554. ASSERT(prAdapter);
  2555. prRxCtrl = &prAdapter->rRxCtrl;
  2556. ASSERT(prRxCtrl);
  2557. prQueList = &prRxCtrl->rIndicatedRfbList;
  2558. DBGLOG(RX, WARN, "%s: IndicatedRfbList num = %u\n", __func__, prQueList->u4NumElem);
  2559. while (QUEUE_IS_NOT_EMPTY(&prRxCtrl->rIndicatedRfbList)) {
  2560. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_FREE_QUE);
  2561. QUEUE_REMOVE_HEAD(&prRxCtrl->rIndicatedRfbList, prSwRfb, P_SW_RFB_T);
  2562. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_FREE_QUE);
  2563. status = nicRxSetupRFB(prAdapter, prSwRfb);
  2564. nicRxReturnRFB(prAdapter, prSwRfb);
  2565. if (status != WLAN_STATUS_SUCCESS)
  2566. break;
  2567. }
  2568. if (status != WLAN_STATUS_SUCCESS) {
  2569. DBGLOG(RX, WARN, "Restart ReturnIndicatedRfb Timer (%u)\n", RX_RETURN_INDICATED_RFB_TIMEOUT_SEC);
  2570. /* restart timer */
  2571. cnmTimerStartTimer(prAdapter,
  2572. &prAdapter->rPacketDelaySetupTimer,
  2573. SEC_TO_MSEC(RX_RETURN_INDICATED_RFB_TIMEOUT_SEC));
  2574. }
  2575. }
  2576. /*----------------------------------------------------------------------------*/
  2577. /*!
  2578. * \brief Return the packet buffer and reallocate one to the RFB
  2579. *
  2580. * \param prAdapter Pointer of Adapter Data Structure
  2581. * \param pvPacket Pointer of returned packet
  2582. *
  2583. * \retval WLAN_STATUS_SUCCESS: Success
  2584. * \retval WLAN_STATUS_FAILURE: Failed
  2585. */
  2586. /*----------------------------------------------------------------------------*/
  2587. VOID wlanReturnPacket(IN P_ADAPTER_T prAdapter, IN PVOID pvPacket)
  2588. {
  2589. P_RX_CTRL_T prRxCtrl;
  2590. P_SW_RFB_T prSwRfb = NULL;
  2591. KAL_SPIN_LOCK_DECLARATION();
  2592. DEBUGFUNC("wlanReturnPacket");
  2593. ASSERT(prAdapter);
  2594. prRxCtrl = &prAdapter->rRxCtrl;
  2595. ASSERT(prRxCtrl);
  2596. if (pvPacket) {
  2597. kalPacketFree(prAdapter->prGlueInfo, pvPacket);
  2598. RX_ADD_CNT(prRxCtrl, RX_DATA_RETURNED_COUNT, 1);
  2599. #if CFG_NATIVE_802_11
  2600. if (GLUE_TEST_FLAG(prAdapter->prGlueInfo, GLUE_FLAG_HALT)) {
  2601. /*Todo:: nothing*/
  2602. /*Todo:: nothing*/
  2603. }
  2604. #endif
  2605. }
  2606. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_FREE_QUE);
  2607. QUEUE_REMOVE_HEAD(&prRxCtrl->rIndicatedRfbList, prSwRfb, P_SW_RFB_T);
  2608. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_RX_FREE_QUE);
  2609. if (!prSwRfb) {
  2610. DBGLOG(RX, WARN, "No free SwRfb!\n");
  2611. return;
  2612. }
  2613. if (nicRxSetupRFB(prAdapter, prSwRfb)) {
  2614. DBGLOG(RX, WARN, "Cannot allocate packet buffer for SwRfb!\n");
  2615. if (!timerPendingTimer(&prAdapter->rPacketDelaySetupTimer)) {
  2616. DBGLOG(RX, WARN,
  2617. "Start ReturnIndicatedRfb Timer (%u)\n", RX_RETURN_INDICATED_RFB_TIMEOUT_SEC);
  2618. cnmTimerStartTimer(prAdapter, &prAdapter->rPacketDelaySetupTimer,
  2619. SEC_TO_MSEC(RX_RETURN_INDICATED_RFB_TIMEOUT_SEC));
  2620. }
  2621. }
  2622. nicRxReturnRFB(prAdapter, prSwRfb);
  2623. }
  2624. /*----------------------------------------------------------------------------*/
  2625. /*!
  2626. * \brief This function is a required function that returns information about
  2627. * the capabilities and status of the driver and/or its network adapter.
  2628. *
  2629. * \param[IN] prAdapter Pointer to the Adapter structure.
  2630. * \param[IN] pfnOidQryHandler Function pointer for the OID query handler.
  2631. * \param[IN] pvInfoBuf Points to a buffer for return the query information.
  2632. * \param[IN] u4QueryBufferLen Specifies the number of bytes at pvInfoBuf.
  2633. * \param[OUT] pu4QueryInfoLen Points to the number of bytes it written or is needed.
  2634. *
  2635. * \retval WLAN_STATUS_xxx Different WLAN_STATUS code returned by different handlers.
  2636. *
  2637. */
  2638. /*----------------------------------------------------------------------------*/
  2639. WLAN_STATUS
  2640. wlanQueryInformation(IN P_ADAPTER_T prAdapter,
  2641. IN PFN_OID_HANDLER_FUNC pfnOidQryHandler,
  2642. IN PVOID pvInfoBuf, IN UINT_32 u4InfoBufLen, OUT PUINT_32 pu4QryInfoLen)
  2643. {
  2644. WLAN_STATUS status = WLAN_STATUS_FAILURE;
  2645. ASSERT(prAdapter);
  2646. ASSERT(pu4QryInfoLen);
  2647. /* ignore any OID request after connected, under PS current measurement mode */
  2648. if (prAdapter->u4PsCurrentMeasureEn &&
  2649. (prAdapter->prGlueInfo->eParamMediaStateIndicated == PARAM_MEDIA_STATE_CONNECTED)) {
  2650. /* note: return WLAN_STATUS_FAILURE or
  2651. * WLAN_STATUS_SUCCESS for blocking OIDs during current measurement ?? */
  2652. return WLAN_STATUS_SUCCESS;
  2653. }
  2654. #if 1
  2655. /* most OID handler will just queue a command packet */
  2656. status = pfnOidQryHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4QryInfoLen);
  2657. #else
  2658. if (wlanIsHandlerNeedHwAccess(pfnOidQryHandler, FALSE)) {
  2659. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  2660. /* Reset sleepy state */
  2661. if (prAdapter->fgWiFiInSleepyState == TRUE)
  2662. prAdapter->fgWiFiInSleepyState = FALSE;
  2663. status = pfnOidQryHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4QryInfoLen);
  2664. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  2665. } else
  2666. status = pfnOidQryHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4QryInfoLen);
  2667. #endif
  2668. return status;
  2669. }
  2670. /*----------------------------------------------------------------------------*/
  2671. /*!
  2672. * \brief This function is a required function that allows bound protocol drivers,
  2673. * or NDIS, to request changes in the state information that the miniport
  2674. * maintains for particular object identifiers, such as changes in multicast
  2675. * addresses.
  2676. *
  2677. * \param[IN] prAdapter Pointer to the Glue info structure.
  2678. * \param[IN] pfnOidSetHandler Points to the OID set handlers.
  2679. * \param[IN] pvInfoBuf Points to a buffer containing the OID-specific data for the set.
  2680. * \param[IN] u4InfoBufLen Specifies the number of bytes at prSetBuffer.
  2681. * \param[OUT] pu4SetInfoLen Points to the number of bytes it read or is needed.
  2682. *
  2683. * \retval WLAN_STATUS_xxx Different WLAN_STATUS code returned by different handlers.
  2684. *
  2685. */
  2686. /*----------------------------------------------------------------------------*/
  2687. WLAN_STATUS
  2688. wlanSetInformation(IN P_ADAPTER_T prAdapter,
  2689. IN PFN_OID_HANDLER_FUNC pfnOidSetHandler,
  2690. IN PVOID pvInfoBuf, IN UINT_32 u4InfoBufLen, OUT PUINT_32 pu4SetInfoLen)
  2691. {
  2692. WLAN_STATUS status = WLAN_STATUS_FAILURE;
  2693. ASSERT(prAdapter);
  2694. ASSERT(pu4SetInfoLen);
  2695. /* ignore any OID request after connected, under PS current measurement mode */
  2696. if (prAdapter->u4PsCurrentMeasureEn &&
  2697. (prAdapter->prGlueInfo->eParamMediaStateIndicated == PARAM_MEDIA_STATE_CONNECTED)) {
  2698. /* note: return WLAN_STATUS_FAILURE or WLAN_STATUS_SUCCESS
  2699. * for blocking OIDs during current measurement ?? */
  2700. return WLAN_STATUS_SUCCESS;
  2701. }
  2702. #if 1
  2703. /* most OID handler will just queue a command packet
  2704. * for power state transition OIDs, handler will acquire power control by itself
  2705. */
  2706. status = pfnOidSetHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4SetInfoLen);
  2707. #else
  2708. if (wlanIsHandlerNeedHwAccess(pfnOidSetHandler, TRUE)) {
  2709. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  2710. /* Reset sleepy state */
  2711. if (prAdapter->fgWiFiInSleepyState == TRUE)
  2712. prAdapter->fgWiFiInSleepyState = FALSE;
  2713. status = pfnOidSetHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4SetInfoLen);
  2714. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  2715. } else {
  2716. status = pfnOidSetHandler(prAdapter, pvInfoBuf, u4InfoBufLen, pu4SetInfoLen);
  2717. }
  2718. #endif
  2719. return status;
  2720. }
  2721. #if CFG_SUPPORT_WAPI
  2722. /*----------------------------------------------------------------------------*/
  2723. /*!
  2724. * \brief This function is a used to query driver's config wapi mode or not
  2725. *
  2726. * \param[IN] prAdapter Pointer to the Glue info structure.
  2727. *
  2728. * \retval TRUE for use wapi mode
  2729. *
  2730. */
  2731. /*----------------------------------------------------------------------------*/
  2732. BOOLEAN wlanQueryWapiMode(IN P_ADAPTER_T prAdapter)
  2733. {
  2734. ASSERT(prAdapter);
  2735. return prAdapter->rWifiVar.rConnSettings.fgWapiMode;
  2736. }
  2737. #endif
  2738. /*----------------------------------------------------------------------------*/
  2739. /*!
  2740. * \brief This function is called to set RX filter to Promiscuous Mode.
  2741. *
  2742. * \param[IN] prAdapter Pointer to the Adapter structure.
  2743. * \param[IN] fgEnablePromiscuousMode Enable/ disable RX Promiscuous Mode.
  2744. *
  2745. * \return (none)
  2746. */
  2747. /*----------------------------------------------------------------------------*/
  2748. VOID wlanSetPromiscuousMode(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgEnablePromiscuousMode)
  2749. {
  2750. ASSERT(prAdapter);
  2751. }
  2752. /*----------------------------------------------------------------------------*/
  2753. /*!
  2754. * \brief This function is called to set RX filter to allow to receive
  2755. * broadcast address packets.
  2756. *
  2757. * \param[IN] prAdapter Pointer to the Adapter structure.
  2758. * \param[IN] fgEnableBroadcast Enable/ disable broadcast packet to be received.
  2759. *
  2760. * \return (none)
  2761. */
  2762. /*----------------------------------------------------------------------------*/
  2763. VOID wlanRxSetBroadcast(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgEnableBroadcast)
  2764. {
  2765. ASSERT(prAdapter);
  2766. }
  2767. /*----------------------------------------------------------------------------*/
  2768. /*!
  2769. * \brief This function is called to send out CMD_NIC_POWER_CTRL command packet
  2770. *
  2771. * \param[IN] prAdapter Pointer to the Adapter structure.
  2772. * \param[IN] ucPowerMode refer to CMD/EVENT document
  2773. *
  2774. * \return WLAN_STATUS_SUCCESS
  2775. * \return WLAN_STATUS_FAILURE
  2776. */
  2777. /*----------------------------------------------------------------------------*/
  2778. WLAN_STATUS wlanSendNicPowerCtrlCmd(IN P_ADAPTER_T prAdapter, IN UINT_8 ucPowerMode)
  2779. {
  2780. WLAN_STATUS status = WLAN_STATUS_SUCCESS;
  2781. P_GLUE_INFO_T prGlueInfo;
  2782. P_CMD_INFO_T prCmdInfo;
  2783. P_WIFI_CMD_T prWifiCmd;
  2784. UINT_8 ucTC, ucCmdSeqNum;
  2785. ASSERT(prAdapter);
  2786. prGlueInfo = prAdapter->prGlueInfo;
  2787. /* 1. Prepare CMD */
  2788. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, (CMD_HDR_SIZE + sizeof(CMD_NIC_POWER_CTRL)));
  2789. if (!prCmdInfo) {
  2790. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  2791. return WLAN_STATUS_FAILURE;
  2792. }
  2793. /* 2.1 increase command sequence number */
  2794. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  2795. DBGLOG(REQ, TRACE, "ucCmdSeqNum =%d\n", ucCmdSeqNum);
  2796. /* 2.2 Setup common CMD Info Packet */
  2797. prCmdInfo->eCmdType = COMMAND_TYPE_GENERAL_IOCTL;
  2798. prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + sizeof(CMD_NIC_POWER_CTRL));
  2799. prCmdInfo->pfCmdDoneHandler = NULL;
  2800. prCmdInfo->pfCmdTimeoutHandler = NULL;
  2801. prCmdInfo->fgIsOid = TRUE;
  2802. prCmdInfo->ucCID = CMD_ID_NIC_POWER_CTRL;
  2803. prCmdInfo->fgSetQuery = TRUE;
  2804. prCmdInfo->fgNeedResp = FALSE;
  2805. prCmdInfo->fgDriverDomainMCR = FALSE;
  2806. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  2807. prCmdInfo->u4SetInfoLen = sizeof(CMD_NIC_POWER_CTRL);
  2808. /* 2.3 Setup WIFI_CMD_T */
  2809. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  2810. prWifiCmd->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  2811. prWifiCmd->u2PQ_ID = CMD_PQ_ID;
  2812. prWifiCmd->ucPktTypeID = CMD_PACKET_TYPE_ID;
  2813. prWifiCmd->ucCID = prCmdInfo->ucCID;
  2814. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  2815. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  2816. kalMemZero(prWifiCmd->aucBuffer, sizeof(CMD_NIC_POWER_CTRL));
  2817. ((P_CMD_NIC_POWER_CTRL) (prWifiCmd->aucBuffer))->ucPowerMode = ucPowerMode;
  2818. /* 3. Issue CMD for entering specific power mode */
  2819. ucTC = TC4_INDEX;
  2820. while (1) {
  2821. /* 3.0 Removal check */
  2822. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  2823. status = WLAN_STATUS_FAILURE;
  2824. break;
  2825. }
  2826. /* 3.1 Acquire TX Resource */
  2827. if (nicTxAcquireResource(prAdapter, ucTC, nicTxGetCmdPageCount(prCmdInfo)) == WLAN_STATUS_RESOURCES) {
  2828. if (nicTxPollingResource(prAdapter, ucTC) != WLAN_STATUS_SUCCESS) {
  2829. DBGLOG(INIT, ERROR, "Fail to get TX resource return within timeout\n");
  2830. status = WLAN_STATUS_FAILURE;
  2831. prAdapter->fgIsChipNoAck = TRUE;
  2832. break;
  2833. }
  2834. continue;
  2835. }
  2836. /* 3.2 Send CMD Info Packet */
  2837. if (nicTxCmd(prAdapter, prCmdInfo, ucTC) != WLAN_STATUS_SUCCESS) {
  2838. DBGLOG(INIT, ERROR, "Fail to transmit CMD_NIC_POWER_CTRL command\n");
  2839. status = WLAN_STATUS_FAILURE;
  2840. }
  2841. break;
  2842. };
  2843. /* 4. Free CMD Info Packet. */
  2844. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2845. /* 5. Add flag */
  2846. if (ucPowerMode == 1)
  2847. prAdapter->fgIsEnterD3ReqIssued = TRUE;
  2848. return status;
  2849. }
  2850. /*----------------------------------------------------------------------------*/
  2851. /*!
  2852. * \brief This function is called to check if it is RF test mode and
  2853. * the OID is allowed to be called or not
  2854. *
  2855. * \param[IN] prAdapter Pointer to the Adapter structure.
  2856. * \param[IN] fgEnableBroadcast Enable/ disable broadcast packet to be received.
  2857. *
  2858. * \return (none)
  2859. */
  2860. /*----------------------------------------------------------------------------*/
  2861. BOOLEAN wlanIsHandlerAllowedInRFTest(IN PFN_OID_HANDLER_FUNC pfnOidHandler, IN BOOLEAN fgSetInfo)
  2862. {
  2863. PFN_OID_HANDLER_FUNC *apfnOidHandlerAllowedInRFTest;
  2864. UINT_32 i;
  2865. UINT_32 u4NumOfElem;
  2866. if (fgSetInfo) {
  2867. apfnOidHandlerAllowedInRFTest = apfnOidSetHandlerAllowedInRFTest;
  2868. u4NumOfElem = sizeof(apfnOidSetHandlerAllowedInRFTest) / sizeof(PFN_OID_HANDLER_FUNC);
  2869. } else {
  2870. apfnOidHandlerAllowedInRFTest = apfnOidQueryHandlerAllowedInRFTest;
  2871. u4NumOfElem = sizeof(apfnOidQueryHandlerAllowedInRFTest) / sizeof(PFN_OID_HANDLER_FUNC);
  2872. }
  2873. for (i = 0; i < u4NumOfElem; i++) {
  2874. if (apfnOidHandlerAllowedInRFTest[i] == pfnOidHandler)
  2875. return TRUE;
  2876. }
  2877. return FALSE;
  2878. }
  2879. #if CFG_ENABLE_FW_DOWNLOAD
  2880. /*----------------------------------------------------------------------------*/
  2881. /*!
  2882. * @brief This function is called to configure FWDL parameters
  2883. *
  2884. * @param prAdapter Pointer to the Adapter structure.
  2885. * u4DestAddr Address of destination address
  2886. * u4ImgSecSize Length of the firmware block
  2887. * fgReset should be set to TRUE if this is the 1st configuration
  2888. *
  2889. * @return WLAN_STATUS_SUCCESS
  2890. * WLAN_STATUS_FAILURE
  2891. */
  2892. /*----------------------------------------------------------------------------*/
  2893. WLAN_STATUS
  2894. wlanImageSectionConfig(IN P_ADAPTER_T prAdapter, IN UINT_32 u4DestAddr, IN UINT_32 u4ImgSecSize, IN BOOLEAN fgReset)
  2895. {
  2896. P_CMD_INFO_T prCmdInfo;
  2897. P_INIT_HIF_TX_HEADER_T prInitHifTxHeader;
  2898. P_INIT_CMD_DOWNLOAD_CONFIG prInitCmdDownloadConfig;
  2899. UINT_8 ucTC, ucCmdSeqNum;
  2900. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  2901. ASSERT(prAdapter);
  2902. DEBUGFUNC("wlanImageSectionConfig");
  2903. if (u4ImgSecSize == 0)
  2904. return WLAN_STATUS_SUCCESS;
  2905. /* 1. Allocate CMD Info Packet and its Buffer. */
  2906. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, sizeof(INIT_HIF_TX_HEADER_T) + sizeof(INIT_CMD_DOWNLOAD_CONFIG));
  2907. if (!prCmdInfo) {
  2908. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  2909. return WLAN_STATUS_FAILURE;
  2910. }
  2911. prCmdInfo->u2InfoBufLen = sizeof(INIT_HIF_TX_HEADER_T) + sizeof(INIT_CMD_DOWNLOAD_CONFIG);
  2912. /* 2. Use TC4's resource to download image. (TC4 as CPU) */
  2913. ucTC = TC4_INDEX;
  2914. /* 3. increase command sequence number */
  2915. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  2916. /* 4. Setup common CMD Info Packet */
  2917. prInitHifTxHeader = (P_INIT_HIF_TX_HEADER_T) (prCmdInfo->pucInfoBuffer);
  2918. prInitHifTxHeader->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  2919. prInitHifTxHeader->u2PQ_ID = INIT_CMD_PQ_ID;
  2920. prInitHifTxHeader->rInitWifiCmd.ucCID = INIT_CMD_ID_DOWNLOAD_CONFIG;
  2921. prInitHifTxHeader->rInitWifiCmd.ucPktTypeID = INIT_CMD_PACKET_TYPE_ID;
  2922. prInitHifTxHeader->rInitWifiCmd.ucSeqNum = ucCmdSeqNum;
  2923. /* 5. Setup CMD_DOWNLOAD_CONFIG */
  2924. prInitCmdDownloadConfig = (P_INIT_CMD_DOWNLOAD_CONFIG) (prInitHifTxHeader->rInitWifiCmd.aucBuffer);
  2925. prInitCmdDownloadConfig->u4Address = u4DestAddr;
  2926. prInitCmdDownloadConfig->u4Length = u4ImgSecSize;
  2927. prInitCmdDownloadConfig->u4DataMode = 0
  2928. #if CFG_ENABLE_FW_DOWNLOAD_ACK
  2929. | DOWNLOAD_CONFIG_ACK_OPTION /* ACK needed */
  2930. #endif
  2931. #if CFG_ENABLE_FW_ENCRYPTION
  2932. | DOWNLOAD_CONFIG_ENCRYPTION_MODE
  2933. #endif
  2934. ;
  2935. if (fgReset == TRUE)
  2936. prInitCmdDownloadConfig->u4DataMode |= DOWNLOAD_CONFIG_RESET_OPTION;
  2937. /* 6. Send FW_Download command */
  2938. while (1) {
  2939. /* 6.1 Acquire TX Resource */
  2940. if (nicTxAcquireResource
  2941. (prAdapter, ucTC, nicTxGetPageCount(prCmdInfo->u2InfoBufLen, TRUE)) == WLAN_STATUS_RESOURCES) {
  2942. if (nicTxPollingResource(prAdapter, ucTC) != WLAN_STATUS_SUCCESS) {
  2943. u4Status = WLAN_STATUS_FAILURE;
  2944. DBGLOG(INIT, ERROR, "Fail to get TX resource return within timeout\n");
  2945. break;
  2946. }
  2947. continue;
  2948. }
  2949. /* 6.2 Send CMD Info Packet */
  2950. if (nicTxInitCmd(prAdapter, prCmdInfo) != WLAN_STATUS_SUCCESS) {
  2951. u4Status = WLAN_STATUS_FAILURE;
  2952. DBGLOG(INIT, ERROR, "Fail to transmit image download command\n");
  2953. }
  2954. break;
  2955. };
  2956. #if CFG_ENABLE_FW_DOWNLOAD_ACK
  2957. /* 7. Wait for INIT_EVENT_ID_CMD_RESULT */
  2958. u4Status = wlanImageSectionDownloadStatus(prAdapter, ucCmdSeqNum);
  2959. #endif
  2960. /* 8. Free CMD Info Packet. */
  2961. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  2962. return u4Status;
  2963. }
  2964. /*----------------------------------------------------------------------------*/
  2965. /*!
  2966. * @brief This function is called to download FW image.
  2967. *
  2968. * @param prAdapter Pointer to the Adapter structure.
  2969. *
  2970. * @return (none)
  2971. */
  2972. /*----------------------------------------------------------------------------*/
  2973. WLAN_STATUS wlanImageSectionDownload(IN P_ADAPTER_T prAdapter, IN UINT_32 u4ImgSecSize, IN PUINT_8 pucImgSecBuf)
  2974. {
  2975. P_CMD_INFO_T prCmdInfo;
  2976. P_INIT_HIF_TX_HEADER_T prInitHifTxHeader;
  2977. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  2978. ASSERT(prAdapter);
  2979. ASSERT(pucImgSecBuf);
  2980. ASSERT(u4ImgSecSize <= CMD_PKT_SIZE_FOR_IMAGE);
  2981. DEBUGFUNC("wlanImageSectionDownload");
  2982. if (u4ImgSecSize == 0)
  2983. return WLAN_STATUS_SUCCESS;
  2984. /* 1. Allocate CMD Info Packet and its Buffer. */
  2985. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, sizeof(INIT_HIF_TX_HEADER_T) + u4ImgSecSize);
  2986. if (!prCmdInfo) {
  2987. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  2988. return WLAN_STATUS_FAILURE;
  2989. }
  2990. prCmdInfo->u2InfoBufLen = sizeof(INIT_HIF_TX_HEADER_T) + (UINT_16) u4ImgSecSize;
  2991. /* 2. Setup common CMD Info Packet */
  2992. prInitHifTxHeader = (P_INIT_HIF_TX_HEADER_T) (prCmdInfo->pucInfoBuffer);
  2993. prInitHifTxHeader->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  2994. prInitHifTxHeader->u2PQ_ID = INIT_CMD_PDA_PQ_ID;
  2995. prInitHifTxHeader->rInitWifiCmd.ucCID = 0;
  2996. prInitHifTxHeader->rInitWifiCmd.ucPktTypeID = INIT_CMD_PDA_PACKET_TYPE_ID;
  2997. prInitHifTxHeader->rInitWifiCmd.ucSeqNum = 0;
  2998. /* 3. Setup DOWNLOAD_BUF */
  2999. kalMemCopy(prInitHifTxHeader->rInitWifiCmd.aucBuffer, pucImgSecBuf, u4ImgSecSize);
  3000. /* 4. Send FW_Download command */
  3001. if (nicTxInitCmd(prAdapter, prCmdInfo) != WLAN_STATUS_SUCCESS) {
  3002. u4Status = WLAN_STATUS_FAILURE;
  3003. DBGLOG(INIT, ERROR, "Fail to transmit image download command\n");
  3004. }
  3005. /* 5. Free CMD Info Packet. */
  3006. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3007. return u4Status;
  3008. }
  3009. /* for AOSP */
  3010. /*----------------------------------------------------------------------------*/
  3011. /*!
  3012. * @brief This function is called to download FW by ilm and dlm section.
  3013. *
  3014. * @param prAdapter Pointer to the Adapter structure.
  3015. *
  3016. * @return (none)
  3017. */
  3018. /*----------------------------------------------------------------------------*/
  3019. VOID
  3020. wlanFwDvdDwnloadHandler(IN P_ADAPTER_T prAdapter,
  3021. IN P_FIRMWARE_DIVIDED_DOWNLOAD_T prFwHead, IN PVOID pvFwImageMapFile,
  3022. OUT WLAN_STATUS *u4Status)
  3023. {
  3024. UINT_32 u4ImgSecSize, i, j;
  3025. for (i = 0; i < prFwHead->u4NumOfEntries; i++) {
  3026. if (wlanImageSectionConfig(prAdapter,
  3027. prFwHead->arSection[i].u4DestAddr,
  3028. prFwHead->arSection[i].u4Length,
  3029. i == 0 ? TRUE : FALSE) != WLAN_STATUS_SUCCESS) {
  3030. DBGLOG(INIT, ERROR, "Firmware download configuration failed!\n");
  3031. *u4Status = WLAN_STATUS_FAILURE;
  3032. break;
  3033. }
  3034. for (j = 0; j < prFwHead->arSection[i].u4Length; j += CMD_PKT_SIZE_FOR_IMAGE) {
  3035. if (j + CMD_PKT_SIZE_FOR_IMAGE < prFwHead->arSection[i].u4Length)
  3036. u4ImgSecSize = CMD_PKT_SIZE_FOR_IMAGE;
  3037. else
  3038. u4ImgSecSize = prFwHead->arSection[i].u4Length - j;
  3039. if (wlanImageSectionDownload(prAdapter,
  3040. u4ImgSecSize,
  3041. (PUINT_8) pvFwImageMapFile +
  3042. prFwHead->arSection[i].u4Offset + j) !=
  3043. WLAN_STATUS_SUCCESS) {
  3044. DBGLOG(INIT, ERROR, "Firmware scatter download failed!\n");
  3045. *u4Status = WLAN_STATUS_FAILURE;
  3046. break;
  3047. }
  3048. }
  3049. /* escape from loop if any pending error occurs */
  3050. if (*u4Status == WLAN_STATUS_FAILURE)
  3051. break;
  3052. }
  3053. }
  3054. /* for AOSP */
  3055. /*----------------------------------------------------------------------------*/
  3056. /*!
  3057. * @brief This function is called to download FW
  3058. *
  3059. * @param prAdapter Pointer to the Adapter structure.
  3060. *
  3061. * @return (none)
  3062. */
  3063. /*----------------------------------------------------------------------------*/
  3064. VOID
  3065. wlanFwDwnloadHandler(IN P_ADAPTER_T prAdapter,
  3066. IN UINT_32 u4FwImgLength, IN PVOID pvFwImageMapFile, OUT WLAN_STATUS *u4Status)
  3067. {
  3068. UINT_32 u4ImgSecSize, i;
  3069. for (i = 0; i < u4FwImgLength; i += CMD_PKT_SIZE_FOR_IMAGE) {
  3070. if (i + CMD_PKT_SIZE_FOR_IMAGE < u4FwImgLength)
  3071. u4ImgSecSize = CMD_PKT_SIZE_FOR_IMAGE;
  3072. else
  3073. u4ImgSecSize = u4FwImgLength - i;
  3074. if (wlanImageSectionDownload(prAdapter,
  3075. u4ImgSecSize, (PUINT_8) pvFwImageMapFile + i) != WLAN_STATUS_SUCCESS) {
  3076. DBGLOG(INIT, ERROR, "wlanImageSectionDownload failed!\n");
  3077. *u4Status = WLAN_STATUS_FAILURE;
  3078. break;
  3079. }
  3080. }
  3081. }
  3082. #if !CFG_ENABLE_FW_DOWNLOAD_ACK
  3083. /*----------------------------------------------------------------------------*/
  3084. /*!
  3085. * @brief This function is called to confirm previously firmware download is done without error
  3086. *
  3087. * @param prAdapter Pointer to the Adapter structure.
  3088. *
  3089. * @return (none)
  3090. */
  3091. /*----------------------------------------------------------------------------*/
  3092. WLAN_STATUS wlanImageQueryStatus(IN P_ADAPTER_T prAdapter)
  3093. {
  3094. P_CMD_INFO_T prCmdInfo;
  3095. P_INIT_HIF_TX_HEADER_T prInitHifTxHeader;
  3096. UINT_8 aucBuffer[sizeof(INIT_HIF_RX_HEADER_T) + sizeof(INIT_EVENT_PENDING_ERROR)];
  3097. UINT_32 u4RxPktLength;
  3098. P_INIT_HIF_RX_HEADER_T prInitHifRxHeader;
  3099. P_INIT_EVENT_PENDING_ERROR prEventPendingError;
  3100. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  3101. UINT_8 ucTC, ucCmdSeqNum;
  3102. ASSERT(prAdapter);
  3103. DEBUGFUNC("wlanImageQueryStatus");
  3104. /* 1. Allocate CMD Info Packet and it Buffer. */
  3105. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, sizeof(INIT_HIF_TX_HEADER_T));
  3106. if (!prCmdInfo) {
  3107. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  3108. return WLAN_STATUS_FAILURE;
  3109. }
  3110. kalMemZero(prCmdInfo->pucInfoBuffer, sizeof(INIT_HIF_TX_HEADER_T));
  3111. prCmdInfo->u2InfoBufLen = sizeof(INIT_HIF_TX_HEADER_T);
  3112. /* 2. Use TC0's resource to download image. (only TC0 is allowed) */
  3113. ucTC = TC0_INDEX;
  3114. /* 3. increase command sequence number */
  3115. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  3116. /* 4. Setup common CMD Info Packet */
  3117. prInitHifTxHeader = (P_INIT_HIF_TX_HEADER_T) (prCmdInfo->pucInfoBuffer);
  3118. prInitHifTxHeader->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  3119. prInitHifTxHeader->u2PQ_ID = INIT_CMD_PQ_ID;
  3120. prInitHifTxHeader->rInitWifiCmd.ucCID = INIT_CMD_ID_QUERY_PENDING_ERROR;
  3121. prInitHifTxHeader->rInitWifiCmd.ucPktTypeID = INIT_CMD_PACKET_TYPE_ID;
  3122. prInitHifTxHeader->rInitWifiCmd.ucSeqNum = ucCmdSeqNum;
  3123. /* 5. Send command */
  3124. while (1) {
  3125. /* 5.1 Acquire TX Resource */
  3126. if (nicTxAcquireResource
  3127. (prAdapter, ucTC, nicTxGetPageCount(prCmdInfo->u2InfoBufLen, TRUE)) == WLAN_STATUS_RESOURCES) {
  3128. if (nicTxPollingResource(prAdapter, ucTC) != WLAN_STATUS_SUCCESS) {
  3129. u4Status = WLAN_STATUS_FAILURE;
  3130. DBGLOG(INIT, ERROR, "Fail to get TX resource return within timeout\n");
  3131. break;
  3132. }
  3133. continue;
  3134. }
  3135. /* 5.2 Send CMD Info Packet */
  3136. if (nicTxInitCmd(prAdapter, prCmdInfo) != WLAN_STATUS_SUCCESS) {
  3137. u4Status = WLAN_STATUS_FAILURE;
  3138. DBGLOG(INIT, ERROR, "Fail to transmit image download command\n");
  3139. }
  3140. break;
  3141. };
  3142. /* 6. Wait for INIT_EVENT_ID_PENDING_ERROR */
  3143. do {
  3144. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  3145. u4Status = WLAN_STATUS_FAILURE;
  3146. } else if (nicRxWaitResponse(prAdapter,
  3147. 0,
  3148. aucBuffer,
  3149. sizeof(INIT_HIF_RX_HEADER_T) +
  3150. sizeof(INIT_EVENT_PENDING_ERROR), &u4RxPktLength) != WLAN_STATUS_SUCCESS) {
  3151. u4Status = WLAN_STATUS_FAILURE;
  3152. } else {
  3153. prInitHifRxHeader = (P_INIT_HIF_RX_HEADER_T) aucBuffer;
  3154. /* EID / SeqNum check */
  3155. if (prInitHifRxHeader->rInitWifiEvent.ucEID != INIT_EVENT_ID_PENDING_ERROR) {
  3156. u4Status = WLAN_STATUS_FAILURE;
  3157. } else if (prInitHifRxHeader->rInitWifiEvent.ucSeqNum != ucCmdSeqNum) {
  3158. u4Status = WLAN_STATUS_FAILURE;
  3159. } else {
  3160. prEventPendingError =
  3161. (P_INIT_EVENT_PENDING_ERROR) (prInitHifRxHeader->rInitWifiEvent.aucBuffer);
  3162. if (prEventPendingError->ucStatus != 0) { /* 0 for download success */
  3163. u4Status = WLAN_STATUS_FAILURE;
  3164. } else {
  3165. u4Status = WLAN_STATUS_SUCCESS;
  3166. }
  3167. }
  3168. }
  3169. } while (FALSE);
  3170. /* 7. Free CMD Info Packet. */
  3171. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3172. return u4Status;
  3173. }
  3174. #else
  3175. /*----------------------------------------------------------------------------*/
  3176. /*!
  3177. * @brief This function is called to confirm the status of
  3178. * previously downloaded firmware scatter
  3179. *
  3180. * @param prAdapter Pointer to the Adapter structure.
  3181. * ucCmdSeqNum Sequence number of previous firmware scatter
  3182. *
  3183. * @return WLAN_STATUS_SUCCESS
  3184. * WLAN_STATUS_FAILURE
  3185. */
  3186. /*----------------------------------------------------------------------------*/
  3187. WLAN_STATUS wlanImageSectionDownloadStatus(IN P_ADAPTER_T prAdapter, IN UINT_8 ucCmdSeqNum)
  3188. {
  3189. UINT_8 aucBuffer[sizeof(INIT_HIF_RX_HEADER_T) + sizeof(INIT_EVENT_CMD_RESULT)];
  3190. P_INIT_HIF_RX_HEADER_T prInitHifRxHeader;
  3191. P_INIT_EVENT_CMD_RESULT prEventCmdResult;
  3192. UINT_32 u4RxPktLength;
  3193. WLAN_STATUS u4Status;
  3194. ASSERT(prAdapter);
  3195. do {
  3196. if (kalIsCardRemoved(prAdapter->prGlueInfo) == TRUE || fgIsBusAccessFailed == TRUE) {
  3197. u4Status = WLAN_STATUS_FAILURE;
  3198. } else if (nicRxWaitResponse(prAdapter,
  3199. 0,
  3200. aucBuffer,
  3201. sizeof(INIT_HIF_RX_HEADER_T) +
  3202. sizeof(INIT_EVENT_CMD_RESULT), &u4RxPktLength) != WLAN_STATUS_SUCCESS) {
  3203. u4Status = WLAN_STATUS_FAILURE;
  3204. } else {
  3205. prInitHifRxHeader = (P_INIT_HIF_RX_HEADER_T) aucBuffer;
  3206. /* EID / SeqNum check */
  3207. if (prInitHifRxHeader->rInitWifiEvent.ucEID != INIT_EVENT_ID_CMD_RESULT) {
  3208. u4Status = WLAN_STATUS_FAILURE;
  3209. } else if (prInitHifRxHeader->rInitWifiEvent.ucSeqNum != ucCmdSeqNum) {
  3210. u4Status = WLAN_STATUS_FAILURE;
  3211. } else {
  3212. prEventCmdResult =
  3213. (P_INIT_EVENT_CMD_RESULT) (prInitHifRxHeader->rInitWifiEvent.aucBuffer);
  3214. if (prEventCmdResult->ucStatus != 0) { /* 0 for download success */
  3215. u4Status = WLAN_STATUS_FAILURE;
  3216. } else {
  3217. u4Status = WLAN_STATUS_SUCCESS;
  3218. }
  3219. }
  3220. }
  3221. } while (FALSE);
  3222. return u4Status;
  3223. }
  3224. #endif
  3225. /*----------------------------------------------------------------------------*/
  3226. /*!
  3227. * @brief This function is called to start FW normal operation.
  3228. *
  3229. * @param prAdapter Pointer to the Adapter structure.
  3230. *
  3231. * @return (none)
  3232. */
  3233. /*----------------------------------------------------------------------------*/
  3234. WLAN_STATUS wlanConfigWifiFunc(IN P_ADAPTER_T prAdapter, IN BOOLEAN fgEnable, IN UINT_32 u4StartAddress)
  3235. {
  3236. P_CMD_INFO_T prCmdInfo;
  3237. P_INIT_HIF_TX_HEADER_T prInitHifTxHeader;
  3238. P_INIT_CMD_WIFI_START prInitCmdWifiStart;
  3239. UINT_8 ucTC, ucCmdSeqNum;
  3240. WLAN_STATUS u4Status = WLAN_STATUS_SUCCESS;
  3241. ASSERT(prAdapter);
  3242. DEBUGFUNC("wlanConfigWifiFunc");
  3243. /* 1. Allocate CMD Info Packet and its Buffer. */
  3244. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, sizeof(INIT_HIF_TX_HEADER_T) + sizeof(INIT_CMD_WIFI_START));
  3245. if (!prCmdInfo) {
  3246. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  3247. return WLAN_STATUS_FAILURE;
  3248. }
  3249. kalMemZero(prCmdInfo->pucInfoBuffer, sizeof(INIT_HIF_TX_HEADER_T) + sizeof(INIT_CMD_WIFI_START));
  3250. prCmdInfo->u2InfoBufLen = sizeof(INIT_HIF_TX_HEADER_T) + sizeof(INIT_CMD_WIFI_START);
  3251. /* 2. Always use TC0 */
  3252. ucTC = TC0_INDEX;
  3253. /* 3. increase command sequence number */
  3254. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  3255. /* 4. Setup common CMD Info Packet */
  3256. prInitHifTxHeader = (P_INIT_HIF_TX_HEADER_T) (prCmdInfo->pucInfoBuffer);
  3257. prInitHifTxHeader->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  3258. prInitHifTxHeader->u2PQ_ID = INIT_CMD_PQ_ID;
  3259. prInitHifTxHeader->rInitWifiCmd.ucCID = INIT_CMD_ID_WIFI_START;
  3260. prInitHifTxHeader->rInitWifiCmd.ucPktTypeID = INIT_CMD_PACKET_TYPE_ID;
  3261. prInitHifTxHeader->rInitWifiCmd.ucSeqNum = ucCmdSeqNum;
  3262. prInitCmdWifiStart = (P_INIT_CMD_WIFI_START) (prInitHifTxHeader->rInitWifiCmd.aucBuffer);
  3263. prInitCmdWifiStart->u4Override = (fgEnable == TRUE ? 1 : 0);
  3264. prInitCmdWifiStart->u4Address = u4StartAddress;
  3265. /* 5. Seend WIFI start command */
  3266. while (1) {
  3267. /* 5.1 Acquire TX Resource */
  3268. if (nicTxAcquireResource
  3269. (prAdapter, ucTC, nicTxGetPageCount(prCmdInfo->u2InfoBufLen, TRUE)) == WLAN_STATUS_RESOURCES) {
  3270. if (nicTxPollingResource(prAdapter, ucTC) != WLAN_STATUS_SUCCESS) {
  3271. u4Status = WLAN_STATUS_FAILURE;
  3272. DBGLOG(INIT, ERROR, "Fail to get TX resource return within timeout\n");
  3273. break;
  3274. }
  3275. continue;
  3276. }
  3277. /* 5.2 Send CMD Info Packet */
  3278. if (nicTxInitCmd(prAdapter, prCmdInfo) != WLAN_STATUS_SUCCESS) {
  3279. u4Status = WLAN_STATUS_FAILURE;
  3280. DBGLOG(INIT, ERROR, "Fail to transmit WIFI start command\n");
  3281. }
  3282. break;
  3283. };
  3284. /* 6. Free CMD Info Packet. */
  3285. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3286. return u4Status;
  3287. }
  3288. /*----------------------------------------------------------------------------*/
  3289. /*!
  3290. * @brief This function is used to generate CRC32 checksum
  3291. *
  3292. * @param buf Pointer to the data.
  3293. * @param len data length
  3294. *
  3295. * @return crc32 value
  3296. */
  3297. /*----------------------------------------------------------------------------*/
  3298. UINT_32 wlanCRC32(PUINT_8 buf, UINT_32 len)
  3299. {
  3300. UINT_32 i, crc32 = 0xFFFFFFFF;
  3301. const UINT_32 crc32_ccitt_table[256] = {
  3302. 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
  3303. 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
  3304. 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
  3305. 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
  3306. 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
  3307. 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
  3308. 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
  3309. 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
  3310. 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
  3311. 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
  3312. 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
  3313. 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
  3314. 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
  3315. 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
  3316. 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
  3317. 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
  3318. 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
  3319. 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
  3320. 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
  3321. 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
  3322. 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
  3323. 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
  3324. 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
  3325. 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
  3326. 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
  3327. 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
  3328. 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
  3329. 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
  3330. 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
  3331. 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
  3332. 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
  3333. 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
  3334. 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
  3335. 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
  3336. 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
  3337. 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
  3338. 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
  3339. 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
  3340. 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
  3341. 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
  3342. 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
  3343. 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
  3344. 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
  3345. 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
  3346. 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
  3347. 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
  3348. 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
  3349. 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
  3350. 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
  3351. 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
  3352. 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
  3353. 0x2d02ef8d
  3354. };
  3355. for (i = 0; i < len; i++)
  3356. crc32 = crc32_ccitt_table[(crc32 ^ buf[i]) & 0xff] ^ (crc32 >> 8);
  3357. return ~crc32;
  3358. }
  3359. #endif
  3360. /*----------------------------------------------------------------------------*/
  3361. /*!
  3362. * @brief This function is called to process queued RX packets
  3363. *
  3364. * @param prAdapter Pointer to the Adapter structure.
  3365. * prSwRfbListHead Pointer to head of RX packets link list
  3366. *
  3367. * @return (none)
  3368. */
  3369. /*----------------------------------------------------------------------------*/
  3370. WLAN_STATUS wlanProcessQueuedSwRfb(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfbListHead)
  3371. {
  3372. P_SW_RFB_T prSwRfb, prNextSwRfb;
  3373. P_TX_CTRL_T prTxCtrl;
  3374. P_RX_CTRL_T prRxCtrl;
  3375. ASSERT(prAdapter);
  3376. ASSERT(prSwRfbListHead);
  3377. prTxCtrl = &prAdapter->rTxCtrl;
  3378. prRxCtrl = &prAdapter->rRxCtrl;
  3379. prSwRfb = prSwRfbListHead;
  3380. do {
  3381. /* save next first */
  3382. prNextSwRfb = (P_SW_RFB_T) QUEUE_GET_NEXT_ENTRY((P_QUE_ENTRY_T) prSwRfb);
  3383. switch (prSwRfb->eDst) {
  3384. case RX_PKT_DESTINATION_HOST:
  3385. nicRxProcessPktWithoutReorder(prAdapter, prSwRfb);
  3386. break;
  3387. case RX_PKT_DESTINATION_FORWARD:
  3388. nicRxProcessForwardPkt(prAdapter, prSwRfb);
  3389. break;
  3390. case RX_PKT_DESTINATION_HOST_WITH_FORWARD:
  3391. nicRxProcessGOBroadcastPkt(prAdapter, prSwRfb);
  3392. break;
  3393. case RX_PKT_DESTINATION_NULL:
  3394. nicRxReturnRFB(prAdapter, prSwRfb);
  3395. break;
  3396. default:
  3397. break;
  3398. }
  3399. #if CFG_HIF_RX_STARVATION_WARNING
  3400. prRxCtrl->u4DequeuedCnt++;
  3401. #endif
  3402. prSwRfb = prNextSwRfb;
  3403. } while (prSwRfb);
  3404. return WLAN_STATUS_SUCCESS;
  3405. }
  3406. /*----------------------------------------------------------------------------*/
  3407. /*!
  3408. * @brief This function is called to purge queued TX packets
  3409. * by indicating failure to OS and returned to free list
  3410. *
  3411. * @param prAdapter Pointer to the Adapter structure.
  3412. * prMsduInfoListHead Pointer to head of TX packets link list
  3413. *
  3414. * @return (none)
  3415. */
  3416. /*----------------------------------------------------------------------------*/
  3417. WLAN_STATUS wlanProcessQueuedMsduInfo(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfoListHead)
  3418. {
  3419. ASSERT(prAdapter);
  3420. ASSERT(prMsduInfoListHead);
  3421. nicTxFreeMsduInfoPacket(prAdapter, prMsduInfoListHead);
  3422. nicTxReturnMsduInfo(prAdapter, prMsduInfoListHead);
  3423. return WLAN_STATUS_SUCCESS;
  3424. }
  3425. /*----------------------------------------------------------------------------*/
  3426. /*!
  3427. * @brief This function is called to check if the OID handler needs timeout
  3428. *
  3429. * @param prAdapter Pointer to the Adapter structure.
  3430. * pfnOidHandler Pointer to the OID handler
  3431. *
  3432. * @return TRUE
  3433. * FALSE
  3434. */
  3435. /*----------------------------------------------------------------------------*/
  3436. BOOLEAN wlanoidTimeoutCheck(IN P_ADAPTER_T prAdapter, IN PFN_OID_HANDLER_FUNC pfnOidHandler)
  3437. {
  3438. PFN_OID_HANDLER_FUNC *apfnOidHandlerWOTimeoutCheck;
  3439. UINT_32 i;
  3440. UINT_32 u4NumOfElem;
  3441. UINT_32 u4OidTimeout;
  3442. apfnOidHandlerWOTimeoutCheck = apfnOidWOTimeoutCheck;
  3443. u4NumOfElem = sizeof(apfnOidWOTimeoutCheck) / sizeof(PFN_OID_HANDLER_FUNC);
  3444. for (i = 0; i < u4NumOfElem; i++) {
  3445. if (apfnOidHandlerWOTimeoutCheck[i] == pfnOidHandler)
  3446. return FALSE;
  3447. }
  3448. /* Decrease OID timeout threshold if chip NoAck/resetting */
  3449. if (wlanIsChipNoAck(prAdapter)) {
  3450. u4OidTimeout = WLAN_OID_TIMEOUT_THRESHOLD_IN_RESETTING;
  3451. DBGLOG(INIT, INFO, "Decrease OID timeout to %ums due to NoACK/CHIP-RESET\n", u4OidTimeout);
  3452. } else {
  3453. u4OidTimeout = WLAN_OID_TIMEOUT_THRESHOLD;
  3454. }
  3455. /* Set OID timer for timeout check */
  3456. cnmTimerStartTimer(prAdapter, &(prAdapter->rOidTimeoutTimer), u4OidTimeout);
  3457. return TRUE;
  3458. }
  3459. /*----------------------------------------------------------------------------*/
  3460. /*!
  3461. * @brief This function is called to clear any pending OID timeout check
  3462. *
  3463. * @param prAdapter Pointer to the Adapter structure.
  3464. *
  3465. * @return none
  3466. */
  3467. /*----------------------------------------------------------------------------*/
  3468. VOID wlanoidClearTimeoutCheck(IN P_ADAPTER_T prAdapter)
  3469. {
  3470. ASSERT(prAdapter);
  3471. cnmTimerStopTimer(prAdapter, &(prAdapter->rOidTimeoutTimer));
  3472. }
  3473. /*----------------------------------------------------------------------------*/
  3474. /*!
  3475. * @brief This function is called to override network address
  3476. * if NVRAM has a valid value
  3477. *
  3478. * @param prAdapter Pointer to the Adapter structure.
  3479. *
  3480. * @return WLAN_STATUS_FAILURE The request could not be processed
  3481. * WLAN_STATUS_PENDING The request has been queued for later processing
  3482. * WLAN_STATUS_SUCCESS The request has been processed
  3483. */
  3484. /*----------------------------------------------------------------------------*/
  3485. WLAN_STATUS wlanUpdateNetworkAddress(IN P_ADAPTER_T prAdapter)
  3486. {
  3487. const UINT_8 aucZeroMacAddr[] = NULL_MAC_ADDR;
  3488. PARAM_MAC_ADDRESS rMacAddr = {0};
  3489. UINT_32 u4SysTime;
  3490. DEBUGFUNC("wlanUpdateNetworkAddress");
  3491. ASSERT(prAdapter);
  3492. if (kalRetrieveNetworkAddress(prAdapter->prGlueInfo, &rMacAddr) == FALSE || IS_BMCAST_MAC_ADDR(rMacAddr)
  3493. || EQUAL_MAC_ADDR(aucZeroMacAddr, rMacAddr)) {
  3494. /* eFUSE has a valid address, don't do anything */
  3495. if (prAdapter->fgIsEmbbededMacAddrValid == FALSE) {
  3496. #if CFG_SHOW_MACADDR_SOURCE
  3497. DBGLOG(INIT, INFO, "Using dynamically generated MAC address");
  3498. #endif
  3499. /* dynamic generate */
  3500. u4SysTime = (UINT_32) kalGetTimeTick();
  3501. rMacAddr[0] = 0x00;
  3502. rMacAddr[1] = 0x08;
  3503. rMacAddr[2] = 0x22;
  3504. kalMemCopy(&rMacAddr[3], &u4SysTime, 3);
  3505. } else {
  3506. #if CFG_SHOW_MACADDR_SOURCE
  3507. DBGLOG(INIT, INFO, "Using embedded MAC address");
  3508. #endif
  3509. return WLAN_STATUS_SUCCESS;
  3510. }
  3511. } else {
  3512. #if CFG_SHOW_MACADDR_SOURCE
  3513. DBGLOG(INIT, INFO, "Using host-supplied MAC address");
  3514. #endif
  3515. }
  3516. COPY_MAC_ADDR(prAdapter->rWifiVar.aucMacAddress, rMacAddr);
  3517. return WLAN_STATUS_SUCCESS;
  3518. }
  3519. /*----------------------------------------------------------------------------*/
  3520. /*!
  3521. * @brief This function is called to update basic configuration into firmware domain
  3522. *
  3523. * @param prAdapter Pointer to the Adapter structure.
  3524. *
  3525. * @return WLAN_STATUS_FAILURE The request could not be processed
  3526. * WLAN_STATUS_PENDING The request has been queued for later processing
  3527. * WLAN_STATUS_SUCCESS The request has been processed
  3528. */
  3529. /*----------------------------------------------------------------------------*/
  3530. WLAN_STATUS wlanUpdateBasicConfig(IN P_ADAPTER_T prAdapter)
  3531. {
  3532. UINT_8 ucCmdSeqNum;
  3533. P_CMD_INFO_T prCmdInfo;
  3534. P_WIFI_CMD_T prWifiCmd;
  3535. P_CMD_BASIC_CONFIG_T prCmdBasicConfig;
  3536. DEBUGFUNC("wlanUpdateBasicConfig");
  3537. ASSERT(prAdapter);
  3538. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, CMD_HDR_SIZE + sizeof(CMD_BASIC_CONFIG_T));
  3539. if (!prCmdInfo) {
  3540. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  3541. return WLAN_STATUS_FAILURE;
  3542. }
  3543. /* increase command sequence number */
  3544. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  3545. /* compose CMD_BUILD_CONNECTION cmd pkt */
  3546. prCmdInfo->eCmdType = COMMAND_TYPE_GENERAL_IOCTL;
  3547. prCmdInfo->u2InfoBufLen = CMD_HDR_SIZE + sizeof(CMD_BASIC_CONFIG_T);
  3548. prCmdInfo->pfCmdDoneHandler = NULL;
  3549. prCmdInfo->pfCmdTimeoutHandler = NULL;
  3550. prCmdInfo->fgIsOid = FALSE;
  3551. prCmdInfo->ucCID = CMD_ID_BASIC_CONFIG;
  3552. prCmdInfo->fgSetQuery = TRUE;
  3553. prCmdInfo->fgNeedResp = FALSE;
  3554. prCmdInfo->fgDriverDomainMCR = FALSE;
  3555. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  3556. prCmdInfo->u4SetInfoLen = sizeof(CMD_BASIC_CONFIG_T);
  3557. /* Setup WIFI_CMD_T */
  3558. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  3559. prWifiCmd->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  3560. prWifiCmd->u2PQ_ID = CMD_PQ_ID;
  3561. prWifiCmd->ucPktTypeID = CMD_PACKET_TYPE_ID;
  3562. prWifiCmd->ucCID = prCmdInfo->ucCID;
  3563. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  3564. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  3565. /* configure CMD_BASIC_CONFIG */
  3566. prCmdBasicConfig = (P_CMD_BASIC_CONFIG_T) (prWifiCmd->aucBuffer);
  3567. prCmdBasicConfig->ucNative80211 = 0;
  3568. prCmdBasicConfig->rCsumOffload.u2RxChecksum = 0;
  3569. prCmdBasicConfig->rCsumOffload.u2TxChecksum = 0;
  3570. #if CFG_TCP_IP_CHKSUM_OFFLOAD
  3571. if (prAdapter->u4CSUMFlags & CSUM_OFFLOAD_EN_TX_TCP)
  3572. prCmdBasicConfig->rCsumOffload.u2TxChecksum |= BIT(2);
  3573. if (prAdapter->u4CSUMFlags & CSUM_OFFLOAD_EN_TX_UDP)
  3574. prCmdBasicConfig->rCsumOffload.u2TxChecksum |= BIT(1);
  3575. if (prAdapter->u4CSUMFlags & CSUM_OFFLOAD_EN_TX_IP)
  3576. prCmdBasicConfig->rCsumOffload.u2TxChecksum |= BIT(0);
  3577. if (prAdapter->u4CSUMFlags & CSUM_OFFLOAD_EN_RX_TCP)
  3578. prCmdBasicConfig->rCsumOffload.u2RxChecksum |= BIT(2);
  3579. if (prAdapter->u4CSUMFlags & CSUM_OFFLOAD_EN_RX_UDP)
  3580. prCmdBasicConfig->rCsumOffload.u2RxChecksum |= BIT(1);
  3581. if (prAdapter->u4CSUMFlags & (CSUM_OFFLOAD_EN_RX_IPv4 | CSUM_OFFLOAD_EN_RX_IPv6))
  3582. prCmdBasicConfig->rCsumOffload.u2RxChecksum |= BIT(0);
  3583. #endif
  3584. if (wlanSendCommand(prAdapter, prCmdInfo) == WLAN_STATUS_RESOURCES) {
  3585. kalEnqueueCommand(prAdapter->prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
  3586. return WLAN_STATUS_PENDING;
  3587. }
  3588. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3589. return WLAN_STATUS_SUCCESS;
  3590. }
  3591. /*----------------------------------------------------------------------------*/
  3592. /*!
  3593. * @brief This function is called to check if the device is in RF test mode
  3594. *
  3595. * @param pfnOidHandler Pointer to the OID handler
  3596. *
  3597. * @return TRUE
  3598. * FALSE
  3599. */
  3600. /*----------------------------------------------------------------------------*/
  3601. BOOLEAN wlanQueryTestMode(IN P_ADAPTER_T prAdapter)
  3602. {
  3603. ASSERT(prAdapter);
  3604. return prAdapter->fgTestMode;
  3605. }
  3606. BOOLEAN wlanProcessTxFrame(IN P_ADAPTER_T prAdapter, IN P_NATIVE_PACKET prPacket)
  3607. {
  3608. UINT_32 u4SysTime;
  3609. UINT_8 ucMacHeaderLen;
  3610. TX_PACKET_INFO rTxPacketInfo;
  3611. ASSERT(prAdapter);
  3612. ASSERT(prPacket);
  3613. if (kalQoSFrameClassifierAndPacketInfo(prAdapter->prGlueInfo, prPacket, &rTxPacketInfo)) {
  3614. /* Save the value of Priority Parameter */
  3615. GLUE_SET_PKT_TID(prPacket, rTxPacketInfo.ucPriorityParam);
  3616. #if 1
  3617. if (rTxPacketInfo.u2Flag) {
  3618. if (rTxPacketInfo.u2Flag & BIT(ENUM_PKT_1X)) {
  3619. P_STA_RECORD_T prStaRec;
  3620. DBGLOG(TX, TRACE, "T1X len=%d\n", rTxPacketInfo.u4PacketLen);
  3621. prStaRec = cnmGetStaRecByAddress(prAdapter,
  3622. GLUE_GET_PKT_BSS_IDX(prPacket),
  3623. rTxPacketInfo.aucEthDestAddr);
  3624. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_1X);
  3625. if (secIsProtected1xFrame(prAdapter, prStaRec))
  3626. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_PROTECTED_1X);
  3627. }
  3628. if (rTxPacketInfo.u2Flag & BIT(ENUM_PKT_802_3))
  3629. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_802_3);
  3630. if (rTxPacketInfo.u2Flag & BIT(ENUM_PKT_VLAN_EXIST))
  3631. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_VLAN_EXIST);
  3632. if (rTxPacketInfo.u2Flag & BIT(ENUM_PKT_DHCP))
  3633. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_DHCP);
  3634. if (rTxPacketInfo.u2Flag & BIT(ENUM_PKT_ARP))
  3635. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_ARP);
  3636. }
  3637. #else
  3638. if (rTxPacketInfo.fgIs1X) {
  3639. P_STA_RECORD_T prStaRec;
  3640. DBGLOG(RSN, INFO, "T1X len=%d\n", rTxPacketInfo.u4PacketLen);
  3641. prStaRec = cnmGetStaRecByAddress(prAdapter,
  3642. GLUE_GET_PKT_BSS_IDX(prPacket), rTxPacketInfo.aucEthDestAddr);
  3643. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_1X);
  3644. if (secIsProtected1xFrame(prAdapter, prStaRec))
  3645. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_PROTECTED_1X);
  3646. }
  3647. if (rTxPacketInfo.fgIs802_3)
  3648. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_802_3);
  3649. if (rTxPacketInfo.fgIsVlanExists)
  3650. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_VLAN_EXIST);
  3651. if (rTxPacketInfo.fgIsDhcp)
  3652. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_DHCP);
  3653. if (rTxPacketInfo.fgIsArp)
  3654. GLUE_SET_PKT_FLAG(prPacket, ENUM_PKT_ARP);
  3655. #endif
  3656. ucMacHeaderLen = ETHER_HEADER_LEN;
  3657. /* Save the value of Header Length */
  3658. GLUE_SET_PKT_HEADER_LEN(prPacket, ucMacHeaderLen);
  3659. /* Save the value of Frame Length */
  3660. GLUE_SET_PKT_FRAME_LEN(prPacket, (UINT_16) rTxPacketInfo.u4PacketLen);
  3661. /* Save the value of Arrival Time */
  3662. u4SysTime = (OS_SYSTIME) kalGetTimeTick();
  3663. GLUE_SET_PKT_ARRIVAL_TIME(prPacket, u4SysTime);
  3664. return TRUE;
  3665. }
  3666. return FALSE;
  3667. }
  3668. /*----------------------------------------------------------------------------*/
  3669. /*!
  3670. * @brief This function is called to identify 802.1x and Bluetooth-over-Wi-Fi
  3671. * security frames, and queued into command queue for strict ordering
  3672. * due to 802.1x frames before add-key OIDs are not to be encrypted
  3673. *
  3674. * @param prAdapter Pointer of Adapter Data Structure
  3675. * @param prPacket Pointer of native packet
  3676. *
  3677. * @return TRUE
  3678. * FALSE
  3679. */
  3680. /*----------------------------------------------------------------------------*/
  3681. BOOLEAN wlanProcessSecurityFrame(IN P_ADAPTER_T prAdapter, IN P_NATIVE_PACKET prPacket)
  3682. {
  3683. P_CMD_INFO_T prCmdInfo;
  3684. P_STA_RECORD_T prStaRec;
  3685. UINT_8 ucBssIndex;
  3686. UINT_32 u4PacketLen;
  3687. UINT_8 aucEthDestAddr[PARAM_MAC_ADDR_LEN];
  3688. P_MSDU_INFO_T prMsduInfo;
  3689. ASSERT(prAdapter);
  3690. ASSERT(prPacket);
  3691. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, 0);
  3692. /* Get MSDU_INFO for TxDone */
  3693. prMsduInfo = cnmPktAlloc(prAdapter, 0);
  3694. u4PacketLen = (UINT_32) GLUE_GET_PKT_FRAME_LEN(prPacket);
  3695. if (prCmdInfo && prMsduInfo) {
  3696. ucBssIndex = GLUE_GET_PKT_BSS_IDX(prPacket);
  3697. kalGetEthDestAddr(prAdapter->prGlueInfo, prPacket, aucEthDestAddr);
  3698. prStaRec = cnmGetStaRecByAddress(prAdapter, ucBssIndex, aucEthDestAddr);
  3699. prCmdInfo->eCmdType = COMMAND_TYPE_SECURITY_FRAME;
  3700. prCmdInfo->u2InfoBufLen = (UINT_16) u4PacketLen;
  3701. prCmdInfo->prPacket = prPacket;
  3702. prCmdInfo->prMsduInfo = prMsduInfo;
  3703. if (prStaRec)
  3704. prCmdInfo->ucStaRecIndex = prStaRec->ucIndex;
  3705. else
  3706. prCmdInfo->ucStaRecIndex = STA_REC_INDEX_NOT_FOUND;
  3707. prCmdInfo->ucBssIndex = ucBssIndex;
  3708. prCmdInfo->pfCmdDoneHandler = wlanSecurityFrameTxDone;
  3709. prCmdInfo->pfCmdTimeoutHandler = wlanSecurityFrameTxTimeout;
  3710. prCmdInfo->fgIsOid = FALSE;
  3711. prCmdInfo->fgSetQuery = TRUE;
  3712. prCmdInfo->fgNeedResp = FALSE;
  3713. /* Fill-up MSDU_INFO */
  3714. nicTxSetDataPacket(prAdapter, prMsduInfo, ucBssIndex,
  3715. prCmdInfo->ucStaRecIndex, 0, u4PacketLen, nicTxDummyTxDone,
  3716. MSDU_RATE_MODE_AUTO, TX_PACKET_OS, 0, FALSE, TRUE);
  3717. prMsduInfo->prPacket = prPacket;
  3718. /* No Tx descriptor template for MMPDU */
  3719. prMsduInfo->fgIsTXDTemplateValid = FALSE;
  3720. if (GLUE_TEST_PKT_FLAG(prPacket, ENUM_PKT_PROTECTED_1X))
  3721. nicTxConfigPktOption(prMsduInfo, MSDU_OPT_PROTECTED_FRAME, TRUE);
  3722. #if CFG_SUPPORT_MULTITHREAD
  3723. nicTxComposeSecurityFrameDesc(prAdapter, prCmdInfo, prMsduInfo->aucTxDescBuffer, NULL);
  3724. #endif
  3725. kalEnqueueCommand(prAdapter->prGlueInfo, (P_QUE_ENTRY_T) prCmdInfo);
  3726. GLUE_SET_EVENT(prAdapter->prGlueInfo);
  3727. } else {
  3728. DBGLOG(RSN, INFO, "Failed to alloc CMD/MGMT INFO for 1X frame!!\n");
  3729. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3730. cnmPktFree(prAdapter, prMsduInfo);
  3731. return FALSE;
  3732. }
  3733. return TRUE;
  3734. }
  3735. /*----------------------------------------------------------------------------*/
  3736. /*!
  3737. * @brief This function is called when 802.1x or Bluetooth-over-Wi-Fi
  3738. * security frames has been sent to firmware
  3739. *
  3740. * @param prAdapter Pointer of Adapter Data Structure
  3741. * @param prCmdInfo Pointer of CMD_INFO_T
  3742. * @param pucEventBuf meaningless, only for API compatibility
  3743. *
  3744. * @return none
  3745. */
  3746. /*----------------------------------------------------------------------------*/
  3747. VOID wlanSecurityFrameTxDone(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo, IN PUINT_8 pucEventBuf)
  3748. {
  3749. ASSERT(prAdapter);
  3750. ASSERT(prCmdInfo);
  3751. if (GET_BSS_INFO_BY_INDEX(prAdapter, prCmdInfo->ucBssIndex)->eNetworkType ==
  3752. NETWORK_TYPE_AIS && prAdapter->rWifiVar.rAisSpecificBssInfo.fgCounterMeasure) {
  3753. P_STA_RECORD_T prSta = cnmGetStaRecByIndex(prAdapter, prCmdInfo->ucBssIndex);
  3754. if (prSta) {
  3755. kalMsleep(10);
  3756. if (authSendDeauthFrame(prAdapter,
  3757. GET_BSS_INFO_BY_INDEX(prAdapter,
  3758. prCmdInfo->ucBssIndex), prSta,
  3759. (P_SW_RFB_T) NULL, REASON_CODE_MIC_FAILURE, (PFN_TX_DONE_HANDLER) NULL
  3760. /* secFsmEventDeauthTxDone left upper layer handle the 60 timer */
  3761. ) != WLAN_STATUS_SUCCESS) {
  3762. ASSERT(FALSE);
  3763. }
  3764. /* secFsmEventEapolTxDone(prAdapter, prSta, TX_RESULT_SUCCESS); */
  3765. }
  3766. }
  3767. DBGLOG(RSN, INFO, "SECURITY PKT TX DONE\n");
  3768. kalSecurityFrameSendComplete(prAdapter->prGlueInfo, prCmdInfo->prPacket, WLAN_STATUS_SUCCESS);
  3769. }
  3770. /*----------------------------------------------------------------------------*/
  3771. /*!
  3772. * @brief This function is called when 802.1x or Bluetooth-over-Wi-Fi
  3773. * security frames has failed sending to firmware
  3774. *
  3775. * @param prAdapter Pointer of Adapter Data Structure
  3776. * @param prCmdInfo Pointer of CMD_INFO_T
  3777. *
  3778. * @return none
  3779. */
  3780. /*----------------------------------------------------------------------------*/
  3781. VOID wlanSecurityFrameTxTimeout(IN P_ADAPTER_T prAdapter, IN P_CMD_INFO_T prCmdInfo)
  3782. {
  3783. ASSERT(prAdapter);
  3784. ASSERT(prCmdInfo);
  3785. kalSecurityFrameSendComplete(prAdapter->prGlueInfo, prCmdInfo->prPacket, WLAN_STATUS_FAILURE);
  3786. }
  3787. /*----------------------------------------------------------------------------*/
  3788. /*!
  3789. * @brief This function is called before AIS is starting a new scan
  3790. *
  3791. * @param prAdapter Pointer of Adapter Data Structure
  3792. *
  3793. * @return none
  3794. */
  3795. /*----------------------------------------------------------------------------*/
  3796. VOID wlanClearScanningResult(IN P_ADAPTER_T prAdapter)
  3797. {
  3798. BOOLEAN fgKeepCurrOne = FALSE;
  3799. UINT_32 i;
  3800. ASSERT(prAdapter);
  3801. /* clear scanning result */
  3802. if (kalGetMediaStateIndicated(prAdapter->prGlueInfo) == PARAM_MEDIA_STATE_CONNECTED) {
  3803. for (i = 0; i < prAdapter->rWlanInfo.u4ScanResultNum; i++) {
  3804. if (EQUAL_MAC_ADDR(prAdapter->rWlanInfo.rCurrBssId.arMacAddress,
  3805. prAdapter->rWlanInfo.arScanResult[i].arMacAddress)) {
  3806. fgKeepCurrOne = TRUE;
  3807. if (i != 0) {
  3808. /* copy structure */
  3809. kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[0]),
  3810. &(prAdapter->rWlanInfo.arScanResult[i]),
  3811. OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
  3812. }
  3813. if (prAdapter->rWlanInfo.arScanResult[i].u4IELength > 0) {
  3814. if (prAdapter->rWlanInfo.apucScanResultIEs[i] !=
  3815. &(prAdapter->rWlanInfo.aucScanIEBuf[0])) {
  3816. /* move IEs to head */
  3817. kalMemCopy(prAdapter->rWlanInfo.aucScanIEBuf,
  3818. prAdapter->rWlanInfo.apucScanResultIEs[i],
  3819. prAdapter->rWlanInfo.arScanResult[i].u4IELength);
  3820. }
  3821. /* modify IE pointer */
  3822. prAdapter->rWlanInfo.apucScanResultIEs[0] =
  3823. &(prAdapter->rWlanInfo.aucScanIEBuf[0]);
  3824. } else {
  3825. prAdapter->rWlanInfo.apucScanResultIEs[0] = NULL;
  3826. }
  3827. break;
  3828. }
  3829. }
  3830. }
  3831. if (fgKeepCurrOne == TRUE) {
  3832. prAdapter->rWlanInfo.u4ScanResultNum = 1;
  3833. prAdapter->rWlanInfo.u4ScanIEBufferUsage = ALIGN_4(prAdapter->rWlanInfo.arScanResult[0].u4IELength);
  3834. } else {
  3835. prAdapter->rWlanInfo.u4ScanResultNum = 0;
  3836. prAdapter->rWlanInfo.u4ScanIEBufferUsage = 0;
  3837. }
  3838. }
  3839. /*----------------------------------------------------------------------------*/
  3840. /*!
  3841. * @brief This function is called when AIS received a beacon timeout event
  3842. *
  3843. * @param prAdapter Pointer of Adapter Data Structure
  3844. * @param arBSSID MAC address of the specified BSS
  3845. *
  3846. * @return none
  3847. */
  3848. /*----------------------------------------------------------------------------*/
  3849. VOID wlanClearBssInScanningResult(IN P_ADAPTER_T prAdapter, IN PUINT_8 arBSSID)
  3850. {
  3851. UINT_32 i, j, u4IELength = 0, u4IEMoveLength;
  3852. PUINT_8 pucIEPtr;
  3853. ASSERT(prAdapter);
  3854. /* clear scanning result */
  3855. i = 0;
  3856. while (1) {
  3857. if (i >= prAdapter->rWlanInfo.u4ScanResultNum)
  3858. break;
  3859. if (EQUAL_MAC_ADDR(arBSSID, prAdapter->rWlanInfo.arScanResult[i].arMacAddress)) {
  3860. /* backup current IE length */
  3861. u4IELength = ALIGN_4(prAdapter->rWlanInfo.arScanResult[i].u4IELength);
  3862. pucIEPtr = prAdapter->rWlanInfo.apucScanResultIEs[i];
  3863. /* removed from middle */
  3864. for (j = i + 1; j < prAdapter->rWlanInfo.u4ScanResultNum; j++) {
  3865. kalMemCopy(&(prAdapter->rWlanInfo.arScanResult[j - 1]),
  3866. &(prAdapter->rWlanInfo.arScanResult[j]),
  3867. OFFSET_OF(PARAM_BSSID_EX_T, aucIEs));
  3868. prAdapter->rWlanInfo.apucScanResultIEs[j - 1] =
  3869. prAdapter->rWlanInfo.apucScanResultIEs[j];
  3870. }
  3871. prAdapter->rWlanInfo.u4ScanResultNum--;
  3872. /* remove IE buffer if needed := move rest of IE buffer */
  3873. if (u4IELength > 0) {
  3874. u4IEMoveLength = prAdapter->rWlanInfo.u4ScanIEBufferUsage -
  3875. (((ULONG) pucIEPtr) + u4IELength -
  3876. ((ULONG) (&(prAdapter->rWlanInfo.aucScanIEBuf[0]))));
  3877. kalMemCopy(pucIEPtr, (PUINT_8) (((ULONG) pucIEPtr) + u4IELength), u4IEMoveLength);
  3878. prAdapter->rWlanInfo.u4ScanIEBufferUsage -= u4IELength;
  3879. /* correction of pointers to IE buffer */
  3880. for (j = 0; j < prAdapter->rWlanInfo.u4ScanResultNum; j++) {
  3881. if (prAdapter->rWlanInfo.apucScanResultIEs[j] > pucIEPtr) {
  3882. prAdapter->rWlanInfo.apucScanResultIEs[j] =
  3883. (PUINT_8) ((ULONG) (prAdapter->rWlanInfo.apucScanResultIEs[j]) -
  3884. u4IELength);
  3885. }
  3886. }
  3887. }
  3888. }
  3889. i++;
  3890. }
  3891. }
  3892. #if CFG_TEST_WIFI_DIRECT_GO
  3893. VOID wlanEnableP2pFunction(IN P_ADAPTER_T prAdapter)
  3894. {
  3895. #if 0
  3896. P_MSG_P2P_FUNCTION_SWITCH_T prMsgFuncSwitch = (P_MSG_P2P_FUNCTION_SWITCH_T) NULL;
  3897. prMsgFuncSwitch =
  3898. (P_MSG_P2P_FUNCTION_SWITCH_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_FUNCTION_SWITCH_T));
  3899. if (!prMsgFuncSwitch) {
  3900. ASSERT(FALSE);
  3901. return;
  3902. }
  3903. prMsgFuncSwitch->rMsgHdr.eMsgId = MID_MNY_P2P_FUN_SWITCH;
  3904. prMsgFuncSwitch->fgIsFuncOn = TRUE;
  3905. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgFuncSwitch, MSG_SEND_METHOD_BUF);
  3906. #endif
  3907. }
  3908. VOID wlanEnableATGO(IN P_ADAPTER_T prAdapter)
  3909. {
  3910. P_MSG_P2P_CONNECTION_REQUEST_T prMsgConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T) NULL;
  3911. UINT_8 aucTargetDeviceID[MAC_ADDR_LEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  3912. prMsgConnReq =
  3913. (P_MSG_P2P_CONNECTION_REQUEST_T) cnmMemAlloc(prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CONNECTION_REQUEST_T));
  3914. if (!prMsgConnReq) {
  3915. ASSERT(FALSE);
  3916. return;
  3917. }
  3918. prMsgConnReq->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_REQ;
  3919. /*=====Param Modified for test=====*/
  3920. COPY_MAC_ADDR(prMsgConnReq->aucDeviceID, aucTargetDeviceID);
  3921. prMsgConnReq->fgIsTobeGO = TRUE;
  3922. prMsgConnReq->fgIsPersistentGroup = FALSE;
  3923. /*=====Param Modified for test=====*/
  3924. mboxSendMsg(prAdapter, MBOX_ID_0, (P_MSG_HDR_T) prMsgConnReq, MSG_SEND_METHOD_BUF);
  3925. }
  3926. #endif
  3927. /*----------------------------------------------------------------------------*/
  3928. /*!
  3929. * @brief This function is called to retrieve NIC capability from firmware
  3930. *
  3931. * @param prAdapter Pointer of Adapter Data Structure
  3932. *
  3933. * @return WLAN_STATUS_SUCCESS
  3934. * WLAN_STATUS_FAILURE
  3935. */
  3936. /*----------------------------------------------------------------------------*/
  3937. WLAN_STATUS wlanQueryNicCapability(IN P_ADAPTER_T prAdapter)
  3938. {
  3939. UINT_8 aucZeroMacAddr[] = NULL_MAC_ADDR;
  3940. UINT_8 ucCmdSeqNum;
  3941. P_CMD_INFO_T prCmdInfo;
  3942. P_WIFI_CMD_T prWifiCmd;
  3943. UINT_32 u4RxPktLength;
  3944. UINT_8 aucBuffer[sizeof(WIFI_EVENT_T) + sizeof(EVENT_NIC_CAPABILITY_T)];
  3945. P_HW_MAC_RX_DESC_T prRxStatus;
  3946. P_WIFI_EVENT_T prEvent;
  3947. P_EVENT_NIC_CAPABILITY_T prEventNicCapability;
  3948. ASSERT(prAdapter);
  3949. DEBUGFUNC("wlanQueryNicCapability");
  3950. /* 1. Allocate CMD Info Packet and its Buffer */
  3951. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, CMD_HDR_SIZE + sizeof(EVENT_NIC_CAPABILITY_T));
  3952. if (!prCmdInfo) {
  3953. DBGLOG(NIC, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  3954. return WLAN_STATUS_FAILURE;
  3955. }
  3956. /* increase command sequence number */
  3957. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  3958. /* compose CMD_BUILD_CONNECTION cmd pkt */
  3959. prCmdInfo->eCmdType = COMMAND_TYPE_GENERAL_IOCTL;
  3960. prCmdInfo->u2InfoBufLen = CMD_HDR_SIZE + sizeof(EVENT_NIC_CAPABILITY_T);
  3961. prCmdInfo->pfCmdDoneHandler = NULL;
  3962. prCmdInfo->fgIsOid = FALSE;
  3963. prCmdInfo->ucCID = CMD_ID_GET_NIC_CAPABILITY;
  3964. prCmdInfo->fgSetQuery = FALSE;
  3965. prCmdInfo->fgNeedResp = TRUE;
  3966. prCmdInfo->fgDriverDomainMCR = FALSE;
  3967. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  3968. prCmdInfo->u4SetInfoLen = 0;
  3969. /* Setup WIFI_CMD_T */
  3970. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  3971. prWifiCmd->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  3972. prWifiCmd->u2PQ_ID = CMD_PQ_ID;
  3973. prWifiCmd->ucPktTypeID = CMD_PACKET_TYPE_ID;
  3974. prWifiCmd->ucCID = prCmdInfo->ucCID;
  3975. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  3976. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  3977. wlanSendCommand(prAdapter, prCmdInfo);
  3978. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  3979. if (nicRxWaitResponse(prAdapter,
  3980. 1,
  3981. aucBuffer,
  3982. sizeof(WIFI_EVENT_T) + sizeof(EVENT_NIC_CAPABILITY_T),
  3983. &u4RxPktLength) != WLAN_STATUS_SUCCESS) {
  3984. return WLAN_STATUS_FAILURE;
  3985. }
  3986. /* header checking .. */
  3987. prRxStatus = (P_HW_MAC_RX_DESC_T) aucBuffer;
  3988. if (prRxStatus->u2PktTYpe != RXM_RXD_PKT_TYPE_SW_EVENT)
  3989. return WLAN_STATUS_FAILURE;
  3990. prEvent = (P_WIFI_EVENT_T) aucBuffer;
  3991. if (prEvent->ucEID != EVENT_ID_NIC_CAPABILITY)
  3992. return WLAN_STATUS_FAILURE;
  3993. prEventNicCapability = (P_EVENT_NIC_CAPABILITY_T) (prEvent->aucBuffer);
  3994. prAdapter->rVerInfo.u2FwProductID = prEventNicCapability->u2ProductID;
  3995. prAdapter->rVerInfo.u2FwOwnVersion = prEventNicCapability->u2FwVersion;
  3996. prAdapter->rVerInfo.u2FwPeerVersion = prEventNicCapability->u2DriverVersion;
  3997. /*support FW version extend*/
  3998. prAdapter->rVerInfo.u2FwOwnVersionExtend =
  3999. (prEventNicCapability->aucReserved0[0] << 24)
  4000. | (prEventNicCapability->aucReserved0[1] << 16)
  4001. | (prEventNicCapability->aucReserved0[2] << 8)
  4002. | (prEventNicCapability->aucReserved0[3]);
  4003. prAdapter->fgIsHw5GBandDisabled = (BOOLEAN) prEventNicCapability->ucHw5GBandDisabled;
  4004. prAdapter->fgIsEepromUsed = (BOOLEAN) prEventNicCapability->ucEepromUsed;
  4005. prAdapter->fgIsEmbbededMacAddrValid = (BOOLEAN)
  4006. (!IS_BMCAST_MAC_ADDR(prEventNicCapability->aucMacAddr) &&
  4007. !EQUAL_MAC_ADDR(aucZeroMacAddr, prEventNicCapability->aucMacAddr));
  4008. COPY_MAC_ADDR(prAdapter->rWifiVar.aucPermanentAddress, prEventNicCapability->aucMacAddr);
  4009. COPY_MAC_ADDR(prAdapter->rWifiVar.aucMacAddress, prEventNicCapability->aucMacAddr);
  4010. prAdapter->u4FwCompileFlag0 = prEventNicCapability->u4CompileFlag0;
  4011. prAdapter->u4FwCompileFlag1 = prEventNicCapability->u4CompileFlag1;
  4012. prAdapter->u4FwFeatureFlag0 = prEventNicCapability->u4FeatureFlag0;
  4013. prAdapter->u4FwFeatureFlag1 = prEventNicCapability->u4FeatureFlag1;
  4014. #if CFG_ENABLE_CAL_LOG
  4015. DBGLOG(NIC, LOUD, " RF CAL FAIL = (%d),BB CAL FAIL = (%d)\n",
  4016. prEventNicCapability->ucRfCalFail, prEventNicCapability->ucBbCalFail);
  4017. #endif
  4018. DBGLOG(NIC, INFO, "FW Ver DEC[%u.%u] HEX[%x.%x], Driver Ver[%u.%u]\n",
  4019. (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
  4020. (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
  4021. (prAdapter->rVerInfo.u2FwOwnVersion >> 8),
  4022. (prAdapter->rVerInfo.u2FwOwnVersion & BITS(0, 7)),
  4023. (prAdapter->rVerInfo.u2FwPeerVersion >> 8),
  4024. (prAdapter->rVerInfo.u2FwPeerVersion & BITS(0, 7)));
  4025. return WLAN_STATUS_SUCCESS;
  4026. }
  4027. #if TXPWR_USE_PDSLOPE
  4028. /*----------------------------------------------------------------------------*/
  4029. /*!
  4030. * @brief
  4031. *
  4032. * @param prAdapter Pointer of Adapter Data Structure
  4033. *
  4034. * @return WLAN_STATUS_SUCCESS
  4035. * WLAN_STATUS_FAILURE
  4036. */
  4037. /*----------------------------------------------------------------------------*/
  4038. WLAN_STATUS wlanQueryPdMcr(IN P_ADAPTER_T prAdapter, P_PARAM_MCR_RW_STRUCT_T prMcrRdInfo)
  4039. {
  4040. UINT_8 ucCmdSeqNum;
  4041. P_CMD_INFO_T prCmdInfo;
  4042. P_WIFI_CMD_T prWifiCmd;
  4043. UINT_32 u4RxPktLength;
  4044. UINT_8 aucBuffer[sizeof(WIFI_EVENT_T) + sizeof(CMD_ACCESS_REG)];
  4045. P_HW_MAC_RX_DESC_T prRxStatus;
  4046. P_WIFI_EVENT_T prEvent;
  4047. P_CMD_ACCESS_REG prCmdMcrQuery;
  4048. ASSERT(prAdapter);
  4049. /* 1. Allocate CMD Info Packet and its Buffer */
  4050. prCmdInfo = cmdBufAllocateCmdInfo(prAdapter, CMD_HDR_SIZE + sizeof(CMD_ACCESS_REG));
  4051. if (!prCmdInfo) {
  4052. DBGLOG(INIT, ERROR, "Allocate CMD_INFO_T ==> FAILED.\n");
  4053. return WLAN_STATUS_FAILURE;
  4054. }
  4055. /* increase command sequence number */
  4056. ucCmdSeqNum = nicIncreaseCmdSeqNum(prAdapter);
  4057. /* compose CMD_BUILD_CONNECTION cmd pkt */
  4058. prCmdInfo->eCmdType = COMMAND_TYPE_GENERAL_IOCTL;
  4059. prCmdInfo->u2InfoBufLen = (UINT_16) (CMD_HDR_SIZE + sizeof(CMD_ACCESS_REG));
  4060. prCmdInfo->pfCmdDoneHandler = NULL;
  4061. prCmdInfo->pfCmdTimeoutHandler = nicOidCmdTimeoutCommon;
  4062. prCmdInfo->fgIsOid = FALSE;
  4063. prCmdInfo->ucCID = CMD_ID_ACCESS_REG;
  4064. prCmdInfo->fgSetQuery = FALSE;
  4065. prCmdInfo->fgNeedResp = TRUE;
  4066. prCmdInfo->fgDriverDomainMCR = FALSE;
  4067. prCmdInfo->ucCmdSeqNum = ucCmdSeqNum;
  4068. prCmdInfo->u4SetInfoLen = sizeof(CMD_ACCESS_REG);
  4069. /* Setup WIFI_CMD_T */
  4070. prWifiCmd = (P_WIFI_CMD_T) (prCmdInfo->pucInfoBuffer);
  4071. prWifiCmd->u2TxByteCount = prCmdInfo->u2InfoBufLen;
  4072. prWifiCmd->u2PQ_ID = CMD_PQ_ID;
  4073. prWifiCmd->ucPktTypeID = CMD_PACKET_TYPE_ID;
  4074. prWifiCmd->ucCID = prCmdInfo->ucCID;
  4075. prWifiCmd->ucSetQuery = prCmdInfo->fgSetQuery;
  4076. prWifiCmd->ucSeqNum = prCmdInfo->ucCmdSeqNum;
  4077. kalMemCopy(prWifiCmd->aucBuffer, prMcrRdInfo, sizeof(CMD_ACCESS_REG));
  4078. wlanSendCommand(prAdapter, prCmdInfo);
  4079. cmdBufFreeCmdInfo(prAdapter, prCmdInfo);
  4080. if (nicRxWaitResponse(prAdapter,
  4081. 1,
  4082. aucBuffer,
  4083. sizeof(WIFI_EVENT_T) + sizeof(CMD_ACCESS_REG), &u4RxPktLength) != WLAN_STATUS_SUCCESS) {
  4084. return WLAN_STATUS_FAILURE;
  4085. }
  4086. /* header checking .. */
  4087. prRxStatus = (P_HW_MAC_RX_DESC_T) aucBuffer;
  4088. if (prRxStatus->u2PktTYpe != RXM_RXD_PKT_TYPE_SW_EVENT)
  4089. return WLAN_STATUS_FAILURE;
  4090. prEvent = (P_WIFI_EVENT_T) aucBuffer;
  4091. if (prEvent->ucEID != EVENT_ID_ACCESS_REG)
  4092. return WLAN_STATUS_FAILURE;
  4093. prCmdMcrQuery = (P_CMD_ACCESS_REG) (prEvent->aucBuffer);
  4094. prMcrRdInfo->u4McrOffset = prCmdMcrQuery->u4Address;
  4095. prMcrRdInfo->u4McrData = prCmdMcrQuery->u4Data;
  4096. return WLAN_STATUS_SUCCESS;
  4097. }
  4098. static INT_32 wlanIntRound(INT_32 au4Input)
  4099. {
  4100. if (au4Input >= 0) {
  4101. if ((au4Input % 10) == 5) {
  4102. au4Input = au4Input + 5;
  4103. return au4Input;
  4104. }
  4105. }
  4106. if (au4Input < 0) {
  4107. if ((au4Input % 10) == -5) {
  4108. au4Input = au4Input - 5;
  4109. return au4Input;
  4110. }
  4111. }
  4112. return au4Input;
  4113. }
  4114. static INT_32 wlanCal6628EfuseForm(IN P_ADAPTER_T prAdapter, INT_32 au4Input)
  4115. {
  4116. PARAM_MCR_RW_STRUCT_T rMcrRdInfo;
  4117. INT_32 au4PdSlope, au4TxPwrOffset, au4TxPwrOffset_Round;
  4118. INT_8 auTxPwrOffset_Round;
  4119. rMcrRdInfo.u4McrOffset = 0x60205c68;
  4120. rMcrRdInfo.u4McrData = 0;
  4121. au4TxPwrOffset = au4Input;
  4122. wlanQueryPdMcr(prAdapter, &rMcrRdInfo);
  4123. au4PdSlope = (rMcrRdInfo.u4McrData) & BITS(0, 6);
  4124. au4TxPwrOffset_Round = wlanIntRound((au4TxPwrOffset * au4PdSlope)) / 10;
  4125. au4TxPwrOffset_Round = -au4TxPwrOffset_Round;
  4126. if (au4TxPwrOffset_Round < -128)
  4127. au4TxPwrOffset_Round = 128;
  4128. else if (au4TxPwrOffset_Round < 0)
  4129. au4TxPwrOffset_Round += 256;
  4130. else if (au4TxPwrOffset_Round > 127)
  4131. au4TxPwrOffset_Round = 127;
  4132. auTxPwrOffset_Round = (UINT_8) au4TxPwrOffset_Round;
  4133. return au4TxPwrOffset_Round;
  4134. }
  4135. #endif
  4136. #if CFG_SUPPORT_NVRAM_5G
  4137. WLAN_STATUS wlanLoadManufactureData_5G(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
  4138. {
  4139. P_BANDEDGE_5G_T pr5GBandEdge;
  4140. ASSERT(prAdapter);
  4141. pr5GBandEdge = &prRegInfo->prOldEfuseMapping->r5GBandEdgePwr;
  4142. /* 1. set band edge tx power if available */
  4143. if (pr5GBandEdge->uc5GBandEdgePwrUsed != 0) {
  4144. CMD_EDGE_TXPWR_LIMIT_T rCmdEdgeTxPwrLimit;
  4145. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrCCK = 0;
  4146. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrOFDM20 = pr5GBandEdge->c5GBandEdgeMaxPwrOFDM20;
  4147. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrOFDM40 = pr5GBandEdge->c5GBandEdgeMaxPwrOFDM40;
  4148. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrOFDM80 = pr5GBandEdge->c5GBandEdgeMaxPwrOFDM80;
  4149. wlanSendSetQueryCmd(prAdapter,
  4150. CMD_ID_SET_EDGE_TXPWR_LIMIT_5G,
  4151. TRUE,
  4152. FALSE,
  4153. FALSE,
  4154. NULL,
  4155. NULL, sizeof(CMD_EDGE_TXPWR_LIMIT_T), (PUINT_8) &rCmdEdgeTxPwrLimit, NULL, 0);
  4156. /* dumpMemory8(&rCmdEdgeTxPwrLimit,4); */
  4157. }
  4158. /*2.set channel offset for 8 sub-band */
  4159. if (prRegInfo->prOldEfuseMapping->uc5GChannelOffsetVaild) {
  4160. CMD_POWER_OFFSET_T rCmdPowerOffset;
  4161. UINT_8 i;
  4162. rCmdPowerOffset.ucBand = BAND_5G;
  4163. for (i = 0; i < MAX_SUBBAND_NUM_5G; i++)
  4164. rCmdPowerOffset.ucSubBandOffset[i] = prRegInfo->prOldEfuseMapping->auc5GChOffset[i];
  4165. wlanSendSetQueryCmd(prAdapter,
  4166. CMD_ID_SET_CHANNEL_PWR_OFFSET,
  4167. TRUE,
  4168. FALSE,
  4169. FALSE, NULL, NULL, sizeof(rCmdPowerOffset), (PUINT_8) &rCmdPowerOffset, NULL, 0);
  4170. /* dumpMemory8(&rCmdPowerOffset,9); */
  4171. }
  4172. /*3.set 5G AC power */
  4173. if (prRegInfo->prOldEfuseMapping->uc11AcTxPwrValid) {
  4174. CMD_TX_AC_PWR_T rCmdAcPwr;
  4175. kalMemCopy(&rCmdAcPwr.rAcPwr, &prRegInfo->prOldEfuseMapping->r11AcTxPwr, sizeof(AC_PWR_SETTING_STRUCT));
  4176. rCmdAcPwr.ucBand = BAND_5G;
  4177. wlanSendSetQueryCmd(prAdapter,
  4178. CMD_ID_SET_80211AC_TX_PWR,
  4179. TRUE,
  4180. FALSE, FALSE, NULL, NULL, sizeof(CMD_TX_AC_PWR_T), (PUINT_8) &rCmdAcPwr, NULL, 0);
  4181. /* dumpMemory8(&rCmdAcPwr,9); */
  4182. }
  4183. return WLAN_STATUS_SUCCESS;
  4184. }
  4185. #endif
  4186. /*----------------------------------------------------------------------------*/
  4187. /*!
  4188. * @brief This function is called to load manufacture data from NVRAM
  4189. * if available and valid
  4190. *
  4191. * @param prAdapter Pointer of Adapter Data Structure
  4192. * @param prRegInfo Pointer of REG_INFO_T
  4193. *
  4194. * @return WLAN_STATUS_SUCCESS
  4195. * WLAN_STATUS_FAILURE
  4196. */
  4197. /*----------------------------------------------------------------------------*/
  4198. WLAN_STATUS wlanLoadManufactureData(IN P_ADAPTER_T prAdapter, IN P_REG_INFO_T prRegInfo)
  4199. {
  4200. #if CFG_SUPPORT_RDD_TEST_MODE
  4201. CMD_RDD_CH_T rRddParam;
  4202. #endif
  4203. CMD_NVRAM_SETTING_T rCmdNvramSettings;
  4204. ASSERT(prAdapter);
  4205. /* 1. Version Check */
  4206. kalGetConfigurationVersion(prAdapter->prGlueInfo,
  4207. &(prAdapter->rVerInfo.u2Part1CfgOwnVersion),
  4208. &(prAdapter->rVerInfo.u2Part1CfgPeerVersion),
  4209. &(prAdapter->rVerInfo.u2Part2CfgOwnVersion),
  4210. &(prAdapter->rVerInfo.u2Part2CfgPeerVersion));
  4211. #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
  4212. if (CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part1CfgPeerVersion
  4213. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part2CfgPeerVersion
  4214. || prAdapter->rVerInfo.u2Part1CfgOwnVersion < CFG_DRV_PEER_VERSION
  4215. || prAdapter->rVerInfo.u2Part2CfgOwnVersion < CFG_DRV_PEER_VERSION) {
  4216. return WLAN_STATUS_FAILURE;
  4217. }
  4218. #endif
  4219. /* MT6620 E1/E2 would be ignored directly */
  4220. if (prAdapter->rVerInfo.u2Part1CfgOwnVersion == 0x0001) {
  4221. prRegInfo->ucTxPwrValid = 1;
  4222. } else {
  4223. /* 2. Load TX power gain parameters if valid */
  4224. if (prRegInfo->ucTxPwrValid != 0) {
  4225. /* send to F/W */
  4226. nicUpdateTxPower(prAdapter, (P_CMD_TX_PWR_T) (&(prRegInfo->rTxPwr)));
  4227. }
  4228. }
  4229. /* 3. Check if needs to support 5GHz */
  4230. if (prRegInfo->ucEnable5GBand) {
  4231. #if CFG_SUPPORT_NVRAM_5G
  4232. wlanLoadManufactureData_5G(prAdapter, prRegInfo);
  4233. #endif
  4234. /* check if it is disabled by hardware */
  4235. if (prAdapter->fgIsHw5GBandDisabled || prRegInfo->ucSupport5GBand == 0)
  4236. prAdapter->fgEnable5GBand = FALSE;
  4237. else
  4238. prAdapter->fgEnable5GBand = TRUE;
  4239. } else
  4240. prAdapter->fgEnable5GBand = FALSE;
  4241. /* 4. Send EFUSE data */
  4242. #if CFG_SUPPORT_NVRAM_5G
  4243. /* If NvRAM read failed, this pointer will be NULL */
  4244. if (prRegInfo->prOldEfuseMapping) {
  4245. /*2.set channel offset for 3 sub-band */
  4246. if (prRegInfo->prOldEfuseMapping->ucChannelOffsetVaild) {
  4247. CMD_POWER_OFFSET_T rCmdPowerOffset;
  4248. UINT_8 i;
  4249. rCmdPowerOffset.ucBand = BAND_2G4;
  4250. for (i = 0; i < 3; i++)
  4251. rCmdPowerOffset.ucSubBandOffset[i] = prRegInfo->prOldEfuseMapping->aucChOffset[i];
  4252. rCmdPowerOffset.ucSubBandOffset[i] = prRegInfo->prOldEfuseMapping->acAllChannelOffset;
  4253. wlanSendSetQueryCmd(prAdapter,
  4254. CMD_ID_SET_CHANNEL_PWR_OFFSET,
  4255. TRUE,
  4256. FALSE,
  4257. FALSE,
  4258. NULL, NULL, sizeof(rCmdPowerOffset), (PUINT_8) &rCmdPowerOffset, NULL, 0);
  4259. /* dumpMemory8(&rCmdPowerOffset,9); */
  4260. }
  4261. }
  4262. #else
  4263. wlanSendSetQueryCmd(prAdapter,
  4264. CMD_ID_SET_PHY_PARAM,
  4265. TRUE,
  4266. FALSE,
  4267. FALSE, NULL, NULL, sizeof(CMD_PHY_PARAM_T), (PUINT_8) (prRegInfo->aucEFUSE), NULL, 0);
  4268. #endif
  4269. /*RSSI path compasation */
  4270. if (prRegInfo->ucRssiPathCompasationUsed) {
  4271. CMD_RSSI_PATH_COMPASATION_T rCmdRssiPathCompasation;
  4272. rCmdRssiPathCompasation.c2GRssiCompensation = prRegInfo->rRssiPathCompasation.c2GRssiCompensation;
  4273. rCmdRssiPathCompasation.c5GRssiCompensation = prRegInfo->rRssiPathCompasation.c5GRssiCompensation;
  4274. wlanSendSetQueryCmd(prAdapter,
  4275. CMD_ID_SET_PATH_COMPASATION,
  4276. TRUE,
  4277. FALSE,
  4278. FALSE,
  4279. NULL,
  4280. NULL,
  4281. sizeof(rCmdRssiPathCompasation), (PUINT_8) &rCmdRssiPathCompasation, NULL, 0);
  4282. }
  4283. #if CFG_SUPPORT_RDD_TEST_MODE
  4284. rRddParam.ucRddTestMode = (UINT_8) prRegInfo->u4RddTestMode;
  4285. rRddParam.ucRddShutCh = (UINT_8) prRegInfo->u4RddShutFreq;
  4286. rRddParam.ucRddStartCh = (UINT_8) nicFreq2ChannelNum(prRegInfo->u4RddStartFreq);
  4287. rRddParam.ucRddStopCh = (UINT_8) nicFreq2ChannelNum(prRegInfo->u4RddStopFreq);
  4288. rRddParam.ucRddDfs = (UINT_8) prRegInfo->u4RddDfs;
  4289. prAdapter->ucRddStatus = 0;
  4290. nicUpdateRddTestMode(prAdapter, (P_CMD_RDD_CH_T) (&rRddParam));
  4291. #endif
  4292. /* 5. Get 16-bits Country Code and Bandwidth */
  4293. prAdapter->rWifiVar.rConnSettings.u2CountryCode =
  4294. (((UINT_16) prRegInfo->au2CountryCode[0]) << 8) | (((UINT_16) prRegInfo->au2CountryCode[1]) & BITS(0, 7));
  4295. #if 0 /* Bandwidth control will be controlled by GUI. 20110930
  4296. * So ignore the setting from registry/NVRAM
  4297. */
  4298. prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode =
  4299. prRegInfo->uc2G4BwFixed20M ? CONFIG_BW_20M : CONFIG_BW_20_40M;
  4300. prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode =
  4301. prRegInfo->uc5GBwFixed20M ? CONFIG_BW_20M : CONFIG_BW_20_40M;
  4302. #endif
  4303. /* 6. Set domain and channel information to chip */
  4304. rlmDomainSendCmd(prAdapter, FALSE);
  4305. /* Update supported channel list in channel table */
  4306. wlanUpdateChannelTable(prAdapter->prGlueInfo);
  4307. /* 7. set band edge tx power if available */
  4308. if (prRegInfo->fg2G4BandEdgePwrUsed) {
  4309. CMD_EDGE_TXPWR_LIMIT_T rCmdEdgeTxPwrLimit;
  4310. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrCCK = prRegInfo->cBandEdgeMaxPwrCCK;
  4311. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrOFDM20 = prRegInfo->cBandEdgeMaxPwrOFDM20;
  4312. rCmdEdgeTxPwrLimit.cBandEdgeMaxPwrOFDM40 = prRegInfo->cBandEdgeMaxPwrOFDM40;
  4313. wlanSendSetQueryCmd(prAdapter,
  4314. CMD_ID_SET_EDGE_TXPWR_LIMIT,
  4315. TRUE,
  4316. FALSE,
  4317. FALSE,
  4318. NULL,
  4319. NULL, sizeof(CMD_EDGE_TXPWR_LIMIT_T), (PUINT_8) &rCmdEdgeTxPwrLimit, NULL, 0);
  4320. }
  4321. /*8. Set 2.4G AC power */
  4322. if (prRegInfo->prOldEfuseMapping) {
  4323. if (prRegInfo->prOldEfuseMapping->uc11AcTxPwrValid2G) {
  4324. CMD_TX_AC_PWR_T rCmdAcPwr;
  4325. kalMemCopy(&rCmdAcPwr.rAcPwr, &prRegInfo->prOldEfuseMapping->r11AcTxPwr2G,
  4326. sizeof(AC_PWR_SETTING_STRUCT));
  4327. rCmdAcPwr.ucBand = BAND_2G4;
  4328. wlanSendSetQueryCmd(prAdapter,
  4329. CMD_ID_SET_80211AC_TX_PWR,
  4330. TRUE,
  4331. FALSE, FALSE, NULL, NULL, sizeof(CMD_TX_AC_PWR_T),
  4332. (PUINT_8)&rCmdAcPwr, NULL, 0);
  4333. /* dumpMemory8(&rCmdAcPwr,9); */
  4334. }
  4335. }
  4336. /* 9. Send the full Parameters of NVRAM to FW */
  4337. kalMemCopy(&rCmdNvramSettings.rNvramSettings,
  4338. &prRegInfo->prNvramSettings->u2Part1OwnVersion, sizeof(WIFI_CFG_PARAM_STRUCT));
  4339. ASSERT(sizeof(WIFI_CFG_PARAM_STRUCT) == 512);
  4340. wlanSendSetQueryCmd(prAdapter,
  4341. CMD_ID_SET_NVRAM_SETTINGS,
  4342. TRUE,
  4343. FALSE,
  4344. FALSE, NULL, NULL, sizeof(rCmdNvramSettings), (PUINT_8) &rCmdNvramSettings, NULL, 0);
  4345. return WLAN_STATUS_SUCCESS;
  4346. }
  4347. /*----------------------------------------------------------------------------*/
  4348. /*!
  4349. * @brief This function is called to check
  4350. * Media Stream Mode is set to non-default value or not,
  4351. * and clear to default value if above criteria is met
  4352. *
  4353. * @param prAdapter Pointer of Adapter Data Structure
  4354. *
  4355. * @return TRUE
  4356. * The media stream mode was non-default value and has been reset
  4357. * FALSE
  4358. * The media stream mode is default value
  4359. */
  4360. /*----------------------------------------------------------------------------*/
  4361. BOOLEAN wlanResetMediaStreamMode(IN P_ADAPTER_T prAdapter)
  4362. {
  4363. ASSERT(prAdapter);
  4364. if (prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode != 0) {
  4365. prAdapter->rWlanInfo.eLinkAttr.ucMediaStreamMode = 0;
  4366. return TRUE;
  4367. } else {
  4368. return FALSE;
  4369. }
  4370. }
  4371. /*----------------------------------------------------------------------------*/
  4372. /*!
  4373. * @brief This function is called to check if any pending timer has expired
  4374. *
  4375. * @param prAdapter Pointer of Adapter Data Structure
  4376. *
  4377. * @return WLAN_STATUS_SUCCESS
  4378. */
  4379. /*----------------------------------------------------------------------------*/
  4380. WLAN_STATUS wlanTimerTimeoutCheck(IN P_ADAPTER_T prAdapter)
  4381. {
  4382. ASSERT(prAdapter);
  4383. cnmTimerDoTimeOutCheck(prAdapter);
  4384. return WLAN_STATUS_SUCCESS;
  4385. }
  4386. /*----------------------------------------------------------------------------*/
  4387. /*!
  4388. * @brief This function is called to check if any pending mailbox message
  4389. * to be handled
  4390. *
  4391. * @param prAdapter Pointer of Adapter Data Structure
  4392. *
  4393. * @return WLAN_STATUS_SUCCESS
  4394. */
  4395. /*----------------------------------------------------------------------------*/
  4396. WLAN_STATUS wlanProcessMboxMessage(IN P_ADAPTER_T prAdapter)
  4397. {
  4398. UINT_32 i;
  4399. ASSERT(prAdapter);
  4400. for (i = 0; i < MBOX_ID_TOTAL_NUM; i++)
  4401. mboxRcvAllMsg(prAdapter, (ENUM_MBOX_ID_T) i);
  4402. return WLAN_STATUS_SUCCESS;
  4403. }
  4404. /*----------------------------------------------------------------------------*/
  4405. /*!
  4406. * @brief This function is called to enqueue a single TX packet into CORE
  4407. *
  4408. * @param prAdapter Pointer of Adapter Data Structure
  4409. * prNativePacket Pointer of Native Packet
  4410. *
  4411. * @return WLAN_STATUS_SUCCESS
  4412. * WLAN_STATUS_RESOURCES
  4413. * WLAN_STATUS_INVALID_PACKET
  4414. */
  4415. /*----------------------------------------------------------------------------*/
  4416. WLAN_STATUS wlanEnqueueTxPacket(IN P_ADAPTER_T prAdapter, IN P_NATIVE_PACKET prNativePacket)
  4417. {
  4418. P_TX_CTRL_T prTxCtrl;
  4419. P_MSDU_INFO_T prMsduInfo;
  4420. ASSERT(prAdapter);
  4421. prTxCtrl = &prAdapter->rTxCtrl;
  4422. prMsduInfo = cnmPktAlloc(prAdapter, 0);
  4423. if (!prMsduInfo)
  4424. return WLAN_STATUS_RESOURCES;
  4425. if (nicTxFillMsduInfo(prAdapter, prMsduInfo, prNativePacket)) {
  4426. /* prMsduInfo->eSrc = TX_PACKET_OS; */
  4427. /* Tx profiling */
  4428. wlanTxProfilingTagMsdu(prAdapter, prMsduInfo, TX_PROF_TAG_DRV_ENQUE);
  4429. /* enqueue to QM */
  4430. nicTxEnqueueMsdu(prAdapter, prMsduInfo);
  4431. } else {
  4432. kalSendComplete(prAdapter->prGlueInfo, prNativePacket, WLAN_STATUS_INVALID_PACKET);
  4433. nicTxReturnMsduInfo(prAdapter, prMsduInfo);
  4434. return WLAN_STATUS_INVALID_PACKET;
  4435. }
  4436. return WLAN_STATUS_SUCCESS;
  4437. }
  4438. /*----------------------------------------------------------------------------*/
  4439. /*!
  4440. * @brief This function is called to flush pending TX packets in CORE
  4441. *
  4442. * @param prAdapter Pointer of Adapter Data Structure
  4443. *
  4444. * @return WLAN_STATUS_SUCCESS
  4445. */
  4446. /*----------------------------------------------------------------------------*/
  4447. WLAN_STATUS wlanFlushTxPendingPackets(IN P_ADAPTER_T prAdapter)
  4448. {
  4449. ASSERT(prAdapter);
  4450. return nicTxFlush(prAdapter);
  4451. }
  4452. /*----------------------------------------------------------------------------*/
  4453. /*!
  4454. * \brief this function sends pending MSDU_INFO_T to MT6620
  4455. *
  4456. * @param prAdapter Pointer to the Adapter structure.
  4457. * @param pfgHwAccess Pointer for tracking LP-OWN status
  4458. *
  4459. * @retval WLAN_STATUS_SUCCESS Reset is done successfully.
  4460. */
  4461. /*----------------------------------------------------------------------------*/
  4462. WLAN_STATUS wlanTxPendingPackets(IN P_ADAPTER_T prAdapter, IN OUT PBOOLEAN pfgHwAccess)
  4463. {
  4464. P_TX_CTRL_T prTxCtrl;
  4465. P_MSDU_INFO_T prMsduInfo;
  4466. KAL_SPIN_LOCK_DECLARATION();
  4467. ASSERT(prAdapter);
  4468. prTxCtrl = &prAdapter->rTxCtrl;
  4469. #if !CFG_SUPPORT_MULTITHREAD
  4470. ASSERT(pfgHwAccess);
  4471. #endif
  4472. /* <1> dequeue packet by txDequeuTxPackets() */
  4473. #if CFG_SUPPORT_MULTITHREAD
  4474. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  4475. prMsduInfo = qmDequeueTxPacketsMthread(prAdapter, &prTxCtrl->rTc);
  4476. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  4477. #else
  4478. KAL_ACQUIRE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  4479. prMsduInfo = qmDequeueTxPackets(prAdapter, &prTxCtrl->rTc);
  4480. KAL_RELEASE_SPIN_LOCK(prAdapter, SPIN_LOCK_QM_TX_QUEUE);
  4481. #endif
  4482. if (prMsduInfo != NULL) {
  4483. if (kalIsCardRemoved(prAdapter->prGlueInfo) == FALSE) {
  4484. #if !CFG_SUPPORT_MULTITHREAD
  4485. /* <2> Acquire LP-OWN if necessary */
  4486. if (*pfgHwAccess == FALSE) {
  4487. *pfgHwAccess = TRUE;
  4488. wlanAcquirePowerControl(prAdapter);
  4489. }
  4490. #endif
  4491. /* <3> send packets */
  4492. #if CFG_SUPPORT_MULTITHREAD
  4493. nicTxMsduInfoListMthread(prAdapter, prMsduInfo);
  4494. #else
  4495. nicTxMsduInfoList(prAdapter, prMsduInfo);
  4496. #endif
  4497. /* <4> update TC by txAdjustTcQuotas() */
  4498. nicTxAdjustTcq(prAdapter);
  4499. } else
  4500. wlanProcessQueuedMsduInfo(prAdapter, prMsduInfo);
  4501. }
  4502. return WLAN_STATUS_SUCCESS;
  4503. }
  4504. /*----------------------------------------------------------------------------*/
  4505. /*!
  4506. * @brief This function is called to acquire power control from firmware
  4507. *
  4508. * @param prAdapter Pointer of Adapter Data Structure
  4509. *
  4510. * @return WLAN_STATUS_SUCCESS
  4511. */
  4512. /*----------------------------------------------------------------------------*/
  4513. WLAN_STATUS wlanAcquirePowerControl(IN P_ADAPTER_T prAdapter)
  4514. {
  4515. ASSERT(prAdapter);
  4516. /* DBGLOG(INIT, INFO, ("Acquire Power Ctrl\n")); */
  4517. ACQUIRE_POWER_CONTROL_FROM_PM(prAdapter);
  4518. /* Reset sleepy state */
  4519. if (prAdapter->fgWiFiInSleepyState == TRUE)
  4520. prAdapter->fgWiFiInSleepyState = FALSE;
  4521. return WLAN_STATUS_SUCCESS;
  4522. }
  4523. /*----------------------------------------------------------------------------*/
  4524. /*!
  4525. * @brief This function is called to release power control to firmware
  4526. *
  4527. * @param prAdapter Pointer of Adapter Data Structure
  4528. *
  4529. * @return WLAN_STATUS_SUCCESS
  4530. */
  4531. /*----------------------------------------------------------------------------*/
  4532. WLAN_STATUS wlanReleasePowerControl(IN P_ADAPTER_T prAdapter)
  4533. {
  4534. ASSERT(prAdapter);
  4535. /* DBGLOG(INIT, INFO, ("Release Power Ctrl\n")); */
  4536. RECLAIM_POWER_CONTROL_TO_PM(prAdapter, FALSE);
  4537. return WLAN_STATUS_SUCCESS;
  4538. }
  4539. /*----------------------------------------------------------------------------*/
  4540. /*!
  4541. * @brief This function is called to report currently pending TX frames count
  4542. * (command packets are not included)
  4543. *
  4544. * @param prAdapter Pointer of Adapter Data Structure
  4545. *
  4546. * @return number of pending TX frames
  4547. */
  4548. /*----------------------------------------------------------------------------*/
  4549. UINT_32 wlanGetTxPendingFrameCount(IN P_ADAPTER_T prAdapter)
  4550. {
  4551. P_TX_CTRL_T prTxCtrl;
  4552. UINT_32 u4Num;
  4553. ASSERT(prAdapter);
  4554. prTxCtrl = &prAdapter->rTxCtrl;
  4555. u4Num = kalGetTxPendingFrameCount(prAdapter->prGlueInfo) + (UINT_32) (prTxCtrl->i4PendingFwdFrameCount);
  4556. return u4Num;
  4557. }
  4558. /*----------------------------------------------------------------------------*/
  4559. /*!
  4560. * @brief This function is to report current ACPI state
  4561. *
  4562. * @param prAdapter Pointer of Adapter Data Structure
  4563. *
  4564. * @return ACPI_STATE_D0 Normal Operation Mode
  4565. * ACPI_STATE_D3 Suspend Mode
  4566. */
  4567. /*----------------------------------------------------------------------------*/
  4568. ENUM_ACPI_STATE_T wlanGetAcpiState(IN P_ADAPTER_T prAdapter)
  4569. {
  4570. ASSERT(prAdapter);
  4571. return prAdapter->rAcpiState;
  4572. }
  4573. /*----------------------------------------------------------------------------*/
  4574. /*!
  4575. * @brief This function is to update current ACPI state only
  4576. *
  4577. * @param prAdapter Pointer of Adapter Data Structure
  4578. * @param ePowerState ACPI_STATE_D0 Normal Operation Mode
  4579. * ACPI_STATE_D3 Suspend Mode
  4580. *
  4581. * @return none
  4582. */
  4583. /*----------------------------------------------------------------------------*/
  4584. VOID wlanSetAcpiState(IN P_ADAPTER_T prAdapter, IN ENUM_ACPI_STATE_T ePowerState)
  4585. {
  4586. ASSERT(prAdapter);
  4587. ASSERT(ePowerState <= ACPI_STATE_D3);
  4588. prAdapter->rAcpiState = ePowerState;
  4589. }
  4590. /*----------------------------------------------------------------------------*/
  4591. /*!
  4592. * @brief This function is to query ECO version from HIFSYS CR
  4593. *
  4594. * @param prAdapter Pointer of Adapter Data Structure
  4595. *
  4596. * @return zero Unable to retrieve ECO version information
  4597. * non-zero ECO version (1-based)
  4598. */
  4599. /*----------------------------------------------------------------------------*/
  4600. UINT_8 wlanGetEcoVersion(IN P_ADAPTER_T prAdapter)
  4601. {
  4602. UINT_8 ucEcoVersion;
  4603. ASSERT(prAdapter);
  4604. #if CFG_MULTI_ECOVER_SUPPORT
  4605. ucEcoVersion = nicGetChipEcoVer();
  4606. DBGLOG(INIT, TRACE, "%s: %u\n", __func__, ucEcoVersion);
  4607. return ucEcoVersion;
  4608. #else
  4609. if (nicVerifyChipID(prAdapter) == TRUE)
  4610. return prAdapter->ucRevID + 1;
  4611. else
  4612. return 0;
  4613. #endif
  4614. }
  4615. /*----------------------------------------------------------------------------*/
  4616. /*!
  4617. * @brief This function is to setting the default Tx Power configuration
  4618. *
  4619. * @param prAdapter Pointer of Adapter Data Structure
  4620. *
  4621. * @return zero Unable to retrieve ECO version information
  4622. * non-zero ECO version (1-based)
  4623. */
  4624. /*----------------------------------------------------------------------------*/
  4625. VOID wlanDefTxPowerCfg(IN P_ADAPTER_T prAdapter)
  4626. {
  4627. UINT_8 i;
  4628. P_GLUE_INFO_T prGlueInfo = prAdapter->prGlueInfo;
  4629. P_SET_TXPWR_CTRL_T prTxpwr;
  4630. ASSERT(prGlueInfo);
  4631. prTxpwr = &prGlueInfo->rTxPwr;
  4632. prTxpwr->c2GLegacyStaPwrOffset = 0;
  4633. prTxpwr->c2GHotspotPwrOffset = 0;
  4634. prTxpwr->c2GP2pPwrOffset = 0;
  4635. prTxpwr->c2GBowPwrOffset = 0;
  4636. prTxpwr->c5GLegacyStaPwrOffset = 0;
  4637. prTxpwr->c5GHotspotPwrOffset = 0;
  4638. prTxpwr->c5GP2pPwrOffset = 0;
  4639. prTxpwr->c5GBowPwrOffset = 0;
  4640. prTxpwr->ucConcurrencePolicy = 0;
  4641. for (i = 0; i < 3; i++)
  4642. prTxpwr->acReserved1[i] = 0;
  4643. for (i = 0; i < 14; i++)
  4644. prTxpwr->acTxPwrLimit2G[i] = 63;
  4645. for (i = 0; i < 4; i++)
  4646. prTxpwr->acTxPwrLimit5G[i] = 63;
  4647. for (i = 0; i < 2; i++)
  4648. prTxpwr->acReserved2[i] = 0;
  4649. }
  4650. /*----------------------------------------------------------------------------*/
  4651. /*!
  4652. * @brief This function is to
  4653. * set preferred band configuration corresponding to network type
  4654. *
  4655. * @param prAdapter Pointer of Adapter Data Structure
  4656. * @param eBand Given band
  4657. * @param ucBssIndex BSS Info Index
  4658. *
  4659. * @return none
  4660. */
  4661. /*----------------------------------------------------------------------------*/
  4662. VOID wlanSetPreferBandByNetwork(IN P_ADAPTER_T prAdapter, IN ENUM_BAND_T eBand, IN UINT_8 ucBssIndex)
  4663. {
  4664. ASSERT(prAdapter);
  4665. ASSERT(eBand <= BAND_NUM);
  4666. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  4667. ASSERT(ucBssIndex <= BSS_INFO_NUM);
  4668. /* 1. set prefer band according to network type */
  4669. prAdapter->aePreferBand[ucBssIndex] = eBand;
  4670. /* 2. remove buffered BSS descriptors correspondingly */
  4671. if (eBand == BAND_2G4)
  4672. scanRemoveBssDescByBandAndNetwork(prAdapter, BAND_5G, ucBssIndex);
  4673. else if (eBand == BAND_5G)
  4674. scanRemoveBssDescByBandAndNetwork(prAdapter, BAND_2G4, ucBssIndex);
  4675. }
  4676. /*----------------------------------------------------------------------------*/
  4677. /*!
  4678. * @brief This function is to
  4679. * get channel information corresponding to specified network type
  4680. *
  4681. * @param prAdapter Pointer of Adapter Data Structure
  4682. * @param ucBssIndex BSS Info Index
  4683. *
  4684. * @return channel number
  4685. */
  4686. /*----------------------------------------------------------------------------*/
  4687. UINT_8 wlanGetChannelNumberByNetwork(IN P_ADAPTER_T prAdapter, IN UINT_8 ucBssIndex)
  4688. {
  4689. P_BSS_INFO_T prBssInfo;
  4690. ASSERT(prAdapter);
  4691. ASSERT(ucBssIndex <= MAX_BSS_INDEX);
  4692. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  4693. return prBssInfo->ucPrimaryChannel;
  4694. }
  4695. /*----------------------------------------------------------------------------*/
  4696. /*!
  4697. * @brief This function is to
  4698. * check unconfigured system properties and generate related message on
  4699. * scan list to notify users
  4700. *
  4701. * @param prAdapter Pointer of Adapter Data Structure
  4702. *
  4703. * @return WLAN_STATUS_SUCCESS
  4704. */
  4705. /*----------------------------------------------------------------------------*/
  4706. WLAN_STATUS wlanCheckSystemConfiguration(IN P_ADAPTER_T prAdapter)
  4707. {
  4708. #if (CFG_NVRAM_EXISTENCE_CHECK == 1) || (CFG_SW_NVRAM_VERSION_CHECK == 1)
  4709. const UINT_8 aucZeroMacAddr[] = NULL_MAC_ADDR;
  4710. const UINT_8 aucBCAddr[] = BC_MAC_ADDR;
  4711. BOOLEAN fgIsConfExist = TRUE;
  4712. BOOLEAN fgGenErrMsg = FALSE;
  4713. P_REG_INFO_T prRegInfo = NULL;
  4714. P_WLAN_BEACON_FRAME_T prBeacon = NULL;
  4715. P_IE_SSID_T prSsid = NULL;
  4716. UINT_32 u4ErrCode = 0;
  4717. UINT_8 aucErrMsg[32];
  4718. PARAM_SSID_T rSsid;
  4719. PARAM_802_11_CONFIG_T rConfiguration;
  4720. PARAM_RATES_EX rSupportedRates;
  4721. #endif
  4722. DEBUGFUNC("wlanCheckSystemConfiguration");
  4723. ASSERT(prAdapter);
  4724. #if (CFG_NVRAM_EXISTENCE_CHECK == 1)
  4725. if (kalIsConfigurationExist(prAdapter->prGlueInfo) == FALSE) {
  4726. fgIsConfExist = FALSE;
  4727. fgGenErrMsg = TRUE;
  4728. }
  4729. #endif
  4730. #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
  4731. prRegInfo = kalGetConfiguration(prAdapter->prGlueInfo);
  4732. #if (CFG_SUPPORT_PWR_LIMIT_COUNTRY == 1)
  4733. if (fgIsConfExist == TRUE && (CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part1CfgPeerVersion
  4734. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part2CfgPeerVersion
  4735. || prAdapter->rVerInfo.u2Part1CfgOwnVersion < CFG_DRV_PEER_VERSION
  4736. || prAdapter->rVerInfo.u2Part2CfgOwnVersion < CFG_DRV_PEER_VERSION /* NVRAM */
  4737. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2FwPeerVersion
  4738. || prAdapter->rVerInfo.u2FwOwnVersion < CFG_DRV_PEER_VERSION
  4739. || (prAdapter->fgIsEmbbededMacAddrValid == FALSE &&
  4740. (IS_BMCAST_MAC_ADDR(prRegInfo->aucMacAddr)
  4741. || EQUAL_MAC_ADDR(aucZeroMacAddr, prRegInfo->aucMacAddr)))
  4742. || prRegInfo->ucTxPwrValid == 0 || prAdapter->fgIsPowerLimitTableValid == FALSE))
  4743. fgGenErrMsg = TRUE;
  4744. #else
  4745. if (fgIsConfExist == TRUE && (CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part1CfgPeerVersion
  4746. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part2CfgPeerVersion
  4747. || prAdapter->rVerInfo.u2Part1CfgOwnVersion < CFG_DRV_PEER_VERSION
  4748. || prAdapter->rVerInfo.u2Part2CfgOwnVersion < CFG_DRV_PEER_VERSION /* NVRAM */
  4749. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2FwPeerVersion
  4750. || prAdapter->rVerInfo.u2FwOwnVersion < CFG_DRV_PEER_VERSION
  4751. || (prAdapter->fgIsEmbbededMacAddrValid == FALSE &&
  4752. (IS_BMCAST_MAC_ADDR(prRegInfo->aucMacAddr)
  4753. || EQUAL_MAC_ADDR(aucZeroMacAddr, prRegInfo->aucMacAddr)))
  4754. || prRegInfo->ucTxPwrValid == 0))
  4755. fgGenErrMsg = TRUE;
  4756. #endif
  4757. #endif
  4758. if (fgGenErrMsg == TRUE) {
  4759. prBeacon = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(WLAN_BEACON_FRAME_T) + sizeof(IE_SSID_T));
  4760. /* initialization */
  4761. kalMemZero(prBeacon, sizeof(WLAN_BEACON_FRAME_T) + sizeof(IE_SSID_T));
  4762. /* prBeacon initialization */
  4763. prBeacon->u2FrameCtrl = MAC_FRAME_BEACON;
  4764. COPY_MAC_ADDR(prBeacon->aucDestAddr, aucBCAddr);
  4765. COPY_MAC_ADDR(prBeacon->aucSrcAddr, aucZeroMacAddr);
  4766. COPY_MAC_ADDR(prBeacon->aucBSSID, aucZeroMacAddr);
  4767. prBeacon->u2BeaconInterval = 100;
  4768. prBeacon->u2CapInfo = CAP_INFO_ESS;
  4769. /* prSSID initialization */
  4770. prSsid = (P_IE_SSID_T) (&prBeacon->aucInfoElem[0]);
  4771. prSsid->ucId = ELEM_ID_SSID;
  4772. /* rConfiguration initialization */
  4773. rConfiguration.u4Length = sizeof(PARAM_802_11_CONFIG_T);
  4774. rConfiguration.u4BeaconPeriod = 100;
  4775. rConfiguration.u4ATIMWindow = 1;
  4776. rConfiguration.u4DSConfig = 2412;
  4777. rConfiguration.rFHConfig.u4Length = sizeof(PARAM_802_11_CONFIG_FH_T);
  4778. /* rSupportedRates initialization */
  4779. kalMemZero(rSupportedRates, sizeof(PARAM_RATES_EX));
  4780. }
  4781. #if (CFG_NVRAM_EXISTENCE_CHECK == 1)
  4782. #define NVRAM_ERR_MSG "NVRAM WARNING: Err = 0x01"
  4783. if ((kalIsConfigurationExist(prAdapter->prGlueInfo) == FALSE) && (prSsid)) {
  4784. COPY_SSID(prSsid->aucSSID, prSsid->ucLength, NVRAM_ERR_MSG, (UINT_8) (strlen(NVRAM_ERR_MSG)));
  4785. kalIndicateBssInfo(prAdapter->prGlueInfo,
  4786. (PUINT_8) prBeacon,
  4787. OFFSET_OF(WLAN_BEACON_FRAME_T,
  4788. aucInfoElem) + OFFSET_OF(IE_SSID_T, aucSSID) + prSsid->ucLength, 1, 0);
  4789. COPY_SSID(rSsid.aucSsid, rSsid.u4SsidLen, NVRAM_ERR_MSG, strlen(NVRAM_ERR_MSG));
  4790. nicAddScanResult(prAdapter,
  4791. prBeacon->aucBSSID,
  4792. &rSsid,
  4793. 0,
  4794. 0,
  4795. PARAM_NETWORK_TYPE_FH,
  4796. &rConfiguration,
  4797. NET_TYPE_INFRA,
  4798. rSupportedRates,
  4799. OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem) + OFFSET_OF(IE_SSID_T,
  4800. aucSSID) +
  4801. prSsid->ucLength - WLAN_MAC_MGMT_HEADER_LEN,
  4802. (PUINT_8) ((ULONG) (prBeacon) + WLAN_MAC_MGMT_HEADER_LEN));
  4803. }
  4804. #endif
  4805. #if (CFG_SW_NVRAM_VERSION_CHECK == 1)
  4806. #define VER_ERR_MSG "NVRAM WARNING: Err = 0x%02X"
  4807. if (fgIsConfExist == TRUE) {
  4808. if ((CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part1CfgPeerVersion
  4809. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2Part2CfgPeerVersion
  4810. || prAdapter->rVerInfo.u2Part1CfgOwnVersion < CFG_DRV_PEER_VERSION
  4811. || prAdapter->rVerInfo.u2Part2CfgOwnVersion < CFG_DRV_PEER_VERSION /* NVRAM */
  4812. || CFG_DRV_OWN_VERSION < prAdapter->rVerInfo.u2FwPeerVersion
  4813. || prAdapter->rVerInfo.u2FwOwnVersion < CFG_DRV_PEER_VERSION))
  4814. u4ErrCode |= NVRAM_ERROR_VERSION_MISMATCH;
  4815. if (prRegInfo->ucTxPwrValid == 0)
  4816. u4ErrCode |= NVRAM_ERROR_INVALID_TXPWR;
  4817. if (prAdapter->fgIsEmbbededMacAddrValid == FALSE && (IS_BMCAST_MAC_ADDR(prRegInfo->aucMacAddr)
  4818. || EQUAL_MAC_ADDR(aucZeroMacAddr,
  4819. prRegInfo->aucMacAddr))) {
  4820. u4ErrCode |= NVRAM_ERROR_INVALID_MAC_ADDR;
  4821. }
  4822. #if CFG_SUPPORT_PWR_LIMIT_COUNTRY
  4823. if (prAdapter->fgIsPowerLimitTableValid == FALSE)
  4824. u4ErrCode |= NVRAM_POWER_LIMIT_TABLE_INVALID;
  4825. #endif
  4826. if ((u4ErrCode != 0) && (prSsid)) {
  4827. sprintf(aucErrMsg, VER_ERR_MSG, (unsigned int)u4ErrCode);
  4828. COPY_SSID(prSsid->aucSSID, prSsid->ucLength, aucErrMsg, (UINT_8) (strlen(aucErrMsg)));
  4829. kalIndicateBssInfo(prAdapter->prGlueInfo,
  4830. (PUINT_8) prBeacon,
  4831. OFFSET_OF(WLAN_BEACON_FRAME_T,
  4832. aucInfoElem) + OFFSET_OF(IE_SSID_T,
  4833. aucSSID) + prSsid->ucLength, 1, 0);
  4834. COPY_SSID(rSsid.aucSsid, rSsid.u4SsidLen, NVRAM_ERR_MSG, strlen(NVRAM_ERR_MSG));
  4835. nicAddScanResult(prAdapter, prBeacon->aucBSSID, &rSsid, 0, 0,
  4836. PARAM_NETWORK_TYPE_FH, &rConfiguration, NET_TYPE_INFRA,
  4837. rSupportedRates, OFFSET_OF(WLAN_BEACON_FRAME_T,
  4838. aucInfoElem) +
  4839. OFFSET_OF(IE_SSID_T,
  4840. aucSSID) + prSsid->ucLength -
  4841. WLAN_MAC_MGMT_HEADER_LEN,
  4842. (PUINT_8) ((ULONG) (prBeacon) + WLAN_MAC_MGMT_HEADER_LEN));
  4843. }
  4844. }
  4845. #endif
  4846. if (fgGenErrMsg == TRUE)
  4847. cnmMemFree(prAdapter, prBeacon);
  4848. return WLAN_STATUS_SUCCESS;
  4849. }
  4850. WLAN_STATUS
  4851. wlanoidQueryBssStatistics(IN P_ADAPTER_T prAdapter,
  4852. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  4853. {
  4854. P_PARAM_GET_BSS_STATISTICS prQueryBssStatistics;
  4855. P_BSS_INFO_T prBssInfo;
  4856. P_STA_RECORD_T prStaRec;
  4857. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  4858. UINT_8 ucBssIndex;
  4859. ENUM_WMM_ACI_T eAci;
  4860. DEBUGFUNC("wlanoidQueryBssStatistics");
  4861. do {
  4862. ASSERT(pvQueryBuffer);
  4863. /* 4 1. Sanity test */
  4864. if ((prAdapter == NULL) || (pu4QueryInfoLen == NULL))
  4865. break;
  4866. if ((u4QueryBufferLen) && (pvQueryBuffer == NULL))
  4867. break;
  4868. if (u4QueryBufferLen < sizeof(P_PARAM_GET_BSS_STATISTICS)) {
  4869. *pu4QueryInfoLen = sizeof(P_PARAM_GET_BSS_STATISTICS);
  4870. rResult = WLAN_STATUS_BUFFER_TOO_SHORT;
  4871. break;
  4872. }
  4873. prQueryBssStatistics = (P_PARAM_GET_BSS_STATISTICS) pvQueryBuffer;
  4874. *pu4QueryInfoLen = sizeof(PARAM_GET_BSS_STATISTICS);
  4875. ucBssIndex = prQueryBssStatistics->ucBssIndex;
  4876. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIndex);
  4877. if (prBssInfo) {
  4878. /*AIS*/
  4879. if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
  4880. prStaRec = prBssInfo->prStaRecOfAP;
  4881. if (prStaRec) {
  4882. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  4883. prQueryBssStatistics->arLinkStatistics[eAci].u4TxMsdu =
  4884. prStaRec->arLinkStatistics[eAci].u4TxMsdu;
  4885. prQueryBssStatistics->arLinkStatistics[eAci].u4RxMsdu =
  4886. prStaRec->arLinkStatistics[eAci].u4RxMsdu;
  4887. prQueryBssStatistics->arLinkStatistics[eAci].u4TxDropMsdu =
  4888. prStaRec->arLinkStatistics[eAci].u4TxDropMsdu +
  4889. prBssInfo->arLinkStatistics[eAci].u4TxDropMsdu;
  4890. prQueryBssStatistics->arLinkStatistics[eAci].u4TxFailMsdu =
  4891. prStaRec->arLinkStatistics[eAci].u4TxFailMsdu;
  4892. prQueryBssStatistics->arLinkStatistics[eAci].u4TxRetryMsdu =
  4893. prStaRec->arLinkStatistics[eAci].u4TxRetryMsdu;
  4894. }
  4895. }
  4896. }
  4897. rResult = WLAN_STATUS_SUCCESS;
  4898. /*P2P */
  4899. /* TODO */
  4900. /*BOW*/
  4901. /* TODO */
  4902. }
  4903. } while (FALSE);
  4904. return rResult;
  4905. }
  4906. VOID wlanDumpBssStatistics(IN P_ADAPTER_T prAdapter, UINT_8 ucBssIdx)
  4907. {
  4908. P_BSS_INFO_T prBssInfo;
  4909. P_STA_RECORD_T prStaRec;
  4910. ENUM_WMM_ACI_T eAci;
  4911. WIFI_WMM_AC_STAT_T arLLStats[WMM_AC_INDEX_NUM];
  4912. UINT_8 ucIdx;
  4913. if (ucBssIdx > MAX_BSS_INDEX) {
  4914. DBGLOG(SW4, WARN, "Invalid BssInfo index[%u], skip dump!\n", ucBssIdx);
  4915. return;
  4916. }
  4917. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucBssIdx);
  4918. if (!prBssInfo) {
  4919. DBGLOG(SW4, WARN, "Invalid BssInfo index[%u], skip dump!\n", ucBssIdx);
  4920. return;
  4921. }
  4922. /* <1> fill per-BSS statistics */
  4923. #if 0
  4924. /*AIS*/ if (prBssInfo->eCurrentOPMode == OP_MODE_INFRASTRUCTURE) {
  4925. prStaRec = prBssInfo->prStaRecOfAP;
  4926. if (prStaRec) {
  4927. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  4928. prBssInfo->arLinkStatistics[eAci].u4TxMsdu = prStaRec->arLinkStatistics[eAci].u4TxMsdu;
  4929. prBssInfo->arLinkStatistics[eAci].u4RxMsdu = prStaRec->arLinkStatistics[eAci].u4RxMsdu;
  4930. prBssInfo->arLinkStatistics[eAci].u4TxDropMsdu +=
  4931. prStaRec->arLinkStatistics[eAci].u4TxDropMsdu;
  4932. prBssInfo->arLinkStatistics[eAci].u4TxFailMsdu =
  4933. prStaRec->arLinkStatistics[eAci].u4TxFailMsdu;
  4934. prBssInfo->arLinkStatistics[eAci].u4TxRetryMsdu =
  4935. prStaRec->arLinkStatistics[eAci].u4TxRetryMsdu;
  4936. }
  4937. }
  4938. }
  4939. #else
  4940. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  4941. arLLStats[eAci].u4TxMsdu = prBssInfo->arLinkStatistics[eAci].u4TxMsdu;
  4942. arLLStats[eAci].u4RxMsdu = prBssInfo->arLinkStatistics[eAci].u4RxMsdu;
  4943. arLLStats[eAci].u4TxDropMsdu = prBssInfo->arLinkStatistics[eAci].u4TxDropMsdu;
  4944. arLLStats[eAci].u4TxFailMsdu = prBssInfo->arLinkStatistics[eAci].u4TxFailMsdu;
  4945. arLLStats[eAci].u4TxRetryMsdu = prBssInfo->arLinkStatistics[eAci].u4TxRetryMsdu;
  4946. }
  4947. for (ucIdx = 0; ucIdx < CFG_NUM_OF_STA_RECORD; ucIdx++) {
  4948. prStaRec = cnmGetStaRecByIndex(prAdapter, ucIdx);
  4949. if (prStaRec) {
  4950. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prStaRec->ucBssIndex);
  4951. if (!prBssInfo)
  4952. continue;
  4953. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  4954. arLLStats[eAci].u4TxMsdu += prStaRec->arLinkStatistics[eAci].u4TxMsdu;
  4955. arLLStats[eAci].u4RxMsdu += prStaRec->arLinkStatistics[eAci].u4RxMsdu;
  4956. arLLStats[eAci].u4TxDropMsdu += prStaRec->arLinkStatistics[eAci].u4TxDropMsdu;
  4957. arLLStats[eAci].u4TxFailMsdu += prStaRec->arLinkStatistics[eAci].u4TxFailMsdu;
  4958. arLLStats[eAci].u4TxRetryMsdu += prStaRec->arLinkStatistics[eAci].u4TxRetryMsdu;
  4959. }
  4960. }
  4961. }
  4962. #endif
  4963. /* <2>Dump BSS statistics */
  4964. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  4965. DBGLOG(BSS, TRACE, "LLS BSS[%u] AC[%u]: T[%u] R[%u] T_D[%u] T_F[%u]\n",
  4966. prBssInfo->ucBssIndex, eAci, arLLStats[eAci].u4TxMsdu,
  4967. arLLStats[eAci].u4RxMsdu, arLLStats[eAci].u4TxDropMsdu,
  4968. arLLStats[eAci].u4TxFailMsdu);
  4969. }
  4970. }
  4971. VOID wlanDumpAllBssStatistics(IN P_ADAPTER_T prAdapter)
  4972. {
  4973. P_BSS_INFO_T prBssInfo;
  4974. /* ENUM_WMM_ACI_T eAci; */
  4975. UINT_32 ucIdx;
  4976. /* wlanUpdateAllBssStatistics(prAdapter); */
  4977. for (ucIdx = 0; ucIdx < BSS_INFO_NUM; ucIdx++) {
  4978. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, ucIdx);
  4979. if (!IS_BSS_ACTIVE(prBssInfo)) {
  4980. DBGLOG(SW4, TRACE, "Invalid BssInfo index[%u], skip dump!\n", ucIdx);
  4981. continue;
  4982. }
  4983. wlanDumpBssStatistics(prAdapter, ucIdx);
  4984. }
  4985. }
  4986. WLAN_STATUS
  4987. wlanoidQueryStaStatistics(IN P_ADAPTER_T prAdapter,
  4988. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  4989. {
  4990. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  4991. P_STA_RECORD_T prStaRec, prTempStaRec;
  4992. P_PARAM_GET_STA_STATISTICS prQueryStaStatistics;
  4993. UINT_8 ucStaRecIdx;
  4994. P_QUE_MGT_T prQM = &prAdapter->rQM;
  4995. CMD_GET_STA_STATISTICS_T rQueryCmdStaStatistics;
  4996. UINT_8 ucIdx;
  4997. ENUM_WMM_ACI_T eAci;
  4998. DEBUGFUNC("wlanoidQueryStaStatistics");
  4999. do {
  5000. ASSERT(pvQueryBuffer);
  5001. /* 4 1. Sanity test */
  5002. if ((prAdapter == NULL) || (pu4QueryInfoLen == NULL))
  5003. break;
  5004. if ((u4QueryBufferLen) && (pvQueryBuffer == NULL))
  5005. break;
  5006. if (u4QueryBufferLen < sizeof(PARAM_GET_STA_STA_STATISTICS)) {
  5007. *pu4QueryInfoLen = sizeof(PARAM_GET_STA_STA_STATISTICS);
  5008. rResult = WLAN_STATUS_BUFFER_TOO_SHORT;
  5009. break;
  5010. }
  5011. prQueryStaStatistics = (P_PARAM_GET_STA_STATISTICS) pvQueryBuffer;
  5012. *pu4QueryInfoLen = sizeof(PARAM_GET_STA_STA_STATISTICS);
  5013. /* 4 5. Get driver global QM counter */
  5014. for (ucIdx = TC0_INDEX; ucIdx <= TC3_INDEX; ucIdx++) {
  5015. prQueryStaStatistics->au4TcAverageQueLen[ucIdx] = prQM->au4AverageQueLen[ucIdx];
  5016. prQueryStaStatistics->au4TcCurrentQueLen[ucIdx] = prQM->au4CurrentTcResource[ucIdx];
  5017. }
  5018. /* 4 2. Get StaRec by MAC address */
  5019. prStaRec = NULL;
  5020. for (ucStaRecIdx = 0; ucStaRecIdx < CFG_NUM_OF_STA_RECORD; ucStaRecIdx++) {
  5021. prTempStaRec = &(prAdapter->arStaRec[ucStaRecIdx]);
  5022. if (prTempStaRec->fgIsValid && prTempStaRec->fgIsInUse) {
  5023. if (EQUAL_MAC_ADDR(prTempStaRec->aucMacAddr, prQueryStaStatistics->aucMacAddr)) {
  5024. prStaRec = prTempStaRec;
  5025. break;
  5026. }
  5027. }
  5028. }
  5029. if (!prStaRec) {
  5030. rResult = WLAN_STATUS_INVALID_DATA;
  5031. break;
  5032. }
  5033. prQueryStaStatistics->u4Flag |= BIT(0);
  5034. #if CFG_ENABLE_PER_STA_STATISTICS
  5035. /* 4 3. Get driver statistics */
  5036. prQueryStaStatistics->u4TxTotalCount = prStaRec->u4TotalTxPktsNumber;
  5037. prQueryStaStatistics->u4RxTotalCount = prStaRec->u4TotalRxPktsNumber;
  5038. prQueryStaStatistics->u4TxExceedThresholdCount = prStaRec->u4ThresholdCounter;
  5039. prQueryStaStatistics->u4TxMaxTime = prStaRec->u4MaxTxPktsTime;
  5040. if (prStaRec->u4TotalTxPktsNumber) {
  5041. prQueryStaStatistics->u4TxAverageProcessTime =
  5042. (prStaRec->u4TotalTxPktsTime / prStaRec->u4TotalTxPktsNumber);
  5043. } else
  5044. prQueryStaStatistics->u4TxAverageProcessTime = 0;
  5045. /*link layer statistics */
  5046. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  5047. prQueryStaStatistics->arLinkStatistics[eAci].u4TxMsdu =
  5048. prStaRec->arLinkStatistics[eAci].u4TxMsdu;
  5049. prQueryStaStatistics->arLinkStatistics[eAci].u4RxMsdu =
  5050. prStaRec->arLinkStatistics[eAci].u4RxMsdu;
  5051. prQueryStaStatistics->arLinkStatistics[eAci].u4TxDropMsdu =
  5052. prStaRec->arLinkStatistics[eAci].u4TxDropMsdu;
  5053. }
  5054. for (ucIdx = TC0_INDEX; ucIdx <= TC3_INDEX; ucIdx++) {
  5055. prQueryStaStatistics->au4TcResourceEmptyCount[ucIdx] =
  5056. prQM->au4QmTcResourceEmptyCounter[prStaRec->ucBssIndex][ucIdx];
  5057. /* Reset */
  5058. prQM->au4QmTcResourceEmptyCounter[prStaRec->ucBssIndex][ucIdx] = 0;
  5059. }
  5060. /* 4 4.1 Reset statistics */
  5061. if (prQueryStaStatistics->ucReadClear) {
  5062. prStaRec->u4ThresholdCounter = 0;
  5063. prStaRec->u4TotalTxPktsNumber = 0;
  5064. prStaRec->u4TotalTxPktsTime = 0;
  5065. prStaRec->u4TotalRxPktsNumber = 0;
  5066. prStaRec->u4MaxTxPktsTime = 0;
  5067. }
  5068. /*link layer statistics */
  5069. if (prQueryStaStatistics->ucLlsReadClear) {
  5070. for (eAci = 0; eAci < WMM_AC_INDEX_NUM; eAci++) {
  5071. prStaRec->arLinkStatistics[eAci].u4TxMsdu = 0;
  5072. prStaRec->arLinkStatistics[eAci].u4RxMsdu = 0;
  5073. prStaRec->arLinkStatistics[eAci].u4TxDropMsdu = 0;
  5074. }
  5075. }
  5076. #endif
  5077. for (ucIdx = TC0_INDEX; ucIdx <= TC3_INDEX; ucIdx++)
  5078. prQueryStaStatistics->au4TcQueLen[ucIdx] = prStaRec->arTxQueue[ucIdx].u4NumElem;
  5079. rResult = WLAN_STATUS_SUCCESS;
  5080. /* 4 6. Ensure FW supports get station link status */
  5081. if (prAdapter->u4FwCompileFlag0 & COMPILE_FLAG0_GET_STA_LINK_STATUS) {
  5082. rQueryCmdStaStatistics.ucIndex = prStaRec->ucIndex;
  5083. COPY_MAC_ADDR(rQueryCmdStaStatistics.aucMacAddr, prQueryStaStatistics->aucMacAddr);
  5084. rQueryCmdStaStatistics.ucReadClear = prQueryStaStatistics->ucReadClear;
  5085. rQueryCmdStaStatistics.ucLlsReadClear = prQueryStaStatistics->ucLlsReadClear;
  5086. rResult = wlanSendSetQueryCmd(prAdapter,
  5087. CMD_ID_GET_STA_STATISTICS,
  5088. FALSE,
  5089. TRUE,
  5090. TRUE,
  5091. nicCmdEventQueryStaStatistics,
  5092. nicOidCmdTimeoutCommon,
  5093. sizeof(CMD_GET_STA_STATISTICS_T),
  5094. (PUINT_8) &rQueryCmdStaStatistics,
  5095. pvQueryBuffer, u4QueryBufferLen);
  5096. prQueryStaStatistics->u4Flag |= BIT(1);
  5097. } else {
  5098. rResult = WLAN_STATUS_NOT_SUPPORTED;
  5099. }
  5100. } while (FALSE);
  5101. return rResult;
  5102. } /* wlanoidQueryP2pVersion */
  5103. /*----------------------------------------------------------------------------*/
  5104. /*!
  5105. * @brief This function is to query Nic resource information
  5106. *
  5107. * @param prAdapter Pointer of Adapter Data Structure
  5108. *
  5109. * @return WLAN_STATUS_SUCCESS
  5110. */
  5111. /*----------------------------------------------------------------------------*/
  5112. VOID wlanQueryNicResourceInformation(IN P_ADAPTER_T prAdapter)
  5113. {
  5114. /* 3 1. Get Nic resource information from FW */
  5115. /* 3 2. Setup resource parameter */
  5116. /* 3 3. Reset Tx resource */
  5117. nicTxResetResource(prAdapter);
  5118. }
  5119. #if 0
  5120. /*----------------------------------------------------------------------------*/
  5121. /*!
  5122. * @brief This function is to SET network interface index for a network interface.
  5123. * A network interface is a TX/RX data port hooked to OS.
  5124. *
  5125. * @param prGlueInfo Pointer of prGlueInfo Data Structure
  5126. * @param ucNetInterfaceIndex Index of network interface
  5127. * @param ucBssIndex Index of BSS
  5128. *
  5129. * @return VOID
  5130. */
  5131. /*----------------------------------------------------------------------------*/
  5132. VOID wlanBindNetInterface(IN P_GLUE_INFO_T prGlueInfo, IN UINT_8 ucNetInterfaceIndex, IN PVOID pvNetInterface)
  5133. {
  5134. P_NET_INTERFACE_INFO_T prNetIfInfo;
  5135. prNetIfInfo = &prGlueInfo->arNetInterfaceInfo[ucNetInterfaceIndex];
  5136. prNetIfInfo->pvNetInterface = pvNetInterface;
  5137. }
  5138. #endif
  5139. /*----------------------------------------------------------------------------*/
  5140. /*!
  5141. * @brief This function is to SET BSS index for a network interface.
  5142. * A network interface is a TX/RX data port hooked to OS.
  5143. *
  5144. * @param prGlueInfo Pointer of prGlueInfo Data Structure
  5145. * @param ucNetInterfaceIndex Index of network interface
  5146. * @param ucBssIndex Index of BSS
  5147. *
  5148. * @return VOID
  5149. */
  5150. /*----------------------------------------------------------------------------*/
  5151. VOID wlanBindBssIdxToNetInterface(IN P_GLUE_INFO_T prGlueInfo, IN UINT_8 ucBssIndex, IN PVOID pvNetInterface)
  5152. {
  5153. P_NET_INTERFACE_INFO_T prNetIfInfo;
  5154. if (ucBssIndex >= MAX_BSS_INDEX)
  5155. return;
  5156. prNetIfInfo = &prGlueInfo->arNetInterfaceInfo[ucBssIndex];
  5157. prNetIfInfo->ucBssIndex = ucBssIndex;
  5158. prNetIfInfo->pvNetInterface = pvNetInterface;
  5159. /* prGlueInfo->aprBssIdxToNetInterfaceInfo[ucBssIndex] = prNetIfInfo; */
  5160. }
  5161. #if 0
  5162. /*----------------------------------------------------------------------------*/
  5163. /*!
  5164. * @brief This function is to GET BSS index for a network interface.
  5165. * A network interface is a TX/RX data port hooked to OS.
  5166. *
  5167. * @param prGlueInfo Pointer of prGlueInfo Data Structure
  5168. * @param ucNetInterfaceIndex Index of network interface
  5169. *
  5170. * @return UINT_8 Index of BSS
  5171. */
  5172. /*----------------------------------------------------------------------------*/
  5173. UINT_8 wlanGetBssIdxByNetInterface(IN P_GLUE_INFO_T prGlueInfo, IN PVOID pvNetInterface)
  5174. {
  5175. UINT_8 ucIdx = 0;
  5176. for (ucIdx = 0; ucIdx < HW_BSSID_NUM; ucIdx++) {
  5177. if (prGlueInfo->arNetInterfaceInfo[ucIdx].pvNetInterface == pvNetInterface)
  5178. break;
  5179. }
  5180. return ucIdx;
  5181. }
  5182. #endif
  5183. /*----------------------------------------------------------------------------*/
  5184. /*!
  5185. * @brief This function is to GET network interface for a BSS.
  5186. * A network interface is a TX/RX data port hooked to OS.
  5187. *
  5188. * @param prGlueInfo Pointer of prGlueInfo Data Structure
  5189. * @param ucBssIndex Index of BSS
  5190. *
  5191. * @return PVOID pointer of network interface structure
  5192. */
  5193. /*----------------------------------------------------------------------------*/
  5194. PVOID wlanGetNetInterfaceByBssIdx(IN P_GLUE_INFO_T prGlueInfo, IN UINT_8 ucBssIndex)
  5195. {
  5196. if (ucBssIndex < HW_BSSID_NUM)
  5197. return prGlueInfo->arNetInterfaceInfo[ucBssIndex].pvNetInterface;
  5198. return NULL;
  5199. }
  5200. /*----------------------------------------------------------------------------*/
  5201. /*!
  5202. * @brief This function is to get BSS-INDEX for AIS network.
  5203. *
  5204. * @param prAdapter Pointer of ADAPTER_T
  5205. *
  5206. * @return value, as corresponding index of BSS
  5207. */
  5208. /*----------------------------------------------------------------------------*/
  5209. UINT_8 wlanGetAisBssIndex(IN P_ADAPTER_T prAdapter)
  5210. {
  5211. ASSERT(prAdapter);
  5212. return prAdapter->prAisBssInfo->ucBssIndex;
  5213. }
  5214. /*----------------------------------------------------------------------------*/
  5215. /*!
  5216. * @brief This function is to initialize WLAN feature options
  5217. *
  5218. * @param prAdapter Pointer of ADAPTER_T
  5219. *
  5220. * @return none
  5221. */
  5222. /*----------------------------------------------------------------------------*/
  5223. VOID wlanInitFeatureOption(IN P_ADAPTER_T prAdapter)
  5224. {
  5225. P_WIFI_VAR_T prWifiVar = &prAdapter->rWifiVar;
  5226. P_QUE_MGT_T prQM = &prAdapter->rQM;
  5227. /* Feature options will be filled by config file */
  5228. prWifiVar->ucQoS = (UINT_8) wlanCfgGetUint32(prAdapter, "Qos", FEATURE_ENABLED);
  5229. prWifiVar->ucStaHt = (UINT_8) wlanCfgGetUint32(prAdapter, "StaHT", FEATURE_ENABLED);
  5230. prWifiVar->ucStaVht = (UINT_8) wlanCfgGetUint32(prAdapter, "StaVHT", FEATURE_ENABLED);
  5231. prWifiVar->ucApHt = (UINT_8) wlanCfgGetUint32(prAdapter, "ApHT", FEATURE_ENABLED);
  5232. prWifiVar->ucApVht = (UINT_8) wlanCfgGetUint32(prAdapter, "ApVHT", FEATURE_ENABLED);
  5233. prWifiVar->ucP2pGoHt = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pGoHT", FEATURE_ENABLED);
  5234. prWifiVar->ucP2pGoVht = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pGoVHT", FEATURE_ENABLED);
  5235. prWifiVar->ucP2pGcHt = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pGcHT", FEATURE_ENABLED);
  5236. prWifiVar->ucP2pGcVht = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pGcVHT", FEATURE_ENABLED);
  5237. prWifiVar->ucAmpduRx = (UINT_8) wlanCfgGetUint32(prAdapter, "AmpduRx", FEATURE_ENABLED);
  5238. prWifiVar->ucAmpduTx = (UINT_8) wlanCfgGetUint32(prAdapter, "AmpduTx", FEATURE_ENABLED);
  5239. prWifiVar->ucTspec = (UINT_8) wlanCfgGetUint32(prAdapter, "Tspec", FEATURE_DISABLED);
  5240. prWifiVar->ucUapsd = (UINT_8) wlanCfgGetUint32(prAdapter, "Uapsd", FEATURE_ENABLED);
  5241. prWifiVar->ucStaUapsd = (UINT_8) wlanCfgGetUint32(prAdapter, "StaUapsd", FEATURE_DISABLED);
  5242. prWifiVar->ucApUapsd = (UINT_8) wlanCfgGetUint32(prAdapter, "ApUapsd", FEATURE_DISABLED);
  5243. prWifiVar->ucP2pUapsd = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pUapsd", FEATURE_ENABLED);
  5244. prWifiVar->ucTxShortGI = (UINT_8) wlanCfgGetUint32(prAdapter, "SgiTx", FEATURE_ENABLED);
  5245. prWifiVar->ucRxShortGI = (UINT_8) wlanCfgGetUint32(prAdapter, "SgiRx", FEATURE_ENABLED);
  5246. prWifiVar->ucTxLdpc = (UINT_8) wlanCfgGetUint32(prAdapter, "LdpcTx", FEATURE_ENABLED);
  5247. prWifiVar->ucRxLdpc = (UINT_8) wlanCfgGetUint32(prAdapter, "LdpcRx", FEATURE_ENABLED);
  5248. prWifiVar->ucTxStbc = (UINT_8) wlanCfgGetUint32(prAdapter, "StbcTx", FEATURE_DISABLED);
  5249. prWifiVar->ucRxStbc = (UINT_8) wlanCfgGetUint32(prAdapter, "StbcRx", FEATURE_ENABLED);
  5250. prWifiVar->ucTxGf = (UINT_8) wlanCfgGetUint32(prAdapter, "GfTx", FEATURE_ENABLED);
  5251. prWifiVar->ucRxGf = (UINT_8) wlanCfgGetUint32(prAdapter, "GfRx", FEATURE_ENABLED);
  5252. prWifiVar->ucSigTaRts = (UINT_8) wlanCfgGetUint32(prAdapter, "SigTaRts", FEATURE_DISABLED);
  5253. prWifiVar->ucDynBwRts = (UINT_8) wlanCfgGetUint32(prAdapter, "DynBwRts", FEATURE_DISABLED);
  5254. prWifiVar->ucTxopPsTx = (UINT_8) wlanCfgGetUint32(prAdapter, "TxopPsTx", FEATURE_DISABLED);
  5255. prWifiVar->ucStaHtBfee = (UINT_8) wlanCfgGetUint32(prAdapter, "StaHTBfee", FEATURE_DISABLED);
  5256. prWifiVar->ucStaVhtBfee = (UINT_8) wlanCfgGetUint32(prAdapter, "StaVHTBfee", FEATURE_ENABLED);
  5257. prWifiVar->ucStaBfer = (UINT_8) wlanCfgGetUint32(prAdapter, "StaBfer", FEATURE_DISABLED);
  5258. prWifiVar->ucApWpsMode = (UINT_8) wlanCfgGetUint32(prAdapter, "ApWpsMode", 0);
  5259. DBGLOG(INIT, LOUD, "ucApWpsMode = %u\n", prWifiVar->ucApWpsMode);
  5260. prWifiVar->ucThreadScheduling = (UINT_8) wlanCfgGetUint32(prAdapter, "ThreadSched", 0);
  5261. prWifiVar->ucThreadPriority =
  5262. (UINT_8) wlanCfgGetUint32(prAdapter, "ThreadPriority", WLAN_TX_THREAD_TASK_PRIORITY);
  5263. prWifiVar->cThreadNice = (INT_8) wlanCfgGetInt32(prAdapter, "ThreadNice", WLAN_TX_THREAD_TASK_NICE);
  5264. prAdapter->rQM.u4MaxForwardBufferCount =
  5265. (UINT_32) wlanCfgGetUint32(prAdapter, "ApForwardBufferCnt", QM_FWD_PKT_QUE_THRESHOLD);
  5266. /* AP channel setting
  5267. * 0: auto
  5268. */
  5269. prWifiVar->ucApChannel = (UINT_8) wlanCfgGetUint32(prAdapter, "ApChannel", 0);
  5270. /*
  5271. * 0: SCN
  5272. * 1: SCA
  5273. * 2: RES
  5274. * 3: SCB
  5275. */
  5276. prWifiVar->ucApSco = (UINT_8) wlanCfgGetUint32(prAdapter, "ApSco", 0);
  5277. prWifiVar->ucP2pGoSco = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pGoSco", 0);
  5278. /* Max bandwidth setting
  5279. * 0: 20Mhz
  5280. * 1: 40Mhz
  5281. * 2: 80Mhz
  5282. * 3: 80+80 or 160Mhz
  5283. * Note: For VHT STA, BW 80Mhz is a must!
  5284. */
  5285. prWifiVar->ucStaBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "StaBw", MAX_BW_80MHZ);
  5286. prWifiVar->ucSta2gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "Sta2gBw", MAX_BW_40MHZ);
  5287. prWifiVar->ucSta5gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "Sta5gBw", MAX_BW_80MHZ);
  5288. prWifiVar->ucAp2gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "Ap2gBw", MAX_BW_20MHZ);
  5289. prWifiVar->ucAp5gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "Ap5gBw", MAX_BW_40MHZ);
  5290. prWifiVar->ucP2p2gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "P2p2gBw", MAX_BW_40MHZ);
  5291. prWifiVar->ucP2p5gBandwidth = (UINT_8) wlanCfgGetUint32(prAdapter, "P2p5gBw", MAX_BW_40MHZ);
  5292. prWifiVar->ucStaDisconnectDetectTh = (UINT_8) wlanCfgGetUint32(prAdapter, "StaDisconnectDetectTh", 0);
  5293. prWifiVar->ucApDisconnectDetectTh = (UINT_8) wlanCfgGetUint32(prAdapter, "ApDisconnectDetectTh", 0);
  5294. prWifiVar->ucP2pDisconnectDetectTh = (UINT_8) wlanCfgGetUint32(prAdapter, "P2pDisconnectDetectTh", 0);
  5295. prWifiVar->ucTcRestrict = (UINT_8) wlanCfgGetUint32(prAdapter, "TcRestrict", 0xFF);
  5296. /* Max Tx dequeue limit: 0 => auto */
  5297. prWifiVar->u4MaxTxDeQLimit = (UINT_32) wlanCfgGetUint32(prAdapter, "MaxTxDeQLimit", 0x0);
  5298. prWifiVar->ucAlwaysResetUsedRes = (UINT_32) wlanCfgGetUint32(prAdapter, "AlwaysResetUsedRes", 0x0);
  5299. #if CFG_SUPPORT_MTK_SYNERGY
  5300. prWifiVar->ucMtkOui = (UINT_8) wlanCfgGetUint32(prAdapter, "MtkOui", FEATURE_ENABLED);
  5301. prWifiVar->u4MtkOuiCap = (UINT_32) wlanCfgGetUint32(prAdapter, "MtkOuiCap", 0);
  5302. prWifiVar->aucMtkFeature[0] = 0xff;
  5303. prWifiVar->aucMtkFeature[1] = 0xff;
  5304. prWifiVar->aucMtkFeature[2] = 0xff;
  5305. prWifiVar->aucMtkFeature[3] = 0xff;
  5306. #endif
  5307. prWifiVar->ucCmdRsvResource = (UINT_8) wlanCfgGetUint32(prAdapter, "TxCmdRsv", QM_CMD_RESERVED_THRESHOLD);
  5308. prWifiVar->u4MgmtQueueDelayTimeout =
  5309. (UINT_32) wlanCfgGetUint32(prAdapter, "TxMgmtQueTO", QM_MGMT_QUEUED_TIMEOUT); /* ms */
  5310. /* Performance related */
  5311. prWifiVar->u4HifIstLoopCount = (UINT_32) wlanCfgGetUint32(prAdapter, "IstLoop", CFG_IST_LOOP_COUNT);
  5312. prWifiVar->u4Rx2OsLoopCount = (UINT_32) wlanCfgGetUint32(prAdapter, "Rx2OsLoop", 4);
  5313. prWifiVar->u4HifTxloopCount = (UINT_32) wlanCfgGetUint32(prAdapter, "HifTxLoop", 1);
  5314. prWifiVar->u4TxFromOsLoopCount = (UINT_32) wlanCfgGetUint32(prAdapter, "OsTxLoop", 1);
  5315. prWifiVar->u4TxRxLoopCount = (UINT_32) wlanCfgGetUint32(prAdapter, "Rx2ReorderLoop", 1);
  5316. prWifiVar->u4NetifStopTh =
  5317. (UINT_32) wlanCfgGetUint32(prAdapter, "NetifStopTh", CFG_TX_STOP_NETIF_PER_QUEUE_THRESHOLD);
  5318. prWifiVar->u4NetifStartTh =
  5319. (UINT_32) wlanCfgGetUint32(prAdapter, "NetifStartTh", CFG_TX_START_NETIF_PER_QUEUE_THRESHOLD);
  5320. prWifiVar->ucTxBaSize = (UINT_8) wlanCfgGetUint32(prAdapter, "TxBaSize", 64);
  5321. prWifiVar->ucRxHtBaSize = (UINT_8) wlanCfgGetUint32(prAdapter, "RxHtBaSize", 64);
  5322. prWifiVar->ucRxVhtBaSize = (UINT_8) wlanCfgGetUint32(prAdapter, "RxVhtBaSize", 32);
  5323. /* Tx Buffer Management */
  5324. prWifiVar->ucExtraTxDone = (UINT_32) wlanCfgGetUint32(prAdapter, "ExtraTxDone", 1);
  5325. prWifiVar->ucTxDbg = (UINT_32) wlanCfgGetUint32(prAdapter, "TxDbg", 0);
  5326. kalMemZero(prWifiVar->au4TcPageCount, sizeof(prWifiVar->au4TcPageCount));
  5327. prWifiVar->au4TcPageCount[TC0_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc0Page", NIC_TX_PAGE_COUNT_TC0);
  5328. prWifiVar->au4TcPageCount[TC1_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc1Page", NIC_TX_PAGE_COUNT_TC1);
  5329. prWifiVar->au4TcPageCount[TC2_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc2Page", NIC_TX_PAGE_COUNT_TC2);
  5330. prWifiVar->au4TcPageCount[TC3_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc3Page", NIC_TX_PAGE_COUNT_TC3);
  5331. prWifiVar->au4TcPageCount[TC4_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc4Page", NIC_TX_PAGE_COUNT_TC4);
  5332. prWifiVar->au4TcPageCount[TC5_INDEX] = (UINT_32) wlanCfgGetUint32(prAdapter, "Tc5Page", NIC_TX_PAGE_COUNT_TC5);
  5333. prQM->au4MinReservedTcResource[TC0_INDEX] =
  5334. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc0MinRsv", QM_MIN_RESERVED_TC0_RESOURCE);
  5335. prQM->au4MinReservedTcResource[TC1_INDEX] =
  5336. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc1MinRsv", QM_MIN_RESERVED_TC1_RESOURCE);
  5337. prQM->au4MinReservedTcResource[TC2_INDEX] =
  5338. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc2MinRsv", QM_MIN_RESERVED_TC2_RESOURCE);
  5339. prQM->au4MinReservedTcResource[TC3_INDEX] =
  5340. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc3MinRsv", QM_MIN_RESERVED_TC3_RESOURCE);
  5341. prQM->au4MinReservedTcResource[TC4_INDEX] =
  5342. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc4MinRsv", QM_MIN_RESERVED_TC4_RESOURCE);
  5343. prQM->au4MinReservedTcResource[TC5_INDEX] =
  5344. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc5MinRsv", QM_MIN_RESERVED_TC5_RESOURCE);
  5345. prQM->au4GuaranteedTcResource[TC0_INDEX] =
  5346. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc0Grt", QM_GUARANTEED_TC0_RESOURCE);
  5347. prQM->au4GuaranteedTcResource[TC1_INDEX] =
  5348. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc1Grt", QM_GUARANTEED_TC1_RESOURCE);
  5349. prQM->au4GuaranteedTcResource[TC2_INDEX] =
  5350. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc2Grt", QM_GUARANTEED_TC2_RESOURCE);
  5351. prQM->au4GuaranteedTcResource[TC3_INDEX] =
  5352. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc3Grt", QM_GUARANTEED_TC3_RESOURCE);
  5353. prQM->au4GuaranteedTcResource[TC4_INDEX] =
  5354. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc4Grt", QM_GUARANTEED_TC4_RESOURCE);
  5355. prQM->au4GuaranteedTcResource[TC5_INDEX] =
  5356. (UINT_32) wlanCfgGetUint32(prAdapter, "Tc5Grt", QM_GUARANTEED_TC5_RESOURCE);
  5357. prQM->u4TimeToAdjustTcResource =
  5358. (UINT_32) wlanCfgGetUint32(prAdapter, "TcAdjustTime", QM_INIT_TIME_TO_ADJUST_TC_RSC);
  5359. prQM->u4TimeToUpdateQueLen =
  5360. (UINT_32) wlanCfgGetUint32(prAdapter, "QueLenUpdateTime", QM_INIT_TIME_TO_UPDATE_QUE_LEN);
  5361. prQM->u4QueLenMovingAverage =
  5362. (UINT_32) wlanCfgGetUint32(prAdapter, "QueLenMovingAvg", QM_QUE_LEN_MOVING_AVE_FACTOR);
  5363. prQM->u4ExtraReservedTcResource =
  5364. (UINT_32) wlanCfgGetUint32(prAdapter, "TcExtraRsv", QM_EXTRA_RESERVED_RESOURCE_WHEN_BUSY);
  5365. /* Stats log */
  5366. prWifiVar->u4StatsLogTimeout = (UINT_32) wlanCfgGetUint32(prAdapter, "StatsLogTO", WLAN_TX_STATS_LOG_TIMEOUT);
  5367. prWifiVar->u4StatsLogDuration =
  5368. (UINT_32) wlanCfgGetUint32(prAdapter, "StatsLogDur", WLAN_TX_STATS_LOG_DURATION);
  5369. prWifiVar->ucDhcpTxDone = (UINT_8) wlanCfgGetUint32(prAdapter, "DhcpTxDone", 1);
  5370. prWifiVar->ucArpTxDone = (UINT_8) wlanCfgGetUint32(prAdapter, "ArpTxDone", 1);
  5371. }
  5372. VOID wlanCfgSetSwCtrl(IN P_ADAPTER_T prAdapter)
  5373. {
  5374. UINT_32 i = 0;
  5375. CHAR aucKey[WLAN_CFG_VALUE_LEN_MAX];
  5376. CHAR aucValue[WLAN_CFG_VALUE_LEN_MAX];
  5377. CHAR *pcPtr = NULL;
  5378. CHAR *pcDupValue = NULL;
  5379. UINT_32 au4Values[2];
  5380. UINT_32 u4TokenCount = 0;
  5381. UINT_32 u4BufLen = 0;
  5382. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  5383. P_GLUE_INFO_T prGlueInfo = prAdapter->prGlueInfo;
  5384. PARAM_CUSTOM_SW_CTRL_STRUCT_T rSwCtrlInfo;
  5385. INT_32 u4Ret = 0;
  5386. const CHAR acDelim[] = " ";
  5387. for (i = 0; i < WLAN_CFG_SET_SW_CTRL_LEN_MAX; i++) {
  5388. kalMemZero(aucValue, WLAN_CFG_VALUE_LEN_MAX);
  5389. kalMemZero(aucKey, WLAN_CFG_VALUE_LEN_MAX);
  5390. kalSprintf(aucKey, "SwCtrl%d", i);
  5391. /* get nothing */
  5392. if (wlanCfgGet(prAdapter, aucKey, aucValue, "", 0) != WLAN_STATUS_SUCCESS)
  5393. continue;
  5394. if (!kalStrCmp(aucValue, ""))
  5395. continue;
  5396. pcDupValue = aucValue;
  5397. u4TokenCount = 0;
  5398. while ((pcPtr = kalStrSep((char **)(&pcDupValue), acDelim)) != NULL) {
  5399. if (!kalStrCmp(pcPtr, ""))
  5400. continue;
  5401. /* au4Values[u4TokenCount] = kalStrtoul(pcPtr, NULL, 0); */
  5402. u4Ret = kalkStrtou32(pcPtr, 0, &(au4Values[u4TokenCount]));
  5403. if (u4Ret)
  5404. DBGLOG(INIT, LOUD, "parse au4Values error u4Ret=%d\n", u4Ret);
  5405. u4TokenCount++;
  5406. /* Only need 2 tokens */
  5407. if (u4TokenCount >= 2)
  5408. break;
  5409. }
  5410. if (u4TokenCount != 2)
  5411. continue;
  5412. rSwCtrlInfo.u4Id = au4Values[0];
  5413. rSwCtrlInfo.u4Data = au4Values[1];
  5414. rStatus = kalIoctl(prGlueInfo,
  5415. wlanoidSetSwCtrlWrite,
  5416. &rSwCtrlInfo, sizeof(rSwCtrlInfo), FALSE, FALSE, TRUE, &u4BufLen);
  5417. }
  5418. }
  5419. VOID wlanCfgSetChip(IN P_ADAPTER_T prAdapter)
  5420. {
  5421. UINT_32 i = 0;
  5422. CHAR aucKey[WLAN_CFG_VALUE_LEN_MAX];
  5423. CHAR aucValue[WLAN_CFG_VALUE_LEN_MAX];
  5424. UINT_32 u4BufLen = 0;
  5425. WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
  5426. P_GLUE_INFO_T prGlueInfo = prAdapter->prGlueInfo;
  5427. PARAM_CUSTOM_CHIP_CONFIG_STRUCT_T rChipConfigInfo;
  5428. for (i = 0; i < WLAN_CFG_SET_CHIP_LEN_MAX; i++) {
  5429. kalMemZero(aucValue, WLAN_CFG_VALUE_LEN_MAX);
  5430. kalMemZero(aucKey, WLAN_CFG_VALUE_LEN_MAX);
  5431. kalSprintf(aucKey, "SetChip%d", i);
  5432. /* get nothing */
  5433. if (wlanCfgGet(prAdapter, aucKey, aucValue, "", 0) != WLAN_STATUS_SUCCESS)
  5434. continue;
  5435. if (!kalStrCmp(aucValue, ""))
  5436. continue;
  5437. kalMemZero(&rChipConfigInfo, sizeof(rChipConfigInfo));
  5438. rChipConfigInfo.ucType = CHIP_CONFIG_TYPE_WO_RESPONSE;
  5439. rChipConfigInfo.u2MsgSize = kalStrnLen(aucValue, WLAN_CFG_VALUE_LEN_MAX);
  5440. kalStrnCpy(rChipConfigInfo.aucCmd, aucValue, CHIP_CONFIG_RESP_SIZE);
  5441. rStatus = kalIoctl(prGlueInfo,
  5442. wlanoidSetChipConfig,
  5443. &rChipConfigInfo, sizeof(rChipConfigInfo), FALSE, FALSE, TRUE, &u4BufLen);
  5444. }
  5445. }
  5446. VOID wlanCfgSetDebugLevel(IN P_ADAPTER_T prAdapter)
  5447. {
  5448. UINT_32 i = 0;
  5449. CHAR aucKey[WLAN_CFG_VALUE_LEN_MAX];
  5450. CHAR aucValue[WLAN_CFG_VALUE_LEN_MAX];
  5451. const CHAR acDelim[] = " ";
  5452. CHAR *pcDupValue;
  5453. CHAR *pcPtr = NULL;
  5454. UINT_32 au4Values[2];
  5455. UINT_32 u4TokenCount = 0;
  5456. UINT_32 u4DbgIdx = 0;
  5457. UINT_32 u4DbgMask = 0;
  5458. INT_32 u4Ret = 0;
  5459. for (i = 0; i < WLAN_CFG_SET_DEBUG_LEVEL_LEN_MAX; i++) {
  5460. kalMemZero(aucValue, WLAN_CFG_VALUE_LEN_MAX);
  5461. kalMemZero(aucKey, WLAN_CFG_VALUE_LEN_MAX);
  5462. kalSprintf(aucKey, "DbgLevel%d", i);
  5463. /* get nothing */
  5464. if (wlanCfgGet(prAdapter, aucKey, aucValue, "", 0) != WLAN_STATUS_SUCCESS)
  5465. continue;
  5466. if (!kalStrCmp(aucValue, ""))
  5467. continue;
  5468. pcDupValue = aucValue;
  5469. u4TokenCount = 0;
  5470. while ((pcPtr = kalStrSep((char **)(&pcDupValue), acDelim)) != NULL) {
  5471. if (!kalStrCmp(pcPtr, ""))
  5472. continue;
  5473. /* au4Values[u4TokenCount] = kalStrtoul(pcPtr, NULL, 0); */
  5474. u4Ret = kalkStrtou32(pcPtr, 0, &(au4Values[u4TokenCount]));
  5475. if (u4Ret)
  5476. DBGLOG(INIT, LOUD, "parse au4Values error u4Ret=%d\n", u4Ret);
  5477. u4TokenCount++;
  5478. /* Only need 2 tokens */
  5479. if (u4TokenCount >= 2)
  5480. break;
  5481. }
  5482. if (u4TokenCount != 2)
  5483. continue;
  5484. u4DbgIdx = au4Values[0];
  5485. u4DbgMask = au4Values[1];
  5486. /* DBG level special control */
  5487. if (u4DbgIdx == 0xFFFFFFFF) {
  5488. wlanSetDebugLevel(DBG_ALL_MODULE_IDX, u4DbgMask);
  5489. DBGLOG(INIT, INFO, "Set ALL DBG module log level to [0x%02x]!", (UINT_8) u4DbgMask);
  5490. } else if (u4DbgIdx == 0xFFFFFFFE) {
  5491. wlanDebugInit();
  5492. DBGLOG(INIT, INFO, "Reset ALL DBG module log level to DEFAULT!");
  5493. } else if (u4DbgIdx < DBG_MODULE_NUM) {
  5494. wlanSetDebugLevel(u4DbgIdx, u4DbgMask);
  5495. DBGLOG(INIT, INFO,
  5496. "Set DBG module[%lu] log level to [0x%02x]!", u4DbgIdx, (UINT_8) u4DbgMask);
  5497. }
  5498. }
  5499. }
  5500. VOID wlanCfgSetCountryCode(IN P_ADAPTER_T prAdapter)
  5501. {
  5502. CHAR aucValue[WLAN_CFG_VALUE_LEN_MAX];
  5503. /* Apply COUNTRY Config */
  5504. if (wlanCfgGet(prAdapter, "Country", aucValue, "", 0) == WLAN_STATUS_SUCCESS) {
  5505. prAdapter->rWifiVar.rConnSettings.u2CountryCode =
  5506. (((UINT_16) aucValue[0]) << 8) | ((UINT_16) aucValue[1]);
  5507. /* Force to re-search country code in country domains */
  5508. prAdapter->prDomainInfo = NULL;
  5509. rlmDomainSendCmd(prAdapter, TRUE);
  5510. /* Update supported channel list in channel table based on current country domain */
  5511. wlanUpdateChannelTable(prAdapter->prGlueInfo);
  5512. }
  5513. }
  5514. #if CFG_SUPPORT_CFG_FILE
  5515. P_WLAN_CFG_ENTRY_T wlanCfgGetEntry(IN P_ADAPTER_T prAdapter, const PCHAR pucKey)
  5516. {
  5517. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5518. P_WLAN_CFG_T prWlanCfg;
  5519. UINT_32 i;
  5520. prWlanCfg = prAdapter->prWlanCfg;
  5521. ASSERT(prWlanCfg);
  5522. ASSERT(pucKey);
  5523. prWlanCfgEntry = NULL;
  5524. for (i = 0; i < WLAN_CFG_ENTRY_NUM_MAX; i++) {
  5525. prWlanCfgEntry = &prWlanCfg->arWlanCfgBuf[i];
  5526. if (prWlanCfgEntry->aucKey[0] != '\0') {
  5527. DBGLOG(INIT, LOUD, "compare key %s saved key %s\n", pucKey, prWlanCfgEntry->aucKey);
  5528. if (kalStrnCmp(pucKey, prWlanCfgEntry->aucKey, WLAN_CFG_KEY_LEN_MAX - 1) == 0)
  5529. return prWlanCfgEntry;
  5530. }
  5531. }
  5532. DBGLOG(INIT, TRACE, "wifi config there is no entry \'%s\'\n", pucKey);
  5533. return NULL;
  5534. }
  5535. WLAN_STATUS wlanCfgGet(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, PCHAR pucValue, PCHAR pucValueDef, UINT_32 u4Flags)
  5536. {
  5537. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5538. P_WLAN_CFG_T prWlanCfg;
  5539. prWlanCfg = prAdapter->prWlanCfg;
  5540. ASSERT(prWlanCfg);
  5541. ASSERT(pucValue);
  5542. /* Find the exist */
  5543. prWlanCfgEntry = wlanCfgGetEntry(prAdapter, pucKey);
  5544. if (prWlanCfgEntry) {
  5545. kalStrnCpy(pucValue, prWlanCfgEntry->aucValue, WLAN_CFG_VALUE_LEN_MAX - 1);
  5546. } else {
  5547. if (pucValueDef)
  5548. kalStrnCpy(pucValue, pucValueDef, WLAN_CFG_VALUE_LEN_MAX - 1);
  5549. return WLAN_STATUS_FAILURE;
  5550. }
  5551. return WLAN_STATUS_SUCCESS;
  5552. }
  5553. UINT_32 wlanCfgGetUint32(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, UINT_32 u4ValueDef)
  5554. {
  5555. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5556. P_WLAN_CFG_T prWlanCfg;
  5557. UINT_32 u4Value;
  5558. INT_32 u4Ret;
  5559. prWlanCfg = prAdapter->prWlanCfg;
  5560. ASSERT(prWlanCfg);
  5561. u4Value = u4ValueDef;
  5562. /* Find the exist */
  5563. prWlanCfgEntry = wlanCfgGetEntry(prAdapter, pucKey);
  5564. if (prWlanCfgEntry) {
  5565. /* u4Ret = kalStrtoul(prWlanCfgEntry->aucValue, NULL, 0); */
  5566. u4Ret = kalkStrtou32(prWlanCfgEntry->aucValue, 0, &u4Value);
  5567. if (u4Ret)
  5568. DBGLOG(INIT, LOUD, "parse aucValue error u4Ret=%d\n", u4Ret);
  5569. }
  5570. return u4Value;
  5571. }
  5572. INT_32 wlanCfgGetInt32(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, INT_32 i4ValueDef)
  5573. {
  5574. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5575. P_WLAN_CFG_T prWlanCfg;
  5576. INT_32 i4Value = 0;
  5577. INT_32 i4Ret = 0;
  5578. prWlanCfg = prAdapter->prWlanCfg;
  5579. ASSERT(prWlanCfg);
  5580. i4Value = i4ValueDef;
  5581. /* Find the exist */
  5582. prWlanCfgEntry = wlanCfgGetEntry(prAdapter, pucKey);
  5583. if (prWlanCfgEntry) {
  5584. /* i4Ret = kalStrtol(prWlanCfgEntry->aucValue, NULL, 0); */
  5585. i4Ret = kalkStrtos32(prWlanCfgEntry->aucValue, 0, &i4Value);
  5586. if (i4Ret)
  5587. DBGLOG(INIT, LOUD, "parse aucValue error i4Ret=%d\n", i4Ret);
  5588. }
  5589. return i4Value;
  5590. }
  5591. WLAN_STATUS wlanCfgSet(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, PCHAR pucValue, UINT_32 u4Flags)
  5592. {
  5593. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5594. P_WLAN_CFG_T prWlanCfg;
  5595. UINT_32 u4EntryIndex;
  5596. UINT_32 i;
  5597. UINT_8 ucExist;
  5598. prWlanCfg = prAdapter->prWlanCfg;
  5599. ASSERT(prWlanCfg);
  5600. ASSERT(pucKey);
  5601. /* Find the exist */
  5602. ucExist = 0;
  5603. prWlanCfgEntry = wlanCfgGetEntry(prAdapter, pucKey);
  5604. if (!prWlanCfgEntry) {
  5605. /* Find the empty */
  5606. for (i = 0; i < WLAN_CFG_ENTRY_NUM_MAX; i++) {
  5607. prWlanCfgEntry = &prWlanCfg->arWlanCfgBuf[i];
  5608. if (prWlanCfgEntry->aucKey[0] == '\0')
  5609. break;
  5610. }
  5611. u4EntryIndex = i;
  5612. if (u4EntryIndex < WLAN_CFG_ENTRY_NUM_MAX) {
  5613. prWlanCfgEntry = &prWlanCfg->arWlanCfgBuf[u4EntryIndex];
  5614. kalMemZero(prWlanCfgEntry, sizeof(WLAN_CFG_ENTRY_T));
  5615. } else {
  5616. prWlanCfgEntry = NULL;
  5617. DBGLOG(INIT, ERROR, "wifi config there is no empty entry\n");
  5618. }
  5619. } /* !prWlanCfgEntry */
  5620. else
  5621. ucExist = 1;
  5622. if (prWlanCfgEntry) {
  5623. if (ucExist == 0) {
  5624. kalStrnCpy(prWlanCfgEntry->aucKey, pucKey, WLAN_CFG_KEY_LEN_MAX - 1);
  5625. prWlanCfgEntry->aucKey[WLAN_CFG_KEY_LEN_MAX - 1] = '\0';
  5626. }
  5627. if (pucValue && pucValue[0] != '\0') {
  5628. kalStrnCpy(prWlanCfgEntry->aucValue, pucValue, WLAN_CFG_VALUE_LEN_MAX - 1);
  5629. prWlanCfgEntry->aucValue[WLAN_CFG_VALUE_LEN_MAX - 1] = '\0';
  5630. if (ucExist) {
  5631. if (prWlanCfgEntry->pfSetCb)
  5632. prWlanCfgEntry->pfSetCb(prAdapter,
  5633. prWlanCfgEntry->aucKey,
  5634. prWlanCfgEntry->aucValue, prWlanCfgEntry->pPrivate, 0);
  5635. }
  5636. } else {
  5637. /* Call the pfSetCb if value is empty ? */
  5638. /* remove the entry if value is empty */
  5639. kalMemZero(prWlanCfgEntry, sizeof(WLAN_CFG_ENTRY_T));
  5640. }
  5641. }
  5642. /* prWlanCfgEntry */
  5643. if (prWlanCfgEntry) {
  5644. DBGLOG(INIT, INFO, "Set wifi config exist %u \'%s\' \'%s\'\n",
  5645. ucExist, prWlanCfgEntry->aucKey, prWlanCfgEntry->aucValue);
  5646. } else {
  5647. if (pucKey) {
  5648. DBGLOG(INIT, ERROR,
  5649. "Set wifi config error key \'%s\'\n", pucKey);
  5650. }
  5651. if (pucValue) {
  5652. DBGLOG(INIT, ERROR,
  5653. "Set wifi config error value \'%s\'\n", pucValue);
  5654. }
  5655. return WLAN_STATUS_FAILURE;
  5656. }
  5657. return WLAN_STATUS_SUCCESS;
  5658. }
  5659. WLAN_STATUS
  5660. wlanCfgSetCb(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, WLAN_CFG_SET_CB pfSetCb, void *pPrivate, UINT_32 u4Flags)
  5661. {
  5662. P_WLAN_CFG_ENTRY_T prWlanCfgEntry;
  5663. P_WLAN_CFG_T prWlanCfg;
  5664. prWlanCfg = prAdapter->prWlanCfg;
  5665. ASSERT(prWlanCfg);
  5666. /* Find the exist */
  5667. prWlanCfgEntry = wlanCfgGetEntry(prAdapter, pucKey);
  5668. if (prWlanCfgEntry) {
  5669. prWlanCfgEntry->pfSetCb = pfSetCb;
  5670. prWlanCfgEntry->pPrivate = pPrivate;
  5671. }
  5672. if (prWlanCfgEntry)
  5673. return WLAN_STATUS_SUCCESS;
  5674. else
  5675. return WLAN_STATUS_FAILURE;
  5676. }
  5677. WLAN_STATUS wlanCfgSetUint32(IN P_ADAPTER_T prAdapter, const PCHAR pucKey, UINT_32 u4Value)
  5678. {
  5679. P_WLAN_CFG_T prWlanCfg;
  5680. UINT_8 aucBuf[WLAN_CFG_VALUE_LEN_MAX];
  5681. prWlanCfg = prAdapter->prWlanCfg;
  5682. ASSERT(prWlanCfg);
  5683. kalMemZero(aucBuf, sizeof(aucBuf));
  5684. kalSnprintf(aucBuf, WLAN_CFG_VALUE_LEN_MAX, "0x%x", (unsigned int)u4Value);
  5685. return wlanCfgSet(prAdapter, pucKey, aucBuf, 0);
  5686. }
  5687. enum {
  5688. STATE_EOF = 0,
  5689. STATE_TEXT = 1,
  5690. STATE_NEWLINE = 2
  5691. };
  5692. struct WLAN_CFG_PARSE_STATE_S {
  5693. CHAR *ptr;
  5694. CHAR *text;
  5695. INT_32 nexttoken;
  5696. UINT_32 maxSize;
  5697. };
  5698. INT_32 wlanCfgFindNextToken(struct WLAN_CFG_PARSE_STATE_S *state)
  5699. {
  5700. CHAR *x = state->ptr;
  5701. CHAR *s;
  5702. if (state->nexttoken) {
  5703. INT_32 t = state->nexttoken;
  5704. state->nexttoken = 0;
  5705. return t;
  5706. }
  5707. for (;;) {
  5708. switch (*x) {
  5709. case 0:
  5710. state->ptr = x;
  5711. return STATE_EOF;
  5712. case '\n':
  5713. x++;
  5714. state->ptr = x;
  5715. return STATE_NEWLINE;
  5716. case ' ':
  5717. case '\t':
  5718. case '\r':
  5719. x++;
  5720. continue;
  5721. case '#':
  5722. while (*x && (*x != '\n'))
  5723. x++;
  5724. if (*x == '\n') {
  5725. state->ptr = x + 1;
  5726. } else {
  5727. state->ptr = x;
  5728. return STATE_EOF;
  5729. }
  5730. return STATE_NEWLINE;
  5731. default:
  5732. goto text;
  5733. }
  5734. }
  5735. textdone:
  5736. state->ptr = x;
  5737. *s = 0;
  5738. return STATE_TEXT;
  5739. text:
  5740. state->text = s = x;
  5741. textresume:
  5742. for (;;) {
  5743. switch (*x) {
  5744. case 0:
  5745. goto textdone;
  5746. case ' ':
  5747. case '\t':
  5748. case '\r':
  5749. x++;
  5750. goto textdone;
  5751. case '\n':
  5752. state->nexttoken = STATE_NEWLINE;
  5753. x++;
  5754. goto textdone;
  5755. case '"':
  5756. x++;
  5757. for (;;) {
  5758. switch (*x) {
  5759. case 0:
  5760. /* unterminated quoted thing */
  5761. state->ptr = x;
  5762. return STATE_EOF;
  5763. case '"':
  5764. x++;
  5765. goto textresume;
  5766. default:
  5767. *s++ = *x++;
  5768. }
  5769. }
  5770. break;
  5771. case '\\':
  5772. x++;
  5773. switch (*x) {
  5774. case 0:
  5775. goto textdone;
  5776. case 'n':
  5777. *s++ = '\n';
  5778. break;
  5779. case 'r':
  5780. *s++ = '\r';
  5781. break;
  5782. case 't':
  5783. *s++ = '\t';
  5784. break;
  5785. case '\\':
  5786. *s++ = '\\';
  5787. break;
  5788. case '\r':
  5789. /* \ <cr> <lf> -> line continuation */
  5790. if (x[1] != '\n') {
  5791. x++;
  5792. continue;
  5793. }
  5794. case '\n':
  5795. /* \ <lf> -> line continuation */
  5796. x++;
  5797. /* eat any extra whitespace */
  5798. while ((*x == ' ') || (*x == '\t'))
  5799. x++;
  5800. continue;
  5801. default:
  5802. /* unknown escape -- just copy */
  5803. *s++ = *x++;
  5804. }
  5805. continue;
  5806. default:
  5807. *s++ = *x++;
  5808. }
  5809. }
  5810. return STATE_EOF;
  5811. }
  5812. WLAN_STATUS wlanCfgParseArgument(CHAR *cmdLine, INT_32 *argc, CHAR *argv[])
  5813. {
  5814. struct WLAN_CFG_PARSE_STATE_S state;
  5815. CHAR **args;
  5816. INT_32 nargs;
  5817. if (cmdLine == NULL || argc == NULL || argv == NULL) {
  5818. ASSERT(0);
  5819. return WLAN_STATUS_FAILURE;
  5820. }
  5821. args = argv;
  5822. nargs = 0;
  5823. state.ptr = cmdLine;
  5824. state.nexttoken = 0;
  5825. state.maxSize = 0;
  5826. if (kalStrnLen(cmdLine, 512) >= 512) {
  5827. ASSERT(0);
  5828. return WLAN_STATUS_FAILURE;
  5829. }
  5830. for (;;) {
  5831. switch (wlanCfgFindNextToken(&state)) {
  5832. case STATE_EOF:
  5833. goto exit;
  5834. case STATE_NEWLINE:
  5835. goto exit;
  5836. case STATE_TEXT:
  5837. if (nargs < WLAN_CFG_ARGV_MAX)
  5838. args[nargs++] = state.text;
  5839. break;
  5840. }
  5841. }
  5842. exit:
  5843. *argc = nargs;
  5844. return WLAN_STATUS_SUCCESS;
  5845. }
  5846. WLAN_STATUS
  5847. wlanCfgParseAddEntry(IN P_ADAPTER_T prAdapter,
  5848. PUINT_8 pucKeyHead, PUINT_8 pucKeyTail, PUINT_8 pucValueHead, PUINT_8 pucValueTail)
  5849. {
  5850. UINT_8 aucKey[WLAN_CFG_KEY_LEN_MAX];
  5851. UINT_8 aucValue[WLAN_CFG_VALUE_LEN_MAX];
  5852. UINT_32 u4Len;
  5853. kalMemZero(aucKey, sizeof(aucKey));
  5854. kalMemZero(aucValue, sizeof(aucValue));
  5855. if ((pucKeyHead == NULL)
  5856. || (pucValueHead == NULL)
  5857. )
  5858. return WLAN_STATUS_FAILURE;
  5859. if (pucKeyTail) {
  5860. if (pucKeyHead > pucKeyTail)
  5861. return WLAN_STATUS_FAILURE;
  5862. u4Len = pucKeyTail - pucKeyHead + 1;
  5863. } else
  5864. u4Len = kalStrnLen(pucKeyHead, WLAN_CFG_KEY_LEN_MAX - 1);
  5865. if (u4Len >= WLAN_CFG_KEY_LEN_MAX)
  5866. u4Len = WLAN_CFG_KEY_LEN_MAX - 1;
  5867. kalStrnCpy(aucKey, pucKeyHead, u4Len);
  5868. if (pucValueTail) {
  5869. if (pucValueHead > pucValueTail)
  5870. return WLAN_STATUS_FAILURE;
  5871. u4Len = pucValueTail - pucValueHead + 1;
  5872. } else
  5873. u4Len = kalStrnLen(pucValueHead, WLAN_CFG_VALUE_LEN_MAX - 1);
  5874. if (u4Len >= WLAN_CFG_VALUE_LEN_MAX)
  5875. u4Len = WLAN_CFG_VALUE_LEN_MAX - 1;
  5876. kalStrnCpy(aucValue, pucValueHead, u4Len);
  5877. return wlanCfgSet(prAdapter, aucKey, aucValue, 0);
  5878. }
  5879. enum {
  5880. WAIT_KEY_HEAD = 0,
  5881. WAIT_KEY_TAIL,
  5882. WAIT_VALUE_HEAD,
  5883. WAIT_VALUE_TAIL,
  5884. WAIT_COMMENT_TAIL
  5885. };
  5886. WLAN_STATUS wlanCfgParse(IN P_ADAPTER_T prAdapter, PUINT_8 pucConfigBuf, UINT_32 u4ConfigBufLen)
  5887. {
  5888. struct WLAN_CFG_PARSE_STATE_S state;
  5889. PCHAR apcArgv[WLAN_CFG_ARGV_MAX];
  5890. CHAR **args;
  5891. INT_32 nargs;
  5892. if (pucConfigBuf == NULL) {
  5893. ASSERT(0);
  5894. return WLAN_STATUS_FAILURE;
  5895. }
  5896. if (kalStrnLen(pucConfigBuf, 4000) >= 4000) {
  5897. ASSERT(0);
  5898. return WLAN_STATUS_FAILURE;
  5899. }
  5900. if (u4ConfigBufLen == 0)
  5901. return WLAN_STATUS_FAILURE;
  5902. args = apcArgv;
  5903. nargs = 0;
  5904. state.ptr = pucConfigBuf;
  5905. state.nexttoken = 0;
  5906. state.maxSize = u4ConfigBufLen;
  5907. for (;;) {
  5908. switch (wlanCfgFindNextToken(&state)) {
  5909. case STATE_EOF:
  5910. if (nargs > 1)
  5911. wlanCfgParseAddEntry(prAdapter, args[0], NULL, args[1], NULL);
  5912. goto exit;
  5913. case STATE_NEWLINE:
  5914. if (nargs > 1)
  5915. wlanCfgParseAddEntry(prAdapter, args[0], NULL, args[1], NULL);
  5916. nargs = 0;
  5917. break;
  5918. case STATE_TEXT:
  5919. if (nargs < WLAN_CFG_ARGV_MAX)
  5920. args[nargs++] = state.text;
  5921. break;
  5922. }
  5923. }
  5924. exit:
  5925. return WLAN_STATUS_SUCCESS;
  5926. #if 0
  5927. /* Old version */
  5928. UINT_32 i;
  5929. UINT_8 c;
  5930. PUINT_8 pbuf;
  5931. UINT_8 ucState;
  5932. PUINT_8 pucKeyTail = NULL;
  5933. PUINT_8 pucKeyHead = NULL;
  5934. PUINT_8 pucValueHead = NULL;
  5935. PUINT_8 pucValueTail = NULL;
  5936. ucState = WAIT_KEY_HEAD;
  5937. pbuf = pucConfigBuf;
  5938. for (i = 0; i < u4ConfigBufLen; i++) {
  5939. c = pbuf[i];
  5940. if (c == '\r' || c == '\n') {
  5941. if (ucState == WAIT_VALUE_TAIL) {
  5942. /* Entry found */
  5943. if (pucValueHead)
  5944. wlanCfgParseAddEntry(prAdapter, pucKeyHead, pucKeyTail,
  5945. pucValueHead, pucValueTail);
  5946. }
  5947. ucState = WAIT_KEY_HEAD;
  5948. pucKeyTail = NULL;
  5949. pucKeyHead = NULL;
  5950. pucValueHead = NULL;
  5951. pucValueTail = NULL;
  5952. } else if (c == '=') {
  5953. if (ucState == WAIT_KEY_TAIL) {
  5954. pucKeyTail = &pbuf[i - 1];
  5955. ucState = WAIT_VALUE_HEAD;
  5956. }
  5957. } else if (c == ' ' || c == '\t') {
  5958. if (ucState == WAIT_KEY_TAIL) {
  5959. pucKeyTail = &pbuf[i - 1];
  5960. ucState = WAIT_VALUE_HEAD;
  5961. }
  5962. } else {
  5963. if (c == '#') {
  5964. /* comments */
  5965. if (ucState == WAIT_KEY_HEAD)
  5966. ucState = WAIT_COMMENT_TAIL;
  5967. else if (ucState == WAIT_VALUE_TAIL)
  5968. pucValueTail = &pbuf[i];
  5969. } else {
  5970. if (ucState == WAIT_KEY_HEAD) {
  5971. pucKeyHead = &pbuf[i];
  5972. pucKeyTail = &pbuf[i];
  5973. ucState = WAIT_KEY_TAIL;
  5974. } else if (ucState == WAIT_VALUE_HEAD) {
  5975. pucValueHead = &pbuf[i];
  5976. pucValueTail = &pbuf[i];
  5977. ucState = WAIT_VALUE_TAIL;
  5978. } else if (ucState == WAIT_VALUE_TAIL)
  5979. pucValueTail = &pbuf[i];
  5980. }
  5981. }
  5982. } /* for */
  5983. if (ucState == WAIT_VALUE_TAIL) {
  5984. /* Entry found */
  5985. if (pucValueTail)
  5986. wlanCfgParseAddEntry(prAdapter, pucKeyHead, pucKeyTail, pucValueHead, pucValueTail);
  5987. }
  5988. #endif
  5989. return WLAN_STATUS_SUCCESS;
  5990. }
  5991. WLAN_STATUS wlanCfgInit(IN P_ADAPTER_T prAdapter, PUINT_8 pucConfigBuf, UINT_32 u4ConfigBufLen, UINT_32 u4Flags)
  5992. {
  5993. P_WLAN_CFG_T prWlanCfg;
  5994. /* P_WLAN_CFG_ENTRY_T prWlanCfgEntry; */
  5995. prAdapter->prWlanCfg = &prAdapter->rWlanCfg;
  5996. prWlanCfg = prAdapter->prWlanCfg;
  5997. kalMemZero(prWlanCfg, sizeof(WLAN_CFG_T));
  5998. ASSERT(prWlanCfg);
  5999. prWlanCfg->u4WlanCfgEntryNumMax = WLAN_CFG_ENTRY_NUM_MAX;
  6000. prWlanCfg->u4WlanCfgKeyLenMax = WLAN_CFG_KEY_LEN_MAX;
  6001. prWlanCfg->u4WlanCfgValueLenMax = WLAN_CFG_VALUE_LEN_MAX;
  6002. DBGLOG(INIT, LOUD, "Init wifi config len %u max entry %u\n", u4ConfigBufLen, prWlanCfg->u4WlanCfgEntryNumMax);
  6003. #if DBG
  6004. /* self test */
  6005. wlanCfgSet(prAdapter, "ConfigValid", "0x123", 0);
  6006. if (wlanCfgGetUint32(prAdapter, "ConfigValid", 0) != 0x123) {
  6007. DBGLOG(INIT, ERROR,
  6008. "wifi config error %u\n", __LINE__);
  6009. }
  6010. wlanCfgSet(prAdapter, "ConfigValid", "1", 0);
  6011. if (wlanCfgGetUint32(prAdapter, "ConfigValid", 0) != 1) {
  6012. DBGLOG(INIT, ERROR,
  6013. "wifi config error %u\n", __LINE__);
  6014. }
  6015. #endif
  6016. /* Parse the pucConfigBuff */
  6017. if (pucConfigBuf && (u4ConfigBufLen > 0))
  6018. wlanCfgParse(prAdapter, pucConfigBuf, u4ConfigBufLen);
  6019. return WLAN_STATUS_SUCCESS;
  6020. }
  6021. #endif /* CFG_SUPPORT_CFG_FILE */
  6022. INT_32 wlanHexToNum(CHAR c)
  6023. {
  6024. if (c >= '0' && c <= '9')
  6025. return c - '0';
  6026. if (c >= 'a' && c <= 'f')
  6027. return c - 'a' + 10;
  6028. if (c >= 'A' && c <= 'F')
  6029. return c - 'A' + 10;
  6030. return -1;
  6031. }
  6032. INT_32 wlanHexToByte(PCHAR hex)
  6033. {
  6034. INT_32 a, b;
  6035. a = wlanHexToNum(*hex++);
  6036. if (a < 0)
  6037. return -1;
  6038. b = wlanHexToNum(*hex++);
  6039. if (b < 0)
  6040. return -1;
  6041. return (a << 4) | b;
  6042. }
  6043. INT_32 wlanHwAddrToBin(PCHAR txt, UINT_8 *addr)
  6044. {
  6045. INT_32 i;
  6046. PCHAR pos = txt;
  6047. for (i = 0; i < 6; i++) {
  6048. INT_32 a, b;
  6049. while (*pos == ':' || *pos == '.' || *pos == '-')
  6050. pos++;
  6051. a = wlanHexToNum(*pos++);
  6052. if (a < 0)
  6053. return -1;
  6054. b = wlanHexToNum(*pos++);
  6055. if (b < 0)
  6056. return -1;
  6057. *addr++ = (a << 4) | b;
  6058. }
  6059. return pos - txt;
  6060. }
  6061. BOOLEAN wlanIsChipNoAck(IN P_ADAPTER_T prAdapter)
  6062. {
  6063. BOOLEAN fgIsNoAck;
  6064. fgIsNoAck = prAdapter->fgIsChipNoAck || kalIsResetting()
  6065. || fgIsBusAccessFailed;
  6066. return fgIsNoAck;
  6067. }
  6068. #if CFG_AUTO_CHANNEL_SEL_SUPPORT
  6069. /* 4 Auto Channel Selection */
  6070. WLAN_STATUS
  6071. wlanoidQueryACSChannelList(IN P_ADAPTER_T prAdapter,
  6072. IN PVOID pvQueryBuffer, IN UINT_32 u4QueryBufferLen, OUT PUINT_32 pu4QueryInfoLen)
  6073. {
  6074. WLAN_STATUS rResult = WLAN_STATUS_FAILURE;
  6075. P_PARAM_GET_LTE_MODE prLteMode;
  6076. UINT_8 ucIdx;
  6077. P_PARAM_CHN_LOAD_INFO prChnLoad;
  6078. DBGLOG(P2P, INFO, "[Auto Channel]wlanoidQueryACSChannelList\n");
  6079. do {
  6080. ASSERT(pvQueryBuffer);
  6081. /* 1. Sanity test */
  6082. if ((prAdapter == NULL) || (pu4QueryInfoLen == NULL))
  6083. break;
  6084. if ((u4QueryBufferLen) && (pvQueryBuffer == NULL))
  6085. break;
  6086. prLteMode = (P_PARAM_GET_LTE_MODE) pvQueryBuffer;
  6087. /* 2. Check AP Numbers */
  6088. for (ucIdx = 0; ucIdx < MAX_AUTO_CHAL_NUM; ucIdx++) {
  6089. prChnLoad = (P_PARAM_CHN_LOAD_INFO) &(prAdapter->rWifiVar.rChnLoadInfo.rEachChnLoad[ucIdx]);
  6090. DBGLOG(P2P, INFO, "[Auto Channel] AP Num: Chn[%d]=%d\n", ucIdx + 1, prChnLoad->u2APNum);
  6091. }
  6092. /* 3. Ensure FW supports get station link status */
  6093. #if 0
  6094. if (prAdapter->u4FwCompileFlag0 & COMPILE_FLAG0_GET_STA_LINK_STATUS) {
  6095. DBGLOG(P2P, INFO, "wlanoidQueryACSChannelList\n");
  6096. CMD_ACCESS_REG rCmdAccessReg;
  6097. rCmdAccessReg.u4Address = 0xFFFFFFFF;
  6098. rCmdAccessReg.u4Data = ELEM_RM_TYPE_ACS_CHN;
  6099. rResult = wlanSendSetQueryCmd(prAdapter, CMD_ID_ACCESS_REG,
  6100. TRUE, TRUE, TRUE,
  6101. /* The handler to receive firmware notification */
  6102. nicCmdEventQueryChannelLoad,
  6103. nicOidCmdTimeoutCommon,
  6104. sizeof(CMD_ACCESS_REG),
  6105. (PUINT_8) &rCmdAccessReg,
  6106. pvQueryBuffer,
  6107. u4QueryBufferLen);
  6108. prQueryChnLoad->u4Flag |= BIT(1);
  6109. } else
  6110. rResult = WLAN_STATUS_NOT_SUPPORTED;
  6111. #endif
  6112. /* 4. Avoid LTE Channels */
  6113. prLteMode->u4Flags &= BIT(0);
  6114. /*if(prAdapter->u4FwCompileFlag0 & COMPILE_FLAG0_GET_STA_LINK_STATUS) */
  6115. {
  6116. CMD_GET_LTE_SAFE_CHN_T rQuery_LTE_SAFE_CHN;
  6117. rResult = wlanSendSetQueryCmd(prAdapter, CMD_ID_GET_LTE_CHN,
  6118. FALSE, TRUE, TRUE, /* Query ID */
  6119. /* The handler to receive firmware notification */
  6120. nicCmdEventQueryLTESafeChn,
  6121. nicOidCmdTimeoutCommon,
  6122. sizeof(CMD_GET_LTE_SAFE_CHN_T),
  6123. (PUINT_8) &rQuery_LTE_SAFE_CHN,
  6124. pvQueryBuffer,
  6125. u4QueryBufferLen);
  6126. DBGLOG(P2P, INFO, "[Auto Channel] Get LTE Channels\n");
  6127. prLteMode->u4Flags |= BIT(1);
  6128. }
  6129. /*
  6130. else {
  6131. rResult = WLAN_STATUS_NOT_SUPPORTED;
  6132. }
  6133. */
  6134. /* 5. Calc the value */
  6135. DBGLOG(P2P, INFO, "[Auto Channel] Candidated Channels\n");
  6136. } while (FALSE);
  6137. return rResult;
  6138. } /* wlanoidQueryP2pVersion */
  6139. #endif
  6140. #if CFG_ENABLE_PER_STA_STATISTICS
  6141. VOID wlanTxLifetimeUpdateStaStats(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  6142. {
  6143. P_STA_RECORD_T prStaRec;
  6144. UINT_32 u4DeltaTime;
  6145. P_QUE_MGT_T prQM = &prAdapter->rQM;
  6146. P_PKT_PROFILE_T prPktProfile = &prMsduInfo->rPktProfile;
  6147. UINT_32 u4PktPrintPeriod = 0;
  6148. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  6149. if (prStaRec) {
  6150. u4DeltaTime = (UINT_32) (prPktProfile->rHifTxDoneTimestamp - prPktProfile->rHardXmitArrivalTimestamp);
  6151. /* Update StaRec statistics */
  6152. prStaRec->u4TotalTxPktsNumber++;
  6153. prStaRec->u4TotalTxPktsTime += u4DeltaTime;
  6154. if (u4DeltaTime > prStaRec->u4MaxTxPktsTime)
  6155. prStaRec->u4MaxTxPktsTime = u4DeltaTime;
  6156. if (u4DeltaTime >= NIC_TX_TIME_THRESHOLD)
  6157. prStaRec->u4ThresholdCounter++;
  6158. if (u4PktPrintPeriod && (prStaRec->u4TotalTxPktsNumber >= u4PktPrintPeriod)) {
  6159. DBGLOG(TX, TRACE, "[%u]N[%4lu]A[%5lu]M[%4lu]T[%4lu]E[%4lu]\n",
  6160. prStaRec->ucIndex,
  6161. prStaRec->u4TotalTxPktsNumber,
  6162. (prStaRec->u4TotalTxPktsTime / prStaRec->u4TotalTxPktsNumber),
  6163. prStaRec->u4MaxTxPktsTime,
  6164. prStaRec->u4ThresholdCounter,
  6165. prQM->au4QmTcResourceEmptyCounter[prStaRec->ucBssIndex][TC2_INDEX]);
  6166. prStaRec->u4TotalTxPktsNumber = 0;
  6167. prStaRec->u4TotalTxPktsTime = 0;
  6168. prStaRec->u4MaxTxPktsTime = 0;
  6169. prStaRec->u4ThresholdCounter = 0;
  6170. prQM->au4QmTcResourceEmptyCounter[prStaRec->ucBssIndex][TC2_INDEX] = 0;
  6171. }
  6172. }
  6173. }
  6174. #endif
  6175. BOOLEAN wlanTxLifetimeIsProfilingEnabled(IN P_ADAPTER_T prAdapter)
  6176. {
  6177. BOOLEAN fgEnabled = FALSE;
  6178. #if CFG_SUPPORT_WFD
  6179. P_WFD_CFG_SETTINGS_T prWfdCfgSettings = (P_WFD_CFG_SETTINGS_T) NULL;
  6180. prWfdCfgSettings = &prAdapter->rWifiVar.rWfdConfigureSettings;
  6181. if (prWfdCfgSettings->ucWfdEnable > 0)
  6182. fgEnabled = TRUE;
  6183. #endif
  6184. return fgEnabled;
  6185. }
  6186. BOOLEAN wlanTxLifetimeIsTargetMsdu(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo)
  6187. {
  6188. BOOLEAN fgResult = TRUE;
  6189. #if 0
  6190. switch (prMsduInfo->ucTID) {
  6191. /* BK */
  6192. case 1:
  6193. case 2:
  6194. /* BE */
  6195. case 0:
  6196. case 3:
  6197. fgResult = FALSE;
  6198. break;
  6199. /* VI */
  6200. case 4:
  6201. case 5:
  6202. /* VO */
  6203. case 6:
  6204. case 7:
  6205. fgResult = TRUE;
  6206. break;
  6207. default:
  6208. break;
  6209. }
  6210. #endif
  6211. return fgResult;
  6212. }
  6213. VOID wlanTxLifetimeTagPacket(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_PROFILING_TAG_T eTag)
  6214. {
  6215. P_PKT_PROFILE_T prPktProfile = &prMsduInfo->rPktProfile;
  6216. if (!wlanTxLifetimeIsProfilingEnabled(prAdapter))
  6217. return;
  6218. switch (eTag) {
  6219. case TX_PROF_TAG_OS_TO_DRV:
  6220. /* arrival time is tagged in wlanProcessTxFrame */
  6221. break;
  6222. case TX_PROF_TAG_DRV_ENQUE:
  6223. /* Reset packet profile */
  6224. prPktProfile->fgIsValid = FALSE;
  6225. if (wlanTxLifetimeIsTargetMsdu(prAdapter, prMsduInfo)) {
  6226. /* Enable packet lifetime profiling */
  6227. prPktProfile->fgIsValid = TRUE;
  6228. /* Packet arrival time at kernel Hard Xmit */
  6229. prPktProfile->rHardXmitArrivalTimestamp = GLUE_GET_PKT_ARRIVAL_TIME(prMsduInfo->prPacket);
  6230. /* Packet enqueue time */
  6231. prPktProfile->rEnqueueTimestamp = (OS_SYSTIME) kalGetTimeTick();
  6232. }
  6233. break;
  6234. case TX_PROF_TAG_DRV_DEQUE:
  6235. if (prPktProfile->fgIsValid)
  6236. prPktProfile->rDequeueTimestamp = (OS_SYSTIME) kalGetTimeTick();
  6237. break;
  6238. case TX_PROF_TAG_DRV_TX_DONE:
  6239. if (prPktProfile->fgIsValid) {
  6240. BOOLEAN fgPrintCurPkt = FALSE;
  6241. prPktProfile->rHifTxDoneTimestamp = (OS_SYSTIME) kalGetTimeTick();
  6242. if (fgPrintCurPkt)
  6243. PRINT_PKT_PROFILE(prPktProfile, "C");
  6244. #if CFG_ENABLE_PER_STA_STATISTICS
  6245. wlanTxLifetimeUpdateStaStats(prAdapter, prMsduInfo);
  6246. #endif
  6247. }
  6248. break;
  6249. case TX_PROF_TAG_MAC_TX_DONE:
  6250. break;
  6251. default:
  6252. break;
  6253. }
  6254. }
  6255. VOID wlanTxProfilingTagPacket(IN P_ADAPTER_T prAdapter, IN P_NATIVE_PACKET prPacket, IN ENUM_TX_PROFILING_TAG_T eTag)
  6256. {
  6257. #if CFG_MET_PACKET_TRACE_SUPPORT
  6258. kalMetTagPacket(prAdapter->prGlueInfo, prPacket, eTag);
  6259. #endif
  6260. }
  6261. VOID wlanTxProfilingTagMsdu(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_PROFILING_TAG_T eTag)
  6262. {
  6263. wlanTxLifetimeTagPacket(prAdapter, prMsduInfo, eTag);
  6264. wlanTxProfilingTagPacket(prAdapter, prMsduInfo->prPacket, eTag);
  6265. }
  6266. VOID wlanUpdateTxStatistics(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN BOOLEAN fgTxDrop)
  6267. {
  6268. P_STA_RECORD_T prStaRec;
  6269. P_BSS_INFO_T prBssInfo;
  6270. ENUM_WMM_ACI_T eAci = WMM_AC_BE_INDEX;
  6271. P_QUE_MGT_T prQM = &prAdapter->rQM;
  6272. OS_SYSTIME rCurTime;
  6273. eAci = aucTid2ACI[prMsduInfo->ucUserPriority];
  6274. prStaRec = cnmGetStaRecByIndex(prAdapter, prMsduInfo->ucStaRecIndex);
  6275. if (prStaRec) {
  6276. if (fgTxDrop)
  6277. prStaRec->arLinkStatistics[eAci].u4TxDropMsdu++;
  6278. else
  6279. prStaRec->arLinkStatistics[eAci].u4TxMsdu++;
  6280. } else {
  6281. prBssInfo = GET_BSS_INFO_BY_INDEX(prAdapter, prMsduInfo->ucBssIndex);
  6282. if (fgTxDrop)
  6283. prBssInfo->arLinkStatistics[eAci].u4TxDropMsdu++;
  6284. else
  6285. prBssInfo->arLinkStatistics[eAci].u4TxMsdu++;
  6286. }
  6287. /* Trigger FW stats log every 20s */
  6288. rCurTime = (OS_SYSTIME) kalGetTimeTick();
  6289. DBGLOG(INIT, TRACE, "CUR[%u] LAST[%u] TO[%u]\n", rCurTime,
  6290. prQM->rLastTxPktDumpTime, CHECK_FOR_TIMEOUT(rCurTime,
  6291. prQM->rLastTxPktDumpTime,
  6292. MSEC_TO_SYSTIME(prAdapter->
  6293. rWifiVar.u4StatsLogTimeout)));
  6294. if (CHECK_FOR_TIMEOUT(rCurTime, prQM->rLastTxPktDumpTime,
  6295. MSEC_TO_SYSTIME(prAdapter->rWifiVar.u4StatsLogTimeout))) {
  6296. wlanTriggerStatsLog(prAdapter, prAdapter->rWifiVar.u4StatsLogDuration);
  6297. wlanDumpAllBssStatistics(prAdapter);
  6298. prQM->rLastTxPktDumpTime = rCurTime;
  6299. }
  6300. }
  6301. VOID wlanUpdateRxStatistics(IN P_ADAPTER_T prAdapter, IN P_SW_RFB_T prSwRfb)
  6302. {
  6303. P_STA_RECORD_T prStaRec;
  6304. ENUM_WMM_ACI_T eAci = WMM_AC_BE_INDEX;
  6305. eAci = aucTid2ACI[prSwRfb->ucTid];
  6306. prStaRec = cnmGetStaRecByIndex(prAdapter, prSwRfb->ucStaRecIdx);
  6307. if (prStaRec)
  6308. prStaRec->arLinkStatistics[eAci].u4RxMsdu++;
  6309. }
  6310. WLAN_STATUS wlanTriggerStatsLog(IN P_ADAPTER_T prAdapter, IN UINT_32 u4DurationInMs)
  6311. {
  6312. CMD_STATS_LOG_T rStatsLogCmd;
  6313. WLAN_STATUS rResult;
  6314. kalMemZero(&rStatsLogCmd, sizeof(CMD_STATS_LOG_T));
  6315. rStatsLogCmd.u4DurationInMs = u4DurationInMs;
  6316. rResult = wlanSendSetQueryCmd(prAdapter, CMD_ID_STATS_LOG, TRUE, FALSE,
  6317. FALSE, nicCmdEventSetCommon, nicOidCmdTimeoutCommon,
  6318. sizeof(CMD_STATS_LOG_T), (PUINT_8) &rStatsLogCmd, NULL, 0);
  6319. return rResult;
  6320. }
  6321. WLAN_STATUS
  6322. wlanDhcpTxDone(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  6323. {
  6324. DBGLOG(SW4, INFO, "DHCP PKT TX DONE WIDX:PID[%u:%u] Status[%u]\n",
  6325. prMsduInfo->ucWlanIndex, prMsduInfo->ucPID, rTxDoneStatus);
  6326. return WLAN_STATUS_SUCCESS;
  6327. }
  6328. WLAN_STATUS wlanArpTxDone(IN P_ADAPTER_T prAdapter, IN P_MSDU_INFO_T prMsduInfo, IN ENUM_TX_RESULT_CODE_T rTxDoneStatus)
  6329. {
  6330. DBGLOG(SW4, INFO, "ARP PKT TX DONE WIDX:PID[%u:%u] Status[%u]\n",
  6331. prMsduInfo->ucWlanIndex, prMsduInfo->ucPID, rTxDoneStatus);
  6332. return WLAN_STATUS_SUCCESS;
  6333. }