dp_htt.c 140 KB

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