dp_htt.c 165 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721
  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 =
  2165. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2166. ppdu_desc->vdev_id);
  2167. if (!vdev)
  2168. return;
  2169. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2170. QDF_MAC_ADDR_SIZE);
  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 =
  2183. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2184. ppdu_desc->vdev_id);
  2185. if (!vdev)
  2186. return;
  2187. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2188. vdev->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2189. return;
  2190. }
  2191. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2192. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2193. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2194. }
  2195. }
  2196. /**
  2197. * dp_process_ppdu_stats_user_rate_tlv() - Process htt_ppdu_stats_user_rate_tlv
  2198. * @pdev: DP pdev handle
  2199. * @tag_buf: T2H message buffer carrying the user rate TLV
  2200. * @ppdu_info: per ppdu tlv structure
  2201. *
  2202. * return:void
  2203. */
  2204. static void dp_process_ppdu_stats_user_rate_tlv(struct dp_pdev *pdev,
  2205. uint32_t *tag_buf,
  2206. struct ppdu_info *ppdu_info)
  2207. {
  2208. uint16_t peer_id;
  2209. struct dp_peer *peer;
  2210. struct cdp_tx_completion_ppdu *ppdu_desc;
  2211. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2212. uint8_t curr_user_index = 0;
  2213. struct dp_vdev *vdev;
  2214. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2215. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2216. tag_buf++;
  2217. peer_id = HTT_PPDU_STATS_USER_RATE_TLV_SW_PEER_ID_GET(*tag_buf);
  2218. curr_user_index =
  2219. dp_get_ppdu_info_user_index(pdev,
  2220. peer_id, ppdu_info);
  2221. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2222. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2223. if (peer_id == DP_SCAN_PEER_ID) {
  2224. vdev =
  2225. dp_get_vdev_from_soc_vdev_id_wifi3(pdev->soc,
  2226. ppdu_desc->vdev_id);
  2227. if (!vdev)
  2228. return;
  2229. qdf_mem_copy(ppdu_user_desc->mac_addr, vdev->mac_addr.raw,
  2230. QDF_MAC_ADDR_SIZE);
  2231. } else {
  2232. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2233. DP_MOD_ID_TX_PPDU_STATS);
  2234. if (peer) {
  2235. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2236. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2237. peer->mac_addr.raw,
  2238. QDF_MAC_ADDR_SIZE);
  2239. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2240. }
  2241. }
  2242. ppdu_user_desc->peer_id = peer_id;
  2243. ppdu_user_desc->tid =
  2244. HTT_PPDU_STATS_USER_RATE_TLV_TID_NUM_GET(*tag_buf);
  2245. tag_buf += 1;
  2246. ppdu_user_desc->user_pos =
  2247. HTT_PPDU_STATS_USER_RATE_TLV_USER_POS_GET(*tag_buf);
  2248. ppdu_user_desc->mu_group_id =
  2249. HTT_PPDU_STATS_USER_RATE_TLV_MU_GROUPID_GET(*tag_buf);
  2250. tag_buf += 1;
  2251. ppdu_user_desc->ru_start =
  2252. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf);
  2253. ppdu_user_desc->ru_tones =
  2254. (HTT_PPDU_STATS_USER_RATE_TLV_RU_END_GET(*tag_buf) -
  2255. HTT_PPDU_STATS_USER_RATE_TLV_RU_START_GET(*tag_buf)) + 1;
  2256. ppdu_desc->usr_ru_tones_sum += ppdu_user_desc->ru_tones;
  2257. tag_buf += 2;
  2258. ppdu_user_desc->ppdu_type =
  2259. HTT_PPDU_STATS_USER_RATE_TLV_PPDU_TYPE_GET(*tag_buf);
  2260. tag_buf++;
  2261. ppdu_user_desc->tx_rate = *tag_buf;
  2262. ppdu_user_desc->ltf_size =
  2263. HTT_PPDU_STATS_USER_RATE_TLV_LTF_SIZE_GET(*tag_buf);
  2264. ppdu_user_desc->stbc =
  2265. HTT_PPDU_STATS_USER_RATE_TLV_STBC_GET(*tag_buf);
  2266. ppdu_user_desc->he_re =
  2267. HTT_PPDU_STATS_USER_RATE_TLV_HE_RE_GET(*tag_buf);
  2268. ppdu_user_desc->txbf =
  2269. HTT_PPDU_STATS_USER_RATE_TLV_TXBF_GET(*tag_buf);
  2270. ppdu_user_desc->bw =
  2271. HTT_PPDU_STATS_USER_RATE_TLV_BW_GET(*tag_buf) - 2;
  2272. ppdu_user_desc->nss = HTT_PPDU_STATS_USER_RATE_TLV_NSS_GET(*tag_buf);
  2273. ppdu_desc->usr_nss_sum += ppdu_user_desc->nss;
  2274. ppdu_user_desc->mcs = HTT_PPDU_STATS_USER_RATE_TLV_MCS_GET(*tag_buf);
  2275. ppdu_user_desc->preamble =
  2276. HTT_PPDU_STATS_USER_RATE_TLV_PREAMBLE_GET(*tag_buf);
  2277. ppdu_user_desc->gi = HTT_PPDU_STATS_USER_RATE_TLV_GI_GET(*tag_buf);
  2278. ppdu_user_desc->dcm = HTT_PPDU_STATS_USER_RATE_TLV_DCM_GET(*tag_buf);
  2279. ppdu_user_desc->ldpc = HTT_PPDU_STATS_USER_RATE_TLV_LDPC_GET(*tag_buf);
  2280. }
  2281. /*
  2282. * dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv: Process
  2283. * htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2284. * pdev: DP PDEV handle
  2285. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_64_tlv
  2286. * @ppdu_info: per ppdu tlv structure
  2287. *
  2288. * return:void
  2289. */
  2290. static void dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  2291. struct dp_pdev *pdev, uint32_t *tag_buf,
  2292. struct ppdu_info *ppdu_info)
  2293. {
  2294. htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *dp_stats_buf =
  2295. (htt_ppdu_stats_enq_mpdu_bitmap_64_tlv *)tag_buf;
  2296. struct cdp_tx_completion_ppdu *ppdu_desc;
  2297. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2298. uint8_t curr_user_index = 0;
  2299. uint16_t peer_id;
  2300. struct dp_peer *peer;
  2301. uint32_t size = CDP_BA_64_BIT_MAP_SIZE_DWORDS;
  2302. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2303. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2304. tag_buf++;
  2305. peer_id =
  2306. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2307. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2308. DP_MOD_ID_TX_PPDU_STATS);
  2309. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2310. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2311. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2312. if (peer) {
  2313. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2314. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2315. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2316. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2317. }
  2318. ppdu_user_desc->peer_id = peer_id;
  2319. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2320. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2321. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2322. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2323. (void *)ppdu_user_desc,
  2324. ppdu_info->ppdu_id,
  2325. size);
  2326. }
  2327. /*
  2328. * dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv: Process
  2329. * htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2330. * soc: DP SOC handle
  2331. * @tag_buf: buffer containing the tlv htt_ppdu_stats_enq_mpdu_bitmap_256_tlv
  2332. * @ppdu_info: per ppdu tlv structure
  2333. *
  2334. * return:void
  2335. */
  2336. static void dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  2337. struct dp_pdev *pdev, uint32_t *tag_buf,
  2338. struct ppdu_info *ppdu_info)
  2339. {
  2340. htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *dp_stats_buf =
  2341. (htt_ppdu_stats_enq_mpdu_bitmap_256_tlv *)tag_buf;
  2342. struct cdp_tx_completion_ppdu *ppdu_desc;
  2343. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2344. uint8_t curr_user_index = 0;
  2345. uint16_t peer_id;
  2346. struct dp_peer *peer;
  2347. uint32_t size = CDP_BA_256_BIT_MAP_SIZE_DWORDS;
  2348. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2349. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2350. tag_buf++;
  2351. peer_id =
  2352. HTT_PPDU_STATS_ENQ_MPDU_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2353. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2354. DP_MOD_ID_TX_PPDU_STATS);
  2355. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2356. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2357. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2358. if (peer) {
  2359. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2360. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2361. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2362. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2363. }
  2364. ppdu_user_desc->peer_id = peer_id;
  2365. ppdu_user_desc->start_seq = dp_stats_buf->start_seq;
  2366. qdf_mem_copy(&ppdu_user_desc->enq_bitmap, &dp_stats_buf->enq_bitmap,
  2367. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2368. dp_process_ppdu_stats_update_failed_bitmap(pdev,
  2369. (void *)ppdu_user_desc,
  2370. ppdu_info->ppdu_id,
  2371. size);
  2372. }
  2373. /*
  2374. * dp_process_ppdu_stats_user_cmpltn_common_tlv: Process
  2375. * htt_ppdu_stats_user_cmpltn_common_tlv
  2376. * soc: DP SOC handle
  2377. * @tag_buf: buffer containing the tlv htt_ppdu_stats_user_cmpltn_common_tlv
  2378. * @ppdu_info: per ppdu tlv structure
  2379. *
  2380. * return:void
  2381. */
  2382. static void dp_process_ppdu_stats_user_cmpltn_common_tlv(
  2383. struct dp_pdev *pdev, uint32_t *tag_buf,
  2384. struct ppdu_info *ppdu_info)
  2385. {
  2386. uint16_t peer_id;
  2387. struct dp_peer *peer;
  2388. struct cdp_tx_completion_ppdu *ppdu_desc;
  2389. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2390. uint8_t curr_user_index = 0;
  2391. uint8_t bw_iter;
  2392. htt_ppdu_stats_user_cmpltn_common_tlv *dp_stats_buf =
  2393. (htt_ppdu_stats_user_cmpltn_common_tlv *)tag_buf;
  2394. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2395. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2396. tag_buf++;
  2397. peer_id =
  2398. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SW_PEER_ID_GET(*tag_buf);
  2399. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2400. DP_MOD_ID_TX_PPDU_STATS);
  2401. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2402. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2403. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2404. if (peer) {
  2405. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2406. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2407. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2408. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2409. }
  2410. ppdu_user_desc->peer_id = peer_id;
  2411. ppdu_user_desc->completion_status =
  2412. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_COMPLETION_STATUS_GET(
  2413. *tag_buf);
  2414. ppdu_user_desc->tid =
  2415. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TID_NUM_GET(*tag_buf);
  2416. tag_buf++;
  2417. if (qdf_likely(ppdu_user_desc->completion_status ==
  2418. HTT_PPDU_STATS_USER_STATUS_OK)) {
  2419. ppdu_desc->ack_rssi = dp_stats_buf->ack_rssi;
  2420. ppdu_user_desc->usr_ack_rssi = dp_stats_buf->ack_rssi;
  2421. ppdu_user_desc->ack_rssi_valid = 1;
  2422. } else {
  2423. ppdu_user_desc->ack_rssi_valid = 0;
  2424. }
  2425. tag_buf++;
  2426. ppdu_user_desc->mpdu_success =
  2427. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_SUCCESS_GET(*tag_buf);
  2428. ppdu_user_desc->mpdu_failed =
  2429. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPDU_TRIED_GET(*tag_buf) -
  2430. ppdu_user_desc->mpdu_success;
  2431. tag_buf++;
  2432. ppdu_user_desc->long_retries =
  2433. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_LONG_RETRY_GET(*tag_buf);
  2434. ppdu_user_desc->short_retries =
  2435. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_SHORT_RETRY_GET(*tag_buf);
  2436. ppdu_user_desc->retry_msdus =
  2437. ppdu_user_desc->long_retries + ppdu_user_desc->short_retries;
  2438. ppdu_user_desc->is_ampdu =
  2439. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_AMPDU_GET(*tag_buf);
  2440. ppdu_info->is_ampdu = ppdu_user_desc->is_ampdu;
  2441. ppdu_desc->resp_type =
  2442. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RESP_TYPE_GET(*tag_buf);
  2443. ppdu_desc->mprot_type =
  2444. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MPROT_TYPE_GET(*tag_buf);
  2445. ppdu_desc->rts_success =
  2446. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_SUCCESS_GET(*tag_buf);
  2447. ppdu_desc->rts_failure =
  2448. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_RTS_FAILURE_GET(*tag_buf);
  2449. ppdu_info->compltn_common_tlv++;
  2450. /*
  2451. * MU BAR may send request to n users but we may received ack only from
  2452. * m users. To have count of number of users respond back, we have a
  2453. * separate counter bar_num_users per PPDU that get increment for every
  2454. * htt_ppdu_stats_user_cmpltn_common_tlv
  2455. */
  2456. ppdu_desc->bar_num_users++;
  2457. tag_buf++;
  2458. for (bw_iter = 0; bw_iter < CDP_RSSI_CHAIN_LEN; bw_iter++) {
  2459. ppdu_user_desc->rssi_chain[bw_iter] =
  2460. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CHAIN_RSSI_GET(*tag_buf);
  2461. tag_buf++;
  2462. }
  2463. ppdu_user_desc->sa_tx_antenna =
  2464. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_TX_ANTENNA_MASK_GET(*tag_buf);
  2465. tag_buf++;
  2466. ppdu_user_desc->sa_is_training =
  2467. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_IS_TRAINING_GET(*tag_buf);
  2468. if (ppdu_user_desc->sa_is_training) {
  2469. ppdu_user_desc->sa_goodput =
  2470. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_PENDING_TRAINING_PKTS_GET(*tag_buf);
  2471. }
  2472. tag_buf++;
  2473. for (bw_iter = 0; bw_iter < CDP_NUM_SA_BW; bw_iter++) {
  2474. ppdu_user_desc->sa_max_rates[bw_iter] =
  2475. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_MAX_RATES_GET(tag_buf[bw_iter]);
  2476. }
  2477. tag_buf += CDP_NUM_SA_BW;
  2478. ppdu_user_desc->current_rate_per =
  2479. HTT_PPDU_STATS_USER_CMPLTN_COMMON_TLV_CURRENT_RATE_PER_GET(*tag_buf);
  2480. }
  2481. /*
  2482. * dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv: Process
  2483. * htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2484. * pdev: DP PDEV handle
  2485. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv
  2486. * @ppdu_info: per ppdu tlv structure
  2487. *
  2488. * return:void
  2489. */
  2490. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  2491. struct dp_pdev *pdev, uint32_t *tag_buf,
  2492. struct ppdu_info *ppdu_info)
  2493. {
  2494. htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *dp_stats_buf =
  2495. (htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv *)tag_buf;
  2496. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2497. struct cdp_tx_completion_ppdu *ppdu_desc;
  2498. uint8_t curr_user_index = 0;
  2499. uint16_t peer_id;
  2500. struct dp_peer *peer;
  2501. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2502. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2503. tag_buf++;
  2504. peer_id =
  2505. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2506. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2507. DP_MOD_ID_TX_PPDU_STATS);
  2508. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2509. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2510. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2511. if (peer) {
  2512. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2513. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2514. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2515. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2516. }
  2517. ppdu_user_desc->peer_id = peer_id;
  2518. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2519. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2520. sizeof(uint32_t) * CDP_BA_64_BIT_MAP_SIZE_DWORDS);
  2521. ppdu_user_desc->ba_size = CDP_BA_64_BIT_MAP_SIZE_DWORDS * 32;
  2522. }
  2523. /*
  2524. * dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv: Process
  2525. * htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2526. * pdev: DP PDEV handle
  2527. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv
  2528. * @ppdu_info: per ppdu tlv structure
  2529. *
  2530. * return:void
  2531. */
  2532. static void dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  2533. struct dp_pdev *pdev, uint32_t *tag_buf,
  2534. struct ppdu_info *ppdu_info)
  2535. {
  2536. htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *dp_stats_buf =
  2537. (htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv *)tag_buf;
  2538. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2539. struct cdp_tx_completion_ppdu *ppdu_desc;
  2540. uint8_t curr_user_index = 0;
  2541. uint16_t peer_id;
  2542. struct dp_peer *peer;
  2543. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2544. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2545. tag_buf++;
  2546. peer_id =
  2547. HTT_PPDU_STATS_USER_CMPLTN_BA_BITMAP_TLV_SW_PEER_ID_GET(*tag_buf);
  2548. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2549. DP_MOD_ID_TX_PPDU_STATS);
  2550. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2551. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2552. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2553. if (peer) {
  2554. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2555. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2556. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2557. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2558. }
  2559. ppdu_user_desc->peer_id = peer_id;
  2560. ppdu_user_desc->ba_seq_no = dp_stats_buf->ba_seq_no;
  2561. qdf_mem_copy(&ppdu_user_desc->ba_bitmap, &dp_stats_buf->ba_bitmap,
  2562. sizeof(uint32_t) * CDP_BA_256_BIT_MAP_SIZE_DWORDS);
  2563. ppdu_user_desc->ba_size = CDP_BA_256_BIT_MAP_SIZE_DWORDS * 32;
  2564. }
  2565. /*
  2566. * dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv: Process
  2567. * htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2568. * pdev: DP PDE handle
  2569. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2570. * @ppdu_info: per ppdu tlv structure
  2571. *
  2572. * return:void
  2573. */
  2574. static void dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  2575. struct dp_pdev *pdev, uint32_t *tag_buf,
  2576. struct ppdu_info *ppdu_info)
  2577. {
  2578. uint16_t peer_id;
  2579. struct dp_peer *peer;
  2580. struct cdp_tx_completion_ppdu *ppdu_desc;
  2581. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2582. uint8_t curr_user_index = 0;
  2583. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2584. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2585. tag_buf += 2;
  2586. peer_id =
  2587. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_SW_PEER_ID_GET(*tag_buf);
  2588. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2589. DP_MOD_ID_TX_PPDU_STATS);
  2590. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2591. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2592. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2593. if (peer) {
  2594. ppdu_desc->vdev_id = peer->vdev->vdev_id;
  2595. qdf_mem_copy(ppdu_user_desc->mac_addr,
  2596. peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
  2597. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2598. }
  2599. if (!ppdu_user_desc->ack_ba_tlv) {
  2600. ppdu_user_desc->ack_ba_tlv = 1;
  2601. } else {
  2602. pdev->stats.ack_ba_comes_twice++;
  2603. return;
  2604. }
  2605. ppdu_user_desc->peer_id = peer_id;
  2606. tag_buf++;
  2607. /* not to update ppdu_desc->tid from this TLV */
  2608. ppdu_user_desc->num_mpdu =
  2609. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MPDU_GET(*tag_buf);
  2610. ppdu_user_desc->num_msdu =
  2611. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_NUM_MSDU_GET(*tag_buf);
  2612. ppdu_user_desc->success_msdus = ppdu_user_desc->num_msdu;
  2613. tag_buf++;
  2614. ppdu_user_desc->start_seq =
  2615. HTT_PPDU_STATS_USER_CMPLTN_ACK_BA_STATUS_TLV_START_SEQ_GET(
  2616. *tag_buf);
  2617. tag_buf++;
  2618. ppdu_user_desc->success_bytes = *tag_buf;
  2619. /* increase ack ba tlv counter on successful mpdu */
  2620. if (ppdu_user_desc->num_mpdu)
  2621. ppdu_info->ack_ba_tlv++;
  2622. if (ppdu_user_desc->ba_size == 0) {
  2623. ppdu_user_desc->ba_seq_no = ppdu_user_desc->start_seq;
  2624. ppdu_user_desc->ba_bitmap[0] = 1;
  2625. ppdu_user_desc->ba_size = 1;
  2626. }
  2627. }
  2628. /*
  2629. * dp_process_ppdu_stats_user_common_array_tlv: Process
  2630. * htt_ppdu_stats_user_common_array_tlv
  2631. * pdev: DP PDEV handle
  2632. * @tag_buf: buffer containing the htt_ppdu_stats_user_compltn_ack_ba_status_tlv
  2633. * @ppdu_info: per ppdu tlv structure
  2634. *
  2635. * return:void
  2636. */
  2637. static void dp_process_ppdu_stats_user_common_array_tlv(
  2638. struct dp_pdev *pdev, uint32_t *tag_buf,
  2639. struct ppdu_info *ppdu_info)
  2640. {
  2641. uint32_t peer_id;
  2642. struct cdp_tx_completion_ppdu *ppdu_desc;
  2643. struct cdp_tx_completion_ppdu_user *ppdu_user_desc;
  2644. uint8_t curr_user_index = 0;
  2645. struct htt_tx_ppdu_stats_info *dp_stats_buf;
  2646. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2647. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  2648. tag_buf++;
  2649. dp_stats_buf = (struct htt_tx_ppdu_stats_info *)tag_buf;
  2650. tag_buf += 3;
  2651. peer_id =
  2652. HTT_PPDU_STATS_ARRAY_ITEM_TLV_PEERID_GET(*tag_buf);
  2653. if (!dp_peer_find_by_id_valid(pdev->soc, peer_id)) {
  2654. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2655. "Invalid peer");
  2656. return;
  2657. }
  2658. curr_user_index = dp_get_ppdu_info_user_index(pdev, peer_id, ppdu_info);
  2659. ppdu_user_desc = &ppdu_desc->user[curr_user_index];
  2660. ppdu_user_desc->tlv_bitmap |= (1 << tlv_type);
  2661. ppdu_user_desc->retry_bytes = dp_stats_buf->tx_retry_bytes;
  2662. ppdu_user_desc->failed_bytes = dp_stats_buf->tx_failed_bytes;
  2663. tag_buf++;
  2664. ppdu_user_desc->success_msdus =
  2665. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_SUCC_MSDUS_GET(*tag_buf);
  2666. ppdu_user_desc->retry_bytes =
  2667. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_RETRY_MSDUS_GET(*tag_buf);
  2668. tag_buf++;
  2669. ppdu_user_desc->failed_msdus =
  2670. HTT_PPDU_STATS_ARRAY_ITEM_TLV_TX_FAILED_MSDUS_GET(*tag_buf);
  2671. }
  2672. /*
  2673. * dp_process_ppdu_stats_flush_tlv: Process
  2674. * htt_ppdu_stats_flush_tlv
  2675. * @pdev: DP PDEV handle
  2676. * @tag_buf: buffer containing the htt_ppdu_stats_flush_tlv
  2677. * @ppdu_info: per ppdu tlv structure
  2678. *
  2679. * return:void
  2680. */
  2681. static void
  2682. dp_process_ppdu_stats_user_compltn_flush_tlv(struct dp_pdev *pdev,
  2683. uint32_t *tag_buf,
  2684. struct ppdu_info *ppdu_info)
  2685. {
  2686. struct cdp_tx_completion_ppdu *ppdu_desc;
  2687. uint32_t peer_id;
  2688. uint8_t tid;
  2689. struct dp_peer *peer;
  2690. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2691. qdf_nbuf_data(ppdu_info->nbuf);
  2692. ppdu_desc->is_flush = 1;
  2693. tag_buf++;
  2694. ppdu_desc->drop_reason = *tag_buf;
  2695. tag_buf++;
  2696. ppdu_desc->num_msdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MSDU_GET(*tag_buf);
  2697. ppdu_desc->num_mpdu = HTT_PPDU_STATS_FLUSH_TLV_NUM_MPDU_GET(*tag_buf);
  2698. ppdu_desc->flow_type = HTT_PPDU_STATS_FLUSH_TLV_FLOW_TYPE_GET(*tag_buf);
  2699. tag_buf++;
  2700. peer_id = HTT_PPDU_STATS_FLUSH_TLV_SW_PEER_ID_GET(*tag_buf);
  2701. tid = HTT_PPDU_STATS_FLUSH_TLV_TID_NUM_GET(*tag_buf);
  2702. ppdu_desc->num_users = 1;
  2703. ppdu_desc->user[0].peer_id = peer_id;
  2704. ppdu_desc->user[0].tid = tid;
  2705. ppdu_desc->queue_type =
  2706. HTT_PPDU_STATS_FLUSH_TLV_QUEUE_TYPE_GET(*tag_buf);
  2707. peer = dp_peer_get_ref_by_id(pdev->soc, peer_id,
  2708. DP_MOD_ID_TX_PPDU_STATS);
  2709. if (!peer)
  2710. goto add_ppdu_to_sched_list;
  2711. if (ppdu_desc->drop_reason == HTT_FLUSH_EXCESS_RETRIES) {
  2712. DP_STATS_INC(peer,
  2713. tx.excess_retries_per_ac[TID_TO_WME_AC(tid)],
  2714. ppdu_desc->num_msdu);
  2715. }
  2716. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2717. add_ppdu_to_sched_list:
  2718. ppdu_info->done = 1;
  2719. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2720. pdev->list_depth--;
  2721. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2722. ppdu_info_list_elem);
  2723. pdev->sched_comp_list_depth++;
  2724. }
  2725. /**
  2726. * dp_process_ppdu_stats_sch_cmd_status_tlv: Process schedule command status tlv
  2727. * Here we are not going to process the buffer.
  2728. * @pdev: DP PDEV handle
  2729. * @ppdu_info: per ppdu tlv structure
  2730. *
  2731. * return:void
  2732. */
  2733. static void
  2734. dp_process_ppdu_stats_sch_cmd_status_tlv(struct dp_pdev *pdev,
  2735. struct ppdu_info *ppdu_info)
  2736. {
  2737. struct cdp_tx_completion_ppdu *ppdu_desc;
  2738. struct dp_peer *peer;
  2739. uint8_t num_users;
  2740. uint8_t i;
  2741. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2742. qdf_nbuf_data(ppdu_info->nbuf);
  2743. num_users = ppdu_desc->bar_num_users;
  2744. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2745. for (i = 0; i < num_users; i++) {
  2746. if (ppdu_desc->user[i].user_pos == 0) {
  2747. /* update phy mode for bar frame */
  2748. ppdu_desc->phy_mode =
  2749. ppdu_desc->user[i].preamble;
  2750. ppdu_desc->user[0].mcs = ppdu_desc->user[i].mcs;
  2751. break;
  2752. }
  2753. }
  2754. }
  2755. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  2756. ppdu_desc->delayed_ba) {
  2757. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  2758. for (i = 0; i < ppdu_desc->num_users; i++) {
  2759. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2760. uint64_t start_tsf;
  2761. uint64_t end_tsf;
  2762. uint32_t ppdu_id;
  2763. ppdu_id = ppdu_desc->ppdu_id;
  2764. peer = dp_peer_get_ref_by_id
  2765. (pdev->soc, ppdu_desc->user[i].peer_id,
  2766. DP_MOD_ID_TX_PPDU_STATS);
  2767. /**
  2768. * This check is to make sure peer is not deleted
  2769. * after processing the TLVs.
  2770. */
  2771. if (!peer)
  2772. continue;
  2773. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2774. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2775. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2776. /**
  2777. * save delayed ba user info
  2778. */
  2779. if (ppdu_desc->user[i].delayed_ba) {
  2780. dp_peer_copy_delay_stats(peer,
  2781. &ppdu_desc->user[i],
  2782. ppdu_id);
  2783. peer->last_delayed_ba_ppduid = ppdu_id;
  2784. delay_ppdu->ppdu_start_timestamp = start_tsf;
  2785. delay_ppdu->ppdu_end_timestamp = end_tsf;
  2786. }
  2787. ppdu_desc->user[i].peer_last_delayed_ba =
  2788. peer->last_delayed_ba;
  2789. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2790. if (ppdu_desc->user[i].delayed_ba &&
  2791. !ppdu_desc->user[i].debug_copied) {
  2792. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2793. QDF_TRACE_LEVEL_INFO_MED,
  2794. "%s: %d ppdu_id[%d] bar_ppdu_id[%d] num_users[%d] usr[%d] htt_frame_type[%d]\n",
  2795. __func__, __LINE__,
  2796. ppdu_desc->ppdu_id,
  2797. ppdu_desc->bar_ppdu_id,
  2798. ppdu_desc->num_users,
  2799. i,
  2800. ppdu_desc->htt_frame_type);
  2801. }
  2802. }
  2803. }
  2804. /*
  2805. * when frame type is BAR and STATS_COMMON_TLV is set
  2806. * copy the store peer delayed info to BAR status
  2807. */
  2808. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  2809. for (i = 0; i < ppdu_desc->bar_num_users; i++) {
  2810. struct cdp_delayed_tx_completion_ppdu_user *delay_ppdu;
  2811. uint64_t start_tsf;
  2812. uint64_t end_tsf;
  2813. peer = dp_peer_get_ref_by_id
  2814. (pdev->soc,
  2815. ppdu_desc->user[i].peer_id,
  2816. DP_MOD_ID_TX_PPDU_STATS);
  2817. /**
  2818. * This check is to make sure peer is not deleted
  2819. * after processing the TLVs.
  2820. */
  2821. if (!peer)
  2822. continue;
  2823. if (ppdu_desc->user[i].completion_status !=
  2824. HTT_PPDU_STATS_USER_STATUS_OK) {
  2825. dp_peer_unref_delete(peer,
  2826. DP_MOD_ID_TX_PPDU_STATS);
  2827. continue;
  2828. }
  2829. delay_ppdu = &peer->delayed_ba_ppdu_stats;
  2830. start_tsf = delay_ppdu->ppdu_start_timestamp;
  2831. end_tsf = delay_ppdu->ppdu_end_timestamp;
  2832. if (peer->last_delayed_ba) {
  2833. dp_peer_copy_stats_to_bar(peer,
  2834. &ppdu_desc->user[i]);
  2835. ppdu_desc->ppdu_id =
  2836. peer->last_delayed_ba_ppduid;
  2837. ppdu_desc->ppdu_start_timestamp = start_tsf;
  2838. ppdu_desc->ppdu_end_timestamp = end_tsf;
  2839. }
  2840. ppdu_desc->user[i].peer_last_delayed_ba =
  2841. peer->last_delayed_ba;
  2842. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  2843. }
  2844. }
  2845. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2846. pdev->list_depth--;
  2847. TAILQ_INSERT_TAIL(&pdev->sched_comp_ppdu_list, ppdu_info,
  2848. ppdu_info_list_elem);
  2849. pdev->sched_comp_list_depth++;
  2850. }
  2851. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  2852. /*
  2853. * dp_deliver_mgmt_frm: Process
  2854. * @pdev: DP PDEV handle
  2855. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2856. *
  2857. * return: void
  2858. */
  2859. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  2860. {
  2861. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  2862. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  2863. nbuf, HTT_INVALID_PEER,
  2864. WDI_NO_VAL, pdev->pdev_id);
  2865. } else {
  2866. if (!pdev->bpr_enable)
  2867. qdf_nbuf_free(nbuf);
  2868. }
  2869. }
  2870. #endif
  2871. /*
  2872. * dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv: Process
  2873. * htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2874. * @pdev: DP PDEV handle
  2875. * @tag_buf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  2876. * @length: tlv_length
  2877. *
  2878. * return:QDF_STATUS_SUCCESS if nbuf as to be freed in caller
  2879. */
  2880. static QDF_STATUS
  2881. dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv(struct dp_pdev *pdev,
  2882. qdf_nbuf_t tag_buf,
  2883. uint32_t ppdu_id)
  2884. {
  2885. uint32_t *nbuf_ptr;
  2886. uint8_t trim_size;
  2887. size_t head_size;
  2888. struct cdp_tx_mgmt_comp_info *ptr_mgmt_comp_info;
  2889. uint32_t *msg_word;
  2890. uint32_t tsf_hdr;
  2891. if ((!pdev->tx_sniffer_enable) && (!pdev->mcopy_mode) &&
  2892. (!pdev->bpr_enable) && (!pdev->tx_capture_enabled))
  2893. return QDF_STATUS_SUCCESS;
  2894. /*
  2895. * get timestamp from htt_t2h_ppdu_stats_ind_hdr_t
  2896. */
  2897. msg_word = (uint32_t *)qdf_nbuf_data(tag_buf);
  2898. msg_word = msg_word + 2;
  2899. tsf_hdr = *msg_word;
  2900. trim_size = ((pdev->mgmtctrl_frm_info.mgmt_buf +
  2901. HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN) -
  2902. qdf_nbuf_data(tag_buf));
  2903. if (!qdf_nbuf_pull_head(tag_buf, trim_size))
  2904. return QDF_STATUS_SUCCESS;
  2905. qdf_nbuf_trim_tail(tag_buf, qdf_nbuf_len(tag_buf) -
  2906. pdev->mgmtctrl_frm_info.mgmt_buf_len);
  2907. if (pdev->tx_capture_enabled) {
  2908. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  2909. if (qdf_unlikely(qdf_nbuf_headroom(tag_buf) < head_size)) {
  2910. qdf_err("Fail to get headroom h_sz %d h_avail %d\n",
  2911. head_size, qdf_nbuf_headroom(tag_buf));
  2912. qdf_assert_always(0);
  2913. return QDF_STATUS_E_NOMEM;
  2914. }
  2915. ptr_mgmt_comp_info = (struct cdp_tx_mgmt_comp_info *)
  2916. qdf_nbuf_push_head(tag_buf, head_size);
  2917. qdf_assert_always(ptr_mgmt_comp_info);
  2918. ptr_mgmt_comp_info->ppdu_id = ppdu_id;
  2919. ptr_mgmt_comp_info->is_sgen_pkt = true;
  2920. ptr_mgmt_comp_info->tx_tsf = tsf_hdr;
  2921. } else {
  2922. head_size = sizeof(ppdu_id);
  2923. nbuf_ptr = (uint32_t *)qdf_nbuf_push_head(tag_buf, head_size);
  2924. *nbuf_ptr = ppdu_id;
  2925. }
  2926. if (pdev->bpr_enable) {
  2927. dp_wdi_event_handler(WDI_EVENT_TX_BEACON, pdev->soc,
  2928. tag_buf, HTT_INVALID_PEER,
  2929. WDI_NO_VAL, pdev->pdev_id);
  2930. }
  2931. dp_deliver_mgmt_frm(pdev, tag_buf);
  2932. return QDF_STATUS_E_ALREADY;
  2933. }
  2934. /**
  2935. * dp_validate_fix_ppdu_tlv(): Function to validate the length of PPDU
  2936. *
  2937. * If the TLV length sent as part of PPDU TLV is less that expected size i.e
  2938. * size of corresponding data structure, pad the remaining bytes with zeros
  2939. * and continue processing the TLVs
  2940. *
  2941. * @pdev: DP pdev handle
  2942. * @tag_buf: TLV buffer
  2943. * @tlv_expected_size: Expected size of Tag
  2944. * @tlv_len: TLV length received from FW
  2945. *
  2946. * Return: Pointer to updated TLV
  2947. */
  2948. static inline uint32_t *dp_validate_fix_ppdu_tlv(struct dp_pdev *pdev,
  2949. uint32_t *tag_buf,
  2950. uint16_t tlv_expected_size,
  2951. uint16_t tlv_len)
  2952. {
  2953. uint32_t *tlv_desc = tag_buf;
  2954. qdf_assert_always(tlv_len != 0);
  2955. if (tlv_len < tlv_expected_size) {
  2956. qdf_mem_zero(pdev->ppdu_tlv_buf, tlv_expected_size);
  2957. qdf_mem_copy(pdev->ppdu_tlv_buf, tag_buf, tlv_len);
  2958. tlv_desc = pdev->ppdu_tlv_buf;
  2959. }
  2960. return tlv_desc;
  2961. }
  2962. /**
  2963. * dp_process_ppdu_tag(): Function to process the PPDU TLVs
  2964. * @pdev: DP pdev handle
  2965. * @tag_buf: TLV buffer
  2966. * @tlv_len: length of tlv
  2967. * @ppdu_info: per ppdu tlv structure
  2968. *
  2969. * return: void
  2970. */
  2971. static void dp_process_ppdu_tag(struct dp_pdev *pdev, uint32_t *tag_buf,
  2972. uint32_t tlv_len, struct ppdu_info *ppdu_info)
  2973. {
  2974. uint32_t tlv_type = HTT_STATS_TLV_TAG_GET(*tag_buf);
  2975. uint16_t tlv_expected_size;
  2976. uint32_t *tlv_desc;
  2977. switch (tlv_type) {
  2978. case HTT_PPDU_STATS_COMMON_TLV:
  2979. tlv_expected_size = sizeof(htt_ppdu_stats_common_tlv);
  2980. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2981. tlv_expected_size, tlv_len);
  2982. dp_process_ppdu_stats_common_tlv(pdev, tlv_desc, ppdu_info);
  2983. break;
  2984. case HTT_PPDU_STATS_USR_COMMON_TLV:
  2985. tlv_expected_size = sizeof(htt_ppdu_stats_user_common_tlv);
  2986. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2987. tlv_expected_size, tlv_len);
  2988. dp_process_ppdu_stats_user_common_tlv(pdev, tlv_desc,
  2989. ppdu_info);
  2990. break;
  2991. case HTT_PPDU_STATS_USR_RATE_TLV:
  2992. tlv_expected_size = sizeof(htt_ppdu_stats_user_rate_tlv);
  2993. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  2994. tlv_expected_size, tlv_len);
  2995. dp_process_ppdu_stats_user_rate_tlv(pdev, tlv_desc,
  2996. ppdu_info);
  2997. break;
  2998. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_64_TLV:
  2999. tlv_expected_size =
  3000. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_64_tlv);
  3001. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3002. tlv_expected_size, tlv_len);
  3003. dp_process_ppdu_stats_enq_mpdu_bitmap_64_tlv(
  3004. pdev, tlv_desc, ppdu_info);
  3005. break;
  3006. case HTT_PPDU_STATS_USR_MPDU_ENQ_BITMAP_256_TLV:
  3007. tlv_expected_size =
  3008. sizeof(htt_ppdu_stats_enq_mpdu_bitmap_256_tlv);
  3009. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3010. tlv_expected_size, tlv_len);
  3011. dp_process_ppdu_stats_enq_mpdu_bitmap_256_tlv(
  3012. pdev, tlv_desc, ppdu_info);
  3013. break;
  3014. case HTT_PPDU_STATS_USR_COMPLTN_COMMON_TLV:
  3015. tlv_expected_size =
  3016. sizeof(htt_ppdu_stats_user_cmpltn_common_tlv);
  3017. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3018. tlv_expected_size, tlv_len);
  3019. dp_process_ppdu_stats_user_cmpltn_common_tlv(
  3020. pdev, tlv_desc, ppdu_info);
  3021. break;
  3022. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_64_TLV:
  3023. tlv_expected_size =
  3024. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_64_tlv);
  3025. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3026. tlv_expected_size, tlv_len);
  3027. dp_process_ppdu_stats_user_compltn_ba_bitmap_64_tlv(
  3028. pdev, tlv_desc, ppdu_info);
  3029. break;
  3030. case HTT_PPDU_STATS_USR_COMPLTN_BA_BITMAP_256_TLV:
  3031. tlv_expected_size =
  3032. sizeof(htt_ppdu_stats_user_compltn_ba_bitmap_256_tlv);
  3033. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3034. tlv_expected_size, tlv_len);
  3035. dp_process_ppdu_stats_user_compltn_ba_bitmap_256_tlv(
  3036. pdev, tlv_desc, ppdu_info);
  3037. break;
  3038. case HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV:
  3039. tlv_expected_size =
  3040. sizeof(htt_ppdu_stats_user_compltn_ack_ba_status_tlv);
  3041. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3042. tlv_expected_size, tlv_len);
  3043. dp_process_ppdu_stats_user_compltn_ack_ba_status_tlv(
  3044. pdev, tlv_desc, ppdu_info);
  3045. break;
  3046. case HTT_PPDU_STATS_USR_COMMON_ARRAY_TLV:
  3047. tlv_expected_size =
  3048. sizeof(htt_ppdu_stats_usr_common_array_tlv_v);
  3049. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3050. tlv_expected_size, tlv_len);
  3051. dp_process_ppdu_stats_user_common_array_tlv(
  3052. pdev, tlv_desc, ppdu_info);
  3053. break;
  3054. case HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV:
  3055. tlv_expected_size = sizeof(htt_ppdu_stats_flush_tlv);
  3056. tlv_desc = dp_validate_fix_ppdu_tlv(pdev, tag_buf,
  3057. tlv_expected_size, tlv_len);
  3058. dp_process_ppdu_stats_user_compltn_flush_tlv(pdev, tlv_desc,
  3059. ppdu_info);
  3060. break;
  3061. case HTT_PPDU_STATS_SCH_CMD_STATUS_TLV:
  3062. dp_process_ppdu_stats_sch_cmd_status_tlv(pdev, ppdu_info);
  3063. break;
  3064. default:
  3065. break;
  3066. }
  3067. }
  3068. #ifdef WLAN_ATF_ENABLE
  3069. static void
  3070. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3071. struct cdp_tx_completion_ppdu *ppdu_desc,
  3072. struct cdp_tx_completion_ppdu_user *user)
  3073. {
  3074. uint32_t nss_ru_width_sum = 0;
  3075. if (!pdev || !ppdu_desc || !user)
  3076. return;
  3077. if (!pdev->dp_atf_stats_enable)
  3078. return;
  3079. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_DATA)
  3080. return;
  3081. nss_ru_width_sum = ppdu_desc->usr_nss_sum * ppdu_desc->usr_ru_tones_sum;
  3082. if (!nss_ru_width_sum)
  3083. nss_ru_width_sum = 1;
  3084. /**
  3085. * For SU-MIMO PPDU phy Tx time is same for the single user.
  3086. * For MU-MIMO phy Tx time is calculated per user as below
  3087. * user phy tx time =
  3088. * Entire PPDU duration * MU Ratio * OFDMA Ratio
  3089. * MU Ratio = usr_nss / Sum_of_nss_of_all_users
  3090. * OFDMA_ratio = usr_ru_width / Sum_of_ru_width_of_all_users
  3091. * usr_ru_widt = ru_end – ru_start + 1
  3092. */
  3093. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_TIDQ_DATA_SU) {
  3094. user->phy_tx_time_us = ppdu_desc->phy_ppdu_tx_time_us;
  3095. } else {
  3096. user->phy_tx_time_us = (ppdu_desc->phy_ppdu_tx_time_us *
  3097. user->nss * user->ru_tones) / nss_ru_width_sum;
  3098. }
  3099. }
  3100. #else
  3101. static void
  3102. dp_ppdu_desc_user_phy_tx_time_update(struct dp_pdev *pdev,
  3103. struct cdp_tx_completion_ppdu *ppdu_desc,
  3104. struct cdp_tx_completion_ppdu_user *user)
  3105. {
  3106. }
  3107. #endif
  3108. /**
  3109. * dp_ppdu_desc_user_stats_update(): Function to update TX user stats
  3110. * @pdev: DP pdev handle
  3111. * @ppdu_info: per PPDU TLV descriptor
  3112. *
  3113. * return: void
  3114. */
  3115. void
  3116. dp_ppdu_desc_user_stats_update(struct dp_pdev *pdev,
  3117. struct ppdu_info *ppdu_info)
  3118. {
  3119. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3120. struct dp_peer *peer = NULL;
  3121. uint32_t tlv_bitmap_expected;
  3122. uint32_t tlv_bitmap_default;
  3123. uint16_t i;
  3124. uint32_t num_users;
  3125. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3126. qdf_nbuf_data(ppdu_info->nbuf);
  3127. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_BAR)
  3128. ppdu_desc->ppdu_id = ppdu_info->ppdu_id;
  3129. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3130. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3131. pdev->tx_capture_enabled) {
  3132. if (ppdu_info->is_ampdu)
  3133. tlv_bitmap_expected =
  3134. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3135. ppdu_info->tlv_bitmap);
  3136. }
  3137. tlv_bitmap_default = tlv_bitmap_expected;
  3138. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) {
  3139. num_users = ppdu_desc->bar_num_users;
  3140. ppdu_desc->num_users = ppdu_desc->bar_num_users;
  3141. } else {
  3142. num_users = ppdu_desc->num_users;
  3143. }
  3144. qdf_assert_always(ppdu_desc->num_users <= ppdu_desc->max_users);
  3145. for (i = 0; i < num_users; i++) {
  3146. ppdu_desc->num_mpdu += ppdu_desc->user[i].num_mpdu;
  3147. ppdu_desc->num_msdu += ppdu_desc->user[i].num_msdu;
  3148. peer = dp_peer_find_hash_find(pdev->soc,
  3149. ppdu_desc->user[i].mac_addr,
  3150. 0, ppdu_desc->vdev_id,
  3151. DP_MOD_ID_TX_PPDU_STATS);
  3152. /**
  3153. * This check is to make sure peer is not deleted
  3154. * after processing the TLVs.
  3155. */
  3156. if (!peer)
  3157. continue;
  3158. /*
  3159. * different frame like DATA, BAR or CTRL has different
  3160. * tlv bitmap expected. Apart from ACK_BA_STATUS TLV, we
  3161. * receive other tlv in-order/sequential from fw.
  3162. * Since ACK_BA_STATUS TLV come from Hardware it is
  3163. * asynchronous So we need to depend on some tlv to confirm
  3164. * all tlv is received for a ppdu.
  3165. * So we depend on both SCHED_CMD_STATUS_TLV and
  3166. * ACK_BA_STATUS_TLV. for failure packet we won't get
  3167. * ACK_BA_STATUS_TLV.
  3168. */
  3169. if (!(ppdu_info->tlv_bitmap &
  3170. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)) ||
  3171. (!(ppdu_info->tlv_bitmap &
  3172. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV)) &&
  3173. (ppdu_desc->user[i].completion_status ==
  3174. HTT_PPDU_STATS_USER_STATUS_OK))) {
  3175. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3176. continue;
  3177. }
  3178. /**
  3179. * Update tx stats for data frames having Qos as well as
  3180. * non-Qos data tid
  3181. */
  3182. if ((ppdu_desc->user[i].tid < CDP_DATA_TID_MAX ||
  3183. (ppdu_desc->user[i].tid == CDP_DATA_NON_QOS_TID) ||
  3184. (ppdu_desc->htt_frame_type ==
  3185. HTT_STATS_FTYPE_SGEN_QOS_NULL) ||
  3186. ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR) &&
  3187. (ppdu_desc->num_mpdu > 1))) &&
  3188. (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL)) {
  3189. dp_tx_stats_update(pdev, peer,
  3190. &ppdu_desc->user[i],
  3191. ppdu_desc->ack_rssi);
  3192. dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
  3193. }
  3194. dp_ppdu_desc_user_phy_tx_time_update(pdev, ppdu_desc,
  3195. &ppdu_desc->user[i]);
  3196. dp_peer_unref_delete(peer, DP_MOD_ID_TX_PPDU_STATS);
  3197. tlv_bitmap_expected = tlv_bitmap_default;
  3198. }
  3199. }
  3200. #ifndef WLAN_TX_PKT_CAPTURE_ENH
  3201. /**
  3202. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  3203. * to upper layer
  3204. * @pdev: DP pdev handle
  3205. * @ppdu_info: per PPDU TLV descriptor
  3206. *
  3207. * return: void
  3208. */
  3209. static
  3210. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  3211. struct ppdu_info *ppdu_info)
  3212. {
  3213. struct ppdu_info *s_ppdu_info = NULL;
  3214. struct ppdu_info *ppdu_info_next = NULL;
  3215. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3216. qdf_nbuf_t nbuf;
  3217. uint32_t time_delta = 0;
  3218. bool starved = 0;
  3219. bool matched = 0;
  3220. bool recv_ack_ba_done = 0;
  3221. if (ppdu_info->tlv_bitmap &
  3222. (1 << HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3223. ppdu_info->done)
  3224. recv_ack_ba_done = 1;
  3225. pdev->last_sched_cmdid = ppdu_info->sched_cmdid;
  3226. s_ppdu_info = TAILQ_FIRST(&pdev->sched_comp_ppdu_list);
  3227. TAILQ_FOREACH_SAFE(s_ppdu_info, &pdev->sched_comp_ppdu_list,
  3228. ppdu_info_list_elem, ppdu_info_next) {
  3229. if (s_ppdu_info->tsf_l32 > ppdu_info->tsf_l32)
  3230. time_delta = (MAX_TSF_32 - s_ppdu_info->tsf_l32) +
  3231. ppdu_info->tsf_l32;
  3232. else
  3233. time_delta = ppdu_info->tsf_l32 - s_ppdu_info->tsf_l32;
  3234. if (!s_ppdu_info->done && !recv_ack_ba_done) {
  3235. if (time_delta < MAX_SCHED_STARVE) {
  3236. qdf_err("pdev[%d] ppdu_id[%d] sched_cmdid[%d] TLV_B[0x%x] TSF[%u] D[%d]",
  3237. pdev->pdev_id,
  3238. s_ppdu_info->ppdu_id,
  3239. s_ppdu_info->sched_cmdid,
  3240. s_ppdu_info->tlv_bitmap,
  3241. s_ppdu_info->tsf_l32,
  3242. s_ppdu_info->done);
  3243. break;
  3244. }
  3245. starved = 1;
  3246. }
  3247. pdev->delivered_sched_cmdid = s_ppdu_info->sched_cmdid;
  3248. TAILQ_REMOVE(&pdev->sched_comp_ppdu_list, s_ppdu_info,
  3249. ppdu_info_list_elem);
  3250. pdev->sched_comp_list_depth--;
  3251. nbuf = s_ppdu_info->nbuf;
  3252. qdf_assert_always(nbuf);
  3253. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3254. qdf_nbuf_data(nbuf);
  3255. ppdu_desc->tlv_bitmap = s_ppdu_info->tlv_bitmap;
  3256. if (starved) {
  3257. qdf_err("ppdu starved fc[0x%x] h_ftype[%d] tlv_bitmap[0x%x] cs[%d]\n",
  3258. ppdu_desc->frame_ctrl,
  3259. ppdu_desc->htt_frame_type,
  3260. ppdu_desc->tlv_bitmap,
  3261. ppdu_desc->user[0].completion_status);
  3262. starved = 0;
  3263. }
  3264. if (ppdu_info->ppdu_id == s_ppdu_info->ppdu_id &&
  3265. ppdu_info->sched_cmdid == s_ppdu_info->sched_cmdid)
  3266. matched = 1;
  3267. dp_ppdu_desc_user_stats_update(pdev, s_ppdu_info);
  3268. qdf_mem_free(s_ppdu_info);
  3269. /**
  3270. * Deliver PPDU stats only for valid (acked) data
  3271. * frames if sniffer mode is not enabled.
  3272. * If sniffer mode is enabled, PPDU stats
  3273. * for all frames including mgmt/control
  3274. * frames should be delivered to upper layer
  3275. */
  3276. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  3277. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3278. pdev->soc,
  3279. nbuf, HTT_INVALID_PEER,
  3280. WDI_NO_VAL,
  3281. pdev->pdev_id);
  3282. } else {
  3283. if (ppdu_desc->num_mpdu != 0 &&
  3284. ppdu_desc->num_users != 0 &&
  3285. ppdu_desc->frame_ctrl &
  3286. HTT_FRAMECTRL_DATATYPE) {
  3287. dp_wdi_event_handler(WDI_EVENT_TX_PPDU_DESC,
  3288. pdev->soc,
  3289. nbuf, HTT_INVALID_PEER,
  3290. WDI_NO_VAL,
  3291. pdev->pdev_id);
  3292. } else {
  3293. qdf_nbuf_free(nbuf);
  3294. }
  3295. }
  3296. if (matched)
  3297. break;
  3298. }
  3299. return;
  3300. }
  3301. #endif
  3302. /**
  3303. * dp_get_ppdu_desc(): Function to allocate new PPDU status
  3304. * desc for new ppdu id
  3305. * @pdev: DP pdev handle
  3306. * @ppdu_id: PPDU unique identifier
  3307. * @tlv_type: TLV type received
  3308. * @tsf_l32: timestamp received along with ppdu stats indication header
  3309. * @max_users: Maximum user for that particular ppdu
  3310. *
  3311. * return: ppdu_info per ppdu tlv structure
  3312. */
  3313. static
  3314. struct ppdu_info *dp_get_ppdu_desc(struct dp_pdev *pdev, uint32_t ppdu_id,
  3315. uint8_t tlv_type, uint32_t tsf_l32,
  3316. uint8_t max_users)
  3317. {
  3318. struct ppdu_info *ppdu_info = NULL;
  3319. struct ppdu_info *s_ppdu_info = NULL;
  3320. struct ppdu_info *ppdu_info_next = NULL;
  3321. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3322. uint32_t size = 0;
  3323. struct cdp_tx_completion_ppdu *tmp_ppdu_desc = NULL;
  3324. struct cdp_tx_completion_ppdu_user *tmp_user;
  3325. uint32_t time_delta;
  3326. /*
  3327. * Find ppdu_id node exists or not
  3328. */
  3329. TAILQ_FOREACH_SAFE(ppdu_info, &pdev->ppdu_info_list,
  3330. ppdu_info_list_elem, ppdu_info_next) {
  3331. if (ppdu_info && (ppdu_info->ppdu_id == ppdu_id)) {
  3332. if (ppdu_info->tsf_l32 > tsf_l32)
  3333. time_delta = (MAX_TSF_32 -
  3334. ppdu_info->tsf_l32) + tsf_l32;
  3335. else
  3336. time_delta = tsf_l32 - ppdu_info->tsf_l32;
  3337. if (time_delta > WRAP_DROP_TSF_DELTA) {
  3338. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3339. ppdu_info, ppdu_info_list_elem);
  3340. pdev->list_depth--;
  3341. pdev->stats.ppdu_wrap_drop++;
  3342. tmp_ppdu_desc =
  3343. (struct cdp_tx_completion_ppdu *)
  3344. qdf_nbuf_data(ppdu_info->nbuf);
  3345. tmp_user = &tmp_ppdu_desc->user[0];
  3346. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  3347. QDF_TRACE_LEVEL_INFO_MED,
  3348. "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",
  3349. ppdu_info->ppdu_id,
  3350. ppdu_info->tsf_l32,
  3351. ppdu_info->tlv_bitmap,
  3352. tmp_user->completion_status,
  3353. ppdu_info->compltn_common_tlv,
  3354. ppdu_info->ack_ba_tlv,
  3355. ppdu_id, tsf_l32, tlv_type);
  3356. qdf_nbuf_free(ppdu_info->nbuf);
  3357. ppdu_info->nbuf = NULL;
  3358. qdf_mem_free(ppdu_info);
  3359. } else {
  3360. break;
  3361. }
  3362. }
  3363. }
  3364. /*
  3365. * check if it is ack ba tlv and if it is not there in ppdu info
  3366. * list then check it in sched completion ppdu list
  3367. */
  3368. if (!ppdu_info &&
  3369. tlv_type == HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) {
  3370. TAILQ_FOREACH(s_ppdu_info,
  3371. &pdev->sched_comp_ppdu_list,
  3372. ppdu_info_list_elem) {
  3373. if (s_ppdu_info && (s_ppdu_info->ppdu_id == ppdu_id)) {
  3374. if (s_ppdu_info->tsf_l32 > tsf_l32)
  3375. time_delta = (MAX_TSF_32 -
  3376. s_ppdu_info->tsf_l32) +
  3377. tsf_l32;
  3378. else
  3379. time_delta = tsf_l32 -
  3380. s_ppdu_info->tsf_l32;
  3381. if (time_delta < WRAP_DROP_TSF_DELTA) {
  3382. ppdu_info = s_ppdu_info;
  3383. break;
  3384. }
  3385. } else {
  3386. /*
  3387. * ACK BA STATUS TLV comes sequential order
  3388. * if we received ack ba status tlv for second
  3389. * ppdu and first ppdu is still waiting for
  3390. * ACK BA STATUS TLV. Based on fw comment
  3391. * we won't receive it tlv later. So we can
  3392. * set ppdu info done.
  3393. */
  3394. if (s_ppdu_info)
  3395. s_ppdu_info->done = 1;
  3396. }
  3397. }
  3398. }
  3399. if (ppdu_info) {
  3400. if (ppdu_info->tlv_bitmap & (1 << tlv_type)) {
  3401. /**
  3402. * if we get tlv_type that is already been processed
  3403. * for ppdu, that means we got a new ppdu with same
  3404. * ppdu id. Hence Flush the older ppdu
  3405. * for MUMIMO and OFDMA, In a PPDU we have
  3406. * multiple user with same tlv types. tlv bitmap is
  3407. * used to check whether SU or MU_MIMO/OFDMA
  3408. */
  3409. if (!(ppdu_info->tlv_bitmap &
  3410. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV)))
  3411. return ppdu_info;
  3412. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  3413. qdf_nbuf_data(ppdu_info->nbuf);
  3414. /**
  3415. * apart from ACK BA STATUS TLV rest all comes in order
  3416. * so if tlv type not ACK BA STATUS TLV we can deliver
  3417. * ppdu_info
  3418. */
  3419. if ((tlv_type ==
  3420. HTT_PPDU_STATS_USR_COMPLTN_ACK_BA_STATUS_TLV) &&
  3421. (ppdu_desc->htt_frame_type ==
  3422. HTT_STATS_FTYPE_SGEN_MU_BAR))
  3423. return ppdu_info;
  3424. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3425. } else {
  3426. return ppdu_info;
  3427. }
  3428. }
  3429. /**
  3430. * Flush the head ppdu descriptor if ppdu desc list reaches max
  3431. * threshold
  3432. */
  3433. if (pdev->list_depth > HTT_PPDU_DESC_MAX_DEPTH) {
  3434. ppdu_info = TAILQ_FIRST(&pdev->ppdu_info_list);
  3435. TAILQ_REMOVE(&pdev->ppdu_info_list,
  3436. ppdu_info, ppdu_info_list_elem);
  3437. pdev->list_depth--;
  3438. pdev->stats.ppdu_drop++;
  3439. qdf_nbuf_free(ppdu_info->nbuf);
  3440. ppdu_info->nbuf = NULL;
  3441. qdf_mem_free(ppdu_info);
  3442. }
  3443. size = sizeof(struct cdp_tx_completion_ppdu) +
  3444. (max_users * sizeof(struct cdp_tx_completion_ppdu_user));
  3445. /*
  3446. * Allocate new ppdu_info node
  3447. */
  3448. ppdu_info = qdf_mem_malloc(sizeof(struct ppdu_info));
  3449. if (!ppdu_info)
  3450. return NULL;
  3451. ppdu_info->nbuf = qdf_nbuf_alloc(pdev->soc->osdev, size,
  3452. 0, 4, TRUE);
  3453. if (!ppdu_info->nbuf) {
  3454. qdf_mem_free(ppdu_info);
  3455. return NULL;
  3456. }
  3457. ppdu_info->ppdu_desc =
  3458. (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(ppdu_info->nbuf);
  3459. qdf_mem_zero(qdf_nbuf_data(ppdu_info->nbuf), size);
  3460. if (qdf_nbuf_put_tail(ppdu_info->nbuf, size) == NULL) {
  3461. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3462. "No tailroom for HTT PPDU");
  3463. qdf_nbuf_free(ppdu_info->nbuf);
  3464. ppdu_info->nbuf = NULL;
  3465. ppdu_info->last_user = 0;
  3466. qdf_mem_free(ppdu_info);
  3467. return NULL;
  3468. }
  3469. ppdu_info->ppdu_desc->max_users = max_users;
  3470. ppdu_info->tsf_l32 = tsf_l32;
  3471. /**
  3472. * No lock is needed because all PPDU TLVs are processed in
  3473. * same context and this list is updated in same context
  3474. */
  3475. TAILQ_INSERT_TAIL(&pdev->ppdu_info_list, ppdu_info,
  3476. ppdu_info_list_elem);
  3477. pdev->list_depth++;
  3478. return ppdu_info;
  3479. }
  3480. /**
  3481. * dp_htt_process_tlv(): Function to process each PPDU TLVs
  3482. * @pdev: DP pdev handle
  3483. * @htt_t2h_msg: HTT target to host message
  3484. *
  3485. * return: ppdu_info per ppdu tlv structure
  3486. */
  3487. static struct ppdu_info *dp_htt_process_tlv(struct dp_pdev *pdev,
  3488. qdf_nbuf_t htt_t2h_msg)
  3489. {
  3490. uint32_t length;
  3491. uint32_t ppdu_id;
  3492. uint8_t tlv_type;
  3493. uint32_t tlv_length, tlv_bitmap_expected;
  3494. uint8_t *tlv_buf;
  3495. struct ppdu_info *ppdu_info = NULL;
  3496. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  3497. uint8_t max_users = CDP_MU_MAX_USERS;
  3498. uint32_t tsf_l32;
  3499. uint32_t *msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3500. length = HTT_T2H_PPDU_STATS_PAYLOAD_SIZE_GET(*msg_word);
  3501. msg_word = msg_word + 1;
  3502. ppdu_id = HTT_T2H_PPDU_STATS_PPDU_ID_GET(*msg_word);
  3503. msg_word = msg_word + 1;
  3504. tsf_l32 = (uint32_t)(*msg_word);
  3505. msg_word = msg_word + 2;
  3506. while (length > 0) {
  3507. tlv_buf = (uint8_t *)msg_word;
  3508. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  3509. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  3510. if (qdf_likely(tlv_type < CDP_PPDU_STATS_MAX_TAG))
  3511. pdev->stats.ppdu_stats_counter[tlv_type]++;
  3512. if (tlv_length == 0)
  3513. break;
  3514. tlv_length += HTT_TLV_HDR_LEN;
  3515. /**
  3516. * Not allocating separate ppdu descriptor for MGMT Payload
  3517. * TLV as this is sent as separate WDI indication and it
  3518. * doesn't contain any ppdu information
  3519. */
  3520. if (tlv_type == HTT_PPDU_STATS_TX_MGMTCTRL_PAYLOAD_TLV) {
  3521. pdev->mgmtctrl_frm_info.mgmt_buf = tlv_buf;
  3522. pdev->mgmtctrl_frm_info.ppdu_id = ppdu_id;
  3523. pdev->mgmtctrl_frm_info.mgmt_buf_len =
  3524. HTT_PPDU_STATS_TX_MGMTCTRL_TLV_FRAME_LENGTH_GET
  3525. (*(msg_word + 1));
  3526. msg_word =
  3527. (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3528. length -= (tlv_length);
  3529. continue;
  3530. }
  3531. /*
  3532. * retrieve max_users if it's USERS_INFO,
  3533. * else, it's 1 for COMPLTN_FLUSH,
  3534. * else, use CDP_MU_MAX_USERS
  3535. */
  3536. if (tlv_type == HTT_PPDU_STATS_USERS_INFO_TLV) {
  3537. max_users =
  3538. HTT_PPDU_STATS_USERS_INFO_TLV_MAX_USERS_GET(*(msg_word + 1));
  3539. } else if (tlv_type == HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV) {
  3540. max_users = 1;
  3541. }
  3542. ppdu_info = dp_get_ppdu_desc(pdev, ppdu_id, tlv_type,
  3543. tsf_l32, max_users);
  3544. if (!ppdu_info)
  3545. return NULL;
  3546. ppdu_info->ppdu_desc->bss_color =
  3547. pdev->rx_mon_recv_status.bsscolor;
  3548. ppdu_info->ppdu_id = ppdu_id;
  3549. ppdu_info->tlv_bitmap |= (1 << tlv_type);
  3550. dp_process_ppdu_tag(pdev, msg_word, tlv_length, ppdu_info);
  3551. /**
  3552. * Increment pdev level tlv count to monitor
  3553. * missing TLVs
  3554. */
  3555. pdev->tlv_count++;
  3556. ppdu_info->last_tlv_cnt = pdev->tlv_count;
  3557. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  3558. length -= (tlv_length);
  3559. }
  3560. if (!ppdu_info)
  3561. return NULL;
  3562. pdev->last_ppdu_id = ppdu_id;
  3563. tlv_bitmap_expected = HTT_PPDU_DEFAULT_TLV_BITMAP;
  3564. if (pdev->tx_sniffer_enable || pdev->mcopy_mode ||
  3565. pdev->tx_capture_enabled) {
  3566. if (ppdu_info->is_ampdu)
  3567. tlv_bitmap_expected =
  3568. dp_htt_get_ppdu_sniffer_ampdu_tlv_bitmap(
  3569. ppdu_info->tlv_bitmap);
  3570. }
  3571. ppdu_desc = ppdu_info->ppdu_desc;
  3572. if (!ppdu_desc)
  3573. return NULL;
  3574. if (ppdu_desc->user[ppdu_desc->last_usr_index].completion_status !=
  3575. HTT_PPDU_STATS_USER_STATUS_OK) {
  3576. tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
  3577. }
  3578. /*
  3579. * for frame type DATA and BAR, we update stats based on MSDU,
  3580. * successful msdu and mpdu are populate from ACK BA STATUS TLV
  3581. * which comes out of order. successful mpdu also populated from
  3582. * COMPLTN COMMON TLV which comes in order. for every ppdu_info
  3583. * we store successful mpdu from both tlv and compare before delivering
  3584. * to make sure we received ACK BA STATUS TLV. For some self generated
  3585. * frame we won't get ack ba status tlv so no need to wait for
  3586. * ack ba status tlv.
  3587. */
  3588. if (ppdu_desc->frame_type != CDP_PPDU_FTYPE_CTRL &&
  3589. ppdu_desc->htt_frame_type != HTT_STATS_FTYPE_SGEN_QOS_NULL) {
  3590. /*
  3591. * most of the time bar frame will have duplicate ack ba
  3592. * status tlv
  3593. */
  3594. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR &&
  3595. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv))
  3596. return NULL;
  3597. /*
  3598. * For data frame, compltn common tlv should match ack ba status
  3599. * tlv and completion status. Reason we are checking first user
  3600. * for ofdma, completion seen at next MU BAR frm, for mimo
  3601. * only for first user completion will be immediate.
  3602. */
  3603. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA &&
  3604. (ppdu_desc->user[0].completion_status == 0 &&
  3605. (ppdu_info->compltn_common_tlv != ppdu_info->ack_ba_tlv)))
  3606. return NULL;
  3607. }
  3608. /**
  3609. * Once all the TLVs for a given PPDU has been processed,
  3610. * return PPDU status to be delivered to higher layer.
  3611. * tlv_bitmap_expected can't be available for different frame type.
  3612. * But SCHED CMD STATS TLV is the last TLV from the FW for a ppdu.
  3613. * apart from ACK BA TLV, FW sends other TLV in sequential order.
  3614. * flush tlv comes separate.
  3615. */
  3616. if ((ppdu_info->tlv_bitmap != 0 &&
  3617. (ppdu_info->tlv_bitmap &
  3618. (1 << HTT_PPDU_STATS_SCH_CMD_STATUS_TLV))) ||
  3619. (ppdu_info->tlv_bitmap &
  3620. (1 << HTT_PPDU_STATS_USR_COMPLTN_FLUSH_TLV))) {
  3621. ppdu_info->done = 1;
  3622. return ppdu_info;
  3623. }
  3624. return NULL;
  3625. }
  3626. #endif /* FEATURE_PERPKT_INFO */
  3627. /**
  3628. * dp_txrx_ppdu_stats_handler() - Function to process HTT PPDU stats from FW
  3629. * @soc: DP SOC handle
  3630. * @pdev_id: pdev id
  3631. * @htt_t2h_msg: HTT message nbuf
  3632. *
  3633. * return:void
  3634. */
  3635. #if defined(WDI_EVENT_ENABLE)
  3636. #ifdef FEATURE_PERPKT_INFO
  3637. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3638. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3639. {
  3640. struct dp_pdev *pdev = soc->pdev_list[pdev_id];
  3641. struct ppdu_info *ppdu_info = NULL;
  3642. bool free_buf = true;
  3643. if (pdev_id >= MAX_PDEV_CNT)
  3644. return true;
  3645. pdev = soc->pdev_list[pdev_id];
  3646. if (!pdev)
  3647. return true;
  3648. if (!pdev->enhanced_stats_en && !pdev->tx_sniffer_enable &&
  3649. !pdev->mcopy_mode && !pdev->bpr_enable)
  3650. return free_buf;
  3651. ppdu_info = dp_htt_process_tlv(pdev, htt_t2h_msg);
  3652. if (pdev->mgmtctrl_frm_info.mgmt_buf) {
  3653. if (dp_process_ppdu_stats_tx_mgmtctrl_payload_tlv
  3654. (pdev, htt_t2h_msg, pdev->mgmtctrl_frm_info.ppdu_id) !=
  3655. QDF_STATUS_SUCCESS)
  3656. free_buf = false;
  3657. }
  3658. if (ppdu_info)
  3659. dp_ppdu_desc_deliver(pdev, ppdu_info);
  3660. pdev->mgmtctrl_frm_info.mgmt_buf = NULL;
  3661. pdev->mgmtctrl_frm_info.mgmt_buf_len = 0;
  3662. pdev->mgmtctrl_frm_info.ppdu_id = 0;
  3663. return free_buf;
  3664. }
  3665. #else
  3666. static bool dp_txrx_ppdu_stats_handler(struct dp_soc *soc,
  3667. uint8_t pdev_id, qdf_nbuf_t htt_t2h_msg)
  3668. {
  3669. return true;
  3670. }
  3671. #endif
  3672. #endif
  3673. /**
  3674. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  3675. * @soc: DP SOC handle
  3676. * @htt_t2h_msg: HTT message nbuf
  3677. *
  3678. * return:void
  3679. */
  3680. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  3681. qdf_nbuf_t htt_t2h_msg)
  3682. {
  3683. uint8_t done;
  3684. qdf_nbuf_t msg_copy;
  3685. uint32_t *msg_word;
  3686. msg_word = (uint32_t *) qdf_nbuf_data(htt_t2h_msg);
  3687. msg_word = msg_word + 3;
  3688. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  3689. /*
  3690. * HTT EXT stats response comes as stream of TLVs which span over
  3691. * multiple T2H messages.
  3692. * The first message will carry length of the response.
  3693. * For rest of the messages length will be zero.
  3694. *
  3695. * Clone the T2H message buffer and store it in a list to process
  3696. * it later.
  3697. *
  3698. * The original T2H message buffers gets freed in the T2H HTT event
  3699. * handler
  3700. */
  3701. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  3702. if (!msg_copy) {
  3703. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3704. "T2H messge clone failed for HTT EXT STATS");
  3705. goto error;
  3706. }
  3707. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3708. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  3709. /*
  3710. * Done bit signifies that this is the last T2H buffer in the stream of
  3711. * HTT EXT STATS message
  3712. */
  3713. if (done) {
  3714. soc->htt_stats.num_stats++;
  3715. qdf_sched_work(0, &soc->htt_stats.work);
  3716. }
  3717. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3718. return;
  3719. error:
  3720. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3721. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  3722. != NULL) {
  3723. qdf_nbuf_free(msg_copy);
  3724. }
  3725. soc->htt_stats.num_stats = 0;
  3726. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3727. return;
  3728. }
  3729. /*
  3730. * htt_soc_attach_target() - SOC level HTT setup
  3731. * @htt_soc: HTT SOC handle
  3732. *
  3733. * Return: 0 on success; error code on failure
  3734. */
  3735. int htt_soc_attach_target(struct htt_soc *htt_soc)
  3736. {
  3737. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3738. return htt_h2t_ver_req_msg(soc);
  3739. }
  3740. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  3741. {
  3742. htt_soc->htc_soc = htc_soc;
  3743. }
  3744. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  3745. {
  3746. return htt_soc->htc_soc;
  3747. }
  3748. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  3749. {
  3750. int i;
  3751. int j;
  3752. int alloc_size = HTT_SW_UMAC_RING_IDX_MAX * sizeof(unsigned long);
  3753. struct htt_soc *htt_soc = NULL;
  3754. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  3755. if (!htt_soc) {
  3756. dp_err("HTT attach failed");
  3757. return NULL;
  3758. }
  3759. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3760. htt_soc->pdevid_tt[i].umac_ttt = qdf_mem_malloc(alloc_size);
  3761. if (!htt_soc->pdevid_tt[i].umac_ttt)
  3762. break;
  3763. qdf_mem_set(htt_soc->pdevid_tt[i].umac_ttt, alloc_size, -1);
  3764. htt_soc->pdevid_tt[i].lmac_ttt = qdf_mem_malloc(alloc_size);
  3765. if (!htt_soc->pdevid_tt[i].lmac_ttt) {
  3766. qdf_mem_free(htt_soc->pdevid_tt[i].umac_ttt);
  3767. break;
  3768. }
  3769. qdf_mem_set(htt_soc->pdevid_tt[i].lmac_ttt, alloc_size, -1);
  3770. }
  3771. if (i != MAX_PDEV_CNT) {
  3772. for (j = 0; j < i; j++) {
  3773. qdf_mem_free(htt_soc->pdevid_tt[j].umac_ttt);
  3774. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_ttt);
  3775. }
  3776. qdf_mem_free(htt_soc);
  3777. return NULL;
  3778. }
  3779. htt_soc->dp_soc = soc;
  3780. htt_soc->htc_soc = htc_handle;
  3781. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  3782. return htt_soc;
  3783. }
  3784. #if defined(WDI_EVENT_ENABLE) && !defined(REMOVE_PKT_LOG)
  3785. /*
  3786. * dp_ppdu_stats_ind_handler() - PPDU stats msg handler
  3787. * @htt_soc: HTT SOC handle
  3788. * @msg_word: Pointer to payload
  3789. * @htt_t2h_msg: HTT msg nbuf
  3790. *
  3791. * Return: True if buffer should be freed by caller.
  3792. */
  3793. static bool
  3794. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3795. uint32_t *msg_word,
  3796. qdf_nbuf_t htt_t2h_msg)
  3797. {
  3798. u_int8_t pdev_id;
  3799. u_int8_t target_pdev_id;
  3800. bool free_buf;
  3801. qdf_nbuf_set_pktlen(htt_t2h_msg, HTT_T2H_MAX_MSG_SIZE);
  3802. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  3803. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3804. target_pdev_id);
  3805. dp_wdi_event_handler(WDI_EVENT_LITE_T2H, soc->dp_soc,
  3806. htt_t2h_msg, HTT_INVALID_PEER, WDI_NO_VAL,
  3807. pdev_id);
  3808. free_buf = dp_txrx_ppdu_stats_handler(soc->dp_soc, pdev_id,
  3809. htt_t2h_msg);
  3810. return free_buf;
  3811. }
  3812. #else
  3813. static bool
  3814. dp_ppdu_stats_ind_handler(struct htt_soc *soc,
  3815. uint32_t *msg_word,
  3816. qdf_nbuf_t htt_t2h_msg)
  3817. {
  3818. return true;
  3819. }
  3820. #endif
  3821. #if defined(WDI_EVENT_ENABLE) && \
  3822. !defined(REMOVE_PKT_LOG)
  3823. /*
  3824. * dp_pktlog_msg_handler() - Pktlog msg handler
  3825. * @htt_soc: HTT SOC handle
  3826. * @msg_word: Pointer to payload
  3827. *
  3828. * Return: None
  3829. */
  3830. static void
  3831. dp_pktlog_msg_handler(struct htt_soc *soc,
  3832. uint32_t *msg_word)
  3833. {
  3834. uint8_t pdev_id;
  3835. uint8_t target_pdev_id;
  3836. uint32_t *pl_hdr;
  3837. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  3838. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3839. target_pdev_id);
  3840. pl_hdr = (msg_word + 1);
  3841. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  3842. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  3843. pdev_id);
  3844. }
  3845. #else
  3846. static void
  3847. dp_pktlog_msg_handler(struct htt_soc *soc,
  3848. uint32_t *msg_word)
  3849. {
  3850. }
  3851. #endif
  3852. /*
  3853. * time_allow_print() - time allow print
  3854. * @htt_ring_tt: ringi_id array of timestamps
  3855. * @ring_id: ring_id (index)
  3856. *
  3857. * Return: 1 for successfully saving timestamp in array
  3858. * and 0 for timestamp falling within 2 seconds after last one
  3859. */
  3860. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  3861. {
  3862. unsigned long tstamp;
  3863. unsigned long delta;
  3864. tstamp = qdf_get_system_timestamp();
  3865. if (!htt_ring_tt)
  3866. return 0; //unable to print backpressure messages
  3867. if (htt_ring_tt[ring_id] == -1) {
  3868. htt_ring_tt[ring_id] = tstamp;
  3869. return 1;
  3870. }
  3871. delta = tstamp - htt_ring_tt[ring_id];
  3872. if (delta >= 2000) {
  3873. htt_ring_tt[ring_id] = tstamp;
  3874. return 1;
  3875. }
  3876. return 0;
  3877. }
  3878. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  3879. u_int8_t pdev_id, u_int8_t ring_id,
  3880. u_int16_t hp_idx, u_int16_t tp_idx,
  3881. u_int32_t bkp_time, char *ring_stype)
  3882. {
  3883. dp_alert("msg_type: %d pdev_id: %d ring_type: %s ",
  3884. msg_type, pdev_id, ring_stype);
  3885. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  3886. ring_id, hp_idx, tp_idx, bkp_time);
  3887. }
  3888. /*
  3889. * dp_htt_bkp_event_alert() - htt backpressure event alert
  3890. * @msg_word: htt packet context
  3891. * @htt_soc: HTT SOC handle
  3892. *
  3893. * Return: after attempting to print stats
  3894. */
  3895. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  3896. {
  3897. u_int8_t ring_type;
  3898. u_int8_t pdev_id;
  3899. uint8_t target_pdev_id;
  3900. u_int8_t ring_id;
  3901. u_int16_t hp_idx;
  3902. u_int16_t tp_idx;
  3903. u_int32_t bkp_time;
  3904. enum htt_t2h_msg_type msg_type;
  3905. struct dp_soc *dpsoc;
  3906. struct dp_pdev *pdev;
  3907. struct dp_htt_timestamp *radio_tt;
  3908. if (!soc)
  3909. return;
  3910. dpsoc = (struct dp_soc *)soc->dp_soc;
  3911. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3912. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  3913. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  3914. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  3915. target_pdev_id);
  3916. if (pdev_id >= MAX_PDEV_CNT) {
  3917. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  3918. "pdev id %d is invalid", pdev_id);
  3919. return;
  3920. }
  3921. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  3922. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  3923. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  3924. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  3925. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  3926. radio_tt = &soc->pdevid_tt[pdev_id];
  3927. switch (ring_type) {
  3928. case HTT_SW_RING_TYPE_UMAC:
  3929. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  3930. return;
  3931. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3932. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  3933. break;
  3934. case HTT_SW_RING_TYPE_LMAC:
  3935. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  3936. return;
  3937. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3938. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  3939. break;
  3940. default:
  3941. dp_htt_alert_print(msg_type, pdev_id, ring_id, hp_idx, tp_idx,
  3942. bkp_time, "UNKNOWN");
  3943. break;
  3944. }
  3945. dp_print_ring_stats(pdev);
  3946. dp_print_napi_stats(pdev->soc);
  3947. }
  3948. /*
  3949. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  3950. * @context: Opaque context (HTT SOC handle)
  3951. * @pkt: HTC packet
  3952. */
  3953. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3954. {
  3955. struct htt_soc *soc = (struct htt_soc *) context;
  3956. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3957. u_int32_t *msg_word;
  3958. enum htt_t2h_msg_type msg_type;
  3959. bool free_buf = true;
  3960. /* check for successful message reception */
  3961. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3962. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3963. soc->stats.htc_err_cnt++;
  3964. qdf_nbuf_free(htt_t2h_msg);
  3965. return;
  3966. }
  3967. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3968. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3969. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3970. htt_event_record(soc->htt_logger_handle,
  3971. msg_type, (uint8_t *)msg_word);
  3972. switch (msg_type) {
  3973. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3974. {
  3975. dp_htt_bkp_event_alert(msg_word, soc);
  3976. break;
  3977. }
  3978. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3979. {
  3980. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3981. u_int8_t *peer_mac_addr;
  3982. u_int16_t peer_id;
  3983. u_int16_t hw_peer_id;
  3984. u_int8_t vdev_id;
  3985. u_int8_t is_wds;
  3986. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3987. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3988. hw_peer_id =
  3989. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3990. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3991. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3992. (u_int8_t *) (msg_word+1),
  3993. &mac_addr_deswizzle_buf[0]);
  3994. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3995. QDF_TRACE_LEVEL_INFO,
  3996. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3997. peer_id, vdev_id);
  3998. /*
  3999. * check if peer already exists for this peer_id, if so
  4000. * this peer map event is in response for a wds peer add
  4001. * wmi command sent during wds source port learning.
  4002. * in this case just add the ast entry to the existing
  4003. * peer ast_list.
  4004. */
  4005. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  4006. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  4007. vdev_id, peer_mac_addr, 0,
  4008. is_wds);
  4009. break;
  4010. }
  4011. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  4012. {
  4013. u_int16_t peer_id;
  4014. u_int8_t vdev_id;
  4015. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  4016. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  4017. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  4018. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4019. vdev_id, mac_addr, 0,
  4020. DP_PEER_WDS_COUNT_INVALID);
  4021. break;
  4022. }
  4023. case HTT_T2H_MSG_TYPE_SEC_IND:
  4024. {
  4025. u_int16_t peer_id;
  4026. enum cdp_sec_type sec_type;
  4027. int is_unicast;
  4028. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  4029. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  4030. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  4031. /* point to the first part of the Michael key */
  4032. msg_word++;
  4033. dp_rx_sec_ind_handler(
  4034. soc->dp_soc, peer_id, sec_type, is_unicast,
  4035. msg_word, msg_word + 2);
  4036. break;
  4037. }
  4038. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  4039. {
  4040. free_buf = dp_ppdu_stats_ind_handler(soc, msg_word,
  4041. htt_t2h_msg);
  4042. break;
  4043. }
  4044. case HTT_T2H_MSG_TYPE_PKTLOG:
  4045. {
  4046. dp_pktlog_msg_handler(soc, msg_word);
  4047. break;
  4048. }
  4049. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  4050. {
  4051. htc_pm_runtime_put(soc->htc_soc);
  4052. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  4053. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  4054. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  4055. "target uses HTT version %d.%d; host uses %d.%d",
  4056. soc->tgt_ver.major, soc->tgt_ver.minor,
  4057. HTT_CURRENT_VERSION_MAJOR,
  4058. HTT_CURRENT_VERSION_MINOR);
  4059. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  4060. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4061. QDF_TRACE_LEVEL_WARN,
  4062. "*** Incompatible host/target HTT versions!");
  4063. }
  4064. /* abort if the target is incompatible with the host */
  4065. qdf_assert(soc->tgt_ver.major ==
  4066. HTT_CURRENT_VERSION_MAJOR);
  4067. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  4068. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4069. QDF_TRACE_LEVEL_INFO_LOW,
  4070. "*** Warning: host/target HTT versions"
  4071. " are different, though compatible!");
  4072. }
  4073. break;
  4074. }
  4075. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  4076. {
  4077. uint16_t peer_id;
  4078. uint8_t tid;
  4079. uint8_t win_sz;
  4080. uint16_t status;
  4081. struct dp_peer *peer;
  4082. /*
  4083. * Update REO Queue Desc with new values
  4084. */
  4085. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  4086. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  4087. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  4088. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  4089. DP_MOD_ID_HTT);
  4090. /*
  4091. * Window size needs to be incremented by 1
  4092. * since fw needs to represent a value of 256
  4093. * using just 8 bits
  4094. */
  4095. if (peer) {
  4096. status = dp_addba_requestprocess_wifi3(
  4097. (struct cdp_soc_t *)soc->dp_soc,
  4098. peer->mac_addr.raw, peer->vdev->vdev_id,
  4099. 0, tid, 0, win_sz + 1, 0xffff);
  4100. /*
  4101. * If PEER_LOCK_REF_PROTECT enbled dec ref
  4102. * which is inc by dp_peer_get_ref_by_id
  4103. */
  4104. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4105. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4106. QDF_TRACE_LEVEL_INFO,
  4107. FL("PeerID %d BAW %d TID %d stat %d"),
  4108. peer_id, win_sz, tid, status);
  4109. } else {
  4110. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4111. QDF_TRACE_LEVEL_ERROR,
  4112. FL("Peer not found peer id %d"),
  4113. peer_id);
  4114. }
  4115. break;
  4116. }
  4117. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  4118. {
  4119. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  4120. break;
  4121. }
  4122. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  4123. {
  4124. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4125. u_int8_t *peer_mac_addr;
  4126. u_int16_t peer_id;
  4127. u_int16_t hw_peer_id;
  4128. u_int8_t vdev_id;
  4129. bool is_wds;
  4130. u_int16_t ast_hash;
  4131. struct dp_ast_flow_override_info ast_flow_info;
  4132. qdf_mem_set(&ast_flow_info, 0,
  4133. sizeof(struct dp_ast_flow_override_info));
  4134. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  4135. hw_peer_id =
  4136. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  4137. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  4138. peer_mac_addr =
  4139. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4140. &mac_addr_deswizzle_buf[0]);
  4141. is_wds =
  4142. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  4143. ast_hash =
  4144. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  4145. /*
  4146. * Update 4 ast_index per peer, ast valid mask
  4147. * and TID flow valid mask.
  4148. * AST valid mask is 3 bit field corresponds to
  4149. * ast_index[3:1]. ast_index 0 is always valid.
  4150. */
  4151. ast_flow_info.ast_valid_mask =
  4152. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  4153. ast_flow_info.ast_idx[0] = hw_peer_id;
  4154. ast_flow_info.ast_flow_mask[0] =
  4155. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  4156. ast_flow_info.ast_idx[1] =
  4157. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  4158. ast_flow_info.ast_flow_mask[1] =
  4159. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  4160. ast_flow_info.ast_idx[2] =
  4161. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  4162. ast_flow_info.ast_flow_mask[2] =
  4163. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  4164. ast_flow_info.ast_idx[3] =
  4165. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  4166. ast_flow_info.ast_flow_mask[3] =
  4167. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  4168. /*
  4169. * TID valid mask is applicable only
  4170. * for HI and LOW priority flows.
  4171. * tid_valid_mas is 8 bit field corresponds
  4172. * to TID[7:0]
  4173. */
  4174. ast_flow_info.tid_valid_low_pri_mask =
  4175. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  4176. ast_flow_info.tid_valid_hi_pri_mask =
  4177. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  4178. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4179. QDF_TRACE_LEVEL_INFO,
  4180. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  4181. peer_id, vdev_id);
  4182. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  4183. hw_peer_id, vdev_id,
  4184. peer_mac_addr, ast_hash,
  4185. is_wds);
  4186. /*
  4187. * Update ast indexes for flow override support
  4188. * Applicable only for non wds peers
  4189. */
  4190. dp_peer_ast_index_flow_queue_map_create(
  4191. soc->dp_soc, is_wds,
  4192. peer_id, peer_mac_addr,
  4193. &ast_flow_info);
  4194. break;
  4195. }
  4196. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  4197. {
  4198. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  4199. u_int8_t *mac_addr;
  4200. u_int16_t peer_id;
  4201. u_int8_t vdev_id;
  4202. u_int8_t is_wds;
  4203. u_int32_t free_wds_count;
  4204. peer_id =
  4205. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  4206. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  4207. mac_addr =
  4208. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  4209. &mac_addr_deswizzle_buf[0]);
  4210. is_wds =
  4211. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  4212. free_wds_count =
  4213. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  4214. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4215. QDF_TRACE_LEVEL_INFO,
  4216. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  4217. peer_id, vdev_id);
  4218. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  4219. vdev_id, mac_addr,
  4220. is_wds, free_wds_count);
  4221. break;
  4222. }
  4223. case HTT_T2H_MSG_TYPE_RX_DELBA:
  4224. {
  4225. uint16_t peer_id;
  4226. uint8_t tid;
  4227. uint8_t win_sz;
  4228. QDF_STATUS status;
  4229. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  4230. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  4231. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  4232. status = dp_rx_delba_ind_handler(
  4233. soc->dp_soc,
  4234. peer_id, tid, win_sz);
  4235. QDF_TRACE(QDF_MODULE_ID_TXRX,
  4236. QDF_TRACE_LEVEL_INFO,
  4237. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  4238. peer_id, win_sz, tid, status);
  4239. break;
  4240. }
  4241. default:
  4242. break;
  4243. };
  4244. /* Free the indication buffer */
  4245. if (free_buf)
  4246. qdf_nbuf_free(htt_t2h_msg);
  4247. }
  4248. /*
  4249. * dp_htt_h2t_full() - Send full handler (called from HTC)
  4250. * @context: Opaque context (HTT SOC handle)
  4251. * @pkt: HTC packet
  4252. *
  4253. * Return: enum htc_send_full_action
  4254. */
  4255. static enum htc_send_full_action
  4256. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  4257. {
  4258. return HTC_SEND_FULL_KEEP;
  4259. }
  4260. /*
  4261. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  4262. * @context: Opaque context (HTT SOC handle)
  4263. * @nbuf: nbuf containing T2H message
  4264. * @pipe_id: HIF pipe ID
  4265. *
  4266. * Return: QDF_STATUS
  4267. *
  4268. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  4269. * will be used for packet log and other high-priority HTT messages. Proper
  4270. * HTC connection to be added later once required FW changes are available
  4271. */
  4272. static QDF_STATUS
  4273. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  4274. {
  4275. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  4276. HTC_PACKET htc_pkt;
  4277. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  4278. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  4279. htc_pkt.Status = QDF_STATUS_SUCCESS;
  4280. htc_pkt.pPktContext = (void *)nbuf;
  4281. dp_htt_t2h_msg_handler(context, &htc_pkt);
  4282. return rc;
  4283. }
  4284. /*
  4285. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  4286. * @htt_soc: HTT SOC handle
  4287. *
  4288. * Return: QDF_STATUS
  4289. */
  4290. static QDF_STATUS
  4291. htt_htc_soc_attach(struct htt_soc *soc)
  4292. {
  4293. struct htc_service_connect_req connect;
  4294. struct htc_service_connect_resp response;
  4295. QDF_STATUS status;
  4296. struct dp_soc *dpsoc = soc->dp_soc;
  4297. qdf_mem_zero(&connect, sizeof(connect));
  4298. qdf_mem_zero(&response, sizeof(response));
  4299. connect.pMetaData = NULL;
  4300. connect.MetaDataLength = 0;
  4301. connect.EpCallbacks.pContext = soc;
  4302. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  4303. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  4304. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  4305. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  4306. connect.EpCallbacks.EpRecvRefill = NULL;
  4307. /* N/A, fill is done by HIF */
  4308. connect.EpCallbacks.RecvRefillWaterMark = 1;
  4309. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  4310. /*
  4311. * Specify how deep to let a queue get before htc_send_pkt will
  4312. * call the EpSendFull function due to excessive send queue depth.
  4313. */
  4314. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  4315. /* disable flow control for HTT data message service */
  4316. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  4317. /* connect to control service */
  4318. connect.service_id = HTT_DATA_MSG_SVC;
  4319. status = htc_connect_service(soc->htc_soc, &connect, &response);
  4320. if (status != QDF_STATUS_SUCCESS)
  4321. return status;
  4322. soc->htc_endpoint = response.Endpoint;
  4323. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  4324. htt_interface_logging_init(&soc->htt_logger_handle);
  4325. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  4326. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  4327. return QDF_STATUS_SUCCESS; /* success */
  4328. }
  4329. /*
  4330. * htt_soc_initialize() - SOC level HTT initialization
  4331. * @htt_soc: Opaque htt SOC handle
  4332. * @ctrl_psoc: Opaque ctrl SOC handle
  4333. * @htc_soc: SOC level HTC handle
  4334. * @hal_soc: Opaque HAL SOC handle
  4335. * @osdev: QDF device
  4336. *
  4337. * Return: HTT handle on success; NULL on failure
  4338. */
  4339. void *
  4340. htt_soc_initialize(struct htt_soc *htt_soc,
  4341. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  4342. HTC_HANDLE htc_soc,
  4343. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  4344. {
  4345. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  4346. soc->osdev = osdev;
  4347. soc->ctrl_psoc = ctrl_psoc;
  4348. soc->htc_soc = htc_soc;
  4349. soc->hal_soc = hal_soc_hdl;
  4350. if (htt_htc_soc_attach(soc))
  4351. goto fail2;
  4352. return soc;
  4353. fail2:
  4354. return NULL;
  4355. }
  4356. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  4357. {
  4358. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  4359. htt_htc_misc_pkt_pool_free(htt_handle);
  4360. htt_htc_pkt_pool_free(htt_handle);
  4361. }
  4362. /*
  4363. * htt_soc_htc_prealloc() - HTC memory prealloc
  4364. * @htt_soc: SOC level HTT handle
  4365. *
  4366. * Return: QDF_STATUS_SUCCESS on Success or
  4367. * QDF_STATUS_E_NOMEM on allocation failure
  4368. */
  4369. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  4370. {
  4371. int i;
  4372. soc->htt_htc_pkt_freelist = NULL;
  4373. /* pre-allocate some HTC_PACKET objects */
  4374. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  4375. struct dp_htt_htc_pkt_union *pkt;
  4376. pkt = qdf_mem_malloc(sizeof(*pkt));
  4377. if (!pkt)
  4378. return QDF_STATUS_E_NOMEM;
  4379. htt_htc_pkt_free(soc, &pkt->u.pkt);
  4380. }
  4381. return QDF_STATUS_SUCCESS;
  4382. }
  4383. /*
  4384. * htt_soc_detach() - Free SOC level HTT handle
  4385. * @htt_hdl: HTT SOC handle
  4386. */
  4387. void htt_soc_detach(struct htt_soc *htt_hdl)
  4388. {
  4389. int i;
  4390. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  4391. for (i = 0; i < MAX_PDEV_CNT; i++) {
  4392. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  4393. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  4394. }
  4395. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  4396. qdf_mem_free(htt_handle);
  4397. }
  4398. /**
  4399. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  4400. * @pdev: DP PDEV handle
  4401. * @stats_type_upload_mask: stats type requested by user
  4402. * @config_param_0: extra configuration parameters
  4403. * @config_param_1: extra configuration parameters
  4404. * @config_param_2: extra configuration parameters
  4405. * @config_param_3: extra configuration parameters
  4406. * @mac_id: mac number
  4407. *
  4408. * return: QDF STATUS
  4409. */
  4410. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  4411. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  4412. uint32_t config_param_1, uint32_t config_param_2,
  4413. uint32_t config_param_3, int cookie_val, int cookie_msb,
  4414. uint8_t mac_id)
  4415. {
  4416. struct htt_soc *soc = pdev->soc->htt_handle;
  4417. struct dp_htt_htc_pkt *pkt;
  4418. qdf_nbuf_t msg;
  4419. uint32_t *msg_word;
  4420. uint8_t pdev_mask = 0;
  4421. uint8_t *htt_logger_bufp;
  4422. int mac_for_pdev;
  4423. int target_pdev_id;
  4424. QDF_STATUS status;
  4425. msg = qdf_nbuf_alloc(
  4426. soc->osdev,
  4427. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  4428. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4429. if (!msg)
  4430. return QDF_STATUS_E_NOMEM;
  4431. /*TODO:Add support for SOC stats
  4432. * Bit 0: SOC Stats
  4433. * Bit 1: Pdev stats for pdev id 0
  4434. * Bit 2: Pdev stats for pdev id 1
  4435. * Bit 3: Pdev stats for pdev id 2
  4436. */
  4437. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4438. target_pdev_id =
  4439. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4440. pdev_mask = 1 << target_pdev_id;
  4441. /*
  4442. * Set the length of the message.
  4443. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4444. * separately during the below call to qdf_nbuf_push_head.
  4445. * The contribution from the HTC header is added separately inside HTC.
  4446. */
  4447. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  4448. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4449. "Failed to expand head for HTT_EXT_STATS");
  4450. qdf_nbuf_free(msg);
  4451. return QDF_STATUS_E_FAILURE;
  4452. }
  4453. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4454. "-----%s:%d----\n cookie <-> %d\n config_param_0 %u\n"
  4455. "config_param_1 %u\n config_param_2 %u\n"
  4456. "config_param_4 %u\n -------------",
  4457. __func__, __LINE__, cookie_val, config_param_0,
  4458. config_param_1, config_param_2, config_param_3);
  4459. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4460. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4461. htt_logger_bufp = (uint8_t *)msg_word;
  4462. *msg_word = 0;
  4463. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  4464. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  4465. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  4466. /* word 1 */
  4467. msg_word++;
  4468. *msg_word = 0;
  4469. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  4470. /* word 2 */
  4471. msg_word++;
  4472. *msg_word = 0;
  4473. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  4474. /* word 3 */
  4475. msg_word++;
  4476. *msg_word = 0;
  4477. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  4478. /* word 4 */
  4479. msg_word++;
  4480. *msg_word = 0;
  4481. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  4482. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  4483. /* word 5 */
  4484. msg_word++;
  4485. /* word 6 */
  4486. msg_word++;
  4487. *msg_word = 0;
  4488. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  4489. /* word 7 */
  4490. msg_word++;
  4491. *msg_word = 0;
  4492. /*Using last 2 bits for pdev_id */
  4493. cookie_msb = ((cookie_msb << 2) | pdev->pdev_id);
  4494. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  4495. pkt = htt_htc_pkt_alloc(soc);
  4496. if (!pkt) {
  4497. qdf_nbuf_free(msg);
  4498. return QDF_STATUS_E_NOMEM;
  4499. }
  4500. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4501. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4502. dp_htt_h2t_send_complete_free_netbuf,
  4503. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4504. soc->htc_endpoint,
  4505. /* tag for FW response msg not guaranteed */
  4506. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4507. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4508. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  4509. htt_logger_bufp);
  4510. if (status != QDF_STATUS_SUCCESS) {
  4511. qdf_nbuf_free(msg);
  4512. htt_htc_pkt_free(soc, pkt);
  4513. }
  4514. return status;
  4515. }
  4516. /**
  4517. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  4518. * HTT message to pass to FW
  4519. * @pdev: DP PDEV handle
  4520. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4521. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4522. *
  4523. * tuple_mask[1:0]:
  4524. * 00 - Do not report 3 tuple hash value
  4525. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4526. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4527. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4528. *
  4529. * return: QDF STATUS
  4530. */
  4531. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4532. uint32_t tuple_mask, uint8_t mac_id)
  4533. {
  4534. struct htt_soc *soc = pdev->soc->htt_handle;
  4535. struct dp_htt_htc_pkt *pkt;
  4536. qdf_nbuf_t msg;
  4537. uint32_t *msg_word;
  4538. uint8_t *htt_logger_bufp;
  4539. int mac_for_pdev;
  4540. int target_pdev_id;
  4541. msg = qdf_nbuf_alloc(
  4542. soc->osdev,
  4543. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4544. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4545. if (!msg)
  4546. return QDF_STATUS_E_NOMEM;
  4547. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4548. target_pdev_id =
  4549. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4550. /*
  4551. * Set the length of the message.
  4552. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4553. * separately during the below call to qdf_nbuf_push_head.
  4554. * The contribution from the HTC header is added separately inside HTC.
  4555. */
  4556. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4557. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4558. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4559. qdf_nbuf_free(msg);
  4560. return QDF_STATUS_E_FAILURE;
  4561. }
  4562. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  4563. "config_param_sent %s:%d 0x%x for target_pdev %d\n -------------",
  4564. __func__, __LINE__, tuple_mask, target_pdev_id);
  4565. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4566. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4567. htt_logger_bufp = (uint8_t *)msg_word;
  4568. *msg_word = 0;
  4569. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4570. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4571. msg_word++;
  4572. *msg_word = 0;
  4573. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4574. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4575. pkt = htt_htc_pkt_alloc(soc);
  4576. if (!pkt) {
  4577. qdf_nbuf_free(msg);
  4578. return QDF_STATUS_E_NOMEM;
  4579. }
  4580. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4581. SET_HTC_PACKET_INFO_TX(
  4582. &pkt->htc_pkt,
  4583. dp_htt_h2t_send_complete_free_netbuf,
  4584. qdf_nbuf_data(msg),
  4585. qdf_nbuf_len(msg),
  4586. soc->htc_endpoint,
  4587. /* tag for no FW response msg */
  4588. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4589. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4590. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4591. htt_logger_bufp);
  4592. return QDF_STATUS_SUCCESS;
  4593. }
  4594. /* This macro will revert once proper HTT header will define for
  4595. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4596. * */
  4597. #if defined(WDI_EVENT_ENABLE)
  4598. /**
  4599. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  4600. * @pdev: DP PDEV handle
  4601. * @stats_type_upload_mask: stats type requested by user
  4602. * @mac_id: Mac id number
  4603. *
  4604. * return: QDF STATUS
  4605. */
  4606. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4607. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4608. {
  4609. struct htt_soc *soc = pdev->soc->htt_handle;
  4610. struct dp_htt_htc_pkt *pkt;
  4611. qdf_nbuf_t msg;
  4612. uint32_t *msg_word;
  4613. uint8_t pdev_mask;
  4614. QDF_STATUS status;
  4615. msg = qdf_nbuf_alloc(
  4616. soc->osdev,
  4617. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4618. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4619. if (!msg) {
  4620. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4621. "Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer");
  4622. qdf_assert(0);
  4623. return QDF_STATUS_E_NOMEM;
  4624. }
  4625. /*TODO:Add support for SOC stats
  4626. * Bit 0: SOC Stats
  4627. * Bit 1: Pdev stats for pdev id 0
  4628. * Bit 2: Pdev stats for pdev id 1
  4629. * Bit 3: Pdev stats for pdev id 2
  4630. */
  4631. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4632. mac_id);
  4633. /*
  4634. * Set the length of the message.
  4635. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4636. * separately during the below call to qdf_nbuf_push_head.
  4637. * The contribution from the HTC header is added separately inside HTC.
  4638. */
  4639. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4640. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4641. "Failed to expand head for HTT_CFG_STATS");
  4642. qdf_nbuf_free(msg);
  4643. return QDF_STATUS_E_FAILURE;
  4644. }
  4645. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4646. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4647. *msg_word = 0;
  4648. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4649. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4650. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4651. stats_type_upload_mask);
  4652. pkt = htt_htc_pkt_alloc(soc);
  4653. if (!pkt) {
  4654. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  4655. "Fail to allocate dp_htt_htc_pkt buffer");
  4656. qdf_assert(0);
  4657. qdf_nbuf_free(msg);
  4658. return QDF_STATUS_E_NOMEM;
  4659. }
  4660. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4661. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4662. dp_htt_h2t_send_complete_free_netbuf,
  4663. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4664. soc->htc_endpoint,
  4665. /* tag for no FW response msg */
  4666. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4667. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4668. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4669. (uint8_t *)msg_word);
  4670. if (status != QDF_STATUS_SUCCESS) {
  4671. qdf_nbuf_free(msg);
  4672. htt_htc_pkt_free(soc, pkt);
  4673. }
  4674. return status;
  4675. }
  4676. #endif
  4677. void
  4678. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4679. uint32_t *tag_buf)
  4680. {
  4681. struct dp_peer *peer = NULL;
  4682. switch (tag_type) {
  4683. case HTT_STATS_PEER_DETAILS_TAG:
  4684. {
  4685. htt_peer_details_tlv *dp_stats_buf =
  4686. (htt_peer_details_tlv *)tag_buf;
  4687. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4688. }
  4689. break;
  4690. case HTT_STATS_PEER_STATS_CMN_TAG:
  4691. {
  4692. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4693. (htt_peer_stats_cmn_tlv *)tag_buf;
  4694. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4695. DP_MOD_ID_HTT);
  4696. if (peer && !peer->bss_peer) {
  4697. peer->stats.tx.inactive_time =
  4698. dp_stats_buf->inactive_time;
  4699. qdf_event_set(&pdev->fw_peer_stats_event);
  4700. }
  4701. if (peer)
  4702. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4703. }
  4704. break;
  4705. default:
  4706. qdf_err("Invalid tag_type");
  4707. }
  4708. }
  4709. /**
  4710. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  4711. * @pdev: DP pdev handle
  4712. * @fse_setup_info: FST setup parameters
  4713. *
  4714. * Return: Success when HTT message is sent, error on failure
  4715. */
  4716. QDF_STATUS
  4717. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4718. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4719. {
  4720. struct htt_soc *soc = pdev->soc->htt_handle;
  4721. struct dp_htt_htc_pkt *pkt;
  4722. qdf_nbuf_t msg;
  4723. u_int32_t *msg_word;
  4724. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4725. uint8_t *htt_logger_bufp;
  4726. u_int32_t *key;
  4727. QDF_STATUS status;
  4728. msg = qdf_nbuf_alloc(
  4729. soc->osdev,
  4730. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4731. /* reserve room for the HTC header */
  4732. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4733. if (!msg)
  4734. return QDF_STATUS_E_NOMEM;
  4735. /*
  4736. * Set the length of the message.
  4737. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4738. * separately during the below call to qdf_nbuf_push_head.
  4739. * The contribution from the HTC header is added separately inside HTC.
  4740. */
  4741. if (!qdf_nbuf_put_tail(msg,
  4742. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4743. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4744. return QDF_STATUS_E_FAILURE;
  4745. }
  4746. /* fill in the message contents */
  4747. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4748. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4749. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4750. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4751. htt_logger_bufp = (uint8_t *)msg_word;
  4752. *msg_word = 0;
  4753. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4754. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4755. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4756. msg_word++;
  4757. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4758. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4759. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4760. fse_setup_info->ip_da_sa_prefix);
  4761. msg_word++;
  4762. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4763. fse_setup_info->base_addr_lo);
  4764. msg_word++;
  4765. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4766. fse_setup_info->base_addr_hi);
  4767. key = (u_int32_t *)fse_setup_info->hash_key;
  4768. fse_setup->toeplitz31_0 = *key++;
  4769. fse_setup->toeplitz63_32 = *key++;
  4770. fse_setup->toeplitz95_64 = *key++;
  4771. fse_setup->toeplitz127_96 = *key++;
  4772. fse_setup->toeplitz159_128 = *key++;
  4773. fse_setup->toeplitz191_160 = *key++;
  4774. fse_setup->toeplitz223_192 = *key++;
  4775. fse_setup->toeplitz255_224 = *key++;
  4776. fse_setup->toeplitz287_256 = *key++;
  4777. fse_setup->toeplitz314_288 = *key;
  4778. msg_word++;
  4779. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4780. msg_word++;
  4781. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4782. msg_word++;
  4783. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4784. msg_word++;
  4785. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4786. msg_word++;
  4787. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4788. msg_word++;
  4789. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4790. msg_word++;
  4791. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4792. msg_word++;
  4793. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4794. msg_word++;
  4795. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4796. msg_word++;
  4797. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4798. fse_setup->toeplitz314_288);
  4799. pkt = htt_htc_pkt_alloc(soc);
  4800. if (!pkt) {
  4801. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4802. qdf_assert(0);
  4803. qdf_nbuf_free(msg);
  4804. return QDF_STATUS_E_RESOURCES; /* failure */
  4805. }
  4806. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4807. SET_HTC_PACKET_INFO_TX(
  4808. &pkt->htc_pkt,
  4809. dp_htt_h2t_send_complete_free_netbuf,
  4810. qdf_nbuf_data(msg),
  4811. qdf_nbuf_len(msg),
  4812. soc->htc_endpoint,
  4813. /* tag for no FW response msg */
  4814. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4815. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4816. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4817. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4818. htt_logger_bufp);
  4819. if (status == QDF_STATUS_SUCCESS) {
  4820. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4821. fse_setup_info->pdev_id);
  4822. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4823. (void *)fse_setup_info->hash_key,
  4824. fse_setup_info->hash_key_len);
  4825. } else {
  4826. qdf_nbuf_free(msg);
  4827. htt_htc_pkt_free(soc, pkt);
  4828. }
  4829. return status;
  4830. }
  4831. /**
  4832. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  4833. * add/del a flow in HW
  4834. * @pdev: DP pdev handle
  4835. * @fse_op_info: Flow entry parameters
  4836. *
  4837. * Return: Success when HTT message is sent, error on failure
  4838. */
  4839. QDF_STATUS
  4840. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4841. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4842. {
  4843. struct htt_soc *soc = pdev->soc->htt_handle;
  4844. struct dp_htt_htc_pkt *pkt;
  4845. qdf_nbuf_t msg;
  4846. u_int32_t *msg_word;
  4847. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4848. uint8_t *htt_logger_bufp;
  4849. QDF_STATUS status;
  4850. msg = qdf_nbuf_alloc(
  4851. soc->osdev,
  4852. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4853. /* reserve room for the HTC header */
  4854. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4855. if (!msg)
  4856. return QDF_STATUS_E_NOMEM;
  4857. /*
  4858. * Set the length of the message.
  4859. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4860. * separately during the below call to qdf_nbuf_push_head.
  4861. * The contribution from the HTC header is added separately inside HTC.
  4862. */
  4863. if (!qdf_nbuf_put_tail(msg,
  4864. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4865. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4866. qdf_nbuf_free(msg);
  4867. return QDF_STATUS_E_FAILURE;
  4868. }
  4869. /* fill in the message contents */
  4870. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4871. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4872. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4873. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4874. htt_logger_bufp = (uint8_t *)msg_word;
  4875. *msg_word = 0;
  4876. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4877. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4878. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4879. msg_word++;
  4880. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4881. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4882. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4883. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4884. msg_word++;
  4885. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4886. *msg_word,
  4887. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4888. msg_word++;
  4889. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4890. *msg_word,
  4891. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4892. msg_word++;
  4893. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4894. *msg_word,
  4895. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4896. msg_word++;
  4897. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4898. *msg_word,
  4899. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4900. msg_word++;
  4901. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4902. *msg_word,
  4903. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4904. msg_word++;
  4905. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4906. *msg_word,
  4907. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4908. msg_word++;
  4909. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4910. *msg_word,
  4911. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4912. msg_word++;
  4913. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4914. *msg_word,
  4915. qdf_htonl(
  4916. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4917. msg_word++;
  4918. HTT_RX_FSE_SOURCEPORT_SET(
  4919. *msg_word,
  4920. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4921. HTT_RX_FSE_DESTPORT_SET(
  4922. *msg_word,
  4923. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4924. msg_word++;
  4925. HTT_RX_FSE_L4_PROTO_SET(
  4926. *msg_word,
  4927. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4928. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4929. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4930. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4931. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4932. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4933. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4934. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4935. }
  4936. pkt = htt_htc_pkt_alloc(soc);
  4937. if (!pkt) {
  4938. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4939. qdf_assert(0);
  4940. qdf_nbuf_free(msg);
  4941. return QDF_STATUS_E_RESOURCES; /* failure */
  4942. }
  4943. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4944. SET_HTC_PACKET_INFO_TX(
  4945. &pkt->htc_pkt,
  4946. dp_htt_h2t_send_complete_free_netbuf,
  4947. qdf_nbuf_data(msg),
  4948. qdf_nbuf_len(msg),
  4949. soc->htc_endpoint,
  4950. /* tag for no FW response msg */
  4951. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4952. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4953. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4954. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4955. htt_logger_bufp);
  4956. if (status == QDF_STATUS_SUCCESS) {
  4957. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4958. fse_op_info->pdev_id);
  4959. } else {
  4960. qdf_nbuf_free(msg);
  4961. htt_htc_pkt_free(soc, pkt);
  4962. }
  4963. return status;
  4964. }
  4965. /**
  4966. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4967. * @pdev: DP pdev handle
  4968. * @fse_op_info: Flow entry parameters
  4969. *
  4970. * Return: Success when HTT message is sent, error on failure
  4971. */
  4972. QDF_STATUS
  4973. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4974. struct dp_htt_rx_fisa_cfg *fisa_config)
  4975. {
  4976. struct htt_soc *soc = pdev->soc->htt_handle;
  4977. struct dp_htt_htc_pkt *pkt;
  4978. qdf_nbuf_t msg;
  4979. u_int32_t *msg_word;
  4980. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4981. uint8_t *htt_logger_bufp;
  4982. uint32_t len;
  4983. QDF_STATUS status;
  4984. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4985. msg = qdf_nbuf_alloc(soc->osdev,
  4986. len,
  4987. /* reserve room for the HTC header */
  4988. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4989. 4,
  4990. TRUE);
  4991. if (!msg)
  4992. return QDF_STATUS_E_NOMEM;
  4993. /*
  4994. * Set the length of the message.
  4995. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4996. * separately during the below call to qdf_nbuf_push_head.
  4997. * The contribution from the HTC header is added separately inside HTC.
  4998. */
  4999. if (!qdf_nbuf_put_tail(msg,
  5000. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  5001. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  5002. qdf_nbuf_free(msg);
  5003. return QDF_STATUS_E_FAILURE;
  5004. }
  5005. /* fill in the message contents */
  5006. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  5007. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  5008. /* rewind beyond alignment pad to get to the HTC header reserved area */
  5009. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  5010. htt_logger_bufp = (uint8_t *)msg_word;
  5011. *msg_word = 0;
  5012. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  5013. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  5014. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  5015. msg_word++;
  5016. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  5017. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  5018. msg_word++;
  5019. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  5020. pkt = htt_htc_pkt_alloc(soc);
  5021. if (!pkt) {
  5022. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  5023. qdf_assert(0);
  5024. qdf_nbuf_free(msg);
  5025. return QDF_STATUS_E_RESOURCES; /* failure */
  5026. }
  5027. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  5028. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  5029. dp_htt_h2t_send_complete_free_netbuf,
  5030. qdf_nbuf_data(msg),
  5031. qdf_nbuf_len(msg),
  5032. soc->htc_endpoint,
  5033. /* tag for no FW response msg */
  5034. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  5035. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  5036. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  5037. htt_logger_bufp);
  5038. if (status == QDF_STATUS_SUCCESS) {
  5039. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  5040. fisa_config->pdev_id);
  5041. } else {
  5042. qdf_nbuf_free(msg);
  5043. htt_htc_pkt_free(soc, pkt);
  5044. }
  5045. return status;
  5046. }