dp_htt.c 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617
  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. #ifdef CONFIG_SAWF
  2154. /*
  2155. * dp_sawf_msduq_map() - Msdu queue creation information received
  2156. * from target
  2157. * @soc: soc handle.
  2158. * @msg_word: Pointer to htt msg word.
  2159. * @htt_t2h_msg: HTT message nbuf
  2160. *
  2161. * @return: void
  2162. */
  2163. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2164. qdf_nbuf_t htt_t2h_msg)
  2165. {
  2166. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2167. }
  2168. #else
  2169. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2170. qdf_nbuf_t htt_t2h_msg)
  2171. {}
  2172. #endif
  2173. /*
  2174. * time_allow_print() - time allow print
  2175. * @htt_ring_tt: ringi_id array of timestamps
  2176. * @ring_id: ring_id (index)
  2177. *
  2178. * Return: 1 for successfully saving timestamp in array
  2179. * and 0 for timestamp falling within 2 seconds after last one
  2180. */
  2181. static bool time_allow_print(unsigned long *htt_ring_tt, u_int8_t ring_id)
  2182. {
  2183. unsigned long tstamp;
  2184. unsigned long delta;
  2185. tstamp = qdf_get_system_timestamp();
  2186. if (!htt_ring_tt)
  2187. return 0; //unable to print backpressure messages
  2188. if (htt_ring_tt[ring_id] == -1) {
  2189. htt_ring_tt[ring_id] = tstamp;
  2190. return 1;
  2191. }
  2192. delta = tstamp - htt_ring_tt[ring_id];
  2193. if (delta >= 2000) {
  2194. htt_ring_tt[ring_id] = tstamp;
  2195. return 1;
  2196. }
  2197. return 0;
  2198. }
  2199. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2200. struct dp_pdev *pdev, u_int8_t ring_id,
  2201. u_int16_t hp_idx, u_int16_t tp_idx,
  2202. u_int32_t bkp_time, char *ring_stype)
  2203. {
  2204. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2205. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2206. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2207. ring_id, hp_idx, tp_idx, bkp_time);
  2208. }
  2209. /**
  2210. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2211. * @soc: DP_SOC handle
  2212. * @srng: DP_SRNG handle
  2213. * @ring_type: srng src/dst ring
  2214. *
  2215. * Return: void
  2216. */
  2217. static QDF_STATUS
  2218. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2219. struct dp_pdev *pdev,
  2220. struct dp_srng *srng,
  2221. enum hal_ring_type ring_type,
  2222. struct dp_srng_ring_state *state)
  2223. {
  2224. struct hal_soc *hal_soc;
  2225. if (!soc || !srng || !srng->hal_srng || !state)
  2226. return QDF_STATUS_E_INVAL;
  2227. hal_soc = (struct hal_soc *)soc->hal_soc;
  2228. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2229. &state->sw_head);
  2230. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2231. &state->hw_tail, ring_type);
  2232. state->ring_type = ring_type;
  2233. return QDF_STATUS_SUCCESS;
  2234. }
  2235. #ifdef QCA_MONITOR_PKT_SUPPORT
  2236. static void
  2237. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2238. int lmac_id, uint32_t *num_srng,
  2239. struct dp_soc_srngs_state *soc_srngs_state)
  2240. {
  2241. QDF_STATUS status;
  2242. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2243. status = dp_get_srng_ring_state_from_hal
  2244. (pdev->soc, pdev,
  2245. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2246. RXDMA_MONITOR_BUF,
  2247. &soc_srngs_state->ring_state[*num_srng]);
  2248. if (status == QDF_STATUS_SUCCESS)
  2249. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2250. status = dp_get_srng_ring_state_from_hal
  2251. (pdev->soc, pdev,
  2252. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2253. RXDMA_MONITOR_DST,
  2254. &soc_srngs_state->ring_state[*num_srng]);
  2255. if (status == QDF_STATUS_SUCCESS)
  2256. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2257. status = dp_get_srng_ring_state_from_hal
  2258. (pdev->soc, pdev,
  2259. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2260. RXDMA_MONITOR_DESC,
  2261. &soc_srngs_state->ring_state[*num_srng]);
  2262. if (status == QDF_STATUS_SUCCESS)
  2263. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2264. }
  2265. }
  2266. #else
  2267. static void
  2268. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2269. int lmac_id, uint32_t *num_srng,
  2270. struct dp_soc_srngs_state *soc_srngs_state)
  2271. {
  2272. }
  2273. #endif
  2274. /**
  2275. * dp_queue_srng_ring_stats(): Print pdev hal level ring stats
  2276. * @pdev: DP_pdev handle
  2277. *
  2278. * Return: void
  2279. */
  2280. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2281. {
  2282. uint32_t i;
  2283. int mac_id;
  2284. int lmac_id;
  2285. uint32_t j = 0;
  2286. struct dp_soc *soc = pdev->soc;
  2287. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2288. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2289. QDF_STATUS status;
  2290. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2291. if (!soc_srngs_state) {
  2292. dp_htt_alert("Memory alloc failed for back pressure event");
  2293. return;
  2294. }
  2295. status = dp_get_srng_ring_state_from_hal
  2296. (pdev->soc, pdev,
  2297. &pdev->soc->reo_exception_ring,
  2298. REO_EXCEPTION,
  2299. &soc_srngs_state->ring_state[j]);
  2300. if (status == QDF_STATUS_SUCCESS)
  2301. qdf_assert_always(++j < DP_MAX_SRNGS);
  2302. status = dp_get_srng_ring_state_from_hal
  2303. (pdev->soc, pdev,
  2304. &pdev->soc->reo_reinject_ring,
  2305. REO_REINJECT,
  2306. &soc_srngs_state->ring_state[j]);
  2307. if (status == QDF_STATUS_SUCCESS)
  2308. qdf_assert_always(++j < DP_MAX_SRNGS);
  2309. status = dp_get_srng_ring_state_from_hal
  2310. (pdev->soc, pdev,
  2311. &pdev->soc->reo_cmd_ring,
  2312. REO_CMD,
  2313. &soc_srngs_state->ring_state[j]);
  2314. if (status == QDF_STATUS_SUCCESS)
  2315. qdf_assert_always(++j < DP_MAX_SRNGS);
  2316. status = dp_get_srng_ring_state_from_hal
  2317. (pdev->soc, pdev,
  2318. &pdev->soc->reo_status_ring,
  2319. REO_STATUS,
  2320. &soc_srngs_state->ring_state[j]);
  2321. if (status == QDF_STATUS_SUCCESS)
  2322. qdf_assert_always(++j < DP_MAX_SRNGS);
  2323. status = dp_get_srng_ring_state_from_hal
  2324. (pdev->soc, pdev,
  2325. &pdev->soc->rx_rel_ring,
  2326. WBM2SW_RELEASE,
  2327. &soc_srngs_state->ring_state[j]);
  2328. if (status == QDF_STATUS_SUCCESS)
  2329. qdf_assert_always(++j < DP_MAX_SRNGS);
  2330. status = dp_get_srng_ring_state_from_hal
  2331. (pdev->soc, pdev,
  2332. &pdev->soc->tcl_cmd_credit_ring,
  2333. TCL_CMD_CREDIT,
  2334. &soc_srngs_state->ring_state[j]);
  2335. if (status == QDF_STATUS_SUCCESS)
  2336. qdf_assert_always(++j < DP_MAX_SRNGS);
  2337. status = dp_get_srng_ring_state_from_hal
  2338. (pdev->soc, pdev,
  2339. &pdev->soc->tcl_status_ring,
  2340. TCL_STATUS,
  2341. &soc_srngs_state->ring_state[j]);
  2342. if (status == QDF_STATUS_SUCCESS)
  2343. qdf_assert_always(++j < DP_MAX_SRNGS);
  2344. status = dp_get_srng_ring_state_from_hal
  2345. (pdev->soc, pdev,
  2346. &pdev->soc->wbm_desc_rel_ring,
  2347. SW2WBM_RELEASE,
  2348. &soc_srngs_state->ring_state[j]);
  2349. if (status == QDF_STATUS_SUCCESS)
  2350. qdf_assert_always(++j < DP_MAX_SRNGS);
  2351. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2352. status = dp_get_srng_ring_state_from_hal
  2353. (pdev->soc, pdev,
  2354. &pdev->soc->reo_dest_ring[i],
  2355. REO_DST,
  2356. &soc_srngs_state->ring_state[j]);
  2357. if (status == QDF_STATUS_SUCCESS)
  2358. qdf_assert_always(++j < DP_MAX_SRNGS);
  2359. }
  2360. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2361. status = dp_get_srng_ring_state_from_hal
  2362. (pdev->soc, pdev,
  2363. &pdev->soc->tcl_data_ring[i],
  2364. TCL_DATA,
  2365. &soc_srngs_state->ring_state[j]);
  2366. if (status == QDF_STATUS_SUCCESS)
  2367. qdf_assert_always(++j < DP_MAX_SRNGS);
  2368. }
  2369. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2370. status = dp_get_srng_ring_state_from_hal
  2371. (pdev->soc, pdev,
  2372. &pdev->soc->tx_comp_ring[i],
  2373. WBM2SW_RELEASE,
  2374. &soc_srngs_state->ring_state[j]);
  2375. if (status == QDF_STATUS_SUCCESS)
  2376. qdf_assert_always(++j < DP_MAX_SRNGS);
  2377. }
  2378. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2379. status = dp_get_srng_ring_state_from_hal
  2380. (pdev->soc, pdev,
  2381. &pdev->soc->rx_refill_buf_ring
  2382. [lmac_id],
  2383. RXDMA_BUF,
  2384. &soc_srngs_state->ring_state[j]);
  2385. if (status == QDF_STATUS_SUCCESS)
  2386. qdf_assert_always(++j < DP_MAX_SRNGS);
  2387. status = dp_get_srng_ring_state_from_hal
  2388. (pdev->soc, pdev,
  2389. &pdev->rx_refill_buf_ring2,
  2390. RXDMA_BUF,
  2391. &soc_srngs_state->ring_state[j]);
  2392. if (status == QDF_STATUS_SUCCESS)
  2393. qdf_assert_always(++j < DP_MAX_SRNGS);
  2394. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2395. dp_get_srng_ring_state_from_hal
  2396. (pdev->soc, pdev,
  2397. &pdev->rx_mac_buf_ring[i],
  2398. RXDMA_BUF,
  2399. &soc_srngs_state->ring_state[j]);
  2400. if (status == QDF_STATUS_SUCCESS)
  2401. qdf_assert_always(++j < DP_MAX_SRNGS);
  2402. }
  2403. for (mac_id = 0;
  2404. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2405. mac_id++) {
  2406. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2407. mac_id, pdev->pdev_id);
  2408. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2409. soc_srngs_state);
  2410. status = dp_get_srng_ring_state_from_hal
  2411. (pdev->soc, pdev,
  2412. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2413. RXDMA_MONITOR_STATUS,
  2414. &soc_srngs_state->ring_state[j]);
  2415. if (status == QDF_STATUS_SUCCESS)
  2416. qdf_assert_always(++j < DP_MAX_SRNGS);
  2417. }
  2418. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2419. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2420. i, pdev->pdev_id);
  2421. status = dp_get_srng_ring_state_from_hal
  2422. (pdev->soc, pdev,
  2423. &pdev->soc->rxdma_err_dst_ring
  2424. [lmac_id],
  2425. RXDMA_DST,
  2426. &soc_srngs_state->ring_state[j]);
  2427. if (status == QDF_STATUS_SUCCESS)
  2428. qdf_assert_always(++j < DP_MAX_SRNGS);
  2429. }
  2430. soc_srngs_state->max_ring_id = j;
  2431. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2432. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2433. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2434. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2435. qdf_assert_always(drop_srngs_state);
  2436. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2437. list_elem);
  2438. qdf_mem_free(drop_srngs_state);
  2439. pdev->bkp_stats.queue_depth--;
  2440. }
  2441. pdev->bkp_stats.queue_depth++;
  2442. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2443. list_elem);
  2444. pdev->bkp_stats.seq_num++;
  2445. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2446. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2447. &pdev->bkp_stats.work);
  2448. }
  2449. /*
  2450. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2451. * @msg_word: htt packet context
  2452. * @htt_soc: HTT SOC handle
  2453. *
  2454. * Return: after attempting to print stats
  2455. */
  2456. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2457. {
  2458. u_int8_t ring_type;
  2459. u_int8_t pdev_id;
  2460. uint8_t target_pdev_id;
  2461. u_int8_t ring_id;
  2462. u_int16_t hp_idx;
  2463. u_int16_t tp_idx;
  2464. u_int32_t bkp_time;
  2465. enum htt_t2h_msg_type msg_type;
  2466. struct dp_soc *dpsoc;
  2467. struct dp_pdev *pdev;
  2468. struct dp_htt_timestamp *radio_tt;
  2469. if (!soc)
  2470. return;
  2471. dpsoc = (struct dp_soc *)soc->dp_soc;
  2472. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2473. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2474. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2475. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2476. target_pdev_id);
  2477. if (pdev_id >= MAX_PDEV_CNT) {
  2478. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2479. return;
  2480. }
  2481. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2482. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2483. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2484. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2485. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2486. radio_tt = &soc->pdevid_tt[pdev_id];
  2487. switch (ring_type) {
  2488. case HTT_SW_RING_TYPE_UMAC:
  2489. if (!time_allow_print(radio_tt->umac_ttt, ring_id))
  2490. return;
  2491. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2492. bkp_time, "HTT_SW_RING_TYPE_UMAC");
  2493. break;
  2494. case HTT_SW_RING_TYPE_LMAC:
  2495. if (!time_allow_print(radio_tt->lmac_ttt, ring_id))
  2496. return;
  2497. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2498. bkp_time, "HTT_SW_RING_TYPE_LMAC");
  2499. break;
  2500. default:
  2501. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2502. bkp_time, "UNKNOWN");
  2503. break;
  2504. }
  2505. dp_queue_ring_stats(pdev);
  2506. }
  2507. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2508. /*
  2509. * dp_offload_ind_handler() - offload msg handler
  2510. * @htt_soc: HTT SOC handle
  2511. * @msg_word: Pointer to payload
  2512. *
  2513. * Return: None
  2514. */
  2515. static void
  2516. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2517. {
  2518. u_int8_t pdev_id;
  2519. u_int8_t target_pdev_id;
  2520. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2521. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2522. target_pdev_id);
  2523. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2524. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2525. pdev_id);
  2526. }
  2527. #else
  2528. static void
  2529. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2530. {
  2531. }
  2532. #endif
  2533. #ifdef WLAN_FEATURE_11BE_MLO
  2534. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2535. uint32_t *msg_word)
  2536. {
  2537. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2538. uint8_t *mlo_peer_mac_addr;
  2539. uint16_t mlo_peer_id;
  2540. uint8_t num_links;
  2541. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2542. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2543. num_links =
  2544. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2545. mlo_peer_mac_addr =
  2546. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2547. &mac_addr_deswizzle_buf[0]);
  2548. mlo_flow_info[0].ast_idx =
  2549. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2550. mlo_flow_info[0].ast_idx_valid =
  2551. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2552. mlo_flow_info[0].chip_id =
  2553. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2554. mlo_flow_info[0].tidmask =
  2555. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2556. mlo_flow_info[0].cache_set_num =
  2557. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2558. mlo_flow_info[1].ast_idx =
  2559. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2560. mlo_flow_info[1].ast_idx_valid =
  2561. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2562. mlo_flow_info[1].chip_id =
  2563. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2564. mlo_flow_info[1].tidmask =
  2565. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2566. mlo_flow_info[1].cache_set_num =
  2567. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2568. mlo_flow_info[2].ast_idx =
  2569. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2570. mlo_flow_info[2].ast_idx_valid =
  2571. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2572. mlo_flow_info[2].chip_id =
  2573. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2574. mlo_flow_info[2].tidmask =
  2575. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2576. mlo_flow_info[2].cache_set_num =
  2577. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2578. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2579. mlo_peer_mac_addr,
  2580. mlo_flow_info);
  2581. }
  2582. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2583. uint32_t *msg_word)
  2584. {
  2585. uint16_t mlo_peer_id;
  2586. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  2587. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  2588. }
  2589. static void
  2590. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  2591. uint32_t *msg_word)
  2592. {
  2593. uint8_t pdev_id;
  2594. uint8_t target_pdev_id;
  2595. struct dp_pdev *pdev;
  2596. if (!soc)
  2597. return;
  2598. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  2599. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  2600. target_pdev_id);
  2601. if (pdev_id >= MAX_PDEV_CNT) {
  2602. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2603. return;
  2604. }
  2605. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  2606. if (!pdev) {
  2607. dp_err("Invalid pdev");
  2608. return;
  2609. }
  2610. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  2611. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  2612. pdev_id);
  2613. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2614. pdev->timestamp.msg_type =
  2615. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  2616. pdev->timestamp.pdev_id = pdev_id;
  2617. pdev->timestamp.chip_id =
  2618. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  2619. pdev->timestamp.mac_clk_freq =
  2620. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  2621. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  2622. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  2623. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  2624. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  2625. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  2626. pdev->timestamp.mlo_comp_us =
  2627. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  2628. *(msg_word + 6));
  2629. pdev->timestamp.mlo_comp_clks =
  2630. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  2631. *(msg_word + 6));
  2632. pdev->timestamp.mlo_comp_timer =
  2633. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  2634. *(msg_word + 7));
  2635. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2636. }
  2637. #else
  2638. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2639. uint32_t *msg_word)
  2640. {
  2641. qdf_assert_always(0);
  2642. }
  2643. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2644. uint32_t *msg_word)
  2645. {
  2646. qdf_assert_always(0);
  2647. }
  2648. static void
  2649. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  2650. uint32_t *msg_word)
  2651. {
  2652. qdf_assert_always(0);
  2653. }
  2654. #endif
  2655. /*
  2656. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  2657. * @context: Opaque context (HTT SOC handle)
  2658. * @pkt: HTC packet
  2659. */
  2660. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  2661. {
  2662. struct htt_soc *soc = (struct htt_soc *) context;
  2663. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  2664. u_int32_t *msg_word;
  2665. enum htt_t2h_msg_type msg_type;
  2666. bool free_buf = true;
  2667. /* check for successful message reception */
  2668. if (pkt->Status != QDF_STATUS_SUCCESS) {
  2669. if (pkt->Status != QDF_STATUS_E_CANCELED)
  2670. soc->stats.htc_err_cnt++;
  2671. qdf_nbuf_free(htt_t2h_msg);
  2672. return;
  2673. }
  2674. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  2675. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  2676. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2677. htt_event_record(soc->htt_logger_handle,
  2678. msg_type, (uint8_t *)msg_word);
  2679. switch (msg_type) {
  2680. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  2681. {
  2682. dp_htt_bkp_event_alert(msg_word, soc);
  2683. break;
  2684. }
  2685. case HTT_T2H_MSG_TYPE_PEER_MAP:
  2686. {
  2687. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2688. u_int8_t *peer_mac_addr;
  2689. u_int16_t peer_id;
  2690. u_int16_t hw_peer_id;
  2691. u_int8_t vdev_id;
  2692. u_int8_t is_wds;
  2693. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2694. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  2695. hw_peer_id =
  2696. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  2697. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  2698. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  2699. (u_int8_t *) (msg_word+1),
  2700. &mac_addr_deswizzle_buf[0]);
  2701. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2702. QDF_TRACE_LEVEL_INFO,
  2703. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2704. peer_id, vdev_id);
  2705. /*
  2706. * check if peer already exists for this peer_id, if so
  2707. * this peer map event is in response for a wds peer add
  2708. * wmi command sent during wds source port learning.
  2709. * in this case just add the ast entry to the existing
  2710. * peer ast_list.
  2711. */
  2712. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  2713. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  2714. vdev_id, peer_mac_addr, 0,
  2715. is_wds);
  2716. break;
  2717. }
  2718. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  2719. {
  2720. u_int16_t peer_id;
  2721. u_int8_t vdev_id;
  2722. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  2723. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  2724. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  2725. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2726. vdev_id, mac_addr, 0,
  2727. DP_PEER_WDS_COUNT_INVALID);
  2728. break;
  2729. }
  2730. case HTT_T2H_MSG_TYPE_SEC_IND:
  2731. {
  2732. u_int16_t peer_id;
  2733. enum cdp_sec_type sec_type;
  2734. int is_unicast;
  2735. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  2736. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  2737. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  2738. /* point to the first part of the Michael key */
  2739. msg_word++;
  2740. dp_rx_sec_ind_handler(
  2741. soc->dp_soc, peer_id, sec_type, is_unicast,
  2742. msg_word, msg_word + 2);
  2743. break;
  2744. }
  2745. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  2746. {
  2747. free_buf =
  2748. dp_monitor_ppdu_stats_ind_handler(soc,
  2749. msg_word,
  2750. htt_t2h_msg);
  2751. break;
  2752. }
  2753. case HTT_T2H_MSG_TYPE_PKTLOG:
  2754. {
  2755. dp_pktlog_msg_handler(soc, msg_word);
  2756. break;
  2757. }
  2758. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  2759. {
  2760. /*
  2761. * HTC maintains runtime pm count for H2T messages that
  2762. * have a response msg from FW. This count ensures that
  2763. * in the case FW does not sent out the response or host
  2764. * did not process this indication runtime_put happens
  2765. * properly in the cleanup path.
  2766. */
  2767. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  2768. htc_pm_runtime_put(soc->htc_soc);
  2769. else
  2770. soc->stats.htt_ver_req_put_skip++;
  2771. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  2772. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  2773. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  2774. "target uses HTT version %d.%d; host uses %d.%d",
  2775. soc->tgt_ver.major, soc->tgt_ver.minor,
  2776. HTT_CURRENT_VERSION_MAJOR,
  2777. HTT_CURRENT_VERSION_MINOR);
  2778. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  2779. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2780. QDF_TRACE_LEVEL_WARN,
  2781. "*** Incompatible host/target HTT versions!");
  2782. }
  2783. /* abort if the target is incompatible with the host */
  2784. qdf_assert(soc->tgt_ver.major ==
  2785. HTT_CURRENT_VERSION_MAJOR);
  2786. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  2787. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2788. QDF_TRACE_LEVEL_INFO_LOW,
  2789. "*** Warning: host/target HTT versions"
  2790. " are different, though compatible!");
  2791. }
  2792. break;
  2793. }
  2794. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  2795. {
  2796. uint16_t peer_id;
  2797. uint8_t tid;
  2798. uint8_t win_sz;
  2799. uint16_t status;
  2800. struct dp_peer *peer;
  2801. /*
  2802. * Update REO Queue Desc with new values
  2803. */
  2804. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  2805. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  2806. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  2807. peer = dp_peer_get_ref_by_id(soc->dp_soc, peer_id,
  2808. DP_MOD_ID_HTT);
  2809. /*
  2810. * Window size needs to be incremented by 1
  2811. * since fw needs to represent a value of 256
  2812. * using just 8 bits
  2813. */
  2814. if (peer) {
  2815. status = dp_addba_requestprocess_wifi3(
  2816. (struct cdp_soc_t *)soc->dp_soc,
  2817. peer->mac_addr.raw, peer->vdev->vdev_id,
  2818. 0, tid, 0, win_sz + 1, 0xffff);
  2819. /*
  2820. * If PEER_LOCK_REF_PROTECT enbled dec ref
  2821. * which is inc by dp_peer_get_ref_by_id
  2822. */
  2823. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  2824. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2825. QDF_TRACE_LEVEL_INFO,
  2826. FL("PeerID %d BAW %d TID %d stat %d"),
  2827. peer_id, win_sz, tid, status);
  2828. } else {
  2829. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2830. QDF_TRACE_LEVEL_ERROR,
  2831. FL("Peer not found peer id %d"),
  2832. peer_id);
  2833. }
  2834. break;
  2835. }
  2836. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  2837. {
  2838. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  2839. break;
  2840. }
  2841. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  2842. {
  2843. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2844. u_int8_t *peer_mac_addr;
  2845. u_int16_t peer_id;
  2846. u_int16_t hw_peer_id;
  2847. u_int8_t vdev_id;
  2848. bool is_wds;
  2849. u_int16_t ast_hash;
  2850. struct dp_ast_flow_override_info ast_flow_info;
  2851. qdf_mem_set(&ast_flow_info, 0,
  2852. sizeof(struct dp_ast_flow_override_info));
  2853. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  2854. hw_peer_id =
  2855. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  2856. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  2857. peer_mac_addr =
  2858. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2859. &mac_addr_deswizzle_buf[0]);
  2860. is_wds =
  2861. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  2862. ast_hash =
  2863. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  2864. /*
  2865. * Update 4 ast_index per peer, ast valid mask
  2866. * and TID flow valid mask.
  2867. * AST valid mask is 3 bit field corresponds to
  2868. * ast_index[3:1]. ast_index 0 is always valid.
  2869. */
  2870. ast_flow_info.ast_valid_mask =
  2871. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  2872. ast_flow_info.ast_idx[0] = hw_peer_id;
  2873. ast_flow_info.ast_flow_mask[0] =
  2874. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  2875. ast_flow_info.ast_idx[1] =
  2876. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  2877. ast_flow_info.ast_flow_mask[1] =
  2878. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  2879. ast_flow_info.ast_idx[2] =
  2880. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  2881. ast_flow_info.ast_flow_mask[2] =
  2882. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  2883. ast_flow_info.ast_idx[3] =
  2884. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  2885. ast_flow_info.ast_flow_mask[3] =
  2886. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  2887. /*
  2888. * TID valid mask is applicable only
  2889. * for HI and LOW priority flows.
  2890. * tid_valid_mas is 8 bit field corresponds
  2891. * to TID[7:0]
  2892. */
  2893. ast_flow_info.tid_valid_low_pri_mask =
  2894. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  2895. ast_flow_info.tid_valid_hi_pri_mask =
  2896. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  2897. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2898. QDF_TRACE_LEVEL_INFO,
  2899. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2900. peer_id, vdev_id);
  2901. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2902. QDF_TRACE_LEVEL_INFO,
  2903. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  2904. ast_flow_info.ast_idx[0],
  2905. ast_flow_info.ast_idx[1],
  2906. ast_flow_info.ast_idx[2],
  2907. ast_flow_info.ast_idx[3]);
  2908. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  2909. hw_peer_id, vdev_id,
  2910. peer_mac_addr, ast_hash,
  2911. is_wds);
  2912. /*
  2913. * Update ast indexes for flow override support
  2914. * Applicable only for non wds peers
  2915. */
  2916. if (!soc->dp_soc->ast_offload_support)
  2917. dp_peer_ast_index_flow_queue_map_create(
  2918. soc->dp_soc, is_wds,
  2919. peer_id, peer_mac_addr,
  2920. &ast_flow_info);
  2921. break;
  2922. }
  2923. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  2924. {
  2925. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2926. u_int8_t *mac_addr;
  2927. u_int16_t peer_id;
  2928. u_int8_t vdev_id;
  2929. u_int8_t is_wds;
  2930. u_int32_t free_wds_count;
  2931. peer_id =
  2932. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  2933. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  2934. mac_addr =
  2935. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2936. &mac_addr_deswizzle_buf[0]);
  2937. is_wds =
  2938. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  2939. free_wds_count =
  2940. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  2941. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2942. QDF_TRACE_LEVEL_INFO,
  2943. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  2944. peer_id, vdev_id);
  2945. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2946. vdev_id, mac_addr,
  2947. is_wds, free_wds_count);
  2948. break;
  2949. }
  2950. case HTT_T2H_MSG_TYPE_RX_DELBA:
  2951. {
  2952. uint16_t peer_id;
  2953. uint8_t tid;
  2954. uint8_t win_sz;
  2955. QDF_STATUS status;
  2956. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  2957. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  2958. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  2959. status = dp_rx_delba_ind_handler(
  2960. soc->dp_soc,
  2961. peer_id, tid, win_sz);
  2962. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2963. QDF_TRACE_LEVEL_INFO,
  2964. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  2965. peer_id, win_sz, tid, status);
  2966. break;
  2967. }
  2968. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  2969. {
  2970. uint16_t num_entries;
  2971. uint32_t cmem_ba_lo;
  2972. uint32_t cmem_ba_hi;
  2973. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  2974. cmem_ba_lo = *(msg_word + 1);
  2975. cmem_ba_hi = *(msg_word + 2);
  2976. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  2977. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  2978. num_entries, cmem_ba_lo, cmem_ba_hi);
  2979. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  2980. cmem_ba_lo, cmem_ba_hi);
  2981. break;
  2982. }
  2983. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  2984. {
  2985. dp_offload_ind_handler(soc, msg_word);
  2986. break;
  2987. }
  2988. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  2989. {
  2990. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2991. u_int8_t *peer_mac_addr;
  2992. u_int16_t peer_id;
  2993. u_int16_t hw_peer_id;
  2994. u_int8_t vdev_id;
  2995. uint8_t is_wds;
  2996. u_int16_t ast_hash = 0;
  2997. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  2998. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  2999. peer_mac_addr =
  3000. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3001. &mac_addr_deswizzle_buf[0]);
  3002. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3003. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3004. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3005. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3006. peer_id, vdev_id);
  3007. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3008. hw_peer_id, vdev_id,
  3009. peer_mac_addr, ast_hash,
  3010. is_wds);
  3011. break;
  3012. }
  3013. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3014. {
  3015. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3016. break;
  3017. }
  3018. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3019. {
  3020. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3021. break;
  3022. }
  3023. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3024. {
  3025. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3026. break;
  3027. }
  3028. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3029. {
  3030. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3031. break;
  3032. }
  3033. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3034. {
  3035. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3036. htt_t2h_msg);
  3037. break;
  3038. }
  3039. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3040. {
  3041. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3042. break;
  3043. }
  3044. default:
  3045. break;
  3046. };
  3047. /* Free the indication buffer */
  3048. if (free_buf)
  3049. qdf_nbuf_free(htt_t2h_msg);
  3050. }
  3051. /*
  3052. * dp_htt_h2t_full() - Send full handler (called from HTC)
  3053. * @context: Opaque context (HTT SOC handle)
  3054. * @pkt: HTC packet
  3055. *
  3056. * Return: enum htc_send_full_action
  3057. */
  3058. static enum htc_send_full_action
  3059. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3060. {
  3061. return HTC_SEND_FULL_KEEP;
  3062. }
  3063. /*
  3064. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  3065. * @context: Opaque context (HTT SOC handle)
  3066. * @nbuf: nbuf containing T2H message
  3067. * @pipe_id: HIF pipe ID
  3068. *
  3069. * Return: QDF_STATUS
  3070. *
  3071. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  3072. * will be used for packet log and other high-priority HTT messages. Proper
  3073. * HTC connection to be added later once required FW changes are available
  3074. */
  3075. static QDF_STATUS
  3076. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3077. {
  3078. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3079. HTC_PACKET htc_pkt;
  3080. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3081. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3082. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3083. htc_pkt.pPktContext = (void *)nbuf;
  3084. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3085. return rc;
  3086. }
  3087. /*
  3088. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3089. * @htt_soc: HTT SOC handle
  3090. *
  3091. * Return: QDF_STATUS
  3092. */
  3093. static QDF_STATUS
  3094. htt_htc_soc_attach(struct htt_soc *soc)
  3095. {
  3096. struct htc_service_connect_req connect;
  3097. struct htc_service_connect_resp response;
  3098. QDF_STATUS status;
  3099. struct dp_soc *dpsoc = soc->dp_soc;
  3100. qdf_mem_zero(&connect, sizeof(connect));
  3101. qdf_mem_zero(&response, sizeof(response));
  3102. connect.pMetaData = NULL;
  3103. connect.MetaDataLength = 0;
  3104. connect.EpCallbacks.pContext = soc;
  3105. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3106. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3107. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3108. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3109. connect.EpCallbacks.EpRecvRefill = NULL;
  3110. /* N/A, fill is done by HIF */
  3111. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3112. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3113. /*
  3114. * Specify how deep to let a queue get before htc_send_pkt will
  3115. * call the EpSendFull function due to excessive send queue depth.
  3116. */
  3117. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3118. /* disable flow control for HTT data message service */
  3119. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3120. /* connect to control service */
  3121. connect.service_id = HTT_DATA_MSG_SVC;
  3122. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3123. if (status != QDF_STATUS_SUCCESS)
  3124. return status;
  3125. soc->htc_endpoint = response.Endpoint;
  3126. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3127. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3128. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3129. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3130. return QDF_STATUS_SUCCESS; /* success */
  3131. }
  3132. /*
  3133. * htt_soc_initialize() - SOC level HTT initialization
  3134. * @htt_soc: Opaque htt SOC handle
  3135. * @ctrl_psoc: Opaque ctrl SOC handle
  3136. * @htc_soc: SOC level HTC handle
  3137. * @hal_soc: Opaque HAL SOC handle
  3138. * @osdev: QDF device
  3139. *
  3140. * Return: HTT handle on success; NULL on failure
  3141. */
  3142. void *
  3143. htt_soc_initialize(struct htt_soc *htt_soc,
  3144. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3145. HTC_HANDLE htc_soc,
  3146. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3147. {
  3148. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3149. soc->osdev = osdev;
  3150. soc->ctrl_psoc = ctrl_psoc;
  3151. soc->htc_soc = htc_soc;
  3152. soc->hal_soc = hal_soc_hdl;
  3153. if (htt_htc_soc_attach(soc))
  3154. goto fail2;
  3155. return soc;
  3156. fail2:
  3157. return NULL;
  3158. }
  3159. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3160. {
  3161. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3162. htt_htc_misc_pkt_pool_free(htt_handle);
  3163. htt_htc_pkt_pool_free(htt_handle);
  3164. }
  3165. /*
  3166. * htt_soc_htc_prealloc() - HTC memory prealloc
  3167. * @htt_soc: SOC level HTT handle
  3168. *
  3169. * Return: QDF_STATUS_SUCCESS on Success or
  3170. * QDF_STATUS_E_NOMEM on allocation failure
  3171. */
  3172. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3173. {
  3174. int i;
  3175. soc->htt_htc_pkt_freelist = NULL;
  3176. /* pre-allocate some HTC_PACKET objects */
  3177. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3178. struct dp_htt_htc_pkt_union *pkt;
  3179. pkt = qdf_mem_malloc(sizeof(*pkt));
  3180. if (!pkt)
  3181. return QDF_STATUS_E_NOMEM;
  3182. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3183. }
  3184. return QDF_STATUS_SUCCESS;
  3185. }
  3186. /*
  3187. * htt_soc_detach() - Free SOC level HTT handle
  3188. * @htt_hdl: HTT SOC handle
  3189. */
  3190. void htt_soc_detach(struct htt_soc *htt_hdl)
  3191. {
  3192. int i;
  3193. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3194. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3195. qdf_mem_free(htt_handle->pdevid_tt[i].umac_ttt);
  3196. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_ttt);
  3197. }
  3198. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3199. qdf_mem_free(htt_handle);
  3200. }
  3201. /**
  3202. * dp_h2t_ext_stats_msg_send(): function to contruct HTT message to pass to FW
  3203. * @pdev: DP PDEV handle
  3204. * @stats_type_upload_mask: stats type requested by user
  3205. * @config_param_0: extra configuration parameters
  3206. * @config_param_1: extra configuration parameters
  3207. * @config_param_2: extra configuration parameters
  3208. * @config_param_3: extra configuration parameters
  3209. * @mac_id: mac number
  3210. *
  3211. * return: QDF STATUS
  3212. */
  3213. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3214. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3215. uint32_t config_param_1, uint32_t config_param_2,
  3216. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3217. uint8_t mac_id)
  3218. {
  3219. struct htt_soc *soc = pdev->soc->htt_handle;
  3220. struct dp_htt_htc_pkt *pkt;
  3221. qdf_nbuf_t msg;
  3222. uint32_t *msg_word;
  3223. uint8_t pdev_mask = 0;
  3224. uint8_t *htt_logger_bufp;
  3225. int mac_for_pdev;
  3226. int target_pdev_id;
  3227. QDF_STATUS status;
  3228. msg = qdf_nbuf_alloc(
  3229. soc->osdev,
  3230. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3231. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3232. if (!msg)
  3233. return QDF_STATUS_E_NOMEM;
  3234. /*TODO:Add support for SOC stats
  3235. * Bit 0: SOC Stats
  3236. * Bit 1: Pdev stats for pdev id 0
  3237. * Bit 2: Pdev stats for pdev id 1
  3238. * Bit 3: Pdev stats for pdev id 2
  3239. */
  3240. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3241. target_pdev_id =
  3242. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3243. pdev_mask = 1 << target_pdev_id;
  3244. /*
  3245. * Set the length of the message.
  3246. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3247. * separately during the below call to qdf_nbuf_push_head.
  3248. * The contribution from the HTC header is added separately inside HTC.
  3249. */
  3250. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3251. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3252. "Failed to expand head for HTT_EXT_STATS");
  3253. qdf_nbuf_free(msg);
  3254. return QDF_STATUS_E_FAILURE;
  3255. }
  3256. dp_htt_tx_stats_info("%pK: cookie <-> %d\n config_param_0 %u\n"
  3257. "config_param_1 %u\n config_param_2 %u\n"
  3258. "config_param_4 %u\n -------------",
  3259. pdev->soc, cookie_val,
  3260. config_param_0,
  3261. config_param_1, config_param_2, config_param_3);
  3262. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3263. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3264. htt_logger_bufp = (uint8_t *)msg_word;
  3265. *msg_word = 0;
  3266. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3267. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3268. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3269. /* word 1 */
  3270. msg_word++;
  3271. *msg_word = 0;
  3272. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3273. /* word 2 */
  3274. msg_word++;
  3275. *msg_word = 0;
  3276. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3277. /* word 3 */
  3278. msg_word++;
  3279. *msg_word = 0;
  3280. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3281. /* word 4 */
  3282. msg_word++;
  3283. *msg_word = 0;
  3284. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3285. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3286. /* word 5 */
  3287. msg_word++;
  3288. /* word 6 */
  3289. msg_word++;
  3290. *msg_word = 0;
  3291. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3292. /* word 7 */
  3293. msg_word++;
  3294. *msg_word = 0;
  3295. /* Currently Using last 2 bits for pdev_id
  3296. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3297. */
  3298. cookie_msb = (cookie_msb | pdev->pdev_id);
  3299. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3300. pkt = htt_htc_pkt_alloc(soc);
  3301. if (!pkt) {
  3302. qdf_nbuf_free(msg);
  3303. return QDF_STATUS_E_NOMEM;
  3304. }
  3305. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3306. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3307. dp_htt_h2t_send_complete_free_netbuf,
  3308. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3309. soc->htc_endpoint,
  3310. /* tag for FW response msg not guaranteed */
  3311. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3312. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3313. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3314. htt_logger_bufp);
  3315. if (status != QDF_STATUS_SUCCESS) {
  3316. qdf_nbuf_free(msg);
  3317. htt_htc_pkt_free(soc, pkt);
  3318. }
  3319. return status;
  3320. }
  3321. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3322. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3323. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3324. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3325. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3326. uint8_t pdev_id, bool enable,
  3327. bool reset, uint64_t reset_bitmask)
  3328. {
  3329. struct htt_soc *soc = dpsoc->htt_handle;
  3330. struct dp_htt_htc_pkt *pkt;
  3331. qdf_nbuf_t msg;
  3332. uint32_t *msg_word;
  3333. uint8_t *htt_logger_bufp;
  3334. QDF_STATUS status;
  3335. int duration;
  3336. uint32_t bitmask;
  3337. int target_pdev_id;
  3338. msg = qdf_nbuf_alloc(
  3339. soc->osdev,
  3340. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3341. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3342. if (!msg) {
  3343. dp_htt_err("%pK: Fail to allocate "
  3344. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3345. return QDF_STATUS_E_NOMEM;
  3346. }
  3347. if (pdev_id != INVALID_PDEV_ID)
  3348. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3349. else
  3350. target_pdev_id = 0;
  3351. duration =
  3352. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3353. /*
  3354. * Set the length of the message.
  3355. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3356. * separately during the below call to qdf_nbuf_push_head.
  3357. * The contribution from the HTC header is added separately inside HTC.
  3358. */
  3359. if (!qdf_nbuf_put_tail(msg,
  3360. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  3361. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  3362. , dpsoc);
  3363. qdf_nbuf_free(msg);
  3364. return QDF_STATUS_E_FAILURE;
  3365. }
  3366. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3367. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3368. htt_logger_bufp = (uint8_t *)msg_word;
  3369. *msg_word = 0;
  3370. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  3371. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  3372. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  3373. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  3374. (duration >> 3));
  3375. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  3376. msg_word++;
  3377. *msg_word = 0;
  3378. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  3379. *msg_word = bitmask;
  3380. msg_word++;
  3381. *msg_word = 0;
  3382. bitmask =
  3383. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  3384. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  3385. *msg_word = bitmask;
  3386. pkt = htt_htc_pkt_alloc(soc);
  3387. if (!pkt) {
  3388. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  3389. dpsoc);
  3390. qdf_assert(0);
  3391. qdf_nbuf_free(msg);
  3392. return QDF_STATUS_E_NOMEM;
  3393. }
  3394. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3395. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3396. dp_htt_h2t_send_complete_free_netbuf,
  3397. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3398. soc->htc_endpoint,
  3399. /* tag for no FW response msg */
  3400. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3401. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3402. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3403. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  3404. htt_logger_bufp);
  3405. if (status != QDF_STATUS_SUCCESS) {
  3406. qdf_nbuf_free(msg);
  3407. htt_htc_pkt_free(soc, pkt);
  3408. }
  3409. return status;
  3410. }
  3411. #else
  3412. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3413. uint8_t pdev_id, bool enable,
  3414. bool reset, uint64_t reset_bitmask)
  3415. {
  3416. return QDF_STATUS_SUCCESS;
  3417. }
  3418. #endif
  3419. /**
  3420. * dp_h2t_3tuple_config_send(): function to contruct 3 tuple configuration
  3421. * HTT message to pass to FW
  3422. * @pdev: DP PDEV handle
  3423. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  3424. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  3425. *
  3426. * tuple_mask[1:0]:
  3427. * 00 - Do not report 3 tuple hash value
  3428. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  3429. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  3430. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  3431. *
  3432. * return: QDF STATUS
  3433. */
  3434. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  3435. uint32_t tuple_mask, uint8_t mac_id)
  3436. {
  3437. struct htt_soc *soc = pdev->soc->htt_handle;
  3438. struct dp_htt_htc_pkt *pkt;
  3439. qdf_nbuf_t msg;
  3440. uint32_t *msg_word;
  3441. uint8_t *htt_logger_bufp;
  3442. int mac_for_pdev;
  3443. int target_pdev_id;
  3444. msg = qdf_nbuf_alloc(
  3445. soc->osdev,
  3446. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  3447. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3448. if (!msg)
  3449. return QDF_STATUS_E_NOMEM;
  3450. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3451. target_pdev_id =
  3452. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3453. /*
  3454. * Set the length of the message.
  3455. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3456. * separately during the below call to qdf_nbuf_push_head.
  3457. * The contribution from the HTC header is added separately inside HTC.
  3458. */
  3459. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  3460. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3461. "Failed to expand head for HTT_3TUPLE_CONFIG");
  3462. qdf_nbuf_free(msg);
  3463. return QDF_STATUS_E_FAILURE;
  3464. }
  3465. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  3466. pdev->soc, tuple_mask, target_pdev_id);
  3467. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3468. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3469. htt_logger_bufp = (uint8_t *)msg_word;
  3470. *msg_word = 0;
  3471. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  3472. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  3473. msg_word++;
  3474. *msg_word = 0;
  3475. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3476. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3477. pkt = htt_htc_pkt_alloc(soc);
  3478. if (!pkt) {
  3479. qdf_nbuf_free(msg);
  3480. return QDF_STATUS_E_NOMEM;
  3481. }
  3482. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3483. SET_HTC_PACKET_INFO_TX(
  3484. &pkt->htc_pkt,
  3485. dp_htt_h2t_send_complete_free_netbuf,
  3486. qdf_nbuf_data(msg),
  3487. qdf_nbuf_len(msg),
  3488. soc->htc_endpoint,
  3489. /* tag for no FW response msg */
  3490. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3491. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3492. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  3493. htt_logger_bufp);
  3494. return QDF_STATUS_SUCCESS;
  3495. }
  3496. /* This macro will revert once proper HTT header will define for
  3497. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  3498. * */
  3499. #if defined(WDI_EVENT_ENABLE)
  3500. /**
  3501. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  3502. * @pdev: DP PDEV handle
  3503. * @stats_type_upload_mask: stats type requested by user
  3504. * @mac_id: Mac id number
  3505. *
  3506. * return: QDF STATUS
  3507. */
  3508. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  3509. uint32_t stats_type_upload_mask, uint8_t mac_id)
  3510. {
  3511. struct htt_soc *soc = pdev->soc->htt_handle;
  3512. struct dp_htt_htc_pkt *pkt;
  3513. qdf_nbuf_t msg;
  3514. uint32_t *msg_word;
  3515. uint8_t pdev_mask;
  3516. QDF_STATUS status;
  3517. msg = qdf_nbuf_alloc(
  3518. soc->osdev,
  3519. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  3520. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3521. if (!msg) {
  3522. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  3523. , pdev->soc);
  3524. qdf_assert(0);
  3525. return QDF_STATUS_E_NOMEM;
  3526. }
  3527. /*TODO:Add support for SOC stats
  3528. * Bit 0: SOC Stats
  3529. * Bit 1: Pdev stats for pdev id 0
  3530. * Bit 2: Pdev stats for pdev id 1
  3531. * Bit 3: Pdev stats for pdev id 2
  3532. */
  3533. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  3534. mac_id);
  3535. /*
  3536. * Set the length of the message.
  3537. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3538. * separately during the below call to qdf_nbuf_push_head.
  3539. * The contribution from the HTC header is added separately inside HTC.
  3540. */
  3541. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  3542. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  3543. , pdev->soc);
  3544. qdf_nbuf_free(msg);
  3545. return QDF_STATUS_E_FAILURE;
  3546. }
  3547. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3548. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3549. *msg_word = 0;
  3550. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  3551. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  3552. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  3553. stats_type_upload_mask);
  3554. pkt = htt_htc_pkt_alloc(soc);
  3555. if (!pkt) {
  3556. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  3557. qdf_assert(0);
  3558. qdf_nbuf_free(msg);
  3559. return QDF_STATUS_E_NOMEM;
  3560. }
  3561. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3562. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3563. dp_htt_h2t_send_complete_free_netbuf,
  3564. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3565. soc->htc_endpoint,
  3566. /* tag for no FW response msg */
  3567. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3568. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3569. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  3570. (uint8_t *)msg_word);
  3571. if (status != QDF_STATUS_SUCCESS) {
  3572. qdf_nbuf_free(msg);
  3573. htt_htc_pkt_free(soc, pkt);
  3574. }
  3575. return status;
  3576. }
  3577. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  3578. #endif
  3579. void
  3580. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  3581. uint32_t *tag_buf)
  3582. {
  3583. struct dp_peer *peer = NULL;
  3584. switch (tag_type) {
  3585. case HTT_STATS_PEER_DETAILS_TAG:
  3586. {
  3587. htt_peer_details_tlv *dp_stats_buf =
  3588. (htt_peer_details_tlv *)tag_buf;
  3589. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  3590. }
  3591. break;
  3592. case HTT_STATS_PEER_STATS_CMN_TAG:
  3593. {
  3594. htt_peer_stats_cmn_tlv *dp_stats_buf =
  3595. (htt_peer_stats_cmn_tlv *)tag_buf;
  3596. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  3597. DP_MOD_ID_HTT);
  3598. if (peer && !peer->bss_peer) {
  3599. peer->stats.tx.inactive_time =
  3600. dp_stats_buf->inactive_time;
  3601. qdf_event_set(&pdev->fw_peer_stats_event);
  3602. }
  3603. if (peer)
  3604. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3605. }
  3606. break;
  3607. default:
  3608. qdf_err("Invalid tag_type");
  3609. }
  3610. }
  3611. /**
  3612. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  3613. * @pdev: DP pdev handle
  3614. * @fse_setup_info: FST setup parameters
  3615. *
  3616. * Return: Success when HTT message is sent, error on failure
  3617. */
  3618. QDF_STATUS
  3619. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  3620. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  3621. {
  3622. struct htt_soc *soc = pdev->soc->htt_handle;
  3623. struct dp_htt_htc_pkt *pkt;
  3624. qdf_nbuf_t msg;
  3625. u_int32_t *msg_word;
  3626. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  3627. uint8_t *htt_logger_bufp;
  3628. u_int32_t *key;
  3629. QDF_STATUS status;
  3630. msg = qdf_nbuf_alloc(
  3631. soc->osdev,
  3632. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  3633. /* reserve room for the HTC header */
  3634. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3635. if (!msg)
  3636. return QDF_STATUS_E_NOMEM;
  3637. /*
  3638. * Set the length of the message.
  3639. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3640. * separately during the below call to qdf_nbuf_push_head.
  3641. * The contribution from the HTC header is added separately inside HTC.
  3642. */
  3643. if (!qdf_nbuf_put_tail(msg,
  3644. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  3645. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  3646. return QDF_STATUS_E_FAILURE;
  3647. }
  3648. /* fill in the message contents */
  3649. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3650. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  3651. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3652. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3653. htt_logger_bufp = (uint8_t *)msg_word;
  3654. *msg_word = 0;
  3655. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  3656. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  3657. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  3658. msg_word++;
  3659. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  3660. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  3661. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  3662. fse_setup_info->ip_da_sa_prefix);
  3663. msg_word++;
  3664. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  3665. fse_setup_info->base_addr_lo);
  3666. msg_word++;
  3667. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  3668. fse_setup_info->base_addr_hi);
  3669. key = (u_int32_t *)fse_setup_info->hash_key;
  3670. fse_setup->toeplitz31_0 = *key++;
  3671. fse_setup->toeplitz63_32 = *key++;
  3672. fse_setup->toeplitz95_64 = *key++;
  3673. fse_setup->toeplitz127_96 = *key++;
  3674. fse_setup->toeplitz159_128 = *key++;
  3675. fse_setup->toeplitz191_160 = *key++;
  3676. fse_setup->toeplitz223_192 = *key++;
  3677. fse_setup->toeplitz255_224 = *key++;
  3678. fse_setup->toeplitz287_256 = *key++;
  3679. fse_setup->toeplitz314_288 = *key;
  3680. msg_word++;
  3681. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  3682. msg_word++;
  3683. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  3684. msg_word++;
  3685. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  3686. msg_word++;
  3687. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  3688. msg_word++;
  3689. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  3690. msg_word++;
  3691. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  3692. msg_word++;
  3693. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  3694. msg_word++;
  3695. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  3696. msg_word++;
  3697. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  3698. msg_word++;
  3699. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  3700. fse_setup->toeplitz314_288);
  3701. pkt = htt_htc_pkt_alloc(soc);
  3702. if (!pkt) {
  3703. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3704. qdf_assert(0);
  3705. qdf_nbuf_free(msg);
  3706. return QDF_STATUS_E_RESOURCES; /* failure */
  3707. }
  3708. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3709. SET_HTC_PACKET_INFO_TX(
  3710. &pkt->htc_pkt,
  3711. dp_htt_h2t_send_complete_free_netbuf,
  3712. qdf_nbuf_data(msg),
  3713. qdf_nbuf_len(msg),
  3714. soc->htc_endpoint,
  3715. /* tag for no FW response msg */
  3716. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3717. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3718. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3719. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  3720. htt_logger_bufp);
  3721. if (status == QDF_STATUS_SUCCESS) {
  3722. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  3723. fse_setup_info->pdev_id);
  3724. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  3725. (void *)fse_setup_info->hash_key,
  3726. fse_setup_info->hash_key_len);
  3727. } else {
  3728. qdf_nbuf_free(msg);
  3729. htt_htc_pkt_free(soc, pkt);
  3730. }
  3731. return status;
  3732. }
  3733. /**
  3734. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  3735. * add/del a flow in HW
  3736. * @pdev: DP pdev handle
  3737. * @fse_op_info: Flow entry parameters
  3738. *
  3739. * Return: Success when HTT message is sent, error on failure
  3740. */
  3741. QDF_STATUS
  3742. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  3743. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  3744. {
  3745. struct htt_soc *soc = pdev->soc->htt_handle;
  3746. struct dp_htt_htc_pkt *pkt;
  3747. qdf_nbuf_t msg;
  3748. u_int32_t *msg_word;
  3749. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  3750. uint8_t *htt_logger_bufp;
  3751. QDF_STATUS status;
  3752. msg = qdf_nbuf_alloc(
  3753. soc->osdev,
  3754. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  3755. /* reserve room for the HTC header */
  3756. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3757. if (!msg)
  3758. return QDF_STATUS_E_NOMEM;
  3759. /*
  3760. * Set the length of the message.
  3761. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3762. * separately during the below call to qdf_nbuf_push_head.
  3763. * The contribution from the HTC header is added separately inside HTC.
  3764. */
  3765. if (!qdf_nbuf_put_tail(msg,
  3766. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  3767. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  3768. qdf_nbuf_free(msg);
  3769. return QDF_STATUS_E_FAILURE;
  3770. }
  3771. /* fill in the message contents */
  3772. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3773. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  3774. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3775. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3776. htt_logger_bufp = (uint8_t *)msg_word;
  3777. *msg_word = 0;
  3778. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  3779. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  3780. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  3781. msg_word++;
  3782. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  3783. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  3784. HTT_RX_FSE_OPERATION_SET(*msg_word,
  3785. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  3786. msg_word++;
  3787. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3788. *msg_word,
  3789. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  3790. msg_word++;
  3791. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3792. *msg_word,
  3793. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  3794. msg_word++;
  3795. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3796. *msg_word,
  3797. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  3798. msg_word++;
  3799. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3800. *msg_word,
  3801. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  3802. msg_word++;
  3803. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3804. *msg_word,
  3805. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  3806. msg_word++;
  3807. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3808. *msg_word,
  3809. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  3810. msg_word++;
  3811. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3812. *msg_word,
  3813. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  3814. msg_word++;
  3815. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  3816. *msg_word,
  3817. qdf_htonl(
  3818. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  3819. msg_word++;
  3820. HTT_RX_FSE_SOURCEPORT_SET(
  3821. *msg_word,
  3822. fse_op_info->rx_flow->flow_tuple_info.src_port);
  3823. HTT_RX_FSE_DESTPORT_SET(
  3824. *msg_word,
  3825. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  3826. msg_word++;
  3827. HTT_RX_FSE_L4_PROTO_SET(
  3828. *msg_word,
  3829. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  3830. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  3831. HTT_RX_FSE_OPERATION_SET(*msg_word,
  3832. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  3833. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  3834. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  3835. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  3836. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  3837. }
  3838. pkt = htt_htc_pkt_alloc(soc);
  3839. if (!pkt) {
  3840. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3841. qdf_assert(0);
  3842. qdf_nbuf_free(msg);
  3843. return QDF_STATUS_E_RESOURCES; /* failure */
  3844. }
  3845. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3846. SET_HTC_PACKET_INFO_TX(
  3847. &pkt->htc_pkt,
  3848. dp_htt_h2t_send_complete_free_netbuf,
  3849. qdf_nbuf_data(msg),
  3850. qdf_nbuf_len(msg),
  3851. soc->htc_endpoint,
  3852. /* tag for no FW response msg */
  3853. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3854. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3855. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3856. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  3857. htt_logger_bufp);
  3858. if (status == QDF_STATUS_SUCCESS) {
  3859. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  3860. fse_op_info->pdev_id);
  3861. } else {
  3862. qdf_nbuf_free(msg);
  3863. htt_htc_pkt_free(soc, pkt);
  3864. }
  3865. return status;
  3866. }
  3867. /**
  3868. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  3869. * @pdev: DP pdev handle
  3870. * @fse_op_info: Flow entry parameters
  3871. *
  3872. * Return: Success when HTT message is sent, error on failure
  3873. */
  3874. QDF_STATUS
  3875. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  3876. struct dp_htt_rx_fisa_cfg *fisa_config)
  3877. {
  3878. struct htt_soc *soc = pdev->soc->htt_handle;
  3879. struct dp_htt_htc_pkt *pkt;
  3880. qdf_nbuf_t msg;
  3881. u_int32_t *msg_word;
  3882. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  3883. uint8_t *htt_logger_bufp;
  3884. uint32_t len;
  3885. QDF_STATUS status;
  3886. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  3887. msg = qdf_nbuf_alloc(soc->osdev,
  3888. len,
  3889. /* reserve room for the HTC header */
  3890. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  3891. 4,
  3892. TRUE);
  3893. if (!msg)
  3894. return QDF_STATUS_E_NOMEM;
  3895. /*
  3896. * Set the length of the message.
  3897. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3898. * separately during the below call to qdf_nbuf_push_head.
  3899. * The contribution from the HTC header is added separately inside HTC.
  3900. */
  3901. if (!qdf_nbuf_put_tail(msg,
  3902. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  3903. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  3904. qdf_nbuf_free(msg);
  3905. return QDF_STATUS_E_FAILURE;
  3906. }
  3907. /* fill in the message contents */
  3908. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3909. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  3910. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3911. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3912. htt_logger_bufp = (uint8_t *)msg_word;
  3913. *msg_word = 0;
  3914. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  3915. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  3916. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  3917. msg_word++;
  3918. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  3919. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  3920. msg_word++;
  3921. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  3922. pkt = htt_htc_pkt_alloc(soc);
  3923. if (!pkt) {
  3924. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3925. qdf_assert(0);
  3926. qdf_nbuf_free(msg);
  3927. return QDF_STATUS_E_RESOURCES; /* failure */
  3928. }
  3929. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3930. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3931. dp_htt_h2t_send_complete_free_netbuf,
  3932. qdf_nbuf_data(msg),
  3933. qdf_nbuf_len(msg),
  3934. soc->htc_endpoint,
  3935. /* tag for no FW response msg */
  3936. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3937. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3938. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  3939. htt_logger_bufp);
  3940. if (status == QDF_STATUS_SUCCESS) {
  3941. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  3942. fisa_config->pdev_id);
  3943. } else {
  3944. qdf_nbuf_free(msg);
  3945. htt_htc_pkt_free(soc, pkt);
  3946. }
  3947. return status;
  3948. }
  3949. /**
  3950. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  3951. * stats
  3952. *
  3953. * @context : argument to work function
  3954. */
  3955. static void dp_bk_pressure_stats_handler(void *context)
  3956. {
  3957. struct dp_pdev *pdev = (struct dp_pdev *)context;
  3958. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  3959. const char *ring_name;
  3960. int i;
  3961. struct dp_srng_ring_state *ring_state;
  3962. bool empty_flag;
  3963. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  3964. /* Extract only first entry for printing in one work event */
  3965. if (pdev->bkp_stats.queue_depth &&
  3966. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  3967. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  3968. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  3969. list_elem);
  3970. pdev->bkp_stats.queue_depth--;
  3971. }
  3972. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  3973. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  3974. if (soc_srngs_state) {
  3975. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  3976. soc_srngs_state->seq_num);
  3977. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  3978. ring_state = &soc_srngs_state->ring_state[i];
  3979. ring_name = dp_srng_get_str_from_hal_ring_type
  3980. (ring_state->ring_type);
  3981. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  3982. ring_name,
  3983. ring_state->sw_head,
  3984. ring_state->sw_tail);
  3985. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  3986. ring_name,
  3987. ring_state->hw_head,
  3988. ring_state->hw_tail);
  3989. }
  3990. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  3991. soc_srngs_state->seq_num);
  3992. qdf_mem_free(soc_srngs_state);
  3993. }
  3994. dp_print_napi_stats(pdev->soc);
  3995. /* Schedule work again if queue is not empty */
  3996. if (!empty_flag)
  3997. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  3998. &pdev->bkp_stats.work);
  3999. }
  4000. /*
  4001. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  4002. * processing
  4003. * @pdev: Datapath PDEV handle
  4004. *
  4005. */
  4006. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4007. {
  4008. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4009. if (!pdev->bkp_stats.work_queue)
  4010. return;
  4011. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4012. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4013. qdf_flush_work(&pdev->bkp_stats.work);
  4014. qdf_disable_work(&pdev->bkp_stats.work);
  4015. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4016. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4017. list_elem, ring_state_next) {
  4018. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4019. list_elem);
  4020. qdf_mem_free(ring_state);
  4021. }
  4022. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4023. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4024. }
  4025. /*
  4026. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  4027. * processing
  4028. * @pdev: Datapath PDEV handle
  4029. *
  4030. * Return: QDF_STATUS_SUCCESS: Success
  4031. * QDF_STATUS_E_NOMEM: Error
  4032. */
  4033. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4034. {
  4035. TAILQ_INIT(&pdev->bkp_stats.list);
  4036. pdev->bkp_stats.seq_num = 0;
  4037. pdev->bkp_stats.queue_depth = 0;
  4038. qdf_create_work(0, &pdev->bkp_stats.work,
  4039. dp_bk_pressure_stats_handler, pdev);
  4040. pdev->bkp_stats.work_queue =
  4041. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4042. if (!pdev->bkp_stats.work_queue)
  4043. goto fail;
  4044. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4045. return QDF_STATUS_SUCCESS;
  4046. fail:
  4047. dp_htt_alert("BKP stats attach failed");
  4048. qdf_flush_work(&pdev->bkp_stats.work);
  4049. qdf_disable_work(&pdev->bkp_stats.work);
  4050. return QDF_STATUS_E_FAILURE;
  4051. }