dp_htt.c 156 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <htt.h>
  20. #include <hal_hw_headers.h>
  21. #include <hal_api.h>
  22. #include "dp_peer.h"
  23. #include "dp_types.h"
  24. #include "dp_internal.h"
  25. #include "dp_ipa.h"
  26. #include "dp_rx.h"
  27. #include "htt_stats.h"
  28. #include "htt_ppdu_stats.h"
  29. #include "dp_htt.h"
  30. #ifdef WIFI_MONITOR_SUPPORT
  31. #include <dp_mon.h>
  32. #endif
  33. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  34. #include "cdp_txrx_cmn_struct.h"
  35. #ifdef IPA_OPT_WIFI_DP
  36. #include "cdp_txrx_ipa.h"
  37. #endif
  38. #ifdef FEATURE_PERPKT_INFO
  39. #include "dp_ratetable.h"
  40. #endif
  41. #include <qdf_module.h>
  42. #ifdef CONFIG_SAWF_DEF_QUEUES
  43. #include <dp_sawf_htt.h>
  44. #endif
  45. #include <wbuff.h>
  46. #define HTT_TLV_HDR_LEN HTT_T2H_EXT_STATS_CONF_TLV_HDR_SIZE
  47. #define HTT_HTC_PKT_POOL_INIT_SIZE 64
  48. #define HTT_MSG_BUF_SIZE(msg_bytes) \
  49. ((msg_bytes) + HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING)
  50. #define HTT_PID_BIT_MASK 0x3
  51. #define DP_EXT_MSG_LENGTH 2048
  52. #define HTT_HEADER_LEN 16
  53. #define HTT_MGMT_CTRL_TLV_HDR_RESERVERD_LEN 16
  54. #define HTT_SHIFT_UPPER_TIMESTAMP 32
  55. #define HTT_MASK_UPPER_TIMESTAMP 0xFFFFFFFF00000000
  56. #define HTT_BKP_STATS_MAX_QUEUE_DEPTH 16
  57. struct dp_htt_htc_pkt *
  58. htt_htc_pkt_alloc(struct htt_soc *soc)
  59. {
  60. struct dp_htt_htc_pkt_union *pkt = NULL;
  61. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  62. if (soc->htt_htc_pkt_freelist) {
  63. pkt = soc->htt_htc_pkt_freelist;
  64. soc->htt_htc_pkt_freelist = soc->htt_htc_pkt_freelist->u.next;
  65. }
  66. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  67. if (!pkt)
  68. pkt = qdf_mem_malloc(sizeof(*pkt));
  69. if (!pkt)
  70. return NULL;
  71. htc_packet_set_magic_cookie(&(pkt->u.pkt.htc_pkt), 0);
  72. return &pkt->u.pkt; /* not actually a dereference */
  73. }
  74. qdf_export_symbol(htt_htc_pkt_alloc);
  75. void
  76. htt_htc_pkt_free(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  77. {
  78. struct dp_htt_htc_pkt_union *u_pkt =
  79. (struct dp_htt_htc_pkt_union *)pkt;
  80. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  81. htc_packet_set_magic_cookie(&(u_pkt->u.pkt.htc_pkt), 0);
  82. u_pkt->u.next = soc->htt_htc_pkt_freelist;
  83. soc->htt_htc_pkt_freelist = u_pkt;
  84. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  85. }
  86. qdf_export_symbol(htt_htc_pkt_free);
  87. void
  88. htt_htc_pkt_pool_free(struct htt_soc *soc)
  89. {
  90. struct dp_htt_htc_pkt_union *pkt, *next;
  91. pkt = soc->htt_htc_pkt_freelist;
  92. while (pkt) {
  93. next = pkt->u.next;
  94. qdf_mem_free(pkt);
  95. pkt = next;
  96. }
  97. soc->htt_htc_pkt_freelist = NULL;
  98. }
  99. #ifndef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  100. /**
  101. * htt_htc_misc_pkt_list_trim() - trim misc list
  102. * @soc: HTT SOC handle
  103. * @level: max no. of pkts in list
  104. */
  105. static void
  106. htt_htc_misc_pkt_list_trim(struct htt_soc *soc, int level)
  107. {
  108. struct dp_htt_htc_pkt_union *pkt, *next, *prev = NULL;
  109. int i = 0;
  110. qdf_nbuf_t netbuf;
  111. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  112. pkt = soc->htt_htc_pkt_misclist;
  113. while (pkt) {
  114. next = pkt->u.next;
  115. /* trim the out grown list*/
  116. if (++i > level) {
  117. netbuf =
  118. (qdf_nbuf_t)(pkt->u.pkt.htc_pkt.pNetBufContext);
  119. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  120. qdf_nbuf_free(netbuf);
  121. qdf_mem_free(pkt);
  122. pkt = NULL;
  123. if (prev)
  124. prev->u.next = NULL;
  125. }
  126. prev = pkt;
  127. pkt = next;
  128. }
  129. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  130. }
  131. void
  132. htt_htc_misc_pkt_list_add(struct htt_soc *soc, struct dp_htt_htc_pkt *pkt)
  133. {
  134. struct dp_htt_htc_pkt_union *u_pkt =
  135. (struct dp_htt_htc_pkt_union *)pkt;
  136. int misclist_trim_level = htc_get_tx_queue_depth(soc->htc_soc,
  137. pkt->htc_pkt.Endpoint)
  138. + DP_HTT_HTC_PKT_MISCLIST_SIZE;
  139. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  140. if (soc->htt_htc_pkt_misclist) {
  141. u_pkt->u.next = soc->htt_htc_pkt_misclist;
  142. soc->htt_htc_pkt_misclist = u_pkt;
  143. } else {
  144. soc->htt_htc_pkt_misclist = u_pkt;
  145. }
  146. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  147. /* only ce pipe size + tx_queue_depth could possibly be in use
  148. * free older packets in the misclist
  149. */
  150. htt_htc_misc_pkt_list_trim(soc, misclist_trim_level);
  151. }
  152. qdf_export_symbol(htt_htc_misc_pkt_list_add);
  153. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  154. /**
  155. * htt_htc_misc_pkt_pool_free() - free pkts in misc list
  156. * @soc: HTT SOC handle
  157. */
  158. static void
  159. htt_htc_misc_pkt_pool_free(struct htt_soc *soc)
  160. {
  161. struct dp_htt_htc_pkt_union *pkt, *next;
  162. qdf_nbuf_t netbuf;
  163. HTT_TX_MUTEX_ACQUIRE(&soc->htt_tx_mutex);
  164. pkt = soc->htt_htc_pkt_misclist;
  165. while (pkt) {
  166. next = pkt->u.next;
  167. if (htc_packet_get_magic_cookie(&(pkt->u.pkt.htc_pkt)) !=
  168. HTC_PACKET_MAGIC_COOKIE) {
  169. pkt = next;
  170. soc->stats.skip_count++;
  171. continue;
  172. }
  173. netbuf = (qdf_nbuf_t) (pkt->u.pkt.htc_pkt.pNetBufContext);
  174. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  175. soc->stats.htc_pkt_free++;
  176. dp_htt_info("%pK: Pkt free count %d",
  177. soc->dp_soc, soc->stats.htc_pkt_free);
  178. qdf_nbuf_free(netbuf);
  179. qdf_mem_free(pkt);
  180. pkt = next;
  181. }
  182. soc->htt_htc_pkt_misclist = NULL;
  183. HTT_TX_MUTEX_RELEASE(&soc->htt_tx_mutex);
  184. dp_info("HTC Packets, fail count = %d, skip count = %d",
  185. soc->stats.fail_count, soc->stats.skip_count);
  186. }
  187. /**
  188. * htt_t2h_mac_addr_deswizzle() - Swap MAC addr bytes if FW endianness differ
  189. * @tgt_mac_addr: Target MAC
  190. * @buffer: Output buffer
  191. */
  192. static u_int8_t *
  193. htt_t2h_mac_addr_deswizzle(u_int8_t *tgt_mac_addr, u_int8_t *buffer)
  194. {
  195. #ifdef BIG_ENDIAN_HOST
  196. /*
  197. * The host endianness is opposite of the target endianness.
  198. * To make u_int32_t elements come out correctly, the target->host
  199. * upload has swizzled the bytes in each u_int32_t element of the
  200. * message.
  201. * For byte-array message fields like the MAC address, this
  202. * upload swizzling puts the bytes in the wrong order, and needs
  203. * to be undone.
  204. */
  205. buffer[0] = tgt_mac_addr[3];
  206. buffer[1] = tgt_mac_addr[2];
  207. buffer[2] = tgt_mac_addr[1];
  208. buffer[3] = tgt_mac_addr[0];
  209. buffer[4] = tgt_mac_addr[7];
  210. buffer[5] = tgt_mac_addr[6];
  211. return buffer;
  212. #else
  213. /*
  214. * The host endianness matches the target endianness -
  215. * we can use the mac addr directly from the message buffer.
  216. */
  217. return tgt_mac_addr;
  218. #endif
  219. }
  220. /**
  221. * dp_htt_h2t_send_complete_free_netbuf() - Free completed buffer
  222. * @soc: SOC handle
  223. * @status: Completion status
  224. * @netbuf: HTT buffer
  225. */
  226. static void
  227. dp_htt_h2t_send_complete_free_netbuf(
  228. void *soc, A_STATUS status, qdf_nbuf_t netbuf)
  229. {
  230. qdf_nbuf_free(netbuf);
  231. }
  232. #ifdef ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST
  233. void
  234. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  235. {
  236. struct htt_soc *soc = (struct htt_soc *) context;
  237. struct dp_htt_htc_pkt *htt_pkt;
  238. qdf_nbuf_t netbuf;
  239. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  240. /* process (free or keep) the netbuf that held the message */
  241. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  242. /*
  243. * adf sendcomplete is required for windows only
  244. */
  245. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  246. /* free the htt_htc_pkt / HTC_PACKET object */
  247. qdf_nbuf_free(netbuf);
  248. htt_htc_pkt_free(soc, htt_pkt);
  249. }
  250. #else /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  251. void
  252. dp_htt_h2t_send_complete(void *context, HTC_PACKET *htc_pkt)
  253. {
  254. void (*send_complete_part2)(
  255. void *soc, QDF_STATUS status, qdf_nbuf_t msdu);
  256. struct htt_soc *soc = (struct htt_soc *) context;
  257. struct dp_htt_htc_pkt *htt_pkt;
  258. qdf_nbuf_t netbuf;
  259. send_complete_part2 = htc_pkt->pPktContext;
  260. htt_pkt = container_of(htc_pkt, struct dp_htt_htc_pkt, htc_pkt);
  261. /* process (free or keep) the netbuf that held the message */
  262. netbuf = (qdf_nbuf_t) htc_pkt->pNetBufContext;
  263. /*
  264. * adf sendcomplete is required for windows only
  265. */
  266. /* qdf_nbuf_set_sendcompleteflag(netbuf, TRUE); */
  267. if (send_complete_part2){
  268. send_complete_part2(
  269. htt_pkt->soc_ctxt, htc_pkt->Status, netbuf);
  270. }
  271. /* free the htt_htc_pkt / HTC_PACKET object */
  272. htt_htc_pkt_free(soc, htt_pkt);
  273. }
  274. #endif /* ENABLE_CE4_COMP_DISABLE_HTT_HTC_MISC_LIST */
  275. /**
  276. * dp_htt_h2t_add_tcl_metadata_ver_v1() - Add tcl_metadata version V1
  277. * @soc: HTT SOC handle
  278. * @msg: Pointer to nbuf
  279. *
  280. * Return: 0 on success; error code on failure
  281. */
  282. static int dp_htt_h2t_add_tcl_metadata_ver_v1(struct htt_soc *soc,
  283. qdf_nbuf_t *msg)
  284. {
  285. uint32_t *msg_word;
  286. *msg = qdf_nbuf_alloc(
  287. soc->osdev,
  288. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES),
  289. /* reserve room for the HTC header */
  290. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  291. if (!*msg)
  292. return QDF_STATUS_E_NOMEM;
  293. /*
  294. * Set the length of the message.
  295. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  296. * separately during the below call to qdf_nbuf_push_head.
  297. * The contribution from the HTC header is added separately inside HTC.
  298. */
  299. if (!qdf_nbuf_put_tail(*msg, HTT_VER_REQ_BYTES)) {
  300. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  301. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  302. __func__);
  303. return QDF_STATUS_E_FAILURE;
  304. }
  305. /* fill in the message contents */
  306. msg_word = (u_int32_t *)qdf_nbuf_data(*msg);
  307. /* rewind beyond alignment pad to get to the HTC header reserved area */
  308. qdf_nbuf_push_head(*msg, HTC_HDR_ALIGNMENT_PADDING);
  309. *msg_word = 0;
  310. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  311. return QDF_STATUS_SUCCESS;
  312. }
  313. #ifdef QCA_DP_TX_FW_METADATA_V2
  314. /**
  315. * dp_htt_h2t_add_tcl_metadata_ver_v2() - Add tcl_metadata version V2
  316. * @soc: HTT SOC handle
  317. * @msg: Pointer to nbuf
  318. *
  319. * Return: 0 on success; error code on failure
  320. */
  321. static int dp_htt_h2t_add_tcl_metadata_ver_v2(struct htt_soc *soc,
  322. qdf_nbuf_t *msg)
  323. {
  324. uint32_t *msg_word;
  325. *msg = qdf_nbuf_alloc(
  326. soc->osdev,
  327. HTT_MSG_BUF_SIZE(HTT_VER_REQ_BYTES + HTT_TCL_METADATA_VER_SZ),
  328. /* reserve room for the HTC header */
  329. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  330. if (!*msg)
  331. return QDF_STATUS_E_NOMEM;
  332. /*
  333. * Set the length of the message.
  334. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  335. * separately during the below call to qdf_nbuf_push_head.
  336. * The contribution from the HTC header is added separately inside HTC.
  337. */
  338. if (!qdf_nbuf_put_tail(*msg,
  339. HTT_VER_REQ_BYTES + HTT_TCL_METADATA_VER_SZ)) {
  340. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  341. "%s: Failed to expand head for HTT_H2T_MSG_TYPE_VERSION_REQ msg",
  342. __func__);
  343. return QDF_STATUS_E_FAILURE;
  344. }
  345. /* fill in the message contents */
  346. msg_word = (u_int32_t *)qdf_nbuf_data(*msg);
  347. /* rewind beyond alignment pad to get to the HTC header reserved area */
  348. qdf_nbuf_push_head(*msg, HTC_HDR_ALIGNMENT_PADDING);
  349. *msg_word = 0;
  350. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VERSION_REQ);
  351. /* word 1 */
  352. msg_word++;
  353. *msg_word = 0;
  354. HTT_OPTION_TLV_TAG_SET(*msg_word, HTT_OPTION_TLV_TAG_TCL_METADATA_VER);
  355. HTT_OPTION_TLV_LENGTH_SET(*msg_word, HTT_TCL_METADATA_VER_SZ);
  356. HTT_OPTION_TLV_TCL_METADATA_VER_SET(*msg_word,
  357. HTT_OPTION_TLV_TCL_METADATA_V21);
  358. return QDF_STATUS_SUCCESS;
  359. }
  360. /**
  361. * dp_htt_h2t_add_tcl_metadata_ver() - Add tcl_metadata version
  362. * @soc: HTT SOC handle
  363. * @msg: Pointer to nbuf
  364. *
  365. * Return: 0 on success; error code on failure
  366. */
  367. static int dp_htt_h2t_add_tcl_metadata_ver(struct htt_soc *soc, qdf_nbuf_t *msg)
  368. {
  369. /* Use tcl_metadata_v1 when NSS offload is enabled */
  370. if (wlan_cfg_get_dp_soc_nss_cfg(soc->dp_soc->wlan_cfg_ctx) ||
  371. soc->dp_soc->cdp_soc.ol_ops->get_con_mode() == QDF_GLOBAL_FTM_MODE)
  372. return dp_htt_h2t_add_tcl_metadata_ver_v1(soc, msg);
  373. else
  374. return dp_htt_h2t_add_tcl_metadata_ver_v2(soc, msg);
  375. }
  376. #else
  377. static int dp_htt_h2t_add_tcl_metadata_ver(struct htt_soc *soc, qdf_nbuf_t *msg)
  378. {
  379. return dp_htt_h2t_add_tcl_metadata_ver_v1(soc, msg);
  380. }
  381. #endif
  382. /**
  383. * htt_h2t_ver_req_msg() - Send HTT version request message to target
  384. * @soc: HTT SOC handle
  385. *
  386. * Return: 0 on success; error code on failure
  387. */
  388. static int htt_h2t_ver_req_msg(struct htt_soc *soc)
  389. {
  390. struct dp_htt_htc_pkt *pkt;
  391. qdf_nbuf_t msg = NULL;
  392. QDF_STATUS status;
  393. status = dp_htt_h2t_add_tcl_metadata_ver(soc, &msg);
  394. if (status != QDF_STATUS_SUCCESS)
  395. return status;
  396. pkt = htt_htc_pkt_alloc(soc);
  397. if (!pkt) {
  398. qdf_nbuf_free(msg);
  399. return QDF_STATUS_E_FAILURE;
  400. }
  401. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  402. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  403. dp_htt_h2t_send_complete_free_netbuf, qdf_nbuf_data(msg),
  404. qdf_nbuf_len(msg), soc->htc_endpoint,
  405. HTC_TX_PACKET_TAG_RTPM_PUT_RC);
  406. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  407. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_VERSION_REQ,
  408. NULL);
  409. if (status != QDF_STATUS_SUCCESS) {
  410. qdf_nbuf_free(msg);
  411. htt_htc_pkt_free(soc, pkt);
  412. }
  413. return status;
  414. }
  415. #ifdef IPA_OPT_WIFI_DP
  416. QDF_STATUS htt_h2t_rx_cce_super_rule_setup(struct htt_soc *soc, void *param)
  417. {
  418. struct wifi_dp_flt_setup *flt_params =
  419. (struct wifi_dp_flt_setup *)param;
  420. struct dp_htt_htc_pkt *pkt;
  421. qdf_nbuf_t msg;
  422. uint32_t *msg_word;
  423. uint8_t *htt_logger_bufp;
  424. uint16_t ver = 0;
  425. uint8_t i, valid = 0;
  426. uint8_t num_filters = flt_params->num_filters;
  427. uint8_t pdev_id = flt_params->pdev_id;
  428. uint8_t op = flt_params->op;
  429. uint16_t ipv4 = qdf_ntohs(QDF_NBUF_TRAC_IPV4_ETH_TYPE);
  430. uint16_t ipv6 = qdf_ntohs(QDF_NBUF_TRAC_IPV6_ETH_TYPE);
  431. QDF_STATUS status;
  432. if (num_filters > RX_CCE_SUPER_RULE_SETUP_NUM) {
  433. dp_htt_err("Wrong filter count %d", num_filters);
  434. return QDF_STATUS_FILT_REQ_ERROR;
  435. }
  436. msg = qdf_nbuf_alloc(soc->osdev,
  437. HTT_MSG_BUF_SIZE(HTT_RX_CCE_SUPER_RULE_SETUP_SZ),
  438. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4,
  439. true);
  440. if (!msg) {
  441. dp_htt_err("Fail to allocate SUPER_RULE_SETUP msg ");
  442. return QDF_STATUS_E_FAILURE;
  443. }
  444. qdf_nbuf_put_tail(msg, HTT_RX_CCE_SUPER_RULE_SETUP_SZ);
  445. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  446. memset(msg_word, 0, HTT_RX_CCE_SUPER_RULE_SETUP_SZ);
  447. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  448. htt_logger_bufp = (uint8_t *)msg_word;
  449. *msg_word = 0;
  450. HTT_H2T_MSG_TYPE_SET(*msg_word,
  451. HTT_H2T_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP);
  452. HTT_RX_CCE_SUPER_RULE_SETUP_PDEV_ID_SET(*msg_word, pdev_id);
  453. HTT_RX_CCE_SUPER_RULE_SETUP_OPERATION_SET(*msg_word, op);
  454. /* Set cce_super_rule_params */
  455. for (i = 0; i < RX_CCE_SUPER_RULE_SETUP_NUM; i++) {
  456. valid = flt_params->flt_addr_params[i].valid;
  457. ver = flt_params->flt_addr_params[i].l3_type;
  458. msg_word++;
  459. if (ver == ipv4) {
  460. HTT_RX_CCE_SUPER_RULE_SETUP_IPV4_ADDR_ARRAY_SET(
  461. msg_word,
  462. flt_params->flt_addr_params[i].src_ipv4_addr);
  463. } else if (ver == ipv6) {
  464. HTT_RX_CCE_SUPER_RULE_SETUP_IPV6_ADDR_ARRAY_SET(
  465. msg_word,
  466. flt_params->flt_addr_params[i].src_ipv6_addr);
  467. } else {
  468. dp_htt_debug("Filter %d not in use.", i);
  469. }
  470. /* move uint32_t *msg_word by IPV6 addr size */
  471. msg_word += (QDF_IPV6_ADDR_SIZE / 4);
  472. if (ver == ipv4) {
  473. HTT_RX_CCE_SUPER_RULE_SETUP_IPV4_ADDR_ARRAY_SET(
  474. msg_word,
  475. flt_params->flt_addr_params[i].dst_ipv4_addr);
  476. } else if (ver == ipv6) {
  477. HTT_RX_CCE_SUPER_RULE_SETUP_IPV6_ADDR_ARRAY_SET(
  478. msg_word,
  479. flt_params->flt_addr_params[i].dst_ipv6_addr);
  480. } else {
  481. dp_htt_debug("Filter %d not in use.", i);
  482. }
  483. /* move uint32_t *msg_word by IPV6 addr size */
  484. msg_word += (QDF_IPV6_ADDR_SIZE / 4);
  485. HTT_RX_CCE_SUPER_RULE_SETUP_L3_TYPE_SET(*msg_word, ver);
  486. HTT_RX_CCE_SUPER_RULE_SETUP_L4_TYPE_SET(
  487. *msg_word,
  488. flt_params->flt_addr_params[i].l4_type);
  489. HTT_RX_CCE_SUPER_RULE_SETUP_IS_VALID_SET(*msg_word, valid);
  490. msg_word++;
  491. HTT_RX_CCE_SUPER_RULE_SETUP_L4_SRC_PORT_SET(
  492. *msg_word,
  493. flt_params->flt_addr_params[i].src_port);
  494. HTT_RX_CCE_SUPER_RULE_SETUP_L4_DST_PORT_SET(
  495. *msg_word,
  496. flt_params->flt_addr_params[i].dst_port);
  497. dp_info("opt_dp:: pdev: %u ver %u, flt_num %u, op %u",
  498. pdev_id, ver, i, op);
  499. dp_info("valid %u", valid);
  500. }
  501. pkt = htt_htc_pkt_alloc(soc);
  502. if (!pkt) {
  503. dp_htt_err("Fail to allocate dp_htt_htc_pkt buffer");
  504. qdf_assert(0);
  505. qdf_nbuf_free(msg);
  506. return QDF_STATUS_E_NOMEM;
  507. }
  508. pkt->soc_ctxt = NULL; /*not used during send-done callback */
  509. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  510. dp_htt_h2t_send_complete_free_netbuf,
  511. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  512. soc->htc_endpoint,
  513. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  514. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  515. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  516. HTT_H2T_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP,
  517. htt_logger_bufp);
  518. if (status != QDF_STATUS_SUCCESS) {
  519. qdf_nbuf_free(msg);
  520. htt_htc_pkt_free(soc, pkt);
  521. }
  522. return status;
  523. }
  524. #endif /* IPA_OPT_WIFI_DP */
  525. int htt_srng_setup(struct htt_soc *soc, int mac_id,
  526. hal_ring_handle_t hal_ring_hdl,
  527. int hal_ring_type)
  528. {
  529. struct dp_htt_htc_pkt *pkt;
  530. qdf_nbuf_t htt_msg;
  531. uint32_t *msg_word;
  532. struct hal_srng_params srng_params;
  533. qdf_dma_addr_t hp_addr, tp_addr;
  534. uint32_t ring_entry_size =
  535. hal_srng_get_entrysize(soc->hal_soc, hal_ring_type);
  536. int htt_ring_type, htt_ring_id;
  537. uint8_t *htt_logger_bufp;
  538. int target_pdev_id;
  539. int lmac_id = dp_get_lmac_id_for_pdev_id(soc->dp_soc, 0, mac_id);
  540. QDF_STATUS status;
  541. /* Sizes should be set in 4-byte words */
  542. ring_entry_size = ring_entry_size >> 2;
  543. htt_msg = qdf_nbuf_alloc(soc->osdev,
  544. HTT_MSG_BUF_SIZE(HTT_SRING_SETUP_SZ),
  545. /* reserve room for the HTC header */
  546. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  547. if (!htt_msg) {
  548. dp_err("htt_msg alloc failed ring type %d", hal_ring_type);
  549. goto fail0;
  550. }
  551. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  552. hp_addr = hal_srng_get_hp_addr(soc->hal_soc, hal_ring_hdl);
  553. tp_addr = hal_srng_get_tp_addr(soc->hal_soc, hal_ring_hdl);
  554. switch (hal_ring_type) {
  555. case RXDMA_BUF:
  556. #ifdef QCA_HOST2FW_RXBUF_RING
  557. if (srng_params.ring_id ==
  558. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  559. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  560. htt_ring_id = HTT_HOST1_TO_FW_RXBUF_RING;
  561. htt_ring_type = HTT_SW_TO_SW_RING;
  562. #ifdef IPA_OFFLOAD
  563. } else if (srng_params.ring_id ==
  564. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF1 +
  565. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  566. htt_ring_id = HTT_HOST2_TO_FW_RXBUF_RING;
  567. htt_ring_type = HTT_SW_TO_SW_RING;
  568. #ifdef IPA_WDI3_VLAN_SUPPORT
  569. } else if (srng_params.ring_id ==
  570. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF2 +
  571. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  572. htt_ring_id = HTT_HOST3_TO_FW_RXBUF_RING;
  573. htt_ring_type = HTT_SW_TO_SW_RING;
  574. #endif
  575. #endif
  576. #else
  577. if (srng_params.ring_id ==
  578. (HAL_SRNG_WMAC1_SW2RXDMA0_BUF0 +
  579. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  580. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  581. htt_ring_type = HTT_SW_TO_HW_RING;
  582. #endif
  583. } else if (srng_params.ring_id ==
  584. (HAL_SRNG_WMAC1_SW2RXDMA1_BUF +
  585. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  586. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  587. htt_ring_type = HTT_SW_TO_HW_RING;
  588. #ifdef FEATURE_DIRECT_LINK
  589. } else if (srng_params.ring_id ==
  590. (HAL_SRNG_WMAC1_RX_DIRECT_LINK_SW_REFILL_RING +
  591. (lmac_id * HAL_MAX_RINGS_PER_LMAC))) {
  592. htt_ring_id = HTT_LPASS_TO_FW_RXBUF_RING;
  593. htt_ring_type = HTT_SW_TO_SW_RING;
  594. #endif
  595. } else {
  596. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  597. "%s: Ring %d currently not supported",
  598. __func__, srng_params.ring_id);
  599. goto fail1;
  600. }
  601. break;
  602. case RXDMA_MONITOR_BUF:
  603. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  604. RXDMA_MONITOR_BUF);
  605. htt_ring_type = HTT_SW_TO_HW_RING;
  606. break;
  607. case RXDMA_MONITOR_STATUS:
  608. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  609. htt_ring_type = HTT_SW_TO_HW_RING;
  610. break;
  611. case RXDMA_MONITOR_DST:
  612. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  613. RXDMA_MONITOR_DST);
  614. htt_ring_type = HTT_HW_TO_SW_RING;
  615. break;
  616. case RXDMA_MONITOR_DESC:
  617. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  618. htt_ring_type = HTT_SW_TO_HW_RING;
  619. break;
  620. case RXDMA_DST:
  621. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  622. htt_ring_type = HTT_HW_TO_SW_RING;
  623. break;
  624. case TX_MONITOR_BUF:
  625. htt_ring_id = HTT_TX_MON_HOST2MON_BUF_RING;
  626. htt_ring_type = HTT_SW_TO_HW_RING;
  627. break;
  628. case TX_MONITOR_DST:
  629. htt_ring_id = HTT_TX_MON_MON2HOST_DEST_RING;
  630. htt_ring_type = HTT_HW_TO_SW_RING;
  631. break;
  632. case SW2RXDMA_LINK_RELEASE:
  633. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  634. htt_ring_type = HTT_SW_TO_HW_RING;
  635. break;
  636. default:
  637. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  638. "%s: Ring currently not supported", __func__);
  639. goto fail1;
  640. }
  641. dp_info("ring_type %d ring_id %d htt_ring_id %d hp_addr 0x%llx tp_addr 0x%llx",
  642. hal_ring_type, srng_params.ring_id, htt_ring_id,
  643. (uint64_t)hp_addr,
  644. (uint64_t)tp_addr);
  645. /*
  646. * Set the length of the message.
  647. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  648. * separately during the below call to qdf_nbuf_push_head.
  649. * The contribution from the HTC header is added separately inside HTC.
  650. */
  651. if (qdf_nbuf_put_tail(htt_msg, HTT_SRING_SETUP_SZ) == NULL) {
  652. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  653. "%s: Failed to expand head for SRING_SETUP msg",
  654. __func__);
  655. return QDF_STATUS_E_FAILURE;
  656. }
  657. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  658. /* rewind beyond alignment pad to get to the HTC header reserved area */
  659. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  660. /* word 0 */
  661. *msg_word = 0;
  662. htt_logger_bufp = (uint8_t *)msg_word;
  663. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_SRING_SETUP);
  664. target_pdev_id =
  665. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, mac_id);
  666. if ((htt_ring_type == HTT_SW_TO_HW_RING) ||
  667. (htt_ring_type == HTT_HW_TO_SW_RING))
  668. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, target_pdev_id);
  669. else
  670. HTT_SRING_SETUP_PDEV_ID_SET(*msg_word, mac_id);
  671. dp_info("mac_id %d", mac_id);
  672. HTT_SRING_SETUP_RING_TYPE_SET(*msg_word, htt_ring_type);
  673. /* TODO: Discuss with FW on changing this to unique ID and using
  674. * htt_ring_type to send the type of ring
  675. */
  676. HTT_SRING_SETUP_RING_ID_SET(*msg_word, htt_ring_id);
  677. /* word 1 */
  678. msg_word++;
  679. *msg_word = 0;
  680. HTT_SRING_SETUP_RING_BASE_ADDR_LO_SET(*msg_word,
  681. srng_params.ring_base_paddr & 0xffffffff);
  682. /* word 2 */
  683. msg_word++;
  684. *msg_word = 0;
  685. HTT_SRING_SETUP_RING_BASE_ADDR_HI_SET(*msg_word,
  686. (uint64_t)srng_params.ring_base_paddr >> 32);
  687. /* word 3 */
  688. msg_word++;
  689. *msg_word = 0;
  690. HTT_SRING_SETUP_ENTRY_SIZE_SET(*msg_word, ring_entry_size);
  691. HTT_SRING_SETUP_RING_SIZE_SET(*msg_word,
  692. (ring_entry_size * srng_params.num_entries));
  693. dp_info("entry_size %d", ring_entry_size);
  694. dp_info("num_entries %d", srng_params.num_entries);
  695. dp_info("ring_size %d", (ring_entry_size * srng_params.num_entries));
  696. if (htt_ring_type == HTT_SW_TO_HW_RING)
  697. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_LOOPCOUNT_DISABLE_SET(
  698. *msg_word, 1);
  699. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_MSI_SWAP_SET(*msg_word,
  700. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  701. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_TLV_SWAP_SET(*msg_word,
  702. !!(srng_params.flags & HAL_SRNG_DATA_TLV_SWAP));
  703. HTT_SRING_SETUP_RING_MISC_CFG_FLAG_HOST_FW_SWAP_SET(*msg_word,
  704. !!(srng_params.flags & HAL_SRNG_RING_PTR_SWAP));
  705. /* word 4 */
  706. msg_word++;
  707. *msg_word = 0;
  708. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  709. hp_addr & 0xffffffff);
  710. /* word 5 */
  711. msg_word++;
  712. *msg_word = 0;
  713. HTT_SRING_SETUP_HEAD_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  714. (uint64_t)hp_addr >> 32);
  715. /* word 6 */
  716. msg_word++;
  717. *msg_word = 0;
  718. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_LO_SET(*msg_word,
  719. tp_addr & 0xffffffff);
  720. /* word 7 */
  721. msg_word++;
  722. *msg_word = 0;
  723. HTT_SRING_SETUP_TAIL_OFFSET32_REMOTE_BASE_ADDR_HI_SET(*msg_word,
  724. (uint64_t)tp_addr >> 32);
  725. /* word 8 */
  726. msg_word++;
  727. *msg_word = 0;
  728. HTT_SRING_SETUP_RING_MSI_ADDR_LO_SET(*msg_word,
  729. srng_params.msi_addr & 0xffffffff);
  730. /* word 9 */
  731. msg_word++;
  732. *msg_word = 0;
  733. HTT_SRING_SETUP_RING_MSI_ADDR_HI_SET(*msg_word,
  734. (uint64_t)(srng_params.msi_addr) >> 32);
  735. /* word 10 */
  736. msg_word++;
  737. *msg_word = 0;
  738. HTT_SRING_SETUP_RING_MSI_DATA_SET(*msg_word,
  739. qdf_cpu_to_le32(srng_params.msi_data));
  740. /* word 11 */
  741. msg_word++;
  742. *msg_word = 0;
  743. HTT_SRING_SETUP_INTR_BATCH_COUNTER_TH_SET(*msg_word,
  744. srng_params.intr_batch_cntr_thres_entries *
  745. ring_entry_size);
  746. HTT_SRING_SETUP_INTR_TIMER_TH_SET(*msg_word,
  747. srng_params.intr_timer_thres_us >> 3);
  748. /* word 12 */
  749. msg_word++;
  750. *msg_word = 0;
  751. if (srng_params.flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  752. /* TODO: Setting low threshold to 1/8th of ring size - see
  753. * if this needs to be configurable
  754. */
  755. HTT_SRING_SETUP_INTR_LOW_TH_SET(*msg_word,
  756. srng_params.low_threshold);
  757. }
  758. /* "response_required" field should be set if a HTT response message is
  759. * required after setting up the ring.
  760. */
  761. pkt = htt_htc_pkt_alloc(soc);
  762. if (!pkt) {
  763. dp_err("pkt alloc failed, ring_type %d ring_id %d htt_ring_id %d",
  764. hal_ring_type, srng_params.ring_id, htt_ring_id);
  765. goto fail1;
  766. }
  767. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  768. SET_HTC_PACKET_INFO_TX(
  769. &pkt->htc_pkt,
  770. dp_htt_h2t_send_complete_free_netbuf,
  771. qdf_nbuf_data(htt_msg),
  772. qdf_nbuf_len(htt_msg),
  773. soc->htc_endpoint,
  774. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  775. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  776. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_SRING_SETUP,
  777. htt_logger_bufp);
  778. if (status != QDF_STATUS_SUCCESS) {
  779. qdf_nbuf_free(htt_msg);
  780. htt_htc_pkt_free(soc, pkt);
  781. }
  782. return status;
  783. fail1:
  784. qdf_nbuf_free(htt_msg);
  785. fail0:
  786. return QDF_STATUS_E_FAILURE;
  787. }
  788. qdf_export_symbol(htt_srng_setup);
  789. #ifdef QCA_SUPPORT_FULL_MON
  790. /**
  791. * htt_h2t_full_mon_cfg() - Send full monitor configuration msg to FW
  792. *
  793. * @htt_soc: HTT Soc handle
  794. * @pdev_id: Radio id
  795. * @config: enabled/disable configuration
  796. *
  797. * Return: Success when HTT message is sent, error on failure
  798. */
  799. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  800. uint8_t pdev_id,
  801. enum dp_full_mon_config config)
  802. {
  803. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  804. struct dp_htt_htc_pkt *pkt;
  805. qdf_nbuf_t htt_msg;
  806. uint32_t *msg_word;
  807. uint8_t *htt_logger_bufp;
  808. htt_msg = qdf_nbuf_alloc(soc->osdev,
  809. HTT_MSG_BUF_SIZE(
  810. HTT_RX_FULL_MONITOR_MODE_SETUP_SZ),
  811. /* reserve room for the HTC header */
  812. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  813. 4,
  814. TRUE);
  815. if (!htt_msg)
  816. return QDF_STATUS_E_FAILURE;
  817. /*
  818. * Set the length of the message.
  819. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  820. * separately during the below call to qdf_nbuf_push_head.
  821. * The contribution from the HTC header is added separately inside HTC.
  822. */
  823. if (!qdf_nbuf_put_tail(htt_msg, HTT_RX_FULL_MONITOR_MODE_SETUP_SZ)) {
  824. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  825. "%s: Failed to expand head for RX Ring Cfg msg",
  826. __func__);
  827. goto fail1;
  828. }
  829. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  830. /* rewind beyond alignment pad to get to the HTC header reserved area */
  831. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  832. /* word 0 */
  833. *msg_word = 0;
  834. htt_logger_bufp = (uint8_t *)msg_word;
  835. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE);
  836. HTT_RX_FULL_MONITOR_MODE_OPERATION_PDEV_ID_SET(
  837. *msg_word, DP_SW2HW_MACID(pdev_id));
  838. msg_word++;
  839. *msg_word = 0;
  840. /* word 1 */
  841. if (config == DP_FULL_MON_ENABLE) {
  842. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  843. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, true);
  844. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, true);
  845. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  846. } else if (config == DP_FULL_MON_DISABLE) {
  847. /* As per MAC team's suggestion, While disabling full monitor
  848. * mode, Set 'en' bit to true in full monitor mode register.
  849. */
  850. HTT_RX_FULL_MONITOR_MODE_ENABLE_SET(*msg_word, true);
  851. HTT_RX_FULL_MONITOR_MODE_ZERO_MPDU_SET(*msg_word, false);
  852. HTT_RX_FULL_MONITOR_MODE_NON_ZERO_MPDU_SET(*msg_word, false);
  853. HTT_RX_FULL_MONITOR_MODE_RELEASE_RINGS_SET(*msg_word, 0x2);
  854. }
  855. pkt = htt_htc_pkt_alloc(soc);
  856. if (!pkt) {
  857. qdf_err("HTC packet allocation failed");
  858. goto fail1;
  859. }
  860. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  861. SET_HTC_PACKET_INFO_TX(
  862. &pkt->htc_pkt,
  863. dp_htt_h2t_send_complete_free_netbuf,
  864. qdf_nbuf_data(htt_msg),
  865. qdf_nbuf_len(htt_msg),
  866. soc->htc_endpoint,
  867. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  868. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  869. qdf_debug("config: %d", config);
  870. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FULL_MONITOR_MODE,
  871. htt_logger_bufp);
  872. return QDF_STATUS_SUCCESS;
  873. fail1:
  874. qdf_nbuf_free(htt_msg);
  875. return QDF_STATUS_E_FAILURE;
  876. }
  877. qdf_export_symbol(htt_h2t_full_mon_cfg);
  878. #else
  879. int htt_h2t_full_mon_cfg(struct htt_soc *htt_soc,
  880. uint8_t pdev_id,
  881. enum dp_full_mon_config config)
  882. {
  883. return 0;
  884. }
  885. qdf_export_symbol(htt_h2t_full_mon_cfg);
  886. #endif
  887. #ifdef QCA_UNDECODED_METADATA_SUPPORT
  888. static inline void
  889. dp_mon_rx_enable_phy_errors(uint32_t *msg_word,
  890. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  891. {
  892. if (htt_tlv_filter->phy_err_filter_valid) {
  893. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_SET
  894. (*msg_word, htt_tlv_filter->fp_phy_err);
  895. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_BUF_SRC_SET
  896. (*msg_word, htt_tlv_filter->fp_phy_err_buf_src);
  897. HTT_RX_RING_SELECTION_CFG_FP_PHY_ERR_BUF_DEST_SET
  898. (*msg_word, htt_tlv_filter->fp_phy_err_buf_dest);
  899. /* word 12*/
  900. msg_word++;
  901. *msg_word = 0;
  902. HTT_RX_RING_SELECTION_CFG_PHY_ERR_MASK_SET
  903. (*msg_word, htt_tlv_filter->phy_err_mask);
  904. /* word 13*/
  905. msg_word++;
  906. *msg_word = 0;
  907. HTT_RX_RING_SELECTION_CFG_PHY_ERR_MASK_CONT_SET
  908. (*msg_word, htt_tlv_filter->phy_err_mask_cont);
  909. }
  910. }
  911. #else
  912. static inline void
  913. dp_mon_rx_enable_phy_errors(uint32_t *msg_word,
  914. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  915. {
  916. }
  917. #endif
  918. int htt_h2t_rx_ring_cfg(struct htt_soc *htt_soc, int pdev_id,
  919. hal_ring_handle_t hal_ring_hdl,
  920. int hal_ring_type, int ring_buf_size,
  921. struct htt_rx_ring_tlv_filter *htt_tlv_filter)
  922. {
  923. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  924. struct dp_htt_htc_pkt *pkt;
  925. qdf_nbuf_t htt_msg;
  926. uint32_t *msg_word;
  927. uint32_t *msg_word_data;
  928. struct hal_srng_params srng_params;
  929. uint32_t htt_ring_type, htt_ring_id;
  930. uint32_t tlv_filter;
  931. uint8_t *htt_logger_bufp;
  932. struct wlan_cfg_dp_soc_ctxt *wlan_cfg_ctx = soc->dp_soc->wlan_cfg_ctx;
  933. uint32_t mon_drop_th = wlan_cfg_get_mon_drop_thresh(wlan_cfg_ctx);
  934. int target_pdev_id;
  935. QDF_STATUS status;
  936. htt_msg = qdf_nbuf_alloc(soc->osdev,
  937. HTT_MSG_BUF_SIZE(HTT_RX_RING_SELECTION_CFG_SZ),
  938. /* reserve room for the HTC header */
  939. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  940. if (!htt_msg) {
  941. dp_err("htt_msg alloc failed ring type %d", hal_ring_type);
  942. goto fail0;
  943. }
  944. hal_get_srng_params(soc->hal_soc, hal_ring_hdl, &srng_params);
  945. switch (hal_ring_type) {
  946. case RXDMA_BUF:
  947. htt_ring_id = HTT_RXDMA_HOST_BUF_RING;
  948. htt_ring_type = HTT_SW_TO_HW_RING;
  949. break;
  950. case RXDMA_MONITOR_BUF:
  951. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  952. RXDMA_MONITOR_BUF);
  953. htt_ring_type = HTT_SW_TO_HW_RING;
  954. break;
  955. case RXDMA_MONITOR_STATUS:
  956. htt_ring_id = HTT_RXDMA_MONITOR_STATUS_RING;
  957. htt_ring_type = HTT_SW_TO_HW_RING;
  958. break;
  959. case RXDMA_MONITOR_DST:
  960. htt_ring_id = dp_htt_get_mon_htt_ring_id(soc->dp_soc,
  961. RXDMA_MONITOR_DST);
  962. htt_ring_type = HTT_HW_TO_SW_RING;
  963. break;
  964. case RXDMA_MONITOR_DESC:
  965. htt_ring_id = HTT_RXDMA_MONITOR_DESC_RING;
  966. htt_ring_type = HTT_SW_TO_HW_RING;
  967. break;
  968. case RXDMA_DST:
  969. htt_ring_id = HTT_RXDMA_NON_MONITOR_DEST_RING;
  970. htt_ring_type = HTT_HW_TO_SW_RING;
  971. break;
  972. default:
  973. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  974. "%s: Ring currently not supported", __func__);
  975. goto fail1;
  976. }
  977. dp_info("ring_type %d ring_id %d htt_ring_id %d",
  978. hal_ring_type, srng_params.ring_id, htt_ring_id);
  979. /*
  980. * Set the length of the message.
  981. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  982. * separately during the below call to qdf_nbuf_push_head.
  983. * The contribution from the HTC header is added separately inside HTC.
  984. */
  985. if (qdf_nbuf_put_tail(htt_msg, HTT_RX_RING_SELECTION_CFG_SZ) == NULL) {
  986. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  987. "%s: Failed to expand head for RX Ring Cfg msg",
  988. __func__);
  989. goto fail1; /* failure */
  990. }
  991. msg_word = (uint32_t *)qdf_nbuf_data(htt_msg);
  992. /* rewind beyond alignment pad to get to the HTC header reserved area */
  993. qdf_nbuf_push_head(htt_msg, HTC_HDR_ALIGNMENT_PADDING);
  994. /* word 0 */
  995. htt_logger_bufp = (uint8_t *)msg_word;
  996. *msg_word = 0;
  997. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG);
  998. /* applicable only for post Li */
  999. dp_rx_mon_enable(soc->dp_soc, msg_word, htt_tlv_filter);
  1000. /*
  1001. * pdev_id is indexed from 0 whereas mac_id is indexed from 1
  1002. * SW_TO_SW and SW_TO_HW rings are unaffected by this
  1003. */
  1004. target_pdev_id =
  1005. dp_get_target_pdev_id_for_host_pdev_id(soc->dp_soc, pdev_id);
  1006. if (htt_ring_type == HTT_SW_TO_SW_RING ||
  1007. htt_ring_type == HTT_SW_TO_HW_RING ||
  1008. htt_ring_type == HTT_HW_TO_SW_RING)
  1009. HTT_RX_RING_SELECTION_CFG_PDEV_ID_SET(*msg_word,
  1010. target_pdev_id);
  1011. /* TODO: Discuss with FW on changing this to unique ID and using
  1012. * htt_ring_type to send the type of ring
  1013. */
  1014. HTT_RX_RING_SELECTION_CFG_RING_ID_SET(*msg_word, htt_ring_id);
  1015. HTT_RX_RING_SELECTION_CFG_STATUS_TLV_SET(*msg_word,
  1016. !!(srng_params.flags & HAL_SRNG_MSI_SWAP));
  1017. HTT_RX_RING_SELECTION_CFG_RX_OFFSETS_VALID_SET(*msg_word,
  1018. htt_tlv_filter->offset_valid);
  1019. if (mon_drop_th > 0)
  1020. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1021. 1);
  1022. else
  1023. HTT_RX_RING_SELECTION_CFG_DROP_THRESHOLD_VALID_SET(*msg_word,
  1024. 0);
  1025. /* word 1 */
  1026. msg_word++;
  1027. *msg_word = 0;
  1028. HTT_RX_RING_SELECTION_CFG_RING_BUFFER_SIZE_SET(*msg_word,
  1029. ring_buf_size);
  1030. dp_mon_rx_packet_length_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1031. dp_mon_rx_hdr_length_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1032. dp_mon_rx_mac_filter_set(soc->dp_soc, msg_word, htt_tlv_filter);
  1033. /* word 2 */
  1034. msg_word++;
  1035. *msg_word = 0;
  1036. if (htt_tlv_filter->enable_fp) {
  1037. /* TYPE: MGMT */
  1038. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1039. FP, MGMT, 0000,
  1040. (htt_tlv_filter->fp_mgmt_filter &
  1041. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1042. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1043. FP, MGMT, 0001,
  1044. (htt_tlv_filter->fp_mgmt_filter &
  1045. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1046. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1047. FP, MGMT, 0010,
  1048. (htt_tlv_filter->fp_mgmt_filter &
  1049. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1050. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1051. FP, MGMT, 0011,
  1052. (htt_tlv_filter->fp_mgmt_filter &
  1053. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1054. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1055. FP, MGMT, 0100,
  1056. (htt_tlv_filter->fp_mgmt_filter &
  1057. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1058. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1059. FP, MGMT, 0101,
  1060. (htt_tlv_filter->fp_mgmt_filter &
  1061. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1062. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1063. FP, MGMT, 0110,
  1064. (htt_tlv_filter->fp_mgmt_filter &
  1065. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1066. /* reserved */
  1067. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, FP,
  1068. MGMT, 0111,
  1069. (htt_tlv_filter->fp_mgmt_filter &
  1070. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1071. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1072. FP, MGMT, 1000,
  1073. (htt_tlv_filter->fp_mgmt_filter &
  1074. FILTER_MGMT_BEACON) ? 1 : 0);
  1075. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1076. FP, MGMT, 1001,
  1077. (htt_tlv_filter->fp_mgmt_filter &
  1078. FILTER_MGMT_ATIM) ? 1 : 0);
  1079. }
  1080. if (htt_tlv_filter->enable_md) {
  1081. /* TYPE: MGMT */
  1082. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1083. MD, MGMT, 0000,
  1084. (htt_tlv_filter->md_mgmt_filter &
  1085. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1086. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1087. MD, MGMT, 0001,
  1088. (htt_tlv_filter->md_mgmt_filter &
  1089. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1090. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1091. MD, MGMT, 0010,
  1092. (htt_tlv_filter->md_mgmt_filter &
  1093. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1094. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1095. MD, MGMT, 0011,
  1096. (htt_tlv_filter->md_mgmt_filter &
  1097. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1098. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1099. MD, MGMT, 0100,
  1100. (htt_tlv_filter->md_mgmt_filter &
  1101. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1102. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1103. MD, MGMT, 0101,
  1104. (htt_tlv_filter->md_mgmt_filter &
  1105. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1106. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1107. MD, MGMT, 0110,
  1108. (htt_tlv_filter->md_mgmt_filter &
  1109. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1110. /* reserved */
  1111. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MD,
  1112. MGMT, 0111,
  1113. (htt_tlv_filter->md_mgmt_filter &
  1114. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1115. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1116. MD, MGMT, 1000,
  1117. (htt_tlv_filter->md_mgmt_filter &
  1118. FILTER_MGMT_BEACON) ? 1 : 0);
  1119. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1120. MD, MGMT, 1001,
  1121. (htt_tlv_filter->md_mgmt_filter &
  1122. FILTER_MGMT_ATIM) ? 1 : 0);
  1123. }
  1124. if (htt_tlv_filter->enable_mo) {
  1125. /* TYPE: MGMT */
  1126. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1127. MO, MGMT, 0000,
  1128. (htt_tlv_filter->mo_mgmt_filter &
  1129. FILTER_MGMT_ASSOC_REQ) ? 1 : 0);
  1130. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1131. MO, MGMT, 0001,
  1132. (htt_tlv_filter->mo_mgmt_filter &
  1133. FILTER_MGMT_ASSOC_RES) ? 1 : 0);
  1134. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1135. MO, MGMT, 0010,
  1136. (htt_tlv_filter->mo_mgmt_filter &
  1137. FILTER_MGMT_REASSOC_REQ) ? 1 : 0);
  1138. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1139. MO, MGMT, 0011,
  1140. (htt_tlv_filter->mo_mgmt_filter &
  1141. FILTER_MGMT_REASSOC_RES) ? 1 : 0);
  1142. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1143. MO, MGMT, 0100,
  1144. (htt_tlv_filter->mo_mgmt_filter &
  1145. FILTER_MGMT_PROBE_REQ) ? 1 : 0);
  1146. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1147. MO, MGMT, 0101,
  1148. (htt_tlv_filter->mo_mgmt_filter &
  1149. FILTER_MGMT_PROBE_RES) ? 1 : 0);
  1150. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1151. MO, MGMT, 0110,
  1152. (htt_tlv_filter->mo_mgmt_filter &
  1153. FILTER_MGMT_TIM_ADVT) ? 1 : 0);
  1154. /* reserved */
  1155. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0, MO,
  1156. MGMT, 0111,
  1157. (htt_tlv_filter->mo_mgmt_filter &
  1158. FILTER_MGMT_RESERVED_7) ? 1 : 0);
  1159. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1160. MO, MGMT, 1000,
  1161. (htt_tlv_filter->mo_mgmt_filter &
  1162. FILTER_MGMT_BEACON) ? 1 : 0);
  1163. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG0,
  1164. MO, MGMT, 1001,
  1165. (htt_tlv_filter->mo_mgmt_filter &
  1166. FILTER_MGMT_ATIM) ? 1 : 0);
  1167. }
  1168. /* word 3 */
  1169. msg_word++;
  1170. *msg_word = 0;
  1171. if (htt_tlv_filter->enable_fp) {
  1172. /* TYPE: MGMT */
  1173. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1174. FP, MGMT, 1010,
  1175. (htt_tlv_filter->fp_mgmt_filter &
  1176. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1177. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1178. FP, MGMT, 1011,
  1179. (htt_tlv_filter->fp_mgmt_filter &
  1180. FILTER_MGMT_AUTH) ? 1 : 0);
  1181. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1182. FP, MGMT, 1100,
  1183. (htt_tlv_filter->fp_mgmt_filter &
  1184. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1185. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1186. FP, MGMT, 1101,
  1187. (htt_tlv_filter->fp_mgmt_filter &
  1188. FILTER_MGMT_ACTION) ? 1 : 0);
  1189. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1190. FP, MGMT, 1110,
  1191. (htt_tlv_filter->fp_mgmt_filter &
  1192. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1193. /* reserved*/
  1194. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, FP,
  1195. MGMT, 1111,
  1196. (htt_tlv_filter->fp_mgmt_filter &
  1197. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1198. }
  1199. if (htt_tlv_filter->enable_md) {
  1200. /* TYPE: MGMT */
  1201. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1202. MD, MGMT, 1010,
  1203. (htt_tlv_filter->md_mgmt_filter &
  1204. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1205. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1206. MD, MGMT, 1011,
  1207. (htt_tlv_filter->md_mgmt_filter &
  1208. FILTER_MGMT_AUTH) ? 1 : 0);
  1209. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1210. MD, MGMT, 1100,
  1211. (htt_tlv_filter->md_mgmt_filter &
  1212. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1213. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1214. MD, MGMT, 1101,
  1215. (htt_tlv_filter->md_mgmt_filter &
  1216. FILTER_MGMT_ACTION) ? 1 : 0);
  1217. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1218. MD, MGMT, 1110,
  1219. (htt_tlv_filter->md_mgmt_filter &
  1220. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1221. }
  1222. if (htt_tlv_filter->enable_mo) {
  1223. /* TYPE: MGMT */
  1224. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1225. MO, MGMT, 1010,
  1226. (htt_tlv_filter->mo_mgmt_filter &
  1227. FILTER_MGMT_DISASSOC) ? 1 : 0);
  1228. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1229. MO, MGMT, 1011,
  1230. (htt_tlv_filter->mo_mgmt_filter &
  1231. FILTER_MGMT_AUTH) ? 1 : 0);
  1232. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1233. MO, MGMT, 1100,
  1234. (htt_tlv_filter->mo_mgmt_filter &
  1235. FILTER_MGMT_DEAUTH) ? 1 : 0);
  1236. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1237. MO, MGMT, 1101,
  1238. (htt_tlv_filter->mo_mgmt_filter &
  1239. FILTER_MGMT_ACTION) ? 1 : 0);
  1240. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1,
  1241. MO, MGMT, 1110,
  1242. (htt_tlv_filter->mo_mgmt_filter &
  1243. FILTER_MGMT_ACT_NO_ACK) ? 1 : 0);
  1244. /* reserved*/
  1245. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG1, MO,
  1246. MGMT, 1111,
  1247. (htt_tlv_filter->mo_mgmt_filter &
  1248. FILTER_MGMT_RESERVED_15) ? 1 : 0);
  1249. }
  1250. /* word 4 */
  1251. msg_word++;
  1252. *msg_word = 0;
  1253. if (htt_tlv_filter->enable_fp) {
  1254. /* TYPE: CTRL */
  1255. /* reserved */
  1256. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1257. CTRL, 0000,
  1258. (htt_tlv_filter->fp_ctrl_filter &
  1259. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1260. /* reserved */
  1261. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1262. CTRL, 0001,
  1263. (htt_tlv_filter->fp_ctrl_filter &
  1264. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1265. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1266. CTRL, 0010,
  1267. (htt_tlv_filter->fp_ctrl_filter &
  1268. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1269. /* reserved */
  1270. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1271. CTRL, 0011,
  1272. (htt_tlv_filter->fp_ctrl_filter &
  1273. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1274. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1275. CTRL, 0100,
  1276. (htt_tlv_filter->fp_ctrl_filter &
  1277. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1278. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1279. CTRL, 0101,
  1280. (htt_tlv_filter->fp_ctrl_filter &
  1281. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1282. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1283. CTRL, 0110,
  1284. (htt_tlv_filter->fp_ctrl_filter &
  1285. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1286. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1287. CTRL, 0111,
  1288. (htt_tlv_filter->fp_ctrl_filter &
  1289. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1290. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1291. CTRL, 1000,
  1292. (htt_tlv_filter->fp_ctrl_filter &
  1293. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1294. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, FP,
  1295. CTRL, 1001,
  1296. (htt_tlv_filter->fp_ctrl_filter &
  1297. FILTER_CTRL_BA) ? 1 : 0);
  1298. }
  1299. if (htt_tlv_filter->enable_md) {
  1300. /* TYPE: CTRL */
  1301. /* reserved */
  1302. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1303. CTRL, 0000,
  1304. (htt_tlv_filter->md_ctrl_filter &
  1305. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1306. /* reserved */
  1307. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1308. CTRL, 0001,
  1309. (htt_tlv_filter->md_ctrl_filter &
  1310. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1311. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1312. CTRL, 0010,
  1313. (htt_tlv_filter->md_ctrl_filter &
  1314. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1315. /* reserved */
  1316. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1317. CTRL, 0011,
  1318. (htt_tlv_filter->md_ctrl_filter &
  1319. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1320. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1321. CTRL, 0100,
  1322. (htt_tlv_filter->md_ctrl_filter &
  1323. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1324. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1325. CTRL, 0101,
  1326. (htt_tlv_filter->md_ctrl_filter &
  1327. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1328. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1329. CTRL, 0110,
  1330. (htt_tlv_filter->md_ctrl_filter &
  1331. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1332. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1333. CTRL, 0111,
  1334. (htt_tlv_filter->md_ctrl_filter &
  1335. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1336. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1337. CTRL, 1000,
  1338. (htt_tlv_filter->md_ctrl_filter &
  1339. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1340. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MD,
  1341. CTRL, 1001,
  1342. (htt_tlv_filter->md_ctrl_filter &
  1343. FILTER_CTRL_BA) ? 1 : 0);
  1344. }
  1345. if (htt_tlv_filter->enable_mo) {
  1346. /* TYPE: CTRL */
  1347. /* reserved */
  1348. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1349. CTRL, 0000,
  1350. (htt_tlv_filter->mo_ctrl_filter &
  1351. FILTER_CTRL_RESERVED_1) ? 1 : 0);
  1352. /* reserved */
  1353. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1354. CTRL, 0001,
  1355. (htt_tlv_filter->mo_ctrl_filter &
  1356. FILTER_CTRL_RESERVED_2) ? 1 : 0);
  1357. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1358. CTRL, 0010,
  1359. (htt_tlv_filter->mo_ctrl_filter &
  1360. FILTER_CTRL_TRIGGER) ? 1 : 0);
  1361. /* reserved */
  1362. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1363. CTRL, 0011,
  1364. (htt_tlv_filter->mo_ctrl_filter &
  1365. FILTER_CTRL_RESERVED_4) ? 1 : 0);
  1366. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1367. CTRL, 0100,
  1368. (htt_tlv_filter->mo_ctrl_filter &
  1369. FILTER_CTRL_BF_REP_POLL) ? 1 : 0);
  1370. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1371. CTRL, 0101,
  1372. (htt_tlv_filter->mo_ctrl_filter &
  1373. FILTER_CTRL_VHT_NDP) ? 1 : 0);
  1374. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1375. CTRL, 0110,
  1376. (htt_tlv_filter->mo_ctrl_filter &
  1377. FILTER_CTRL_FRAME_EXT) ? 1 : 0);
  1378. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1379. CTRL, 0111,
  1380. (htt_tlv_filter->mo_ctrl_filter &
  1381. FILTER_CTRL_CTRLWRAP) ? 1 : 0);
  1382. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1383. CTRL, 1000,
  1384. (htt_tlv_filter->mo_ctrl_filter &
  1385. FILTER_CTRL_BA_REQ) ? 1 : 0);
  1386. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG2, MO,
  1387. CTRL, 1001,
  1388. (htt_tlv_filter->mo_ctrl_filter &
  1389. FILTER_CTRL_BA) ? 1 : 0);
  1390. }
  1391. /* word 5 */
  1392. msg_word++;
  1393. *msg_word = 0;
  1394. if (htt_tlv_filter->enable_fp) {
  1395. /* TYPE: CTRL */
  1396. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1397. CTRL, 1010,
  1398. (htt_tlv_filter->fp_ctrl_filter &
  1399. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1400. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1401. CTRL, 1011,
  1402. (htt_tlv_filter->fp_ctrl_filter &
  1403. FILTER_CTRL_RTS) ? 1 : 0);
  1404. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1405. CTRL, 1100,
  1406. (htt_tlv_filter->fp_ctrl_filter &
  1407. FILTER_CTRL_CTS) ? 1 : 0);
  1408. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1409. CTRL, 1101,
  1410. (htt_tlv_filter->fp_ctrl_filter &
  1411. FILTER_CTRL_ACK) ? 1 : 0);
  1412. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1413. CTRL, 1110,
  1414. (htt_tlv_filter->fp_ctrl_filter &
  1415. FILTER_CTRL_CFEND) ? 1 : 0);
  1416. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1417. CTRL, 1111,
  1418. (htt_tlv_filter->fp_ctrl_filter &
  1419. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1420. /* TYPE: DATA */
  1421. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1422. DATA, MCAST,
  1423. (htt_tlv_filter->fp_data_filter &
  1424. FILTER_DATA_MCAST) ? 1 : 0);
  1425. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1426. DATA, UCAST,
  1427. (htt_tlv_filter->fp_data_filter &
  1428. FILTER_DATA_UCAST) ? 1 : 0);
  1429. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, FP,
  1430. DATA, NULL,
  1431. (htt_tlv_filter->fp_data_filter &
  1432. FILTER_DATA_NULL) ? 1 : 0);
  1433. }
  1434. if (htt_tlv_filter->enable_md) {
  1435. /* TYPE: CTRL */
  1436. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1437. CTRL, 1010,
  1438. (htt_tlv_filter->md_ctrl_filter &
  1439. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1440. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1441. CTRL, 1011,
  1442. (htt_tlv_filter->md_ctrl_filter &
  1443. FILTER_CTRL_RTS) ? 1 : 0);
  1444. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1445. CTRL, 1100,
  1446. (htt_tlv_filter->md_ctrl_filter &
  1447. FILTER_CTRL_CTS) ? 1 : 0);
  1448. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1449. CTRL, 1101,
  1450. (htt_tlv_filter->md_ctrl_filter &
  1451. FILTER_CTRL_ACK) ? 1 : 0);
  1452. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1453. CTRL, 1110,
  1454. (htt_tlv_filter->md_ctrl_filter &
  1455. FILTER_CTRL_CFEND) ? 1 : 0);
  1456. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1457. CTRL, 1111,
  1458. (htt_tlv_filter->md_ctrl_filter &
  1459. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1460. /* TYPE: DATA */
  1461. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1462. DATA, MCAST,
  1463. (htt_tlv_filter->md_data_filter &
  1464. FILTER_DATA_MCAST) ? 1 : 0);
  1465. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1466. DATA, UCAST,
  1467. (htt_tlv_filter->md_data_filter &
  1468. FILTER_DATA_UCAST) ? 1 : 0);
  1469. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MD,
  1470. DATA, NULL,
  1471. (htt_tlv_filter->md_data_filter &
  1472. FILTER_DATA_NULL) ? 1 : 0);
  1473. }
  1474. if (htt_tlv_filter->enable_mo) {
  1475. /* TYPE: CTRL */
  1476. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1477. CTRL, 1010,
  1478. (htt_tlv_filter->mo_ctrl_filter &
  1479. FILTER_CTRL_PSPOLL) ? 1 : 0);
  1480. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1481. CTRL, 1011,
  1482. (htt_tlv_filter->mo_ctrl_filter &
  1483. FILTER_CTRL_RTS) ? 1 : 0);
  1484. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1485. CTRL, 1100,
  1486. (htt_tlv_filter->mo_ctrl_filter &
  1487. FILTER_CTRL_CTS) ? 1 : 0);
  1488. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1489. CTRL, 1101,
  1490. (htt_tlv_filter->mo_ctrl_filter &
  1491. FILTER_CTRL_ACK) ? 1 : 0);
  1492. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1493. CTRL, 1110,
  1494. (htt_tlv_filter->mo_ctrl_filter &
  1495. FILTER_CTRL_CFEND) ? 1 : 0);
  1496. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1497. CTRL, 1111,
  1498. (htt_tlv_filter->mo_ctrl_filter &
  1499. FILTER_CTRL_CFEND_CFACK) ? 1 : 0);
  1500. /* TYPE: DATA */
  1501. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1502. DATA, MCAST,
  1503. (htt_tlv_filter->mo_data_filter &
  1504. FILTER_DATA_MCAST) ? 1 : 0);
  1505. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1506. DATA, UCAST,
  1507. (htt_tlv_filter->mo_data_filter &
  1508. FILTER_DATA_UCAST) ? 1 : 0);
  1509. htt_rx_ring_pkt_enable_subtype_set(*msg_word, FLAG3, MO,
  1510. DATA, NULL,
  1511. (htt_tlv_filter->mo_data_filter &
  1512. FILTER_DATA_NULL) ? 1 : 0);
  1513. }
  1514. /* word 6 */
  1515. msg_word++;
  1516. *msg_word = 0;
  1517. tlv_filter = 0;
  1518. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_START,
  1519. htt_tlv_filter->mpdu_start);
  1520. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_START,
  1521. htt_tlv_filter->msdu_start);
  1522. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET,
  1523. htt_tlv_filter->packet);
  1524. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MSDU_END,
  1525. htt_tlv_filter->msdu_end);
  1526. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, MPDU_END,
  1527. htt_tlv_filter->mpdu_end);
  1528. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PACKET_HEADER,
  1529. htt_tlv_filter->packet_header);
  1530. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, ATTENTION,
  1531. htt_tlv_filter->attention);
  1532. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START,
  1533. htt_tlv_filter->ppdu_start);
  1534. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END,
  1535. htt_tlv_filter->ppdu_end);
  1536. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_USER_STATS,
  1537. htt_tlv_filter->ppdu_end_user_stats);
  1538. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter,
  1539. PPDU_END_USER_STATS_EXT,
  1540. htt_tlv_filter->ppdu_end_user_stats_ext);
  1541. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_END_STATUS_DONE,
  1542. htt_tlv_filter->ppdu_end_status_done);
  1543. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, PPDU_START_USER_INFO,
  1544. htt_tlv_filter->ppdu_start_user_info);
  1545. /* RESERVED bit maps to header_per_msdu in htt_tlv_filter*/
  1546. htt_rx_ring_tlv_filter_in_enable_set(tlv_filter, RESERVED,
  1547. htt_tlv_filter->header_per_msdu);
  1548. HTT_RX_RING_SELECTION_CFG_TLV_FILTER_IN_FLAG_SET(*msg_word, tlv_filter);
  1549. msg_word_data = (uint32_t *)qdf_nbuf_data(htt_msg);
  1550. dp_info("config_data: [0x%x][0x%x][0x%x][0x%x][0x%x][0x%x][0x%x]",
  1551. msg_word_data[0], msg_word_data[1], msg_word_data[2],
  1552. msg_word_data[3], msg_word_data[4], msg_word_data[5],
  1553. msg_word_data[6]);
  1554. /* word 7 */
  1555. msg_word++;
  1556. *msg_word = 0;
  1557. if (htt_tlv_filter->offset_valid) {
  1558. HTT_RX_RING_SELECTION_CFG_RX_PACKET_OFFSET_SET(*msg_word,
  1559. htt_tlv_filter->rx_packet_offset);
  1560. HTT_RX_RING_SELECTION_CFG_RX_HEADER_OFFSET_SET(*msg_word,
  1561. htt_tlv_filter->rx_header_offset);
  1562. /* word 8 */
  1563. msg_word++;
  1564. *msg_word = 0;
  1565. HTT_RX_RING_SELECTION_CFG_RX_MPDU_END_OFFSET_SET(*msg_word,
  1566. htt_tlv_filter->rx_mpdu_end_offset);
  1567. HTT_RX_RING_SELECTION_CFG_RX_MPDU_START_OFFSET_SET(*msg_word,
  1568. htt_tlv_filter->rx_mpdu_start_offset);
  1569. /* word 9 */
  1570. msg_word++;
  1571. *msg_word = 0;
  1572. HTT_RX_RING_SELECTION_CFG_RX_MSDU_END_OFFSET_SET(*msg_word,
  1573. htt_tlv_filter->rx_msdu_end_offset);
  1574. HTT_RX_RING_SELECTION_CFG_RX_MSDU_START_OFFSET_SET(*msg_word,
  1575. htt_tlv_filter->rx_msdu_start_offset);
  1576. /* word 10 */
  1577. msg_word++;
  1578. *msg_word = 0;
  1579. HTT_RX_RING_SELECTION_CFG_RX_ATTENTION_OFFSET_SET(*msg_word,
  1580. htt_tlv_filter->rx_attn_offset);
  1581. /* word 11 */
  1582. msg_word++;
  1583. *msg_word = 0;
  1584. } else {
  1585. /* word 11 */
  1586. msg_word += 4;
  1587. *msg_word = 0;
  1588. }
  1589. soc->dp_soc->arch_ops.dp_rx_word_mask_subscribe(
  1590. soc->dp_soc,
  1591. msg_word,
  1592. (void *)htt_tlv_filter);
  1593. dp_mon_rx_wmask_subscribe(soc->dp_soc, msg_word,
  1594. pdev_id, htt_tlv_filter);
  1595. if (mon_drop_th > 0)
  1596. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1597. mon_drop_th);
  1598. dp_mon_rx_enable_mpdu_logging(soc->dp_soc, msg_word, htt_tlv_filter);
  1599. dp_mon_rx_enable_phy_errors(msg_word, htt_tlv_filter);
  1600. /* word 14*/
  1601. msg_word += 3;
  1602. /* word 15*/
  1603. msg_word++;
  1604. /* word 16*/
  1605. msg_word++;
  1606. *msg_word = 0;
  1607. dp_mon_rx_enable_pkt_tlv_offset(soc->dp_soc, msg_word, htt_tlv_filter);
  1608. /* word 20 and 21*/
  1609. msg_word += 4;
  1610. *msg_word = 0;
  1611. dp_mon_rx_enable_fpmo(soc->dp_soc, msg_word, htt_tlv_filter);
  1612. /* "response_required" field should be set if a HTT response message is
  1613. * required after setting up the ring.
  1614. */
  1615. pkt = htt_htc_pkt_alloc(soc);
  1616. if (!pkt) {
  1617. dp_err("pkt alloc failed, ring_type %d ring_id %d htt_ring_id %d",
  1618. hal_ring_type, srng_params.ring_id, htt_ring_id);
  1619. goto fail1;
  1620. }
  1621. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1622. SET_HTC_PACKET_INFO_TX(
  1623. &pkt->htc_pkt,
  1624. dp_htt_h2t_send_complete_free_netbuf,
  1625. qdf_nbuf_data(htt_msg),
  1626. qdf_nbuf_len(htt_msg),
  1627. soc->htc_endpoint,
  1628. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1629. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1630. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1631. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1632. htt_logger_bufp);
  1633. if (status != QDF_STATUS_SUCCESS) {
  1634. qdf_nbuf_free(htt_msg);
  1635. htt_htc_pkt_free(soc, pkt);
  1636. }
  1637. return status;
  1638. fail1:
  1639. qdf_nbuf_free(htt_msg);
  1640. fail0:
  1641. return QDF_STATUS_E_FAILURE;
  1642. }
  1643. qdf_export_symbol(htt_h2t_rx_ring_cfg);
  1644. #if defined(HTT_STATS_ENABLE)
  1645. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1646. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1647. {
  1648. uint32_t pdev_id;
  1649. uint32_t *msg_word = NULL;
  1650. uint32_t msg_remain_len = 0;
  1651. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1652. /*COOKIE MSB*/
  1653. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1654. /* stats message length + 16 size of HTT header*/
  1655. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1656. (uint32_t)DP_EXT_MSG_LENGTH);
  1657. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1658. msg_word, msg_remain_len,
  1659. WDI_NO_VAL, pdev_id);
  1660. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1661. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1662. }
  1663. /* Need to be freed here as WDI handler will
  1664. * make a copy of pkt to send data to application
  1665. */
  1666. qdf_nbuf_free(htt_msg);
  1667. return QDF_STATUS_SUCCESS;
  1668. }
  1669. #else
  1670. static inline QDF_STATUS
  1671. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1672. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1673. {
  1674. return QDF_STATUS_E_NOSUPPORT;
  1675. }
  1676. #endif
  1677. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1678. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer.
  1679. * @pdev: dp pdev handle
  1680. * @msg_word: HTT msg
  1681. * @msg_len: Length of HTT msg sent
  1682. *
  1683. * Return: none
  1684. */
  1685. static inline void
  1686. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1687. uint32_t msg_len)
  1688. {
  1689. struct htt_dbgfs_cfg dbgfs_cfg;
  1690. int done = 0;
  1691. /* send 5th word of HTT msg to upper layer */
  1692. dbgfs_cfg.msg_word = (msg_word + 4);
  1693. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1694. /* stats message length + 16 size of HTT header*/
  1695. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1696. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1697. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1698. (msg_len - HTT_HEADER_LEN));
  1699. /* Get TLV Done bit from 4th msg word */
  1700. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1701. if (done) {
  1702. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1703. dp_htt_err("%pK: Failed to set event for debugfs htt stats"
  1704. , pdev->soc);
  1705. }
  1706. }
  1707. #else
  1708. static inline void
  1709. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1710. uint32_t msg_len)
  1711. {
  1712. }
  1713. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1714. #ifdef WLAN_SYSFS_DP_STATS
  1715. /* dp_htt_stats_sysfs_update_config() - Function to send htt data to upper layer.
  1716. * @pdev: dp pdev handle
  1717. *
  1718. * This function sets the process id and printing mode within the sysfs config
  1719. * struct. which enables DP_PRINT statements within this process to write to the
  1720. * console buffer provided by the user space.
  1721. *
  1722. * Return: None
  1723. */
  1724. static inline void
  1725. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1726. {
  1727. struct dp_soc *soc = pdev->soc;
  1728. if (!soc) {
  1729. dp_htt_err("soc is null");
  1730. return;
  1731. }
  1732. if (!soc->sysfs_config) {
  1733. dp_htt_err("soc->sysfs_config is NULL");
  1734. return;
  1735. }
  1736. /* set sysfs config parameters */
  1737. soc->sysfs_config->process_id = qdf_get_current_pid();
  1738. soc->sysfs_config->printing_mode = PRINTING_MODE_ENABLED;
  1739. }
  1740. /**
  1741. * dp_htt_stats_sysfs_set_event() - Set sysfs stats event.
  1742. * @soc: soc handle.
  1743. * @msg_word: Pointer to htt msg word.
  1744. *
  1745. * Return: void
  1746. */
  1747. static inline void
  1748. dp_htt_stats_sysfs_set_event(struct dp_soc *soc, uint32_t *msg_word)
  1749. {
  1750. int done = 0;
  1751. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1752. if (done) {
  1753. if (qdf_event_set(&soc->sysfs_config->sysfs_txrx_fw_request_done))
  1754. dp_htt_err("%pK:event compl Fail to set event ",
  1755. soc);
  1756. }
  1757. }
  1758. #else /* WLAN_SYSFS_DP_STATS */
  1759. static inline void
  1760. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1761. {
  1762. }
  1763. static inline void
  1764. dp_htt_stats_sysfs_set_event(struct dp_soc *dp_soc, uint32_t *msg_word)
  1765. {
  1766. }
  1767. #endif /* WLAN_SYSFS_DP_STATS */
  1768. /* dp_htt_set_pdev_obss_stats() - Function to set pdev obss stats.
  1769. * @pdev: dp pdev handle
  1770. * @tag_type: HTT TLV tag type
  1771. * @tag_buf: TLV buffer pointer
  1772. *
  1773. * Return: None
  1774. */
  1775. static inline void
  1776. dp_htt_set_pdev_obss_stats(struct dp_pdev *pdev, uint32_t tag_type,
  1777. uint32_t *tag_buf)
  1778. {
  1779. if (tag_type != HTT_STATS_PDEV_OBSS_PD_TAG) {
  1780. dp_err("Tag mismatch");
  1781. return;
  1782. }
  1783. qdf_mem_copy(&pdev->stats.htt_tx_pdev_stats.obss_pd_stats_tlv,
  1784. tag_buf, sizeof(struct cdp_pdev_obss_pd_stats_tlv));
  1785. qdf_event_set(&pdev->fw_obss_stats_event);
  1786. }
  1787. /**
  1788. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1789. * @htt_stats: htt stats info
  1790. * @soc: dp_soc
  1791. *
  1792. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1793. * contains sub messages which are identified by a TLV header.
  1794. * In this function we will process the stream of T2H messages and read all the
  1795. * TLV contained in the message.
  1796. *
  1797. * The following cases have been taken care of
  1798. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1799. * In this case the buffer will contain multiple tlvs.
  1800. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1801. * Only one tlv will be contained in the HTT message and this tag
  1802. * will extend onto the next buffer.
  1803. * Case 3: When the buffer is the continuation of the previous message
  1804. * Case 4: tlv length is 0. which will indicate the end of message
  1805. *
  1806. * Return: void
  1807. */
  1808. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1809. struct dp_soc *soc)
  1810. {
  1811. htt_tlv_tag_t tlv_type = 0xff;
  1812. qdf_nbuf_t htt_msg = NULL;
  1813. uint32_t *msg_word;
  1814. uint8_t *tlv_buf_head = NULL;
  1815. uint8_t *tlv_buf_tail = NULL;
  1816. uint32_t msg_remain_len = 0;
  1817. uint32_t tlv_remain_len = 0;
  1818. uint32_t *tlv_start;
  1819. int cookie_val = 0;
  1820. int cookie_msb = 0;
  1821. int pdev_id;
  1822. bool copy_stats = false;
  1823. struct dp_pdev *pdev;
  1824. /* Process node in the HTT message queue */
  1825. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1826. != NULL) {
  1827. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1828. cookie_val = *(msg_word + 1);
  1829. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1830. *(msg_word +
  1831. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1832. if (cookie_val) {
  1833. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1834. == QDF_STATUS_SUCCESS) {
  1835. continue;
  1836. }
  1837. }
  1838. cookie_msb = *(msg_word + 2);
  1839. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1840. pdev = soc->pdev_list[pdev_id];
  1841. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1842. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1843. htt_stats->msg_len);
  1844. qdf_nbuf_free(htt_msg);
  1845. continue;
  1846. }
  1847. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1848. dp_htt_stats_sysfs_update_config(pdev);
  1849. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1850. copy_stats = true;
  1851. /* read 5th word */
  1852. msg_word = msg_word + 4;
  1853. msg_remain_len = qdf_min(htt_stats->msg_len,
  1854. (uint32_t) DP_EXT_MSG_LENGTH);
  1855. /* Keep processing the node till node length is 0 */
  1856. while (msg_remain_len) {
  1857. /*
  1858. * if message is not a continuation of previous message
  1859. * read the tlv type and tlv length
  1860. */
  1861. if (!tlv_buf_head) {
  1862. tlv_type = HTT_STATS_TLV_TAG_GET(
  1863. *msg_word);
  1864. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1865. *msg_word);
  1866. }
  1867. if (tlv_remain_len == 0) {
  1868. msg_remain_len = 0;
  1869. if (tlv_buf_head) {
  1870. qdf_mem_free(tlv_buf_head);
  1871. tlv_buf_head = NULL;
  1872. tlv_buf_tail = NULL;
  1873. }
  1874. goto error;
  1875. }
  1876. if (!tlv_buf_head)
  1877. tlv_remain_len += HTT_TLV_HDR_LEN;
  1878. if ((tlv_remain_len <= msg_remain_len)) {
  1879. /* Case 3 */
  1880. if (tlv_buf_head) {
  1881. qdf_mem_copy(tlv_buf_tail,
  1882. (uint8_t *)msg_word,
  1883. tlv_remain_len);
  1884. tlv_start = (uint32_t *)tlv_buf_head;
  1885. } else {
  1886. /* Case 1 */
  1887. tlv_start = msg_word;
  1888. }
  1889. if (copy_stats)
  1890. dp_htt_stats_copy_tag(pdev,
  1891. tlv_type,
  1892. tlv_start);
  1893. else
  1894. dp_htt_stats_print_tag(pdev,
  1895. tlv_type,
  1896. tlv_start);
  1897. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1898. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1899. dp_peer_update_inactive_time(pdev,
  1900. tlv_type,
  1901. tlv_start);
  1902. if (cookie_msb & DBG_STATS_COOKIE_HTT_OBSS)
  1903. dp_htt_set_pdev_obss_stats(pdev,
  1904. tlv_type,
  1905. tlv_start);
  1906. msg_remain_len -= tlv_remain_len;
  1907. msg_word = (uint32_t *)
  1908. (((uint8_t *)msg_word) +
  1909. tlv_remain_len);
  1910. tlv_remain_len = 0;
  1911. if (tlv_buf_head) {
  1912. qdf_mem_free(tlv_buf_head);
  1913. tlv_buf_head = NULL;
  1914. tlv_buf_tail = NULL;
  1915. }
  1916. } else { /* tlv_remain_len > msg_remain_len */
  1917. /* Case 2 & 3 */
  1918. if (!tlv_buf_head) {
  1919. tlv_buf_head = qdf_mem_malloc(
  1920. tlv_remain_len);
  1921. if (!tlv_buf_head) {
  1922. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1923. QDF_TRACE_LEVEL_ERROR,
  1924. "Alloc failed");
  1925. goto error;
  1926. }
  1927. tlv_buf_tail = tlv_buf_head;
  1928. }
  1929. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1930. msg_remain_len);
  1931. tlv_remain_len -= msg_remain_len;
  1932. tlv_buf_tail += msg_remain_len;
  1933. }
  1934. }
  1935. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1936. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1937. }
  1938. /* indicate event completion in case the event is done */
  1939. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1940. dp_htt_stats_sysfs_set_event(soc, msg_word);
  1941. qdf_nbuf_free(htt_msg);
  1942. }
  1943. return;
  1944. error:
  1945. qdf_nbuf_free(htt_msg);
  1946. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1947. != NULL)
  1948. qdf_nbuf_free(htt_msg);
  1949. }
  1950. void htt_t2h_stats_handler(void *context)
  1951. {
  1952. struct dp_soc *soc = (struct dp_soc *)context;
  1953. struct htt_stats_context htt_stats;
  1954. uint32_t *msg_word;
  1955. qdf_nbuf_t htt_msg = NULL;
  1956. uint8_t done;
  1957. uint32_t rem_stats;
  1958. if (!soc) {
  1959. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1960. "soc is NULL");
  1961. return;
  1962. }
  1963. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1964. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1965. "soc: 0x%pK, init_done: %d", soc,
  1966. qdf_atomic_read(&soc->cmn_init_done));
  1967. return;
  1968. }
  1969. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1970. qdf_nbuf_queue_init(&htt_stats.msg);
  1971. /* pull one completed stats from soc->htt_stats_msg and process */
  1972. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1973. if (!soc->htt_stats.num_stats) {
  1974. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1975. return;
  1976. }
  1977. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  1978. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1979. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  1980. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1981. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  1982. /*
  1983. * Done bit signifies that this is the last T2H buffer in the
  1984. * stream of HTT EXT STATS message
  1985. */
  1986. if (done)
  1987. break;
  1988. }
  1989. rem_stats = --soc->htt_stats.num_stats;
  1990. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1991. /* If there are more stats to process, schedule stats work again.
  1992. * Scheduling prior to processing ht_stats to queue with early
  1993. * index
  1994. */
  1995. if (rem_stats)
  1996. qdf_sched_work(0, &soc->htt_stats.work);
  1997. dp_process_htt_stat_msg(&htt_stats, soc);
  1998. }
  1999. /**
  2000. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  2001. * @soc: DP SOC handle
  2002. * @htt_t2h_msg: HTT message nbuf
  2003. *
  2004. * return:void
  2005. */
  2006. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  2007. qdf_nbuf_t htt_t2h_msg)
  2008. {
  2009. uint8_t done;
  2010. qdf_nbuf_t msg_copy;
  2011. uint32_t *msg_word;
  2012. msg_word = (uint32_t *)qdf_nbuf_data(htt_t2h_msg);
  2013. msg_word = msg_word + 3;
  2014. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  2015. /*
  2016. * HTT EXT stats response comes as stream of TLVs which span over
  2017. * multiple T2H messages.
  2018. * The first message will carry length of the response.
  2019. * For rest of the messages length will be zero.
  2020. *
  2021. * Clone the T2H message buffer and store it in a list to process
  2022. * it later.
  2023. *
  2024. * The original T2H message buffers gets freed in the T2H HTT event
  2025. * handler
  2026. */
  2027. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  2028. if (!msg_copy) {
  2029. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2030. "T2H message clone failed for HTT EXT STATS");
  2031. goto error;
  2032. }
  2033. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2034. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  2035. /*
  2036. * Done bit signifies that this is the last T2H buffer in the stream of
  2037. * HTT EXT STATS message
  2038. */
  2039. if (done) {
  2040. soc->htt_stats.num_stats++;
  2041. qdf_sched_work(0, &soc->htt_stats.work);
  2042. }
  2043. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2044. return;
  2045. error:
  2046. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2047. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  2048. != NULL) {
  2049. qdf_nbuf_free(msg_copy);
  2050. }
  2051. soc->htt_stats.num_stats = 0;
  2052. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2053. return;
  2054. }
  2055. int htt_soc_attach_target(struct htt_soc *htt_soc)
  2056. {
  2057. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  2058. return htt_h2t_ver_req_msg(soc);
  2059. }
  2060. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  2061. {
  2062. htt_soc->htc_soc = htc_soc;
  2063. }
  2064. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  2065. {
  2066. return htt_soc->htc_soc;
  2067. }
  2068. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  2069. {
  2070. int i;
  2071. int j;
  2072. int umac_alloc_size = HTT_SW_UMAC_RING_IDX_MAX *
  2073. sizeof(struct bp_handler);
  2074. int lmac_alloc_size = HTT_SW_LMAC_RING_IDX_MAX *
  2075. sizeof(struct bp_handler);
  2076. struct htt_soc *htt_soc = NULL;
  2077. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  2078. if (!htt_soc) {
  2079. dp_err("HTT attach failed");
  2080. return NULL;
  2081. }
  2082. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2083. htt_soc->pdevid_tt[i].umac_path =
  2084. qdf_mem_malloc(umac_alloc_size);
  2085. if (!htt_soc->pdevid_tt[i].umac_path)
  2086. break;
  2087. for (j = 0; j < HTT_SW_UMAC_RING_IDX_MAX; j++)
  2088. htt_soc->pdevid_tt[i].umac_path[j].bp_start_tt = -1;
  2089. htt_soc->pdevid_tt[i].lmac_path =
  2090. qdf_mem_malloc(lmac_alloc_size);
  2091. if (!htt_soc->pdevid_tt[i].lmac_path) {
  2092. qdf_mem_free(htt_soc->pdevid_tt[i].umac_path);
  2093. break;
  2094. }
  2095. for (j = 0; j < HTT_SW_LMAC_RING_IDX_MAX ; j++)
  2096. htt_soc->pdevid_tt[i].lmac_path[j].bp_start_tt = -1;
  2097. }
  2098. if (i != MAX_PDEV_CNT) {
  2099. for (j = 0; j < i; j++) {
  2100. qdf_mem_free(htt_soc->pdevid_tt[j].umac_path);
  2101. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_path);
  2102. }
  2103. qdf_mem_free(htt_soc);
  2104. return NULL;
  2105. }
  2106. htt_soc->dp_soc = soc;
  2107. htt_soc->htc_soc = htc_handle;
  2108. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  2109. return htt_soc;
  2110. }
  2111. #if defined(WDI_EVENT_ENABLE) && \
  2112. !defined(REMOVE_PKT_LOG)
  2113. /**
  2114. * dp_pktlog_msg_handler() - Pktlog msg handler
  2115. * @soc: HTT SOC handle
  2116. * @msg_word: Pointer to payload
  2117. *
  2118. * Return: None
  2119. */
  2120. static void
  2121. dp_pktlog_msg_handler(struct htt_soc *soc,
  2122. uint32_t *msg_word)
  2123. {
  2124. uint8_t pdev_id;
  2125. uint8_t target_pdev_id;
  2126. uint32_t *pl_hdr;
  2127. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  2128. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2129. target_pdev_id);
  2130. pl_hdr = (msg_word + 1);
  2131. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  2132. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  2133. pdev_id);
  2134. }
  2135. #else
  2136. static void
  2137. dp_pktlog_msg_handler(struct htt_soc *soc,
  2138. uint32_t *msg_word)
  2139. {
  2140. }
  2141. #endif
  2142. #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
  2143. QDF_STATUS
  2144. dp_h2t_ptqm_migration_msg_send(struct dp_soc *dp_soc, uint16_t vdev_id,
  2145. uint8_t pdev_id,
  2146. uint8_t chip_id, uint16_t peer_id,
  2147. uint16_t ml_peer_id, uint16_t src_info,
  2148. QDF_STATUS status)
  2149. {
  2150. struct htt_soc *soc = dp_soc->htt_handle;
  2151. struct dp_htt_htc_pkt *pkt;
  2152. uint8_t *htt_logger_bufp;
  2153. qdf_nbuf_t msg;
  2154. uint32_t *msg_word;
  2155. QDF_STATUS ret = QDF_STATUS_SUCCESS;
  2156. bool src_info_valid = false;
  2157. msg = qdf_nbuf_alloc(
  2158. soc->osdev,
  2159. HTT_MSG_BUF_SIZE(sizeof(htt_h2t_primary_link_peer_migrate_resp_t)),
  2160. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2161. if (!msg)
  2162. return QDF_STATUS_E_NOMEM;
  2163. /*
  2164. * Set the length of the message.
  2165. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2166. * separately during the below call to qdf_nbuf_push_head.
  2167. * The contribution from the HTC header is added separately inside HTC.
  2168. */
  2169. if (qdf_nbuf_put_tail(msg, sizeof(htt_h2t_primary_link_peer_migrate_resp_t))
  2170. == NULL) {
  2171. dp_htt_err("Failed to expand head for"
  2172. "HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP");
  2173. qdf_nbuf_free(msg);
  2174. return QDF_STATUS_E_FAILURE;
  2175. }
  2176. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  2177. memset(msg_word, 0, sizeof(htt_h2t_primary_link_peer_migrate_resp_t));
  2178. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2179. htt_logger_bufp = (uint8_t *)msg_word;
  2180. *msg_word = 0;
  2181. HTT_H2T_MSG_TYPE_SET(*msg_word,
  2182. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP);
  2183. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_SET(*msg_word, pdev_id);
  2184. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_SET(*msg_word, chip_id);
  2185. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_SET(*msg_word, vdev_id);
  2186. /* word 1 */
  2187. msg_word++;
  2188. *msg_word = 0;
  2189. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_SET(*msg_word,
  2190. peer_id);
  2191. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_SET(*msg_word,
  2192. ml_peer_id);
  2193. /* word 1 */
  2194. msg_word++;
  2195. *msg_word = 0;
  2196. if (src_info != 0)
  2197. src_info_valid = true;
  2198. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SRC_INFO_VALID_SET(*msg_word,
  2199. src_info_valid);
  2200. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SRC_INFO_SET(*msg_word,
  2201. src_info);
  2202. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_STATUS_SET(*msg_word,
  2203. status);
  2204. pkt = htt_htc_pkt_alloc(soc);
  2205. if (!pkt) {
  2206. dp_htt_err("Fail to allocate dp_htt_htc_pkt buffer");
  2207. qdf_nbuf_free(msg);
  2208. return QDF_STATUS_E_NOMEM;
  2209. }
  2210. pkt->soc_ctxt = NULL;
  2211. /* macro to set packet parameters for TX */
  2212. SET_HTC_PACKET_INFO_TX(
  2213. &pkt->htc_pkt,
  2214. dp_htt_h2t_send_complete_free_netbuf,
  2215. qdf_nbuf_data(msg),
  2216. qdf_nbuf_len(msg),
  2217. soc->htc_endpoint,
  2218. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  2219. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2220. ret = DP_HTT_SEND_HTC_PKT(
  2221. soc, pkt,
  2222. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP,
  2223. htt_logger_bufp);
  2224. if (ret != QDF_STATUS_SUCCESS) {
  2225. qdf_nbuf_free(msg);
  2226. htt_htc_pkt_free(soc, pkt);
  2227. }
  2228. return ret;
  2229. }
  2230. #endif
  2231. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  2232. /**
  2233. * dp_vdev_txrx_hw_stats_handler - Handle vdev stats received from FW
  2234. * @soc: htt soc handle
  2235. * @msg_word: buffer containing stats
  2236. *
  2237. * Return: void
  2238. */
  2239. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2240. uint32_t *msg_word)
  2241. {
  2242. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2243. uint8_t pdev_id;
  2244. uint8_t vdev_id;
  2245. uint8_t target_pdev_id;
  2246. uint16_t payload_size;
  2247. struct dp_pdev *pdev;
  2248. struct dp_vdev *vdev;
  2249. uint8_t *tlv_buf;
  2250. uint32_t *tlv_buf_temp;
  2251. uint32_t *tag_buf;
  2252. htt_tlv_tag_t tlv_type;
  2253. uint16_t tlv_length;
  2254. uint64_t pkt_count = 0;
  2255. uint64_t byte_count = 0;
  2256. uint64_t soc_drop_cnt = 0;
  2257. struct cdp_pkt_info tx_comp = { 0 };
  2258. struct cdp_pkt_info tx_failed = { 0 };
  2259. target_pdev_id =
  2260. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PDEV_ID_GET(*msg_word);
  2261. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(dpsoc,
  2262. target_pdev_id);
  2263. if (pdev_id >= MAX_PDEV_CNT)
  2264. return;
  2265. pdev = dpsoc->pdev_list[pdev_id];
  2266. if (!pdev) {
  2267. dp_err("PDEV is NULL for pdev_id:%d", pdev_id);
  2268. return;
  2269. }
  2270. payload_size =
  2271. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PAYLOAD_SIZE_GET(*msg_word);
  2272. qdf_trace_hex_dump(QDF_MODULE_ID_DP_HTT, QDF_TRACE_LEVEL_INFO,
  2273. (void *)msg_word, payload_size + 16);
  2274. /* Adjust msg_word to point to the first TLV in buffer */
  2275. msg_word = msg_word + 4;
  2276. /* Parse the received buffer till payload size reaches 0 */
  2277. while (payload_size > 0) {
  2278. tlv_buf = (uint8_t *)msg_word;
  2279. tlv_buf_temp = msg_word;
  2280. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2281. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2282. /* Add header size to tlv length*/
  2283. tlv_length += 4;
  2284. switch (tlv_type) {
  2285. case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
  2286. {
  2287. tag_buf = tlv_buf_temp +
  2288. HTT_VDEV_STATS_GET_INDEX(SOC_DROP_CNT);
  2289. soc_drop_cnt = HTT_VDEV_GET_STATS_U64(tag_buf);
  2290. DP_STATS_UPD(dpsoc, tx.tqm_drop_no_peer, soc_drop_cnt);
  2291. break;
  2292. }
  2293. case HTT_STATS_VDEV_TXRX_STATS_HW_STATS_TAG:
  2294. {
  2295. tag_buf = tlv_buf_temp +
  2296. HTT_VDEV_STATS_GET_INDEX(VDEV_ID);
  2297. vdev_id = (uint8_t)(*tag_buf);
  2298. vdev = dp_vdev_get_ref_by_id(dpsoc, vdev_id,
  2299. DP_MOD_ID_HTT);
  2300. if (!vdev)
  2301. goto invalid_vdev;
  2302. /* Extract received packet count from buffer */
  2303. tag_buf = tlv_buf_temp +
  2304. HTT_VDEV_STATS_GET_INDEX(RX_PKT_CNT);
  2305. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2306. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.num, pkt_count);
  2307. /* Extract received packet byte count from buffer */
  2308. tag_buf = tlv_buf_temp +
  2309. HTT_VDEV_STATS_GET_INDEX(RX_BYTE_CNT);
  2310. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2311. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.bytes, byte_count);
  2312. /* Extract tx success packet count from buffer */
  2313. tag_buf = tlv_buf_temp +
  2314. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_PKT_CNT);
  2315. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2316. tx_comp.num = pkt_count;
  2317. /* Extract tx success packet byte count from buffer */
  2318. tag_buf = tlv_buf_temp +
  2319. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_BYTE_CNT);
  2320. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2321. tx_comp.bytes = byte_count;
  2322. /* Extract tx retry packet count from buffer */
  2323. tag_buf = tlv_buf_temp +
  2324. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_PKT_CNT);
  2325. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2326. tx_comp.num += pkt_count;
  2327. tx_failed.num = pkt_count;
  2328. /* Extract tx retry packet byte count from buffer */
  2329. tag_buf = tlv_buf_temp +
  2330. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_BYTE_CNT);
  2331. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2332. tx_comp.bytes += byte_count;
  2333. tx_failed.bytes = byte_count;
  2334. /* Extract tx drop packet count from buffer */
  2335. tag_buf = tlv_buf_temp +
  2336. HTT_VDEV_STATS_GET_INDEX(TX_DROP_PKT_CNT);
  2337. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2338. tx_comp.num += pkt_count;
  2339. tx_failed.num += pkt_count;
  2340. /* Extract tx drop packet byte count from buffer */
  2341. tag_buf = tlv_buf_temp +
  2342. HTT_VDEV_STATS_GET_INDEX(TX_DROP_BYTE_CNT);
  2343. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2344. tx_comp.bytes += byte_count;
  2345. tx_failed.bytes += byte_count;
  2346. /* Extract tx age-out packet count from buffer */
  2347. tag_buf = tlv_buf_temp +
  2348. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_PKT_CNT);
  2349. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2350. tx_comp.num += pkt_count;
  2351. tx_failed.num += pkt_count;
  2352. /* Extract tx age-out packet byte count from buffer */
  2353. tag_buf = tlv_buf_temp +
  2354. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_BYTE_CNT);
  2355. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2356. tx_comp.bytes += byte_count;
  2357. tx_failed.bytes += byte_count;
  2358. /* Extract tqm bypass packet count from buffer */
  2359. tag_buf = tlv_buf_temp +
  2360. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_PKT_CNT);
  2361. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2362. tx_comp.num += pkt_count;
  2363. /* Extract tx bypass packet byte count from buffer */
  2364. tag_buf = tlv_buf_temp +
  2365. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_BYTE_CNT);
  2366. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2367. tx_comp.bytes += byte_count;
  2368. DP_STATS_UPD(vdev, tx.comp_pkt.num, tx_comp.num);
  2369. DP_STATS_UPD(vdev, tx.comp_pkt.bytes, tx_comp.bytes);
  2370. DP_STATS_UPD(vdev, tx.tx_failed, tx_failed.num);
  2371. dp_vdev_unref_delete(dpsoc, vdev, DP_MOD_ID_HTT);
  2372. break;
  2373. }
  2374. default:
  2375. dp_htt_err("Invalid tlv_type value:%d\n", tlv_type);
  2376. }
  2377. invalid_vdev:
  2378. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2379. payload_size -= tlv_length;
  2380. }
  2381. }
  2382. #else
  2383. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2384. uint32_t *msg_word)
  2385. {}
  2386. #endif
  2387. #ifdef CONFIG_SAWF_DEF_QUEUES
  2388. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2389. uint32_t *msg_word,
  2390. qdf_nbuf_t htt_t2h_msg)
  2391. {
  2392. dp_htt_sawf_def_queues_map_report_conf(soc, msg_word, htt_t2h_msg);
  2393. }
  2394. #else
  2395. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2396. uint32_t *msg_word,
  2397. qdf_nbuf_t htt_t2h_msg)
  2398. {}
  2399. #endif
  2400. #ifdef CONFIG_SAWF
  2401. /**
  2402. * dp_sawf_msduq_map() - Msdu queue creation information received
  2403. * from target
  2404. * @soc: soc handle.
  2405. * @msg_word: Pointer to htt msg word.
  2406. * @htt_t2h_msg: HTT message nbuf
  2407. *
  2408. * Return: void
  2409. */
  2410. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2411. qdf_nbuf_t htt_t2h_msg)
  2412. {
  2413. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2414. }
  2415. /**
  2416. * dp_sawf_dynamic_ast_update() - Dynamic AST index update for SAWF peer
  2417. * from target
  2418. * @soc: soc handle.
  2419. * @msg_word: Pointer to htt msg word.
  2420. * @htt_t2h_msg: HTT message nbuf
  2421. *
  2422. * Return: void
  2423. */
  2424. static void dp_sawf_dynamic_ast_update(struct htt_soc *soc, uint32_t *msg_word,
  2425. qdf_nbuf_t htt_t2h_msg)
  2426. {
  2427. dp_htt_sawf_dynamic_ast_update(soc, msg_word, htt_t2h_msg);
  2428. }
  2429. /**
  2430. * dp_sawf_mpdu_stats_handler() - HTT message handler for MPDU stats
  2431. * @soc: soc handle.
  2432. * @htt_t2h_msg: HTT message nbuf
  2433. *
  2434. * Return: void
  2435. */
  2436. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2437. qdf_nbuf_t htt_t2h_msg)
  2438. {
  2439. dp_sawf_htt_mpdu_stats_handler(soc, htt_t2h_msg);
  2440. }
  2441. #else
  2442. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2443. qdf_nbuf_t htt_t2h_msg)
  2444. {}
  2445. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2446. qdf_nbuf_t htt_t2h_msg)
  2447. {}
  2448. static void dp_sawf_dynamic_ast_update(struct htt_soc *soc, uint32_t *msg_word,
  2449. qdf_nbuf_t htt_t2h_msg)
  2450. {}
  2451. #endif
  2452. /**
  2453. * time_allow_print() - time allow print
  2454. * @htt_bp_handler: backpressure handler
  2455. * @ring_id: ring_id (index)
  2456. * @th_time: threshold time
  2457. *
  2458. * Return: 1 for successfully saving timestamp in array
  2459. * and 0 for timestamp falling within 2 seconds after last one
  2460. */
  2461. static bool time_allow_print(struct bp_handler *htt_bp_handler,
  2462. u_int8_t ring_id, u_int32_t th_time)
  2463. {
  2464. unsigned long tstamp;
  2465. struct bp_handler *path = &htt_bp_handler[ring_id];
  2466. tstamp = qdf_get_system_timestamp();
  2467. if (!path)
  2468. return 0; //unable to print backpressure messages
  2469. if (path->bp_start_tt == -1) {
  2470. path->bp_start_tt = tstamp;
  2471. path->bp_duration = 0;
  2472. path->bp_last_tt = tstamp;
  2473. path->bp_counter = 1;
  2474. return 1;
  2475. }
  2476. path->bp_duration = tstamp - path->bp_start_tt;
  2477. path->bp_last_tt = tstamp;
  2478. path->bp_counter++;
  2479. if (path->bp_duration >= th_time) {
  2480. path->bp_start_tt = -1;
  2481. return 1;
  2482. }
  2483. return 0;
  2484. }
  2485. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2486. struct dp_pdev *pdev, u_int8_t ring_id,
  2487. u_int16_t hp_idx, u_int16_t tp_idx,
  2488. u_int32_t bkp_time,
  2489. struct bp_handler *htt_bp_handler,
  2490. char *ring_stype)
  2491. {
  2492. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2493. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2494. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2495. ring_id, hp_idx, tp_idx, bkp_time);
  2496. dp_alert("last_bp_event: %ld, total_bp_duration: %ld, bp_counter: %ld",
  2497. htt_bp_handler[ring_id].bp_last_tt,
  2498. htt_bp_handler[ring_id].bp_duration,
  2499. htt_bp_handler[ring_id].bp_counter);
  2500. }
  2501. /**
  2502. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2503. * @soc: DP_SOC handle
  2504. * @pdev: DP pdev handle
  2505. * @srng: DP_SRNG handle
  2506. * @ring_type: srng src/dst ring
  2507. * @state: ring state
  2508. * @pdev: pdev
  2509. * @srng: DP_SRNG handle
  2510. * @ring_type: srng src/dst ring
  2511. * @state: ring_state
  2512. *
  2513. * Return: void
  2514. */
  2515. static QDF_STATUS
  2516. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2517. struct dp_pdev *pdev,
  2518. struct dp_srng *srng,
  2519. enum hal_ring_type ring_type,
  2520. struct dp_srng_ring_state *state)
  2521. {
  2522. struct hal_soc *hal_soc;
  2523. if (!soc || !srng || !srng->hal_srng || !state)
  2524. return QDF_STATUS_E_INVAL;
  2525. hal_soc = (struct hal_soc *)soc->hal_soc;
  2526. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2527. &state->sw_head);
  2528. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2529. &state->hw_tail, ring_type);
  2530. state->ring_type = ring_type;
  2531. return QDF_STATUS_SUCCESS;
  2532. }
  2533. #ifdef QCA_MONITOR_PKT_SUPPORT
  2534. static void
  2535. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2536. int lmac_id, uint32_t *num_srng,
  2537. struct dp_soc_srngs_state *soc_srngs_state)
  2538. {
  2539. QDF_STATUS status;
  2540. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2541. status = dp_get_srng_ring_state_from_hal
  2542. (pdev->soc, pdev,
  2543. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2544. RXDMA_MONITOR_BUF,
  2545. &soc_srngs_state->ring_state[*num_srng]);
  2546. if (status == QDF_STATUS_SUCCESS)
  2547. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2548. status = dp_get_srng_ring_state_from_hal
  2549. (pdev->soc, pdev,
  2550. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2551. RXDMA_MONITOR_DST,
  2552. &soc_srngs_state->ring_state[*num_srng]);
  2553. if (status == QDF_STATUS_SUCCESS)
  2554. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2555. status = dp_get_srng_ring_state_from_hal
  2556. (pdev->soc, pdev,
  2557. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2558. RXDMA_MONITOR_DESC,
  2559. &soc_srngs_state->ring_state[*num_srng]);
  2560. if (status == QDF_STATUS_SUCCESS)
  2561. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2562. }
  2563. }
  2564. #else
  2565. static void
  2566. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2567. int lmac_id, uint32_t *num_srng,
  2568. struct dp_soc_srngs_state *soc_srngs_state)
  2569. {
  2570. }
  2571. #endif
  2572. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  2573. static inline QDF_STATUS
  2574. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2575. struct dp_srng_ring_state *ring_state)
  2576. {
  2577. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2578. &pdev->soc->tcl_cmd_credit_ring,
  2579. TCL_CMD_CREDIT, ring_state);
  2580. }
  2581. #else
  2582. static inline QDF_STATUS
  2583. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2584. struct dp_srng_ring_state *ring_state)
  2585. {
  2586. return QDF_STATUS_SUCCESS;
  2587. }
  2588. #endif
  2589. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  2590. static inline QDF_STATUS
  2591. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2592. struct dp_srng_ring_state *ring_state)
  2593. {
  2594. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2595. &pdev->soc->tcl_status_ring,
  2596. TCL_STATUS, ring_state);
  2597. }
  2598. #else
  2599. static inline QDF_STATUS
  2600. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2601. struct dp_srng_ring_state *ring_state)
  2602. {
  2603. return QDF_STATUS_SUCCESS;
  2604. }
  2605. #endif
  2606. /**
  2607. * dp_queue_ring_stats() - Print pdev hal level ring stats
  2608. * dp_queue_ring_stats(): Print pdev hal level ring stats
  2609. * @pdev: DP_pdev handle
  2610. *
  2611. * Return: void
  2612. */
  2613. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2614. {
  2615. uint32_t i;
  2616. int mac_id;
  2617. int lmac_id;
  2618. uint32_t j = 0;
  2619. struct dp_soc *soc = pdev->soc;
  2620. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2621. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2622. QDF_STATUS status;
  2623. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2624. if (!soc_srngs_state) {
  2625. dp_htt_alert("Memory alloc failed for back pressure event");
  2626. return;
  2627. }
  2628. status = dp_get_srng_ring_state_from_hal
  2629. (pdev->soc, pdev,
  2630. &pdev->soc->reo_exception_ring,
  2631. REO_EXCEPTION,
  2632. &soc_srngs_state->ring_state[j]);
  2633. if (status == QDF_STATUS_SUCCESS) {
  2634. j++;
  2635. qdf_assert_always(j < DP_MAX_SRNGS);
  2636. }
  2637. status = dp_get_srng_ring_state_from_hal
  2638. (pdev->soc, pdev,
  2639. &pdev->soc->reo_reinject_ring,
  2640. REO_REINJECT,
  2641. &soc_srngs_state->ring_state[j]);
  2642. if (status == QDF_STATUS_SUCCESS) {
  2643. j++;
  2644. qdf_assert_always(j < DP_MAX_SRNGS);
  2645. }
  2646. status = dp_get_srng_ring_state_from_hal
  2647. (pdev->soc, pdev,
  2648. &pdev->soc->reo_cmd_ring,
  2649. REO_CMD,
  2650. &soc_srngs_state->ring_state[j]);
  2651. if (status == QDF_STATUS_SUCCESS) {
  2652. j++;
  2653. qdf_assert_always(j < DP_MAX_SRNGS);
  2654. }
  2655. status = dp_get_srng_ring_state_from_hal
  2656. (pdev->soc, pdev,
  2657. &pdev->soc->reo_status_ring,
  2658. REO_STATUS,
  2659. &soc_srngs_state->ring_state[j]);
  2660. if (status == QDF_STATUS_SUCCESS) {
  2661. j++;
  2662. qdf_assert_always(j < DP_MAX_SRNGS);
  2663. }
  2664. status = dp_get_srng_ring_state_from_hal
  2665. (pdev->soc, pdev,
  2666. &pdev->soc->rx_rel_ring,
  2667. WBM2SW_RELEASE,
  2668. &soc_srngs_state->ring_state[j]);
  2669. if (status == QDF_STATUS_SUCCESS) {
  2670. j++;
  2671. qdf_assert_always(j < DP_MAX_SRNGS);
  2672. }
  2673. status = dp_get_tcl_cmd_cred_ring_state_from_hal
  2674. (pdev, &soc_srngs_state->ring_state[j]);
  2675. if (status == QDF_STATUS_SUCCESS) {
  2676. j++;
  2677. qdf_assert_always(j < DP_MAX_SRNGS);
  2678. }
  2679. status = dp_get_tcl_status_ring_state_from_hal
  2680. (pdev, &soc_srngs_state->ring_state[j]);
  2681. if (status == QDF_STATUS_SUCCESS) {
  2682. j++;
  2683. qdf_assert_always(j < DP_MAX_SRNGS);
  2684. }
  2685. status = dp_get_srng_ring_state_from_hal
  2686. (pdev->soc, pdev,
  2687. &pdev->soc->wbm_desc_rel_ring,
  2688. SW2WBM_RELEASE,
  2689. &soc_srngs_state->ring_state[j]);
  2690. if (status == QDF_STATUS_SUCCESS) {
  2691. j++;
  2692. qdf_assert_always(j < DP_MAX_SRNGS);
  2693. }
  2694. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2695. status = dp_get_srng_ring_state_from_hal
  2696. (pdev->soc, pdev,
  2697. &pdev->soc->reo_dest_ring[i],
  2698. REO_DST,
  2699. &soc_srngs_state->ring_state[j]);
  2700. if (status == QDF_STATUS_SUCCESS) {
  2701. j++;
  2702. qdf_assert_always(j < DP_MAX_SRNGS);
  2703. }
  2704. }
  2705. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2706. status = dp_get_srng_ring_state_from_hal
  2707. (pdev->soc, pdev,
  2708. &pdev->soc->tcl_data_ring[i],
  2709. TCL_DATA,
  2710. &soc_srngs_state->ring_state[j]);
  2711. if (status == QDF_STATUS_SUCCESS) {
  2712. j++;
  2713. qdf_assert_always(j < DP_MAX_SRNGS);
  2714. }
  2715. }
  2716. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2717. status = dp_get_srng_ring_state_from_hal
  2718. (pdev->soc, pdev,
  2719. &pdev->soc->tx_comp_ring[i],
  2720. WBM2SW_RELEASE,
  2721. &soc_srngs_state->ring_state[j]);
  2722. if (status == QDF_STATUS_SUCCESS) {
  2723. j++;
  2724. qdf_assert_always(j < DP_MAX_SRNGS);
  2725. }
  2726. }
  2727. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2728. status = dp_get_srng_ring_state_from_hal
  2729. (pdev->soc, pdev,
  2730. &pdev->soc->rx_refill_buf_ring
  2731. [lmac_id],
  2732. RXDMA_BUF,
  2733. &soc_srngs_state->ring_state[j]);
  2734. if (status == QDF_STATUS_SUCCESS) {
  2735. j++;
  2736. qdf_assert_always(j < DP_MAX_SRNGS);
  2737. }
  2738. status = dp_get_srng_ring_state_from_hal
  2739. (pdev->soc, pdev,
  2740. &pdev->rx_refill_buf_ring2,
  2741. RXDMA_BUF,
  2742. &soc_srngs_state->ring_state[j]);
  2743. if (status == QDF_STATUS_SUCCESS) {
  2744. j++;
  2745. qdf_assert_always(j < DP_MAX_SRNGS);
  2746. }
  2747. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2748. dp_get_srng_ring_state_from_hal
  2749. (pdev->soc, pdev,
  2750. &pdev->rx_mac_buf_ring[i],
  2751. RXDMA_BUF,
  2752. &soc_srngs_state->ring_state[j]);
  2753. if (status == QDF_STATUS_SUCCESS) {
  2754. j++;
  2755. qdf_assert_always(j < DP_MAX_SRNGS);
  2756. }
  2757. }
  2758. for (mac_id = 0;
  2759. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2760. mac_id++) {
  2761. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2762. mac_id, pdev->pdev_id);
  2763. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2764. soc_srngs_state);
  2765. status = dp_get_srng_ring_state_from_hal
  2766. (pdev->soc, pdev,
  2767. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2768. RXDMA_MONITOR_STATUS,
  2769. &soc_srngs_state->ring_state[j]);
  2770. if (status == QDF_STATUS_SUCCESS) {
  2771. j++;
  2772. qdf_assert_always(j < DP_MAX_SRNGS);
  2773. }
  2774. }
  2775. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2776. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2777. i, pdev->pdev_id);
  2778. status = dp_get_srng_ring_state_from_hal
  2779. (pdev->soc, pdev,
  2780. &pdev->soc->rxdma_err_dst_ring
  2781. [lmac_id],
  2782. RXDMA_DST,
  2783. &soc_srngs_state->ring_state[j]);
  2784. if (status == QDF_STATUS_SUCCESS) {
  2785. j++;
  2786. qdf_assert_always(j < DP_MAX_SRNGS);
  2787. }
  2788. }
  2789. soc_srngs_state->max_ring_id = j;
  2790. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2791. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2792. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2793. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2794. qdf_assert_always(drop_srngs_state);
  2795. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2796. list_elem);
  2797. qdf_mem_free(drop_srngs_state);
  2798. pdev->bkp_stats.queue_depth--;
  2799. }
  2800. pdev->bkp_stats.queue_depth++;
  2801. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2802. list_elem);
  2803. pdev->bkp_stats.seq_num++;
  2804. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2805. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2806. &pdev->bkp_stats.work);
  2807. }
  2808. #ifdef WIFI_MONITOR_SUPPORT
  2809. static void
  2810. dp_check_backpressure_in_monitor(uint8_t ring_id, struct dp_pdev *pdev)
  2811. {
  2812. if (ring_id >= HTT_SW_RING_IDX_MONITOR_STATUS_RING &&
  2813. ring_id <= HTT_SW_LMAC_RING_IDX_MAX)
  2814. pdev->monitor_pdev->is_bkpressure = true;
  2815. }
  2816. #else
  2817. static void
  2818. dp_check_backpressure_in_monitor(uint8_t ring_id, struct dp_pdev *pdev)
  2819. {
  2820. }
  2821. #endif
  2822. /**
  2823. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2824. * @msg_word: htt packet context
  2825. * @soc: HTT SOC handle
  2826. *
  2827. * Return: after attempting to print stats
  2828. */
  2829. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2830. {
  2831. u_int8_t ring_type;
  2832. u_int8_t pdev_id;
  2833. uint8_t target_pdev_id;
  2834. u_int8_t ring_id;
  2835. u_int16_t hp_idx;
  2836. u_int16_t tp_idx;
  2837. u_int32_t bkp_time;
  2838. u_int32_t th_time;
  2839. enum htt_t2h_msg_type msg_type;
  2840. struct dp_soc *dpsoc;
  2841. struct dp_pdev *pdev;
  2842. struct dp_htt_timestamp *radio_tt;
  2843. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2844. if (!soc)
  2845. return;
  2846. dpsoc = (struct dp_soc *)soc->dp_soc;
  2847. soc_cfg_ctx = dpsoc->wlan_cfg_ctx;
  2848. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2849. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2850. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2851. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2852. target_pdev_id);
  2853. if (pdev_id >= MAX_PDEV_CNT) {
  2854. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2855. return;
  2856. }
  2857. th_time = wlan_cfg_time_control_bp(soc_cfg_ctx);
  2858. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2859. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2860. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2861. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2862. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2863. radio_tt = &soc->pdevid_tt[pdev_id];
  2864. switch (ring_type) {
  2865. case HTT_SW_RING_TYPE_UMAC:
  2866. if (!time_allow_print(radio_tt->umac_path, ring_id, th_time))
  2867. return;
  2868. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2869. bkp_time, radio_tt->umac_path,
  2870. "HTT_SW_RING_TYPE_UMAC");
  2871. break;
  2872. case HTT_SW_RING_TYPE_LMAC:
  2873. if (!time_allow_print(radio_tt->lmac_path, ring_id, th_time))
  2874. return;
  2875. dp_check_backpressure_in_monitor(ring_id, pdev);
  2876. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2877. bkp_time, radio_tt->lmac_path,
  2878. "HTT_SW_RING_TYPE_LMAC");
  2879. break;
  2880. default:
  2881. dp_alert("Invalid ring type: %d", ring_type);
  2882. break;
  2883. }
  2884. dp_queue_ring_stats(pdev);
  2885. }
  2886. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2887. /**
  2888. * dp_offload_ind_handler() - offload msg handler
  2889. * @soc: HTT SOC handle
  2890. * @msg_word: Pointer to payload
  2891. *
  2892. * Return: None
  2893. */
  2894. static void
  2895. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2896. {
  2897. u_int8_t pdev_id;
  2898. u_int8_t target_pdev_id;
  2899. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2900. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2901. target_pdev_id);
  2902. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2903. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2904. pdev_id);
  2905. }
  2906. #else
  2907. static void
  2908. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2909. {
  2910. }
  2911. #endif
  2912. #ifdef WLAN_FEATURE_11BE_MLO
  2913. #ifdef WLAN_MLO_MULTI_CHIP
  2914. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2915. uint32_t ts_lo, uint32_t ts_hi)
  2916. {
  2917. uint64_t mlo_offset;
  2918. mlo_offset = ((uint64_t)(ts_hi) << 32 | ts_lo);
  2919. soc->cdp_soc.ops->mlo_ops->mlo_update_mlo_ts_offset
  2920. ((struct cdp_soc_t *)soc, mlo_offset);
  2921. }
  2922. static inline
  2923. void dp_update_mlo_delta_tsf2(struct dp_soc *soc, struct dp_pdev *pdev)
  2924. {
  2925. uint64_t delta_tsf2 = 0;
  2926. hal_get_tsf2_offset(soc->hal_soc, pdev->lmac_id, &delta_tsf2);
  2927. soc->cdp_soc.ops->mlo_ops->mlo_update_delta_tsf2
  2928. ((struct cdp_soc_t *)soc, pdev->pdev_id, delta_tsf2);
  2929. }
  2930. #else
  2931. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2932. uint32_t ts_lo, uint32_t ts_hi)
  2933. {}
  2934. static inline
  2935. void dp_update_mlo_delta_tsf2(struct dp_soc *soc, struct dp_pdev *pdev)
  2936. {}
  2937. #endif
  2938. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2939. uint32_t *msg_word)
  2940. {
  2941. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2942. uint8_t *mlo_peer_mac_addr;
  2943. uint16_t mlo_peer_id;
  2944. uint8_t num_links;
  2945. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2946. struct dp_mlo_link_info mlo_link_info[DP_MAX_MLO_LINKS];
  2947. MLO_PEER_MAP_TLV_TAG_ID tlv_type = 0xff;
  2948. uint16_t tlv_len = 0;
  2949. int i = 0;
  2950. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2951. num_links =
  2952. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2953. mlo_peer_mac_addr =
  2954. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2955. &mac_addr_deswizzle_buf[0]);
  2956. mlo_flow_info[0].ast_idx =
  2957. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2958. mlo_flow_info[0].ast_idx_valid =
  2959. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2960. mlo_flow_info[0].chip_id =
  2961. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2962. mlo_flow_info[0].tidmask =
  2963. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2964. mlo_flow_info[0].cache_set_num =
  2965. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2966. mlo_flow_info[1].ast_idx =
  2967. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2968. mlo_flow_info[1].ast_idx_valid =
  2969. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2970. mlo_flow_info[1].chip_id =
  2971. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2972. mlo_flow_info[1].tidmask =
  2973. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2974. mlo_flow_info[1].cache_set_num =
  2975. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2976. mlo_flow_info[2].ast_idx =
  2977. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2978. mlo_flow_info[2].ast_idx_valid =
  2979. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2980. mlo_flow_info[2].chip_id =
  2981. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2982. mlo_flow_info[2].tidmask =
  2983. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2984. mlo_flow_info[2].cache_set_num =
  2985. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2986. msg_word = msg_word + 8;
  2987. while (msg_word && (i < DP_MAX_MLO_LINKS)) {
  2988. mlo_link_info[i].peer_chip_id = 0xFF;
  2989. mlo_link_info[i].vdev_id = 0xFF;
  2990. tlv_type = HTT_RX_MLO_PEER_MAP_TLV_TAG_GET(*msg_word);
  2991. tlv_len = HTT_RX_MLO_PEER_MAP_TLV_LENGTH_GET(*msg_word);
  2992. if (tlv_len == 0) {
  2993. dp_err("TLV Length is 0");
  2994. break;
  2995. }
  2996. if (tlv_type == MLO_PEER_MAP_TLV_STRUCT_SOC_VDEV_PEER_IDS) {
  2997. mlo_link_info[i].peer_chip_id =
  2998. HTT_RX_MLO_PEER_MAP_CHIP_ID_GET(
  2999. *(msg_word + 1));
  3000. mlo_link_info[i].vdev_id =
  3001. HTT_RX_MLO_PEER_MAP_VDEV_ID_GET(
  3002. *(msg_word + 1));
  3003. }
  3004. /* Add header size to tlv length */
  3005. tlv_len = tlv_len + HTT_TLV_HDR_LEN;
  3006. msg_word = (uint32_t *)(((uint8_t *)msg_word) + tlv_len);
  3007. i++;
  3008. }
  3009. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  3010. mlo_peer_mac_addr,
  3011. mlo_flow_info, mlo_link_info);
  3012. }
  3013. #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
  3014. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  3015. uint32_t *msg_word)
  3016. {
  3017. u_int16_t peer_id;
  3018. u_int16_t ml_peer_id;
  3019. u_int16_t vdev_id;
  3020. u_int8_t pdev_id;
  3021. u_int8_t chip_id;
  3022. vdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_GET(
  3023. *msg_word);
  3024. pdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_GET(
  3025. *msg_word);
  3026. chip_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_GET(
  3027. *msg_word);
  3028. ml_peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_GET(
  3029. *(msg_word + 1));
  3030. peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_GET(
  3031. *(msg_word + 1));
  3032. dp_htt_info("HTT_T2H_MSG_TYPE_PRIMARY_PEER_MIGRATE_IND msg"
  3033. "for peer id %d vdev id %d", peer_id, vdev_id);
  3034. dp_htt_reo_migration(soc->dp_soc, peer_id, ml_peer_id,
  3035. vdev_id, pdev_id, chip_id);
  3036. }
  3037. #else
  3038. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  3039. uint32_t *msg_word)
  3040. {
  3041. }
  3042. #endif
  3043. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  3044. uint32_t *msg_word)
  3045. {
  3046. uint16_t mlo_peer_id;
  3047. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  3048. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  3049. }
  3050. static void
  3051. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  3052. uint32_t *msg_word)
  3053. {
  3054. uint8_t pdev_id;
  3055. uint8_t target_pdev_id;
  3056. struct dp_pdev *pdev;
  3057. if (!soc)
  3058. return;
  3059. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  3060. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  3061. target_pdev_id);
  3062. if (pdev_id >= MAX_PDEV_CNT) {
  3063. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  3064. return;
  3065. }
  3066. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  3067. if (!pdev) {
  3068. dp_err("Invalid pdev");
  3069. return;
  3070. }
  3071. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  3072. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  3073. pdev_id);
  3074. qdf_spin_lock_bh(&soc->htt_stats.lock);
  3075. pdev->timestamp.msg_type =
  3076. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  3077. pdev->timestamp.pdev_id = pdev_id;
  3078. pdev->timestamp.chip_id =
  3079. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  3080. pdev->timestamp.mac_clk_freq =
  3081. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  3082. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  3083. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  3084. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  3085. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  3086. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  3087. pdev->timestamp.mlo_comp_us =
  3088. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  3089. *(msg_word + 6));
  3090. pdev->timestamp.mlo_comp_clks =
  3091. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  3092. *(msg_word + 6));
  3093. pdev->timestamp.mlo_comp_timer =
  3094. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  3095. *(msg_word + 7));
  3096. dp_htt_debug("tsf_lo=%d tsf_hi=%d, mlo_ofst_lo=%d, mlo_ofst_hi=%d",
  3097. pdev->timestamp.sync_tstmp_lo_us,
  3098. pdev->timestamp.sync_tstmp_hi_us,
  3099. pdev->timestamp.mlo_offset_lo_us,
  3100. pdev->timestamp.mlo_offset_hi_us);
  3101. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3102. dp_update_mlo_ts_offset(soc,
  3103. pdev->timestamp.mlo_offset_lo_us,
  3104. pdev->timestamp.mlo_offset_hi_us);
  3105. dp_update_mlo_delta_tsf2(soc, pdev);
  3106. }
  3107. #else
  3108. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  3109. uint32_t *msg_word)
  3110. {
  3111. dp_alert("Unexpected event");
  3112. }
  3113. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  3114. uint32_t *msg_word)
  3115. {
  3116. dp_alert("Unexpected event");
  3117. }
  3118. static void
  3119. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  3120. uint32_t *msg_word)
  3121. {
  3122. dp_alert("Unexpected event");
  3123. }
  3124. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  3125. uint32_t *msg_word)
  3126. {
  3127. }
  3128. #endif
  3129. /**
  3130. * dp_htt_rx_addba_handler() - RX Addba HTT msg handler
  3131. * @soc: DP Soc handler
  3132. * @peer_id: ID of peer
  3133. * @tid: TID number
  3134. * @win_sz: BA window size
  3135. *
  3136. * Return: None
  3137. */
  3138. static void
  3139. dp_htt_rx_addba_handler(struct dp_soc *soc, uint16_t peer_id,
  3140. uint8_t tid, uint16_t win_sz)
  3141. {
  3142. uint16_t status;
  3143. struct dp_peer *peer;
  3144. peer = dp_peer_get_ref_by_id(soc, peer_id, DP_MOD_ID_HTT);
  3145. if (!peer) {
  3146. dp_err("Peer not found peer id %d", peer_id);
  3147. return;
  3148. }
  3149. status = dp_addba_requestprocess_wifi3((struct cdp_soc_t *)soc,
  3150. peer->mac_addr.raw,
  3151. peer->vdev->vdev_id, 0,
  3152. tid, 0, win_sz, 0xffff);
  3153. dp_addba_resp_tx_completion_wifi3(
  3154. (struct cdp_soc_t *)soc,
  3155. peer->mac_addr.raw, peer->vdev->vdev_id,
  3156. tid,
  3157. status);
  3158. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3159. dp_info("PeerID %d BAW %d TID %d stat %d",
  3160. peer_id, win_sz, tid, status);
  3161. }
  3162. /**
  3163. * dp_htt_ppdu_id_fmt_handler() - PPDU ID Format handler
  3164. * @soc: HTT SOC handle
  3165. * @msg_word: Pointer to payload
  3166. *
  3167. * Return: None
  3168. */
  3169. static void
  3170. dp_htt_ppdu_id_fmt_handler(struct dp_soc *soc, uint32_t *msg_word)
  3171. {
  3172. uint8_t msg_type, valid, bits, offset;
  3173. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3174. msg_word += HTT_PPDU_ID_FMT_IND_LINK_ID_OFFSET;
  3175. valid = HTT_PPDU_ID_FMT_IND_VALID_GET_BITS31_16(*msg_word);
  3176. bits = HTT_PPDU_ID_FMT_IND_BITS_GET_BITS31_16(*msg_word);
  3177. offset = HTT_PPDU_ID_FMT_IND_OFFSET_GET_BITS31_16(*msg_word);
  3178. dp_info("link_id: valid %u bits %u offset %u", valid, bits, offset);
  3179. if (valid) {
  3180. soc->link_id_offset = offset;
  3181. soc->link_id_bits = bits;
  3182. }
  3183. }
  3184. #ifdef IPA_OPT_WIFI_DP
  3185. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3186. uint32_t *msg_word)
  3187. {
  3188. uint8_t pdev_id = 0;
  3189. uint8_t resp_type = 0;
  3190. uint8_t is_rules_enough = 0;
  3191. uint8_t num_rules_avail = 0;
  3192. int filter0_result = 0, filter1_result = 0;
  3193. bool is_success = false;
  3194. pdev_id = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_PDEV_ID_GET(*msg_word);
  3195. resp_type = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_RESPONSE_TYPE_GET(
  3196. *msg_word);
  3197. dp_info("opt_dp:: cce_super_rule_rsp pdev_id: %d resp_type: %d",
  3198. pdev_id, resp_type);
  3199. switch (resp_type) {
  3200. case HTT_RX_CCE_SUPER_RULE_SETUP_REQ_RESPONSE:
  3201. {
  3202. is_rules_enough =
  3203. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_IS_RULE_ENOUGH_GET(
  3204. *msg_word);
  3205. num_rules_avail =
  3206. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_AVAIL_RULE_NUM_GET(
  3207. *msg_word);
  3208. if (is_rules_enough == 1) {
  3209. is_success = true;
  3210. soc->stats.reserve_fail_cnt = 0;
  3211. } else {
  3212. is_success = false;
  3213. soc->stats.reserve_fail_cnt++;
  3214. if (soc->stats.reserve_fail_cnt >
  3215. MAX_RESERVE_FAIL_ATTEMPT) {
  3216. /*
  3217. * IPA will retry only after an hour by default
  3218. * after MAX_RESERVE_FAIL_ATTEMPT
  3219. */
  3220. soc->stats.abort_count++;
  3221. soc->stats.reserve_fail_cnt = 0;
  3222. dp_info(
  3223. "opt_dp: Filter reserve failed max attempts");
  3224. }
  3225. dp_info("opt_dp:: Filter reserve failed. Rules avail %d",
  3226. num_rules_avail);
  3227. }
  3228. dp_ipa_wdi_opt_dpath_notify_flt_rsvd(is_success);
  3229. break;
  3230. }
  3231. case HTT_RX_CCE_SUPER_RULE_INSTALL_RESPONSE:
  3232. {
  3233. filter0_result =
  3234. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3235. *msg_word);
  3236. filter1_result =
  3237. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3238. *msg_word);
  3239. dp_ipa_wdi_opt_dpath_notify_flt_add_rem_cb(filter0_result,
  3240. filter1_result);
  3241. break;
  3242. }
  3243. case HTT_RX_CCE_SUPER_RULE_RELEASE_RESPONSE:
  3244. {
  3245. filter0_result =
  3246. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3247. *msg_word);
  3248. filter1_result =
  3249. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3250. *msg_word);
  3251. dp_ipa_wdi_opt_dpath_notify_flt_rlsd(filter0_result,
  3252. filter1_result);
  3253. break;
  3254. }
  3255. default:
  3256. dp_info("opt_dp:: Wrong Super rule setup response");
  3257. };
  3258. dp_info("opt_dp:: cce super rule resp type: %d, is_rules_enough: %d",
  3259. resp_type, is_rules_enough);
  3260. dp_info("num_rules_avail: %d, rslt0: %d, rslt1: %d",
  3261. num_rules_avail, filter0_result, filter1_result);
  3262. }
  3263. #else
  3264. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3265. uint32_t *msg_word)
  3266. {
  3267. }
  3268. #endif
  3269. #if defined(WLAN_FEATURE_11BE_MLO) && defined(DP_MLO_LINK_STATS_SUPPORT)
  3270. static inline void
  3271. dp_htt_peer_ext_evt(struct htt_soc *soc, uint32_t *msg_word)
  3272. {
  3273. struct dp_peer_ext_evt_info info;
  3274. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3275. info.peer_id = HTT_RX_PEER_EXTENDED_PEER_ID_GET(*msg_word);
  3276. info.vdev_id = HTT_RX_PEER_EXTENDED_VDEV_ID_GET(*msg_word);
  3277. info.link_id =
  3278. HTT_RX_PEER_EXTENDED_LOGICAL_LINK_ID_GET(*(msg_word + 2));
  3279. info.link_id_valid =
  3280. HTT_RX_PEER_EXTENDED_LOGICAL_LINK_ID_VALID_GET(*(msg_word + 2));
  3281. info.peer_mac_addr =
  3282. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3283. &mac_addr_deswizzle_buf[0]);
  3284. dp_htt_info("peer id %u, vdev id %u, link id %u, valid %u,peer_mac " QDF_MAC_ADDR_FMT,
  3285. info.peer_id, info.vdev_id, info.link_id,
  3286. info.link_id_valid, QDF_MAC_ADDR_REF(info.peer_mac_addr));
  3287. dp_rx_peer_ext_evt(soc->dp_soc, &info);
  3288. }
  3289. #else
  3290. static inline void
  3291. dp_htt_peer_ext_evt(struct htt_soc *soc, uint32_t *msg_word)
  3292. {
  3293. }
  3294. #endif
  3295. #ifdef WLAN_FEATURE_CE_RX_BUFFER_REUSE
  3296. static void dp_htt_rx_nbuf_free(qdf_nbuf_t nbuf)
  3297. {
  3298. nbuf = wbuff_buff_put(nbuf);
  3299. if (nbuf)
  3300. qdf_nbuf_free(nbuf);
  3301. }
  3302. #else
  3303. static inline void dp_htt_rx_nbuf_free(qdf_nbuf_t nbuf)
  3304. {
  3305. return qdf_nbuf_free(nbuf);
  3306. }
  3307. #endif
  3308. void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3309. {
  3310. struct htt_soc *soc = (struct htt_soc *) context;
  3311. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3312. u_int32_t *msg_word;
  3313. enum htt_t2h_msg_type msg_type;
  3314. bool free_buf = true;
  3315. /* check for successful message reception */
  3316. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3317. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3318. soc->stats.htc_err_cnt++;
  3319. dp_htt_rx_nbuf_free(htt_t2h_msg);
  3320. return;
  3321. }
  3322. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3323. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3324. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3325. htt_event_record(soc->htt_logger_handle,
  3326. msg_type, (uint8_t *)msg_word);
  3327. switch (msg_type) {
  3328. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3329. {
  3330. dp_htt_bkp_event_alert(msg_word, soc);
  3331. break;
  3332. }
  3333. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3334. {
  3335. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3336. u_int8_t *peer_mac_addr;
  3337. u_int16_t peer_id;
  3338. u_int16_t hw_peer_id;
  3339. u_int8_t vdev_id;
  3340. u_int8_t is_wds;
  3341. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3342. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3343. hw_peer_id =
  3344. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3345. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3346. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3347. (u_int8_t *) (msg_word+1),
  3348. &mac_addr_deswizzle_buf[0]);
  3349. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3350. QDF_TRACE_LEVEL_DEBUG,
  3351. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3352. peer_id, vdev_id);
  3353. /*
  3354. * check if peer already exists for this peer_id, if so
  3355. * this peer map event is in response for a wds peer add
  3356. * wmi command sent during wds source port learning.
  3357. * in this case just add the ast entry to the existing
  3358. * peer ast_list.
  3359. */
  3360. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  3361. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  3362. vdev_id, peer_mac_addr, 0,
  3363. is_wds);
  3364. break;
  3365. }
  3366. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  3367. {
  3368. u_int16_t peer_id;
  3369. u_int8_t vdev_id;
  3370. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  3371. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  3372. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  3373. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3374. vdev_id, mac_addr, 0,
  3375. DP_PEER_WDS_COUNT_INVALID);
  3376. break;
  3377. }
  3378. case HTT_T2H_MSG_TYPE_SEC_IND:
  3379. {
  3380. u_int16_t peer_id;
  3381. enum cdp_sec_type sec_type;
  3382. int is_unicast;
  3383. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  3384. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  3385. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  3386. /* point to the first part of the Michael key */
  3387. msg_word++;
  3388. dp_rx_sec_ind_handler(
  3389. soc->dp_soc, peer_id, sec_type, is_unicast,
  3390. msg_word, msg_word + 2);
  3391. break;
  3392. }
  3393. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  3394. {
  3395. free_buf =
  3396. dp_monitor_ppdu_stats_ind_handler(soc,
  3397. msg_word,
  3398. htt_t2h_msg);
  3399. break;
  3400. }
  3401. case HTT_T2H_MSG_TYPE_PKTLOG:
  3402. {
  3403. dp_pktlog_msg_handler(soc, msg_word);
  3404. break;
  3405. }
  3406. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  3407. {
  3408. /*
  3409. * HTC maintains runtime pm count for H2T messages that
  3410. * have a response msg from FW. This count ensures that
  3411. * in the case FW does not sent out the response or host
  3412. * did not process this indication runtime_put happens
  3413. * properly in the cleanup path.
  3414. */
  3415. if (htc_dec_return_htt_runtime_cnt(soc->htc_soc) >= 0)
  3416. htc_pm_runtime_put(soc->htc_soc);
  3417. else
  3418. soc->stats.htt_ver_req_put_skip++;
  3419. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3420. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3421. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  3422. "target uses HTT version %d.%d; host uses %d.%d",
  3423. soc->tgt_ver.major, soc->tgt_ver.minor,
  3424. HTT_CURRENT_VERSION_MAJOR,
  3425. HTT_CURRENT_VERSION_MINOR);
  3426. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3427. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3428. QDF_TRACE_LEVEL_WARN,
  3429. "*** Incompatible host/target HTT versions!");
  3430. }
  3431. /* abort if the target is incompatible with the host */
  3432. qdf_assert(soc->tgt_ver.major ==
  3433. HTT_CURRENT_VERSION_MAJOR);
  3434. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  3435. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3436. QDF_TRACE_LEVEL_INFO_LOW,
  3437. "*** Warning: host/target HTT versions"
  3438. " are different, though compatible!");
  3439. }
  3440. break;
  3441. }
  3442. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3443. {
  3444. uint16_t peer_id;
  3445. uint8_t tid;
  3446. uint16_t win_sz;
  3447. /*
  3448. * Update REO Queue Desc with new values
  3449. */
  3450. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3451. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3452. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3453. /*
  3454. * Window size needs to be incremented by 1
  3455. * since fw needs to represent a value of 256
  3456. * using just 8 bits
  3457. */
  3458. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3459. tid, win_sz + 1);
  3460. break;
  3461. }
  3462. case HTT_T2H_MSG_TYPE_RX_ADDBA_EXTN:
  3463. {
  3464. uint16_t peer_id;
  3465. uint8_t tid;
  3466. uint16_t win_sz;
  3467. peer_id = HTT_RX_ADDBA_EXTN_PEER_ID_GET(*msg_word);
  3468. tid = HTT_RX_ADDBA_EXTN_TID_GET(*msg_word);
  3469. msg_word++;
  3470. win_sz = HTT_RX_ADDBA_EXTN_WIN_SIZE_GET(*msg_word);
  3471. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3472. tid, win_sz);
  3473. break;
  3474. }
  3475. case HTT_T2H_PPDU_ID_FMT_IND:
  3476. {
  3477. dp_htt_ppdu_id_fmt_handler(soc->dp_soc, msg_word);
  3478. break;
  3479. }
  3480. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3481. {
  3482. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3483. break;
  3484. }
  3485. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3486. {
  3487. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3488. u_int8_t *peer_mac_addr;
  3489. u_int16_t peer_id;
  3490. u_int16_t hw_peer_id;
  3491. u_int8_t vdev_id;
  3492. bool is_wds;
  3493. u_int16_t ast_hash;
  3494. struct dp_ast_flow_override_info ast_flow_info = {0};
  3495. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3496. hw_peer_id =
  3497. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3498. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3499. peer_mac_addr =
  3500. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3501. &mac_addr_deswizzle_buf[0]);
  3502. is_wds =
  3503. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3504. ast_hash =
  3505. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3506. /*
  3507. * Update 4 ast_index per peer, ast valid mask
  3508. * and TID flow valid mask.
  3509. * AST valid mask is 3 bit field corresponds to
  3510. * ast_index[3:1]. ast_index 0 is always valid.
  3511. */
  3512. ast_flow_info.ast_valid_mask =
  3513. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  3514. ast_flow_info.ast_idx[0] = hw_peer_id;
  3515. ast_flow_info.ast_flow_mask[0] =
  3516. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  3517. ast_flow_info.ast_idx[1] =
  3518. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  3519. ast_flow_info.ast_flow_mask[1] =
  3520. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  3521. ast_flow_info.ast_idx[2] =
  3522. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  3523. ast_flow_info.ast_flow_mask[2] =
  3524. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  3525. ast_flow_info.ast_idx[3] =
  3526. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  3527. ast_flow_info.ast_flow_mask[3] =
  3528. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  3529. /*
  3530. * TID valid mask is applicable only
  3531. * for HI and LOW priority flows.
  3532. * tid_valid_mas is 8 bit field corresponds
  3533. * to TID[7:0]
  3534. */
  3535. ast_flow_info.tid_valid_low_pri_mask =
  3536. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  3537. ast_flow_info.tid_valid_hi_pri_mask =
  3538. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  3539. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3540. QDF_TRACE_LEVEL_DEBUG,
  3541. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3542. peer_id, vdev_id);
  3543. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3544. QDF_TRACE_LEVEL_INFO,
  3545. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  3546. ast_flow_info.ast_idx[0],
  3547. ast_flow_info.ast_idx[1],
  3548. ast_flow_info.ast_idx[2],
  3549. ast_flow_info.ast_idx[3]);
  3550. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3551. hw_peer_id, vdev_id,
  3552. peer_mac_addr, ast_hash,
  3553. is_wds);
  3554. /*
  3555. * Update ast indexes for flow override support
  3556. * Applicable only for non wds peers
  3557. */
  3558. if (!soc->dp_soc->ast_offload_support)
  3559. dp_peer_ast_index_flow_queue_map_create(
  3560. soc->dp_soc, is_wds,
  3561. peer_id, peer_mac_addr,
  3562. &ast_flow_info);
  3563. break;
  3564. }
  3565. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3566. {
  3567. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3568. u_int8_t *mac_addr;
  3569. u_int16_t peer_id;
  3570. u_int8_t vdev_id;
  3571. u_int8_t is_wds;
  3572. u_int32_t free_wds_count;
  3573. peer_id =
  3574. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3575. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3576. mac_addr =
  3577. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3578. &mac_addr_deswizzle_buf[0]);
  3579. is_wds =
  3580. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3581. free_wds_count =
  3582. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  3583. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3584. QDF_TRACE_LEVEL_INFO,
  3585. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3586. peer_id, vdev_id);
  3587. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3588. vdev_id, mac_addr,
  3589. is_wds, free_wds_count);
  3590. break;
  3591. }
  3592. case HTT_T2H_MSG_TYPE_RX_DELBA:
  3593. {
  3594. uint16_t peer_id;
  3595. uint8_t tid;
  3596. uint8_t win_sz;
  3597. QDF_STATUS status;
  3598. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  3599. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  3600. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  3601. status = dp_rx_delba_ind_handler(
  3602. soc->dp_soc,
  3603. peer_id, tid, win_sz);
  3604. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3605. QDF_TRACE_LEVEL_INFO,
  3606. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  3607. peer_id, win_sz, tid, status);
  3608. break;
  3609. }
  3610. case HTT_T2H_MSG_TYPE_RX_DELBA_EXTN:
  3611. {
  3612. uint16_t peer_id;
  3613. uint8_t tid;
  3614. uint16_t win_sz;
  3615. QDF_STATUS status;
  3616. peer_id = HTT_RX_DELBA_EXTN_PEER_ID_GET(*msg_word);
  3617. tid = HTT_RX_DELBA_EXTN_TID_GET(*msg_word);
  3618. msg_word++;
  3619. win_sz = HTT_RX_DELBA_EXTN_WIN_SIZE_GET(*msg_word);
  3620. status = dp_rx_delba_ind_handler(soc->dp_soc,
  3621. peer_id, tid,
  3622. win_sz);
  3623. dp_info("DELBA PeerID %d BAW %d TID %d stat %d",
  3624. peer_id, win_sz, tid, status);
  3625. break;
  3626. }
  3627. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  3628. {
  3629. uint16_t num_entries;
  3630. uint32_t cmem_ba_lo;
  3631. uint32_t cmem_ba_hi;
  3632. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  3633. cmem_ba_lo = *(msg_word + 1);
  3634. cmem_ba_hi = *(msg_word + 2);
  3635. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3636. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  3637. num_entries, cmem_ba_lo, cmem_ba_hi);
  3638. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  3639. cmem_ba_lo, cmem_ba_hi);
  3640. break;
  3641. }
  3642. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  3643. {
  3644. dp_offload_ind_handler(soc, msg_word);
  3645. break;
  3646. }
  3647. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  3648. {
  3649. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3650. u_int8_t *peer_mac_addr;
  3651. u_int16_t peer_id;
  3652. u_int16_t hw_peer_id;
  3653. u_int8_t vdev_id;
  3654. uint8_t is_wds;
  3655. u_int16_t ast_hash = 0;
  3656. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  3657. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  3658. peer_mac_addr =
  3659. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3660. &mac_addr_deswizzle_buf[0]);
  3661. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3662. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3663. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3664. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3665. peer_id, vdev_id);
  3666. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3667. hw_peer_id, vdev_id,
  3668. peer_mac_addr, ast_hash,
  3669. is_wds);
  3670. break;
  3671. }
  3672. case HTT_T2H_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_IND:
  3673. {
  3674. dp_htt_t2h_primary_link_migration(soc, msg_word);
  3675. break;
  3676. }
  3677. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3678. {
  3679. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3680. break;
  3681. }
  3682. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3683. {
  3684. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3685. break;
  3686. }
  3687. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3688. {
  3689. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3690. break;
  3691. }
  3692. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3693. {
  3694. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3695. break;
  3696. }
  3697. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3698. {
  3699. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3700. htt_t2h_msg);
  3701. break;
  3702. }
  3703. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3704. {
  3705. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3706. break;
  3707. }
  3708. case HTT_T2H_MSG_TYPE_PEER_AST_OVERRIDE_INDEX_IND:
  3709. {
  3710. dp_sawf_dynamic_ast_update(soc, msg_word, htt_t2h_msg);
  3711. break;
  3712. }
  3713. case HTT_T2H_MSG_TYPE_STREAMING_STATS_IND:
  3714. {
  3715. dp_sawf_mpdu_stats_handler(soc, htt_t2h_msg);
  3716. break;
  3717. }
  3718. case HTT_T2H_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP_DONE:
  3719. {
  3720. dp_ipa_rx_cce_super_rule_setup_done_handler(soc, msg_word);
  3721. break;
  3722. }
  3723. case HTT_T2H_MSG_TYPE_PEER_EXTENDED_EVENT:
  3724. {
  3725. dp_htt_peer_ext_evt(soc, msg_word);
  3726. break;
  3727. }
  3728. default:
  3729. break;
  3730. };
  3731. /* Free the indication buffer */
  3732. if (free_buf)
  3733. dp_htt_rx_nbuf_free(htt_t2h_msg);
  3734. }
  3735. enum htc_send_full_action
  3736. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3737. {
  3738. return HTC_SEND_FULL_KEEP;
  3739. }
  3740. QDF_STATUS
  3741. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3742. {
  3743. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3744. HTC_PACKET htc_pkt;
  3745. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3746. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3747. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3748. htc_pkt.pPktContext = (void *)nbuf;
  3749. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3750. return rc;
  3751. }
  3752. /**
  3753. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3754. * @soc: HTT SOC handle
  3755. *
  3756. * Return: QDF_STATUS
  3757. */
  3758. static QDF_STATUS
  3759. htt_htc_soc_attach(struct htt_soc *soc)
  3760. {
  3761. struct htc_service_connect_req connect;
  3762. struct htc_service_connect_resp response;
  3763. QDF_STATUS status;
  3764. struct dp_soc *dpsoc = soc->dp_soc;
  3765. qdf_mem_zero(&connect, sizeof(connect));
  3766. qdf_mem_zero(&response, sizeof(response));
  3767. connect.pMetaData = NULL;
  3768. connect.MetaDataLength = 0;
  3769. connect.EpCallbacks.pContext = soc;
  3770. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3771. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3772. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3773. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3774. connect.EpCallbacks.EpRecvRefill = NULL;
  3775. /* N/A, fill is done by HIF */
  3776. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3777. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3778. /*
  3779. * Specify how deep to let a queue get before htc_send_pkt will
  3780. * call the EpSendFull function due to excessive send queue depth.
  3781. */
  3782. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3783. /* disable flow control for HTT data message service */
  3784. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3785. /* connect to control service */
  3786. connect.service_id = HTT_DATA_MSG_SVC;
  3787. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3788. if (status != QDF_STATUS_SUCCESS)
  3789. return status;
  3790. soc->htc_endpoint = response.Endpoint;
  3791. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3792. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3793. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3794. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3795. return QDF_STATUS_SUCCESS; /* success */
  3796. }
  3797. void *
  3798. htt_soc_initialize(struct htt_soc *htt_soc,
  3799. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3800. HTC_HANDLE htc_soc,
  3801. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3802. {
  3803. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3804. soc->osdev = osdev;
  3805. soc->ctrl_psoc = ctrl_psoc;
  3806. soc->htc_soc = htc_soc;
  3807. soc->hal_soc = hal_soc_hdl;
  3808. if (htt_htc_soc_attach(soc))
  3809. goto fail2;
  3810. return soc;
  3811. fail2:
  3812. return NULL;
  3813. }
  3814. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3815. {
  3816. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3817. htt_htc_misc_pkt_pool_free(htt_handle);
  3818. htt_htc_pkt_pool_free(htt_handle);
  3819. }
  3820. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3821. {
  3822. int i;
  3823. soc->htt_htc_pkt_freelist = NULL;
  3824. /* pre-allocate some HTC_PACKET objects */
  3825. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3826. struct dp_htt_htc_pkt_union *pkt;
  3827. pkt = qdf_mem_malloc(sizeof(*pkt));
  3828. if (!pkt)
  3829. return QDF_STATUS_E_NOMEM;
  3830. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3831. }
  3832. return QDF_STATUS_SUCCESS;
  3833. }
  3834. void htt_soc_detach(struct htt_soc *htt_hdl)
  3835. {
  3836. int i;
  3837. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3838. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3839. qdf_mem_free(htt_handle->pdevid_tt[i].umac_path);
  3840. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_path);
  3841. }
  3842. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3843. qdf_mem_free(htt_handle);
  3844. }
  3845. /**
  3846. * dp_h2t_ext_stats_msg_send(): function to construct HTT message to pass to FW
  3847. * @pdev: DP PDEV handle
  3848. * @stats_type_upload_mask: stats type requested by user
  3849. * @config_param_0: extra configuration parameters
  3850. * @config_param_1: extra configuration parameters
  3851. * @config_param_2: extra configuration parameters
  3852. * @config_param_3: extra configuration parameters
  3853. * @cookie_val: cookie value
  3854. * @cookie_msb: msb of debug status cookie
  3855. * @mac_id: mac number
  3856. *
  3857. * return: QDF STATUS
  3858. */
  3859. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3860. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3861. uint32_t config_param_1, uint32_t config_param_2,
  3862. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3863. uint8_t mac_id)
  3864. {
  3865. struct htt_soc *soc = pdev->soc->htt_handle;
  3866. struct dp_htt_htc_pkt *pkt;
  3867. qdf_nbuf_t msg;
  3868. uint32_t *msg_word;
  3869. uint8_t pdev_mask = 0;
  3870. uint8_t *htt_logger_bufp;
  3871. int mac_for_pdev;
  3872. int target_pdev_id;
  3873. QDF_STATUS status;
  3874. msg = qdf_nbuf_alloc(
  3875. soc->osdev,
  3876. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3877. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3878. if (!msg)
  3879. return QDF_STATUS_E_NOMEM;
  3880. /*TODO:Add support for SOC stats
  3881. * Bit 0: SOC Stats
  3882. * Bit 1: Pdev stats for pdev id 0
  3883. * Bit 2: Pdev stats for pdev id 1
  3884. * Bit 3: Pdev stats for pdev id 2
  3885. */
  3886. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3887. target_pdev_id =
  3888. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3889. pdev_mask = 1 << target_pdev_id;
  3890. /*
  3891. * Set the length of the message.
  3892. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3893. * separately during the below call to qdf_nbuf_push_head.
  3894. * The contribution from the HTC header is added separately inside HTC.
  3895. */
  3896. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3897. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3898. "Failed to expand head for HTT_EXT_STATS");
  3899. qdf_nbuf_free(msg);
  3900. return QDF_STATUS_E_FAILURE;
  3901. }
  3902. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3903. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3904. htt_logger_bufp = (uint8_t *)msg_word;
  3905. *msg_word = 0;
  3906. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3907. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3908. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3909. /* word 1 */
  3910. msg_word++;
  3911. *msg_word = 0;
  3912. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3913. /* word 2 */
  3914. msg_word++;
  3915. *msg_word = 0;
  3916. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3917. /* word 3 */
  3918. msg_word++;
  3919. *msg_word = 0;
  3920. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3921. /* word 4 */
  3922. msg_word++;
  3923. *msg_word = 0;
  3924. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3925. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3926. /* word 5 */
  3927. msg_word++;
  3928. /* word 6 */
  3929. msg_word++;
  3930. *msg_word = 0;
  3931. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3932. /* word 7 */
  3933. msg_word++;
  3934. *msg_word = 0;
  3935. /* Currently Using last 2 bits for pdev_id
  3936. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3937. */
  3938. cookie_msb = (cookie_msb | pdev->pdev_id);
  3939. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3940. pkt = htt_htc_pkt_alloc(soc);
  3941. if (!pkt) {
  3942. qdf_nbuf_free(msg);
  3943. return QDF_STATUS_E_NOMEM;
  3944. }
  3945. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3946. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3947. dp_htt_h2t_send_complete_free_netbuf,
  3948. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3949. soc->htc_endpoint,
  3950. /* tag for FW response msg not guaranteed */
  3951. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3952. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3953. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3954. htt_logger_bufp);
  3955. if (status != QDF_STATUS_SUCCESS) {
  3956. qdf_nbuf_free(msg);
  3957. htt_htc_pkt_free(soc, pkt);
  3958. }
  3959. return status;
  3960. }
  3961. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3962. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3963. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3964. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3965. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3966. uint8_t pdev_id, bool enable,
  3967. bool reset, uint64_t reset_bitmask)
  3968. {
  3969. struct htt_soc *soc = dpsoc->htt_handle;
  3970. struct dp_htt_htc_pkt *pkt;
  3971. qdf_nbuf_t msg;
  3972. uint32_t *msg_word;
  3973. uint8_t *htt_logger_bufp;
  3974. QDF_STATUS status;
  3975. int duration;
  3976. uint32_t bitmask;
  3977. int target_pdev_id;
  3978. msg = qdf_nbuf_alloc(
  3979. soc->osdev,
  3980. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3981. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3982. if (!msg) {
  3983. dp_htt_err("%pK: Fail to allocate "
  3984. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3985. return QDF_STATUS_E_NOMEM;
  3986. }
  3987. if (pdev_id != INVALID_PDEV_ID)
  3988. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3989. else
  3990. target_pdev_id = 0;
  3991. duration =
  3992. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3993. /*
  3994. * Set the length of the message.
  3995. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3996. * separately during the below call to qdf_nbuf_push_head.
  3997. * The contribution from the HTC header is added separately inside HTC.
  3998. */
  3999. if (!qdf_nbuf_put_tail(msg,
  4000. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  4001. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  4002. , dpsoc);
  4003. qdf_nbuf_free(msg);
  4004. return QDF_STATUS_E_FAILURE;
  4005. }
  4006. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4007. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4008. htt_logger_bufp = (uint8_t *)msg_word;
  4009. *msg_word = 0;
  4010. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  4011. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  4012. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  4013. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  4014. (duration >> 3));
  4015. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  4016. msg_word++;
  4017. *msg_word = 0;
  4018. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  4019. *msg_word = bitmask;
  4020. msg_word++;
  4021. *msg_word = 0;
  4022. bitmask =
  4023. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  4024. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  4025. *msg_word = bitmask;
  4026. pkt = htt_htc_pkt_alloc(soc);
  4027. if (!pkt) {
  4028. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  4029. dpsoc);
  4030. qdf_assert(0);
  4031. qdf_nbuf_free(msg);
  4032. return QDF_STATUS_E_NOMEM;
  4033. }
  4034. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4035. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4036. dp_htt_h2t_send_complete_free_netbuf,
  4037. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4038. soc->htc_endpoint,
  4039. /* tag for no FW response msg */
  4040. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4041. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4042. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4043. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  4044. htt_logger_bufp);
  4045. if (status != QDF_STATUS_SUCCESS) {
  4046. qdf_nbuf_free(msg);
  4047. htt_htc_pkt_free(soc, pkt);
  4048. }
  4049. return status;
  4050. }
  4051. #else
  4052. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  4053. uint8_t pdev_id, bool enable,
  4054. bool reset, uint64_t reset_bitmask)
  4055. {
  4056. return QDF_STATUS_SUCCESS;
  4057. }
  4058. #endif
  4059. /**
  4060. * dp_h2t_3tuple_config_send(): function to construct 3 tuple configuration
  4061. * HTT message to pass to FW
  4062. * @pdev: DP PDEV handle
  4063. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  4064. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  4065. * @mac_id: mac id
  4066. *
  4067. * tuple_mask[1:0]:
  4068. * 00 - Do not report 3 tuple hash value
  4069. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  4070. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  4071. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  4072. *
  4073. * return: QDF STATUS
  4074. */
  4075. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  4076. uint32_t tuple_mask, uint8_t mac_id)
  4077. {
  4078. struct htt_soc *soc = pdev->soc->htt_handle;
  4079. struct dp_htt_htc_pkt *pkt;
  4080. qdf_nbuf_t msg;
  4081. uint32_t *msg_word;
  4082. uint8_t *htt_logger_bufp;
  4083. int mac_for_pdev;
  4084. int target_pdev_id;
  4085. msg = qdf_nbuf_alloc(
  4086. soc->osdev,
  4087. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  4088. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4089. if (!msg)
  4090. return QDF_STATUS_E_NOMEM;
  4091. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  4092. target_pdev_id =
  4093. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  4094. /*
  4095. * Set the length of the message.
  4096. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4097. * separately during the below call to qdf_nbuf_push_head.
  4098. * The contribution from the HTC header is added separately inside HTC.
  4099. */
  4100. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  4101. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  4102. "Failed to expand head for HTT_3TUPLE_CONFIG");
  4103. qdf_nbuf_free(msg);
  4104. return QDF_STATUS_E_FAILURE;
  4105. }
  4106. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  4107. pdev->soc, tuple_mask, target_pdev_id);
  4108. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4109. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4110. htt_logger_bufp = (uint8_t *)msg_word;
  4111. *msg_word = 0;
  4112. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  4113. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  4114. msg_word++;
  4115. *msg_word = 0;
  4116. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4117. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  4118. pkt = htt_htc_pkt_alloc(soc);
  4119. if (!pkt) {
  4120. qdf_nbuf_free(msg);
  4121. return QDF_STATUS_E_NOMEM;
  4122. }
  4123. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4124. SET_HTC_PACKET_INFO_TX(
  4125. &pkt->htc_pkt,
  4126. dp_htt_h2t_send_complete_free_netbuf,
  4127. qdf_nbuf_data(msg),
  4128. qdf_nbuf_len(msg),
  4129. soc->htc_endpoint,
  4130. /* tag for no FW response msg */
  4131. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4132. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4133. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4134. htt_logger_bufp);
  4135. return QDF_STATUS_SUCCESS;
  4136. }
  4137. /* This macro will revert once proper HTT header will define for
  4138. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4139. * */
  4140. #if defined(WDI_EVENT_ENABLE)
  4141. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4142. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4143. {
  4144. struct htt_soc *soc = pdev->soc->htt_handle;
  4145. struct dp_htt_htc_pkt *pkt;
  4146. qdf_nbuf_t msg;
  4147. uint32_t *msg_word;
  4148. uint8_t pdev_mask;
  4149. QDF_STATUS status;
  4150. msg = qdf_nbuf_alloc(
  4151. soc->osdev,
  4152. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4153. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4154. if (!msg) {
  4155. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  4156. , pdev->soc);
  4157. qdf_assert(0);
  4158. return QDF_STATUS_E_NOMEM;
  4159. }
  4160. /*TODO:Add support for SOC stats
  4161. * Bit 0: SOC Stats
  4162. * Bit 1: Pdev stats for pdev id 0
  4163. * Bit 2: Pdev stats for pdev id 1
  4164. * Bit 3: Pdev stats for pdev id 2
  4165. */
  4166. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4167. mac_id);
  4168. /*
  4169. * Set the length of the message.
  4170. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4171. * separately during the below call to qdf_nbuf_push_head.
  4172. * The contribution from the HTC header is added separately inside HTC.
  4173. */
  4174. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4175. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  4176. , pdev->soc);
  4177. qdf_nbuf_free(msg);
  4178. return QDF_STATUS_E_FAILURE;
  4179. }
  4180. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4181. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4182. *msg_word = 0;
  4183. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4184. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4185. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4186. stats_type_upload_mask);
  4187. pkt = htt_htc_pkt_alloc(soc);
  4188. if (!pkt) {
  4189. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  4190. qdf_assert(0);
  4191. qdf_nbuf_free(msg);
  4192. return QDF_STATUS_E_NOMEM;
  4193. }
  4194. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4195. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4196. dp_htt_h2t_send_complete_free_netbuf,
  4197. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4198. soc->htc_endpoint,
  4199. /* tag for no FW response msg */
  4200. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4201. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4202. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4203. (uint8_t *)msg_word);
  4204. if (status != QDF_STATUS_SUCCESS) {
  4205. qdf_nbuf_free(msg);
  4206. htt_htc_pkt_free(soc, pkt);
  4207. }
  4208. return status;
  4209. }
  4210. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  4211. #endif
  4212. void
  4213. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4214. uint32_t *tag_buf)
  4215. {
  4216. struct dp_peer *peer = NULL;
  4217. switch (tag_type) {
  4218. case HTT_STATS_PEER_DETAILS_TAG:
  4219. {
  4220. htt_peer_details_tlv *dp_stats_buf =
  4221. (htt_peer_details_tlv *)tag_buf;
  4222. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4223. }
  4224. break;
  4225. case HTT_STATS_PEER_STATS_CMN_TAG:
  4226. {
  4227. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4228. (htt_peer_stats_cmn_tlv *)tag_buf;
  4229. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4230. DP_MOD_ID_HTT);
  4231. if (peer && !peer->bss_peer) {
  4232. peer->stats.tx.inactive_time =
  4233. dp_stats_buf->inactive_time;
  4234. qdf_event_set(&pdev->fw_peer_stats_event);
  4235. }
  4236. if (peer)
  4237. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4238. }
  4239. break;
  4240. default:
  4241. qdf_err("Invalid tag_type: %u", tag_type);
  4242. }
  4243. }
  4244. QDF_STATUS
  4245. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4246. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4247. {
  4248. struct htt_soc *soc = pdev->soc->htt_handle;
  4249. struct dp_htt_htc_pkt *pkt;
  4250. qdf_nbuf_t msg;
  4251. u_int32_t *msg_word;
  4252. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4253. uint8_t *htt_logger_bufp;
  4254. u_int32_t *key;
  4255. QDF_STATUS status;
  4256. msg = qdf_nbuf_alloc(
  4257. soc->osdev,
  4258. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4259. /* reserve room for the HTC header */
  4260. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4261. if (!msg)
  4262. return QDF_STATUS_E_NOMEM;
  4263. /*
  4264. * Set the length of the message.
  4265. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4266. * separately during the below call to qdf_nbuf_push_head.
  4267. * The contribution from the HTC header is added separately inside HTC.
  4268. */
  4269. if (!qdf_nbuf_put_tail(msg,
  4270. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4271. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4272. return QDF_STATUS_E_FAILURE;
  4273. }
  4274. /* fill in the message contents */
  4275. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4276. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4277. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4278. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4279. htt_logger_bufp = (uint8_t *)msg_word;
  4280. *msg_word = 0;
  4281. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4282. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4283. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4284. msg_word++;
  4285. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4286. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4287. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4288. fse_setup_info->ip_da_sa_prefix);
  4289. msg_word++;
  4290. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4291. fse_setup_info->base_addr_lo);
  4292. msg_word++;
  4293. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4294. fse_setup_info->base_addr_hi);
  4295. key = (u_int32_t *)fse_setup_info->hash_key;
  4296. fse_setup->toeplitz31_0 = *key++;
  4297. fse_setup->toeplitz63_32 = *key++;
  4298. fse_setup->toeplitz95_64 = *key++;
  4299. fse_setup->toeplitz127_96 = *key++;
  4300. fse_setup->toeplitz159_128 = *key++;
  4301. fse_setup->toeplitz191_160 = *key++;
  4302. fse_setup->toeplitz223_192 = *key++;
  4303. fse_setup->toeplitz255_224 = *key++;
  4304. fse_setup->toeplitz287_256 = *key++;
  4305. fse_setup->toeplitz314_288 = *key;
  4306. msg_word++;
  4307. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4308. msg_word++;
  4309. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4310. msg_word++;
  4311. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4312. msg_word++;
  4313. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4314. msg_word++;
  4315. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4316. msg_word++;
  4317. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4318. msg_word++;
  4319. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4320. msg_word++;
  4321. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4322. msg_word++;
  4323. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4324. msg_word++;
  4325. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4326. fse_setup->toeplitz314_288);
  4327. pkt = htt_htc_pkt_alloc(soc);
  4328. if (!pkt) {
  4329. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4330. qdf_assert(0);
  4331. qdf_nbuf_free(msg);
  4332. return QDF_STATUS_E_RESOURCES; /* failure */
  4333. }
  4334. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4335. SET_HTC_PACKET_INFO_TX(
  4336. &pkt->htc_pkt,
  4337. dp_htt_h2t_send_complete_free_netbuf,
  4338. qdf_nbuf_data(msg),
  4339. qdf_nbuf_len(msg),
  4340. soc->htc_endpoint,
  4341. /* tag for no FW response msg */
  4342. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4343. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4344. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4345. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4346. htt_logger_bufp);
  4347. if (status == QDF_STATUS_SUCCESS) {
  4348. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4349. fse_setup_info->pdev_id);
  4350. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4351. (void *)fse_setup_info->hash_key,
  4352. fse_setup_info->hash_key_len);
  4353. } else {
  4354. qdf_nbuf_free(msg);
  4355. htt_htc_pkt_free(soc, pkt);
  4356. }
  4357. return status;
  4358. }
  4359. QDF_STATUS
  4360. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4361. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4362. {
  4363. struct htt_soc *soc = pdev->soc->htt_handle;
  4364. struct dp_htt_htc_pkt *pkt;
  4365. qdf_nbuf_t msg;
  4366. u_int32_t *msg_word;
  4367. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4368. uint8_t *htt_logger_bufp;
  4369. QDF_STATUS status;
  4370. msg = qdf_nbuf_alloc(
  4371. soc->osdev,
  4372. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4373. /* reserve room for the HTC header */
  4374. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4375. if (!msg)
  4376. return QDF_STATUS_E_NOMEM;
  4377. /*
  4378. * Set the length of the message.
  4379. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4380. * separately during the below call to qdf_nbuf_push_head.
  4381. * The contribution from the HTC header is added separately inside HTC.
  4382. */
  4383. if (!qdf_nbuf_put_tail(msg,
  4384. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4385. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4386. qdf_nbuf_free(msg);
  4387. return QDF_STATUS_E_FAILURE;
  4388. }
  4389. /* fill in the message contents */
  4390. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4391. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4392. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4393. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4394. htt_logger_bufp = (uint8_t *)msg_word;
  4395. *msg_word = 0;
  4396. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4397. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4398. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4399. msg_word++;
  4400. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4401. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4402. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4403. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4404. msg_word++;
  4405. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4406. *msg_word,
  4407. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4408. msg_word++;
  4409. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4410. *msg_word,
  4411. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4412. msg_word++;
  4413. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4414. *msg_word,
  4415. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4416. msg_word++;
  4417. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4418. *msg_word,
  4419. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4420. msg_word++;
  4421. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4422. *msg_word,
  4423. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4424. msg_word++;
  4425. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4426. *msg_word,
  4427. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4428. msg_word++;
  4429. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4430. *msg_word,
  4431. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4432. msg_word++;
  4433. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4434. *msg_word,
  4435. qdf_htonl(
  4436. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4437. msg_word++;
  4438. HTT_RX_FSE_SOURCEPORT_SET(
  4439. *msg_word,
  4440. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4441. HTT_RX_FSE_DESTPORT_SET(
  4442. *msg_word,
  4443. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4444. msg_word++;
  4445. HTT_RX_FSE_L4_PROTO_SET(
  4446. *msg_word,
  4447. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4448. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4449. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4450. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4451. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4452. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4453. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4454. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4455. }
  4456. pkt = htt_htc_pkt_alloc(soc);
  4457. if (!pkt) {
  4458. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4459. qdf_assert(0);
  4460. qdf_nbuf_free(msg);
  4461. return QDF_STATUS_E_RESOURCES; /* failure */
  4462. }
  4463. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4464. SET_HTC_PACKET_INFO_TX(
  4465. &pkt->htc_pkt,
  4466. dp_htt_h2t_send_complete_free_netbuf,
  4467. qdf_nbuf_data(msg),
  4468. qdf_nbuf_len(msg),
  4469. soc->htc_endpoint,
  4470. /* tag for no FW response msg */
  4471. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4472. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4473. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4474. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4475. htt_logger_bufp);
  4476. if (status == QDF_STATUS_SUCCESS) {
  4477. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4478. fse_op_info->pdev_id);
  4479. } else {
  4480. qdf_nbuf_free(msg);
  4481. htt_htc_pkt_free(soc, pkt);
  4482. }
  4483. return status;
  4484. }
  4485. /**
  4486. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4487. * @pdev: DP pdev handle
  4488. * @fisa_config: Fisa config struct
  4489. *
  4490. * Return: Success when HTT message is sent, error on failure
  4491. */
  4492. QDF_STATUS
  4493. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4494. struct dp_htt_rx_fisa_cfg *fisa_config)
  4495. {
  4496. struct htt_soc *soc = pdev->soc->htt_handle;
  4497. struct dp_htt_htc_pkt *pkt;
  4498. qdf_nbuf_t msg;
  4499. u_int32_t *msg_word;
  4500. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4501. uint8_t *htt_logger_bufp;
  4502. uint32_t len;
  4503. QDF_STATUS status;
  4504. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4505. msg = qdf_nbuf_alloc(soc->osdev,
  4506. len,
  4507. /* reserve room for the HTC header */
  4508. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4509. 4,
  4510. TRUE);
  4511. if (!msg)
  4512. return QDF_STATUS_E_NOMEM;
  4513. /*
  4514. * Set the length of the message.
  4515. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4516. * separately during the below call to qdf_nbuf_push_head.
  4517. * The contribution from the HTC header is added separately inside HTC.
  4518. */
  4519. if (!qdf_nbuf_put_tail(msg,
  4520. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4521. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4522. qdf_nbuf_free(msg);
  4523. return QDF_STATUS_E_FAILURE;
  4524. }
  4525. /* fill in the message contents */
  4526. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4527. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4528. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4529. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4530. htt_logger_bufp = (uint8_t *)msg_word;
  4531. *msg_word = 0;
  4532. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4533. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4534. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4535. msg_word++;
  4536. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4537. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word,
  4538. (fisa_config->max_aggr_supported ? fisa_config->max_aggr_supported : 0xf));
  4539. msg_word++;
  4540. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4541. pkt = htt_htc_pkt_alloc(soc);
  4542. if (!pkt) {
  4543. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4544. qdf_assert(0);
  4545. qdf_nbuf_free(msg);
  4546. return QDF_STATUS_E_RESOURCES; /* failure */
  4547. }
  4548. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4549. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4550. dp_htt_h2t_send_complete_free_netbuf,
  4551. qdf_nbuf_data(msg),
  4552. qdf_nbuf_len(msg),
  4553. soc->htc_endpoint,
  4554. /* tag for no FW response msg */
  4555. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4556. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4557. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4558. htt_logger_bufp);
  4559. if (status == QDF_STATUS_SUCCESS) {
  4560. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4561. fisa_config->pdev_id);
  4562. } else {
  4563. qdf_nbuf_free(msg);
  4564. htt_htc_pkt_free(soc, pkt);
  4565. }
  4566. return status;
  4567. }
  4568. #ifdef WLAN_SUPPORT_PPEDS
  4569. /**
  4570. * dp_htt_rxdma_rxole_ppe_cfg_set() - Send RxOLE and RxDMA PPE config
  4571. * @soc: Data path SoC handle
  4572. * @cfg: RxDMA and RxOLE PPE config
  4573. *
  4574. * Return: Success when HTT message is sent, error on failure
  4575. */
  4576. QDF_STATUS
  4577. dp_htt_rxdma_rxole_ppe_cfg_set(struct dp_soc *soc,
  4578. struct dp_htt_rxdma_rxole_ppe_config *cfg)
  4579. {
  4580. struct htt_soc *htt_handle = soc->htt_handle;
  4581. uint32_t len;
  4582. qdf_nbuf_t msg;
  4583. u_int32_t *msg_word;
  4584. QDF_STATUS status;
  4585. uint8_t *htt_logger_bufp;
  4586. struct dp_htt_htc_pkt *pkt;
  4587. len = HTT_MSG_BUF_SIZE(
  4588. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4589. msg = qdf_nbuf_alloc(soc->osdev,
  4590. len,
  4591. /* reserve room for the HTC header */
  4592. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4593. 4,
  4594. TRUE);
  4595. if (!msg)
  4596. return QDF_STATUS_E_NOMEM;
  4597. /*
  4598. * Set the length of the message.
  4599. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4600. * separately during the below call to qdf_nbuf_push_head.
  4601. * The contribution from the HTC header is added separately inside HTC.
  4602. */
  4603. if (!qdf_nbuf_put_tail(
  4604. msg, sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t))) {
  4605. qdf_err("Failed to expand head for HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG msg");
  4606. qdf_nbuf_free(msg);
  4607. return QDF_STATUS_E_FAILURE;
  4608. }
  4609. /* fill in the message contents */
  4610. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4611. memset(msg_word, 0,
  4612. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4613. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4614. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4615. htt_logger_bufp = (uint8_t *)msg_word;
  4616. *msg_word = 0;
  4617. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG);
  4618. HTT_PPE_CFG_OVERRIDE_SET(*msg_word, cfg->override);
  4619. HTT_PPE_CFG_REO_DEST_IND_SET(
  4620. *msg_word, cfg->reo_destination_indication);
  4621. HTT_PPE_CFG_MULTI_BUF_MSDU_OVERRIDE_EN_SET(
  4622. *msg_word, cfg->multi_buffer_msdu_override_en);
  4623. HTT_PPE_CFG_INTRA_BSS_OVERRIDE_EN_SET(
  4624. *msg_word, cfg->intra_bss_override);
  4625. HTT_PPE_CFG_DECAP_RAW_OVERRIDE_EN_SET(
  4626. *msg_word, cfg->decap_raw_override);
  4627. HTT_PPE_CFG_DECAP_NWIFI_OVERRIDE_EN_SET(
  4628. *msg_word, cfg->decap_nwifi_override);
  4629. HTT_PPE_CFG_IP_FRAG_OVERRIDE_EN_SET(
  4630. *msg_word, cfg->ip_frag_override);
  4631. pkt = htt_htc_pkt_alloc(htt_handle);
  4632. if (!pkt) {
  4633. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4634. qdf_assert(0);
  4635. qdf_nbuf_free(msg);
  4636. return QDF_STATUS_E_RESOURCES; /* failure */
  4637. }
  4638. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4639. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4640. dp_htt_h2t_send_complete_free_netbuf,
  4641. qdf_nbuf_data(msg),
  4642. qdf_nbuf_len(msg),
  4643. htt_handle->htc_endpoint,
  4644. /* tag for no FW response msg */
  4645. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4646. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4647. status = DP_HTT_SEND_HTC_PKT(htt_handle, pkt,
  4648. HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG,
  4649. htt_logger_bufp);
  4650. if (status != QDF_STATUS_SUCCESS) {
  4651. qdf_nbuf_free(msg);
  4652. htt_htc_pkt_free(htt_handle, pkt);
  4653. return status;
  4654. }
  4655. dp_info("HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG sent");
  4656. return status;
  4657. }
  4658. #endif /* WLAN_SUPPORT_PPEDS */
  4659. /**
  4660. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  4661. * stats
  4662. *
  4663. * @context : argument to work function
  4664. */
  4665. static void dp_bk_pressure_stats_handler(void *context)
  4666. {
  4667. struct dp_pdev *pdev = (struct dp_pdev *)context;
  4668. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  4669. const char *ring_name;
  4670. int i;
  4671. struct dp_srng_ring_state *ring_state;
  4672. bool empty_flag;
  4673. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4674. /* Extract only first entry for printing in one work event */
  4675. if (pdev->bkp_stats.queue_depth &&
  4676. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  4677. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  4678. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  4679. list_elem);
  4680. pdev->bkp_stats.queue_depth--;
  4681. }
  4682. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  4683. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4684. if (soc_srngs_state) {
  4685. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  4686. soc_srngs_state->seq_num);
  4687. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  4688. ring_state = &soc_srngs_state->ring_state[i];
  4689. ring_name = dp_srng_get_str_from_hal_ring_type
  4690. (ring_state->ring_type);
  4691. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  4692. ring_name,
  4693. ring_state->sw_head,
  4694. ring_state->sw_tail);
  4695. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  4696. ring_name,
  4697. ring_state->hw_head,
  4698. ring_state->hw_tail);
  4699. }
  4700. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  4701. soc_srngs_state->seq_num);
  4702. qdf_mem_free(soc_srngs_state);
  4703. }
  4704. dp_print_napi_stats(pdev->soc);
  4705. /* Schedule work again if queue is not empty */
  4706. if (!empty_flag)
  4707. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  4708. &pdev->bkp_stats.work);
  4709. }
  4710. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4711. {
  4712. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4713. if (!pdev->bkp_stats.work_queue)
  4714. return;
  4715. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4716. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4717. qdf_flush_work(&pdev->bkp_stats.work);
  4718. qdf_disable_work(&pdev->bkp_stats.work);
  4719. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4720. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4721. list_elem, ring_state_next) {
  4722. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4723. list_elem);
  4724. qdf_mem_free(ring_state);
  4725. }
  4726. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4727. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4728. }
  4729. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4730. {
  4731. TAILQ_INIT(&pdev->bkp_stats.list);
  4732. pdev->bkp_stats.seq_num = 0;
  4733. pdev->bkp_stats.queue_depth = 0;
  4734. qdf_create_work(0, &pdev->bkp_stats.work,
  4735. dp_bk_pressure_stats_handler, pdev);
  4736. pdev->bkp_stats.work_queue =
  4737. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4738. if (!pdev->bkp_stats.work_queue)
  4739. goto fail;
  4740. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4741. return QDF_STATUS_SUCCESS;
  4742. fail:
  4743. dp_htt_alert("BKP stats attach failed");
  4744. qdf_flush_work(&pdev->bkp_stats.work);
  4745. qdf_disable_work(&pdev->bkp_stats.work);
  4746. return QDF_STATUS_E_FAILURE;
  4747. }
  4748. #ifdef DP_UMAC_HW_RESET_SUPPORT
  4749. QDF_STATUS dp_htt_umac_reset_send_setup_cmd(
  4750. struct dp_soc *soc,
  4751. const struct dp_htt_umac_reset_setup_cmd_params *setup_params)
  4752. {
  4753. struct htt_soc *htt_handle = soc->htt_handle;
  4754. uint32_t len;
  4755. qdf_nbuf_t msg;
  4756. u_int32_t *msg_word;
  4757. QDF_STATUS status;
  4758. uint8_t *htt_logger_bufp;
  4759. struct dp_htt_htc_pkt *pkt;
  4760. len = HTT_MSG_BUF_SIZE(
  4761. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4762. msg = qdf_nbuf_alloc(soc->osdev,
  4763. len,
  4764. /* reserve room for the HTC header */
  4765. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4766. 4,
  4767. TRUE);
  4768. if (!msg)
  4769. return QDF_STATUS_E_NOMEM;
  4770. /*
  4771. * Set the length of the message.
  4772. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4773. * separately during the below call to qdf_nbuf_push_head.
  4774. * The contribution from the HTC header is added separately inside HTC.
  4775. */
  4776. if (!qdf_nbuf_put_tail(
  4777. msg, HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES)) {
  4778. dp_htt_err("Failed to expand head");
  4779. qdf_nbuf_free(msg);
  4780. return QDF_STATUS_E_FAILURE;
  4781. }
  4782. /* fill in the message contents */
  4783. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4784. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4785. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4786. htt_logger_bufp = (uint8_t *)msg_word;
  4787. qdf_mem_zero(msg_word,
  4788. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4789. HTT_H2T_MSG_TYPE_SET(
  4790. *msg_word,
  4791. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP);
  4792. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_T2H_MSG_METHOD_SET(
  4793. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4794. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_H2T_MSG_METHOD_SET(
  4795. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4796. msg_word++;
  4797. *msg_word = setup_params->msi_data;
  4798. msg_word++;
  4799. *msg_word = sizeof(htt_umac_hang_recovery_msg_shmem_t);
  4800. msg_word++;
  4801. *msg_word = setup_params->shmem_addr_low;
  4802. msg_word++;
  4803. *msg_word = setup_params->shmem_addr_high;
  4804. pkt = htt_htc_pkt_alloc(htt_handle);
  4805. if (!pkt) {
  4806. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4807. qdf_assert(0);
  4808. qdf_nbuf_free(msg);
  4809. return QDF_STATUS_E_NOMEM;
  4810. }
  4811. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4812. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4813. dp_htt_h2t_send_complete_free_netbuf,
  4814. qdf_nbuf_data(msg),
  4815. qdf_nbuf_len(msg),
  4816. htt_handle->htc_endpoint,
  4817. /* tag for no FW response msg */
  4818. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4819. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4820. status = DP_HTT_SEND_HTC_PKT(
  4821. htt_handle, pkt,
  4822. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP,
  4823. htt_logger_bufp);
  4824. if (QDF_IS_STATUS_ERROR(status)) {
  4825. qdf_nbuf_free(msg);
  4826. htt_htc_pkt_free(htt_handle, pkt);
  4827. return status;
  4828. }
  4829. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP sent");
  4830. return status;
  4831. }
  4832. QDF_STATUS dp_htt_umac_reset_send_start_pre_reset_cmd(
  4833. struct dp_soc *soc, bool is_initiator, bool is_umac_hang)
  4834. {
  4835. struct htt_soc *htt_handle = soc->htt_handle;
  4836. uint32_t len;
  4837. qdf_nbuf_t msg;
  4838. u_int32_t *msg_word;
  4839. QDF_STATUS status;
  4840. uint8_t *htt_logger_bufp;
  4841. struct dp_htt_htc_pkt *pkt;
  4842. len = HTT_MSG_BUF_SIZE(
  4843. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4844. msg = qdf_nbuf_alloc(soc->osdev,
  4845. len,
  4846. /* reserve room for the HTC header */
  4847. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4848. 4,
  4849. TRUE);
  4850. if (!msg)
  4851. return QDF_STATUS_E_NOMEM;
  4852. /*
  4853. * Set the length of the message.
  4854. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4855. * separately during the below call to qdf_nbuf_push_head.
  4856. * The contribution from the HTC header is added separately inside HTC.
  4857. */
  4858. if (!qdf_nbuf_put_tail(
  4859. msg, HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES)) {
  4860. dp_htt_err("Failed to expand head");
  4861. qdf_nbuf_free(msg);
  4862. return QDF_STATUS_E_FAILURE;
  4863. }
  4864. /* fill in the message contents */
  4865. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4866. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4867. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4868. htt_logger_bufp = (uint8_t *)msg_word;
  4869. qdf_mem_zero(msg_word,
  4870. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4871. HTT_H2T_MSG_TYPE_SET(
  4872. *msg_word,
  4873. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET);
  4874. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_INITIATOR_SET(
  4875. *msg_word, is_initiator);
  4876. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_UMAC_HANG_SET(
  4877. *msg_word, is_umac_hang);
  4878. pkt = htt_htc_pkt_alloc(htt_handle);
  4879. if (!pkt) {
  4880. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4881. qdf_assert(0);
  4882. qdf_nbuf_free(msg);
  4883. return QDF_STATUS_E_NOMEM;
  4884. }
  4885. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4886. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4887. dp_htt_h2t_send_complete_free_netbuf,
  4888. qdf_nbuf_data(msg),
  4889. qdf_nbuf_len(msg),
  4890. htt_handle->htc_endpoint,
  4891. /* tag for no FW response msg */
  4892. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4893. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4894. status = DP_HTT_SEND_HTC_PKT(
  4895. htt_handle, pkt,
  4896. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET,
  4897. htt_logger_bufp);
  4898. if (QDF_IS_STATUS_ERROR(status)) {
  4899. qdf_nbuf_free(msg);
  4900. htt_htc_pkt_free(htt_handle, pkt);
  4901. return status;
  4902. }
  4903. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET sent");
  4904. return status;
  4905. }
  4906. #endif