dp_htt.c 126 KB

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