dp_htt.c 166 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748
  1. /*
  2. * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <htt.h>
  19. #include <hal_hw_headers.h>
  20. #include <hal_api.h>
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "dp_internal.h"
  24. #include "dp_rx.h"
  25. #include "dp_rx_mon.h"
  26. #include "htt_stats.h"
  27. #include "htt_ppdu_stats.h"
  28. #include "dp_htt.h"
  29. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  30. #include "cdp_txrx_cmn_struct.h"
  31. #ifdef FEATURE_PERPKT_INFO
  32. #include "dp_ratetable.h"
  33. #endif
  34. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  35. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  36. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  37. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  38. #define HTT_PID_BIT_MASK 0x3
  39. #define DP_EXT_MSG_LENGTH 2048
  40. #define HTT_HEADER_LEN 16
  41. #define HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN 16
  42. #define HTT_SHIFT_UPPER_TIMESTAMP 32
  43. #define HTT_MASK_UPPER_TIMESTAMP 0xFFFFFFFF00000000
  44. /*
  45. * dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap() - Get ppdu stats tlv
  46. * bitmap for sniffer mode
  47. * @bitmap: received bitmap
  48. *
  49. * Return: expected bitmap value, returns zero if doesn't match with
  50. * either 64-bit Tx window or 256-bit window tlv bitmap
  51. */
  52. int
  53. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(uint32_t bitmap)
  54. {
  55. if (bitmap == (HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64))
  56. return HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_64;
  57. else if (bitmap == (HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256))
  58. return HTT_PPDU_SNIFFER_AMPDU_TLV_BITMAP_256;
  59. return 0;
  60. }
  61. #ifdef FEATURE_PERPKT_INFO
  62. /*
  63. * dp_peer_find_by_id_valid - check if peer exists for given id
  64. * @soc: core DP soc context
  65. * @peer_id: peer id from peer object can be retrieved
  66. *
  67. * Return: true if peer exists of false otherwise
  68. */
  69. static
  70. bool dp_peer_find_by_id_valid(struct dp_soc *soc, uint16_t peer_id)
  71. {
  72. struct dp_peer *peer = dp_peer_get_ref_by_id(soc, peer_id,
  73. DP_MOD_ID_HTT);
  74. if (peer) {
  75. /*
  76. * Decrement the peer ref which is taken as part of
  77. * dp_peer_get_ref_by_id if PEER_LOCK_REF_PROTECT is enabled
  78. */
  79. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  80. return true;
  81. }
  82. return false;
  83. }
  84. /*
  85. * dp_peer_copy_delay_stats() - copy ppdu stats to peer delayed stats.
  86. * @peer: Datapath peer handle
  87. * @ppdu: User PPDU Descriptor
  88. * @cur_ppdu_id: PPDU_ID
  89. *
  90. * Return: None
  91. *
  92. * on Tx data frame, we may get delayed ba set
  93. * in htt_ppdu_stats_user_common_tlv. which mean we get Block Ack(BA) after we
  94. * request Block Ack Request(BAR). Successful msdu is received only after Block
  95. * Ack. To populate peer stats we need successful msdu(data frame).
  96. * So we hold the Tx data stats on delayed_ba for stats update.
  97. */
  98. static void
  99. dp_peer_copy_delay_stats(struct dp_peer *peer,
  100. struct cdp_tx_completion_ppdu_user *ppdu,
  101. uint32_t cur_ppdu_id)
  102. {
  103. struct dp_pdev *pdev;
  104. struct dp_vdev *vdev;
  105. if (peer->last_delayed_ba) {
  106. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  107. "BA not yet recv for prev delayed ppdu[%d] - cur ppdu[%d]",
  108. peer->last_delayed_ba_ppduid, cur_ppdu_id);
  109. vdev = peer->vdev;
  110. if (vdev) {
  111. pdev = vdev->pdev;
  112. pdev->stats.cdp_delayed_ba_not_recev++;
  113. }
  114. }
  115. peer->delayed_ba_ppdu_stats.ltf_size = ppdu->ltf_size;
  116. peer->delayed_ba_ppdu_stats.stbc = ppdu->stbc;
  117. peer->delayed_ba_ppdu_stats.he_re = ppdu->he_re;
  118. peer->delayed_ba_ppdu_stats.txbf = ppdu->txbf;
  119. peer->delayed_ba_ppdu_stats.bw = ppdu->bw;
  120. peer->delayed_ba_ppdu_stats.nss = ppdu->nss;
  121. peer->delayed_ba_ppdu_stats.preamble = ppdu->preamble;
  122. peer->delayed_ba_ppdu_stats.gi = ppdu->gi;
  123. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  124. peer->delayed_ba_ppdu_stats.ldpc = ppdu->ldpc;
  125. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  126. peer->delayed_ba_ppdu_stats.mpdu_tried_ucast = ppdu->mpdu_tried_ucast;
  127. peer->delayed_ba_ppdu_stats.mpdu_tried_mcast = ppdu->mpdu_tried_mcast;
  128. peer->delayed_ba_ppdu_stats.frame_ctrl = ppdu->frame_ctrl;
  129. peer->delayed_ba_ppdu_stats.qos_ctrl = ppdu->qos_ctrl;
  130. peer->delayed_ba_ppdu_stats.dcm = ppdu->dcm;
  131. peer->delayed_ba_ppdu_stats.ru_start = ppdu->ru_start;
  132. peer->delayed_ba_ppdu_stats.ru_tones = ppdu->ru_tones;
  133. peer->delayed_ba_ppdu_stats.is_mcast = ppdu->is_mcast;
  134. peer->delayed_ba_ppdu_stats.user_pos = ppdu->user_pos;
  135. peer->delayed_ba_ppdu_stats.mu_group_id = ppdu->mu_group_id;
  136. peer->last_delayed_ba = true;
  137. ppdu->debug_copied = true;
  138. }
  139. /*
  140. * dp_peer_copy_stats_to_bar() - copy delayed stats to ppdu stats.
  141. * @peer: Datapath peer handle
  142. * @ppdu: PPDU Descriptor
  143. *
  144. * Return: None
  145. *
  146. * For Tx BAR, PPDU stats TLV include Block Ack info. PPDU info
  147. * from Tx BAR frame not required to populate peer stats.
  148. * But we need successful MPDU and MSDU to update previous
  149. * transmitted Tx data frame. Overwrite ppdu stats with the previous
  150. * stored ppdu stats.
  151. */
  152. static void
  153. dp_peer_copy_stats_to_bar(struct dp_peer *peer,
  154. struct cdp_tx_completion_ppdu_user *ppdu)
  155. {
  156. ppdu->ltf_size = peer->delayed_ba_ppdu_stats.ltf_size;
  157. ppdu->stbc = peer->delayed_ba_ppdu_stats.stbc;
  158. ppdu->he_re = peer->delayed_ba_ppdu_stats.he_re;
  159. ppdu->txbf = peer->delayed_ba_ppdu_stats.txbf;
  160. ppdu->bw = peer->delayed_ba_ppdu_stats.bw;
  161. ppdu->nss = peer->delayed_ba_ppdu_stats.nss;
  162. ppdu->preamble = peer->delayed_ba_ppdu_stats.preamble;
  163. ppdu->gi = peer->delayed_ba_ppdu_stats.gi;
  164. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  165. ppdu->ldpc = peer->delayed_ba_ppdu_stats.ldpc;
  166. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  167. ppdu->mpdu_tried_ucast = peer->delayed_ba_ppdu_stats.mpdu_tried_ucast;
  168. ppdu->mpdu_tried_mcast = peer->delayed_ba_ppdu_stats.mpdu_tried_mcast;
  169. ppdu->frame_ctrl = peer->delayed_ba_ppdu_stats.frame_ctrl;
  170. ppdu->qos_ctrl = peer->delayed_ba_ppdu_stats.qos_ctrl;
  171. ppdu->dcm = peer->delayed_ba_ppdu_stats.dcm;
  172. ppdu->ru_start = peer->delayed_ba_ppdu_stats.ru_start;
  173. ppdu->ru_tones = peer->delayed_ba_ppdu_stats.ru_tones;
  174. ppdu->is_mcast = peer->delayed_ba_ppdu_stats.is_mcast;
  175. ppdu->user_pos = peer->delayed_ba_ppdu_stats.user_pos;
  176. ppdu->mu_group_id = peer->delayed_ba_ppdu_stats.mu_group_id;
  177. peer->last_delayed_ba = false;
  178. ppdu->debug_copied = true;
  179. }
  180. /*
  181. * dp_tx_rate_stats_update() - Update rate per-peer statistics
  182. * @peer: Datapath peer handle
  183. * @ppdu: PPDU Descriptor
  184. *
  185. * Return: None
  186. */
  187. static void
  188. dp_tx_rate_stats_update(struct dp_peer *peer,
  189. struct cdp_tx_completion_ppdu_user *ppdu)
  190. {
  191. uint32_t ratekbps = 0;
  192. uint64_t ppdu_tx_rate = 0;
  193. uint32_t rix;
  194. uint16_t ratecode = 0;
  195. if (!peer || !ppdu)
  196. return;
  197. if (ppdu->completion_status != HTT_PPDU_STATS_USER_STATUS_OK)
  198. return;
  199. ratekbps = dp_getrateindex(ppdu->gi,
  200. ppdu->mcs,
  201. ppdu->nss,
  202. ppdu->preamble,
  203. ppdu->bw,
  204. &rix,
  205. &ratecode);
  206. DP_STATS_UPD(peer, tx.last_tx_rate, ratekbps);
  207. if (!ratekbps)
  208. return;
  209. /* Calculate goodput in non-training period
  210. * In training period, don't do anything as
  211. * pending pkt is send as goodput.
  212. */
  213. if ((!peer->bss_peer) && (!ppdu->sa_is_training)) {
  214. ppdu->sa_goodput = ((ratekbps / CDP_NUM_KB_IN_MB) *
  215. (CDP_PERCENT_MACRO - ppdu->current_rate_per));
  216. }
  217. ppdu->rix = rix;
  218. ppdu->tx_ratekbps = ratekbps;
  219. ppdu->tx_ratecode = ratecode;
  220. peer->stats.tx.avg_tx_rate =
  221. dp_ath_rate_lpf(peer->stats.tx.avg_tx_rate, ratekbps);
  222. ppdu_tx_rate = dp_ath_rate_out(peer->stats.tx.avg_tx_rate);
  223. DP_STATS_UPD(peer, tx.rnd_avg_tx_rate, ppdu_tx_rate);
  224. if (peer->vdev) {
  225. /*
  226. * In STA mode:
  227. * We get ucast stats as BSS peer stats.
  228. *
  229. * In AP mode:
  230. * We get mcast stats as BSS peer stats.
  231. * We get ucast stats as assoc peer stats.
  232. */
  233. if (peer->vdev->opmode == wlan_op_mode_ap && peer->bss_peer) {
  234. peer->vdev->stats.tx.mcast_last_tx_rate = ratekbps;
  235. peer->vdev->stats.tx.mcast_last_tx_rate_mcs = ppdu->mcs;
  236. } else {
  237. peer->vdev->stats.tx.last_tx_rate = ratekbps;
  238. peer->vdev->stats.tx.last_tx_rate_mcs = ppdu->mcs;
  239. }
  240. }
  241. }
  242. /*
  243. * dp_tx_stats_update() - Update per-peer statistics
  244. * @pdev: Datapath pdev handle
  245. * @peer: Datapath peer handle
  246. * @ppdu: PPDU Descriptor
  247. * @ack_rssi: RSSI of last ack received
  248. *
  249. * Return: None
  250. */
  251. static void
  252. dp_tx_stats_update(struct dp_pdev *pdev, struct dp_peer *peer,
  253. struct cdp_tx_completion_ppdu_user *ppdu,
  254. uint32_t ack_rssi)
  255. {
  256. uint8_t preamble, mcs;
  257. uint16_t num_msdu;
  258. uint16_t num_mpdu;
  259. uint16_t mpdu_tried;
  260. uint16_t mpdu_failed;
  261. preamble = ppdu->preamble;
  262. mcs = ppdu->mcs;
  263. num_msdu = ppdu->num_msdu;
  264. num_mpdu = ppdu->mpdu_success;
  265. mpdu_tried = ppdu->mpdu_tried_ucast + ppdu->mpdu_tried_mcast;
  266. mpdu_failed = mpdu_tried - num_mpdu;
  267. /* If the peer statistics are already processed as part of
  268. * per-MSDU completion handler, do not process these again in per-PPDU
  269. * indications */
  270. if (pdev->soc->process_tx_status)
  271. return;
  272. if (ppdu->completion_status != HTT_PPDU_STATS_USER_STATUS_OK) {
  273. /*
  274. * All failed mpdu will be retried, so incrementing
  275. * retries mpdu based on mpdu failed. Even for
  276. * ack failure i.e for long retries we get
  277. * mpdu failed equal mpdu tried.
  278. */
  279. DP_STATS_INC(peer, tx.retries, mpdu_failed);
  280. DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
  281. return;
  282. }
  283. if (ppdu->is_ppdu_cookie_valid)
  284. DP_STATS_INC(peer, tx.num_ppdu_cookie_valid, 1);
  285. if (ppdu->mu_group_id <= MAX_MU_GROUP_ID &&
  286. ppdu->ppdu_type != HTT_PPDU_STATS_PPDU_TYPE_SU) {
  287. if (unlikely(!(ppdu->mu_group_id & (MAX_MU_GROUP_ID - 1))))
  288. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  289. "mu_group_id out of bound!!\n");
  290. else
  291. DP_STATS_UPD(peer, tx.mu_group_id[ppdu->mu_group_id],
  292. (ppdu->user_pos + 1));
  293. }
  294. if (ppdu->ppdu_type == HTT_PPDU_STATS_PPDU_TYPE_MU_OFDMA ||
  295. ppdu->ppdu_type == HTT_PPDU_STATS_PPDU_TYPE_MU_MIMO_OFDMA) {
  296. DP_STATS_UPD(peer, tx.ru_tones, ppdu->ru_tones);
  297. DP_STATS_UPD(peer, tx.ru_start, ppdu->ru_start);
  298. switch (ppdu->ru_tones) {
  299. case RU_26:
  300. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].num_msdu,
  301. num_msdu);
  302. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].num_mpdu,
  303. num_mpdu);
  304. DP_STATS_INC(peer, tx.ru_loc[RU_26_INDEX].mpdu_tried,
  305. mpdu_tried);
  306. break;
  307. case RU_52:
  308. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].num_msdu,
  309. num_msdu);
  310. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].num_mpdu,
  311. num_mpdu);
  312. DP_STATS_INC(peer, tx.ru_loc[RU_52_INDEX].mpdu_tried,
  313. mpdu_tried);
  314. break;
  315. case RU_106:
  316. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].num_msdu,
  317. num_msdu);
  318. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].num_mpdu,
  319. num_mpdu);
  320. DP_STATS_INC(peer, tx.ru_loc[RU_106_INDEX].mpdu_tried,
  321. mpdu_tried);
  322. break;
  323. case RU_242:
  324. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].num_msdu,
  325. num_msdu);
  326. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].num_mpdu,
  327. num_mpdu);
  328. DP_STATS_INC(peer, tx.ru_loc[RU_242_INDEX].mpdu_tried,
  329. mpdu_tried);
  330. break;
  331. case RU_484:
  332. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].num_msdu,
  333. num_msdu);
  334. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].num_mpdu,
  335. num_mpdu);
  336. DP_STATS_INC(peer, tx.ru_loc[RU_484_INDEX].mpdu_tried,
  337. mpdu_tried);
  338. break;
  339. case RU_996:
  340. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].num_msdu,
  341. num_msdu);
  342. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].num_mpdu,
  343. num_mpdu);
  344. DP_STATS_INC(peer, tx.ru_loc[RU_996_INDEX].mpdu_tried,
  345. mpdu_tried);
  346. break;
  347. }
  348. }
  349. /*
  350. * All failed mpdu will be retried, so incrementing
  351. * retries mpdu based on mpdu failed. Even for
  352. * ack failure i.e for long retries we get
  353. * mpdu failed equal mpdu tried.
  354. */
  355. DP_STATS_INC(peer, tx.retries, mpdu_failed);
  356. DP_STATS_INC(peer, tx.tx_failed, ppdu->failed_msdus);
  357. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].num_msdu,
  358. num_msdu);
  359. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].num_mpdu,
  360. num_mpdu);
  361. DP_STATS_INC(peer, tx.transmit_type[ppdu->ppdu_type].mpdu_tried,
  362. mpdu_tried);
  363. DP_STATS_INC_PKT(peer, tx.comp_pkt,
  364. num_msdu, (ppdu->success_bytes +
  365. ppdu->retry_bytes + ppdu->failed_bytes));
  366. DP_STATS_UPD(peer, tx.tx_rate, ppdu->tx_rate);
  367. DP_STATS_INC(peer, tx.sgi_count[ppdu->gi], num_msdu);
  368. DP_STATS_INC(peer, tx.bw[ppdu->bw], num_msdu);
  369. DP_STATS_INC(peer, tx.nss[ppdu->nss], num_msdu);
  370. if (ppdu->tid < CDP_DATA_TID_MAX)
  371. DP_STATS_INC(peer, tx.wme_ac_type[TID_TO_WME_AC(ppdu->tid)],
  372. num_msdu);
  373. DP_STATS_INCC(peer, tx.stbc, num_msdu, ppdu->stbc);
  374. DP_STATS_INCC(peer, tx.ldpc, num_msdu, ppdu->ldpc);
  375. if (!(ppdu->is_mcast) && ppdu->ack_rssi_valid)
  376. DP_STATS_UPD(peer, tx.last_ack_rssi, ack_rssi);
  377. DP_STATS_INCC(peer,
  378. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  379. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
  380. DP_STATS_INCC(peer,
  381. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  382. ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
  383. DP_STATS_INCC(peer,
  384. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  385. ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
  386. DP_STATS_INCC(peer,
  387. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  388. ((mcs < (MAX_MCS_11B)) && (preamble == DOT11_B)));
  389. DP_STATS_INCC(peer,
  390. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  391. ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
  392. DP_STATS_INCC(peer,
  393. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  394. ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
  395. DP_STATS_INCC(peer,
  396. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  397. ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
  398. DP_STATS_INCC(peer,
  399. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  400. ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
  401. DP_STATS_INCC(peer,
  402. tx.pkt_type[preamble].mcs_count[MAX_MCS-1], num_msdu,
  403. ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  404. DP_STATS_INCC(peer,
  405. tx.pkt_type[preamble].mcs_count[mcs], num_msdu,
  406. ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
  407. DP_STATS_INCC(peer, tx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
  408. DP_STATS_INCC(peer, tx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
  409. DP_STATS_INCC(peer, tx.pream_punct_cnt, 1, ppdu->pream_punct);
  410. dp_peer_stats_notify(pdev, peer);
  411. #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
  412. dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
  413. &peer->stats, ppdu->peer_id,
  414. UPDATE_PEER_STATS, pdev->pdev_id);
  415. #endif
  416. }
  417. #endif
  418. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  419. #include "dp_tx_capture.h"
  420. #else
  421. static inline void
  422. dp_process_ppdu_stats_update_failed_bitmap(struct dp_pdev *pdev,
  423. void *data,
  424. uint32_t ppdu_id,
  425. uint32_t size)
  426. {
  427. }
  428. #endif
  429. /*
  430. * htt_htc_pkt_alloc() - Allocate HTC packet buffer
  431. * @htt_soc: HTT SOC handle
  432. *
  433. * Return: Pointer to htc packet buffer
  434. */
  435. static struct dp_htt_htc_pkt *
  436. htt_htc_pkt_alloc(struct htt_soc *soc)
  437. {
  438. struct dp_htt_htc_pkt_union *pkt = NULL;
  439. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  440. if (soc->htt_htc_pkt_freelist) {
  441. pkt = soc->htt_htc_pkt_freelist;
  442. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  443. }
  444. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  445. if (!pkt)
  446. pkt = qdf_mem_malloc(sizeof(*pkt));
  447. if (!pkt)
  448. return NULL;
  449. htc_packet_set_magic_cookie(&(pkt->u.pkt.htc_pkt), 0);
  450. return &pkt->u.pkt; /* not actually a dereference */
  451. }
  452. /*
  453. * htt_htc_pkt_free() - Free HTC packet buffer
  454. * @htt_soc: HTT SOC handle
  455. */
  456. static void
  457. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  458. {
  459. struct dp_htt_htc_pkt_union *u_pkt =
  460. (struct dp_htt_htc_pkt_union *)pkt;
  461. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  462. htc_packet_set_magic_cookie(&(u_pkt->u.pkt.htc_pkt), 0);
  463. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  464. soc->htt_htc_pkt_freelist = u_pkt;
  465. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  466. }
  467. /*
  468. * htt_htc_pkt_pool_free() - Free HTC packet pool
  469. * @htt_soc: HTT SOC handle
  470. */
  471. void
  472. htt_htc_pkt_pool_free(struct htt_soc *soc)
  473. {
  474. struct dp_htt_htc_pkt_union *pkt, *next;
  475. pkt = soc->htt_htc_pkt_freelist;
  476. while (pkt) {
  477. next = pkt->u.next;
  478. qdf_mem_free(pkt);
  479. pkt = next;
  480. }
  481. soc->htt_htc_pkt_freelist = NULL;
  482. }
  483. /*
  484. * htt_htc_misc_pkt_list_trim() - trim misc list
  485. * @htt_soc: HTT SOC handle
  486. * @level: max no. of pkts in list
  487. */
  488. static void
  489. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  490. {
  491. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  492. int i = 0;
  493. qdf_nbuf_t netbuf;
  494. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  495. pkt = soc->htt_htc_pkt_misclist;
  496. while (pkt) {
  497. next = pkt->u.next;
  498. /* trim the out grown list*/
  499. if (++i > level) {
  500. netbuf =
  501. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  502. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  503. qdf_nbuf_free(netbuf);
  504. qdf_mem_free(pkt);
  505. pkt = NULL;
  506. if (prev)
  507. prev->u.next = NULL;
  508. }
  509. prev = pkt;
  510. pkt = next;
  511. }
  512. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  513. }
  514. /*
  515. * htt_htc_misc_pkt_list_add() - Add pkt to misc list
  516. * @htt_soc: HTT SOC handle
  517. * @dp_htt_htc_pkt: pkt to be added to list
  518. */
  519. static void
  520. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  521. {
  522. struct dp_htt_htc_pkt_union *u_pkt =
  523. (struct dp_htt_htc_pkt_union *)pkt;
  524. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  525. pkt->htc_pkt.Endpoint)
  526. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  527. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  528. if (soc->htt_htc_pkt_misclist) {
  529. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  530. soc->htt_htc_pkt_misclist = u_pkt;
  531. } else {
  532. soc->htt_htc_pkt_misclist = u_pkt;
  533. }
  534. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  535. /* only ce pipe size + tx_queue_depth could possibly be in use
  536. * free older packets in the misclist
  537. */
  538. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  539. }
  540. /**
  541. * DP_HTT_SEND_HTC_PKT() - Send htt packet from host
  542. * @soc : HTT SOC handle
  543. * @pkt: pkt to be send
  544. * @cmd : command to be recorded in dp htt logger
  545. * @buf : Pointer to buffer needs to be recored for above cmd
  546. *
  547. * Return: None
  548. */
  549. static inline QDF_STATUS DP_HTT_SEND_HTC_PKT(struct htt_soc *soc,
  550. struct dp_htt_htc_pkt *pkt,
  551. uint8_t cmd, uint8_t *buf)
  552. {
  553. QDF_STATUS status;
  554. htt_command_record(soc->htt_logger_handle, cmd, buf);
  555. status = htc_send_pkt(soc->htc_soc, &pkt->htc_pkt);
  556. if (status == QDF_STATUS_SUCCESS)
  557. htt_htc_misc_pkt_list_add(soc, pkt);
  558. else
  559. soc->stats.fail_count++;
  560. return status;
  561. }
  562. /*
  563. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  564. * @htt_soc: HTT SOC handle
  565. */
  566. static void
  567. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  568. {
  569. struct dp_htt_htc_pkt_union *pkt, *next;
  570. qdf_nbuf_t netbuf;
  571. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  572. pkt = soc->htt_htc_pkt_misclist;
  573. while (pkt) {
  574. next = pkt->u.next;
  575. if (htc_packet_get_magic_cookie(&(pkt->u.pkt.htc_pkt)) !=
  576. HTC_PACKET_MAGIC_COOKIE) {
  577. pkt = next;
  578. soc->stats.skip_count++;
  579. continue;
  580. }
  581. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  582. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  583. soc->stats.htc_pkt_free++;
  584. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
  585. "%s: Pkt free count %d",
  586. __func__, soc->stats.htc_pkt_free);
  587. qdf_nbuf_free(netbuf);
  588. qdf_mem_free(pkt);
  589. pkt = next;
  590. }
  591. soc->htt_htc_pkt_misclist = NULL;
  592. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  593. dp_info("HTC Packets, fail count = %d, skip count = %d",
  594. soc->stats.fail_count, soc->stats.skip_count);
  595. }
  596. /*
  597. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianness differ
  598. * @tgt_mac_addr: Target MAC
  599. * @buffer: Output buffer
  600. */
  601. static u_int8_t *
  602. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  603. {
  604. #ifdef BIG_ENDIAN_HOST
  605. /*
  606. * The host endianness is opposite of the target endianness.
  607. * To make u_int32_t elements come out correctly, the target->host
  608. * upload has swizzled the bytes in each u_int32_t element of the
  609. * message.
  610. * For byte-array message fields like the MAC address, this
  611. * upload swizzling puts the bytes in the wrong order, and needs
  612. * to be undone.
  613. */
  614. buffer[0] = tgt_mac_addr[3];
  615. buffer[1] = tgt_mac_addr[2];
  616. buffer[2] = tgt_mac_addr[1];
  617. buffer[3] = tgt_mac_addr[0];
  618. buffer[4] = tgt_mac_addr[7];
  619. buffer[5] = tgt_mac_addr[6];
  620. return buffer;
  621. #else
  622. /*
  623. * The host endianness matches the target endianness -
  624. * we can use the mac addr directly from the message buffer.
  625. */
  626. return tgt_mac_addr;
  627. #endif
  628. }
  629. /*
  630. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  631. * @soc: SOC handle
  632. * @status: Completion status
  633. * @netbuf: HTT buffer
  634. */
  635. static void
  636. dp_htt_h2t_send_complete_free_netbuf(
  637. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  638. {
  639. qdf_nbuf_free(netbuf);
  640. }
  641. /*
  642. * dp_htt_h2t_send_complete() - H2T completion handler
  643. * @context: Opaque context (HTT SOC handle)
  644. * @htc_pkt: HTC packet
  645. */
  646. static void
  647. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  648. {
  649. void (*send_complete_part2)(
  650. void *soc, QDF_STATUS status, qdf_nbuf_t msdu);
  651. struct htt_soc *soc = (struct htt_soc *) context;
  652. struct dp_htt_htc_pkt *htt_pkt;
  653. qdf_nbuf_t netbuf;
  654. send_complete_part2 = htc_pkt->pPktContext;
  655. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  656. /* process (free or keep) the netbuf that held the message */
  657. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  658. /*
  659. * adf sendcomplete is required for windows only
  660. */
  661. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  662. if (send_complete_part2) {
  663. send_complete_part2(
  664. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  665. }
  666. /* free the htt_htc_pkt / HTC_PACKET object */
  667. htt_htc_pkt_free(soc, htt_pkt);
  668. }
  669. /*
  670. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  671. * @htt_soc: HTT SOC handle
  672. *
  673. * Return: 0 on success; error code on failure
  674. */
  675. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  676. {
  677. struct dp_htt_htc_pkt *pkt;
  678. qdf_nbuf_t msg;
  679. uint32_t *msg_word;
  680. QDF_STATUS status;
  681. msg = qdf_nbuf_alloc(
  682. soc->osdev,
  683. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  684. /* reserve room for the HTC header */
  685. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  686. if (!msg)
  687. return QDF_STATUS_E_NOMEM;
  688. /*
  689. * Set the length of the message.
  690. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  691. * separately during the below call to qdf_nbuf_push_head.
  692. * The contribution from the HTC header is added separately inside HTC.
  693. */
  694. if (qdf_nbuf_put_tail(msg, HTT_VER_REQ_BYTES) == NULL) {
  695. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  696. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  697. __func__);
  698. return QDF_STATUS_E_FAILURE;
  699. }
  700. /* fill in the message contents */
  701. msg_word = (u_int32_t *) qdf_nbuf_data(msg);
  702. /* rewind beyond alignment pad to get to the HTC header reserved area */
  703. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  704. *msg_word = 0;
  705. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  706. pkt = htt_htc_pkt_alloc(soc);
  707. if (!pkt) {
  708. qdf_nbuf_free(msg);
  709. return QDF_STATUS_E_FAILURE;
  710. }
  711. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  712. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  713. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  714. qdf_nbuf_len(msg), soc->htc_endpoint,
  715. HTC_TX_PACKET_TAG_RTPM_PUT_RC);
  716. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  717. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_VERSION_REQ,
  718. NULL);
  719. if (status != QDF_STATUS_SUCCESS) {
  720. qdf_nbuf_free(msg);
  721. htt_htc_pkt_free(soc, pkt);
  722. }
  723. return status;
  724. }
  725. /*
  726. * htt_srng_setup() - Send SRNG setup message to target
  727. * @htt_soc: HTT SOC handle
  728. * @mac_id: MAC Id
  729. * @hal_srng: Opaque HAL SRNG pointer
  730. * @hal_ring_type: SRNG ring type
  731. *
  732. * Return: 0 on success; error code on failure
  733. */
  734. int htt_srng_setup(struct htt_soc *soc, int mac_id,
  735. hal_ring_handle_t hal_ring_hdl,
  736. int hal_ring_type)
  737. {
  738. struct dp_htt_htc_pkt *pkt;
  739. qdf_nbuf_t htt_msg;
  740. uint32_t *msg_word;
  741. struct hal_srng_params srng_params;
  742. qdf_dma_addr_t hp_addr, tp_addr;
  743. uint32_t ring_entry_size =
  744. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  745. int htt_ring_type, htt_ring_id;
  746. uint8_t *htt_logger_bufp;
  747. int target_pdev_id;
  748. int lmac_id = dp_get_lmac_id_for_pdev_id(soc->dp_soc, 0, mac_id);
  749. QDF_STATUS status;
  750. /* Sizes should be set in 4-byte words */
  751. ring_entry_size = ring_entry_size >> 2;
  752. htt_msg = qdf_nbuf_alloc(soc->osdev,
  753. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  754. /* reserve room for the HTC header */
  755. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  756. if (!htt_msg)
  757. goto fail0;
  758. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  759. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_ring_hdl);
  760. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_ring_hdl);
  761. switch (hal_ring_type) {
  762. case RXDMA_BUF:
  763. #ifdef QCA_HOST2FW_RXBUF_RING
  764. if (srng_params.ring_id ==
  765. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0)) {
  766. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  767. htt_ring_type = HTT_SW_TO_SW_RING;
  768. #ifdef IPA_OFFLOAD
  769. } else if (srng_params.ring_id ==
  770. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2)) {
  771. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  772. htt_ring_type = HTT_SW_TO_SW_RING;
  773. #endif
  774. #else
  775. if (srng_params.ring_id ==
  776. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  777. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  778. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  779. htt_ring_type = HTT_SW_TO_HW_RING;
  780. #endif
  781. } else if (srng_params.ring_id ==
  782. #ifdef IPA_OFFLOAD
  783. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  784. #else
  785. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  786. #endif
  787. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  788. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  789. htt_ring_type = HTT_SW_TO_HW_RING;
  790. } else {
  791. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  792. "%s: Ring %d currently not supported",
  793. __func__, srng_params.ring_id);
  794. goto fail1;
  795. }
  796. dp_info("ring_type %d ring_id %d htt_ring_id %d hp_addr 0x%llx tp_addr 0x%llx",
  797. hal_ring_type, srng_params.ring_id, htt_ring_id,
  798. (uint64_t)hp_addr,
  799. (uint64_t)tp_addr);
  800. break;
  801. case RXDMA_MONITOR_BUF:
  802. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  803. htt_ring_type = HTT_SW_TO_HW_RING;
  804. break;
  805. case RXDMA_MONITOR_STATUS:
  806. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  807. htt_ring_type = HTT_SW_TO_HW_RING;
  808. break;
  809. case RXDMA_MONITOR_DST:
  810. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  811. htt_ring_type = HTT_HW_TO_SW_RING;
  812. break;
  813. case RXDMA_MONITOR_DESC:
  814. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  815. htt_ring_type = HTT_SW_TO_HW_RING;
  816. break;
  817. case RXDMA_DST:
  818. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  819. htt_ring_type = HTT_HW_TO_SW_RING;
  820. break;
  821. default:
  822. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  823. "%s: Ring currently not supported", __func__);
  824. goto fail1;
  825. }
  826. /*
  827. * Set the length of the message.
  828. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  829. * separately during the below call to qdf_nbuf_push_head.
  830. * The contribution from the HTC header is added separately inside HTC.
  831. */
  832. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  833. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  834. "%s: Failed to expand head for SRING_SETUP msg",
  835. __func__);
  836. return QDF_STATUS_E_FAILURE;
  837. }
  838. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  839. /* rewind beyond alignment pad to get to the HTC header reserved area */
  840. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  841. /* word 0 */
  842. *msg_word = 0;
  843. htt_logger_bufp = (uint8_t *)msg_word;
  844. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  845. target_pdev_id =
  846. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, mac_id);
  847. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  848. (htt_ring_type == HTT_HW_TO_SW_RING))
  849. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, target_pdev_id);
  850. else
  851. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  852. dp_info("mac_id %d", mac_id);
  853. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  854. /* TODO: Discuss with FW on changing this to unique ID and using
  855. * htt_ring_type to send the type of ring
  856. */
  857. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  858. /* word 1 */
  859. msg_word++;
  860. *msg_word = 0;
  861. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  862. srng_params.ring_base_paddr & 0xffffffff);
  863. /* word 2 */
  864. msg_word++;
  865. *msg_word = 0;
  866. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  867. (uint64_t)srng_params.ring_base_paddr >> 32);
  868. /* word 3 */
  869. msg_word++;
  870. *msg_word = 0;
  871. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  872. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  873. (ring_entry_size * srng_params.num_entries));
  874. dp_info("entry_size %d", ring_entry_size);
  875. dp_info("num_entries %d", srng_params.num_entries);
  876. dp_info("ring_size %d", (ring_entry_size * srng_params.num_entries));
  877. if (htt_ring_type == HTT_SW_TO_HW_RING)
  878. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  879. *msg_word, 1);
  880. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  881. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  882. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  883. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  884. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  885. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  886. /* word 4 */
  887. msg_word++;
  888. *msg_word = 0;
  889. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  890. hp_addr & 0xffffffff);
  891. /* word 5 */
  892. msg_word++;
  893. *msg_word = 0;
  894. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  895. (uint64_t)hp_addr >> 32);
  896. /* word 6 */
  897. msg_word++;
  898. *msg_word = 0;
  899. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  900. tp_addr & 0xffffffff);
  901. /* word 7 */
  902. msg_word++;
  903. *msg_word = 0;
  904. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  905. (uint64_t)tp_addr >> 32);
  906. /* word 8 */
  907. msg_word++;
  908. *msg_word = 0;
  909. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  910. srng_params.msi_addr & 0xffffffff);
  911. /* word 9 */
  912. msg_word++;
  913. *msg_word = 0;
  914. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  915. (uint64_t)(srng_params.msi_addr) >> 32);
  916. /* word 10 */
  917. msg_word++;
  918. *msg_word = 0;
  919. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  920. qdf_cpu_to_le32(srng_params.msi_data));
  921. /* word 11 */
  922. msg_word++;
  923. *msg_word = 0;
  924. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  925. srng_params.intr_batch_cntr_thres_entries *
  926. ring_entry_size);
  927. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  928. srng_params.intr_timer_thres_us >> 3);
  929. /* word 12 */
  930. msg_word++;
  931. *msg_word = 0;
  932. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  933. /* TODO: Setting low threshold to 1/8th of ring size - see
  934. * if this needs to be configurable
  935. */
  936. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  937. srng_params.low_threshold);
  938. }
  939. /* "response_required" field should be set if a HTT response message is
  940. * required after setting up the ring.
  941. */
  942. pkt = htt_htc_pkt_alloc(soc);
  943. if (!pkt)
  944. goto fail1;
  945. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  946. SET_HTC_PACKET_INFO_TX(
  947. &pkt->htc_pkt,
  948. dp_htt_h2t_send_complete_free_netbuf,
  949. qdf_nbuf_data(htt_msg),
  950. qdf_nbuf_len(htt_msg),
  951. soc->htc_endpoint,
  952. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  953. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  954. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  955. htt_logger_bufp);
  956. if (status != QDF_STATUS_SUCCESS) {
  957. qdf_nbuf_free(htt_msg);
  958. htt_htc_pkt_free(soc, pkt);
  959. }
  960. return status;
  961. fail1:
  962. qdf_nbuf_free(htt_msg);
  963. fail0:
  964. return QDF_STATUS_E_FAILURE;
  965. }
  966. #ifdef QCA_SUPPORT_FULL_MON
  967. /**
  968. * htt_h2t_full_mon_cfg() - Send full monitor configuarion msg to FW
  969. *
  970. * @htt_soc: HTT Soc handle
  971. * @pdev_id: Radio id
  972. * @dp_full_mon_config: enabled/disable configuration
  973. *
  974. * Return: Success when HTT message is sent, error on failure
  975. */
  976. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  977. uint8_t pdev_id,
  978. enum dp_full_mon_config config)
  979. {
  980. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  981. struct dp_htt_htc_pkt *pkt;
  982. qdf_nbuf_t htt_msg;
  983. uint32_t *msg_word;
  984. uint8_t *htt_logger_bufp;
  985. htt_msg = qdf_nbuf_alloc(soc->osdev,
  986. HTT_MSG_BUF_SIZE(
  987. HTT_RX_FULL_MONITOR_MODE_SETUP_SZ),
  988. /* reserve room for the HTC header */
  989. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  990. 4,
  991. TRUE);
  992. if (!htt_msg)
  993. return QDF_STATUS_E_FAILURE;
  994. /*
  995. * Set the length of the message.
  996. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  997. * separately during the below call to qdf_nbuf_push_head.
  998. * The contribution from the HTC header is added separately inside HTC.
  999. */
  1000. if (!qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ)) {
  1001. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1002. "%s: Failed to expand head for RX Ring Cfg msg",
  1003. __func__);
  1004. goto fail1;
  1005. }
  1006. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  1007. /* rewind beyond alignment pad to get to the HTC header reserved area */
  1008. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  1009. /* word 0 */
  1010. *msg_word = 0;
  1011. htt_logger_bufp = (uint8_t *)msg_word;
  1012. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE);
  1013. HTT_RX_FULL_MONITOR_MODE_OPERATION_PDEV_ID_SET(
  1014. *msg_word, DP_SW2HW_MACID(pdev_id));
  1015. msg_word++;
  1016. *msg_word = 0;
  1017. /* word 1 */
  1018. if (config == DP_FULL_MON_ENABLE) {
  1019. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  1020. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, true);
  1021. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, true);
  1022. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  1023. } else if (config == DP_FULL_MON_DISABLE) {
  1024. /* As per MAC team's suggestion, While disbaling full monitor
  1025. * mode, Set 'en' bit to true in full monitor mode register.
  1026. */
  1027. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  1028. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, false);
  1029. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, false);
  1030. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  1031. }
  1032. pkt = htt_htc_pkt_alloc(soc);
  1033. if (!pkt) {
  1034. qdf_err("HTC packet allocation failed");
  1035. goto fail1;
  1036. }
  1037. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1038. SET_HTC_PACKET_INFO_TX(
  1039. &pkt->htc_pkt,
  1040. dp_htt_h2t_send_complete_free_netbuf,
  1041. qdf_nbuf_data(htt_msg),
  1042. qdf_nbuf_len(htt_msg),
  1043. soc->htc_endpoint,
  1044. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1045. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1046. qdf_info("config: %d", config);
  1047. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  1048. htt_logger_bufp);
  1049. return QDF_STATUS_SUCCESS;
  1050. fail1:
  1051. qdf_nbuf_free(htt_msg);
  1052. return QDF_STATUS_E_FAILURE;
  1053. }
  1054. #else
  1055. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  1056. uint8_t pdev_id,
  1057. enum dp_full_mon_config config)
  1058. {
  1059. return 0;
  1060. }
  1061. #endif
  1062. /*
  1063. * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
  1064. * config message to target
  1065. * @htt_soc: HTT SOC handle
  1066. * @pdev_id: WIN- PDEV Id, MCL- mac id
  1067. * @hal_srng: Opaque HAL SRNG pointer
  1068. * @hal_ring_type: SRNG ring type
  1069. * @ring_buf_size: SRNG buffer size
  1070. * @htt_tlv_filter: Rx SRNG TLV and filter setting
  1071. * Return: 0 on success; error code on failure
  1072. */
  1073. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  1074. hal_ring_handle_t hal_ring_hdl,
  1075. int hal_ring_type, int ring_buf_size,
  1076. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  1077. {
  1078. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  1079. struct dp_htt_htc_pkt *pkt;
  1080. qdf_nbuf_t htt_msg;
  1081. uint32_t *msg_word;
  1082. struct hal_srng_params srng_params;
  1083. uint32_t htt_ring_type, htt_ring_id;
  1084. uint32_t tlv_filter;
  1085. uint8_t *htt_logger_bufp;
  1086. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
  1087. uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
  1088. int target_pdev_id;
  1089. QDF_STATUS status;
  1090. htt_msg = qdf_nbuf_alloc(soc->osdev,
  1091. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  1092. /* reserve room for the HTC header */
  1093. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  1094. if (!htt_msg)
  1095. goto fail0;
  1096. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  1097. switch (hal_ring_type) {
  1098. case RXDMA_BUF:
  1099. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  1100. htt_ring_type = HTT_SW_TO_HW_RING;
  1101. break;
  1102. case RXDMA_MONITOR_BUF:
  1103. htt_ring_id = HTT_RXDMA_MONITOR_BUF_RING;
  1104. htt_ring_type = HTT_SW_TO_HW_RING;
  1105. break;
  1106. case RXDMA_MONITOR_STATUS:
  1107. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  1108. htt_ring_type = HTT_SW_TO_HW_RING;
  1109. break;
  1110. case RXDMA_MONITOR_DST:
  1111. htt_ring_id = HTT_RXDMA_MONITOR_DEST_RING;
  1112. htt_ring_type = HTT_HW_TO_SW_RING;
  1113. break;
  1114. case RXDMA_MONITOR_DESC:
  1115. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  1116. htt_ring_type = HTT_SW_TO_HW_RING;
  1117. break;
  1118. case RXDMA_DST:
  1119. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  1120. htt_ring_type = HTT_HW_TO_SW_RING;
  1121. break;
  1122. default:
  1123. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1124. "%s: Ring currently not supported", __func__);
  1125. goto fail1;
  1126. }
  1127. /*
  1128. * Set the length of the message.
  1129. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  1130. * separately during the below call to qdf_nbuf_push_head.
  1131. * The contribution from the HTC header is added separately inside HTC.
  1132. */
  1133. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  1134. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1135. "%s: Failed to expand head for RX Ring Cfg msg",
  1136. __func__);
  1137. goto fail1; /* failure */
  1138. }
  1139. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  1140. /* rewind beyond alignment pad to get to the HTC header reserved area */
  1141. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  1142. /* word 0 */
  1143. htt_logger_bufp = (uint8_t *)msg_word;
  1144. *msg_word = 0;
  1145. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  1146. /*
  1147. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  1148. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  1149. */
  1150. target_pdev_id =
  1151. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, pdev_id);
  1152. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  1153. htt_ring_type == HTT_SW_TO_HW_RING)
  1154. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  1155. target_pdev_id);
  1156. /* TODO: Discuss with FW on changing this to unique ID and using
  1157. * htt_ring_type to send the type of ring
  1158. */
  1159. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  1160. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  1161. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  1162. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  1163. htt_tlv_filter->offset_valid);
  1164. if (mon_drop_th > 0)
  1165. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1166. 1);
  1167. else
  1168. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1169. 0);
  1170. /* word 1 */
  1171. msg_word++;
  1172. *msg_word = 0;
  1173. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  1174. ring_buf_size);
  1175. /* word 2 */
  1176. msg_word++;
  1177. *msg_word = 0;
  1178. if (htt_tlv_filter->enable_fp) {
  1179. /* TYPE: MGMT */
  1180. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1181. FP, MGMT, 0000,
  1182. (htt_tlv_filter->fp_mgmt_filter &
  1183. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1184. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1185. FP, MGMT, 0001,
  1186. (htt_tlv_filter->fp_mgmt_filter &
  1187. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1188. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1189. FP, MGMT, 0010,
  1190. (htt_tlv_filter->fp_mgmt_filter &
  1191. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1192. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1193. FP, MGMT, 0011,
  1194. (htt_tlv_filter->fp_mgmt_filter &
  1195. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1196. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1197. FP, MGMT, 0100,
  1198. (htt_tlv_filter->fp_mgmt_filter &
  1199. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1200. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1201. FP, MGMT, 0101,
  1202. (htt_tlv_filter->fp_mgmt_filter &
  1203. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1204. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1205. FP, MGMT, 0110,
  1206. (htt_tlv_filter->fp_mgmt_filter &
  1207. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1208. /* reserved */
  1209. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  1210. MGMT, 0111,
  1211. (htt_tlv_filter->fp_mgmt_filter &
  1212. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1213. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1214. FP, MGMT, 1000,
  1215. (htt_tlv_filter->fp_mgmt_filter &
  1216. FILTER_MGMT_BEACON) ? 1 : 0);
  1217. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1218. FP, MGMT, 1001,
  1219. (htt_tlv_filter->fp_mgmt_filter &
  1220. FILTER_MGMT_ATIM) ? 1 : 0);
  1221. }
  1222. if (htt_tlv_filter->enable_md) {
  1223. /* TYPE: MGMT */
  1224. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1225. MD, MGMT, 0000,
  1226. (htt_tlv_filter->md_mgmt_filter &
  1227. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1228. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1229. MD, MGMT, 0001,
  1230. (htt_tlv_filter->md_mgmt_filter &
  1231. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1232. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1233. MD, MGMT, 0010,
  1234. (htt_tlv_filter->md_mgmt_filter &
  1235. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1236. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1237. MD, MGMT, 0011,
  1238. (htt_tlv_filter->md_mgmt_filter &
  1239. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1240. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1241. MD, MGMT, 0100,
  1242. (htt_tlv_filter->md_mgmt_filter &
  1243. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1244. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1245. MD, MGMT, 0101,
  1246. (htt_tlv_filter->md_mgmt_filter &
  1247. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1248. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1249. MD, MGMT, 0110,
  1250. (htt_tlv_filter->md_mgmt_filter &
  1251. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1252. /* reserved */
  1253. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  1254. MGMT, 0111,
  1255. (htt_tlv_filter->md_mgmt_filter &
  1256. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1257. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1258. MD, MGMT, 1000,
  1259. (htt_tlv_filter->md_mgmt_filter &
  1260. FILTER_MGMT_BEACON) ? 1 : 0);
  1261. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1262. MD, MGMT, 1001,
  1263. (htt_tlv_filter->md_mgmt_filter &
  1264. FILTER_MGMT_ATIM) ? 1 : 0);
  1265. }
  1266. if (htt_tlv_filter->enable_mo) {
  1267. /* TYPE: MGMT */
  1268. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1269. MO, MGMT, 0000,
  1270. (htt_tlv_filter->mo_mgmt_filter &
  1271. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1272. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1273. MO, MGMT, 0001,
  1274. (htt_tlv_filter->mo_mgmt_filter &
  1275. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1276. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1277. MO, MGMT, 0010,
  1278. (htt_tlv_filter->mo_mgmt_filter &
  1279. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1280. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1281. MO, MGMT, 0011,
  1282. (htt_tlv_filter->mo_mgmt_filter &
  1283. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1284. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1285. MO, MGMT, 0100,
  1286. (htt_tlv_filter->mo_mgmt_filter &
  1287. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1288. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1289. MO, MGMT, 0101,
  1290. (htt_tlv_filter->mo_mgmt_filter &
  1291. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1292. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1293. MO, MGMT, 0110,
  1294. (htt_tlv_filter->mo_mgmt_filter &
  1295. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1296. /* reserved */
  1297. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  1298. MGMT, 0111,
  1299. (htt_tlv_filter->mo_mgmt_filter &
  1300. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1301. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1302. MO, MGMT, 1000,
  1303. (htt_tlv_filter->mo_mgmt_filter &
  1304. FILTER_MGMT_BEACON) ? 1 : 0);
  1305. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1306. MO, MGMT, 1001,
  1307. (htt_tlv_filter->mo_mgmt_filter &
  1308. FILTER_MGMT_ATIM) ? 1 : 0);
  1309. }
  1310. /* word 3 */
  1311. msg_word++;
  1312. *msg_word = 0;
  1313. if (htt_tlv_filter->enable_fp) {
  1314. /* TYPE: MGMT */
  1315. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1316. FP, MGMT, 1010,
  1317. (htt_tlv_filter->fp_mgmt_filter &
  1318. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1319. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1320. FP, MGMT, 1011,
  1321. (htt_tlv_filter->fp_mgmt_filter &
  1322. FILTER_MGMT_AUTH) ? 1 : 0);
  1323. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1324. FP, MGMT, 1100,
  1325. (htt_tlv_filter->fp_mgmt_filter &
  1326. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1327. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1328. FP, MGMT, 1101,
  1329. (htt_tlv_filter->fp_mgmt_filter &
  1330. FILTER_MGMT_ACTION) ? 1 : 0);
  1331. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1332. FP, MGMT, 1110,
  1333. (htt_tlv_filter->fp_mgmt_filter &
  1334. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1335. /* reserved*/
  1336. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  1337. MGMT, 1111,
  1338. (htt_tlv_filter->fp_mgmt_filter &
  1339. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1340. }
  1341. if (htt_tlv_filter->enable_md) {
  1342. /* TYPE: MGMT */
  1343. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1344. MD, MGMT, 1010,
  1345. (htt_tlv_filter->md_mgmt_filter &
  1346. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1347. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1348. MD, MGMT, 1011,
  1349. (htt_tlv_filter->md_mgmt_filter &
  1350. FILTER_MGMT_AUTH) ? 1 : 0);
  1351. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1352. MD, MGMT, 1100,
  1353. (htt_tlv_filter->md_mgmt_filter &
  1354. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1355. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1356. MD, MGMT, 1101,
  1357. (htt_tlv_filter->md_mgmt_filter &
  1358. FILTER_MGMT_ACTION) ? 1 : 0);
  1359. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1360. MD, MGMT, 1110,
  1361. (htt_tlv_filter->md_mgmt_filter &
  1362. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1363. }
  1364. if (htt_tlv_filter->enable_mo) {
  1365. /* TYPE: MGMT */
  1366. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1367. MO, MGMT, 1010,
  1368. (htt_tlv_filter->mo_mgmt_filter &
  1369. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1370. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1371. MO, MGMT, 1011,
  1372. (htt_tlv_filter->mo_mgmt_filter &
  1373. FILTER_MGMT_AUTH) ? 1 : 0);
  1374. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1375. MO, MGMT, 1100,
  1376. (htt_tlv_filter->mo_mgmt_filter &
  1377. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1378. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1379. MO, MGMT, 1101,
  1380. (htt_tlv_filter->mo_mgmt_filter &
  1381. FILTER_MGMT_ACTION) ? 1 : 0);
  1382. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1383. MO, MGMT, 1110,
  1384. (htt_tlv_filter->mo_mgmt_filter &
  1385. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1386. /* reserved*/
  1387. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1388. MGMT, 1111,
  1389. (htt_tlv_filter->mo_mgmt_filter &
  1390. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1391. }
  1392. /* word 4 */
  1393. msg_word++;
  1394. *msg_word = 0;
  1395. if (htt_tlv_filter->enable_fp) {
  1396. /* TYPE: CTRL */
  1397. /* reserved */
  1398. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1399. CTRL, 0000,
  1400. (htt_tlv_filter->fp_ctrl_filter &
  1401. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1402. /* reserved */
  1403. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1404. CTRL, 0001,
  1405. (htt_tlv_filter->fp_ctrl_filter &
  1406. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1407. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1408. CTRL, 0010,
  1409. (htt_tlv_filter->fp_ctrl_filter &
  1410. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1411. /* reserved */
  1412. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1413. CTRL, 0011,
  1414. (htt_tlv_filter->fp_ctrl_filter &
  1415. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1416. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1417. CTRL, 0100,
  1418. (htt_tlv_filter->fp_ctrl_filter &
  1419. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1420. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1421. CTRL, 0101,
  1422. (htt_tlv_filter->fp_ctrl_filter &
  1423. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1424. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1425. CTRL, 0110,
  1426. (htt_tlv_filter->fp_ctrl_filter &
  1427. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1428. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1429. CTRL, 0111,
  1430. (htt_tlv_filter->fp_ctrl_filter &
  1431. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1432. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1433. CTRL, 1000,
  1434. (htt_tlv_filter->fp_ctrl_filter &
  1435. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1436. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1437. CTRL, 1001,
  1438. (htt_tlv_filter->fp_ctrl_filter &
  1439. FILTER_CTRL_BA) ? 1 : 0);
  1440. }
  1441. if (htt_tlv_filter->enable_md) {
  1442. /* TYPE: CTRL */
  1443. /* reserved */
  1444. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1445. CTRL, 0000,
  1446. (htt_tlv_filter->md_ctrl_filter &
  1447. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1448. /* reserved */
  1449. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1450. CTRL, 0001,
  1451. (htt_tlv_filter->md_ctrl_filter &
  1452. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1453. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1454. CTRL, 0010,
  1455. (htt_tlv_filter->md_ctrl_filter &
  1456. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1457. /* reserved */
  1458. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1459. CTRL, 0011,
  1460. (htt_tlv_filter->md_ctrl_filter &
  1461. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1462. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1463. CTRL, 0100,
  1464. (htt_tlv_filter->md_ctrl_filter &
  1465. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1466. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1467. CTRL, 0101,
  1468. (htt_tlv_filter->md_ctrl_filter &
  1469. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1470. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1471. CTRL, 0110,
  1472. (htt_tlv_filter->md_ctrl_filter &
  1473. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1474. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1475. CTRL, 0111,
  1476. (htt_tlv_filter->md_ctrl_filter &
  1477. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1478. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1479. CTRL, 1000,
  1480. (htt_tlv_filter->md_ctrl_filter &
  1481. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1482. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1483. CTRL, 1001,
  1484. (htt_tlv_filter->md_ctrl_filter &
  1485. FILTER_CTRL_BA) ? 1 : 0);
  1486. }
  1487. if (htt_tlv_filter->enable_mo) {
  1488. /* TYPE: CTRL */
  1489. /* reserved */
  1490. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1491. CTRL, 0000,
  1492. (htt_tlv_filter->mo_ctrl_filter &
  1493. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1494. /* reserved */
  1495. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1496. CTRL, 0001,
  1497. (htt_tlv_filter->mo_ctrl_filter &
  1498. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1499. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1500. CTRL, 0010,
  1501. (htt_tlv_filter->mo_ctrl_filter &
  1502. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1503. /* reserved */
  1504. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1505. CTRL, 0011,
  1506. (htt_tlv_filter->mo_ctrl_filter &
  1507. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1508. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1509. CTRL, 0100,
  1510. (htt_tlv_filter->mo_ctrl_filter &
  1511. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1512. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1513. CTRL, 0101,
  1514. (htt_tlv_filter->mo_ctrl_filter &
  1515. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1516. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1517. CTRL, 0110,
  1518. (htt_tlv_filter->mo_ctrl_filter &
  1519. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1520. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1521. CTRL, 0111,
  1522. (htt_tlv_filter->mo_ctrl_filter &
  1523. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1524. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1525. CTRL, 1000,
  1526. (htt_tlv_filter->mo_ctrl_filter &
  1527. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1528. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1529. CTRL, 1001,
  1530. (htt_tlv_filter->mo_ctrl_filter &
  1531. FILTER_CTRL_BA) ? 1 : 0);
  1532. }
  1533. /* word 5 */
  1534. msg_word++;
  1535. *msg_word = 0;
  1536. if (htt_tlv_filter->enable_fp) {
  1537. /* TYPE: CTRL */
  1538. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1539. CTRL, 1010,
  1540. (htt_tlv_filter->fp_ctrl_filter &
  1541. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1542. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1543. CTRL, 1011,
  1544. (htt_tlv_filter->fp_ctrl_filter &
  1545. FILTER_CTRL_RTS) ? 1 : 0);
  1546. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1547. CTRL, 1100,
  1548. (htt_tlv_filter->fp_ctrl_filter &
  1549. FILTER_CTRL_CTS) ? 1 : 0);
  1550. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1551. CTRL, 1101,
  1552. (htt_tlv_filter->fp_ctrl_filter &
  1553. FILTER_CTRL_ACK) ? 1 : 0);
  1554. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1555. CTRL, 1110,
  1556. (htt_tlv_filter->fp_ctrl_filter &
  1557. FILTER_CTRL_CFEND) ? 1 : 0);
  1558. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1559. CTRL, 1111,
  1560. (htt_tlv_filter->fp_ctrl_filter &
  1561. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1562. /* TYPE: DATA */
  1563. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1564. DATA, MCAST,
  1565. (htt_tlv_filter->fp_data_filter &
  1566. FILTER_DATA_MCAST) ? 1 : 0);
  1567. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1568. DATA, UCAST,
  1569. (htt_tlv_filter->fp_data_filter &
  1570. FILTER_DATA_UCAST) ? 1 : 0);
  1571. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1572. DATA, NULL,
  1573. (htt_tlv_filter->fp_data_filter &
  1574. FILTER_DATA_NULL) ? 1 : 0);
  1575. }
  1576. if (htt_tlv_filter->enable_md) {
  1577. /* TYPE: CTRL */
  1578. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1579. CTRL, 1010,
  1580. (htt_tlv_filter->md_ctrl_filter &
  1581. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1582. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1583. CTRL, 1011,
  1584. (htt_tlv_filter->md_ctrl_filter &
  1585. FILTER_CTRL_RTS) ? 1 : 0);
  1586. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1587. CTRL, 1100,
  1588. (htt_tlv_filter->md_ctrl_filter &
  1589. FILTER_CTRL_CTS) ? 1 : 0);
  1590. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1591. CTRL, 1101,
  1592. (htt_tlv_filter->md_ctrl_filter &
  1593. FILTER_CTRL_ACK) ? 1 : 0);
  1594. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1595. CTRL, 1110,
  1596. (htt_tlv_filter->md_ctrl_filter &
  1597. FILTER_CTRL_CFEND) ? 1 : 0);
  1598. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1599. CTRL, 1111,
  1600. (htt_tlv_filter->md_ctrl_filter &
  1601. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1602. /* TYPE: DATA */
  1603. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1604. DATA, MCAST,
  1605. (htt_tlv_filter->md_data_filter &
  1606. FILTER_DATA_MCAST) ? 1 : 0);
  1607. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1608. DATA, UCAST,
  1609. (htt_tlv_filter->md_data_filter &
  1610. FILTER_DATA_UCAST) ? 1 : 0);
  1611. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1612. DATA, NULL,
  1613. (htt_tlv_filter->md_data_filter &
  1614. FILTER_DATA_NULL) ? 1 : 0);
  1615. }
  1616. if (htt_tlv_filter->enable_mo) {
  1617. /* TYPE: CTRL */
  1618. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1619. CTRL, 1010,
  1620. (htt_tlv_filter->mo_ctrl_filter &
  1621. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1622. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1623. CTRL, 1011,
  1624. (htt_tlv_filter->mo_ctrl_filter &
  1625. FILTER_CTRL_RTS) ? 1 : 0);
  1626. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1627. CTRL, 1100,
  1628. (htt_tlv_filter->mo_ctrl_filter &
  1629. FILTER_CTRL_CTS) ? 1 : 0);
  1630. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1631. CTRL, 1101,
  1632. (htt_tlv_filter->mo_ctrl_filter &
  1633. FILTER_CTRL_ACK) ? 1 : 0);
  1634. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1635. CTRL, 1110,
  1636. (htt_tlv_filter->mo_ctrl_filter &
  1637. FILTER_CTRL_CFEND) ? 1 : 0);
  1638. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1639. CTRL, 1111,
  1640. (htt_tlv_filter->mo_ctrl_filter &
  1641. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1642. /* TYPE: DATA */
  1643. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1644. DATA, MCAST,
  1645. (htt_tlv_filter->mo_data_filter &
  1646. FILTER_DATA_MCAST) ? 1 : 0);
  1647. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1648. DATA, UCAST,
  1649. (htt_tlv_filter->mo_data_filter &
  1650. FILTER_DATA_UCAST) ? 1 : 0);
  1651. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1652. DATA, NULL,
  1653. (htt_tlv_filter->mo_data_filter &
  1654. FILTER_DATA_NULL) ? 1 : 0);
  1655. }
  1656. /* word 6 */
  1657. msg_word++;
  1658. *msg_word = 0;
  1659. tlv_filter = 0;
  1660. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1661. htt_tlv_filter->mpdu_start);
  1662. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1663. htt_tlv_filter->msdu_start);
  1664. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1665. htt_tlv_filter->packet);
  1666. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1667. htt_tlv_filter->msdu_end);
  1668. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1669. htt_tlv_filter->mpdu_end);
  1670. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1671. htt_tlv_filter->packet_header);
  1672. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1673. htt_tlv_filter->attention);
  1674. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1675. htt_tlv_filter->ppdu_start);
  1676. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1677. htt_tlv_filter->ppdu_end);
  1678. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1679. htt_tlv_filter->ppdu_end_user_stats);
  1680. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1681. PPDU_END_USER_STATS_EXT,
  1682. htt_tlv_filter->ppdu_end_user_stats_ext);
  1683. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1684. htt_tlv_filter->ppdu_end_status_done);
  1685. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1686. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1687. htt_tlv_filter->header_per_msdu);
  1688. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1689. msg_word++;
  1690. *msg_word = 0;
  1691. if (htt_tlv_filter->offset_valid) {
  1692. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1693. htt_tlv_filter->rx_packet_offset);
  1694. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1695. htt_tlv_filter->rx_header_offset);
  1696. msg_word++;
  1697. *msg_word = 0;
  1698. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1699. htt_tlv_filter->rx_mpdu_end_offset);
  1700. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1701. htt_tlv_filter->rx_mpdu_start_offset);
  1702. msg_word++;
  1703. *msg_word = 0;
  1704. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1705. htt_tlv_filter->rx_msdu_end_offset);
  1706. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1707. htt_tlv_filter->rx_msdu_start_offset);
  1708. msg_word++;
  1709. *msg_word = 0;
  1710. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1711. htt_tlv_filter->rx_attn_offset);
  1712. msg_word++;
  1713. *msg_word = 0;
  1714. } else {
  1715. msg_word += 4;
  1716. *msg_word = 0;
  1717. }
  1718. if (mon_drop_th > 0)
  1719. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1720. mon_drop_th);
  1721. /* "response_required" field should be set if a HTT response message is
  1722. * required after setting up the ring.
  1723. */
  1724. pkt = htt_htc_pkt_alloc(soc);
  1725. if (!pkt)
  1726. goto fail1;
  1727. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1728. SET_HTC_PACKET_INFO_TX(
  1729. &pkt->htc_pkt,
  1730. dp_htt_h2t_send_complete_free_netbuf,
  1731. qdf_nbuf_data(htt_msg),
  1732. qdf_nbuf_len(htt_msg),
  1733. soc->htc_endpoint,
  1734. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1735. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1736. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1737. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1738. htt_logger_bufp);
  1739. if (status != QDF_STATUS_SUCCESS) {
  1740. qdf_nbuf_free(htt_msg);
  1741. htt_htc_pkt_free(soc, pkt);
  1742. }
  1743. return status;
  1744. fail1:
  1745. qdf_nbuf_free(htt_msg);
  1746. fail0:
  1747. return QDF_STATUS_E_FAILURE;
  1748. }
  1749. #if defined(HTT_STATS_ENABLE)
  1750. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1751. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1752. {
  1753. uint32_t pdev_id;
  1754. uint32_t *msg_word = NULL;
  1755. uint32_t msg_remain_len = 0;
  1756. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1757. /*COOKIE MSB*/
  1758. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1759. /* stats message length + 16 size of HTT header*/
  1760. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1761. (uint32_t)DP_EXT_MSG_LENGTH);
  1762. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1763. msg_word, msg_remain_len,
  1764. WDI_NO_VAL, pdev_id);
  1765. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1766. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1767. }
  1768. /* Need to be freed here as WDI handler will
  1769. * make a copy of pkt to send data to application
  1770. */
  1771. qdf_nbuf_free(htt_msg);
  1772. return QDF_STATUS_SUCCESS;
  1773. }
  1774. #else
  1775. static inline QDF_STATUS
  1776. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1777. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1778. {
  1779. return QDF_STATUS_E_NOSUPPORT;
  1780. }
  1781. #endif
  1782. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1783. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer
  1784. * @pdev: dp pdev handle
  1785. * @msg_word: HTT msg
  1786. * @msg_len: Length of HTT msg sent
  1787. *
  1788. * Return: none
  1789. */
  1790. static inline void
  1791. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1792. uint32_t msg_len)
  1793. {
  1794. struct htt_dbgfs_cfg dbgfs_cfg;
  1795. int done = 0;
  1796. /* send 5th word of HTT msg to upper layer */
  1797. dbgfs_cfg.msg_word = (msg_word + 4);
  1798. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1799. /* stats message length + 16 size of HTT header*/
  1800. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1801. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1802. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1803. (msg_len - HTT_HEADER_LEN));
  1804. /* Get TLV Done bit from 4th msg word */
  1805. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1806. if (done) {
  1807. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1808. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1809. "Failed to set event for debugfs htt stats");
  1810. }
  1811. }
  1812. #else
  1813. static inline void
  1814. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1815. uint32_t msg_len)
  1816. {
  1817. }
  1818. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1819. /**
  1820. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1821. * @htt_stats: htt stats info
  1822. *
  1823. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1824. * contains sub messages which are identified by a TLV header.
  1825. * In this function we will process the stream of T2H messages and read all the
  1826. * TLV contained in the message.
  1827. *
  1828. * THe following cases have been taken care of
  1829. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1830. * In this case the buffer will contain multiple tlvs.
  1831. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1832. * Only one tlv will be contained in the HTT message and this tag
  1833. * will extend onto the next buffer.
  1834. * Case 3: When the buffer is the continuation of the previous message
  1835. * Case 4: tlv length is 0. which will indicate the end of message
  1836. *
  1837. * return: void
  1838. */
  1839. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1840. struct dp_soc *soc)
  1841. {
  1842. htt_tlv_tag_t tlv_type = 0xff;
  1843. qdf_nbuf_t htt_msg = NULL;
  1844. uint32_t *msg_word;
  1845. uint8_t *tlv_buf_head = NULL;
  1846. uint8_t *tlv_buf_tail = NULL;
  1847. uint32_t msg_remain_len = 0;
  1848. uint32_t tlv_remain_len = 0;
  1849. uint32_t *tlv_start;
  1850. int cookie_val = 0;
  1851. int cookie_msb = 0;
  1852. int pdev_id;
  1853. bool copy_stats = false;
  1854. struct dp_pdev *pdev;
  1855. /* Process node in the HTT message queue */
  1856. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1857. != NULL) {
  1858. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1859. cookie_val = *(msg_word + 1);
  1860. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1861. *(msg_word +
  1862. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1863. if (cookie_val) {
  1864. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1865. == QDF_STATUS_SUCCESS) {
  1866. continue;
  1867. }
  1868. }
  1869. cookie_msb = *(msg_word + 2);
  1870. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1871. pdev = soc->pdev_list[pdev_id];
  1872. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1873. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1874. htt_stats->msg_len);
  1875. qdf_nbuf_free(htt_msg);
  1876. continue;
  1877. }
  1878. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1879. copy_stats = true;
  1880. /* read 5th word */
  1881. msg_word = msg_word + 4;
  1882. msg_remain_len = qdf_min(htt_stats->msg_len,
  1883. (uint32_t) DP_EXT_MSG_LENGTH);
  1884. /* Keep processing the node till node length is 0 */
  1885. while (msg_remain_len) {
  1886. /*
  1887. * if message is not a continuation of previous message
  1888. * read the tlv type and tlv length
  1889. */
  1890. if (!tlv_buf_head) {
  1891. tlv_type = HTT_STATS_TLV_TAG_GET(
  1892. *msg_word);
  1893. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1894. *msg_word);
  1895. }
  1896. if (tlv_remain_len == 0) {
  1897. msg_remain_len = 0;
  1898. if (tlv_buf_head) {
  1899. qdf_mem_free(tlv_buf_head);
  1900. tlv_buf_head = NULL;
  1901. tlv_buf_tail = NULL;
  1902. }
  1903. goto error;
  1904. }
  1905. if (!tlv_buf_head)
  1906. tlv_remain_len += HTT_TLV_HDR_LEN;
  1907. if ((tlv_remain_len <= msg_remain_len)) {
  1908. /* Case 3 */
  1909. if (tlv_buf_head) {
  1910. qdf_mem_copy(tlv_buf_tail,
  1911. (uint8_t *)msg_word,
  1912. tlv_remain_len);
  1913. tlv_start = (uint32_t *)tlv_buf_head;
  1914. } else {
  1915. /* Case 1 */
  1916. tlv_start = msg_word;
  1917. }
  1918. if (copy_stats)
  1919. dp_htt_stats_copy_tag(pdev,
  1920. tlv_type,
  1921. tlv_start);
  1922. else
  1923. dp_htt_stats_print_tag(pdev,
  1924. tlv_type,
  1925. tlv_start);
  1926. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1927. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1928. dp_peer_update_inactive_time(pdev,
  1929. tlv_type,
  1930. tlv_start);
  1931. msg_remain_len -= tlv_remain_len;
  1932. msg_word = (uint32_t *)
  1933. (((uint8_t *)msg_word) +
  1934. tlv_remain_len);
  1935. tlv_remain_len = 0;
  1936. if (tlv_buf_head) {
  1937. qdf_mem_free(tlv_buf_head);
  1938. tlv_buf_head = NULL;
  1939. tlv_buf_tail = NULL;
  1940. }
  1941. } else { /* tlv_remain_len > msg_remain_len */
  1942. /* Case 2 & 3 */
  1943. if (!tlv_buf_head) {
  1944. tlv_buf_head = qdf_mem_malloc(
  1945. tlv_remain_len);
  1946. if (!tlv_buf_head) {
  1947. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1948. QDF_TRACE_LEVEL_ERROR,
  1949. "Alloc failed");
  1950. goto error;
  1951. }
  1952. tlv_buf_tail = tlv_buf_head;
  1953. }
  1954. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1955. msg_remain_len);
  1956. tlv_remain_len -= msg_remain_len;
  1957. tlv_buf_tail += msg_remain_len;
  1958. }
  1959. }
  1960. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1961. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1962. }
  1963. qdf_nbuf_free(htt_msg);
  1964. }
  1965. return;
  1966. error:
  1967. qdf_nbuf_free(htt_msg);
  1968. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1969. != NULL)
  1970. qdf_nbuf_free(htt_msg);
  1971. }
  1972. void htt_t2h_stats_handler(void *context)
  1973. {
  1974. struct dp_soc *soc = (struct dp_soc *)context;
  1975. struct htt_stats_context htt_stats;
  1976. uint32_t *msg_word;
  1977. qdf_nbuf_t htt_msg = NULL;
  1978. uint8_t done;
  1979. uint32_t rem_stats;
  1980. if (!soc) {
  1981. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1982. "soc is NULL");
  1983. return;
  1984. }
  1985. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1986. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1987. "soc: 0x%pK, init_done: %d", soc,
  1988. qdf_atomic_read(&soc->cmn_init_done));
  1989. return;
  1990. }
  1991. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1992. qdf_nbuf_queue_init(&htt_stats.msg);
  1993. /* pull one completed stats from soc->htt_stats_msg and process */
  1994. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1995. if (!soc->htt_stats.num_stats) {
  1996. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1997. return;
  1998. }
  1999. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  2000. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  2001. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  2002. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2003. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  2004. /*
  2005. * Done bit signifies that this is the last T2H buffer in the
  2006. * stream of HTT EXT STATS message
  2007. */
  2008. if (done)
  2009. break;
  2010. }
  2011. rem_stats = --soc->htt_stats.num_stats;
  2012. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2013. /* If there are more stats to process, schedule stats work again.
  2014. * Scheduling prior to processing ht_stats to queue with early
  2015. * index
  2016. */
  2017. if (rem_stats)
  2018. qdf_sched_work(0, &soc->htt_stats.work);
  2019. dp_process_htt_stat_msg(&htt_stats, soc);
  2020. }
  2021. /*
  2022. * dp_get_ppdu_info_user_index: Find and allocate a per-user descriptor for a PPDU,
  2023. * if a new peer id arrives in a PPDU
  2024. * pdev: DP pdev handle
  2025. * @peer_id : peer unique identifier
  2026. * @ppdu_info: per ppdu tlv structure
  2027. *
  2028. * return:user index to be populated
  2029. */
  2030. #ifdef FEATURE_PERPKT_INFO
  2031. static uint8_t dp_get_ppdu_info_user_index(struct dp_pdev *pdev,
  2032. uint16_t peer_id,
  2033. struct ppdu_info *ppdu_info)
  2034. {
  2035. uint8_t user_index = 0;
  2036. struct cdp_tx_completion_ppdu *ppdu_desc;
  2037. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2038. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2039. while ((user_index + 1) <= ppdu_info->last_user) {
  2040. ppdu_user_desc = &ppdu_desc->user[user_index];
  2041. if (ppdu_user_desc->peer_id != peer_id) {
  2042. user_index++;
  2043. continue;
  2044. } else {
  2045. /* Max users possible is 8 so user array index should
  2046. * not exceed 7
  2047. */
  2048. qdf_assert_always(user_index <= (ppdu_desc->max_users - 1));
  2049. return user_index;
  2050. }
  2051. }
  2052. ppdu_info->last_user++;
  2053. /* Max users possible is 8 so last user should not exceed 8 */
  2054. qdf_assert_always(ppdu_info->last_user <= ppdu_desc->max_users);
  2055. return ppdu_info->last_user - 1;
  2056. }
  2057. /*
  2058. * dp_process_ppdu_stats_common_tlv: Process htt_ppdu_stats_common_tlv
  2059. * pdev: DP pdev handle
  2060. * @tag_buf: buffer containing the tlv htt_ppdu_stats_common_tlv
  2061. * @ppdu_info: per ppdu tlv structure
  2062. *
  2063. * return:void
  2064. */
  2065. static void dp_process_ppdu_stats_common_tlv(struct dp_pdev *pdev,
  2066. uint32_t *tag_buf, struct ppdu_info *ppdu_info)
  2067. {
  2068. uint16_t frame_type;
  2069. uint16_t frame_ctrl;
  2070. uint16_t freq;
  2071. struct dp_soc *soc = NULL;
  2072. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2073. uint64_t ppdu_start_timestamp;
  2074. uint32_t *start_tag_buf;
  2075. start_tag_buf = tag_buf;
  2076. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2077. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  2078. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RING_ID_SCH_CMD_ID);
  2079. ppdu_info->sched_cmdid =
  2080. HTT_PPDU_STATS_COMMON_TLV_SCH_CMDID_GET(*tag_buf);
  2081. ppdu_desc->num_users =
  2082. HTT_PPDU_STATS_COMMON_TLV_NUM_USERS_GET(*tag_buf);
  2083. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2084. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(QTYPE_FRM_TYPE);
  2085. frame_type = HTT_PPDU_STATS_COMMON_TLV_FRM_TYPE_GET(*tag_buf);
  2086. ppdu_desc->htt_frame_type = frame_type;
  2087. frame_ctrl = ppdu_desc->frame_ctrl;
  2088. ppdu_desc->bar_ppdu_id = ppdu_info->ppdu_id;
  2089. switch (frame_type) {
  2090. case HTT_STATS_FTYPE_TIDQ_DATA_SU:
  2091. case HTT_STATS_FTYPE_TIDQ_DATA_MU:
  2092. case HTT_STATS_FTYPE_SGEN_QOS_NULL:
  2093. /*
  2094. * for management packet, frame type come as DATA_SU
  2095. * need to check frame_ctrl before setting frame_type
  2096. */
  2097. if (HTT_GET_FRAME_CTRL_TYPE(frame_ctrl) <= FRAME_CTRL_TYPE_CTRL)
  2098. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2099. else
  2100. ppdu_desc->frame_type = CDP_PPDU_FTYPE_DATA;
  2101. break;
  2102. case HTT_STATS_FTYPE_SGEN_MU_BAR:
  2103. case HTT_STATS_FTYPE_SGEN_BAR:
  2104. ppdu_desc->frame_type = CDP_PPDU_FTYPE_BAR;
  2105. break;
  2106. default:
  2107. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2108. break;
  2109. }
  2110. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(FES_DUR_US);
  2111. ppdu_desc->tx_duration = *tag_buf;
  2112. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_L32_US);
  2113. ppdu_desc->ppdu_start_timestamp = *tag_buf;
  2114. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(CHAN_MHZ_PHY_MODE);
  2115. freq = HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_GET(*tag_buf);
  2116. if (freq != ppdu_desc->channel) {
  2117. soc = pdev->soc;
  2118. ppdu_desc->channel = freq;
  2119. pdev->operating_channel.freq = freq;
  2120. if (soc && soc->cdp_soc.ol_ops->freq_to_channel)
  2121. pdev->operating_channel.num =
  2122. soc->cdp_soc.ol_ops->freq_to_channel(soc->ctrl_psoc,
  2123. pdev->pdev_id,
  2124. freq);
  2125. if (soc && soc->cdp_soc.ol_ops->freq_to_band)
  2126. pdev->operating_channel.band =
  2127. soc->cdp_soc.ol_ops->freq_to_band(soc->ctrl_psoc,
  2128. pdev->pdev_id,
  2129. freq);
  2130. }
  2131. ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
  2132. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RESV_NUM_UL_BEAM);
  2133. ppdu_desc->phy_ppdu_tx_time_us =
  2134. HTT_PPDU_STATS_COMMON_TLV_PHY_PPDU_TX_TIME_US_GET(*tag_buf);
  2135. ppdu_desc->beam_change =
  2136. HTT_PPDU_STATS_COMMON_TLV_BEAM_CHANGE_GET(*tag_buf);
  2137. ppdu_desc->doppler =
  2138. HTT_PPDU_STATS_COMMON_TLV_DOPPLER_INDICATION_GET(*tag_buf);
  2139. ppdu_desc->spatial_reuse =
  2140. HTT_PPDU_STATS_COMMON_TLV_SPATIAL_REUSE_GET(*tag_buf);
  2141. dp_tx_capture_htt_frame_counter(pdev, frame_type);
  2142. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_U32_US);
  2143. ppdu_start_timestamp = *tag_buf;
  2144. ppdu_desc->ppdu_start_timestamp |= ((ppdu_start_timestamp <<
  2145. HTT_SHIFT_UPPER_TIMESTAMP) &
  2146. HTT_MASK_UPPER_TIMESTAMP);
  2147. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2148. ppdu_desc->tx_duration;
  2149. /* Ack time stamp is same as end time stamp*/
  2150. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2151. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2152. ppdu_desc->tx_duration;
  2153. ppdu_desc->bar_ppdu_start_timestamp = ppdu_desc->ppdu_start_timestamp;
  2154. ppdu_desc->bar_ppdu_end_timestamp = ppdu_desc->ppdu_end_timestamp;
  2155. ppdu_desc->bar_tx_duration = ppdu_desc->tx_duration;
  2156. /* Ack time stamp is same as end time stamp*/
  2157. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2158. }
  2159. /*
  2160. * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
  2161. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
  2162. * @ppdu_info: per ppdu tlv structure
  2163. *
  2164. * return:void
  2165. */
  2166. static void dp_process_ppdu_stats_user_common_tlv(
  2167. struct dp_pdev *pdev, uint32_t *tag_buf,
  2168. struct ppdu_info *ppdu_info)
  2169. {
  2170. uint16_t peer_id;
  2171. struct cdp_tx_completion_ppdu *ppdu_desc;
  2172. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2173. uint8_t curr_user_index = 0;
  2174. struct dp_peer *peer;
  2175. struct dp_vdev *vdev;
  2176. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2177. ppdu_desc =
  2178. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2179. tag_buf++;
  2180. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2181. curr_user_index =
  2182. dp_get_ppdu_info_user_index(pdev,
  2183. peer_id, ppdu_info);
  2184. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2185. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2186. ppdu_desc->vdev_id =
  2187. HTT_PPDU_STATS_USER_COMMON_TLV_VAP_ID_GET(*tag_buf);
  2188. ppdu_user_desc->peer_id = peer_id;
  2189. tag_buf++;
  2190. if (HTT_PPDU_STATS_USER_COMMON_TLV_DELAYED_BA_GET(*tag_buf)) {
  2191. ppdu_user_desc->delayed_ba = 1;
  2192. ppdu_desc->delayed_ba = 1;
  2193. }
  2194. if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
  2195. ppdu_user_desc->is_mcast = true;
  2196. ppdu_user_desc->mpdu_tried_mcast =
  2197. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2198. ppdu_user_desc->num_mpdu = ppdu_user_desc->mpdu_tried_mcast;
  2199. } else {
  2200. ppdu_user_desc->mpdu_tried_ucast =
  2201. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2202. }
  2203. tag_buf++;
  2204. ppdu_user_desc->qos_ctrl =
  2205. HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
  2206. ppdu_user_desc->frame_ctrl =
  2207. HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
  2208. ppdu_desc->frame_ctrl = ppdu_user_desc->frame_ctrl;
  2209. if (ppdu_user_desc->delayed_ba)
  2210. ppdu_user_desc->mpdu_success = 0;
  2211. tag_buf += 3;
  2212. if (HTT_PPDU_STATS_IS_OPAQUE_VALID_GET(*tag_buf)) {
  2213. ppdu_user_desc->ppdu_cookie =
  2214. HTT_PPDU_STATS_HOST_OPAQUE_COOKIE_GET(*tag_buf);
  2215. ppdu_user_desc->is_ppdu_cookie_valid = 1;
  2216. }
  2217. /* returning earlier causes other feilds unpopulated */
  2218. if (peer_id == DP_SCAN_PEER_ID) {
  2219. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2220. DP_MOD_ID_TX_PPDU_STATS);
  2221. if (!vdev)
  2222. return;
  2223. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2224. QDF_MAC_ADDR_SIZE);
  2225. dp_vdev_unref_delete(pdev->soc, vdev, DP_MOD_ID_TX_PPDU_STATS);
  2226. } else {
  2227. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2228. DP_MOD_ID_TX_PPDU_STATS);
  2229. if (!peer) {
  2230. /*
  2231. * fw sends peer_id which is about to removed but
  2232. * it was already removed in host.
  2233. * eg: for disassoc, fw send ppdu stats
  2234. * with peer id equal to previously associated
  2235. * peer's peer_id but it was removed
  2236. */
  2237. vdev = dp_vdev_get_ref_by_id(pdev->soc,
  2238. ppdu_desc->vdev_id,
  2239. DP_MOD_ID_TX_PPDU_STATS);
  2240. if (!vdev)
  2241. return;
  2242. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2243. vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2244. dp_vdev_unref_delete(pdev->soc, vdev,
  2245. DP_MOD_ID_TX_PPDU_STATS);
  2246. return;
  2247. }
  2248. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2249. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2250. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2251. }
  2252. }
  2253. /**
  2254. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  2255. * @pdev: DP pdev handle
  2256. * @tag_buf: T2H message buffer carrying the user rate TLV
  2257. * @ppdu_info: per ppdu tlv structure
  2258. *
  2259. * return:void
  2260. */
  2261. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  2262. uint32_t *tag_buf,
  2263. struct ppdu_info *ppdu_info)
  2264. {
  2265. uint16_t peer_id;
  2266. struct cdp_tx_completion_ppdu *ppdu_desc;
  2267. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2268. uint8_t curr_user_index = 0;
  2269. struct dp_vdev *vdev;
  2270. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2271. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2272. tag_buf++;
  2273. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2274. curr_user_index =
  2275. dp_get_ppdu_info_user_index(pdev,
  2276. peer_id, ppdu_info);
  2277. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2278. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2279. if (peer_id == DP_SCAN_PEER_ID) {
  2280. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2281. DP_MOD_ID_TX_PPDU_STATS);
  2282. if (!vdev)
  2283. return;
  2284. dp_vdev_unref_delete(pdev->soc, vdev,
  2285. DP_MOD_ID_TX_PPDU_STATS);
  2286. }
  2287. ppdu_user_desc->peer_id = peer_id;
  2288. ppdu_user_desc->tid =
  2289. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  2290. tag_buf += 1;
  2291. ppdu_user_desc->user_pos =
  2292. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  2293. ppdu_user_desc->mu_group_id =
  2294. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2295. tag_buf += 1;
  2296. ppdu_user_desc->ru_start =
  2297. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2298. ppdu_user_desc->ru_tones =
  2299. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2300. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2301. ppdu_desc->usr_ru_tones_sum += ppdu_user_desc->ru_tones;
  2302. tag_buf += 2;
  2303. ppdu_user_desc->ppdu_type =
  2304. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2305. tag_buf++;
  2306. ppdu_user_desc->tx_rate = *tag_buf;
  2307. ppdu_user_desc->ltf_size =
  2308. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2309. ppdu_user_desc->stbc =
  2310. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2311. ppdu_user_desc->he_re =
  2312. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2313. ppdu_user_desc->txbf =
  2314. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2315. ppdu_user_desc->bw =
  2316. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2317. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2318. ppdu_desc->usr_nss_sum += ppdu_user_desc->nss;
  2319. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2320. ppdu_user_desc->preamble =
  2321. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2322. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2323. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2324. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2325. }
  2326. /*
  2327. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2328. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2329. * pdev: DP PDEV handle
  2330. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2331. * @ppdu_info: per ppdu tlv structure
  2332. *
  2333. * return:void
  2334. */
  2335. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2336. struct dp_pdev *pdev, uint32_t *tag_buf,
  2337. struct ppdu_info *ppdu_info)
  2338. {
  2339. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2340. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2341. struct cdp_tx_completion_ppdu *ppdu_desc;
  2342. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2343. uint8_t curr_user_index = 0;
  2344. uint16_t peer_id;
  2345. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2346. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2347. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2348. tag_buf++;
  2349. peer_id =
  2350. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2351. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2352. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2353. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2354. ppdu_user_desc->peer_id = peer_id;
  2355. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2356. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2357. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2358. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2359. (void *)ppdu_user_desc,
  2360. ppdu_info->ppdu_id,
  2361. size);
  2362. }
  2363. /*
  2364. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2365. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2366. * soc: DP SOC handle
  2367. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2368. * @ppdu_info: per ppdu tlv structure
  2369. *
  2370. * return:void
  2371. */
  2372. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2373. struct dp_pdev *pdev, uint32_t *tag_buf,
  2374. struct ppdu_info *ppdu_info)
  2375. {
  2376. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2377. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2378. struct cdp_tx_completion_ppdu *ppdu_desc;
  2379. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2380. uint8_t curr_user_index = 0;
  2381. uint16_t peer_id;
  2382. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2383. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2384. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2385. tag_buf++;
  2386. peer_id =
  2387. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2388. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2389. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2390. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2391. ppdu_user_desc->peer_id = peer_id;
  2392. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2393. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2394. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2395. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2396. (void *)ppdu_user_desc,
  2397. ppdu_info->ppdu_id,
  2398. size);
  2399. }
  2400. /*
  2401. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2402. * htt_ppdu_stats_user_cmpltn_common_tlv
  2403. * soc: DP SOC handle
  2404. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2405. * @ppdu_info: per ppdu tlv structure
  2406. *
  2407. * return:void
  2408. */
  2409. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2410. struct dp_pdev *pdev, uint32_t *tag_buf,
  2411. struct ppdu_info *ppdu_info)
  2412. {
  2413. uint16_t peer_id;
  2414. struct cdp_tx_completion_ppdu *ppdu_desc;
  2415. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2416. uint8_t curr_user_index = 0;
  2417. uint8_t bw_iter;
  2418. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2419. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2420. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2421. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2422. tag_buf++;
  2423. peer_id =
  2424. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2425. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2426. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2427. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2428. ppdu_user_desc->peer_id = peer_id;
  2429. ppdu_user_desc->completion_status =
  2430. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2431. *tag_buf);
  2432. ppdu_user_desc->tid =
  2433. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2434. tag_buf++;
  2435. if (qdf_likely(ppdu_user_desc->completion_status ==
  2436. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2437. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2438. ppdu_user_desc->usr_ack_rssi = dp_stats_buf->ack_rssi;
  2439. ppdu_user_desc->ack_rssi_valid = 1;
  2440. } else {
  2441. ppdu_user_desc->ack_rssi_valid = 0;
  2442. }
  2443. tag_buf++;
  2444. ppdu_user_desc->mpdu_success =
  2445. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2446. ppdu_user_desc->mpdu_failed =
  2447. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2448. ppdu_user_desc->mpdu_success;
  2449. tag_buf++;
  2450. ppdu_user_desc->long_retries =
  2451. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2452. ppdu_user_desc->short_retries =
  2453. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2454. ppdu_user_desc->retry_msdus =
  2455. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2456. ppdu_user_desc->is_ampdu =
  2457. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2458. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2459. ppdu_desc->resp_type =
  2460. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RESP_TYPE_GET(*tag_buf);
  2461. ppdu_desc->mprot_type =
  2462. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPROT_TYPE_GET(*tag_buf);
  2463. ppdu_desc->rts_success =
  2464. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_SUCCESS_GET(*tag_buf);
  2465. ppdu_desc->rts_failure =
  2466. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_FAILURE_GET(*tag_buf);
  2467. ppdu_user_desc->pream_punct =
  2468. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PREAM_PUNC_TX_GET(*tag_buf);
  2469. ppdu_info->compltn_common_tlv++;
  2470. /*
  2471. * MU BAR may send request to n users but we may received ack only from
  2472. * m users. To have count of number of users respond back, we have a
  2473. * separate counter bar_num_users per PPDU that get increment for every
  2474. * htt_ppdu_stats_user_cmpltn_common_tlv
  2475. */
  2476. ppdu_desc->bar_num_users++;
  2477. tag_buf++;
  2478. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2479. ppdu_user_desc->rssi_chain[bw_iter] =
  2480. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2481. tag_buf++;
  2482. }
  2483. ppdu_user_desc->sa_tx_antenna =
  2484. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2485. tag_buf++;
  2486. ppdu_user_desc->sa_is_training =
  2487. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2488. if (ppdu_user_desc->sa_is_training) {
  2489. ppdu_user_desc->sa_goodput =
  2490. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2491. }
  2492. tag_buf++;
  2493. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2494. ppdu_user_desc->sa_max_rates[bw_iter] =
  2495. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2496. }
  2497. tag_buf += CDP_NUM_SA_BW;
  2498. ppdu_user_desc->current_rate_per =
  2499. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2500. }
  2501. /*
  2502. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2503. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2504. * pdev: DP PDEV handle
  2505. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2506. * @ppdu_info: per ppdu tlv structure
  2507. *
  2508. * return:void
  2509. */
  2510. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2511. struct dp_pdev *pdev, uint32_t *tag_buf,
  2512. struct ppdu_info *ppdu_info)
  2513. {
  2514. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2515. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2516. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2517. struct cdp_tx_completion_ppdu *ppdu_desc;
  2518. uint8_t curr_user_index = 0;
  2519. uint16_t peer_id;
  2520. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2521. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2522. tag_buf++;
  2523. peer_id =
  2524. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2525. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2526. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2527. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2528. ppdu_user_desc->peer_id = peer_id;
  2529. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2530. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2531. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2532. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2533. }
  2534. /*
  2535. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2536. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2537. * pdev: DP PDEV handle
  2538. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2539. * @ppdu_info: per ppdu tlv structure
  2540. *
  2541. * return:void
  2542. */
  2543. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2544. struct dp_pdev *pdev, uint32_t *tag_buf,
  2545. struct ppdu_info *ppdu_info)
  2546. {
  2547. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2548. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2549. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2550. struct cdp_tx_completion_ppdu *ppdu_desc;
  2551. uint8_t curr_user_index = 0;
  2552. uint16_t peer_id;
  2553. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2554. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2555. tag_buf++;
  2556. peer_id =
  2557. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2558. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2559. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2560. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2561. ppdu_user_desc->peer_id = peer_id;
  2562. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2563. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2564. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2565. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2566. }
  2567. /*
  2568. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2569. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2570. * pdev: DP PDE handle
  2571. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2572. * @ppdu_info: per ppdu tlv structure
  2573. *
  2574. * return:void
  2575. */
  2576. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2577. struct dp_pdev *pdev, uint32_t *tag_buf,
  2578. struct ppdu_info *ppdu_info)
  2579. {
  2580. uint16_t peer_id;
  2581. struct cdp_tx_completion_ppdu *ppdu_desc;
  2582. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2583. uint8_t curr_user_index = 0;
  2584. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2585. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2586. tag_buf += 2;
  2587. peer_id =
  2588. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2589. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2590. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2591. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2592. if (!ppdu_user_desc->ack_ba_tlv) {
  2593. ppdu_user_desc->ack_ba_tlv = 1;
  2594. } else {
  2595. pdev->stats.ack_ba_comes_twice++;
  2596. return;
  2597. }
  2598. ppdu_user_desc->peer_id = peer_id;
  2599. tag_buf++;
  2600. /* not to update ppdu_desc->tid from this TLV */
  2601. ppdu_user_desc->num_mpdu =
  2602. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2603. ppdu_user_desc->num_msdu =
  2604. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2605. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2606. tag_buf++;
  2607. ppdu_user_desc->start_seq =
  2608. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2609. *tag_buf);
  2610. tag_buf++;
  2611. ppdu_user_desc->success_bytes = *tag_buf;
  2612. /* increase ack ba tlv counter on successful mpdu */
  2613. if (ppdu_user_desc->num_mpdu)
  2614. ppdu_info->ack_ba_tlv++;
  2615. if (ppdu_user_desc->ba_size == 0) {
  2616. ppdu_user_desc->ba_seq_no = ppdu_user_desc->start_seq;
  2617. ppdu_user_desc->ba_bitmap[0] = 1;
  2618. ppdu_user_desc->ba_size = 1;
  2619. }
  2620. }
  2621. /*
  2622. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2623. * htt_ppdu_stats_user_common_array_tlv
  2624. * pdev: DP PDEV handle
  2625. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2626. * @ppdu_info: per ppdu tlv structure
  2627. *
  2628. * return:void
  2629. */
  2630. static void dp_process_ppdu_stats_user_common_array_tlv(
  2631. struct dp_pdev *pdev, uint32_t *tag_buf,
  2632. struct ppdu_info *ppdu_info)
  2633. {
  2634. uint32_t peer_id;
  2635. struct cdp_tx_completion_ppdu *ppdu_desc;
  2636. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2637. uint8_t curr_user_index = 0;
  2638. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2639. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2640. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2641. tag_buf++;
  2642. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2643. tag_buf += 3;
  2644. peer_id =
  2645. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2646. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2647. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2648. "Invalid peer");
  2649. return;
  2650. }
  2651. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2652. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2653. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2654. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2655. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2656. tag_buf++;
  2657. ppdu_user_desc->success_msdus =
  2658. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2659. ppdu_user_desc->retry_bytes =
  2660. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2661. tag_buf++;
  2662. ppdu_user_desc->failed_msdus =
  2663. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2664. }
  2665. /*
  2666. * dp_process_ppdu_stats_flush_tlv: Process
  2667. * htt_ppdu_stats_flush_tlv
  2668. * @pdev: DP PDEV handle
  2669. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2670. * @ppdu_info: per ppdu tlv structure
  2671. *
  2672. * return:void
  2673. */
  2674. static void
  2675. dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2676. uint32_t *tag_buf,
  2677. struct ppdu_info *ppdu_info)
  2678. {
  2679. struct cdp_tx_completion_ppdu *ppdu_desc;
  2680. uint32_t peer_id;
  2681. uint8_t tid;
  2682. struct dp_peer *peer;
  2683. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2684. qdf_nbuf_data(ppdu_info->nbuf);
  2685. ppdu_desc->is_flush = 1;
  2686. tag_buf++;
  2687. ppdu_desc->drop_reason = *tag_buf;
  2688. tag_buf++;
  2689. ppdu_desc->num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2690. ppdu_desc->num_mpdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MPDU_GET(*tag_buf);
  2691. ppdu_desc->flow_type = HTT_PPDU_STATS_FLUSH_TLV_FLOW_TYPE_GET(*tag_buf);
  2692. tag_buf++;
  2693. peer_id = HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2694. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2695. ppdu_desc->num_users = 1;
  2696. ppdu_desc->user[0].peer_id = peer_id;
  2697. ppdu_desc->user[0].tid = tid;
  2698. ppdu_desc->queue_type =
  2699. HTT_PPDU_STATS_FLUSH_TLV_QUEUE_TYPE_GET(*tag_buf);
  2700. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2701. DP_MOD_ID_TX_PPDU_STATS);
  2702. if (!peer)
  2703. goto add_ppdu_to_sched_list;
  2704. if (ppdu_desc->drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2705. DP_STATS_INC(peer,
  2706. tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2707. ppdu_desc->num_msdu);
  2708. }
  2709. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2710. add_ppdu_to_sched_list:
  2711. ppdu_info->done = 1;
  2712. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2713. pdev->list_depth--;
  2714. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2715. ppdu_info_list_elem);
  2716. pdev->sched_comp_list_depth++;
  2717. }
  2718. /**
  2719. * dp_process_ppdu_stats_sch_cmd_status_tlv: Process schedule command status tlv
  2720. * Here we are not going to process the buffer.
  2721. * @pdev: DP PDEV handle
  2722. * @ppdu_info: per ppdu tlv structure
  2723. *
  2724. * return:void
  2725. */
  2726. static void
  2727. dp_process_ppdu_stats_sch_cmd_status_tlv(struct dp_pdev *pdev,
  2728. struct ppdu_info *ppdu_info)
  2729. {
  2730. struct cdp_tx_completion_ppdu *ppdu_desc;
  2731. struct dp_peer *peer;
  2732. uint8_t num_users;
  2733. uint8_t i;
  2734. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2735. qdf_nbuf_data(ppdu_info->nbuf);
  2736. num_users = ppdu_desc->bar_num_users;
  2737. for (i = 0; i < num_users; i++) {
  2738. if (ppdu_desc->user[i].user_pos == 0) {
  2739. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2740. /* update phy mode for bar frame */
  2741. ppdu_desc->phy_mode =
  2742. ppdu_desc->user[i].preamble;
  2743. ppdu_desc->user[0].mcs = ppdu_desc->user[i].mcs;
  2744. break;
  2745. }
  2746. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_CTRL) {
  2747. ppdu_desc->frame_ctrl =
  2748. ppdu_desc->user[i].frame_ctrl;
  2749. break;
  2750. }
  2751. }
  2752. }
  2753. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2754. ppdu_desc->delayed_ba) {
  2755. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2756. for (i = 0; i < ppdu_desc->num_users; i++) {
  2757. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2758. uint64_t start_tsf;
  2759. uint64_t end_tsf;
  2760. uint32_t ppdu_id;
  2761. ppdu_id = ppdu_desc->ppdu_id;
  2762. peer = dp_peer_get_ref_by_id
  2763. (pdev->soc, ppdu_desc->user[i].peer_id,
  2764. DP_MOD_ID_TX_PPDU_STATS);
  2765. /**
  2766. * This check is to make sure peer is not deleted
  2767. * after processing the TLVs.
  2768. */
  2769. if (!peer)
  2770. continue;
  2771. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2772. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2773. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2774. /**
  2775. * save delayed ba user info
  2776. */
  2777. if (ppdu_desc->user[i].delayed_ba) {
  2778. dp_peer_copy_delay_stats(peer,
  2779. &ppdu_desc->user[i],
  2780. ppdu_id);
  2781. peer->last_delayed_ba_ppduid = ppdu_id;
  2782. delay_ppdu->ppdu_start_timestamp = start_tsf;
  2783. delay_ppdu->ppdu_end_timestamp = end_tsf;
  2784. }
  2785. ppdu_desc->user[i].peer_last_delayed_ba =
  2786. peer->last_delayed_ba;
  2787. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2788. if (ppdu_desc->user[i].delayed_ba &&
  2789. !ppdu_desc->user[i].debug_copied) {
  2790. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2791. QDF_TRACE_LEVEL_INFO_MED,
  2792. "%s: %d ppdu_id[%d] bar_ppdu_id[%d] num_users[%d] usr[%d] htt_frame_type[%d]\n",
  2793. __func__, __LINE__,
  2794. ppdu_desc->ppdu_id,
  2795. ppdu_desc->bar_ppdu_id,
  2796. ppdu_desc->num_users,
  2797. i,
  2798. ppdu_desc->htt_frame_type);
  2799. }
  2800. }
  2801. }
  2802. /*
  2803. * when frame type is BAR and STATS_COMMON_TLV is set
  2804. * copy the store peer delayed info to BAR status
  2805. */
  2806. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2807. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2808. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2809. uint64_t start_tsf;
  2810. uint64_t end_tsf;
  2811. peer = dp_peer_get_ref_by_id
  2812. (pdev->soc,
  2813. ppdu_desc->user[i].peer_id,
  2814. DP_MOD_ID_TX_PPDU_STATS);
  2815. /**
  2816. * This check is to make sure peer is not deleted
  2817. * after processing the TLVs.
  2818. */
  2819. if (!peer)
  2820. continue;
  2821. if (ppdu_desc->user[i].completion_status !=
  2822. HTT_PPDU_STATS_USER_STATUS_OK) {
  2823. dp_peer_unref_delete(peer,
  2824. DP_MOD_ID_TX_PPDU_STATS);
  2825. continue;
  2826. }
  2827. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2828. start_tsf = delay_ppdu->ppdu_start_timestamp;
  2829. end_tsf = delay_ppdu->ppdu_end_timestamp;
  2830. if (peer->last_delayed_ba) {
  2831. dp_peer_copy_stats_to_bar(peer,
  2832. &ppdu_desc->user[i]);
  2833. ppdu_desc->ppdu_id =
  2834. peer->last_delayed_ba_ppduid;
  2835. ppdu_desc->ppdu_start_timestamp = start_tsf;
  2836. ppdu_desc->ppdu_end_timestamp = end_tsf;
  2837. }
  2838. ppdu_desc->user[i].peer_last_delayed_ba =
  2839. peer->last_delayed_ba;
  2840. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2841. }
  2842. }
  2843. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2844. pdev->list_depth--;
  2845. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2846. ppdu_info_list_elem);
  2847. pdev->sched_comp_list_depth++;
  2848. }
  2849. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2850. /*
  2851. * dp_deliver_mgmt_frm: Process
  2852. * @pdev: DP PDEV handle
  2853. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2854. *
  2855. * return: void
  2856. */
  2857. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2858. {
  2859. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2860. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2861. nbuf, HTT_INVALID_PEER,
  2862. WDI_NO_VAL, pdev->pdev_id);
  2863. } else {
  2864. if (!pdev->bpr_enable)
  2865. qdf_nbuf_free(nbuf);
  2866. }
  2867. }
  2868. #endif
  2869. /*
  2870. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2871. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2872. * @pdev: DP PDEV handle
  2873. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2874. * @length: tlv_length
  2875. *
  2876. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2877. */
  2878. static QDF_STATUS
  2879. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2880. qdf_nbuf_t tag_buf,
  2881. uint32_t ppdu_id)
  2882. {
  2883. uint32_t *nbuf_ptr;
  2884. uint8_t trim_size;
  2885. size_t head_size;
  2886. struct cdp_tx_mgmt_comp_info *ptr_mgmt_comp_info;
  2887. uint32_t *msg_word;
  2888. uint32_t tsf_hdr;
  2889. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2890. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2891. return QDF_STATUS_SUCCESS;
  2892. /*
  2893. * get timestamp from htt_t2h_ppdu_stats_ind_hdr_t
  2894. */
  2895. msg_word = (uint32_t *)qdf_nbuf_data(tag_buf);
  2896. msg_word = msg_word + 2;
  2897. tsf_hdr = *msg_word;
  2898. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2899. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2900. qdf_nbuf_data(tag_buf));
  2901. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2902. return QDF_STATUS_SUCCESS;
  2903. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2904. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2905. if (pdev->tx_capture_enabled) {
  2906. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  2907. if (qdf_unlikely(qdf_nbuf_headroom(tag_buf) < head_size)) {
  2908. qdf_err("Fail to get headroom h_sz %d h_avail %d\n",
  2909. head_size, qdf_nbuf_headroom(tag_buf));
  2910. qdf_assert_always(0);
  2911. return QDF_STATUS_E_NOMEM;
  2912. }
  2913. ptr_mgmt_comp_info = (struct cdp_tx_mgmt_comp_info *)
  2914. qdf_nbuf_push_head(tag_buf, head_size);
  2915. qdf_assert_always(ptr_mgmt_comp_info);
  2916. ptr_mgmt_comp_info->ppdu_id = ppdu_id;
  2917. ptr_mgmt_comp_info->is_sgen_pkt = true;
  2918. ptr_mgmt_comp_info->tx_tsf = tsf_hdr;
  2919. } else {
  2920. head_size = sizeof(ppdu_id);
  2921. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(tag_buf, head_size);
  2922. *nbuf_ptr = ppdu_id;
  2923. }
  2924. if (pdev->bpr_enable) {
  2925. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2926. tag_buf, HTT_INVALID_PEER,
  2927. WDI_NO_VAL, pdev->pdev_id);
  2928. }
  2929. dp_deliver_mgmt_frm(pdev, tag_buf);
  2930. return QDF_STATUS_E_ALREADY;
  2931. }
  2932. /**
  2933. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2934. *
  2935. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2936. * size of corresponding data structure, pad the remaining bytes with zeros
  2937. * and continue processing the TLVs
  2938. *
  2939. * @pdev: DP pdev handle
  2940. * @tag_buf: TLV buffer
  2941. * @tlv_expected_size: Expected size of Tag
  2942. * @tlv_len: TLV length received from FW
  2943. *
  2944. * Return: Pointer to updated TLV
  2945. */
  2946. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  2947. uint32_t *tag_buf,
  2948. uint16_t tlv_expected_size,
  2949. uint16_t tlv_len)
  2950. {
  2951. uint32_t *tlv_desc = tag_buf;
  2952. qdf_assert_always(tlv_len != 0);
  2953. if (tlv_len < tlv_expected_size) {
  2954. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  2955. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  2956. tlv_desc = pdev->ppdu_tlv_buf;
  2957. }
  2958. return tlv_desc;
  2959. }
  2960. /**
  2961. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  2962. * @pdev: DP pdev handle
  2963. * @tag_buf: TLV buffer
  2964. * @tlv_len: length of tlv
  2965. * @ppdu_info: per ppdu tlv structure
  2966. *
  2967. * return: void
  2968. */
  2969. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  2970. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  2971. {
  2972. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2973. uint16_t tlv_expected_size;
  2974. uint32_t *tlv_desc;
  2975. switch (tlv_type) {
  2976. case HTT_PPDU_STATS_COMMON_TLV:
  2977. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  2978. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2979. tlv_expected_size, tlv_len);
  2980. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  2981. break;
  2982. case HTT_PPDU_STATS_USR_COMMON_TLV:
  2983. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  2984. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2985. tlv_expected_size, tlv_len);
  2986. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  2987. ppdu_info);
  2988. break;
  2989. case HTT_PPDU_STATS_USR_RATE_TLV:
  2990. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  2991. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2992. tlv_expected_size, tlv_len);
  2993. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  2994. ppdu_info);
  2995. break;
  2996. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  2997. tlv_expected_size =
  2998. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  2999. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3000. tlv_expected_size, tlv_len);
  3001. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  3002. pdev, tlv_desc, ppdu_info);
  3003. break;
  3004. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  3005. tlv_expected_size =
  3006. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  3007. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3008. tlv_expected_size, tlv_len);
  3009. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  3010. pdev, tlv_desc, ppdu_info);
  3011. break;
  3012. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  3013. tlv_expected_size =
  3014. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  3015. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3016. tlv_expected_size, tlv_len);
  3017. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  3018. pdev, tlv_desc, ppdu_info);
  3019. break;
  3020. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  3021. tlv_expected_size =
  3022. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  3023. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3024. tlv_expected_size, tlv_len);
  3025. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  3026. pdev, tlv_desc, ppdu_info);
  3027. break;
  3028. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  3029. tlv_expected_size =
  3030. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  3031. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3032. tlv_expected_size, tlv_len);
  3033. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  3034. pdev, tlv_desc, ppdu_info);
  3035. break;
  3036. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  3037. tlv_expected_size =
  3038. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  3039. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3040. tlv_expected_size, tlv_len);
  3041. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  3042. pdev, tlv_desc, ppdu_info);
  3043. break;
  3044. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  3045. tlv_expected_size =
  3046. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  3047. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3048. tlv_expected_size, tlv_len);
  3049. dp_process_ppdu_stats_user_common_array_tlv(
  3050. pdev, tlv_desc, ppdu_info);
  3051. break;
  3052. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  3053. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  3054. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3055. tlv_expected_size, tlv_len);
  3056. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev, tlv_desc,
  3057. ppdu_info);
  3058. break;
  3059. case HTT_PPDU_STATS_SCH_CMD_STATUS_TLV:
  3060. dp_process_ppdu_stats_sch_cmd_status_tlv(pdev, ppdu_info);
  3061. break;
  3062. default:
  3063. break;
  3064. }
  3065. }
  3066. #ifdef WLAN_ATF_ENABLE
  3067. static void
  3068. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3069. struct cdp_tx_completion_ppdu *ppdu_desc,
  3070. struct cdp_tx_completion_ppdu_user *user)
  3071. {
  3072. uint32_t nss_ru_width_sum = 0;
  3073. if (!pdev || !ppdu_desc || !user)
  3074. return;
  3075. if (!pdev->dp_atf_stats_enable)
  3076. return;
  3077. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_DATA)
  3078. return;
  3079. nss_ru_width_sum = ppdu_desc->usr_nss_sum * ppdu_desc->usr_ru_tones_sum;
  3080. if (!nss_ru_width_sum)
  3081. nss_ru_width_sum = 1;
  3082. /**
  3083. * For SU-MIMO PPDU phy Tx time is same for the single user.
  3084. * For MU-MIMO phy Tx time is calculated per user as below
  3085. * user phy tx time =
  3086. * Entire PPDU duration * MU Ratio * OFDMA Ratio
  3087. * MU Ratio = usr_nss / Sum_of_nss_of_all_users
  3088. * OFDMA_ratio = usr_ru_width / Sum_of_ru_width_of_all_users
  3089. * usr_ru_widt = ru_end – ru_start + 1
  3090. */
  3091. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) {
  3092. user->phy_tx_time_us = ppdu_desc->phy_ppdu_tx_time_us;
  3093. } else {
  3094. user->phy_tx_time_us = (ppdu_desc->phy_ppdu_tx_time_us *
  3095. user->nss * user->ru_tones) / nss_ru_width_sum;
  3096. }
  3097. }
  3098. #else
  3099. static void
  3100. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3101. struct cdp_tx_completion_ppdu *ppdu_desc,
  3102. struct cdp_tx_completion_ppdu_user *user)
  3103. {
  3104. }
  3105. #endif
  3106. /**
  3107. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  3108. * @pdev: DP pdev handle
  3109. * @ppdu_info: per PPDU TLV descriptor
  3110. *
  3111. * return: void
  3112. */
  3113. void
  3114. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  3115. struct ppdu_info *ppdu_info)
  3116. {
  3117. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3118. struct dp_peer *peer = NULL;
  3119. uint32_t tlv_bitmap_expected;
  3120. uint32_t tlv_bitmap_default;
  3121. uint16_t i;
  3122. uint32_t num_users;
  3123. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3124. qdf_nbuf_data(ppdu_info->nbuf);
  3125. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_BAR)
  3126. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  3127. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3128. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3129. pdev->tx_capture_enabled) {
  3130. if (ppdu_info->is_ampdu)
  3131. tlv_bitmap_expected =
  3132. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3133. ppdu_info->tlv_bitmap);
  3134. }
  3135. tlv_bitmap_default = tlv_bitmap_expected;
  3136. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  3137. num_users = ppdu_desc->bar_num_users;
  3138. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  3139. } else {
  3140. num_users = ppdu_desc->num_users;
  3141. }
  3142. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  3143. for (i = 0; i < num_users; i++) {
  3144. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  3145. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  3146. peer = dp_peer_get_ref_by_id(pdev->soc,
  3147. ppdu_desc->user[i].peer_id,
  3148. DP_MOD_ID_TX_PPDU_STATS);
  3149. /**
  3150. * This check is to make sure peer is not deleted
  3151. * after processing the TLVs.
  3152. */
  3153. if (!peer)
  3154. continue;
  3155. /*
  3156. * different frame like DATA, BAR or CTRL has different
  3157. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  3158. * receive other tlv in-order/sequential from fw.
  3159. * Since ACK_BA_STATUS TLV come from Hardware it is
  3160. * asynchronous So we need to depend on some tlv to confirm
  3161. * all tlv is received for a ppdu.
  3162. * So we depend on both SCHED_CMD_STATUS_TLV and
  3163. * ACK_BA_STATUS_TLV. for failure packet we won't get
  3164. * ACK_BA_STATUS_TLV.
  3165. */
  3166. if (!(ppdu_info->tlv_bitmap &
  3167. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)) ||
  3168. (!(ppdu_info->tlv_bitmap &
  3169. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)) &&
  3170. (ppdu_desc->user[i].completion_status ==
  3171. HTT_PPDU_STATS_USER_STATUS_OK))) {
  3172. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3173. continue;
  3174. }
  3175. /**
  3176. * Update tx stats for data frames having Qos as well as
  3177. * non-Qos data tid
  3178. */
  3179. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  3180. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID) ||
  3181. (ppdu_desc->htt_frame_type ==
  3182. HTT_STATS_FTYPE_SGEN_QOS_NULL) ||
  3183. ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) &&
  3184. (ppdu_desc->num_mpdu > 1))) &&
  3185. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  3186. dp_tx_stats_update(pdev, peer,
  3187. &ppdu_desc->user[i],
  3188. ppdu_desc->ack_rssi);
  3189. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  3190. }
  3191. dp_ppdu_desc_user_phy_tx_time_update(pdev, ppdu_desc,
  3192. &ppdu_desc->user[i]);
  3193. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3194. tlv_bitmap_expected = tlv_bitmap_default;
  3195. }
  3196. }
  3197. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  3198. /**
  3199. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  3200. * to upper layer
  3201. * @pdev: DP pdev handle
  3202. * @ppdu_info: per PPDU TLV descriptor
  3203. *
  3204. * return: void
  3205. */
  3206. static
  3207. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  3208. struct ppdu_info *ppdu_info)
  3209. {
  3210. struct ppdu_info *s_ppdu_info = NULL;
  3211. struct ppdu_info *ppdu_info_next = NULL;
  3212. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3213. qdf_nbuf_t nbuf;
  3214. uint32_t time_delta = 0;
  3215. bool starved = 0;
  3216. bool matched = 0;
  3217. bool recv_ack_ba_done = 0;
  3218. if (ppdu_info->tlv_bitmap &
  3219. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3220. ppdu_info->done)
  3221. recv_ack_ba_done = 1;
  3222. pdev->last_sched_cmdid = ppdu_info->sched_cmdid;
  3223. s_ppdu_info = TAILQ_FIRST(&pdev->sched_comp_ppdu_list);
  3224. TAILQ_FOREACH_SAFE(s_ppdu_info, &pdev->sched_comp_ppdu_list,
  3225. ppdu_info_list_elem, ppdu_info_next) {
  3226. if (s_ppdu_info->tsf_l32 > ppdu_info->tsf_l32)
  3227. time_delta = (MAX_TSF_32 - s_ppdu_info->tsf_l32) +
  3228. ppdu_info->tsf_l32;
  3229. else
  3230. time_delta = ppdu_info->tsf_l32 - s_ppdu_info->tsf_l32;
  3231. if (!s_ppdu_info->done && !recv_ack_ba_done) {
  3232. if (time_delta < MAX_SCHED_STARVE) {
  3233. dp_info("pdev[%d] ppdu_id[%d] sched_cmdid[%d] TLV_B[0x%x] TSF[%u] D[%d]",
  3234. pdev->pdev_id,
  3235. s_ppdu_info->ppdu_id,
  3236. s_ppdu_info->sched_cmdid,
  3237. s_ppdu_info->tlv_bitmap,
  3238. s_ppdu_info->tsf_l32,
  3239. s_ppdu_info->done);
  3240. break;
  3241. }
  3242. starved = 1;
  3243. }
  3244. pdev->delivered_sched_cmdid = s_ppdu_info->sched_cmdid;
  3245. TAILQ_REMOVE(&pdev->sched_comp_ppdu_list, s_ppdu_info,
  3246. ppdu_info_list_elem);
  3247. pdev->sched_comp_list_depth--;
  3248. nbuf = s_ppdu_info->nbuf;
  3249. qdf_assert_always(nbuf);
  3250. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3251. qdf_nbuf_data(nbuf);
  3252. ppdu_desc->tlv_bitmap = s_ppdu_info->tlv_bitmap;
  3253. if (starved) {
  3254. dp_err("ppdu starved fc[0x%x] h_ftype[%d] tlv_bitmap[0x%x] cs[%d]\n",
  3255. ppdu_desc->frame_ctrl,
  3256. ppdu_desc->htt_frame_type,
  3257. ppdu_desc->tlv_bitmap,
  3258. ppdu_desc->user[0].completion_status);
  3259. starved = 0;
  3260. }
  3261. if (ppdu_info->ppdu_id == s_ppdu_info->ppdu_id &&
  3262. ppdu_info->sched_cmdid == s_ppdu_info->sched_cmdid)
  3263. matched = 1;
  3264. dp_ppdu_desc_user_stats_update(pdev, s_ppdu_info);
  3265. qdf_mem_free(s_ppdu_info);
  3266. /**
  3267. * Deliver PPDU stats only for valid (acked) data
  3268. * frames if sniffer mode is not enabled.
  3269. * If sniffer mode is enabled, PPDU stats
  3270. * for all frames including mgmt/control
  3271. * frames should be delivered to upper layer
  3272. */
  3273. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  3274. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3275. pdev->soc,
  3276. nbuf, HTT_INVALID_PEER,
  3277. WDI_NO_VAL,
  3278. pdev->pdev_id);
  3279. } else {
  3280. if (ppdu_desc->num_mpdu != 0 &&
  3281. ppdu_desc->num_users != 0 &&
  3282. ppdu_desc->frame_ctrl &
  3283. HTT_FRAMECTRL_DATATYPE) {
  3284. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3285. pdev->soc,
  3286. nbuf, HTT_INVALID_PEER,
  3287. WDI_NO_VAL,
  3288. pdev->pdev_id);
  3289. } else {
  3290. qdf_nbuf_free(nbuf);
  3291. }
  3292. }
  3293. if (matched)
  3294. break;
  3295. }
  3296. return;
  3297. }
  3298. #endif
  3299. /**
  3300. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  3301. * desc for new ppdu id
  3302. * @pdev: DP pdev handle
  3303. * @ppdu_id: PPDU unique identifier
  3304. * @tlv_type: TLV type received
  3305. * @tsf_l32: timestamp received along with ppdu stats indication header
  3306. * @max_users: Maximum user for that particular ppdu
  3307. *
  3308. * return: ppdu_info per ppdu tlv structure
  3309. */
  3310. static
  3311. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  3312. uint8_t tlv_type, uint32_t tsf_l32,
  3313. uint8_t max_users)
  3314. {
  3315. struct ppdu_info *ppdu_info = NULL;
  3316. struct ppdu_info *s_ppdu_info = NULL;
  3317. struct ppdu_info *ppdu_info_next = NULL;
  3318. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3319. uint32_t size = 0;
  3320. struct cdp_tx_completion_ppdu *tmp_ppdu_desc = NULL;
  3321. struct cdp_tx_completion_ppdu_user *tmp_user;
  3322. uint32_t time_delta;
  3323. /*
  3324. * Find ppdu_id node exists or not
  3325. */
  3326. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  3327. ppdu_info_list_elem, ppdu_info_next) {
  3328. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  3329. if (ppdu_info->tsf_l32 > tsf_l32)
  3330. time_delta = (MAX_TSF_32 -
  3331. ppdu_info->tsf_l32) + tsf_l32;
  3332. else
  3333. time_delta = tsf_l32 - ppdu_info->tsf_l32;
  3334. if (time_delta > WRAP_DROP_TSF_DELTA) {
  3335. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3336. ppdu_info, ppdu_info_list_elem);
  3337. pdev->list_depth--;
  3338. pdev->stats.ppdu_wrap_drop++;
  3339. tmp_ppdu_desc =
  3340. (struct cdp_tx_completion_ppdu *)
  3341. qdf_nbuf_data(ppdu_info->nbuf);
  3342. tmp_user = &tmp_ppdu_desc->user[0];
  3343. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  3344. QDF_TRACE_LEVEL_INFO_MED,
  3345. "S_PID [%d] S_TSF[%u] TLV_BITMAP[0x%x] [CMPLTN - %d ACK_BA - %d] CS[%d] - R_PID[%d] R_TSF[%u] R_TLV_TAG[0x%x]\n",
  3346. ppdu_info->ppdu_id,
  3347. ppdu_info->tsf_l32,
  3348. ppdu_info->tlv_bitmap,
  3349. tmp_user->completion_status,
  3350. ppdu_info->compltn_common_tlv,
  3351. ppdu_info->ack_ba_tlv,
  3352. ppdu_id, tsf_l32, tlv_type);
  3353. qdf_nbuf_free(ppdu_info->nbuf);
  3354. ppdu_info->nbuf = NULL;
  3355. qdf_mem_free(ppdu_info);
  3356. } else {
  3357. break;
  3358. }
  3359. }
  3360. }
  3361. /*
  3362. * check if it is ack ba tlv and if it is not there in ppdu info
  3363. * list then check it in sched completion ppdu list
  3364. */
  3365. if (!ppdu_info &&
  3366. tlv_type == HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) {
  3367. TAILQ_FOREACH(s_ppdu_info,
  3368. &pdev->sched_comp_ppdu_list,
  3369. ppdu_info_list_elem) {
  3370. if (s_ppdu_info && (s_ppdu_info->ppdu_id == ppdu_id)) {
  3371. if (s_ppdu_info->tsf_l32 > tsf_l32)
  3372. time_delta = (MAX_TSF_32 -
  3373. s_ppdu_info->tsf_l32) +
  3374. tsf_l32;
  3375. else
  3376. time_delta = tsf_l32 -
  3377. s_ppdu_info->tsf_l32;
  3378. if (time_delta < WRAP_DROP_TSF_DELTA) {
  3379. ppdu_info = s_ppdu_info;
  3380. break;
  3381. }
  3382. } else {
  3383. /*
  3384. * ACK BA STATUS TLV comes sequential order
  3385. * if we received ack ba status tlv for second
  3386. * ppdu and first ppdu is still waiting for
  3387. * ACK BA STATUS TLV. Based on fw comment
  3388. * we won't receive it tlv later. So we can
  3389. * set ppdu info done.
  3390. */
  3391. if (s_ppdu_info)
  3392. s_ppdu_info->done = 1;
  3393. }
  3394. }
  3395. }
  3396. if (ppdu_info) {
  3397. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  3398. /**
  3399. * if we get tlv_type that is already been processed
  3400. * for ppdu, that means we got a new ppdu with same
  3401. * ppdu id. Hence Flush the older ppdu
  3402. * for MUMIMO and OFDMA, In a PPDU we have
  3403. * multiple user with same tlv types. tlv bitmap is
  3404. * used to check whether SU or MU_MIMO/OFDMA
  3405. */
  3406. if (!(ppdu_info->tlv_bitmap &
  3407. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  3408. return ppdu_info;
  3409. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3410. qdf_nbuf_data(ppdu_info->nbuf);
  3411. /**
  3412. * apart from ACK BA STATUS TLV rest all comes in order
  3413. * so if tlv type not ACK BA STATUS TLV we can deliver
  3414. * ppdu_info
  3415. */
  3416. if ((tlv_type ==
  3417. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3418. (ppdu_desc->htt_frame_type ==
  3419. HTT_STATS_FTYPE_SGEN_MU_BAR))
  3420. return ppdu_info;
  3421. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3422. } else {
  3423. return ppdu_info;
  3424. }
  3425. }
  3426. /**
  3427. * Flush the head ppdu descriptor if ppdu desc list reaches max
  3428. * threshold
  3429. */
  3430. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  3431. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  3432. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3433. ppdu_info, ppdu_info_list_elem);
  3434. pdev->list_depth--;
  3435. pdev->stats.ppdu_drop++;
  3436. qdf_nbuf_free(ppdu_info->nbuf);
  3437. ppdu_info->nbuf = NULL;
  3438. qdf_mem_free(ppdu_info);
  3439. }
  3440. size = sizeof(struct cdp_tx_completion_ppdu) +
  3441. (max_users * sizeof(struct cdp_tx_completion_ppdu_user));
  3442. /*
  3443. * Allocate new ppdu_info node
  3444. */
  3445. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  3446. if (!ppdu_info)
  3447. return NULL;
  3448. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev, size,
  3449. 0, 4, TRUE);
  3450. if (!ppdu_info->nbuf) {
  3451. qdf_mem_free(ppdu_info);
  3452. return NULL;
  3453. }
  3454. ppdu_info->ppdu_desc =
  3455. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  3456. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf), size);
  3457. if (qdf_nbuf_put_tail(ppdu_info->nbuf, size) == NULL) {
  3458. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3459. "No tailroom for HTT PPDU");
  3460. qdf_nbuf_free(ppdu_info->nbuf);
  3461. ppdu_info->nbuf = NULL;
  3462. ppdu_info->last_user = 0;
  3463. qdf_mem_free(ppdu_info);
  3464. return NULL;
  3465. }
  3466. ppdu_info->ppdu_desc->max_users = max_users;
  3467. ppdu_info->tsf_l32 = tsf_l32;
  3468. /**
  3469. * No lock is needed because all PPDU TLVs are processed in
  3470. * same context and this list is updated in same context
  3471. */
  3472. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  3473. ppdu_info_list_elem);
  3474. pdev->list_depth++;
  3475. return ppdu_info;
  3476. }
  3477. /**
  3478. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  3479. * @pdev: DP pdev handle
  3480. * @htt_t2h_msg: HTT target to host message
  3481. *
  3482. * return: ppdu_info per ppdu tlv structure
  3483. */
  3484. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  3485. qdf_nbuf_t htt_t2h_msg)
  3486. {
  3487. uint32_t length;
  3488. uint32_t ppdu_id;
  3489. uint8_t tlv_type;
  3490. uint32_t tlv_length, tlv_bitmap_expected;
  3491. uint8_t *tlv_buf;
  3492. struct ppdu_info *ppdu_info = NULL;
  3493. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3494. uint8_t max_users = CDP_MU_MAX_USERS;
  3495. uint32_t tsf_l32;
  3496. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3497. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  3498. msg_word = msg_word + 1;
  3499. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  3500. msg_word = msg_word + 1;
  3501. tsf_l32 = (uint32_t)(*msg_word);
  3502. msg_word = msg_word + 2;
  3503. while (length > 0) {
  3504. tlv_buf = (uint8_t *)msg_word;
  3505. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  3506. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  3507. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  3508. pdev->stats.ppdu_stats_counter[tlv_type]++;
  3509. if (tlv_length == 0)
  3510. break;
  3511. tlv_length += HTT_TLV_HDR_LEN;
  3512. /**
  3513. * Not allocating separate ppdu descriptor for MGMT Payload
  3514. * TLV as this is sent as separate WDI indication and it
  3515. * doesn't contain any ppdu information
  3516. */
  3517. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  3518. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  3519. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  3520. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  3521. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  3522. (*(msg_word + 1));
  3523. msg_word =
  3524. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3525. length -= (tlv_length);
  3526. continue;
  3527. }
  3528. /*
  3529. * retrieve max_users if it's USERS_INFO,
  3530. * else, it's 1 for COMPLTN_FLUSH,
  3531. * else, use CDP_MU_MAX_USERS
  3532. */
  3533. if (tlv_type == HTT_PPDU_STATS_USERS_INFO_TLV) {
  3534. max_users =
  3535. HTT_PPDU_STATS_USERS_INFO_TLV_MAX_USERS_GET(*(msg_word + 1));
  3536. } else if (tlv_type == HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) {
  3537. max_users = 1;
  3538. }
  3539. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type,
  3540. tsf_l32, max_users);
  3541. if (!ppdu_info)
  3542. return NULL;
  3543. ppdu_info->ppdu_desc->bss_color =
  3544. pdev->rx_mon_recv_status.bsscolor;
  3545. ppdu_info->ppdu_id = ppdu_id;
  3546. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  3547. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  3548. /**
  3549. * Increment pdev level tlv count to monitor
  3550. * missing TLVs
  3551. */
  3552. pdev->tlv_count++;
  3553. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  3554. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3555. length -= (tlv_length);
  3556. }
  3557. if (!ppdu_info)
  3558. return NULL;
  3559. pdev->last_ppdu_id = ppdu_id;
  3560. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3561. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3562. pdev->tx_capture_enabled) {
  3563. if (ppdu_info->is_ampdu)
  3564. tlv_bitmap_expected =
  3565. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3566. ppdu_info->tlv_bitmap);
  3567. }
  3568. ppdu_desc = ppdu_info->ppdu_desc;
  3569. if (!ppdu_desc)
  3570. return NULL;
  3571. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  3572. HTT_PPDU_STATS_USER_STATUS_OK) {
  3573. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  3574. }
  3575. /*
  3576. * for frame type DATA and BAR, we update stats based on MSDU,
  3577. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  3578. * which comes out of order. successful mpdu also populated from
  3579. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  3580. * we store successful mpdu from both tlv and compare before delivering
  3581. * to make sure we received ACK BA STATUS TLV. For some self generated
  3582. * frame we won't get ack ba status tlv so no need to wait for
  3583. * ack ba status tlv.
  3584. */
  3585. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL &&
  3586. ppdu_desc->htt_frame_type != HTT_STATS_FTYPE_SGEN_QOS_NULL) {
  3587. /*
  3588. * most of the time bar frame will have duplicate ack ba
  3589. * status tlv
  3590. */
  3591. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  3592. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv))
  3593. return NULL;
  3594. /*
  3595. * For data frame, compltn common tlv should match ack ba status
  3596. * tlv and completion status. Reason we are checking first user
  3597. * for ofdma, completion seen at next MU BAR frm, for mimo
  3598. * only for first user completion will be immediate.
  3599. */
  3600. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  3601. (ppdu_desc->user[0].completion_status == 0 &&
  3602. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv)))
  3603. return NULL;
  3604. }
  3605. /**
  3606. * Once all the TLVs for a given PPDU has been processed,
  3607. * return PPDU status to be delivered to higher layer.
  3608. * tlv_bitmap_expected can't be available for different frame type.
  3609. * But SCHED CMD STATS TLV is the last TLV from the FW for a ppdu.
  3610. * apart from ACK BA TLV, FW sends other TLV in sequential order.
  3611. * flush tlv comes separate.
  3612. */
  3613. if ((ppdu_info->tlv_bitmap != 0 &&
  3614. (ppdu_info->tlv_bitmap &
  3615. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV))) ||
  3616. (ppdu_info->tlv_bitmap &
  3617. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV))) {
  3618. ppdu_info->done = 1;
  3619. return ppdu_info;
  3620. }
  3621. return NULL;
  3622. }
  3623. #endif /* FEATURE_PERPKT_INFO */
  3624. /**
  3625. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  3626. * @soc: DP SOC handle
  3627. * @pdev_id: pdev id
  3628. * @htt_t2h_msg: HTT message nbuf
  3629. *
  3630. * return:void
  3631. */
  3632. #if defined(WDI_EVENT_ENABLE)
  3633. #ifdef FEATURE_PERPKT_INFO
  3634. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3635. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3636. {
  3637. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  3638. struct ppdu_info *ppdu_info = NULL;
  3639. bool free_buf = true;
  3640. if (pdev_id >= MAX_PDEV_CNT)
  3641. return true;
  3642. pdev = soc->pdev_list[pdev_id];
  3643. if (!pdev)
  3644. return true;
  3645. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  3646. !pdev->mcopy_mode && !pdev->bpr_enable)
  3647. return free_buf;
  3648. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  3649. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  3650. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  3651. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  3652. QDF_STATUS_SUCCESS)
  3653. free_buf = false;
  3654. }
  3655. if (ppdu_info)
  3656. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3657. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  3658. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  3659. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  3660. return free_buf;
  3661. }
  3662. #else
  3663. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3664. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3665. {
  3666. return true;
  3667. }
  3668. #endif
  3669. #endif
  3670. /**
  3671. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3672. * @soc: DP SOC handle
  3673. * @htt_t2h_msg: HTT message nbuf
  3674. *
  3675. * return:void
  3676. */
  3677. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3678. qdf_nbuf_t htt_t2h_msg)
  3679. {
  3680. uint8_t done;
  3681. qdf_nbuf_t msg_copy;
  3682. uint32_t *msg_word;
  3683. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3684. msg_word = msg_word + 3;
  3685. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3686. /*
  3687. * HTT EXT stats response comes as stream of TLVs which span over
  3688. * multiple T2H messages.
  3689. * The first message will carry length of the response.
  3690. * For rest of the messages length will be zero.
  3691. *
  3692. * Clone the T2H message buffer and store it in a list to process
  3693. * it later.
  3694. *
  3695. * The original T2H message buffers gets freed in the T2H HTT event
  3696. * handler
  3697. */
  3698. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3699. if (!msg_copy) {
  3700. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3701. "T2H messge clone failed for HTT EXT STATS");
  3702. goto error;
  3703. }
  3704. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3705. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3706. /*
  3707. * Done bit signifies that this is the last T2H buffer in the stream of
  3708. * HTT EXT STATS message
  3709. */
  3710. if (done) {
  3711. soc->htt_stats.num_stats++;
  3712. qdf_sched_work(0, &soc->htt_stats.work);
  3713. }
  3714. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3715. return;
  3716. error:
  3717. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3718. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3719. != NULL) {
  3720. qdf_nbuf_free(msg_copy);
  3721. }
  3722. soc->htt_stats.num_stats = 0;
  3723. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3724. return;
  3725. }
  3726. /*
  3727. * htt_soc_attach_target() - SOC level HTT setup
  3728. * @htt_soc: HTT SOC handle
  3729. *
  3730. * Return: 0 on success; error code on failure
  3731. */
  3732. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3733. {
  3734. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3735. return htt_h2t_ver_req_msg(soc);
  3736. }
  3737. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3738. {
  3739. htt_soc->htc_soc = htc_soc;
  3740. }
  3741. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3742. {
  3743. return htt_soc->htc_soc;
  3744. }
  3745. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3746. {
  3747. int i;
  3748. int j;
  3749. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3750. struct htt_soc *htt_soc = NULL;
  3751. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3752. if (!htt_soc) {
  3753. dp_err("HTT attach failed");
  3754. return NULL;
  3755. }
  3756. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3757. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3758. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3759. break;
  3760. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3761. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3762. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3763. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3764. break;
  3765. }
  3766. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3767. }
  3768. if (i != MAX_PDEV_CNT) {
  3769. for (j = 0; j < i; j++) {
  3770. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  3771. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  3772. }
  3773. qdf_mem_free(htt_soc);
  3774. return NULL;
  3775. }
  3776. htt_soc->dp_soc = soc;
  3777. htt_soc->htc_soc = htc_handle;
  3778. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3779. return htt_soc;
  3780. }
  3781. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3782. /*
  3783. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3784. * @htt_soc: HTT SOC handle
  3785. * @msg_word: Pointer to payload
  3786. * @htt_t2h_msg: HTT msg nbuf
  3787. *
  3788. * Return: True if buffer should be freed by caller.
  3789. */
  3790. static bool
  3791. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3792. uint32_t *msg_word,
  3793. qdf_nbuf_t htt_t2h_msg)
  3794. {
  3795. u_int8_t pdev_id;
  3796. u_int8_t target_pdev_id;
  3797. bool free_buf;
  3798. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3799. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3800. target_pdev_id);
  3801. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3802. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3803. pdev_id);
  3804. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3805. htt_t2h_msg);
  3806. return free_buf;
  3807. }
  3808. #else
  3809. static bool
  3810. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3811. uint32_t *msg_word,
  3812. qdf_nbuf_t htt_t2h_msg)
  3813. {
  3814. return true;
  3815. }
  3816. #endif
  3817. #if defined(WDI_EVENT_ENABLE) && \
  3818. !defined(REMOVE_PKT_LOG)
  3819. /*
  3820. * dp_pktlog_msg_handler() - Pktlog msg handler
  3821. * @htt_soc: HTT SOC handle
  3822. * @msg_word: Pointer to payload
  3823. *
  3824. * Return: None
  3825. */
  3826. static void
  3827. dp_pktlog_msg_handler(struct htt_soc *soc,
  3828. uint32_t *msg_word)
  3829. {
  3830. uint8_t pdev_id;
  3831. uint8_t target_pdev_id;
  3832. uint32_t *pl_hdr;
  3833. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3834. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3835. target_pdev_id);
  3836. pl_hdr = (msg_word + 1);
  3837. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3838. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3839. pdev_id);
  3840. }
  3841. #else
  3842. static void
  3843. dp_pktlog_msg_handler(struct htt_soc *soc,
  3844. uint32_t *msg_word)
  3845. {
  3846. }
  3847. #endif
  3848. /*
  3849. * time_allow_print() - time allow print
  3850. * @htt_ring_tt: ringi_id array of timestamps
  3851. * @ring_id: ring_id (index)
  3852. *
  3853. * Return: 1 for successfully saving timestamp in array
  3854. * and 0 for timestamp falling within 2 seconds after last one
  3855. */
  3856. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3857. {
  3858. unsigned long tstamp;
  3859. unsigned long delta;
  3860. tstamp = qdf_get_system_timestamp();
  3861. if (!htt_ring_tt)
  3862. return 0; //unable to print backpressure messages
  3863. if (htt_ring_tt[ring_id] == -1) {
  3864. htt_ring_tt[ring_id] = tstamp;
  3865. return 1;
  3866. }
  3867. delta = tstamp - htt_ring_tt[ring_id];
  3868. if (delta >= 2000) {
  3869. htt_ring_tt[ring_id] = tstamp;
  3870. return 1;
  3871. }
  3872. return 0;
  3873. }
  3874. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3875. u_int8_t pdev_id, u_int8_t ring_id,
  3876. u_int16_t hp_idx, u_int16_t tp_idx,
  3877. u_int32_t bkp_time, char *ring_stype)
  3878. {
  3879. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3880. msg_type, pdev_id, ring_stype);
  3881. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3882. ring_id, hp_idx, tp_idx, bkp_time);
  3883. }
  3884. /*
  3885. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3886. * @msg_word: htt packet context
  3887. * @htt_soc: HTT SOC handle
  3888. *
  3889. * Return: after attempting to print stats
  3890. */
  3891. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3892. {
  3893. u_int8_t ring_type;
  3894. u_int8_t pdev_id;
  3895. uint8_t target_pdev_id;
  3896. u_int8_t ring_id;
  3897. u_int16_t hp_idx;
  3898. u_int16_t tp_idx;
  3899. u_int32_t bkp_time;
  3900. enum htt_t2h_msg_type msg_type;
  3901. struct dp_soc *dpsoc;
  3902. struct dp_pdev *pdev;
  3903. struct dp_htt_timestamp *radio_tt;
  3904. if (!soc)
  3905. return;
  3906. dpsoc = (struct dp_soc *)soc->dp_soc;
  3907. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3908. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3909. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3910. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3911. target_pdev_id);
  3912. if (pdev_id >= MAX_PDEV_CNT) {
  3913. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  3914. "pdev id %d is invalid", pdev_id);
  3915. return;
  3916. }
  3917. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3918. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3919. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3920. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3921. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3922. radio_tt = &soc->pdevid_tt[pdev_id];
  3923. switch (ring_type) {
  3924. case HTT_SW_RING_TYPE_UMAC:
  3925. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3926. return;
  3927. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3928. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  3929. break;
  3930. case HTT_SW_RING_TYPE_LMAC:
  3931. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3932. return;
  3933. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3934. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3935. break;
  3936. default:
  3937. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3938. bkp_time, "UNKNOWN");
  3939. break;
  3940. }
  3941. dp_print_ring_stats(pdev);
  3942. dp_print_napi_stats(pdev->soc);
  3943. }
  3944. /*
  3945. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  3946. * @context: Opaque context (HTT SOC handle)
  3947. * @pkt: HTC packet
  3948. */
  3949. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3950. {
  3951. struct htt_soc *soc = (struct htt_soc *) context;
  3952. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3953. u_int32_t *msg_word;
  3954. enum htt_t2h_msg_type msg_type;
  3955. bool free_buf = true;
  3956. /* check for successful message reception */
  3957. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3958. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3959. soc->stats.htc_err_cnt++;
  3960. qdf_nbuf_free(htt_t2h_msg);
  3961. return;
  3962. }
  3963. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3964. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3965. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3966. htt_event_record(soc->htt_logger_handle,
  3967. msg_type, (uint8_t *)msg_word);
  3968. switch (msg_type) {
  3969. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3970. {
  3971. dp_htt_bkp_event_alert(msg_word, soc);
  3972. break;
  3973. }
  3974. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3975. {
  3976. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3977. u_int8_t *peer_mac_addr;
  3978. u_int16_t peer_id;
  3979. u_int16_t hw_peer_id;
  3980. u_int8_t vdev_id;
  3981. u_int8_t is_wds;
  3982. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3983. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3984. hw_peer_id =
  3985. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3986. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3987. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3988. (u_int8_t *) (msg_word+1),
  3989. &mac_addr_deswizzle_buf[0]);
  3990. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3991. QDF_TRACE_LEVEL_INFO,
  3992. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3993. peer_id, vdev_id);
  3994. /*
  3995. * check if peer already exists for this peer_id, if so
  3996. * this peer map event is in response for a wds peer add
  3997. * wmi command sent during wds source port learning.
  3998. * in this case just add the ast entry to the existing
  3999. * peer ast_list.
  4000. */
  4001. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  4002. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  4003. vdev_id, peer_mac_addr, 0,
  4004. is_wds);
  4005. break;
  4006. }
  4007. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  4008. {
  4009. u_int16_t peer_id;
  4010. u_int8_t vdev_id;
  4011. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  4012. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  4013. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  4014. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4015. vdev_id, mac_addr, 0,
  4016. DP_PEER_WDS_COUNT_INVALID);
  4017. break;
  4018. }
  4019. case HTT_T2H_MSG_TYPE_SEC_IND:
  4020. {
  4021. u_int16_t peer_id;
  4022. enum cdp_sec_type sec_type;
  4023. int is_unicast;
  4024. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  4025. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  4026. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  4027. /* point to the first part of the Michael key */
  4028. msg_word++;
  4029. dp_rx_sec_ind_handler(
  4030. soc->dp_soc, peer_id, sec_type, is_unicast,
  4031. msg_word, msg_word + 2);
  4032. break;
  4033. }
  4034. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  4035. {
  4036. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  4037. htt_t2h_msg);
  4038. break;
  4039. }
  4040. case HTT_T2H_MSG_TYPE_PKTLOG:
  4041. {
  4042. dp_pktlog_msg_handler(soc, msg_word);
  4043. break;
  4044. }
  4045. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  4046. {
  4047. /*
  4048. * HTC maintains runtime pm count for H2T messages that
  4049. * have a response msg from FW. This count ensures that
  4050. * in the case FW does not sent out the response or host
  4051. * did not process this indication runtime_put happens
  4052. * properly in the cleanup path.
  4053. */
  4054. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  4055. htc_pm_runtime_put(soc->htc_soc);
  4056. else
  4057. soc->stats.htt_ver_req_put_skip++;
  4058. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  4059. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  4060. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  4061. "target uses HTT version %d.%d; host uses %d.%d",
  4062. soc->tgt_ver.major, soc->tgt_ver.minor,
  4063. HTT_CURRENT_VERSION_MAJOR,
  4064. HTT_CURRENT_VERSION_MINOR);
  4065. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  4066. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4067. QDF_TRACE_LEVEL_WARN,
  4068. "*** Incompatible host/target HTT versions!");
  4069. }
  4070. /* abort if the target is incompatible with the host */
  4071. qdf_assert(soc->tgt_ver.major ==
  4072. HTT_CURRENT_VERSION_MAJOR);
  4073. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  4074. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4075. QDF_TRACE_LEVEL_INFO_LOW,
  4076. "*** Warning: host/target HTT versions"
  4077. " are different, though compatible!");
  4078. }
  4079. break;
  4080. }
  4081. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  4082. {
  4083. uint16_t peer_id;
  4084. uint8_t tid;
  4085. uint8_t win_sz;
  4086. uint16_t status;
  4087. struct dp_peer *peer;
  4088. /*
  4089. * Update REO Queue Desc with new values
  4090. */
  4091. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  4092. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  4093. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  4094. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  4095. DP_MOD_ID_HTT);
  4096. /*
  4097. * Window size needs to be incremented by 1
  4098. * since fw needs to represent a value of 256
  4099. * using just 8 bits
  4100. */
  4101. if (peer) {
  4102. status = dp_addba_requestprocess_wifi3(
  4103. (struct cdp_soc_t *)soc->dp_soc,
  4104. peer->mac_addr.raw, peer->vdev->vdev_id,
  4105. 0, tid, 0, win_sz + 1, 0xffff);
  4106. /*
  4107. * If PEER_LOCK_REF_PROTECT enbled dec ref
  4108. * which is inc by dp_peer_get_ref_by_id
  4109. */
  4110. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4111. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4112. QDF_TRACE_LEVEL_INFO,
  4113. FL("PeerID %d BAW %d TID %d stat %d"),
  4114. peer_id, win_sz, tid, status);
  4115. } else {
  4116. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4117. QDF_TRACE_LEVEL_ERROR,
  4118. FL("Peer not found peer id %d"),
  4119. peer_id);
  4120. }
  4121. break;
  4122. }
  4123. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  4124. {
  4125. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  4126. break;
  4127. }
  4128. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  4129. {
  4130. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4131. u_int8_t *peer_mac_addr;
  4132. u_int16_t peer_id;
  4133. u_int16_t hw_peer_id;
  4134. u_int8_t vdev_id;
  4135. bool is_wds;
  4136. u_int16_t ast_hash;
  4137. struct dp_ast_flow_override_info ast_flow_info;
  4138. qdf_mem_set(&ast_flow_info, 0,
  4139. sizeof(struct dp_ast_flow_override_info));
  4140. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  4141. hw_peer_id =
  4142. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  4143. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  4144. peer_mac_addr =
  4145. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4146. &mac_addr_deswizzle_buf[0]);
  4147. is_wds =
  4148. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  4149. ast_hash =
  4150. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  4151. /*
  4152. * Update 4 ast_index per peer, ast valid mask
  4153. * and TID flow valid mask.
  4154. * AST valid mask is 3 bit field corresponds to
  4155. * ast_index[3:1]. ast_index 0 is always valid.
  4156. */
  4157. ast_flow_info.ast_valid_mask =
  4158. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  4159. ast_flow_info.ast_idx[0] = hw_peer_id;
  4160. ast_flow_info.ast_flow_mask[0] =
  4161. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  4162. ast_flow_info.ast_idx[1] =
  4163. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  4164. ast_flow_info.ast_flow_mask[1] =
  4165. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  4166. ast_flow_info.ast_idx[2] =
  4167. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  4168. ast_flow_info.ast_flow_mask[2] =
  4169. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  4170. ast_flow_info.ast_idx[3] =
  4171. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  4172. ast_flow_info.ast_flow_mask[3] =
  4173. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  4174. /*
  4175. * TID valid mask is applicable only
  4176. * for HI and LOW priority flows.
  4177. * tid_valid_mas is 8 bit field corresponds
  4178. * to TID[7:0]
  4179. */
  4180. ast_flow_info.tid_valid_low_pri_mask =
  4181. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  4182. ast_flow_info.tid_valid_hi_pri_mask =
  4183. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  4184. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4185. QDF_TRACE_LEVEL_INFO,
  4186. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4187. peer_id, vdev_id);
  4188. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  4189. hw_peer_id, vdev_id,
  4190. peer_mac_addr, ast_hash,
  4191. is_wds);
  4192. /*
  4193. * Update ast indexes for flow override support
  4194. * Applicable only for non wds peers
  4195. */
  4196. dp_peer_ast_index_flow_queue_map_create(
  4197. soc->dp_soc, is_wds,
  4198. peer_id, peer_mac_addr,
  4199. &ast_flow_info);
  4200. break;
  4201. }
  4202. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  4203. {
  4204. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4205. u_int8_t *mac_addr;
  4206. u_int16_t peer_id;
  4207. u_int8_t vdev_id;
  4208. u_int8_t is_wds;
  4209. u_int32_t free_wds_count;
  4210. peer_id =
  4211. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  4212. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  4213. mac_addr =
  4214. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4215. &mac_addr_deswizzle_buf[0]);
  4216. is_wds =
  4217. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  4218. free_wds_count =
  4219. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  4220. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4221. QDF_TRACE_LEVEL_INFO,
  4222. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  4223. peer_id, vdev_id);
  4224. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4225. vdev_id, mac_addr,
  4226. is_wds, free_wds_count);
  4227. break;
  4228. }
  4229. case HTT_T2H_MSG_TYPE_RX_DELBA:
  4230. {
  4231. uint16_t peer_id;
  4232. uint8_t tid;
  4233. uint8_t win_sz;
  4234. QDF_STATUS status;
  4235. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  4236. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  4237. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  4238. status = dp_rx_delba_ind_handler(
  4239. soc->dp_soc,
  4240. peer_id, tid, win_sz);
  4241. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4242. QDF_TRACE_LEVEL_INFO,
  4243. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  4244. peer_id, win_sz, tid, status);
  4245. break;
  4246. }
  4247. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  4248. {
  4249. uint16_t num_entries;
  4250. uint32_t cmem_ba_lo;
  4251. uint32_t cmem_ba_hi;
  4252. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  4253. cmem_ba_lo = *(msg_word + 1);
  4254. cmem_ba_hi = *(msg_word + 2);
  4255. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  4256. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  4257. num_entries, cmem_ba_lo, cmem_ba_hi);
  4258. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  4259. cmem_ba_lo, cmem_ba_hi);
  4260. }
  4261. default:
  4262. break;
  4263. };
  4264. /* Free the indication buffer */
  4265. if (free_buf)
  4266. qdf_nbuf_free(htt_t2h_msg);
  4267. }
  4268. /*
  4269. * dp_htt_h2t_full() - Send full handler (called from HTC)
  4270. * @context: Opaque context (HTT SOC handle)
  4271. * @pkt: HTC packet
  4272. *
  4273. * Return: enum htc_send_full_action
  4274. */
  4275. static enum htc_send_full_action
  4276. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  4277. {
  4278. return HTC_SEND_FULL_KEEP;
  4279. }
  4280. /*
  4281. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  4282. * @context: Opaque context (HTT SOC handle)
  4283. * @nbuf: nbuf containing T2H message
  4284. * @pipe_id: HIF pipe ID
  4285. *
  4286. * Return: QDF_STATUS
  4287. *
  4288. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  4289. * will be used for packet log and other high-priority HTT messages. Proper
  4290. * HTC connection to be added later once required FW changes are available
  4291. */
  4292. static QDF_STATUS
  4293. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  4294. {
  4295. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  4296. HTC_PACKET htc_pkt;
  4297. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  4298. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  4299. htc_pkt.Status = QDF_STATUS_SUCCESS;
  4300. htc_pkt.pPktContext = (void *)nbuf;
  4301. dp_htt_t2h_msg_handler(context, &htc_pkt);
  4302. return rc;
  4303. }
  4304. /*
  4305. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  4306. * @htt_soc: HTT SOC handle
  4307. *
  4308. * Return: QDF_STATUS
  4309. */
  4310. static QDF_STATUS
  4311. htt_htc_soc_attach(struct htt_soc *soc)
  4312. {
  4313. struct htc_service_connect_req connect;
  4314. struct htc_service_connect_resp response;
  4315. QDF_STATUS status;
  4316. struct dp_soc *dpsoc = soc->dp_soc;
  4317. qdf_mem_zero(&connect, sizeof(connect));
  4318. qdf_mem_zero(&response, sizeof(response));
  4319. connect.pMetaData = NULL;
  4320. connect.MetaDataLength = 0;
  4321. connect.EpCallbacks.pContext = soc;
  4322. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  4323. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  4324. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  4325. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  4326. connect.EpCallbacks.EpRecvRefill = NULL;
  4327. /* N/A, fill is done by HIF */
  4328. connect.EpCallbacks.RecvRefillWaterMark = 1;
  4329. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  4330. /*
  4331. * Specify how deep to let a queue get before htc_send_pkt will
  4332. * call the EpSendFull function due to excessive send queue depth.
  4333. */
  4334. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  4335. /* disable flow control for HTT data message service */
  4336. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  4337. /* connect to control service */
  4338. connect.service_id = HTT_DATA_MSG_SVC;
  4339. status = htc_connect_service(soc->htc_soc, &connect, &response);
  4340. if (status != QDF_STATUS_SUCCESS)
  4341. return status;
  4342. soc->htc_endpoint = response.Endpoint;
  4343. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  4344. htt_interface_logging_init(&soc->htt_logger_handle);
  4345. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  4346. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  4347. return QDF_STATUS_SUCCESS; /* success */
  4348. }
  4349. /*
  4350. * htt_soc_initialize() - SOC level HTT initialization
  4351. * @htt_soc: Opaque htt SOC handle
  4352. * @ctrl_psoc: Opaque ctrl SOC handle
  4353. * @htc_soc: SOC level HTC handle
  4354. * @hal_soc: Opaque HAL SOC handle
  4355. * @osdev: QDF device
  4356. *
  4357. * Return: HTT handle on success; NULL on failure
  4358. */
  4359. void *
  4360. htt_soc_initialize(struct htt_soc *htt_soc,
  4361. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  4362. HTC_HANDLE htc_soc,
  4363. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  4364. {
  4365. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  4366. soc->osdev = osdev;
  4367. soc->ctrl_psoc = ctrl_psoc;
  4368. soc->htc_soc = htc_soc;
  4369. soc->hal_soc = hal_soc_hdl;
  4370. if (htt_htc_soc_attach(soc))
  4371. goto fail2;
  4372. return soc;
  4373. fail2:
  4374. return NULL;
  4375. }
  4376. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  4377. {
  4378. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  4379. htt_htc_misc_pkt_pool_free(htt_handle);
  4380. htt_htc_pkt_pool_free(htt_handle);
  4381. }
  4382. /*
  4383. * htt_soc_htc_prealloc() - HTC memory prealloc
  4384. * @htt_soc: SOC level HTT handle
  4385. *
  4386. * Return: QDF_STATUS_SUCCESS on Success or
  4387. * QDF_STATUS_E_NOMEM on allocation failure
  4388. */
  4389. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  4390. {
  4391. int i;
  4392. soc->htt_htc_pkt_freelist = NULL;
  4393. /* pre-allocate some HTC_PACKET objects */
  4394. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  4395. struct dp_htt_htc_pkt_union *pkt;
  4396. pkt = qdf_mem_malloc(sizeof(*pkt));
  4397. if (!pkt)
  4398. return QDF_STATUS_E_NOMEM;
  4399. htt_htc_pkt_free(soc, &pkt->u.pkt);
  4400. }
  4401. return QDF_STATUS_SUCCESS;
  4402. }
  4403. /*
  4404. * htt_soc_detach() - Free SOC level HTT handle
  4405. * @htt_hdl: HTT SOC handle
  4406. */
  4407. void htt_soc_detach(struct htt_soc *htt_hdl)
  4408. {
  4409. int i;
  4410. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  4411. for (i = 0; i < MAX_PDEV_CNT; i++) {
  4412. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  4413. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  4414. }
  4415. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  4416. qdf_mem_free(htt_handle);
  4417. }
  4418. /**
  4419. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  4420. * @pdev: DP PDEV handle
  4421. * @stats_type_upload_mask: stats type requested by user
  4422. * @config_param_0: extra configuration parameters
  4423. * @config_param_1: extra configuration parameters
  4424. * @config_param_2: extra configuration parameters
  4425. * @config_param_3: extra configuration parameters
  4426. * @mac_id: mac number
  4427. *
  4428. * return: QDF STATUS
  4429. */
  4430. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  4431. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  4432. uint32_t config_param_1, uint32_t config_param_2,
  4433. uint32_t config_param_3, int cookie_val, int cookie_msb,
  4434. uint8_t mac_id)
  4435. {
  4436. struct htt_soc *soc = pdev->soc->htt_handle;
  4437. struct dp_htt_htc_pkt *pkt;
  4438. qdf_nbuf_t msg;
  4439. uint32_t *msg_word;
  4440. uint8_t pdev_mask = 0;
  4441. uint8_t *htt_logger_bufp;
  4442. int mac_for_pdev;
  4443. int target_pdev_id;
  4444. QDF_STATUS status;
  4445. msg = qdf_nbuf_alloc(
  4446. soc->osdev,
  4447. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  4448. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4449. if (!msg)
  4450. return QDF_STATUS_E_NOMEM;
  4451. /*TODO:Add support for SOC stats
  4452. * Bit 0: SOC Stats
  4453. * Bit 1: Pdev stats for pdev id 0
  4454. * Bit 2: Pdev stats for pdev id 1
  4455. * Bit 3: Pdev stats for pdev id 2
  4456. */
  4457. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4458. target_pdev_id =
  4459. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4460. pdev_mask = 1 << target_pdev_id;
  4461. /*
  4462. * Set the length of the message.
  4463. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4464. * separately during the below call to qdf_nbuf_push_head.
  4465. * The contribution from the HTC header is added separately inside HTC.
  4466. */
  4467. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  4468. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4469. "Failed to expand head for HTT_EXT_STATS");
  4470. qdf_nbuf_free(msg);
  4471. return QDF_STATUS_E_FAILURE;
  4472. }
  4473. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4474. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  4475. "config_param_1 %u\n config_param_2 %u\n"
  4476. "config_param_4 %u\n -------------",
  4477. __func__, __LINE__, cookie_val, config_param_0,
  4478. config_param_1, config_param_2, config_param_3);
  4479. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4480. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4481. htt_logger_bufp = (uint8_t *)msg_word;
  4482. *msg_word = 0;
  4483. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  4484. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  4485. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  4486. /* word 1 */
  4487. msg_word++;
  4488. *msg_word = 0;
  4489. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  4490. /* word 2 */
  4491. msg_word++;
  4492. *msg_word = 0;
  4493. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  4494. /* word 3 */
  4495. msg_word++;
  4496. *msg_word = 0;
  4497. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  4498. /* word 4 */
  4499. msg_word++;
  4500. *msg_word = 0;
  4501. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  4502. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  4503. /* word 5 */
  4504. msg_word++;
  4505. /* word 6 */
  4506. msg_word++;
  4507. *msg_word = 0;
  4508. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  4509. /* word 7 */
  4510. msg_word++;
  4511. *msg_word = 0;
  4512. /* Currently Using last 2 bits for pdev_id
  4513. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  4514. */
  4515. cookie_msb = (cookie_msb | pdev->pdev_id);
  4516. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  4517. pkt = htt_htc_pkt_alloc(soc);
  4518. if (!pkt) {
  4519. qdf_nbuf_free(msg);
  4520. return QDF_STATUS_E_NOMEM;
  4521. }
  4522. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4523. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4524. dp_htt_h2t_send_complete_free_netbuf,
  4525. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4526. soc->htc_endpoint,
  4527. /* tag for FW response msg not guaranteed */
  4528. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4529. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4530. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  4531. htt_logger_bufp);
  4532. if (status != QDF_STATUS_SUCCESS) {
  4533. qdf_nbuf_free(msg);
  4534. htt_htc_pkt_free(soc, pkt);
  4535. }
  4536. return status;
  4537. }
  4538. /**
  4539. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  4540. * HTT message to pass to FW
  4541. * @pdev: DP PDEV handle
  4542. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4543. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4544. *
  4545. * tuple_mask[1:0]:
  4546. * 00 - Do not report 3 tuple hash value
  4547. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4548. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4549. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4550. *
  4551. * return: QDF STATUS
  4552. */
  4553. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4554. uint32_t tuple_mask, uint8_t mac_id)
  4555. {
  4556. struct htt_soc *soc = pdev->soc->htt_handle;
  4557. struct dp_htt_htc_pkt *pkt;
  4558. qdf_nbuf_t msg;
  4559. uint32_t *msg_word;
  4560. uint8_t *htt_logger_bufp;
  4561. int mac_for_pdev;
  4562. int target_pdev_id;
  4563. msg = qdf_nbuf_alloc(
  4564. soc->osdev,
  4565. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4566. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4567. if (!msg)
  4568. return QDF_STATUS_E_NOMEM;
  4569. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4570. target_pdev_id =
  4571. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4572. /*
  4573. * Set the length of the message.
  4574. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4575. * separately during the below call to qdf_nbuf_push_head.
  4576. * The contribution from the HTC header is added separately inside HTC.
  4577. */
  4578. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4579. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4580. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4581. qdf_nbuf_free(msg);
  4582. return QDF_STATUS_E_FAILURE;
  4583. }
  4584. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4585. "config_param_sent %s:%d 0x%x for target_pdev %d\n -------------",
  4586. __func__, __LINE__, tuple_mask, target_pdev_id);
  4587. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4588. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4589. htt_logger_bufp = (uint8_t *)msg_word;
  4590. *msg_word = 0;
  4591. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4592. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4593. msg_word++;
  4594. *msg_word = 0;
  4595. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4596. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4597. pkt = htt_htc_pkt_alloc(soc);
  4598. if (!pkt) {
  4599. qdf_nbuf_free(msg);
  4600. return QDF_STATUS_E_NOMEM;
  4601. }
  4602. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4603. SET_HTC_PACKET_INFO_TX(
  4604. &pkt->htc_pkt,
  4605. dp_htt_h2t_send_complete_free_netbuf,
  4606. qdf_nbuf_data(msg),
  4607. qdf_nbuf_len(msg),
  4608. soc->htc_endpoint,
  4609. /* tag for no FW response msg */
  4610. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4611. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4612. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4613. htt_logger_bufp);
  4614. return QDF_STATUS_SUCCESS;
  4615. }
  4616. /* This macro will revert once proper HTT header will define for
  4617. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4618. * */
  4619. #if defined(WDI_EVENT_ENABLE)
  4620. /**
  4621. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  4622. * @pdev: DP PDEV handle
  4623. * @stats_type_upload_mask: stats type requested by user
  4624. * @mac_id: Mac id number
  4625. *
  4626. * return: QDF STATUS
  4627. */
  4628. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4629. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4630. {
  4631. struct htt_soc *soc = pdev->soc->htt_handle;
  4632. struct dp_htt_htc_pkt *pkt;
  4633. qdf_nbuf_t msg;
  4634. uint32_t *msg_word;
  4635. uint8_t pdev_mask;
  4636. QDF_STATUS status;
  4637. msg = qdf_nbuf_alloc(
  4638. soc->osdev,
  4639. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4640. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4641. if (!msg) {
  4642. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4643. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer");
  4644. qdf_assert(0);
  4645. return QDF_STATUS_E_NOMEM;
  4646. }
  4647. /*TODO:Add support for SOC stats
  4648. * Bit 0: SOC Stats
  4649. * Bit 1: Pdev stats for pdev id 0
  4650. * Bit 2: Pdev stats for pdev id 1
  4651. * Bit 3: Pdev stats for pdev id 2
  4652. */
  4653. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4654. mac_id);
  4655. /*
  4656. * Set the length of the message.
  4657. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4658. * separately during the below call to qdf_nbuf_push_head.
  4659. * The contribution from the HTC header is added separately inside HTC.
  4660. */
  4661. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4662. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4663. "Failed to expand head for HTT_CFG_STATS");
  4664. qdf_nbuf_free(msg);
  4665. return QDF_STATUS_E_FAILURE;
  4666. }
  4667. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4668. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4669. *msg_word = 0;
  4670. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4671. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4672. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4673. stats_type_upload_mask);
  4674. pkt = htt_htc_pkt_alloc(soc);
  4675. if (!pkt) {
  4676. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4677. "Fail to allocate dp_htt_htc_pkt buffer");
  4678. qdf_assert(0);
  4679. qdf_nbuf_free(msg);
  4680. return QDF_STATUS_E_NOMEM;
  4681. }
  4682. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4683. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4684. dp_htt_h2t_send_complete_free_netbuf,
  4685. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4686. soc->htc_endpoint,
  4687. /* tag for no FW response msg */
  4688. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4689. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4690. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4691. (uint8_t *)msg_word);
  4692. if (status != QDF_STATUS_SUCCESS) {
  4693. qdf_nbuf_free(msg);
  4694. htt_htc_pkt_free(soc, pkt);
  4695. }
  4696. return status;
  4697. }
  4698. #endif
  4699. void
  4700. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4701. uint32_t *tag_buf)
  4702. {
  4703. struct dp_peer *peer = NULL;
  4704. switch (tag_type) {
  4705. case HTT_STATS_PEER_DETAILS_TAG:
  4706. {
  4707. htt_peer_details_tlv *dp_stats_buf =
  4708. (htt_peer_details_tlv *)tag_buf;
  4709. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4710. }
  4711. break;
  4712. case HTT_STATS_PEER_STATS_CMN_TAG:
  4713. {
  4714. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4715. (htt_peer_stats_cmn_tlv *)tag_buf;
  4716. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4717. DP_MOD_ID_HTT);
  4718. if (peer && !peer->bss_peer) {
  4719. peer->stats.tx.inactive_time =
  4720. dp_stats_buf->inactive_time;
  4721. qdf_event_set(&pdev->fw_peer_stats_event);
  4722. }
  4723. if (peer)
  4724. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4725. }
  4726. break;
  4727. default:
  4728. qdf_err("Invalid tag_type");
  4729. }
  4730. }
  4731. /**
  4732. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  4733. * @pdev: DP pdev handle
  4734. * @fse_setup_info: FST setup parameters
  4735. *
  4736. * Return: Success when HTT message is sent, error on failure
  4737. */
  4738. QDF_STATUS
  4739. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4740. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4741. {
  4742. struct htt_soc *soc = pdev->soc->htt_handle;
  4743. struct dp_htt_htc_pkt *pkt;
  4744. qdf_nbuf_t msg;
  4745. u_int32_t *msg_word;
  4746. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4747. uint8_t *htt_logger_bufp;
  4748. u_int32_t *key;
  4749. QDF_STATUS status;
  4750. msg = qdf_nbuf_alloc(
  4751. soc->osdev,
  4752. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4753. /* reserve room for the HTC header */
  4754. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4755. if (!msg)
  4756. return QDF_STATUS_E_NOMEM;
  4757. /*
  4758. * Set the length of the message.
  4759. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4760. * separately during the below call to qdf_nbuf_push_head.
  4761. * The contribution from the HTC header is added separately inside HTC.
  4762. */
  4763. if (!qdf_nbuf_put_tail(msg,
  4764. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4765. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4766. return QDF_STATUS_E_FAILURE;
  4767. }
  4768. /* fill in the message contents */
  4769. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4770. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4771. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4772. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4773. htt_logger_bufp = (uint8_t *)msg_word;
  4774. *msg_word = 0;
  4775. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4776. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4777. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4778. msg_word++;
  4779. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4780. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4781. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4782. fse_setup_info->ip_da_sa_prefix);
  4783. msg_word++;
  4784. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4785. fse_setup_info->base_addr_lo);
  4786. msg_word++;
  4787. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4788. fse_setup_info->base_addr_hi);
  4789. key = (u_int32_t *)fse_setup_info->hash_key;
  4790. fse_setup->toeplitz31_0 = *key++;
  4791. fse_setup->toeplitz63_32 = *key++;
  4792. fse_setup->toeplitz95_64 = *key++;
  4793. fse_setup->toeplitz127_96 = *key++;
  4794. fse_setup->toeplitz159_128 = *key++;
  4795. fse_setup->toeplitz191_160 = *key++;
  4796. fse_setup->toeplitz223_192 = *key++;
  4797. fse_setup->toeplitz255_224 = *key++;
  4798. fse_setup->toeplitz287_256 = *key++;
  4799. fse_setup->toeplitz314_288 = *key;
  4800. msg_word++;
  4801. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4802. msg_word++;
  4803. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4804. msg_word++;
  4805. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4806. msg_word++;
  4807. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4808. msg_word++;
  4809. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4810. msg_word++;
  4811. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4812. msg_word++;
  4813. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4814. msg_word++;
  4815. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4816. msg_word++;
  4817. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4818. msg_word++;
  4819. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4820. fse_setup->toeplitz314_288);
  4821. pkt = htt_htc_pkt_alloc(soc);
  4822. if (!pkt) {
  4823. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4824. qdf_assert(0);
  4825. qdf_nbuf_free(msg);
  4826. return QDF_STATUS_E_RESOURCES; /* failure */
  4827. }
  4828. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4829. SET_HTC_PACKET_INFO_TX(
  4830. &pkt->htc_pkt,
  4831. dp_htt_h2t_send_complete_free_netbuf,
  4832. qdf_nbuf_data(msg),
  4833. qdf_nbuf_len(msg),
  4834. soc->htc_endpoint,
  4835. /* tag for no FW response msg */
  4836. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4837. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4838. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4839. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4840. htt_logger_bufp);
  4841. if (status == QDF_STATUS_SUCCESS) {
  4842. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4843. fse_setup_info->pdev_id);
  4844. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4845. (void *)fse_setup_info->hash_key,
  4846. fse_setup_info->hash_key_len);
  4847. } else {
  4848. qdf_nbuf_free(msg);
  4849. htt_htc_pkt_free(soc, pkt);
  4850. }
  4851. return status;
  4852. }
  4853. /**
  4854. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  4855. * add/del a flow in HW
  4856. * @pdev: DP pdev handle
  4857. * @fse_op_info: Flow entry parameters
  4858. *
  4859. * Return: Success when HTT message is sent, error on failure
  4860. */
  4861. QDF_STATUS
  4862. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4863. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4864. {
  4865. struct htt_soc *soc = pdev->soc->htt_handle;
  4866. struct dp_htt_htc_pkt *pkt;
  4867. qdf_nbuf_t msg;
  4868. u_int32_t *msg_word;
  4869. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4870. uint8_t *htt_logger_bufp;
  4871. QDF_STATUS status;
  4872. msg = qdf_nbuf_alloc(
  4873. soc->osdev,
  4874. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4875. /* reserve room for the HTC header */
  4876. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4877. if (!msg)
  4878. return QDF_STATUS_E_NOMEM;
  4879. /*
  4880. * Set the length of the message.
  4881. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4882. * separately during the below call to qdf_nbuf_push_head.
  4883. * The contribution from the HTC header is added separately inside HTC.
  4884. */
  4885. if (!qdf_nbuf_put_tail(msg,
  4886. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4887. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4888. qdf_nbuf_free(msg);
  4889. return QDF_STATUS_E_FAILURE;
  4890. }
  4891. /* fill in the message contents */
  4892. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4893. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4894. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4895. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4896. htt_logger_bufp = (uint8_t *)msg_word;
  4897. *msg_word = 0;
  4898. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4899. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4900. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4901. msg_word++;
  4902. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4903. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4904. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4905. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4906. msg_word++;
  4907. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4908. *msg_word,
  4909. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4910. msg_word++;
  4911. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4912. *msg_word,
  4913. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4914. msg_word++;
  4915. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4916. *msg_word,
  4917. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4918. msg_word++;
  4919. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4920. *msg_word,
  4921. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4922. msg_word++;
  4923. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4924. *msg_word,
  4925. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4926. msg_word++;
  4927. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4928. *msg_word,
  4929. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4930. msg_word++;
  4931. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4932. *msg_word,
  4933. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4934. msg_word++;
  4935. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4936. *msg_word,
  4937. qdf_htonl(
  4938. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4939. msg_word++;
  4940. HTT_RX_FSE_SOURCEPORT_SET(
  4941. *msg_word,
  4942. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4943. HTT_RX_FSE_DESTPORT_SET(
  4944. *msg_word,
  4945. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4946. msg_word++;
  4947. HTT_RX_FSE_L4_PROTO_SET(
  4948. *msg_word,
  4949. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4950. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4951. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4952. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4953. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4954. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4955. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4956. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4957. }
  4958. pkt = htt_htc_pkt_alloc(soc);
  4959. if (!pkt) {
  4960. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4961. qdf_assert(0);
  4962. qdf_nbuf_free(msg);
  4963. return QDF_STATUS_E_RESOURCES; /* failure */
  4964. }
  4965. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4966. SET_HTC_PACKET_INFO_TX(
  4967. &pkt->htc_pkt,
  4968. dp_htt_h2t_send_complete_free_netbuf,
  4969. qdf_nbuf_data(msg),
  4970. qdf_nbuf_len(msg),
  4971. soc->htc_endpoint,
  4972. /* tag for no FW response msg */
  4973. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4974. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4975. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4976. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4977. htt_logger_bufp);
  4978. if (status == QDF_STATUS_SUCCESS) {
  4979. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4980. fse_op_info->pdev_id);
  4981. } else {
  4982. qdf_nbuf_free(msg);
  4983. htt_htc_pkt_free(soc, pkt);
  4984. }
  4985. return status;
  4986. }
  4987. /**
  4988. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4989. * @pdev: DP pdev handle
  4990. * @fse_op_info: Flow entry parameters
  4991. *
  4992. * Return: Success when HTT message is sent, error on failure
  4993. */
  4994. QDF_STATUS
  4995. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4996. struct dp_htt_rx_fisa_cfg *fisa_config)
  4997. {
  4998. struct htt_soc *soc = pdev->soc->htt_handle;
  4999. struct dp_htt_htc_pkt *pkt;
  5000. qdf_nbuf_t msg;
  5001. u_int32_t *msg_word;
  5002. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  5003. uint8_t *htt_logger_bufp;
  5004. uint32_t len;
  5005. QDF_STATUS status;
  5006. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5007. msg = qdf_nbuf_alloc(soc->osdev,
  5008. len,
  5009. /* reserve room for the HTC header */
  5010. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  5011. 4,
  5012. TRUE);
  5013. if (!msg)
  5014. return QDF_STATUS_E_NOMEM;
  5015. /*
  5016. * Set the length of the message.
  5017. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  5018. * separately during the below call to qdf_nbuf_push_head.
  5019. * The contribution from the HTC header is added separately inside HTC.
  5020. */
  5021. if (!qdf_nbuf_put_tail(msg,
  5022. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  5023. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  5024. qdf_nbuf_free(msg);
  5025. return QDF_STATUS_E_FAILURE;
  5026. }
  5027. /* fill in the message contents */
  5028. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  5029. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5030. /* rewind beyond alignment pad to get to the HTC header reserved area */
  5031. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  5032. htt_logger_bufp = (uint8_t *)msg_word;
  5033. *msg_word = 0;
  5034. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  5035. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  5036. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  5037. msg_word++;
  5038. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  5039. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  5040. msg_word++;
  5041. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  5042. pkt = htt_htc_pkt_alloc(soc);
  5043. if (!pkt) {
  5044. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  5045. qdf_assert(0);
  5046. qdf_nbuf_free(msg);
  5047. return QDF_STATUS_E_RESOURCES; /* failure */
  5048. }
  5049. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  5050. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  5051. dp_htt_h2t_send_complete_free_netbuf,
  5052. qdf_nbuf_data(msg),
  5053. qdf_nbuf_len(msg),
  5054. soc->htc_endpoint,
  5055. /* tag for no FW response msg */
  5056. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  5057. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  5058. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  5059. htt_logger_bufp);
  5060. if (status == QDF_STATUS_SUCCESS) {
  5061. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  5062. fisa_config->pdev_id);
  5063. } else {
  5064. qdf_nbuf_free(msg);
  5065. htt_htc_pkt_free(soc, pkt);
  5066. }
  5067. return status;
  5068. }