dp_htt.c 134 KB

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