dp_htt.c 126 KB

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