dp_htt.c 162 KB

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