dp_htt.c 166 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751
  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. 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_PKT_TLV_SET(*msg_word,
  1163. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  1164. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  1165. htt_tlv_filter->offset_valid);
  1166. if (mon_drop_th > 0)
  1167. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1168. 1);
  1169. else
  1170. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1171. 0);
  1172. /* word 1 */
  1173. msg_word++;
  1174. *msg_word = 0;
  1175. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  1176. ring_buf_size);
  1177. /* word 2 */
  1178. msg_word++;
  1179. *msg_word = 0;
  1180. if (htt_tlv_filter->enable_fp) {
  1181. /* TYPE: MGMT */
  1182. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1183. FP, MGMT, 0000,
  1184. (htt_tlv_filter->fp_mgmt_filter &
  1185. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1186. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1187. FP, MGMT, 0001,
  1188. (htt_tlv_filter->fp_mgmt_filter &
  1189. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1190. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1191. FP, MGMT, 0010,
  1192. (htt_tlv_filter->fp_mgmt_filter &
  1193. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1194. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1195. FP, MGMT, 0011,
  1196. (htt_tlv_filter->fp_mgmt_filter &
  1197. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1198. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1199. FP, MGMT, 0100,
  1200. (htt_tlv_filter->fp_mgmt_filter &
  1201. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1202. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1203. FP, MGMT, 0101,
  1204. (htt_tlv_filter->fp_mgmt_filter &
  1205. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1206. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1207. FP, MGMT, 0110,
  1208. (htt_tlv_filter->fp_mgmt_filter &
  1209. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1210. /* reserved */
  1211. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  1212. MGMT, 0111,
  1213. (htt_tlv_filter->fp_mgmt_filter &
  1214. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1215. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1216. FP, MGMT, 1000,
  1217. (htt_tlv_filter->fp_mgmt_filter &
  1218. FILTER_MGMT_BEACON) ? 1 : 0);
  1219. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1220. FP, MGMT, 1001,
  1221. (htt_tlv_filter->fp_mgmt_filter &
  1222. FILTER_MGMT_ATIM) ? 1 : 0);
  1223. }
  1224. if (htt_tlv_filter->enable_md) {
  1225. /* TYPE: MGMT */
  1226. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1227. MD, MGMT, 0000,
  1228. (htt_tlv_filter->md_mgmt_filter &
  1229. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1230. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1231. MD, MGMT, 0001,
  1232. (htt_tlv_filter->md_mgmt_filter &
  1233. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1234. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1235. MD, MGMT, 0010,
  1236. (htt_tlv_filter->md_mgmt_filter &
  1237. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1238. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1239. MD, MGMT, 0011,
  1240. (htt_tlv_filter->md_mgmt_filter &
  1241. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1242. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1243. MD, MGMT, 0100,
  1244. (htt_tlv_filter->md_mgmt_filter &
  1245. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1246. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1247. MD, MGMT, 0101,
  1248. (htt_tlv_filter->md_mgmt_filter &
  1249. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1250. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1251. MD, MGMT, 0110,
  1252. (htt_tlv_filter->md_mgmt_filter &
  1253. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1254. /* reserved */
  1255. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  1256. MGMT, 0111,
  1257. (htt_tlv_filter->md_mgmt_filter &
  1258. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1259. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1260. MD, MGMT, 1000,
  1261. (htt_tlv_filter->md_mgmt_filter &
  1262. FILTER_MGMT_BEACON) ? 1 : 0);
  1263. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1264. MD, MGMT, 1001,
  1265. (htt_tlv_filter->md_mgmt_filter &
  1266. FILTER_MGMT_ATIM) ? 1 : 0);
  1267. }
  1268. if (htt_tlv_filter->enable_mo) {
  1269. /* TYPE: MGMT */
  1270. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1271. MO, MGMT, 0000,
  1272. (htt_tlv_filter->mo_mgmt_filter &
  1273. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1274. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1275. MO, MGMT, 0001,
  1276. (htt_tlv_filter->mo_mgmt_filter &
  1277. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1278. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1279. MO, MGMT, 0010,
  1280. (htt_tlv_filter->mo_mgmt_filter &
  1281. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1282. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1283. MO, MGMT, 0011,
  1284. (htt_tlv_filter->mo_mgmt_filter &
  1285. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1286. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1287. MO, MGMT, 0100,
  1288. (htt_tlv_filter->mo_mgmt_filter &
  1289. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1290. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1291. MO, MGMT, 0101,
  1292. (htt_tlv_filter->mo_mgmt_filter &
  1293. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1294. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1295. MO, MGMT, 0110,
  1296. (htt_tlv_filter->mo_mgmt_filter &
  1297. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1298. /* reserved */
  1299. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  1300. MGMT, 0111,
  1301. (htt_tlv_filter->mo_mgmt_filter &
  1302. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1303. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1304. MO, MGMT, 1000,
  1305. (htt_tlv_filter->mo_mgmt_filter &
  1306. FILTER_MGMT_BEACON) ? 1 : 0);
  1307. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1308. MO, MGMT, 1001,
  1309. (htt_tlv_filter->mo_mgmt_filter &
  1310. FILTER_MGMT_ATIM) ? 1 : 0);
  1311. }
  1312. /* word 3 */
  1313. msg_word++;
  1314. *msg_word = 0;
  1315. if (htt_tlv_filter->enable_fp) {
  1316. /* TYPE: MGMT */
  1317. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1318. FP, MGMT, 1010,
  1319. (htt_tlv_filter->fp_mgmt_filter &
  1320. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1321. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1322. FP, MGMT, 1011,
  1323. (htt_tlv_filter->fp_mgmt_filter &
  1324. FILTER_MGMT_AUTH) ? 1 : 0);
  1325. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1326. FP, MGMT, 1100,
  1327. (htt_tlv_filter->fp_mgmt_filter &
  1328. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1329. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1330. FP, MGMT, 1101,
  1331. (htt_tlv_filter->fp_mgmt_filter &
  1332. FILTER_MGMT_ACTION) ? 1 : 0);
  1333. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1334. FP, MGMT, 1110,
  1335. (htt_tlv_filter->fp_mgmt_filter &
  1336. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1337. /* reserved*/
  1338. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  1339. MGMT, 1111,
  1340. (htt_tlv_filter->fp_mgmt_filter &
  1341. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1342. }
  1343. if (htt_tlv_filter->enable_md) {
  1344. /* TYPE: MGMT */
  1345. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1346. MD, MGMT, 1010,
  1347. (htt_tlv_filter->md_mgmt_filter &
  1348. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1349. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1350. MD, MGMT, 1011,
  1351. (htt_tlv_filter->md_mgmt_filter &
  1352. FILTER_MGMT_AUTH) ? 1 : 0);
  1353. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1354. MD, MGMT, 1100,
  1355. (htt_tlv_filter->md_mgmt_filter &
  1356. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1357. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1358. MD, MGMT, 1101,
  1359. (htt_tlv_filter->md_mgmt_filter &
  1360. FILTER_MGMT_ACTION) ? 1 : 0);
  1361. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1362. MD, MGMT, 1110,
  1363. (htt_tlv_filter->md_mgmt_filter &
  1364. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1365. }
  1366. if (htt_tlv_filter->enable_mo) {
  1367. /* TYPE: MGMT */
  1368. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1369. MO, MGMT, 1010,
  1370. (htt_tlv_filter->mo_mgmt_filter &
  1371. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1372. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1373. MO, MGMT, 1011,
  1374. (htt_tlv_filter->mo_mgmt_filter &
  1375. FILTER_MGMT_AUTH) ? 1 : 0);
  1376. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1377. MO, MGMT, 1100,
  1378. (htt_tlv_filter->mo_mgmt_filter &
  1379. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1380. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1381. MO, MGMT, 1101,
  1382. (htt_tlv_filter->mo_mgmt_filter &
  1383. FILTER_MGMT_ACTION) ? 1 : 0);
  1384. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1385. MO, MGMT, 1110,
  1386. (htt_tlv_filter->mo_mgmt_filter &
  1387. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1388. /* reserved*/
  1389. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1390. MGMT, 1111,
  1391. (htt_tlv_filter->mo_mgmt_filter &
  1392. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1393. }
  1394. /* word 4 */
  1395. msg_word++;
  1396. *msg_word = 0;
  1397. if (htt_tlv_filter->enable_fp) {
  1398. /* TYPE: CTRL */
  1399. /* reserved */
  1400. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1401. CTRL, 0000,
  1402. (htt_tlv_filter->fp_ctrl_filter &
  1403. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1404. /* reserved */
  1405. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1406. CTRL, 0001,
  1407. (htt_tlv_filter->fp_ctrl_filter &
  1408. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1409. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1410. CTRL, 0010,
  1411. (htt_tlv_filter->fp_ctrl_filter &
  1412. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1413. /* reserved */
  1414. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1415. CTRL, 0011,
  1416. (htt_tlv_filter->fp_ctrl_filter &
  1417. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1418. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1419. CTRL, 0100,
  1420. (htt_tlv_filter->fp_ctrl_filter &
  1421. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1422. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1423. CTRL, 0101,
  1424. (htt_tlv_filter->fp_ctrl_filter &
  1425. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1426. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1427. CTRL, 0110,
  1428. (htt_tlv_filter->fp_ctrl_filter &
  1429. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1430. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1431. CTRL, 0111,
  1432. (htt_tlv_filter->fp_ctrl_filter &
  1433. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1434. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1435. CTRL, 1000,
  1436. (htt_tlv_filter->fp_ctrl_filter &
  1437. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1438. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1439. CTRL, 1001,
  1440. (htt_tlv_filter->fp_ctrl_filter &
  1441. FILTER_CTRL_BA) ? 1 : 0);
  1442. }
  1443. if (htt_tlv_filter->enable_md) {
  1444. /* TYPE: CTRL */
  1445. /* reserved */
  1446. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1447. CTRL, 0000,
  1448. (htt_tlv_filter->md_ctrl_filter &
  1449. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1450. /* reserved */
  1451. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1452. CTRL, 0001,
  1453. (htt_tlv_filter->md_ctrl_filter &
  1454. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1455. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1456. CTRL, 0010,
  1457. (htt_tlv_filter->md_ctrl_filter &
  1458. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1459. /* reserved */
  1460. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1461. CTRL, 0011,
  1462. (htt_tlv_filter->md_ctrl_filter &
  1463. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1464. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1465. CTRL, 0100,
  1466. (htt_tlv_filter->md_ctrl_filter &
  1467. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1468. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1469. CTRL, 0101,
  1470. (htt_tlv_filter->md_ctrl_filter &
  1471. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1472. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1473. CTRL, 0110,
  1474. (htt_tlv_filter->md_ctrl_filter &
  1475. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1476. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1477. CTRL, 0111,
  1478. (htt_tlv_filter->md_ctrl_filter &
  1479. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1480. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1481. CTRL, 1000,
  1482. (htt_tlv_filter->md_ctrl_filter &
  1483. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1484. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1485. CTRL, 1001,
  1486. (htt_tlv_filter->md_ctrl_filter &
  1487. FILTER_CTRL_BA) ? 1 : 0);
  1488. }
  1489. if (htt_tlv_filter->enable_mo) {
  1490. /* TYPE: CTRL */
  1491. /* reserved */
  1492. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1493. CTRL, 0000,
  1494. (htt_tlv_filter->mo_ctrl_filter &
  1495. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1496. /* reserved */
  1497. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1498. CTRL, 0001,
  1499. (htt_tlv_filter->mo_ctrl_filter &
  1500. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1501. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1502. CTRL, 0010,
  1503. (htt_tlv_filter->mo_ctrl_filter &
  1504. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1505. /* reserved */
  1506. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1507. CTRL, 0011,
  1508. (htt_tlv_filter->mo_ctrl_filter &
  1509. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1510. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1511. CTRL, 0100,
  1512. (htt_tlv_filter->mo_ctrl_filter &
  1513. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1514. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1515. CTRL, 0101,
  1516. (htt_tlv_filter->mo_ctrl_filter &
  1517. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1518. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1519. CTRL, 0110,
  1520. (htt_tlv_filter->mo_ctrl_filter &
  1521. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1522. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1523. CTRL, 0111,
  1524. (htt_tlv_filter->mo_ctrl_filter &
  1525. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1526. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1527. CTRL, 1000,
  1528. (htt_tlv_filter->mo_ctrl_filter &
  1529. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1530. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1531. CTRL, 1001,
  1532. (htt_tlv_filter->mo_ctrl_filter &
  1533. FILTER_CTRL_BA) ? 1 : 0);
  1534. }
  1535. /* word 5 */
  1536. msg_word++;
  1537. *msg_word = 0;
  1538. if (htt_tlv_filter->enable_fp) {
  1539. /* TYPE: CTRL */
  1540. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1541. CTRL, 1010,
  1542. (htt_tlv_filter->fp_ctrl_filter &
  1543. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1544. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1545. CTRL, 1011,
  1546. (htt_tlv_filter->fp_ctrl_filter &
  1547. FILTER_CTRL_RTS) ? 1 : 0);
  1548. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1549. CTRL, 1100,
  1550. (htt_tlv_filter->fp_ctrl_filter &
  1551. FILTER_CTRL_CTS) ? 1 : 0);
  1552. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1553. CTRL, 1101,
  1554. (htt_tlv_filter->fp_ctrl_filter &
  1555. FILTER_CTRL_ACK) ? 1 : 0);
  1556. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1557. CTRL, 1110,
  1558. (htt_tlv_filter->fp_ctrl_filter &
  1559. FILTER_CTRL_CFEND) ? 1 : 0);
  1560. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1561. CTRL, 1111,
  1562. (htt_tlv_filter->fp_ctrl_filter &
  1563. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1564. /* TYPE: DATA */
  1565. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1566. DATA, MCAST,
  1567. (htt_tlv_filter->fp_data_filter &
  1568. FILTER_DATA_MCAST) ? 1 : 0);
  1569. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1570. DATA, UCAST,
  1571. (htt_tlv_filter->fp_data_filter &
  1572. FILTER_DATA_UCAST) ? 1 : 0);
  1573. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1574. DATA, NULL,
  1575. (htt_tlv_filter->fp_data_filter &
  1576. FILTER_DATA_NULL) ? 1 : 0);
  1577. }
  1578. if (htt_tlv_filter->enable_md) {
  1579. /* TYPE: CTRL */
  1580. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1581. CTRL, 1010,
  1582. (htt_tlv_filter->md_ctrl_filter &
  1583. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1584. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1585. CTRL, 1011,
  1586. (htt_tlv_filter->md_ctrl_filter &
  1587. FILTER_CTRL_RTS) ? 1 : 0);
  1588. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1589. CTRL, 1100,
  1590. (htt_tlv_filter->md_ctrl_filter &
  1591. FILTER_CTRL_CTS) ? 1 : 0);
  1592. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1593. CTRL, 1101,
  1594. (htt_tlv_filter->md_ctrl_filter &
  1595. FILTER_CTRL_ACK) ? 1 : 0);
  1596. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1597. CTRL, 1110,
  1598. (htt_tlv_filter->md_ctrl_filter &
  1599. FILTER_CTRL_CFEND) ? 1 : 0);
  1600. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1601. CTRL, 1111,
  1602. (htt_tlv_filter->md_ctrl_filter &
  1603. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1604. /* TYPE: DATA */
  1605. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1606. DATA, MCAST,
  1607. (htt_tlv_filter->md_data_filter &
  1608. FILTER_DATA_MCAST) ? 1 : 0);
  1609. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1610. DATA, UCAST,
  1611. (htt_tlv_filter->md_data_filter &
  1612. FILTER_DATA_UCAST) ? 1 : 0);
  1613. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1614. DATA, NULL,
  1615. (htt_tlv_filter->md_data_filter &
  1616. FILTER_DATA_NULL) ? 1 : 0);
  1617. }
  1618. if (htt_tlv_filter->enable_mo) {
  1619. /* TYPE: CTRL */
  1620. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1621. CTRL, 1010,
  1622. (htt_tlv_filter->mo_ctrl_filter &
  1623. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1624. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1625. CTRL, 1011,
  1626. (htt_tlv_filter->mo_ctrl_filter &
  1627. FILTER_CTRL_RTS) ? 1 : 0);
  1628. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1629. CTRL, 1100,
  1630. (htt_tlv_filter->mo_ctrl_filter &
  1631. FILTER_CTRL_CTS) ? 1 : 0);
  1632. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1633. CTRL, 1101,
  1634. (htt_tlv_filter->mo_ctrl_filter &
  1635. FILTER_CTRL_ACK) ? 1 : 0);
  1636. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1637. CTRL, 1110,
  1638. (htt_tlv_filter->mo_ctrl_filter &
  1639. FILTER_CTRL_CFEND) ? 1 : 0);
  1640. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1641. CTRL, 1111,
  1642. (htt_tlv_filter->mo_ctrl_filter &
  1643. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1644. /* TYPE: DATA */
  1645. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1646. DATA, MCAST,
  1647. (htt_tlv_filter->mo_data_filter &
  1648. FILTER_DATA_MCAST) ? 1 : 0);
  1649. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1650. DATA, UCAST,
  1651. (htt_tlv_filter->mo_data_filter &
  1652. FILTER_DATA_UCAST) ? 1 : 0);
  1653. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1654. DATA, NULL,
  1655. (htt_tlv_filter->mo_data_filter &
  1656. FILTER_DATA_NULL) ? 1 : 0);
  1657. }
  1658. /* word 6 */
  1659. msg_word++;
  1660. *msg_word = 0;
  1661. tlv_filter = 0;
  1662. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1663. htt_tlv_filter->mpdu_start);
  1664. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1665. htt_tlv_filter->msdu_start);
  1666. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1667. htt_tlv_filter->packet);
  1668. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1669. htt_tlv_filter->msdu_end);
  1670. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1671. htt_tlv_filter->mpdu_end);
  1672. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1673. htt_tlv_filter->packet_header);
  1674. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1675. htt_tlv_filter->attention);
  1676. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1677. htt_tlv_filter->ppdu_start);
  1678. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1679. htt_tlv_filter->ppdu_end);
  1680. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1681. htt_tlv_filter->ppdu_end_user_stats);
  1682. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1683. PPDU_END_USER_STATS_EXT,
  1684. htt_tlv_filter->ppdu_end_user_stats_ext);
  1685. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1686. htt_tlv_filter->ppdu_end_status_done);
  1687. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1688. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1689. htt_tlv_filter->header_per_msdu);
  1690. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1691. msg_word++;
  1692. *msg_word = 0;
  1693. if (htt_tlv_filter->offset_valid) {
  1694. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1695. htt_tlv_filter->rx_packet_offset);
  1696. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1697. htt_tlv_filter->rx_header_offset);
  1698. msg_word++;
  1699. *msg_word = 0;
  1700. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1701. htt_tlv_filter->rx_mpdu_end_offset);
  1702. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1703. htt_tlv_filter->rx_mpdu_start_offset);
  1704. msg_word++;
  1705. *msg_word = 0;
  1706. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1707. htt_tlv_filter->rx_msdu_end_offset);
  1708. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1709. htt_tlv_filter->rx_msdu_start_offset);
  1710. msg_word++;
  1711. *msg_word = 0;
  1712. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1713. htt_tlv_filter->rx_attn_offset);
  1714. msg_word++;
  1715. *msg_word = 0;
  1716. } else {
  1717. msg_word += 4;
  1718. *msg_word = 0;
  1719. }
  1720. if (mon_drop_th > 0)
  1721. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1722. mon_drop_th);
  1723. /* "response_required" field should be set if a HTT response message is
  1724. * required after setting up the ring.
  1725. */
  1726. pkt = htt_htc_pkt_alloc(soc);
  1727. if (!pkt)
  1728. goto fail1;
  1729. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1730. SET_HTC_PACKET_INFO_TX(
  1731. &pkt->htc_pkt,
  1732. dp_htt_h2t_send_complete_free_netbuf,
  1733. qdf_nbuf_data(htt_msg),
  1734. qdf_nbuf_len(htt_msg),
  1735. soc->htc_endpoint,
  1736. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1737. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1738. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1739. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1740. htt_logger_bufp);
  1741. if (status != QDF_STATUS_SUCCESS) {
  1742. qdf_nbuf_free(htt_msg);
  1743. htt_htc_pkt_free(soc, pkt);
  1744. }
  1745. return status;
  1746. fail1:
  1747. qdf_nbuf_free(htt_msg);
  1748. fail0:
  1749. return QDF_STATUS_E_FAILURE;
  1750. }
  1751. #if defined(HTT_STATS_ENABLE)
  1752. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1753. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1754. {
  1755. uint32_t pdev_id;
  1756. uint32_t *msg_word = NULL;
  1757. uint32_t msg_remain_len = 0;
  1758. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1759. /*COOKIE MSB*/
  1760. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1761. /* stats message length + 16 size of HTT header*/
  1762. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1763. (uint32_t)DP_EXT_MSG_LENGTH);
  1764. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1765. msg_word, msg_remain_len,
  1766. WDI_NO_VAL, pdev_id);
  1767. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1768. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1769. }
  1770. /* Need to be freed here as WDI handler will
  1771. * make a copy of pkt to send data to application
  1772. */
  1773. qdf_nbuf_free(htt_msg);
  1774. return QDF_STATUS_SUCCESS;
  1775. }
  1776. #else
  1777. static inline QDF_STATUS
  1778. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1779. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1780. {
  1781. return QDF_STATUS_E_NOSUPPORT;
  1782. }
  1783. #endif
  1784. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1785. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer
  1786. * @pdev: dp pdev handle
  1787. * @msg_word: HTT msg
  1788. * @msg_len: Length of HTT msg sent
  1789. *
  1790. * Return: none
  1791. */
  1792. static inline void
  1793. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1794. uint32_t msg_len)
  1795. {
  1796. struct htt_dbgfs_cfg dbgfs_cfg;
  1797. int done = 0;
  1798. /* send 5th word of HTT msg to upper layer */
  1799. dbgfs_cfg.msg_word = (msg_word + 4);
  1800. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1801. /* stats message length + 16 size of HTT header*/
  1802. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1803. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1804. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1805. (msg_len - HTT_HEADER_LEN));
  1806. /* Get TLV Done bit from 4th msg word */
  1807. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1808. if (done) {
  1809. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1810. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1811. "Failed to set event for debugfs htt stats");
  1812. }
  1813. }
  1814. #else
  1815. static inline void
  1816. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1817. uint32_t msg_len)
  1818. {
  1819. }
  1820. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1821. /**
  1822. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1823. * @htt_stats: htt stats info
  1824. *
  1825. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1826. * contains sub messages which are identified by a TLV header.
  1827. * In this function we will process the stream of T2H messages and read all the
  1828. * TLV contained in the message.
  1829. *
  1830. * THe following cases have been taken care of
  1831. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1832. * In this case the buffer will contain multiple tlvs.
  1833. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1834. * Only one tlv will be contained in the HTT message and this tag
  1835. * will extend onto the next buffer.
  1836. * Case 3: When the buffer is the continuation of the previous message
  1837. * Case 4: tlv length is 0. which will indicate the end of message
  1838. *
  1839. * return: void
  1840. */
  1841. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1842. struct dp_soc *soc)
  1843. {
  1844. htt_tlv_tag_t tlv_type = 0xff;
  1845. qdf_nbuf_t htt_msg = NULL;
  1846. uint32_t *msg_word;
  1847. uint8_t *tlv_buf_head = NULL;
  1848. uint8_t *tlv_buf_tail = NULL;
  1849. uint32_t msg_remain_len = 0;
  1850. uint32_t tlv_remain_len = 0;
  1851. uint32_t *tlv_start;
  1852. int cookie_val = 0;
  1853. int cookie_msb = 0;
  1854. int pdev_id;
  1855. bool copy_stats = false;
  1856. struct dp_pdev *pdev;
  1857. /* Process node in the HTT message queue */
  1858. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1859. != NULL) {
  1860. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1861. cookie_val = *(msg_word + 1);
  1862. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1863. *(msg_word +
  1864. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1865. if (cookie_val) {
  1866. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1867. == QDF_STATUS_SUCCESS) {
  1868. continue;
  1869. }
  1870. }
  1871. cookie_msb = *(msg_word + 2);
  1872. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1873. pdev = soc->pdev_list[pdev_id];
  1874. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1875. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1876. htt_stats->msg_len);
  1877. qdf_nbuf_free(htt_msg);
  1878. continue;
  1879. }
  1880. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1881. copy_stats = true;
  1882. /* read 5th word */
  1883. msg_word = msg_word + 4;
  1884. msg_remain_len = qdf_min(htt_stats->msg_len,
  1885. (uint32_t) DP_EXT_MSG_LENGTH);
  1886. /* Keep processing the node till node length is 0 */
  1887. while (msg_remain_len) {
  1888. /*
  1889. * if message is not a continuation of previous message
  1890. * read the tlv type and tlv length
  1891. */
  1892. if (!tlv_buf_head) {
  1893. tlv_type = HTT_STATS_TLV_TAG_GET(
  1894. *msg_word);
  1895. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1896. *msg_word);
  1897. }
  1898. if (tlv_remain_len == 0) {
  1899. msg_remain_len = 0;
  1900. if (tlv_buf_head) {
  1901. qdf_mem_free(tlv_buf_head);
  1902. tlv_buf_head = NULL;
  1903. tlv_buf_tail = NULL;
  1904. }
  1905. goto error;
  1906. }
  1907. if (!tlv_buf_head)
  1908. tlv_remain_len += HTT_TLV_HDR_LEN;
  1909. if ((tlv_remain_len <= msg_remain_len)) {
  1910. /* Case 3 */
  1911. if (tlv_buf_head) {
  1912. qdf_mem_copy(tlv_buf_tail,
  1913. (uint8_t *)msg_word,
  1914. tlv_remain_len);
  1915. tlv_start = (uint32_t *)tlv_buf_head;
  1916. } else {
  1917. /* Case 1 */
  1918. tlv_start = msg_word;
  1919. }
  1920. if (copy_stats)
  1921. dp_htt_stats_copy_tag(pdev,
  1922. tlv_type,
  1923. tlv_start);
  1924. else
  1925. dp_htt_stats_print_tag(pdev,
  1926. tlv_type,
  1927. tlv_start);
  1928. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1929. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1930. dp_peer_update_inactive_time(pdev,
  1931. tlv_type,
  1932. tlv_start);
  1933. msg_remain_len -= tlv_remain_len;
  1934. msg_word = (uint32_t *)
  1935. (((uint8_t *)msg_word) +
  1936. tlv_remain_len);
  1937. tlv_remain_len = 0;
  1938. if (tlv_buf_head) {
  1939. qdf_mem_free(tlv_buf_head);
  1940. tlv_buf_head = NULL;
  1941. tlv_buf_tail = NULL;
  1942. }
  1943. } else { /* tlv_remain_len > msg_remain_len */
  1944. /* Case 2 & 3 */
  1945. if (!tlv_buf_head) {
  1946. tlv_buf_head = qdf_mem_malloc(
  1947. tlv_remain_len);
  1948. if (!tlv_buf_head) {
  1949. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1950. QDF_TRACE_LEVEL_ERROR,
  1951. "Alloc failed");
  1952. goto error;
  1953. }
  1954. tlv_buf_tail = tlv_buf_head;
  1955. }
  1956. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1957. msg_remain_len);
  1958. tlv_remain_len -= msg_remain_len;
  1959. tlv_buf_tail += msg_remain_len;
  1960. }
  1961. }
  1962. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1963. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1964. }
  1965. qdf_nbuf_free(htt_msg);
  1966. }
  1967. return;
  1968. error:
  1969. qdf_nbuf_free(htt_msg);
  1970. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1971. != NULL)
  1972. qdf_nbuf_free(htt_msg);
  1973. }
  1974. void htt_t2h_stats_handler(void *context)
  1975. {
  1976. struct dp_soc *soc = (struct dp_soc *)context;
  1977. struct htt_stats_context htt_stats;
  1978. uint32_t *msg_word;
  1979. qdf_nbuf_t htt_msg = NULL;
  1980. uint8_t done;
  1981. uint32_t rem_stats;
  1982. if (!soc) {
  1983. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1984. "soc is NULL");
  1985. return;
  1986. }
  1987. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1988. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1989. "soc: 0x%pK, init_done: %d", soc,
  1990. qdf_atomic_read(&soc->cmn_init_done));
  1991. return;
  1992. }
  1993. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1994. qdf_nbuf_queue_init(&htt_stats.msg);
  1995. /* pull one completed stats from soc->htt_stats_msg and process */
  1996. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1997. if (!soc->htt_stats.num_stats) {
  1998. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1999. return;
  2000. }
  2001. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  2002. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  2003. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  2004. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2005. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  2006. /*
  2007. * Done bit signifies that this is the last T2H buffer in the
  2008. * stream of HTT EXT STATS message
  2009. */
  2010. if (done)
  2011. break;
  2012. }
  2013. rem_stats = --soc->htt_stats.num_stats;
  2014. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2015. /* If there are more stats to process, schedule stats work again.
  2016. * Scheduling prior to processing ht_stats to queue with early
  2017. * index
  2018. */
  2019. if (rem_stats)
  2020. qdf_sched_work(0, &soc->htt_stats.work);
  2021. dp_process_htt_stat_msg(&htt_stats, soc);
  2022. }
  2023. /*
  2024. * dp_get_ppdu_info_user_index: Find and allocate a per-user descriptor for a PPDU,
  2025. * if a new peer id arrives in a PPDU
  2026. * pdev: DP pdev handle
  2027. * @peer_id : peer unique identifier
  2028. * @ppdu_info: per ppdu tlv structure
  2029. *
  2030. * return:user index to be populated
  2031. */
  2032. #ifdef FEATURE_PERPKT_INFO
  2033. static uint8_t dp_get_ppdu_info_user_index(struct dp_pdev *pdev,
  2034. uint16_t peer_id,
  2035. struct ppdu_info *ppdu_info)
  2036. {
  2037. uint8_t user_index = 0;
  2038. struct cdp_tx_completion_ppdu *ppdu_desc;
  2039. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2040. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2041. while ((user_index + 1) <= ppdu_info->last_user) {
  2042. ppdu_user_desc = &ppdu_desc->user[user_index];
  2043. if (ppdu_user_desc->peer_id != peer_id) {
  2044. user_index++;
  2045. continue;
  2046. } else {
  2047. /* Max users possible is 8 so user array index should
  2048. * not exceed 7
  2049. */
  2050. qdf_assert_always(user_index <= (ppdu_desc->max_users - 1));
  2051. return user_index;
  2052. }
  2053. }
  2054. ppdu_info->last_user++;
  2055. /* Max users possible is 8 so last user should not exceed 8 */
  2056. qdf_assert_always(ppdu_info->last_user <= ppdu_desc->max_users);
  2057. return ppdu_info->last_user - 1;
  2058. }
  2059. /*
  2060. * dp_process_ppdu_stats_common_tlv: Process htt_ppdu_stats_common_tlv
  2061. * pdev: DP pdev handle
  2062. * @tag_buf: buffer containing the tlv htt_ppdu_stats_common_tlv
  2063. * @ppdu_info: per ppdu tlv structure
  2064. *
  2065. * return:void
  2066. */
  2067. static void dp_process_ppdu_stats_common_tlv(struct dp_pdev *pdev,
  2068. uint32_t *tag_buf, struct ppdu_info *ppdu_info)
  2069. {
  2070. uint16_t frame_type;
  2071. uint16_t frame_ctrl;
  2072. uint16_t freq;
  2073. struct dp_soc *soc = NULL;
  2074. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2075. uint64_t ppdu_start_timestamp;
  2076. uint32_t *start_tag_buf;
  2077. start_tag_buf = tag_buf;
  2078. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2079. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  2080. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RING_ID_SCH_CMD_ID);
  2081. ppdu_info->sched_cmdid =
  2082. HTT_PPDU_STATS_COMMON_TLV_SCH_CMDID_GET(*tag_buf);
  2083. ppdu_desc->num_users =
  2084. HTT_PPDU_STATS_COMMON_TLV_NUM_USERS_GET(*tag_buf);
  2085. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2086. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(QTYPE_FRM_TYPE);
  2087. frame_type = HTT_PPDU_STATS_COMMON_TLV_FRM_TYPE_GET(*tag_buf);
  2088. ppdu_desc->htt_frame_type = frame_type;
  2089. frame_ctrl = ppdu_desc->frame_ctrl;
  2090. ppdu_desc->bar_ppdu_id = ppdu_info->ppdu_id;
  2091. switch (frame_type) {
  2092. case HTT_STATS_FTYPE_TIDQ_DATA_SU:
  2093. case HTT_STATS_FTYPE_TIDQ_DATA_MU:
  2094. case HTT_STATS_FTYPE_SGEN_QOS_NULL:
  2095. /*
  2096. * for management packet, frame type come as DATA_SU
  2097. * need to check frame_ctrl before setting frame_type
  2098. */
  2099. if (HTT_GET_FRAME_CTRL_TYPE(frame_ctrl) <= FRAME_CTRL_TYPE_CTRL)
  2100. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2101. else
  2102. ppdu_desc->frame_type = CDP_PPDU_FTYPE_DATA;
  2103. break;
  2104. case HTT_STATS_FTYPE_SGEN_MU_BAR:
  2105. case HTT_STATS_FTYPE_SGEN_BAR:
  2106. ppdu_desc->frame_type = CDP_PPDU_FTYPE_BAR;
  2107. break;
  2108. default:
  2109. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  2110. break;
  2111. }
  2112. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(FES_DUR_US);
  2113. ppdu_desc->tx_duration = *tag_buf;
  2114. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_L32_US);
  2115. ppdu_desc->ppdu_start_timestamp = *tag_buf;
  2116. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(CHAN_MHZ_PHY_MODE);
  2117. freq = HTT_PPDU_STATS_COMMON_TLV_CHAN_MHZ_GET(*tag_buf);
  2118. if (freq != ppdu_desc->channel) {
  2119. soc = pdev->soc;
  2120. ppdu_desc->channel = freq;
  2121. pdev->operating_channel.freq = freq;
  2122. if (soc && soc->cdp_soc.ol_ops->freq_to_channel)
  2123. pdev->operating_channel.num =
  2124. soc->cdp_soc.ol_ops->freq_to_channel(soc->ctrl_psoc,
  2125. pdev->pdev_id,
  2126. freq);
  2127. if (soc && soc->cdp_soc.ol_ops->freq_to_band)
  2128. pdev->operating_channel.band =
  2129. soc->cdp_soc.ol_ops->freq_to_band(soc->ctrl_psoc,
  2130. pdev->pdev_id,
  2131. freq);
  2132. }
  2133. ppdu_desc->phy_mode = HTT_PPDU_STATS_COMMON_TLV_PHY_MODE_GET(*tag_buf);
  2134. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(RESV_NUM_UL_BEAM);
  2135. ppdu_desc->phy_ppdu_tx_time_us =
  2136. HTT_PPDU_STATS_COMMON_TLV_PHY_PPDU_TX_TIME_US_GET(*tag_buf);
  2137. ppdu_desc->beam_change =
  2138. HTT_PPDU_STATS_COMMON_TLV_BEAM_CHANGE_GET(*tag_buf);
  2139. ppdu_desc->doppler =
  2140. HTT_PPDU_STATS_COMMON_TLV_DOPPLER_INDICATION_GET(*tag_buf);
  2141. ppdu_desc->spatial_reuse =
  2142. HTT_PPDU_STATS_COMMON_TLV_SPATIAL_REUSE_GET(*tag_buf);
  2143. dp_tx_capture_htt_frame_counter(pdev, frame_type);
  2144. tag_buf = start_tag_buf + HTT_GET_STATS_CMN_INDEX(START_TSTMP_U32_US);
  2145. ppdu_start_timestamp = *tag_buf;
  2146. ppdu_desc->ppdu_start_timestamp |= ((ppdu_start_timestamp <<
  2147. HTT_SHIFT_UPPER_TIMESTAMP) &
  2148. HTT_MASK_UPPER_TIMESTAMP);
  2149. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2150. ppdu_desc->tx_duration;
  2151. /* Ack time stamp is same as end time stamp*/
  2152. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2153. ppdu_desc->ppdu_end_timestamp = ppdu_desc->ppdu_start_timestamp +
  2154. ppdu_desc->tx_duration;
  2155. ppdu_desc->bar_ppdu_start_timestamp = ppdu_desc->ppdu_start_timestamp;
  2156. ppdu_desc->bar_ppdu_end_timestamp = ppdu_desc->ppdu_end_timestamp;
  2157. ppdu_desc->bar_tx_duration = ppdu_desc->tx_duration;
  2158. /* Ack time stamp is same as end time stamp*/
  2159. ppdu_desc->ack_timestamp = ppdu_desc->ppdu_end_timestamp;
  2160. }
  2161. /*
  2162. * dp_process_ppdu_stats_user_common_tlv: Process ppdu_stats_user_common
  2163. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_common_tlv
  2164. * @ppdu_info: per ppdu tlv structure
  2165. *
  2166. * return:void
  2167. */
  2168. static void dp_process_ppdu_stats_user_common_tlv(
  2169. struct dp_pdev *pdev, uint32_t *tag_buf,
  2170. struct ppdu_info *ppdu_info)
  2171. {
  2172. uint16_t peer_id;
  2173. struct cdp_tx_completion_ppdu *ppdu_desc;
  2174. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2175. uint8_t curr_user_index = 0;
  2176. struct dp_peer *peer;
  2177. struct dp_vdev *vdev;
  2178. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2179. ppdu_desc =
  2180. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2181. tag_buf++;
  2182. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2183. curr_user_index =
  2184. dp_get_ppdu_info_user_index(pdev,
  2185. peer_id, ppdu_info);
  2186. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2187. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2188. ppdu_desc->vdev_id =
  2189. HTT_PPDU_STATS_USER_COMMON_TLV_VAP_ID_GET(*tag_buf);
  2190. ppdu_user_desc->peer_id = peer_id;
  2191. tag_buf++;
  2192. if (HTT_PPDU_STATS_USER_COMMON_TLV_DELAYED_BA_GET(*tag_buf)) {
  2193. ppdu_user_desc->delayed_ba = 1;
  2194. ppdu_desc->delayed_ba = 1;
  2195. }
  2196. if (HTT_PPDU_STATS_USER_COMMON_TLV_MCAST_GET(*tag_buf)) {
  2197. ppdu_user_desc->is_mcast = true;
  2198. ppdu_user_desc->mpdu_tried_mcast =
  2199. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2200. ppdu_user_desc->num_mpdu = ppdu_user_desc->mpdu_tried_mcast;
  2201. } else {
  2202. ppdu_user_desc->mpdu_tried_ucast =
  2203. HTT_PPDU_STATS_USER_COMMON_TLV_MPDUS_TRIED_GET(*tag_buf);
  2204. }
  2205. tag_buf++;
  2206. ppdu_user_desc->qos_ctrl =
  2207. HTT_PPDU_STATS_USER_COMMON_TLV_QOS_CTRL_GET(*tag_buf);
  2208. ppdu_user_desc->frame_ctrl =
  2209. HTT_PPDU_STATS_USER_COMMON_TLV_FRAME_CTRL_GET(*tag_buf);
  2210. ppdu_desc->frame_ctrl = ppdu_user_desc->frame_ctrl;
  2211. if (ppdu_user_desc->delayed_ba)
  2212. ppdu_user_desc->mpdu_success = 0;
  2213. tag_buf += 3;
  2214. if (HTT_PPDU_STATS_IS_OPAQUE_VALID_GET(*tag_buf)) {
  2215. ppdu_user_desc->ppdu_cookie =
  2216. HTT_PPDU_STATS_HOST_OPAQUE_COOKIE_GET(*tag_buf);
  2217. ppdu_user_desc->is_ppdu_cookie_valid = 1;
  2218. }
  2219. /* returning earlier causes other feilds unpopulated */
  2220. if (peer_id == DP_SCAN_PEER_ID) {
  2221. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2222. DP_MOD_ID_TX_PPDU_STATS);
  2223. if (!vdev)
  2224. return;
  2225. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2226. QDF_MAC_ADDR_SIZE);
  2227. dp_vdev_unref_delete(pdev->soc, vdev, DP_MOD_ID_TX_PPDU_STATS);
  2228. } else {
  2229. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2230. DP_MOD_ID_TX_PPDU_STATS);
  2231. if (!peer) {
  2232. /*
  2233. * fw sends peer_id which is about to removed but
  2234. * it was already removed in host.
  2235. * eg: for disassoc, fw send ppdu stats
  2236. * with peer id equal to previously associated
  2237. * peer's peer_id but it was removed
  2238. */
  2239. vdev = dp_vdev_get_ref_by_id(pdev->soc,
  2240. ppdu_desc->vdev_id,
  2241. DP_MOD_ID_TX_PPDU_STATS);
  2242. if (!vdev)
  2243. return;
  2244. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2245. vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2246. dp_vdev_unref_delete(pdev->soc, vdev,
  2247. DP_MOD_ID_TX_PPDU_STATS);
  2248. return;
  2249. }
  2250. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2251. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2252. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2253. }
  2254. }
  2255. /**
  2256. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  2257. * @pdev: DP pdev handle
  2258. * @tag_buf: T2H message buffer carrying the user rate TLV
  2259. * @ppdu_info: per ppdu tlv structure
  2260. *
  2261. * return:void
  2262. */
  2263. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  2264. uint32_t *tag_buf,
  2265. struct ppdu_info *ppdu_info)
  2266. {
  2267. uint16_t peer_id;
  2268. struct cdp_tx_completion_ppdu *ppdu_desc;
  2269. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2270. uint8_t curr_user_index = 0;
  2271. struct dp_vdev *vdev;
  2272. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2273. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2274. tag_buf++;
  2275. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2276. curr_user_index =
  2277. dp_get_ppdu_info_user_index(pdev,
  2278. peer_id, ppdu_info);
  2279. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2280. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2281. if (peer_id == DP_SCAN_PEER_ID) {
  2282. vdev = dp_vdev_get_ref_by_id(pdev->soc, ppdu_desc->vdev_id,
  2283. DP_MOD_ID_TX_PPDU_STATS);
  2284. if (!vdev)
  2285. return;
  2286. dp_vdev_unref_delete(pdev->soc, vdev,
  2287. DP_MOD_ID_TX_PPDU_STATS);
  2288. }
  2289. ppdu_user_desc->peer_id = peer_id;
  2290. ppdu_user_desc->tid =
  2291. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  2292. tag_buf += 1;
  2293. ppdu_user_desc->user_pos =
  2294. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  2295. ppdu_user_desc->mu_group_id =
  2296. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2297. tag_buf += 1;
  2298. ppdu_user_desc->ru_start =
  2299. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2300. ppdu_user_desc->ru_tones =
  2301. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2302. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2303. ppdu_desc->usr_ru_tones_sum += ppdu_user_desc->ru_tones;
  2304. tag_buf += 2;
  2305. ppdu_user_desc->ppdu_type =
  2306. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2307. tag_buf++;
  2308. ppdu_user_desc->tx_rate = *tag_buf;
  2309. ppdu_user_desc->ltf_size =
  2310. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2311. ppdu_user_desc->stbc =
  2312. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2313. ppdu_user_desc->he_re =
  2314. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2315. ppdu_user_desc->txbf =
  2316. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2317. ppdu_user_desc->bw =
  2318. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2319. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2320. ppdu_desc->usr_nss_sum += ppdu_user_desc->nss;
  2321. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2322. ppdu_user_desc->preamble =
  2323. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2324. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2325. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2326. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2327. }
  2328. /*
  2329. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2330. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2331. * pdev: DP PDEV handle
  2332. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2333. * @ppdu_info: per ppdu tlv structure
  2334. *
  2335. * return:void
  2336. */
  2337. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2338. struct dp_pdev *pdev, uint32_t *tag_buf,
  2339. struct ppdu_info *ppdu_info)
  2340. {
  2341. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2342. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2343. struct cdp_tx_completion_ppdu *ppdu_desc;
  2344. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2345. uint8_t curr_user_index = 0;
  2346. uint16_t peer_id;
  2347. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2348. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2349. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2350. tag_buf++;
  2351. peer_id =
  2352. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2353. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2354. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2355. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2356. ppdu_user_desc->peer_id = peer_id;
  2357. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2358. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2359. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2360. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2361. (void *)ppdu_user_desc,
  2362. ppdu_info->ppdu_id,
  2363. size);
  2364. }
  2365. /*
  2366. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2367. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2368. * soc: DP SOC handle
  2369. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2370. * @ppdu_info: per ppdu tlv structure
  2371. *
  2372. * return:void
  2373. */
  2374. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2375. struct dp_pdev *pdev, uint32_t *tag_buf,
  2376. struct ppdu_info *ppdu_info)
  2377. {
  2378. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2379. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2380. struct cdp_tx_completion_ppdu *ppdu_desc;
  2381. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2382. uint8_t curr_user_index = 0;
  2383. uint16_t peer_id;
  2384. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2385. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2386. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2387. tag_buf++;
  2388. peer_id =
  2389. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2390. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2391. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2392. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2393. ppdu_user_desc->peer_id = peer_id;
  2394. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2395. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2396. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2397. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2398. (void *)ppdu_user_desc,
  2399. ppdu_info->ppdu_id,
  2400. size);
  2401. }
  2402. /*
  2403. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2404. * htt_ppdu_stats_user_cmpltn_common_tlv
  2405. * soc: DP SOC handle
  2406. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2407. * @ppdu_info: per ppdu tlv structure
  2408. *
  2409. * return:void
  2410. */
  2411. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2412. struct dp_pdev *pdev, uint32_t *tag_buf,
  2413. struct ppdu_info *ppdu_info)
  2414. {
  2415. uint16_t peer_id;
  2416. struct cdp_tx_completion_ppdu *ppdu_desc;
  2417. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2418. uint8_t curr_user_index = 0;
  2419. uint8_t bw_iter;
  2420. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2421. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2422. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2423. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2424. tag_buf++;
  2425. peer_id =
  2426. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2427. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2428. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2429. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2430. ppdu_user_desc->peer_id = peer_id;
  2431. ppdu_user_desc->completion_status =
  2432. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2433. *tag_buf);
  2434. ppdu_user_desc->tid =
  2435. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2436. tag_buf++;
  2437. if (qdf_likely(ppdu_user_desc->completion_status ==
  2438. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2439. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2440. ppdu_user_desc->usr_ack_rssi = dp_stats_buf->ack_rssi;
  2441. ppdu_user_desc->ack_rssi_valid = 1;
  2442. } else {
  2443. ppdu_user_desc->ack_rssi_valid = 0;
  2444. }
  2445. tag_buf++;
  2446. ppdu_user_desc->mpdu_success =
  2447. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2448. ppdu_user_desc->mpdu_failed =
  2449. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2450. ppdu_user_desc->mpdu_success;
  2451. tag_buf++;
  2452. ppdu_user_desc->long_retries =
  2453. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2454. ppdu_user_desc->short_retries =
  2455. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2456. ppdu_user_desc->retry_msdus =
  2457. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2458. ppdu_user_desc->is_ampdu =
  2459. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2460. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2461. ppdu_desc->resp_type =
  2462. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RESP_TYPE_GET(*tag_buf);
  2463. ppdu_desc->mprot_type =
  2464. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPROT_TYPE_GET(*tag_buf);
  2465. ppdu_desc->rts_success =
  2466. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_SUCCESS_GET(*tag_buf);
  2467. ppdu_desc->rts_failure =
  2468. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_FAILURE_GET(*tag_buf);
  2469. ppdu_user_desc->pream_punct =
  2470. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PREAM_PUNC_TX_GET(*tag_buf);
  2471. ppdu_info->compltn_common_tlv++;
  2472. /*
  2473. * MU BAR may send request to n users but we may received ack only from
  2474. * m users. To have count of number of users respond back, we have a
  2475. * separate counter bar_num_users per PPDU that get increment for every
  2476. * htt_ppdu_stats_user_cmpltn_common_tlv
  2477. */
  2478. ppdu_desc->bar_num_users++;
  2479. tag_buf++;
  2480. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2481. ppdu_user_desc->rssi_chain[bw_iter] =
  2482. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2483. tag_buf++;
  2484. }
  2485. ppdu_user_desc->sa_tx_antenna =
  2486. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2487. tag_buf++;
  2488. ppdu_user_desc->sa_is_training =
  2489. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2490. if (ppdu_user_desc->sa_is_training) {
  2491. ppdu_user_desc->sa_goodput =
  2492. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2493. }
  2494. tag_buf++;
  2495. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2496. ppdu_user_desc->sa_max_rates[bw_iter] =
  2497. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2498. }
  2499. tag_buf += CDP_NUM_SA_BW;
  2500. ppdu_user_desc->current_rate_per =
  2501. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2502. }
  2503. /*
  2504. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2505. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2506. * pdev: DP PDEV handle
  2507. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2508. * @ppdu_info: per ppdu tlv structure
  2509. *
  2510. * return:void
  2511. */
  2512. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2513. struct dp_pdev *pdev, uint32_t *tag_buf,
  2514. struct ppdu_info *ppdu_info)
  2515. {
  2516. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2517. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2518. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2519. struct cdp_tx_completion_ppdu *ppdu_desc;
  2520. uint8_t curr_user_index = 0;
  2521. uint16_t peer_id;
  2522. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2523. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2524. tag_buf++;
  2525. peer_id =
  2526. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2527. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2528. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2529. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2530. ppdu_user_desc->peer_id = peer_id;
  2531. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2532. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2533. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2534. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2535. }
  2536. /*
  2537. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2538. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2539. * pdev: DP PDEV handle
  2540. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2541. * @ppdu_info: per ppdu tlv structure
  2542. *
  2543. * return:void
  2544. */
  2545. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2546. struct dp_pdev *pdev, uint32_t *tag_buf,
  2547. struct ppdu_info *ppdu_info)
  2548. {
  2549. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2550. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2551. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2552. struct cdp_tx_completion_ppdu *ppdu_desc;
  2553. uint8_t curr_user_index = 0;
  2554. uint16_t peer_id;
  2555. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2556. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2557. tag_buf++;
  2558. peer_id =
  2559. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2560. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2561. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2562. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2563. ppdu_user_desc->peer_id = peer_id;
  2564. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2565. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2566. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2567. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2568. }
  2569. /*
  2570. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2571. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2572. * pdev: DP PDE handle
  2573. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2574. * @ppdu_info: per ppdu tlv structure
  2575. *
  2576. * return:void
  2577. */
  2578. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2579. struct dp_pdev *pdev, uint32_t *tag_buf,
  2580. struct ppdu_info *ppdu_info)
  2581. {
  2582. uint16_t peer_id;
  2583. struct cdp_tx_completion_ppdu *ppdu_desc;
  2584. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2585. uint8_t curr_user_index = 0;
  2586. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2587. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2588. tag_buf += 2;
  2589. peer_id =
  2590. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2591. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2592. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2593. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2594. if (!ppdu_user_desc->ack_ba_tlv) {
  2595. ppdu_user_desc->ack_ba_tlv = 1;
  2596. } else {
  2597. pdev->stats.ack_ba_comes_twice++;
  2598. return;
  2599. }
  2600. ppdu_user_desc->peer_id = peer_id;
  2601. tag_buf++;
  2602. /* not to update ppdu_desc->tid from this TLV */
  2603. ppdu_user_desc->num_mpdu =
  2604. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2605. ppdu_user_desc->num_msdu =
  2606. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2607. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2608. tag_buf++;
  2609. ppdu_user_desc->start_seq =
  2610. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2611. *tag_buf);
  2612. tag_buf++;
  2613. ppdu_user_desc->success_bytes = *tag_buf;
  2614. /* increase ack ba tlv counter on successful mpdu */
  2615. if (ppdu_user_desc->num_mpdu)
  2616. ppdu_info->ack_ba_tlv++;
  2617. if (ppdu_user_desc->ba_size == 0) {
  2618. ppdu_user_desc->ba_seq_no = ppdu_user_desc->start_seq;
  2619. ppdu_user_desc->ba_bitmap[0] = 1;
  2620. ppdu_user_desc->ba_size = 1;
  2621. }
  2622. }
  2623. /*
  2624. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2625. * htt_ppdu_stats_user_common_array_tlv
  2626. * pdev: DP PDEV handle
  2627. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2628. * @ppdu_info: per ppdu tlv structure
  2629. *
  2630. * return:void
  2631. */
  2632. static void dp_process_ppdu_stats_user_common_array_tlv(
  2633. struct dp_pdev *pdev, uint32_t *tag_buf,
  2634. struct ppdu_info *ppdu_info)
  2635. {
  2636. uint32_t peer_id;
  2637. struct cdp_tx_completion_ppdu *ppdu_desc;
  2638. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2639. uint8_t curr_user_index = 0;
  2640. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2641. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2642. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2643. tag_buf++;
  2644. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2645. tag_buf += 3;
  2646. peer_id =
  2647. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2648. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2649. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2650. "Invalid peer");
  2651. return;
  2652. }
  2653. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2654. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2655. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2656. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2657. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2658. tag_buf++;
  2659. ppdu_user_desc->success_msdus =
  2660. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2661. ppdu_user_desc->retry_bytes =
  2662. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2663. tag_buf++;
  2664. ppdu_user_desc->failed_msdus =
  2665. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2666. }
  2667. /*
  2668. * dp_process_ppdu_stats_flush_tlv: Process
  2669. * htt_ppdu_stats_flush_tlv
  2670. * @pdev: DP PDEV handle
  2671. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2672. * @ppdu_info: per ppdu tlv structure
  2673. *
  2674. * return:void
  2675. */
  2676. static void
  2677. dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2678. uint32_t *tag_buf,
  2679. struct ppdu_info *ppdu_info)
  2680. {
  2681. struct cdp_tx_completion_ppdu *ppdu_desc;
  2682. uint32_t peer_id;
  2683. uint8_t tid;
  2684. struct dp_peer *peer;
  2685. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2686. qdf_nbuf_data(ppdu_info->nbuf);
  2687. ppdu_desc->is_flush = 1;
  2688. tag_buf++;
  2689. ppdu_desc->drop_reason = *tag_buf;
  2690. tag_buf++;
  2691. ppdu_desc->num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2692. ppdu_desc->num_mpdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MPDU_GET(*tag_buf);
  2693. ppdu_desc->flow_type = HTT_PPDU_STATS_FLUSH_TLV_FLOW_TYPE_GET(*tag_buf);
  2694. tag_buf++;
  2695. peer_id = HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2696. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2697. ppdu_desc->num_users = 1;
  2698. ppdu_desc->user[0].peer_id = peer_id;
  2699. ppdu_desc->user[0].tid = tid;
  2700. ppdu_desc->queue_type =
  2701. HTT_PPDU_STATS_FLUSH_TLV_QUEUE_TYPE_GET(*tag_buf);
  2702. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2703. DP_MOD_ID_TX_PPDU_STATS);
  2704. if (!peer)
  2705. goto add_ppdu_to_sched_list;
  2706. if (ppdu_desc->drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2707. DP_STATS_INC(peer,
  2708. tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2709. ppdu_desc->num_msdu);
  2710. }
  2711. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2712. add_ppdu_to_sched_list:
  2713. ppdu_info->done = 1;
  2714. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2715. pdev->list_depth--;
  2716. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2717. ppdu_info_list_elem);
  2718. pdev->sched_comp_list_depth++;
  2719. }
  2720. /**
  2721. * dp_process_ppdu_stats_sch_cmd_status_tlv: Process schedule command status tlv
  2722. * Here we are not going to process the buffer.
  2723. * @pdev: DP PDEV handle
  2724. * @ppdu_info: per ppdu tlv structure
  2725. *
  2726. * return:void
  2727. */
  2728. static void
  2729. dp_process_ppdu_stats_sch_cmd_status_tlv(struct dp_pdev *pdev,
  2730. struct ppdu_info *ppdu_info)
  2731. {
  2732. struct cdp_tx_completion_ppdu *ppdu_desc;
  2733. struct dp_peer *peer;
  2734. uint8_t num_users;
  2735. uint8_t i;
  2736. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2737. qdf_nbuf_data(ppdu_info->nbuf);
  2738. num_users = ppdu_desc->bar_num_users;
  2739. for (i = 0; i < num_users; i++) {
  2740. if (ppdu_desc->user[i].user_pos == 0) {
  2741. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2742. /* update phy mode for bar frame */
  2743. ppdu_desc->phy_mode =
  2744. ppdu_desc->user[i].preamble;
  2745. ppdu_desc->user[0].mcs = ppdu_desc->user[i].mcs;
  2746. break;
  2747. }
  2748. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_CTRL) {
  2749. ppdu_desc->frame_ctrl =
  2750. ppdu_desc->user[i].frame_ctrl;
  2751. break;
  2752. }
  2753. }
  2754. }
  2755. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2756. ppdu_desc->delayed_ba) {
  2757. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2758. for (i = 0; i < ppdu_desc->num_users; i++) {
  2759. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2760. uint64_t start_tsf;
  2761. uint64_t end_tsf;
  2762. uint32_t ppdu_id;
  2763. ppdu_id = ppdu_desc->ppdu_id;
  2764. peer = dp_peer_get_ref_by_id
  2765. (pdev->soc, ppdu_desc->user[i].peer_id,
  2766. DP_MOD_ID_TX_PPDU_STATS);
  2767. /**
  2768. * This check is to make sure peer is not deleted
  2769. * after processing the TLVs.
  2770. */
  2771. if (!peer)
  2772. continue;
  2773. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2774. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2775. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2776. /**
  2777. * save delayed ba user info
  2778. */
  2779. if (ppdu_desc->user[i].delayed_ba) {
  2780. dp_peer_copy_delay_stats(peer,
  2781. &ppdu_desc->user[i],
  2782. ppdu_id);
  2783. peer->last_delayed_ba_ppduid = ppdu_id;
  2784. delay_ppdu->ppdu_start_timestamp = start_tsf;
  2785. delay_ppdu->ppdu_end_timestamp = end_tsf;
  2786. }
  2787. ppdu_desc->user[i].peer_last_delayed_ba =
  2788. peer->last_delayed_ba;
  2789. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2790. if (ppdu_desc->user[i].delayed_ba &&
  2791. !ppdu_desc->user[i].debug_copied) {
  2792. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2793. QDF_TRACE_LEVEL_INFO_MED,
  2794. "%s: %d ppdu_id[%d] bar_ppdu_id[%d] num_users[%d] usr[%d] htt_frame_type[%d]\n",
  2795. __func__, __LINE__,
  2796. ppdu_desc->ppdu_id,
  2797. ppdu_desc->bar_ppdu_id,
  2798. ppdu_desc->num_users,
  2799. i,
  2800. ppdu_desc->htt_frame_type);
  2801. }
  2802. }
  2803. }
  2804. /*
  2805. * when frame type is BAR and STATS_COMMON_TLV is set
  2806. * copy the store peer delayed info to BAR status
  2807. */
  2808. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2809. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2810. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2811. uint64_t start_tsf;
  2812. uint64_t end_tsf;
  2813. peer = dp_peer_get_ref_by_id
  2814. (pdev->soc,
  2815. ppdu_desc->user[i].peer_id,
  2816. DP_MOD_ID_TX_PPDU_STATS);
  2817. /**
  2818. * This check is to make sure peer is not deleted
  2819. * after processing the TLVs.
  2820. */
  2821. if (!peer)
  2822. continue;
  2823. if (ppdu_desc->user[i].completion_status !=
  2824. HTT_PPDU_STATS_USER_STATUS_OK) {
  2825. dp_peer_unref_delete(peer,
  2826. DP_MOD_ID_TX_PPDU_STATS);
  2827. continue;
  2828. }
  2829. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2830. start_tsf = delay_ppdu->ppdu_start_timestamp;
  2831. end_tsf = delay_ppdu->ppdu_end_timestamp;
  2832. if (peer->last_delayed_ba) {
  2833. dp_peer_copy_stats_to_bar(peer,
  2834. &ppdu_desc->user[i]);
  2835. ppdu_desc->ppdu_id =
  2836. peer->last_delayed_ba_ppduid;
  2837. ppdu_desc->ppdu_start_timestamp = start_tsf;
  2838. ppdu_desc->ppdu_end_timestamp = end_tsf;
  2839. }
  2840. ppdu_desc->user[i].peer_last_delayed_ba =
  2841. peer->last_delayed_ba;
  2842. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2843. }
  2844. }
  2845. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2846. pdev->list_depth--;
  2847. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2848. ppdu_info_list_elem);
  2849. pdev->sched_comp_list_depth++;
  2850. }
  2851. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2852. /*
  2853. * dp_deliver_mgmt_frm: Process
  2854. * @pdev: DP PDEV handle
  2855. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2856. *
  2857. * return: void
  2858. */
  2859. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2860. {
  2861. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2862. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2863. nbuf, HTT_INVALID_PEER,
  2864. WDI_NO_VAL, pdev->pdev_id);
  2865. } else {
  2866. if (!pdev->bpr_enable)
  2867. qdf_nbuf_free(nbuf);
  2868. }
  2869. }
  2870. #endif
  2871. /*
  2872. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2873. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2874. * @pdev: DP PDEV handle
  2875. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2876. * @length: tlv_length
  2877. *
  2878. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2879. */
  2880. static QDF_STATUS
  2881. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2882. qdf_nbuf_t tag_buf,
  2883. uint32_t ppdu_id)
  2884. {
  2885. uint32_t *nbuf_ptr;
  2886. uint8_t trim_size;
  2887. size_t head_size;
  2888. struct cdp_tx_mgmt_comp_info *ptr_mgmt_comp_info;
  2889. uint32_t *msg_word;
  2890. uint32_t tsf_hdr;
  2891. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2892. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2893. return QDF_STATUS_SUCCESS;
  2894. /*
  2895. * get timestamp from htt_t2h_ppdu_stats_ind_hdr_t
  2896. */
  2897. msg_word = (uint32_t *)qdf_nbuf_data(tag_buf);
  2898. msg_word = msg_word + 2;
  2899. tsf_hdr = *msg_word;
  2900. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2901. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2902. qdf_nbuf_data(tag_buf));
  2903. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2904. return QDF_STATUS_SUCCESS;
  2905. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2906. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2907. if (pdev->tx_capture_enabled) {
  2908. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  2909. if (qdf_unlikely(qdf_nbuf_headroom(tag_buf) < head_size)) {
  2910. qdf_err("Fail to get headroom h_sz %d h_avail %d\n",
  2911. head_size, qdf_nbuf_headroom(tag_buf));
  2912. qdf_assert_always(0);
  2913. return QDF_STATUS_E_NOMEM;
  2914. }
  2915. ptr_mgmt_comp_info = (struct cdp_tx_mgmt_comp_info *)
  2916. qdf_nbuf_push_head(tag_buf, head_size);
  2917. qdf_assert_always(ptr_mgmt_comp_info);
  2918. ptr_mgmt_comp_info->ppdu_id = ppdu_id;
  2919. ptr_mgmt_comp_info->is_sgen_pkt = true;
  2920. ptr_mgmt_comp_info->tx_tsf = tsf_hdr;
  2921. } else {
  2922. head_size = sizeof(ppdu_id);
  2923. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(tag_buf, head_size);
  2924. *nbuf_ptr = ppdu_id;
  2925. }
  2926. if (pdev->bpr_enable) {
  2927. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2928. tag_buf, HTT_INVALID_PEER,
  2929. WDI_NO_VAL, pdev->pdev_id);
  2930. }
  2931. dp_deliver_mgmt_frm(pdev, tag_buf);
  2932. return QDF_STATUS_E_ALREADY;
  2933. }
  2934. /**
  2935. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2936. *
  2937. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2938. * size of corresponding data structure, pad the remaining bytes with zeros
  2939. * and continue processing the TLVs
  2940. *
  2941. * @pdev: DP pdev handle
  2942. * @tag_buf: TLV buffer
  2943. * @tlv_expected_size: Expected size of Tag
  2944. * @tlv_len: TLV length received from FW
  2945. *
  2946. * Return: Pointer to updated TLV
  2947. */
  2948. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  2949. uint32_t *tag_buf,
  2950. uint16_t tlv_expected_size,
  2951. uint16_t tlv_len)
  2952. {
  2953. uint32_t *tlv_desc = tag_buf;
  2954. qdf_assert_always(tlv_len != 0);
  2955. if (tlv_len < tlv_expected_size) {
  2956. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  2957. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  2958. tlv_desc = pdev->ppdu_tlv_buf;
  2959. }
  2960. return tlv_desc;
  2961. }
  2962. /**
  2963. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  2964. * @pdev: DP pdev handle
  2965. * @tag_buf: TLV buffer
  2966. * @tlv_len: length of tlv
  2967. * @ppdu_info: per ppdu tlv structure
  2968. *
  2969. * return: void
  2970. */
  2971. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  2972. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  2973. {
  2974. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2975. uint16_t tlv_expected_size;
  2976. uint32_t *tlv_desc;
  2977. switch (tlv_type) {
  2978. case HTT_PPDU_STATS_COMMON_TLV:
  2979. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  2980. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2981. tlv_expected_size, tlv_len);
  2982. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  2983. break;
  2984. case HTT_PPDU_STATS_USR_COMMON_TLV:
  2985. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  2986. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2987. tlv_expected_size, tlv_len);
  2988. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  2989. ppdu_info);
  2990. break;
  2991. case HTT_PPDU_STATS_USR_RATE_TLV:
  2992. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  2993. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2994. tlv_expected_size, tlv_len);
  2995. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  2996. ppdu_info);
  2997. break;
  2998. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  2999. tlv_expected_size =
  3000. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  3001. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3002. tlv_expected_size, tlv_len);
  3003. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  3004. pdev, tlv_desc, ppdu_info);
  3005. break;
  3006. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  3007. tlv_expected_size =
  3008. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  3009. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3010. tlv_expected_size, tlv_len);
  3011. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  3012. pdev, tlv_desc, ppdu_info);
  3013. break;
  3014. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  3015. tlv_expected_size =
  3016. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  3017. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3018. tlv_expected_size, tlv_len);
  3019. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  3020. pdev, tlv_desc, ppdu_info);
  3021. break;
  3022. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  3023. tlv_expected_size =
  3024. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  3025. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3026. tlv_expected_size, tlv_len);
  3027. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  3028. pdev, tlv_desc, ppdu_info);
  3029. break;
  3030. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  3031. tlv_expected_size =
  3032. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  3033. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3034. tlv_expected_size, tlv_len);
  3035. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  3036. pdev, tlv_desc, ppdu_info);
  3037. break;
  3038. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  3039. tlv_expected_size =
  3040. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  3041. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3042. tlv_expected_size, tlv_len);
  3043. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  3044. pdev, tlv_desc, ppdu_info);
  3045. break;
  3046. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  3047. tlv_expected_size =
  3048. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  3049. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3050. tlv_expected_size, tlv_len);
  3051. dp_process_ppdu_stats_user_common_array_tlv(
  3052. pdev, tlv_desc, ppdu_info);
  3053. break;
  3054. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  3055. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  3056. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3057. tlv_expected_size, tlv_len);
  3058. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev, tlv_desc,
  3059. ppdu_info);
  3060. break;
  3061. case HTT_PPDU_STATS_SCH_CMD_STATUS_TLV:
  3062. dp_process_ppdu_stats_sch_cmd_status_tlv(pdev, ppdu_info);
  3063. break;
  3064. default:
  3065. break;
  3066. }
  3067. }
  3068. #ifdef WLAN_ATF_ENABLE
  3069. static void
  3070. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3071. struct cdp_tx_completion_ppdu *ppdu_desc,
  3072. struct cdp_tx_completion_ppdu_user *user)
  3073. {
  3074. uint32_t nss_ru_width_sum = 0;
  3075. if (!pdev || !ppdu_desc || !user)
  3076. return;
  3077. if (!pdev->dp_atf_stats_enable)
  3078. return;
  3079. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_DATA)
  3080. return;
  3081. nss_ru_width_sum = ppdu_desc->usr_nss_sum * ppdu_desc->usr_ru_tones_sum;
  3082. if (!nss_ru_width_sum)
  3083. nss_ru_width_sum = 1;
  3084. /**
  3085. * For SU-MIMO PPDU phy Tx time is same for the single user.
  3086. * For MU-MIMO phy Tx time is calculated per user as below
  3087. * user phy tx time =
  3088. * Entire PPDU duration * MU Ratio * OFDMA Ratio
  3089. * MU Ratio = usr_nss / Sum_of_nss_of_all_users
  3090. * OFDMA_ratio = usr_ru_width / Sum_of_ru_width_of_all_users
  3091. * usr_ru_widt = ru_end – ru_start + 1
  3092. */
  3093. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) {
  3094. user->phy_tx_time_us = ppdu_desc->phy_ppdu_tx_time_us;
  3095. } else {
  3096. user->phy_tx_time_us = (ppdu_desc->phy_ppdu_tx_time_us *
  3097. user->nss * user->ru_tones) / nss_ru_width_sum;
  3098. }
  3099. }
  3100. #else
  3101. static void
  3102. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3103. struct cdp_tx_completion_ppdu *ppdu_desc,
  3104. struct cdp_tx_completion_ppdu_user *user)
  3105. {
  3106. }
  3107. #endif
  3108. /**
  3109. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  3110. * @pdev: DP pdev handle
  3111. * @ppdu_info: per PPDU TLV descriptor
  3112. *
  3113. * return: void
  3114. */
  3115. void
  3116. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  3117. struct ppdu_info *ppdu_info)
  3118. {
  3119. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3120. struct dp_peer *peer = NULL;
  3121. uint32_t tlv_bitmap_expected;
  3122. uint32_t tlv_bitmap_default;
  3123. uint16_t i;
  3124. uint32_t num_users;
  3125. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3126. qdf_nbuf_data(ppdu_info->nbuf);
  3127. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_BAR)
  3128. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  3129. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3130. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3131. pdev->tx_capture_enabled) {
  3132. if (ppdu_info->is_ampdu)
  3133. tlv_bitmap_expected =
  3134. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3135. ppdu_info->tlv_bitmap);
  3136. }
  3137. tlv_bitmap_default = tlv_bitmap_expected;
  3138. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  3139. num_users = ppdu_desc->bar_num_users;
  3140. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  3141. } else {
  3142. num_users = ppdu_desc->num_users;
  3143. }
  3144. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  3145. for (i = 0; i < num_users; i++) {
  3146. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  3147. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  3148. peer = dp_peer_get_ref_by_id(pdev->soc,
  3149. ppdu_desc->user[i].peer_id,
  3150. DP_MOD_ID_TX_PPDU_STATS);
  3151. /**
  3152. * This check is to make sure peer is not deleted
  3153. * after processing the TLVs.
  3154. */
  3155. if (!peer)
  3156. continue;
  3157. /*
  3158. * different frame like DATA, BAR or CTRL has different
  3159. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  3160. * receive other tlv in-order/sequential from fw.
  3161. * Since ACK_BA_STATUS TLV come from Hardware it is
  3162. * asynchronous So we need to depend on some tlv to confirm
  3163. * all tlv is received for a ppdu.
  3164. * So we depend on both SCHED_CMD_STATUS_TLV and
  3165. * ACK_BA_STATUS_TLV. for failure packet we won't get
  3166. * ACK_BA_STATUS_TLV.
  3167. */
  3168. if (!(ppdu_info->tlv_bitmap &
  3169. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)) ||
  3170. (!(ppdu_info->tlv_bitmap &
  3171. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)) &&
  3172. (ppdu_desc->user[i].completion_status ==
  3173. HTT_PPDU_STATS_USER_STATUS_OK))) {
  3174. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3175. continue;
  3176. }
  3177. /**
  3178. * Update tx stats for data frames having Qos as well as
  3179. * non-Qos data tid
  3180. */
  3181. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  3182. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID) ||
  3183. (ppdu_desc->htt_frame_type ==
  3184. HTT_STATS_FTYPE_SGEN_QOS_NULL) ||
  3185. ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) &&
  3186. (ppdu_desc->num_mpdu > 1))) &&
  3187. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  3188. dp_tx_stats_update(pdev, peer,
  3189. &ppdu_desc->user[i],
  3190. ppdu_desc->ack_rssi);
  3191. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  3192. }
  3193. dp_ppdu_desc_user_phy_tx_time_update(pdev, ppdu_desc,
  3194. &ppdu_desc->user[i]);
  3195. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3196. tlv_bitmap_expected = tlv_bitmap_default;
  3197. }
  3198. }
  3199. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  3200. /**
  3201. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  3202. * to upper layer
  3203. * @pdev: DP pdev handle
  3204. * @ppdu_info: per PPDU TLV descriptor
  3205. *
  3206. * return: void
  3207. */
  3208. static
  3209. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  3210. struct ppdu_info *ppdu_info)
  3211. {
  3212. struct ppdu_info *s_ppdu_info = NULL;
  3213. struct ppdu_info *ppdu_info_next = NULL;
  3214. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3215. qdf_nbuf_t nbuf;
  3216. uint32_t time_delta = 0;
  3217. bool starved = 0;
  3218. bool matched = 0;
  3219. bool recv_ack_ba_done = 0;
  3220. if (ppdu_info->tlv_bitmap &
  3221. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3222. ppdu_info->done)
  3223. recv_ack_ba_done = 1;
  3224. pdev->last_sched_cmdid = ppdu_info->sched_cmdid;
  3225. s_ppdu_info = TAILQ_FIRST(&pdev->sched_comp_ppdu_list);
  3226. TAILQ_FOREACH_SAFE(s_ppdu_info, &pdev->sched_comp_ppdu_list,
  3227. ppdu_info_list_elem, ppdu_info_next) {
  3228. if (s_ppdu_info->tsf_l32 > ppdu_info->tsf_l32)
  3229. time_delta = (MAX_TSF_32 - s_ppdu_info->tsf_l32) +
  3230. ppdu_info->tsf_l32;
  3231. else
  3232. time_delta = ppdu_info->tsf_l32 - s_ppdu_info->tsf_l32;
  3233. if (!s_ppdu_info->done && !recv_ack_ba_done) {
  3234. if (time_delta < MAX_SCHED_STARVE) {
  3235. dp_info("pdev[%d] ppdu_id[%d] sched_cmdid[%d] TLV_B[0x%x] TSF[%u] D[%d]",
  3236. pdev->pdev_id,
  3237. s_ppdu_info->ppdu_id,
  3238. s_ppdu_info->sched_cmdid,
  3239. s_ppdu_info->tlv_bitmap,
  3240. s_ppdu_info->tsf_l32,
  3241. s_ppdu_info->done);
  3242. break;
  3243. }
  3244. starved = 1;
  3245. }
  3246. pdev->delivered_sched_cmdid = s_ppdu_info->sched_cmdid;
  3247. TAILQ_REMOVE(&pdev->sched_comp_ppdu_list, s_ppdu_info,
  3248. ppdu_info_list_elem);
  3249. pdev->sched_comp_list_depth--;
  3250. nbuf = s_ppdu_info->nbuf;
  3251. qdf_assert_always(nbuf);
  3252. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3253. qdf_nbuf_data(nbuf);
  3254. ppdu_desc->tlv_bitmap = s_ppdu_info->tlv_bitmap;
  3255. if (starved) {
  3256. dp_err("ppdu starved fc[0x%x] h_ftype[%d] tlv_bitmap[0x%x] cs[%d]\n",
  3257. ppdu_desc->frame_ctrl,
  3258. ppdu_desc->htt_frame_type,
  3259. ppdu_desc->tlv_bitmap,
  3260. ppdu_desc->user[0].completion_status);
  3261. starved = 0;
  3262. }
  3263. if (ppdu_info->ppdu_id == s_ppdu_info->ppdu_id &&
  3264. ppdu_info->sched_cmdid == s_ppdu_info->sched_cmdid)
  3265. matched = 1;
  3266. dp_ppdu_desc_user_stats_update(pdev, s_ppdu_info);
  3267. qdf_mem_free(s_ppdu_info);
  3268. /**
  3269. * Deliver PPDU stats only for valid (acked) data
  3270. * frames if sniffer mode is not enabled.
  3271. * If sniffer mode is enabled, PPDU stats
  3272. * for all frames including mgmt/control
  3273. * frames should be delivered to upper layer
  3274. */
  3275. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  3276. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3277. pdev->soc,
  3278. nbuf, HTT_INVALID_PEER,
  3279. WDI_NO_VAL,
  3280. pdev->pdev_id);
  3281. } else {
  3282. if (ppdu_desc->num_mpdu != 0 &&
  3283. ppdu_desc->num_users != 0 &&
  3284. ppdu_desc->frame_ctrl &
  3285. HTT_FRAMECTRL_DATATYPE) {
  3286. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3287. pdev->soc,
  3288. nbuf, HTT_INVALID_PEER,
  3289. WDI_NO_VAL,
  3290. pdev->pdev_id);
  3291. } else {
  3292. qdf_nbuf_free(nbuf);
  3293. }
  3294. }
  3295. if (matched)
  3296. break;
  3297. }
  3298. return;
  3299. }
  3300. #endif
  3301. /**
  3302. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  3303. * desc for new ppdu id
  3304. * @pdev: DP pdev handle
  3305. * @ppdu_id: PPDU unique identifier
  3306. * @tlv_type: TLV type received
  3307. * @tsf_l32: timestamp received along with ppdu stats indication header
  3308. * @max_users: Maximum user for that particular ppdu
  3309. *
  3310. * return: ppdu_info per ppdu tlv structure
  3311. */
  3312. static
  3313. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  3314. uint8_t tlv_type, uint32_t tsf_l32,
  3315. uint8_t max_users)
  3316. {
  3317. struct ppdu_info *ppdu_info = NULL;
  3318. struct ppdu_info *s_ppdu_info = NULL;
  3319. struct ppdu_info *ppdu_info_next = NULL;
  3320. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3321. uint32_t size = 0;
  3322. struct cdp_tx_completion_ppdu *tmp_ppdu_desc = NULL;
  3323. struct cdp_tx_completion_ppdu_user *tmp_user;
  3324. uint32_t time_delta;
  3325. /*
  3326. * Find ppdu_id node exists or not
  3327. */
  3328. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  3329. ppdu_info_list_elem, ppdu_info_next) {
  3330. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  3331. if (ppdu_info->tsf_l32 > tsf_l32)
  3332. time_delta = (MAX_TSF_32 -
  3333. ppdu_info->tsf_l32) + tsf_l32;
  3334. else
  3335. time_delta = tsf_l32 - ppdu_info->tsf_l32;
  3336. if (time_delta > WRAP_DROP_TSF_DELTA) {
  3337. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3338. ppdu_info, ppdu_info_list_elem);
  3339. pdev->list_depth--;
  3340. pdev->stats.ppdu_wrap_drop++;
  3341. tmp_ppdu_desc =
  3342. (struct cdp_tx_completion_ppdu *)
  3343. qdf_nbuf_data(ppdu_info->nbuf);
  3344. tmp_user = &tmp_ppdu_desc->user[0];
  3345. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  3346. QDF_TRACE_LEVEL_INFO_MED,
  3347. "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",
  3348. ppdu_info->ppdu_id,
  3349. ppdu_info->tsf_l32,
  3350. ppdu_info->tlv_bitmap,
  3351. tmp_user->completion_status,
  3352. ppdu_info->compltn_common_tlv,
  3353. ppdu_info->ack_ba_tlv,
  3354. ppdu_id, tsf_l32, tlv_type);
  3355. qdf_nbuf_free(ppdu_info->nbuf);
  3356. ppdu_info->nbuf = NULL;
  3357. qdf_mem_free(ppdu_info);
  3358. } else {
  3359. break;
  3360. }
  3361. }
  3362. }
  3363. /*
  3364. * check if it is ack ba tlv and if it is not there in ppdu info
  3365. * list then check it in sched completion ppdu list
  3366. */
  3367. if (!ppdu_info &&
  3368. tlv_type == HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) {
  3369. TAILQ_FOREACH(s_ppdu_info,
  3370. &pdev->sched_comp_ppdu_list,
  3371. ppdu_info_list_elem) {
  3372. if (s_ppdu_info && (s_ppdu_info->ppdu_id == ppdu_id)) {
  3373. if (s_ppdu_info->tsf_l32 > tsf_l32)
  3374. time_delta = (MAX_TSF_32 -
  3375. s_ppdu_info->tsf_l32) +
  3376. tsf_l32;
  3377. else
  3378. time_delta = tsf_l32 -
  3379. s_ppdu_info->tsf_l32;
  3380. if (time_delta < WRAP_DROP_TSF_DELTA) {
  3381. ppdu_info = s_ppdu_info;
  3382. break;
  3383. }
  3384. } else {
  3385. /*
  3386. * ACK BA STATUS TLV comes sequential order
  3387. * if we received ack ba status tlv for second
  3388. * ppdu and first ppdu is still waiting for
  3389. * ACK BA STATUS TLV. Based on fw comment
  3390. * we won't receive it tlv later. So we can
  3391. * set ppdu info done.
  3392. */
  3393. if (s_ppdu_info)
  3394. s_ppdu_info->done = 1;
  3395. }
  3396. }
  3397. }
  3398. if (ppdu_info) {
  3399. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  3400. /**
  3401. * if we get tlv_type that is already been processed
  3402. * for ppdu, that means we got a new ppdu with same
  3403. * ppdu id. Hence Flush the older ppdu
  3404. * for MUMIMO and OFDMA, In a PPDU we have
  3405. * multiple user with same tlv types. tlv bitmap is
  3406. * used to check whether SU or MU_MIMO/OFDMA
  3407. */
  3408. if (!(ppdu_info->tlv_bitmap &
  3409. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  3410. return ppdu_info;
  3411. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3412. qdf_nbuf_data(ppdu_info->nbuf);
  3413. /**
  3414. * apart from ACK BA STATUS TLV rest all comes in order
  3415. * so if tlv type not ACK BA STATUS TLV we can deliver
  3416. * ppdu_info
  3417. */
  3418. if ((tlv_type ==
  3419. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3420. (ppdu_desc->htt_frame_type ==
  3421. HTT_STATS_FTYPE_SGEN_MU_BAR))
  3422. return ppdu_info;
  3423. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3424. } else {
  3425. return ppdu_info;
  3426. }
  3427. }
  3428. /**
  3429. * Flush the head ppdu descriptor if ppdu desc list reaches max
  3430. * threshold
  3431. */
  3432. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  3433. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  3434. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3435. ppdu_info, ppdu_info_list_elem);
  3436. pdev->list_depth--;
  3437. pdev->stats.ppdu_drop++;
  3438. qdf_nbuf_free(ppdu_info->nbuf);
  3439. ppdu_info->nbuf = NULL;
  3440. qdf_mem_free(ppdu_info);
  3441. }
  3442. size = sizeof(struct cdp_tx_completion_ppdu) +
  3443. (max_users * sizeof(struct cdp_tx_completion_ppdu_user));
  3444. /*
  3445. * Allocate new ppdu_info node
  3446. */
  3447. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  3448. if (!ppdu_info)
  3449. return NULL;
  3450. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev, size,
  3451. 0, 4, TRUE);
  3452. if (!ppdu_info->nbuf) {
  3453. qdf_mem_free(ppdu_info);
  3454. return NULL;
  3455. }
  3456. ppdu_info->ppdu_desc =
  3457. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  3458. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf), size);
  3459. if (qdf_nbuf_put_tail(ppdu_info->nbuf, size) == NULL) {
  3460. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3461. "No tailroom for HTT PPDU");
  3462. qdf_nbuf_free(ppdu_info->nbuf);
  3463. ppdu_info->nbuf = NULL;
  3464. ppdu_info->last_user = 0;
  3465. qdf_mem_free(ppdu_info);
  3466. return NULL;
  3467. }
  3468. ppdu_info->ppdu_desc->max_users = max_users;
  3469. ppdu_info->tsf_l32 = tsf_l32;
  3470. /**
  3471. * No lock is needed because all PPDU TLVs are processed in
  3472. * same context and this list is updated in same context
  3473. */
  3474. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  3475. ppdu_info_list_elem);
  3476. pdev->list_depth++;
  3477. return ppdu_info;
  3478. }
  3479. /**
  3480. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  3481. * @pdev: DP pdev handle
  3482. * @htt_t2h_msg: HTT target to host message
  3483. *
  3484. * return: ppdu_info per ppdu tlv structure
  3485. */
  3486. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  3487. qdf_nbuf_t htt_t2h_msg)
  3488. {
  3489. uint32_t length;
  3490. uint32_t ppdu_id;
  3491. uint8_t tlv_type;
  3492. uint32_t tlv_length, tlv_bitmap_expected;
  3493. uint8_t *tlv_buf;
  3494. struct ppdu_info *ppdu_info = NULL;
  3495. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3496. uint8_t max_users = CDP_MU_MAX_USERS;
  3497. uint32_t tsf_l32;
  3498. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3499. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  3500. msg_word = msg_word + 1;
  3501. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  3502. msg_word = msg_word + 1;
  3503. tsf_l32 = (uint32_t)(*msg_word);
  3504. msg_word = msg_word + 2;
  3505. while (length > 0) {
  3506. tlv_buf = (uint8_t *)msg_word;
  3507. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  3508. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  3509. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  3510. pdev->stats.ppdu_stats_counter[tlv_type]++;
  3511. if (tlv_length == 0)
  3512. break;
  3513. tlv_length += HTT_TLV_HDR_LEN;
  3514. /**
  3515. * Not allocating separate ppdu descriptor for MGMT Payload
  3516. * TLV as this is sent as separate WDI indication and it
  3517. * doesn't contain any ppdu information
  3518. */
  3519. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  3520. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  3521. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  3522. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  3523. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  3524. (*(msg_word + 1));
  3525. msg_word =
  3526. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3527. length -= (tlv_length);
  3528. continue;
  3529. }
  3530. /*
  3531. * retrieve max_users if it's USERS_INFO,
  3532. * else, it's 1 for COMPLTN_FLUSH,
  3533. * else, use CDP_MU_MAX_USERS
  3534. */
  3535. if (tlv_type == HTT_PPDU_STATS_USERS_INFO_TLV) {
  3536. max_users =
  3537. HTT_PPDU_STATS_USERS_INFO_TLV_MAX_USERS_GET(*(msg_word + 1));
  3538. } else if (tlv_type == HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) {
  3539. max_users = 1;
  3540. }
  3541. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type,
  3542. tsf_l32, max_users);
  3543. if (!ppdu_info)
  3544. return NULL;
  3545. ppdu_info->ppdu_desc->bss_color =
  3546. pdev->rx_mon_recv_status.bsscolor;
  3547. ppdu_info->ppdu_id = ppdu_id;
  3548. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  3549. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  3550. /**
  3551. * Increment pdev level tlv count to monitor
  3552. * missing TLVs
  3553. */
  3554. pdev->tlv_count++;
  3555. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  3556. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3557. length -= (tlv_length);
  3558. }
  3559. if (!ppdu_info)
  3560. return NULL;
  3561. pdev->last_ppdu_id = ppdu_id;
  3562. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3563. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3564. pdev->tx_capture_enabled) {
  3565. if (ppdu_info->is_ampdu)
  3566. tlv_bitmap_expected =
  3567. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3568. ppdu_info->tlv_bitmap);
  3569. }
  3570. ppdu_desc = ppdu_info->ppdu_desc;
  3571. if (!ppdu_desc)
  3572. return NULL;
  3573. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  3574. HTT_PPDU_STATS_USER_STATUS_OK) {
  3575. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  3576. }
  3577. /*
  3578. * for frame type DATA and BAR, we update stats based on MSDU,
  3579. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  3580. * which comes out of order. successful mpdu also populated from
  3581. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  3582. * we store successful mpdu from both tlv and compare before delivering
  3583. * to make sure we received ACK BA STATUS TLV. For some self generated
  3584. * frame we won't get ack ba status tlv so no need to wait for
  3585. * ack ba status tlv.
  3586. */
  3587. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL &&
  3588. ppdu_desc->htt_frame_type != HTT_STATS_FTYPE_SGEN_QOS_NULL) {
  3589. /*
  3590. * most of the time bar frame will have duplicate ack ba
  3591. * status tlv
  3592. */
  3593. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  3594. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv))
  3595. return NULL;
  3596. /*
  3597. * For data frame, compltn common tlv should match ack ba status
  3598. * tlv and completion status. Reason we are checking first user
  3599. * for ofdma, completion seen at next MU BAR frm, for mimo
  3600. * only for first user completion will be immediate.
  3601. */
  3602. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  3603. (ppdu_desc->user[0].completion_status == 0 &&
  3604. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv)))
  3605. return NULL;
  3606. }
  3607. /**
  3608. * Once all the TLVs for a given PPDU has been processed,
  3609. * return PPDU status to be delivered to higher layer.
  3610. * tlv_bitmap_expected can't be available for different frame type.
  3611. * But SCHED CMD STATS TLV is the last TLV from the FW for a ppdu.
  3612. * apart from ACK BA TLV, FW sends other TLV in sequential order.
  3613. * flush tlv comes separate.
  3614. */
  3615. if ((ppdu_info->tlv_bitmap != 0 &&
  3616. (ppdu_info->tlv_bitmap &
  3617. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV))) ||
  3618. (ppdu_info->tlv_bitmap &
  3619. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV))) {
  3620. ppdu_info->done = 1;
  3621. return ppdu_info;
  3622. }
  3623. return NULL;
  3624. }
  3625. #endif /* FEATURE_PERPKT_INFO */
  3626. /**
  3627. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  3628. * @soc: DP SOC handle
  3629. * @pdev_id: pdev id
  3630. * @htt_t2h_msg: HTT message nbuf
  3631. *
  3632. * return:void
  3633. */
  3634. #if defined(WDI_EVENT_ENABLE)
  3635. #ifdef FEATURE_PERPKT_INFO
  3636. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3637. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3638. {
  3639. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  3640. struct ppdu_info *ppdu_info = NULL;
  3641. bool free_buf = true;
  3642. if (pdev_id >= MAX_PDEV_CNT)
  3643. return true;
  3644. pdev = soc->pdev_list[pdev_id];
  3645. if (!pdev)
  3646. return true;
  3647. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  3648. !pdev->mcopy_mode && !pdev->bpr_enable)
  3649. return free_buf;
  3650. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  3651. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  3652. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  3653. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  3654. QDF_STATUS_SUCCESS)
  3655. free_buf = false;
  3656. }
  3657. if (ppdu_info)
  3658. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3659. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  3660. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  3661. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  3662. return free_buf;
  3663. }
  3664. #else
  3665. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3666. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3667. {
  3668. return true;
  3669. }
  3670. #endif
  3671. #endif
  3672. /**
  3673. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3674. * @soc: DP SOC handle
  3675. * @htt_t2h_msg: HTT message nbuf
  3676. *
  3677. * return:void
  3678. */
  3679. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3680. qdf_nbuf_t htt_t2h_msg)
  3681. {
  3682. uint8_t done;
  3683. qdf_nbuf_t msg_copy;
  3684. uint32_t *msg_word;
  3685. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3686. msg_word = msg_word + 3;
  3687. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3688. /*
  3689. * HTT EXT stats response comes as stream of TLVs which span over
  3690. * multiple T2H messages.
  3691. * The first message will carry length of the response.
  3692. * For rest of the messages length will be zero.
  3693. *
  3694. * Clone the T2H message buffer and store it in a list to process
  3695. * it later.
  3696. *
  3697. * The original T2H message buffers gets freed in the T2H HTT event
  3698. * handler
  3699. */
  3700. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3701. if (!msg_copy) {
  3702. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3703. "T2H messge clone failed for HTT EXT STATS");
  3704. goto error;
  3705. }
  3706. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3707. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3708. /*
  3709. * Done bit signifies that this is the last T2H buffer in the stream of
  3710. * HTT EXT STATS message
  3711. */
  3712. if (done) {
  3713. soc->htt_stats.num_stats++;
  3714. qdf_sched_work(0, &soc->htt_stats.work);
  3715. }
  3716. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3717. return;
  3718. error:
  3719. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3720. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3721. != NULL) {
  3722. qdf_nbuf_free(msg_copy);
  3723. }
  3724. soc->htt_stats.num_stats = 0;
  3725. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3726. return;
  3727. }
  3728. /*
  3729. * htt_soc_attach_target() - SOC level HTT setup
  3730. * @htt_soc: HTT SOC handle
  3731. *
  3732. * Return: 0 on success; error code on failure
  3733. */
  3734. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3735. {
  3736. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3737. return htt_h2t_ver_req_msg(soc);
  3738. }
  3739. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3740. {
  3741. htt_soc->htc_soc = htc_soc;
  3742. }
  3743. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3744. {
  3745. return htt_soc->htc_soc;
  3746. }
  3747. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3748. {
  3749. int i;
  3750. int j;
  3751. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3752. struct htt_soc *htt_soc = NULL;
  3753. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3754. if (!htt_soc) {
  3755. dp_err("HTT attach failed");
  3756. return NULL;
  3757. }
  3758. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3759. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3760. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3761. break;
  3762. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3763. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3764. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3765. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3766. break;
  3767. }
  3768. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3769. }
  3770. if (i != MAX_PDEV_CNT) {
  3771. for (j = 0; j < i; j++) {
  3772. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  3773. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  3774. }
  3775. qdf_mem_free(htt_soc);
  3776. return NULL;
  3777. }
  3778. htt_soc->dp_soc = soc;
  3779. htt_soc->htc_soc = htc_handle;
  3780. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3781. return htt_soc;
  3782. }
  3783. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3784. /*
  3785. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3786. * @htt_soc: HTT SOC handle
  3787. * @msg_word: Pointer to payload
  3788. * @htt_t2h_msg: HTT msg nbuf
  3789. *
  3790. * Return: True if buffer should be freed by caller.
  3791. */
  3792. static bool
  3793. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3794. uint32_t *msg_word,
  3795. qdf_nbuf_t htt_t2h_msg)
  3796. {
  3797. u_int8_t pdev_id;
  3798. u_int8_t target_pdev_id;
  3799. bool free_buf;
  3800. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3801. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3802. target_pdev_id);
  3803. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3804. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3805. pdev_id);
  3806. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3807. htt_t2h_msg);
  3808. return free_buf;
  3809. }
  3810. #else
  3811. static bool
  3812. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3813. uint32_t *msg_word,
  3814. qdf_nbuf_t htt_t2h_msg)
  3815. {
  3816. return true;
  3817. }
  3818. #endif
  3819. #if defined(WDI_EVENT_ENABLE) && \
  3820. !defined(REMOVE_PKT_LOG)
  3821. /*
  3822. * dp_pktlog_msg_handler() - Pktlog msg handler
  3823. * @htt_soc: HTT SOC handle
  3824. * @msg_word: Pointer to payload
  3825. *
  3826. * Return: None
  3827. */
  3828. static void
  3829. dp_pktlog_msg_handler(struct htt_soc *soc,
  3830. uint32_t *msg_word)
  3831. {
  3832. uint8_t pdev_id;
  3833. uint8_t target_pdev_id;
  3834. uint32_t *pl_hdr;
  3835. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3836. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3837. target_pdev_id);
  3838. pl_hdr = (msg_word + 1);
  3839. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3840. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3841. pdev_id);
  3842. }
  3843. #else
  3844. static void
  3845. dp_pktlog_msg_handler(struct htt_soc *soc,
  3846. uint32_t *msg_word)
  3847. {
  3848. }
  3849. #endif
  3850. /*
  3851. * time_allow_print() - time allow print
  3852. * @htt_ring_tt: ringi_id array of timestamps
  3853. * @ring_id: ring_id (index)
  3854. *
  3855. * Return: 1 for successfully saving timestamp in array
  3856. * and 0 for timestamp falling within 2 seconds after last one
  3857. */
  3858. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3859. {
  3860. unsigned long tstamp;
  3861. unsigned long delta;
  3862. tstamp = qdf_get_system_timestamp();
  3863. if (!htt_ring_tt)
  3864. return 0; //unable to print backpressure messages
  3865. if (htt_ring_tt[ring_id] == -1) {
  3866. htt_ring_tt[ring_id] = tstamp;
  3867. return 1;
  3868. }
  3869. delta = tstamp - htt_ring_tt[ring_id];
  3870. if (delta >= 2000) {
  3871. htt_ring_tt[ring_id] = tstamp;
  3872. return 1;
  3873. }
  3874. return 0;
  3875. }
  3876. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3877. u_int8_t pdev_id, u_int8_t ring_id,
  3878. u_int16_t hp_idx, u_int16_t tp_idx,
  3879. u_int32_t bkp_time, char *ring_stype)
  3880. {
  3881. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3882. msg_type, pdev_id, ring_stype);
  3883. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3884. ring_id, hp_idx, tp_idx, bkp_time);
  3885. }
  3886. /*
  3887. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3888. * @msg_word: htt packet context
  3889. * @htt_soc: HTT SOC handle
  3890. *
  3891. * Return: after attempting to print stats
  3892. */
  3893. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3894. {
  3895. u_int8_t ring_type;
  3896. u_int8_t pdev_id;
  3897. uint8_t target_pdev_id;
  3898. u_int8_t ring_id;
  3899. u_int16_t hp_idx;
  3900. u_int16_t tp_idx;
  3901. u_int32_t bkp_time;
  3902. enum htt_t2h_msg_type msg_type;
  3903. struct dp_soc *dpsoc;
  3904. struct dp_pdev *pdev;
  3905. struct dp_htt_timestamp *radio_tt;
  3906. if (!soc)
  3907. return;
  3908. dpsoc = (struct dp_soc *)soc->dp_soc;
  3909. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3910. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3911. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3912. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3913. target_pdev_id);
  3914. if (pdev_id >= MAX_PDEV_CNT) {
  3915. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  3916. "pdev id %d is invalid", pdev_id);
  3917. return;
  3918. }
  3919. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3920. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3921. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3922. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3923. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3924. radio_tt = &soc->pdevid_tt[pdev_id];
  3925. switch (ring_type) {
  3926. case HTT_SW_RING_TYPE_UMAC:
  3927. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3928. return;
  3929. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3930. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  3931. break;
  3932. case HTT_SW_RING_TYPE_LMAC:
  3933. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3934. return;
  3935. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3936. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3937. break;
  3938. default:
  3939. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3940. bkp_time, "UNKNOWN");
  3941. break;
  3942. }
  3943. dp_print_ring_stats(pdev);
  3944. dp_print_napi_stats(pdev->soc);
  3945. }
  3946. /*
  3947. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  3948. * @context: Opaque context (HTT SOC handle)
  3949. * @pkt: HTC packet
  3950. */
  3951. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3952. {
  3953. struct htt_soc *soc = (struct htt_soc *) context;
  3954. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3955. u_int32_t *msg_word;
  3956. enum htt_t2h_msg_type msg_type;
  3957. bool free_buf = true;
  3958. /* check for successful message reception */
  3959. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3960. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3961. soc->stats.htc_err_cnt++;
  3962. qdf_nbuf_free(htt_t2h_msg);
  3963. return;
  3964. }
  3965. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3966. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3967. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3968. htt_event_record(soc->htt_logger_handle,
  3969. msg_type, (uint8_t *)msg_word);
  3970. switch (msg_type) {
  3971. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3972. {
  3973. dp_htt_bkp_event_alert(msg_word, soc);
  3974. break;
  3975. }
  3976. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3977. {
  3978. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3979. u_int8_t *peer_mac_addr;
  3980. u_int16_t peer_id;
  3981. u_int16_t hw_peer_id;
  3982. u_int8_t vdev_id;
  3983. u_int8_t is_wds;
  3984. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3985. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3986. hw_peer_id =
  3987. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3988. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3989. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3990. (u_int8_t *) (msg_word+1),
  3991. &mac_addr_deswizzle_buf[0]);
  3992. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3993. QDF_TRACE_LEVEL_INFO,
  3994. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3995. peer_id, vdev_id);
  3996. /*
  3997. * check if peer already exists for this peer_id, if so
  3998. * this peer map event is in response for a wds peer add
  3999. * wmi command sent during wds source port learning.
  4000. * in this case just add the ast entry to the existing
  4001. * peer ast_list.
  4002. */
  4003. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  4004. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  4005. vdev_id, peer_mac_addr, 0,
  4006. is_wds);
  4007. break;
  4008. }
  4009. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  4010. {
  4011. u_int16_t peer_id;
  4012. u_int8_t vdev_id;
  4013. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  4014. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  4015. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  4016. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4017. vdev_id, mac_addr, 0,
  4018. DP_PEER_WDS_COUNT_INVALID);
  4019. break;
  4020. }
  4021. case HTT_T2H_MSG_TYPE_SEC_IND:
  4022. {
  4023. u_int16_t peer_id;
  4024. enum cdp_sec_type sec_type;
  4025. int is_unicast;
  4026. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  4027. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  4028. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  4029. /* point to the first part of the Michael key */
  4030. msg_word++;
  4031. dp_rx_sec_ind_handler(
  4032. soc->dp_soc, peer_id, sec_type, is_unicast,
  4033. msg_word, msg_word + 2);
  4034. break;
  4035. }
  4036. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  4037. {
  4038. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  4039. htt_t2h_msg);
  4040. break;
  4041. }
  4042. case HTT_T2H_MSG_TYPE_PKTLOG:
  4043. {
  4044. dp_pktlog_msg_handler(soc, msg_word);
  4045. break;
  4046. }
  4047. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  4048. {
  4049. /*
  4050. * HTC maintains runtime pm count for H2T messages that
  4051. * have a response msg from FW. This count ensures that
  4052. * in the case FW does not sent out the response or host
  4053. * did not process this indication runtime_put happens
  4054. * properly in the cleanup path.
  4055. */
  4056. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  4057. htc_pm_runtime_put(soc->htc_soc);
  4058. else
  4059. soc->stats.htt_ver_req_put_skip++;
  4060. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  4061. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  4062. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  4063. "target uses HTT version %d.%d; host uses %d.%d",
  4064. soc->tgt_ver.major, soc->tgt_ver.minor,
  4065. HTT_CURRENT_VERSION_MAJOR,
  4066. HTT_CURRENT_VERSION_MINOR);
  4067. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  4068. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4069. QDF_TRACE_LEVEL_WARN,
  4070. "*** Incompatible host/target HTT versions!");
  4071. }
  4072. /* abort if the target is incompatible with the host */
  4073. qdf_assert(soc->tgt_ver.major ==
  4074. HTT_CURRENT_VERSION_MAJOR);
  4075. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  4076. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4077. QDF_TRACE_LEVEL_INFO_LOW,
  4078. "*** Warning: host/target HTT versions"
  4079. " are different, though compatible!");
  4080. }
  4081. break;
  4082. }
  4083. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  4084. {
  4085. uint16_t peer_id;
  4086. uint8_t tid;
  4087. uint8_t win_sz;
  4088. uint16_t status;
  4089. struct dp_peer *peer;
  4090. /*
  4091. * Update REO Queue Desc with new values
  4092. */
  4093. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  4094. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  4095. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  4096. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  4097. DP_MOD_ID_HTT);
  4098. /*
  4099. * Window size needs to be incremented by 1
  4100. * since fw needs to represent a value of 256
  4101. * using just 8 bits
  4102. */
  4103. if (peer) {
  4104. status = dp_addba_requestprocess_wifi3(
  4105. (struct cdp_soc_t *)soc->dp_soc,
  4106. peer->mac_addr.raw, peer->vdev->vdev_id,
  4107. 0, tid, 0, win_sz + 1, 0xffff);
  4108. /*
  4109. * If PEER_LOCK_REF_PROTECT enbled dec ref
  4110. * which is inc by dp_peer_get_ref_by_id
  4111. */
  4112. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4113. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4114. QDF_TRACE_LEVEL_INFO,
  4115. FL("PeerID %d BAW %d TID %d stat %d"),
  4116. peer_id, win_sz, tid, status);
  4117. } else {
  4118. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4119. QDF_TRACE_LEVEL_ERROR,
  4120. FL("Peer not found peer id %d"),
  4121. peer_id);
  4122. }
  4123. break;
  4124. }
  4125. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  4126. {
  4127. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  4128. break;
  4129. }
  4130. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  4131. {
  4132. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4133. u_int8_t *peer_mac_addr;
  4134. u_int16_t peer_id;
  4135. u_int16_t hw_peer_id;
  4136. u_int8_t vdev_id;
  4137. bool is_wds;
  4138. u_int16_t ast_hash;
  4139. struct dp_ast_flow_override_info ast_flow_info;
  4140. qdf_mem_set(&ast_flow_info, 0,
  4141. sizeof(struct dp_ast_flow_override_info));
  4142. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  4143. hw_peer_id =
  4144. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  4145. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  4146. peer_mac_addr =
  4147. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4148. &mac_addr_deswizzle_buf[0]);
  4149. is_wds =
  4150. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  4151. ast_hash =
  4152. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  4153. /*
  4154. * Update 4 ast_index per peer, ast valid mask
  4155. * and TID flow valid mask.
  4156. * AST valid mask is 3 bit field corresponds to
  4157. * ast_index[3:1]. ast_index 0 is always valid.
  4158. */
  4159. ast_flow_info.ast_valid_mask =
  4160. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  4161. ast_flow_info.ast_idx[0] = hw_peer_id;
  4162. ast_flow_info.ast_flow_mask[0] =
  4163. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  4164. ast_flow_info.ast_idx[1] =
  4165. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  4166. ast_flow_info.ast_flow_mask[1] =
  4167. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  4168. ast_flow_info.ast_idx[2] =
  4169. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  4170. ast_flow_info.ast_flow_mask[2] =
  4171. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  4172. ast_flow_info.ast_idx[3] =
  4173. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  4174. ast_flow_info.ast_flow_mask[3] =
  4175. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  4176. /*
  4177. * TID valid mask is applicable only
  4178. * for HI and LOW priority flows.
  4179. * tid_valid_mas is 8 bit field corresponds
  4180. * to TID[7:0]
  4181. */
  4182. ast_flow_info.tid_valid_low_pri_mask =
  4183. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  4184. ast_flow_info.tid_valid_hi_pri_mask =
  4185. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  4186. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4187. QDF_TRACE_LEVEL_INFO,
  4188. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4189. peer_id, vdev_id);
  4190. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  4191. hw_peer_id, vdev_id,
  4192. peer_mac_addr, ast_hash,
  4193. is_wds);
  4194. /*
  4195. * Update ast indexes for flow override support
  4196. * Applicable only for non wds peers
  4197. */
  4198. dp_peer_ast_index_flow_queue_map_create(
  4199. soc->dp_soc, is_wds,
  4200. peer_id, peer_mac_addr,
  4201. &ast_flow_info);
  4202. break;
  4203. }
  4204. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  4205. {
  4206. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4207. u_int8_t *mac_addr;
  4208. u_int16_t peer_id;
  4209. u_int8_t vdev_id;
  4210. u_int8_t is_wds;
  4211. u_int32_t free_wds_count;
  4212. peer_id =
  4213. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  4214. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  4215. mac_addr =
  4216. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4217. &mac_addr_deswizzle_buf[0]);
  4218. is_wds =
  4219. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  4220. free_wds_count =
  4221. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  4222. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4223. QDF_TRACE_LEVEL_INFO,
  4224. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  4225. peer_id, vdev_id);
  4226. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4227. vdev_id, mac_addr,
  4228. is_wds, free_wds_count);
  4229. break;
  4230. }
  4231. case HTT_T2H_MSG_TYPE_RX_DELBA:
  4232. {
  4233. uint16_t peer_id;
  4234. uint8_t tid;
  4235. uint8_t win_sz;
  4236. QDF_STATUS status;
  4237. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  4238. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  4239. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  4240. status = dp_rx_delba_ind_handler(
  4241. soc->dp_soc,
  4242. peer_id, tid, win_sz);
  4243. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4244. QDF_TRACE_LEVEL_INFO,
  4245. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  4246. peer_id, win_sz, tid, status);
  4247. break;
  4248. }
  4249. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  4250. {
  4251. uint16_t num_entries;
  4252. uint32_t cmem_ba_lo;
  4253. uint32_t cmem_ba_hi;
  4254. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  4255. cmem_ba_lo = *(msg_word + 1);
  4256. cmem_ba_hi = *(msg_word + 2);
  4257. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  4258. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  4259. num_entries, cmem_ba_lo, cmem_ba_hi);
  4260. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  4261. cmem_ba_lo, cmem_ba_hi);
  4262. }
  4263. default:
  4264. break;
  4265. };
  4266. /* Free the indication buffer */
  4267. if (free_buf)
  4268. qdf_nbuf_free(htt_t2h_msg);
  4269. }
  4270. /*
  4271. * dp_htt_h2t_full() - Send full handler (called from HTC)
  4272. * @context: Opaque context (HTT SOC handle)
  4273. * @pkt: HTC packet
  4274. *
  4275. * Return: enum htc_send_full_action
  4276. */
  4277. static enum htc_send_full_action
  4278. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  4279. {
  4280. return HTC_SEND_FULL_KEEP;
  4281. }
  4282. /*
  4283. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  4284. * @context: Opaque context (HTT SOC handle)
  4285. * @nbuf: nbuf containing T2H message
  4286. * @pipe_id: HIF pipe ID
  4287. *
  4288. * Return: QDF_STATUS
  4289. *
  4290. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  4291. * will be used for packet log and other high-priority HTT messages. Proper
  4292. * HTC connection to be added later once required FW changes are available
  4293. */
  4294. static QDF_STATUS
  4295. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  4296. {
  4297. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  4298. HTC_PACKET htc_pkt;
  4299. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  4300. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  4301. htc_pkt.Status = QDF_STATUS_SUCCESS;
  4302. htc_pkt.pPktContext = (void *)nbuf;
  4303. dp_htt_t2h_msg_handler(context, &htc_pkt);
  4304. return rc;
  4305. }
  4306. /*
  4307. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  4308. * @htt_soc: HTT SOC handle
  4309. *
  4310. * Return: QDF_STATUS
  4311. */
  4312. static QDF_STATUS
  4313. htt_htc_soc_attach(struct htt_soc *soc)
  4314. {
  4315. struct htc_service_connect_req connect;
  4316. struct htc_service_connect_resp response;
  4317. QDF_STATUS status;
  4318. struct dp_soc *dpsoc = soc->dp_soc;
  4319. qdf_mem_zero(&connect, sizeof(connect));
  4320. qdf_mem_zero(&response, sizeof(response));
  4321. connect.pMetaData = NULL;
  4322. connect.MetaDataLength = 0;
  4323. connect.EpCallbacks.pContext = soc;
  4324. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  4325. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  4326. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  4327. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  4328. connect.EpCallbacks.EpRecvRefill = NULL;
  4329. /* N/A, fill is done by HIF */
  4330. connect.EpCallbacks.RecvRefillWaterMark = 1;
  4331. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  4332. /*
  4333. * Specify how deep to let a queue get before htc_send_pkt will
  4334. * call the EpSendFull function due to excessive send queue depth.
  4335. */
  4336. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  4337. /* disable flow control for HTT data message service */
  4338. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  4339. /* connect to control service */
  4340. connect.service_id = HTT_DATA_MSG_SVC;
  4341. status = htc_connect_service(soc->htc_soc, &connect, &response);
  4342. if (status != QDF_STATUS_SUCCESS)
  4343. return status;
  4344. soc->htc_endpoint = response.Endpoint;
  4345. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  4346. htt_interface_logging_init(&soc->htt_logger_handle);
  4347. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  4348. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  4349. return QDF_STATUS_SUCCESS; /* success */
  4350. }
  4351. /*
  4352. * htt_soc_initialize() - SOC level HTT initialization
  4353. * @htt_soc: Opaque htt SOC handle
  4354. * @ctrl_psoc: Opaque ctrl SOC handle
  4355. * @htc_soc: SOC level HTC handle
  4356. * @hal_soc: Opaque HAL SOC handle
  4357. * @osdev: QDF device
  4358. *
  4359. * Return: HTT handle on success; NULL on failure
  4360. */
  4361. void *
  4362. htt_soc_initialize(struct htt_soc *htt_soc,
  4363. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  4364. HTC_HANDLE htc_soc,
  4365. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  4366. {
  4367. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  4368. soc->osdev = osdev;
  4369. soc->ctrl_psoc = ctrl_psoc;
  4370. soc->htc_soc = htc_soc;
  4371. soc->hal_soc = hal_soc_hdl;
  4372. if (htt_htc_soc_attach(soc))
  4373. goto fail2;
  4374. return soc;
  4375. fail2:
  4376. return NULL;
  4377. }
  4378. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  4379. {
  4380. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  4381. htt_htc_misc_pkt_pool_free(htt_handle);
  4382. htt_htc_pkt_pool_free(htt_handle);
  4383. }
  4384. /*
  4385. * htt_soc_htc_prealloc() - HTC memory prealloc
  4386. * @htt_soc: SOC level HTT handle
  4387. *
  4388. * Return: QDF_STATUS_SUCCESS on Success or
  4389. * QDF_STATUS_E_NOMEM on allocation failure
  4390. */
  4391. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  4392. {
  4393. int i;
  4394. soc->htt_htc_pkt_freelist = NULL;
  4395. /* pre-allocate some HTC_PACKET objects */
  4396. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  4397. struct dp_htt_htc_pkt_union *pkt;
  4398. pkt = qdf_mem_malloc(sizeof(*pkt));
  4399. if (!pkt)
  4400. return QDF_STATUS_E_NOMEM;
  4401. htt_htc_pkt_free(soc, &pkt->u.pkt);
  4402. }
  4403. return QDF_STATUS_SUCCESS;
  4404. }
  4405. /*
  4406. * htt_soc_detach() - Free SOC level HTT handle
  4407. * @htt_hdl: HTT SOC handle
  4408. */
  4409. void htt_soc_detach(struct htt_soc *htt_hdl)
  4410. {
  4411. int i;
  4412. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  4413. for (i = 0; i < MAX_PDEV_CNT; i++) {
  4414. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  4415. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  4416. }
  4417. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  4418. qdf_mem_free(htt_handle);
  4419. }
  4420. /**
  4421. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  4422. * @pdev: DP PDEV handle
  4423. * @stats_type_upload_mask: stats type requested by user
  4424. * @config_param_0: extra configuration parameters
  4425. * @config_param_1: extra configuration parameters
  4426. * @config_param_2: extra configuration parameters
  4427. * @config_param_3: extra configuration parameters
  4428. * @mac_id: mac number
  4429. *
  4430. * return: QDF STATUS
  4431. */
  4432. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  4433. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  4434. uint32_t config_param_1, uint32_t config_param_2,
  4435. uint32_t config_param_3, int cookie_val, int cookie_msb,
  4436. uint8_t mac_id)
  4437. {
  4438. struct htt_soc *soc = pdev->soc->htt_handle;
  4439. struct dp_htt_htc_pkt *pkt;
  4440. qdf_nbuf_t msg;
  4441. uint32_t *msg_word;
  4442. uint8_t pdev_mask = 0;
  4443. uint8_t *htt_logger_bufp;
  4444. int mac_for_pdev;
  4445. int target_pdev_id;
  4446. QDF_STATUS status;
  4447. msg = qdf_nbuf_alloc(
  4448. soc->osdev,
  4449. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  4450. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4451. if (!msg)
  4452. return QDF_STATUS_E_NOMEM;
  4453. /*TODO:Add support for SOC stats
  4454. * Bit 0: SOC Stats
  4455. * Bit 1: Pdev stats for pdev id 0
  4456. * Bit 2: Pdev stats for pdev id 1
  4457. * Bit 3: Pdev stats for pdev id 2
  4458. */
  4459. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4460. target_pdev_id =
  4461. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4462. pdev_mask = 1 << target_pdev_id;
  4463. /*
  4464. * Set the length of the message.
  4465. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4466. * separately during the below call to qdf_nbuf_push_head.
  4467. * The contribution from the HTC header is added separately inside HTC.
  4468. */
  4469. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  4470. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4471. "Failed to expand head for HTT_EXT_STATS");
  4472. qdf_nbuf_free(msg);
  4473. return QDF_STATUS_E_FAILURE;
  4474. }
  4475. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4476. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  4477. "config_param_1 %u\n config_param_2 %u\n"
  4478. "config_param_4 %u\n -------------",
  4479. __func__, __LINE__, cookie_val, config_param_0,
  4480. config_param_1, config_param_2, config_param_3);
  4481. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4482. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4483. htt_logger_bufp = (uint8_t *)msg_word;
  4484. *msg_word = 0;
  4485. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  4486. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  4487. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  4488. /* word 1 */
  4489. msg_word++;
  4490. *msg_word = 0;
  4491. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  4492. /* word 2 */
  4493. msg_word++;
  4494. *msg_word = 0;
  4495. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  4496. /* word 3 */
  4497. msg_word++;
  4498. *msg_word = 0;
  4499. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  4500. /* word 4 */
  4501. msg_word++;
  4502. *msg_word = 0;
  4503. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  4504. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  4505. /* word 5 */
  4506. msg_word++;
  4507. /* word 6 */
  4508. msg_word++;
  4509. *msg_word = 0;
  4510. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  4511. /* word 7 */
  4512. msg_word++;
  4513. *msg_word = 0;
  4514. /* Currently Using last 2 bits for pdev_id
  4515. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  4516. */
  4517. cookie_msb = (cookie_msb | pdev->pdev_id);
  4518. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  4519. pkt = htt_htc_pkt_alloc(soc);
  4520. if (!pkt) {
  4521. qdf_nbuf_free(msg);
  4522. return QDF_STATUS_E_NOMEM;
  4523. }
  4524. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4525. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4526. dp_htt_h2t_send_complete_free_netbuf,
  4527. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4528. soc->htc_endpoint,
  4529. /* tag for FW response msg not guaranteed */
  4530. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4531. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4532. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  4533. htt_logger_bufp);
  4534. if (status != QDF_STATUS_SUCCESS) {
  4535. qdf_nbuf_free(msg);
  4536. htt_htc_pkt_free(soc, pkt);
  4537. }
  4538. return status;
  4539. }
  4540. /**
  4541. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  4542. * HTT message to pass to FW
  4543. * @pdev: DP PDEV handle
  4544. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4545. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4546. *
  4547. * tuple_mask[1:0]:
  4548. * 00 - Do not report 3 tuple hash value
  4549. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4550. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4551. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4552. *
  4553. * return: QDF STATUS
  4554. */
  4555. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4556. uint32_t tuple_mask, uint8_t mac_id)
  4557. {
  4558. struct htt_soc *soc = pdev->soc->htt_handle;
  4559. struct dp_htt_htc_pkt *pkt;
  4560. qdf_nbuf_t msg;
  4561. uint32_t *msg_word;
  4562. uint8_t *htt_logger_bufp;
  4563. int mac_for_pdev;
  4564. int target_pdev_id;
  4565. msg = qdf_nbuf_alloc(
  4566. soc->osdev,
  4567. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4568. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4569. if (!msg)
  4570. return QDF_STATUS_E_NOMEM;
  4571. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4572. target_pdev_id =
  4573. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4574. /*
  4575. * Set the length of the message.
  4576. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4577. * separately during the below call to qdf_nbuf_push_head.
  4578. * The contribution from the HTC header is added separately inside HTC.
  4579. */
  4580. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4581. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4582. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4583. qdf_nbuf_free(msg);
  4584. return QDF_STATUS_E_FAILURE;
  4585. }
  4586. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4587. "config_param_sent %s:%d 0x%x for target_pdev %d\n -------------",
  4588. __func__, __LINE__, tuple_mask, target_pdev_id);
  4589. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4590. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4591. htt_logger_bufp = (uint8_t *)msg_word;
  4592. *msg_word = 0;
  4593. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4594. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4595. msg_word++;
  4596. *msg_word = 0;
  4597. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4598. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4599. pkt = htt_htc_pkt_alloc(soc);
  4600. if (!pkt) {
  4601. qdf_nbuf_free(msg);
  4602. return QDF_STATUS_E_NOMEM;
  4603. }
  4604. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4605. SET_HTC_PACKET_INFO_TX(
  4606. &pkt->htc_pkt,
  4607. dp_htt_h2t_send_complete_free_netbuf,
  4608. qdf_nbuf_data(msg),
  4609. qdf_nbuf_len(msg),
  4610. soc->htc_endpoint,
  4611. /* tag for no FW response msg */
  4612. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4613. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4614. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4615. htt_logger_bufp);
  4616. return QDF_STATUS_SUCCESS;
  4617. }
  4618. /* This macro will revert once proper HTT header will define for
  4619. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4620. * */
  4621. #if defined(WDI_EVENT_ENABLE)
  4622. /**
  4623. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  4624. * @pdev: DP PDEV handle
  4625. * @stats_type_upload_mask: stats type requested by user
  4626. * @mac_id: Mac id number
  4627. *
  4628. * return: QDF STATUS
  4629. */
  4630. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4631. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4632. {
  4633. struct htt_soc *soc = pdev->soc->htt_handle;
  4634. struct dp_htt_htc_pkt *pkt;
  4635. qdf_nbuf_t msg;
  4636. uint32_t *msg_word;
  4637. uint8_t pdev_mask;
  4638. QDF_STATUS status;
  4639. msg = qdf_nbuf_alloc(
  4640. soc->osdev,
  4641. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4642. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4643. if (!msg) {
  4644. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4645. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer");
  4646. qdf_assert(0);
  4647. return QDF_STATUS_E_NOMEM;
  4648. }
  4649. /*TODO:Add support for SOC stats
  4650. * Bit 0: SOC Stats
  4651. * Bit 1: Pdev stats for pdev id 0
  4652. * Bit 2: Pdev stats for pdev id 1
  4653. * Bit 3: Pdev stats for pdev id 2
  4654. */
  4655. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4656. mac_id);
  4657. /*
  4658. * Set the length of the message.
  4659. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4660. * separately during the below call to qdf_nbuf_push_head.
  4661. * The contribution from the HTC header is added separately inside HTC.
  4662. */
  4663. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4664. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4665. "Failed to expand head for HTT_CFG_STATS");
  4666. qdf_nbuf_free(msg);
  4667. return QDF_STATUS_E_FAILURE;
  4668. }
  4669. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4670. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4671. *msg_word = 0;
  4672. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4673. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4674. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4675. stats_type_upload_mask);
  4676. pkt = htt_htc_pkt_alloc(soc);
  4677. if (!pkt) {
  4678. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4679. "Fail to allocate dp_htt_htc_pkt buffer");
  4680. qdf_assert(0);
  4681. qdf_nbuf_free(msg);
  4682. return QDF_STATUS_E_NOMEM;
  4683. }
  4684. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4685. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4686. dp_htt_h2t_send_complete_free_netbuf,
  4687. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4688. soc->htc_endpoint,
  4689. /* tag for no FW response msg */
  4690. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4691. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4692. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4693. (uint8_t *)msg_word);
  4694. if (status != QDF_STATUS_SUCCESS) {
  4695. qdf_nbuf_free(msg);
  4696. htt_htc_pkt_free(soc, pkt);
  4697. }
  4698. return status;
  4699. }
  4700. #endif
  4701. void
  4702. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4703. uint32_t *tag_buf)
  4704. {
  4705. struct dp_peer *peer = NULL;
  4706. switch (tag_type) {
  4707. case HTT_STATS_PEER_DETAILS_TAG:
  4708. {
  4709. htt_peer_details_tlv *dp_stats_buf =
  4710. (htt_peer_details_tlv *)tag_buf;
  4711. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4712. }
  4713. break;
  4714. case HTT_STATS_PEER_STATS_CMN_TAG:
  4715. {
  4716. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4717. (htt_peer_stats_cmn_tlv *)tag_buf;
  4718. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4719. DP_MOD_ID_HTT);
  4720. if (peer && !peer->bss_peer) {
  4721. peer->stats.tx.inactive_time =
  4722. dp_stats_buf->inactive_time;
  4723. qdf_event_set(&pdev->fw_peer_stats_event);
  4724. }
  4725. if (peer)
  4726. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4727. }
  4728. break;
  4729. default:
  4730. qdf_err("Invalid tag_type");
  4731. }
  4732. }
  4733. /**
  4734. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  4735. * @pdev: DP pdev handle
  4736. * @fse_setup_info: FST setup parameters
  4737. *
  4738. * Return: Success when HTT message is sent, error on failure
  4739. */
  4740. QDF_STATUS
  4741. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4742. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4743. {
  4744. struct htt_soc *soc = pdev->soc->htt_handle;
  4745. struct dp_htt_htc_pkt *pkt;
  4746. qdf_nbuf_t msg;
  4747. u_int32_t *msg_word;
  4748. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4749. uint8_t *htt_logger_bufp;
  4750. u_int32_t *key;
  4751. QDF_STATUS status;
  4752. msg = qdf_nbuf_alloc(
  4753. soc->osdev,
  4754. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4755. /* reserve room for the HTC header */
  4756. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4757. if (!msg)
  4758. return QDF_STATUS_E_NOMEM;
  4759. /*
  4760. * Set the length of the message.
  4761. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4762. * separately during the below call to qdf_nbuf_push_head.
  4763. * The contribution from the HTC header is added separately inside HTC.
  4764. */
  4765. if (!qdf_nbuf_put_tail(msg,
  4766. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4767. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4768. return QDF_STATUS_E_FAILURE;
  4769. }
  4770. /* fill in the message contents */
  4771. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4772. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4773. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4774. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4775. htt_logger_bufp = (uint8_t *)msg_word;
  4776. *msg_word = 0;
  4777. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4778. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4779. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4780. msg_word++;
  4781. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4782. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4783. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4784. fse_setup_info->ip_da_sa_prefix);
  4785. msg_word++;
  4786. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4787. fse_setup_info->base_addr_lo);
  4788. msg_word++;
  4789. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4790. fse_setup_info->base_addr_hi);
  4791. key = (u_int32_t *)fse_setup_info->hash_key;
  4792. fse_setup->toeplitz31_0 = *key++;
  4793. fse_setup->toeplitz63_32 = *key++;
  4794. fse_setup->toeplitz95_64 = *key++;
  4795. fse_setup->toeplitz127_96 = *key++;
  4796. fse_setup->toeplitz159_128 = *key++;
  4797. fse_setup->toeplitz191_160 = *key++;
  4798. fse_setup->toeplitz223_192 = *key++;
  4799. fse_setup->toeplitz255_224 = *key++;
  4800. fse_setup->toeplitz287_256 = *key++;
  4801. fse_setup->toeplitz314_288 = *key;
  4802. msg_word++;
  4803. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4804. msg_word++;
  4805. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4806. msg_word++;
  4807. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4808. msg_word++;
  4809. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4810. msg_word++;
  4811. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4812. msg_word++;
  4813. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4814. msg_word++;
  4815. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4816. msg_word++;
  4817. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4818. msg_word++;
  4819. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4820. msg_word++;
  4821. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4822. fse_setup->toeplitz314_288);
  4823. pkt = htt_htc_pkt_alloc(soc);
  4824. if (!pkt) {
  4825. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4826. qdf_assert(0);
  4827. qdf_nbuf_free(msg);
  4828. return QDF_STATUS_E_RESOURCES; /* failure */
  4829. }
  4830. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4831. SET_HTC_PACKET_INFO_TX(
  4832. &pkt->htc_pkt,
  4833. dp_htt_h2t_send_complete_free_netbuf,
  4834. qdf_nbuf_data(msg),
  4835. qdf_nbuf_len(msg),
  4836. soc->htc_endpoint,
  4837. /* tag for no FW response msg */
  4838. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4839. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4840. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4841. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4842. htt_logger_bufp);
  4843. if (status == QDF_STATUS_SUCCESS) {
  4844. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4845. fse_setup_info->pdev_id);
  4846. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4847. (void *)fse_setup_info->hash_key,
  4848. fse_setup_info->hash_key_len);
  4849. } else {
  4850. qdf_nbuf_free(msg);
  4851. htt_htc_pkt_free(soc, pkt);
  4852. }
  4853. return status;
  4854. }
  4855. /**
  4856. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  4857. * add/del a flow in HW
  4858. * @pdev: DP pdev handle
  4859. * @fse_op_info: Flow entry parameters
  4860. *
  4861. * Return: Success when HTT message is sent, error on failure
  4862. */
  4863. QDF_STATUS
  4864. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4865. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4866. {
  4867. struct htt_soc *soc = pdev->soc->htt_handle;
  4868. struct dp_htt_htc_pkt *pkt;
  4869. qdf_nbuf_t msg;
  4870. u_int32_t *msg_word;
  4871. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4872. uint8_t *htt_logger_bufp;
  4873. QDF_STATUS status;
  4874. msg = qdf_nbuf_alloc(
  4875. soc->osdev,
  4876. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4877. /* reserve room for the HTC header */
  4878. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4879. if (!msg)
  4880. return QDF_STATUS_E_NOMEM;
  4881. /*
  4882. * Set the length of the message.
  4883. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4884. * separately during the below call to qdf_nbuf_push_head.
  4885. * The contribution from the HTC header is added separately inside HTC.
  4886. */
  4887. if (!qdf_nbuf_put_tail(msg,
  4888. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4889. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4890. qdf_nbuf_free(msg);
  4891. return QDF_STATUS_E_FAILURE;
  4892. }
  4893. /* fill in the message contents */
  4894. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4895. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4896. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4897. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4898. htt_logger_bufp = (uint8_t *)msg_word;
  4899. *msg_word = 0;
  4900. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4901. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4902. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4903. msg_word++;
  4904. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4905. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4906. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4907. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4908. msg_word++;
  4909. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4910. *msg_word,
  4911. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4912. msg_word++;
  4913. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4914. *msg_word,
  4915. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4916. msg_word++;
  4917. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4918. *msg_word,
  4919. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4920. msg_word++;
  4921. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4922. *msg_word,
  4923. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4924. msg_word++;
  4925. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4926. *msg_word,
  4927. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4928. msg_word++;
  4929. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4930. *msg_word,
  4931. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4932. msg_word++;
  4933. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4934. *msg_word,
  4935. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4936. msg_word++;
  4937. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4938. *msg_word,
  4939. qdf_htonl(
  4940. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4941. msg_word++;
  4942. HTT_RX_FSE_SOURCEPORT_SET(
  4943. *msg_word,
  4944. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4945. HTT_RX_FSE_DESTPORT_SET(
  4946. *msg_word,
  4947. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4948. msg_word++;
  4949. HTT_RX_FSE_L4_PROTO_SET(
  4950. *msg_word,
  4951. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4952. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4953. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4954. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4955. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4956. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4957. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4958. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4959. }
  4960. pkt = htt_htc_pkt_alloc(soc);
  4961. if (!pkt) {
  4962. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4963. qdf_assert(0);
  4964. qdf_nbuf_free(msg);
  4965. return QDF_STATUS_E_RESOURCES; /* failure */
  4966. }
  4967. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4968. SET_HTC_PACKET_INFO_TX(
  4969. &pkt->htc_pkt,
  4970. dp_htt_h2t_send_complete_free_netbuf,
  4971. qdf_nbuf_data(msg),
  4972. qdf_nbuf_len(msg),
  4973. soc->htc_endpoint,
  4974. /* tag for no FW response msg */
  4975. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4976. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4977. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4978. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4979. htt_logger_bufp);
  4980. if (status == QDF_STATUS_SUCCESS) {
  4981. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4982. fse_op_info->pdev_id);
  4983. } else {
  4984. qdf_nbuf_free(msg);
  4985. htt_htc_pkt_free(soc, pkt);
  4986. }
  4987. return status;
  4988. }
  4989. /**
  4990. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4991. * @pdev: DP pdev handle
  4992. * @fse_op_info: Flow entry parameters
  4993. *
  4994. * Return: Success when HTT message is sent, error on failure
  4995. */
  4996. QDF_STATUS
  4997. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4998. struct dp_htt_rx_fisa_cfg *fisa_config)
  4999. {
  5000. struct htt_soc *soc = pdev->soc->htt_handle;
  5001. struct dp_htt_htc_pkt *pkt;
  5002. qdf_nbuf_t msg;
  5003. u_int32_t *msg_word;
  5004. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  5005. uint8_t *htt_logger_bufp;
  5006. uint32_t len;
  5007. QDF_STATUS status;
  5008. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5009. msg = qdf_nbuf_alloc(soc->osdev,
  5010. len,
  5011. /* reserve room for the HTC header */
  5012. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  5013. 4,
  5014. TRUE);
  5015. if (!msg)
  5016. return QDF_STATUS_E_NOMEM;
  5017. /*
  5018. * Set the length of the message.
  5019. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  5020. * separately during the below call to qdf_nbuf_push_head.
  5021. * The contribution from the HTC header is added separately inside HTC.
  5022. */
  5023. if (!qdf_nbuf_put_tail(msg,
  5024. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  5025. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  5026. qdf_nbuf_free(msg);
  5027. return QDF_STATUS_E_FAILURE;
  5028. }
  5029. /* fill in the message contents */
  5030. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  5031. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5032. /* rewind beyond alignment pad to get to the HTC header reserved area */
  5033. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  5034. htt_logger_bufp = (uint8_t *)msg_word;
  5035. *msg_word = 0;
  5036. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  5037. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  5038. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  5039. msg_word++;
  5040. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  5041. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  5042. msg_word++;
  5043. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  5044. pkt = htt_htc_pkt_alloc(soc);
  5045. if (!pkt) {
  5046. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  5047. qdf_assert(0);
  5048. qdf_nbuf_free(msg);
  5049. return QDF_STATUS_E_RESOURCES; /* failure */
  5050. }
  5051. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  5052. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  5053. dp_htt_h2t_send_complete_free_netbuf,
  5054. qdf_nbuf_data(msg),
  5055. qdf_nbuf_len(msg),
  5056. soc->htc_endpoint,
  5057. /* tag for no FW response msg */
  5058. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  5059. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  5060. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  5061. htt_logger_bufp);
  5062. if (status == QDF_STATUS_SUCCESS) {
  5063. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  5064. fisa_config->pdev_id);
  5065. } else {
  5066. qdf_nbuf_free(msg);
  5067. htt_htc_pkt_free(soc, pkt);
  5068. }
  5069. return status;
  5070. }