dp_htt.c 136 KB

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