dp_htt.c 163 KB

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