dp_htt.c 129 KB

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