dp_htt.c 124 KB

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