dp_htt.c 165 KB

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