dp_htt.c 142 KB

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