dp_htt.c 126 KB

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