dp_htt.c 153 KB

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