dp_htt.c 143 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115
  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 version 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 version 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 version
  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 configuration 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 disabling 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. soc->dp_soc->arch_ops.dp_rx_word_mask_subscribe(
  1506. soc->dp_soc,
  1507. msg_word,
  1508. (void *)htt_tlv_filter);
  1509. if (mon_drop_th > 0)
  1510. HTT_RX_RING_SELECTION_CFG_RX_DROP_THRESHOLD_SET(*msg_word,
  1511. mon_drop_th);
  1512. dp_mon_rx_enable_mpdu_logging(soc->dp_soc, msg_word, htt_tlv_filter);
  1513. dp_mon_rx_enable_phy_errors(msg_word, htt_tlv_filter);
  1514. /* word 14*/
  1515. msg_word += 3;
  1516. /* word 15*/
  1517. msg_word++;
  1518. #ifdef FW_SUPPORT_NOT_YET
  1519. /* word 17*/
  1520. msg_word += 3;
  1521. *msg_word = 0;
  1522. dp_mon_rx_enable_fpmo(soc->dp_soc, msg_word, htt_tlv_filter);
  1523. #endif/* FW_SUPPORT_NOT_YET */
  1524. /* "response_required" field should be set if a HTT response message is
  1525. * required after setting up the ring.
  1526. */
  1527. pkt = htt_htc_pkt_alloc(soc);
  1528. if (!pkt) {
  1529. dp_err("pkt alloc failed, ring_type %d ring_id %d htt_ring_id %d",
  1530. hal_ring_type, srng_params.ring_id, htt_ring_id);
  1531. goto fail1;
  1532. }
  1533. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  1534. SET_HTC_PACKET_INFO_TX(
  1535. &pkt->htc_pkt,
  1536. dp_htt_h2t_send_complete_free_netbuf,
  1537. qdf_nbuf_data(htt_msg),
  1538. qdf_nbuf_len(htt_msg),
  1539. soc->htc_endpoint,
  1540. HTC_TX_PACKET_TAG_RUNTIME_PUT); /* tag for no FW response msg */
  1541. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, htt_msg);
  1542. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  1543. HTT_H2T_MSG_TYPE_RX_RING_SELECTION_CFG,
  1544. htt_logger_bufp);
  1545. if (status != QDF_STATUS_SUCCESS) {
  1546. qdf_nbuf_free(htt_msg);
  1547. htt_htc_pkt_free(soc, pkt);
  1548. }
  1549. return status;
  1550. fail1:
  1551. qdf_nbuf_free(htt_msg);
  1552. fail0:
  1553. return QDF_STATUS_E_FAILURE;
  1554. }
  1555. qdf_export_symbol(htt_h2t_rx_ring_cfg);
  1556. #if defined(HTT_STATS_ENABLE)
  1557. static inline QDF_STATUS dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1558. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1559. {
  1560. uint32_t pdev_id;
  1561. uint32_t *msg_word = NULL;
  1562. uint32_t msg_remain_len = 0;
  1563. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1564. /*COOKIE MSB*/
  1565. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1566. /* stats message length + 16 size of HTT header*/
  1567. msg_remain_len = qdf_min(htt_stats->msg_len + 16,
  1568. (uint32_t)DP_EXT_MSG_LENGTH);
  1569. dp_wdi_event_handler(WDI_EVENT_HTT_STATS, soc,
  1570. msg_word, msg_remain_len,
  1571. WDI_NO_VAL, pdev_id);
  1572. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1573. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1574. }
  1575. /* Need to be freed here as WDI handler will
  1576. * make a copy of pkt to send data to application
  1577. */
  1578. qdf_nbuf_free(htt_msg);
  1579. return QDF_STATUS_SUCCESS;
  1580. }
  1581. #else
  1582. static inline QDF_STATUS
  1583. dp_send_htt_stat_resp(struct htt_stats_context *htt_stats,
  1584. struct dp_soc *soc, qdf_nbuf_t htt_msg)
  1585. {
  1586. return QDF_STATUS_E_NOSUPPORT;
  1587. }
  1588. #endif
  1589. #ifdef HTT_STATS_DEBUGFS_SUPPORT
  1590. /* dp_send_htt_stats_dbgfs_msg() - Function to send htt data to upper layer.
  1591. * @pdev: dp pdev handle
  1592. * @msg_word: HTT msg
  1593. * @msg_len: Length of HTT msg sent
  1594. *
  1595. * Return: none
  1596. */
  1597. static inline void
  1598. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1599. uint32_t msg_len)
  1600. {
  1601. struct htt_dbgfs_cfg dbgfs_cfg;
  1602. int done = 0;
  1603. /* send 5th word of HTT msg to upper layer */
  1604. dbgfs_cfg.msg_word = (msg_word + 4);
  1605. dbgfs_cfg.m = pdev->dbgfs_cfg->m;
  1606. /* stats message length + 16 size of HTT header*/
  1607. msg_len = qdf_min(msg_len + HTT_HEADER_LEN, (uint32_t)DP_EXT_MSG_LENGTH);
  1608. if (pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process)
  1609. pdev->dbgfs_cfg->htt_stats_dbgfs_msg_process(&dbgfs_cfg,
  1610. (msg_len - HTT_HEADER_LEN));
  1611. /* Get TLV Done bit from 4th msg word */
  1612. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1613. if (done) {
  1614. if (qdf_event_set(&pdev->dbgfs_cfg->htt_stats_dbgfs_event))
  1615. dp_htt_err("%pK: Failed to set event for debugfs htt stats"
  1616. , pdev->soc);
  1617. }
  1618. }
  1619. #else
  1620. static inline void
  1621. dp_htt_stats_dbgfs_send_msg(struct dp_pdev *pdev, uint32_t *msg_word,
  1622. uint32_t msg_len)
  1623. {
  1624. }
  1625. #endif /* HTT_STATS_DEBUGFS_SUPPORT */
  1626. #ifdef WLAN_SYSFS_DP_STATS
  1627. /* dp_htt_stats_sysfs_update_config() - Function to send htt data to upper layer.
  1628. * @pdev: dp pdev handle
  1629. *
  1630. * This function sets the process id and printing mode within the sysfs config
  1631. * struct. which enables DP_PRINT statements within this process to write to the
  1632. * console buffer provided by the user space.
  1633. *
  1634. * Return: None
  1635. */
  1636. static inline void
  1637. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1638. {
  1639. struct dp_soc *soc = pdev->soc;
  1640. if (!soc) {
  1641. dp_htt_err("soc is null");
  1642. return;
  1643. }
  1644. if (!soc->sysfs_config) {
  1645. dp_htt_err("soc->sysfs_config is NULL");
  1646. return;
  1647. }
  1648. /* set sysfs config parameters */
  1649. soc->sysfs_config->process_id = qdf_get_current_pid();
  1650. soc->sysfs_config->printing_mode = PRINTING_MODE_ENABLED;
  1651. }
  1652. /*
  1653. * dp_htt_stats_sysfs_set_event() - Set sysfs stats event.
  1654. * @soc: soc handle.
  1655. * @msg_word: Pointer to htt msg word.
  1656. *
  1657. * @return: void
  1658. */
  1659. static inline void
  1660. dp_htt_stats_sysfs_set_event(struct dp_soc *soc, uint32_t *msg_word)
  1661. {
  1662. int done = 0;
  1663. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*(msg_word + 3));
  1664. if (done) {
  1665. if (qdf_event_set(&soc->sysfs_config->sysfs_txrx_fw_request_done))
  1666. dp_htt_err("%pK:event compl Fail to set event ",
  1667. soc);
  1668. }
  1669. }
  1670. #else /* WLAN_SYSFS_DP_STATS */
  1671. static inline void
  1672. dp_htt_stats_sysfs_update_config(struct dp_pdev *pdev)
  1673. {
  1674. }
  1675. static inline void
  1676. dp_htt_stats_sysfs_set_event(struct dp_soc *dp_soc, uint32_t *msg_word)
  1677. {
  1678. }
  1679. #endif /* WLAN_SYSFS_DP_STATS */
  1680. /* dp_htt_set_pdev_obss_stats() - Function to set pdev obss stats.
  1681. * @pdev: dp pdev handle
  1682. * @tag_type: HTT TLV tag type
  1683. * @tag_buf: TLV buffer pointer
  1684. *
  1685. * Return: None
  1686. */
  1687. static inline void
  1688. dp_htt_set_pdev_obss_stats(struct dp_pdev *pdev, uint32_t tag_type,
  1689. uint32_t *tag_buf)
  1690. {
  1691. if (tag_type != HTT_STATS_PDEV_OBSS_PD_TAG) {
  1692. dp_err("Tag mismatch");
  1693. return;
  1694. }
  1695. qdf_mem_copy(&pdev->stats.htt_tx_pdev_stats.obss_pd_stats_tlv,
  1696. tag_buf, sizeof(struct cdp_pdev_obss_pd_stats_tlv));
  1697. qdf_event_set(&pdev->fw_obss_stats_event);
  1698. }
  1699. /**
  1700. * dp_process_htt_stat_msg(): Process the list of buffers of HTT EXT stats
  1701. * @htt_stats: htt stats info
  1702. *
  1703. * The FW sends the HTT EXT STATS as a stream of T2H messages. Each T2H message
  1704. * contains sub messages which are identified by a TLV header.
  1705. * In this function we will process the stream of T2H messages and read all the
  1706. * TLV contained in the message.
  1707. *
  1708. * THe following cases have been taken care of
  1709. * Case 1: When the tlv_remain_length <= msg_remain_length of HTT MSG buffer
  1710. * In this case the buffer will contain multiple tlvs.
  1711. * Case 2: When the tlv_remain_length > msg_remain_length of HTT MSG buffer.
  1712. * Only one tlv will be contained in the HTT message and this tag
  1713. * will extend onto the next buffer.
  1714. * Case 3: When the buffer is the continuation of the previous message
  1715. * Case 4: tlv length is 0. which will indicate the end of message
  1716. *
  1717. * return: void
  1718. */
  1719. static inline void dp_process_htt_stat_msg(struct htt_stats_context *htt_stats,
  1720. struct dp_soc *soc)
  1721. {
  1722. htt_tlv_tag_t tlv_type = 0xff;
  1723. qdf_nbuf_t htt_msg = NULL;
  1724. uint32_t *msg_word;
  1725. uint8_t *tlv_buf_head = NULL;
  1726. uint8_t *tlv_buf_tail = NULL;
  1727. uint32_t msg_remain_len = 0;
  1728. uint32_t tlv_remain_len = 0;
  1729. uint32_t *tlv_start;
  1730. int cookie_val = 0;
  1731. int cookie_msb = 0;
  1732. int pdev_id;
  1733. bool copy_stats = false;
  1734. struct dp_pdev *pdev;
  1735. /* Process node in the HTT message queue */
  1736. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1737. != NULL) {
  1738. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1739. cookie_val = *(msg_word + 1);
  1740. htt_stats->msg_len = HTT_T2H_EXT_STATS_CONF_TLV_LENGTH_GET(
  1741. *(msg_word +
  1742. HTT_T2H_EXT_STATS_TLV_START_OFFSET));
  1743. if (cookie_val) {
  1744. if (dp_send_htt_stat_resp(htt_stats, soc, htt_msg)
  1745. == QDF_STATUS_SUCCESS) {
  1746. continue;
  1747. }
  1748. }
  1749. cookie_msb = *(msg_word + 2);
  1750. pdev_id = *(msg_word + 2) & HTT_PID_BIT_MASK;
  1751. pdev = soc->pdev_list[pdev_id];
  1752. if (!cookie_val && (cookie_msb & DBG_STATS_COOKIE_HTT_DBGFS)) {
  1753. dp_htt_stats_dbgfs_send_msg(pdev, msg_word,
  1754. htt_stats->msg_len);
  1755. qdf_nbuf_free(htt_msg);
  1756. continue;
  1757. }
  1758. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1759. dp_htt_stats_sysfs_update_config(pdev);
  1760. if (cookie_msb & DBG_STATS_COOKIE_DP_STATS)
  1761. copy_stats = true;
  1762. /* read 5th word */
  1763. msg_word = msg_word + 4;
  1764. msg_remain_len = qdf_min(htt_stats->msg_len,
  1765. (uint32_t) DP_EXT_MSG_LENGTH);
  1766. /* Keep processing the node till node length is 0 */
  1767. while (msg_remain_len) {
  1768. /*
  1769. * if message is not a continuation of previous message
  1770. * read the tlv type and tlv length
  1771. */
  1772. if (!tlv_buf_head) {
  1773. tlv_type = HTT_STATS_TLV_TAG_GET(
  1774. *msg_word);
  1775. tlv_remain_len = HTT_STATS_TLV_LENGTH_GET(
  1776. *msg_word);
  1777. }
  1778. if (tlv_remain_len == 0) {
  1779. msg_remain_len = 0;
  1780. if (tlv_buf_head) {
  1781. qdf_mem_free(tlv_buf_head);
  1782. tlv_buf_head = NULL;
  1783. tlv_buf_tail = NULL;
  1784. }
  1785. goto error;
  1786. }
  1787. if (!tlv_buf_head)
  1788. tlv_remain_len += HTT_TLV_HDR_LEN;
  1789. if ((tlv_remain_len <= msg_remain_len)) {
  1790. /* Case 3 */
  1791. if (tlv_buf_head) {
  1792. qdf_mem_copy(tlv_buf_tail,
  1793. (uint8_t *)msg_word,
  1794. tlv_remain_len);
  1795. tlv_start = (uint32_t *)tlv_buf_head;
  1796. } else {
  1797. /* Case 1 */
  1798. tlv_start = msg_word;
  1799. }
  1800. if (copy_stats)
  1801. dp_htt_stats_copy_tag(pdev,
  1802. tlv_type,
  1803. tlv_start);
  1804. else
  1805. dp_htt_stats_print_tag(pdev,
  1806. tlv_type,
  1807. tlv_start);
  1808. if (tlv_type == HTT_STATS_PEER_DETAILS_TAG ||
  1809. tlv_type == HTT_STATS_PEER_STATS_CMN_TAG)
  1810. dp_peer_update_inactive_time(pdev,
  1811. tlv_type,
  1812. tlv_start);
  1813. if (cookie_msb & DBG_STATS_COOKIE_HTT_OBSS)
  1814. dp_htt_set_pdev_obss_stats(pdev,
  1815. tlv_type,
  1816. tlv_start);
  1817. msg_remain_len -= tlv_remain_len;
  1818. msg_word = (uint32_t *)
  1819. (((uint8_t *)msg_word) +
  1820. tlv_remain_len);
  1821. tlv_remain_len = 0;
  1822. if (tlv_buf_head) {
  1823. qdf_mem_free(tlv_buf_head);
  1824. tlv_buf_head = NULL;
  1825. tlv_buf_tail = NULL;
  1826. }
  1827. } else { /* tlv_remain_len > msg_remain_len */
  1828. /* Case 2 & 3 */
  1829. if (!tlv_buf_head) {
  1830. tlv_buf_head = qdf_mem_malloc(
  1831. tlv_remain_len);
  1832. if (!tlv_buf_head) {
  1833. QDF_TRACE(QDF_MODULE_ID_TXRX,
  1834. QDF_TRACE_LEVEL_ERROR,
  1835. "Alloc failed");
  1836. goto error;
  1837. }
  1838. tlv_buf_tail = tlv_buf_head;
  1839. }
  1840. qdf_mem_copy(tlv_buf_tail, (uint8_t *)msg_word,
  1841. msg_remain_len);
  1842. tlv_remain_len -= msg_remain_len;
  1843. tlv_buf_tail += msg_remain_len;
  1844. }
  1845. }
  1846. if (htt_stats->msg_len >= DP_EXT_MSG_LENGTH) {
  1847. htt_stats->msg_len -= DP_EXT_MSG_LENGTH;
  1848. }
  1849. /* indicate event completion in case the event is done */
  1850. if (!cookie_val && (cookie_msb & DBG_SYSFS_STATS_COOKIE))
  1851. dp_htt_stats_sysfs_set_event(soc, msg_word);
  1852. qdf_nbuf_free(htt_msg);
  1853. }
  1854. return;
  1855. error:
  1856. qdf_nbuf_free(htt_msg);
  1857. while ((htt_msg = qdf_nbuf_queue_remove(&htt_stats->msg))
  1858. != NULL)
  1859. qdf_nbuf_free(htt_msg);
  1860. }
  1861. void htt_t2h_stats_handler(void *context)
  1862. {
  1863. struct dp_soc *soc = (struct dp_soc *)context;
  1864. struct htt_stats_context htt_stats;
  1865. uint32_t *msg_word;
  1866. qdf_nbuf_t htt_msg = NULL;
  1867. uint8_t done;
  1868. uint32_t rem_stats;
  1869. if (!soc) {
  1870. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1871. "soc is NULL");
  1872. return;
  1873. }
  1874. if (!qdf_atomic_read(&soc->cmn_init_done)) {
  1875. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1876. "soc: 0x%pK, init_done: %d", soc,
  1877. qdf_atomic_read(&soc->cmn_init_done));
  1878. return;
  1879. }
  1880. qdf_mem_zero(&htt_stats, sizeof(htt_stats));
  1881. qdf_nbuf_queue_init(&htt_stats.msg);
  1882. /* pull one completed stats from soc->htt_stats_msg and process */
  1883. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1884. if (!soc->htt_stats.num_stats) {
  1885. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1886. return;
  1887. }
  1888. while ((htt_msg = qdf_nbuf_queue_remove(&soc->htt_stats.msg)) != NULL) {
  1889. msg_word = (uint32_t *) qdf_nbuf_data(htt_msg);
  1890. msg_word = msg_word + HTT_T2H_EXT_STATS_TLV_START_OFFSET;
  1891. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1892. qdf_nbuf_queue_add(&htt_stats.msg, htt_msg);
  1893. /*
  1894. * Done bit signifies that this is the last T2H buffer in the
  1895. * stream of HTT EXT STATS message
  1896. */
  1897. if (done)
  1898. break;
  1899. }
  1900. rem_stats = --soc->htt_stats.num_stats;
  1901. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1902. /* If there are more stats to process, schedule stats work again.
  1903. * Scheduling prior to processing ht_stats to queue with early
  1904. * index
  1905. */
  1906. if (rem_stats)
  1907. qdf_sched_work(0, &soc->htt_stats.work);
  1908. dp_process_htt_stat_msg(&htt_stats, soc);
  1909. }
  1910. /**
  1911. * dp_txrx_fw_stats_handler() - Function to process HTT EXT stats
  1912. * @soc: DP SOC handle
  1913. * @htt_t2h_msg: HTT message nbuf
  1914. *
  1915. * return:void
  1916. */
  1917. static inline void dp_txrx_fw_stats_handler(struct dp_soc *soc,
  1918. qdf_nbuf_t htt_t2h_msg)
  1919. {
  1920. uint8_t done;
  1921. qdf_nbuf_t msg_copy;
  1922. uint32_t *msg_word;
  1923. msg_word = (uint32_t *)qdf_nbuf_data(htt_t2h_msg);
  1924. msg_word = msg_word + 3;
  1925. done = HTT_T2H_EXT_STATS_CONF_TLV_DONE_GET(*msg_word);
  1926. /*
  1927. * HTT EXT stats response comes as stream of TLVs which span over
  1928. * multiple T2H messages.
  1929. * The first message will carry length of the response.
  1930. * For rest of the messages length will be zero.
  1931. *
  1932. * Clone the T2H message buffer and store it in a list to process
  1933. * it later.
  1934. *
  1935. * The original T2H message buffers gets freed in the T2H HTT event
  1936. * handler
  1937. */
  1938. msg_copy = qdf_nbuf_clone(htt_t2h_msg);
  1939. if (!msg_copy) {
  1940. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  1941. "T2H message clone failed for HTT EXT STATS");
  1942. goto error;
  1943. }
  1944. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1945. qdf_nbuf_queue_add(&soc->htt_stats.msg, msg_copy);
  1946. /*
  1947. * Done bit signifies that this is the last T2H buffer in the stream of
  1948. * HTT EXT STATS message
  1949. */
  1950. if (done) {
  1951. soc->htt_stats.num_stats++;
  1952. qdf_sched_work(0, &soc->htt_stats.work);
  1953. }
  1954. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1955. return;
  1956. error:
  1957. qdf_spin_lock_bh(&soc->htt_stats.lock);
  1958. while ((msg_copy = qdf_nbuf_queue_remove(&soc->htt_stats.msg))
  1959. != NULL) {
  1960. qdf_nbuf_free(msg_copy);
  1961. }
  1962. soc->htt_stats.num_stats = 0;
  1963. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  1964. return;
  1965. }
  1966. /*
  1967. * htt_soc_attach_target() - SOC level HTT setup
  1968. * @htt_soc: HTT SOC handle
  1969. *
  1970. * Return: 0 on success; error code on failure
  1971. */
  1972. int htt_soc_attach_target(struct htt_soc *htt_soc)
  1973. {
  1974. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  1975. return htt_h2t_ver_req_msg(soc);
  1976. }
  1977. void htt_set_htc_handle(struct htt_soc *htt_soc, HTC_HANDLE htc_soc)
  1978. {
  1979. htt_soc->htc_soc = htc_soc;
  1980. }
  1981. HTC_HANDLE htt_get_htc_handle(struct htt_soc *htt_soc)
  1982. {
  1983. return htt_soc->htc_soc;
  1984. }
  1985. struct htt_soc *htt_soc_attach(struct dp_soc *soc, HTC_HANDLE htc_handle)
  1986. {
  1987. int i;
  1988. int j;
  1989. int umac_alloc_size = HTT_SW_UMAC_RING_IDX_MAX *
  1990. sizeof(struct bp_handler);
  1991. int lmac_alloc_size = HTT_SW_LMAC_RING_IDX_MAX *
  1992. sizeof(struct bp_handler);
  1993. struct htt_soc *htt_soc = NULL;
  1994. htt_soc = qdf_mem_malloc(sizeof(*htt_soc));
  1995. if (!htt_soc) {
  1996. dp_err("HTT attach failed");
  1997. return NULL;
  1998. }
  1999. for (i = 0; i < MAX_PDEV_CNT; i++) {
  2000. htt_soc->pdevid_tt[i].umac_path =
  2001. qdf_mem_malloc(umac_alloc_size);
  2002. if (!htt_soc->pdevid_tt[i].umac_path)
  2003. break;
  2004. for (j = 0; j < HTT_SW_UMAC_RING_IDX_MAX; j++)
  2005. htt_soc->pdevid_tt[i].umac_path[j].bp_start_tt = -1;
  2006. htt_soc->pdevid_tt[i].lmac_path =
  2007. qdf_mem_malloc(lmac_alloc_size);
  2008. if (!htt_soc->pdevid_tt[i].lmac_path) {
  2009. qdf_mem_free(htt_soc->pdevid_tt[i].umac_path);
  2010. break;
  2011. }
  2012. for (j = 0; j < HTT_SW_LMAC_RING_IDX_MAX ; j++)
  2013. htt_soc->pdevid_tt[i].lmac_path[j].bp_start_tt = -1;
  2014. }
  2015. if (i != MAX_PDEV_CNT) {
  2016. for (j = 0; j < i; j++) {
  2017. qdf_mem_free(htt_soc->pdevid_tt[j].umac_path);
  2018. qdf_mem_free(htt_soc->pdevid_tt[j].lmac_path);
  2019. }
  2020. qdf_mem_free(htt_soc);
  2021. return NULL;
  2022. }
  2023. htt_soc->dp_soc = soc;
  2024. htt_soc->htc_soc = htc_handle;
  2025. HTT_TX_MUTEX_INIT(&htt_soc->htt_tx_mutex);
  2026. return htt_soc;
  2027. }
  2028. #if defined(WDI_EVENT_ENABLE) && \
  2029. !defined(REMOVE_PKT_LOG)
  2030. /*
  2031. * dp_pktlog_msg_handler() - Pktlog msg handler
  2032. * @htt_soc: HTT SOC handle
  2033. * @msg_word: Pointer to payload
  2034. *
  2035. * Return: None
  2036. */
  2037. static void
  2038. dp_pktlog_msg_handler(struct htt_soc *soc,
  2039. uint32_t *msg_word)
  2040. {
  2041. uint8_t pdev_id;
  2042. uint8_t target_pdev_id;
  2043. uint32_t *pl_hdr;
  2044. target_pdev_id = HTT_T2H_PKTLOG_PDEV_ID_GET(*msg_word);
  2045. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2046. target_pdev_id);
  2047. pl_hdr = (msg_word + 1);
  2048. dp_wdi_event_handler(WDI_EVENT_OFFLOAD_ALL, soc->dp_soc,
  2049. pl_hdr, HTT_INVALID_PEER, WDI_NO_VAL,
  2050. pdev_id);
  2051. }
  2052. #else
  2053. static void
  2054. dp_pktlog_msg_handler(struct htt_soc *soc,
  2055. uint32_t *msg_word)
  2056. {
  2057. }
  2058. #endif
  2059. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  2060. /*
  2061. * dp_vdev_txrx_hw_stats_handler - Handle vdev stats received from FW
  2062. * @soc - htt soc handle
  2063. * @ msg_word - buffer containing stats
  2064. *
  2065. * Return: void
  2066. */
  2067. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2068. uint32_t *msg_word)
  2069. {
  2070. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2071. uint8_t pdev_id;
  2072. uint8_t vdev_id;
  2073. uint8_t target_pdev_id;
  2074. uint16_t payload_size;
  2075. struct dp_pdev *pdev;
  2076. struct dp_vdev *vdev;
  2077. uint8_t *tlv_buf;
  2078. uint32_t *tlv_buf_temp;
  2079. uint32_t *tag_buf;
  2080. htt_tlv_tag_t tlv_type;
  2081. uint16_t tlv_length;
  2082. uint64_t pkt_count = 0;
  2083. uint64_t byte_count = 0;
  2084. uint64_t soc_drop_cnt = 0;
  2085. struct cdp_pkt_info tx_comp = { 0 };
  2086. struct cdp_pkt_info tx_failed = { 0 };
  2087. target_pdev_id =
  2088. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PDEV_ID_GET(*msg_word);
  2089. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(dpsoc,
  2090. target_pdev_id);
  2091. if (pdev_id >= MAX_PDEV_CNT)
  2092. return;
  2093. pdev = dpsoc->pdev_list[pdev_id];
  2094. if (!pdev) {
  2095. dp_err("PDEV is NULL for pdev_id:%d", pdev_id);
  2096. return;
  2097. }
  2098. payload_size =
  2099. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PAYLOAD_SIZE_GET(*msg_word);
  2100. qdf_trace_hex_dump(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2101. (void *)msg_word, payload_size + 16);
  2102. /* Adjust msg_word to point to the first TLV in buffer */
  2103. msg_word = msg_word + 4;
  2104. /* Parse the received buffer till payload size reaches 0 */
  2105. while (payload_size > 0) {
  2106. tlv_buf = (uint8_t *)msg_word;
  2107. tlv_buf_temp = msg_word;
  2108. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2109. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2110. /* Add header size to tlv length*/
  2111. tlv_length += 4;
  2112. switch (tlv_type) {
  2113. case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
  2114. {
  2115. tag_buf = tlv_buf_temp +
  2116. HTT_VDEV_STATS_GET_INDEX(SOC_DROP_CNT);
  2117. soc_drop_cnt = HTT_VDEV_GET_STATS_U64(tag_buf);
  2118. DP_STATS_UPD(dpsoc, tx.tqm_drop_no_peer, soc_drop_cnt);
  2119. break;
  2120. }
  2121. case HTT_STATS_VDEV_TXRX_STATS_HW_STATS_TAG:
  2122. {
  2123. tag_buf = tlv_buf_temp +
  2124. HTT_VDEV_STATS_GET_INDEX(VDEV_ID);
  2125. vdev_id = (uint8_t)(*tag_buf);
  2126. vdev = dp_vdev_get_ref_by_id(dpsoc, vdev_id,
  2127. DP_MOD_ID_HTT);
  2128. if (!vdev)
  2129. goto invalid_vdev;
  2130. /* Extract received packet count from buffer */
  2131. tag_buf = tlv_buf_temp +
  2132. HTT_VDEV_STATS_GET_INDEX(RX_PKT_CNT);
  2133. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2134. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.num, pkt_count);
  2135. /* Extract received packet byte count from buffer */
  2136. tag_buf = tlv_buf_temp +
  2137. HTT_VDEV_STATS_GET_INDEX(RX_BYTE_CNT);
  2138. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2139. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.bytes, byte_count);
  2140. /* Extract tx success packet count from buffer */
  2141. tag_buf = tlv_buf_temp +
  2142. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_PKT_CNT);
  2143. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2144. tx_comp.num = pkt_count;
  2145. /* Extract tx success packet byte count from buffer */
  2146. tag_buf = tlv_buf_temp +
  2147. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_BYTE_CNT);
  2148. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2149. tx_comp.bytes = byte_count;
  2150. /* Extract tx retry packet count from buffer */
  2151. tag_buf = tlv_buf_temp +
  2152. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_PKT_CNT);
  2153. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2154. tx_comp.num += pkt_count;
  2155. tx_failed.num = pkt_count;
  2156. /* Extract tx retry packet byte count from buffer */
  2157. tag_buf = tlv_buf_temp +
  2158. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_BYTE_CNT);
  2159. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2160. tx_comp.bytes += byte_count;
  2161. tx_failed.bytes = byte_count;
  2162. /* Extract tx drop packet count from buffer */
  2163. tag_buf = tlv_buf_temp +
  2164. HTT_VDEV_STATS_GET_INDEX(TX_DROP_PKT_CNT);
  2165. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2166. tx_comp.num += pkt_count;
  2167. tx_failed.num += pkt_count;
  2168. /* Extract tx drop packet byte count from buffer */
  2169. tag_buf = tlv_buf_temp +
  2170. HTT_VDEV_STATS_GET_INDEX(TX_DROP_BYTE_CNT);
  2171. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2172. tx_comp.bytes += byte_count;
  2173. tx_failed.bytes += byte_count;
  2174. /* Extract tx age-out packet count from buffer */
  2175. tag_buf = tlv_buf_temp +
  2176. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_PKT_CNT);
  2177. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2178. tx_comp.num += pkt_count;
  2179. tx_failed.num += pkt_count;
  2180. /* Extract tx age-out packet byte count from buffer */
  2181. tag_buf = tlv_buf_temp +
  2182. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_BYTE_CNT);
  2183. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2184. tx_comp.bytes += byte_count;
  2185. tx_failed.bytes += byte_count;
  2186. /* Extract tqm bypass packet count from buffer */
  2187. tag_buf = tlv_buf_temp +
  2188. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_PKT_CNT);
  2189. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2190. tx_comp.num += pkt_count;
  2191. /* Extract tx bypass packet byte count from buffer */
  2192. tag_buf = tlv_buf_temp +
  2193. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_BYTE_CNT);
  2194. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2195. tx_comp.bytes += byte_count;
  2196. DP_STATS_UPD(vdev, tx.comp_pkt.num, tx_comp.num);
  2197. DP_STATS_UPD(vdev, tx.comp_pkt.bytes, tx_comp.bytes);
  2198. DP_STATS_UPD(vdev, tx.tx_failed, tx_failed.num);
  2199. dp_vdev_unref_delete(dpsoc, vdev, DP_MOD_ID_HTT);
  2200. break;
  2201. }
  2202. default:
  2203. qdf_assert(0);
  2204. }
  2205. invalid_vdev:
  2206. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2207. payload_size -= tlv_length;
  2208. }
  2209. }
  2210. #else
  2211. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2212. uint32_t *msg_word)
  2213. {}
  2214. #endif
  2215. #ifdef CONFIG_SAWF_DEF_QUEUES
  2216. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2217. uint32_t *msg_word,
  2218. qdf_nbuf_t htt_t2h_msg)
  2219. {
  2220. dp_htt_sawf_def_queues_map_report_conf(soc, msg_word, htt_t2h_msg);
  2221. }
  2222. #else
  2223. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2224. uint32_t *msg_word,
  2225. qdf_nbuf_t htt_t2h_msg)
  2226. {}
  2227. #endif
  2228. #ifdef CONFIG_SAWF
  2229. /*
  2230. * dp_sawf_msduq_map() - Msdu queue creation information received
  2231. * from target
  2232. * @soc: soc handle.
  2233. * @msg_word: Pointer to htt msg word.
  2234. * @htt_t2h_msg: HTT message nbuf
  2235. *
  2236. * @return: void
  2237. */
  2238. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2239. qdf_nbuf_t htt_t2h_msg)
  2240. {
  2241. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2242. }
  2243. /*
  2244. * dp_sawf_mpdu_stats_handler() - HTT message handler for MPDU stats
  2245. * @soc: soc handle.
  2246. * @htt_t2h_msg: HTT message nbuf
  2247. *
  2248. * @return: void
  2249. */
  2250. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2251. qdf_nbuf_t htt_t2h_msg)
  2252. {
  2253. dp_sawf_htt_mpdu_stats_handler(soc, htt_t2h_msg);
  2254. }
  2255. #else
  2256. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2257. qdf_nbuf_t htt_t2h_msg)
  2258. {}
  2259. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2260. qdf_nbuf_t htt_t2h_msg)
  2261. {}
  2262. #endif
  2263. /*
  2264. * time_allow_print() - time allow print
  2265. * @htt_ring_tt: ringi_id array of timestamps
  2266. * @ring_id: ring_id (index)
  2267. *
  2268. * Return: 1 for successfully saving timestamp in array
  2269. * and 0 for timestamp falling within 2 seconds after last one
  2270. */
  2271. static bool time_allow_print(struct bp_handler *htt_bp_handler,
  2272. u_int8_t ring_id, u_int32_t th_time)
  2273. {
  2274. unsigned long tstamp;
  2275. struct bp_handler *path = &htt_bp_handler[ring_id];
  2276. tstamp = qdf_get_system_timestamp();
  2277. if (!path)
  2278. return 0; //unable to print backpressure messages
  2279. if (path->bp_start_tt == -1) {
  2280. path->bp_start_tt = tstamp;
  2281. path->bp_duration = 0;
  2282. path->bp_last_tt = tstamp;
  2283. path->bp_counter = 1;
  2284. return 1;
  2285. }
  2286. path->bp_duration = tstamp - path->bp_start_tt;
  2287. path->bp_last_tt = tstamp;
  2288. path->bp_counter++;
  2289. if (path->bp_duration >= th_time) {
  2290. path->bp_start_tt = -1;
  2291. return 1;
  2292. }
  2293. return 0;
  2294. }
  2295. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2296. struct dp_pdev *pdev, u_int8_t ring_id,
  2297. u_int16_t hp_idx, u_int16_t tp_idx,
  2298. u_int32_t bkp_time,
  2299. struct bp_handler *htt_bp_handler,
  2300. char *ring_stype)
  2301. {
  2302. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2303. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2304. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2305. ring_id, hp_idx, tp_idx, bkp_time);
  2306. dp_alert("last_bp_event: %ld, total_bp_duration: %ld, bp_counter: %ld",
  2307. htt_bp_handler[ring_id].bp_last_tt,
  2308. htt_bp_handler[ring_id].bp_duration,
  2309. htt_bp_handler[ring_id].bp_counter);
  2310. }
  2311. /**
  2312. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2313. * @soc: DP_SOC handle
  2314. * @srng: DP_SRNG handle
  2315. * @ring_type: srng src/dst ring
  2316. *
  2317. * Return: void
  2318. */
  2319. static QDF_STATUS
  2320. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2321. struct dp_pdev *pdev,
  2322. struct dp_srng *srng,
  2323. enum hal_ring_type ring_type,
  2324. struct dp_srng_ring_state *state)
  2325. {
  2326. struct hal_soc *hal_soc;
  2327. if (!soc || !srng || !srng->hal_srng || !state)
  2328. return QDF_STATUS_E_INVAL;
  2329. hal_soc = (struct hal_soc *)soc->hal_soc;
  2330. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2331. &state->sw_head);
  2332. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2333. &state->hw_tail, ring_type);
  2334. state->ring_type = ring_type;
  2335. return QDF_STATUS_SUCCESS;
  2336. }
  2337. #ifdef QCA_MONITOR_PKT_SUPPORT
  2338. static void
  2339. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2340. int lmac_id, uint32_t *num_srng,
  2341. struct dp_soc_srngs_state *soc_srngs_state)
  2342. {
  2343. QDF_STATUS status;
  2344. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2345. status = dp_get_srng_ring_state_from_hal
  2346. (pdev->soc, pdev,
  2347. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2348. RXDMA_MONITOR_BUF,
  2349. &soc_srngs_state->ring_state[*num_srng]);
  2350. if (status == QDF_STATUS_SUCCESS)
  2351. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2352. status = dp_get_srng_ring_state_from_hal
  2353. (pdev->soc, pdev,
  2354. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2355. RXDMA_MONITOR_DST,
  2356. &soc_srngs_state->ring_state[*num_srng]);
  2357. if (status == QDF_STATUS_SUCCESS)
  2358. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2359. status = dp_get_srng_ring_state_from_hal
  2360. (pdev->soc, pdev,
  2361. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2362. RXDMA_MONITOR_DESC,
  2363. &soc_srngs_state->ring_state[*num_srng]);
  2364. if (status == QDF_STATUS_SUCCESS)
  2365. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2366. }
  2367. }
  2368. #else
  2369. static void
  2370. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2371. int lmac_id, uint32_t *num_srng,
  2372. struct dp_soc_srngs_state *soc_srngs_state)
  2373. {
  2374. }
  2375. #endif
  2376. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  2377. static inline QDF_STATUS
  2378. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2379. struct dp_srng_ring_state *ring_state)
  2380. {
  2381. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2382. &pdev->soc->tcl_cmd_credit_ring,
  2383. TCL_CMD_CREDIT, ring_state);
  2384. }
  2385. #else
  2386. static inline QDF_STATUS
  2387. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2388. struct dp_srng_ring_state *ring_state)
  2389. {
  2390. return QDF_STATUS_SUCCESS;
  2391. }
  2392. #endif
  2393. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  2394. static inline QDF_STATUS
  2395. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2396. struct dp_srng_ring_state *ring_state)
  2397. {
  2398. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2399. &pdev->soc->tcl_status_ring,
  2400. TCL_STATUS, ring_state);
  2401. }
  2402. #else
  2403. static inline QDF_STATUS
  2404. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2405. struct dp_srng_ring_state *ring_state)
  2406. {
  2407. return QDF_STATUS_SUCCESS;
  2408. }
  2409. #endif
  2410. /**
  2411. * dp_queue_srng_ring_stats(): Print pdev hal level ring stats
  2412. * @pdev: DP_pdev handle
  2413. *
  2414. * Return: void
  2415. */
  2416. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2417. {
  2418. uint32_t i;
  2419. int mac_id;
  2420. int lmac_id;
  2421. uint32_t j = 0;
  2422. struct dp_soc *soc = pdev->soc;
  2423. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2424. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2425. QDF_STATUS status;
  2426. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2427. if (!soc_srngs_state) {
  2428. dp_htt_alert("Memory alloc failed for back pressure event");
  2429. return;
  2430. }
  2431. status = dp_get_srng_ring_state_from_hal
  2432. (pdev->soc, pdev,
  2433. &pdev->soc->reo_exception_ring,
  2434. REO_EXCEPTION,
  2435. &soc_srngs_state->ring_state[j]);
  2436. if (status == QDF_STATUS_SUCCESS)
  2437. qdf_assert_always(++j < DP_MAX_SRNGS);
  2438. status = dp_get_srng_ring_state_from_hal
  2439. (pdev->soc, pdev,
  2440. &pdev->soc->reo_reinject_ring,
  2441. REO_REINJECT,
  2442. &soc_srngs_state->ring_state[j]);
  2443. if (status == QDF_STATUS_SUCCESS)
  2444. qdf_assert_always(++j < DP_MAX_SRNGS);
  2445. status = dp_get_srng_ring_state_from_hal
  2446. (pdev->soc, pdev,
  2447. &pdev->soc->reo_cmd_ring,
  2448. REO_CMD,
  2449. &soc_srngs_state->ring_state[j]);
  2450. if (status == QDF_STATUS_SUCCESS)
  2451. qdf_assert_always(++j < DP_MAX_SRNGS);
  2452. status = dp_get_srng_ring_state_from_hal
  2453. (pdev->soc, pdev,
  2454. &pdev->soc->reo_status_ring,
  2455. REO_STATUS,
  2456. &soc_srngs_state->ring_state[j]);
  2457. if (status == QDF_STATUS_SUCCESS)
  2458. qdf_assert_always(++j < DP_MAX_SRNGS);
  2459. status = dp_get_srng_ring_state_from_hal
  2460. (pdev->soc, pdev,
  2461. &pdev->soc->rx_rel_ring,
  2462. WBM2SW_RELEASE,
  2463. &soc_srngs_state->ring_state[j]);
  2464. if (status == QDF_STATUS_SUCCESS)
  2465. qdf_assert_always(++j < DP_MAX_SRNGS);
  2466. status = dp_get_tcl_cmd_cred_ring_state_from_hal
  2467. (pdev, &soc_srngs_state->ring_state[j]);
  2468. if (status == QDF_STATUS_SUCCESS)
  2469. qdf_assert_always(++j < DP_MAX_SRNGS);
  2470. status = dp_get_tcl_status_ring_state_from_hal
  2471. (pdev, &soc_srngs_state->ring_state[j]);
  2472. if (status == QDF_STATUS_SUCCESS)
  2473. qdf_assert_always(++j < DP_MAX_SRNGS);
  2474. status = dp_get_srng_ring_state_from_hal
  2475. (pdev->soc, pdev,
  2476. &pdev->soc->wbm_desc_rel_ring,
  2477. SW2WBM_RELEASE,
  2478. &soc_srngs_state->ring_state[j]);
  2479. if (status == QDF_STATUS_SUCCESS)
  2480. qdf_assert_always(++j < DP_MAX_SRNGS);
  2481. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2482. status = dp_get_srng_ring_state_from_hal
  2483. (pdev->soc, pdev,
  2484. &pdev->soc->reo_dest_ring[i],
  2485. REO_DST,
  2486. &soc_srngs_state->ring_state[j]);
  2487. if (status == QDF_STATUS_SUCCESS)
  2488. qdf_assert_always(++j < DP_MAX_SRNGS);
  2489. }
  2490. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2491. status = dp_get_srng_ring_state_from_hal
  2492. (pdev->soc, pdev,
  2493. &pdev->soc->tcl_data_ring[i],
  2494. TCL_DATA,
  2495. &soc_srngs_state->ring_state[j]);
  2496. if (status == QDF_STATUS_SUCCESS)
  2497. qdf_assert_always(++j < DP_MAX_SRNGS);
  2498. }
  2499. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2500. status = dp_get_srng_ring_state_from_hal
  2501. (pdev->soc, pdev,
  2502. &pdev->soc->tx_comp_ring[i],
  2503. WBM2SW_RELEASE,
  2504. &soc_srngs_state->ring_state[j]);
  2505. if (status == QDF_STATUS_SUCCESS)
  2506. qdf_assert_always(++j < DP_MAX_SRNGS);
  2507. }
  2508. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2509. status = dp_get_srng_ring_state_from_hal
  2510. (pdev->soc, pdev,
  2511. &pdev->soc->rx_refill_buf_ring
  2512. [lmac_id],
  2513. RXDMA_BUF,
  2514. &soc_srngs_state->ring_state[j]);
  2515. if (status == QDF_STATUS_SUCCESS)
  2516. qdf_assert_always(++j < DP_MAX_SRNGS);
  2517. status = dp_get_srng_ring_state_from_hal
  2518. (pdev->soc, pdev,
  2519. &pdev->rx_refill_buf_ring2,
  2520. RXDMA_BUF,
  2521. &soc_srngs_state->ring_state[j]);
  2522. if (status == QDF_STATUS_SUCCESS)
  2523. qdf_assert_always(++j < DP_MAX_SRNGS);
  2524. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2525. dp_get_srng_ring_state_from_hal
  2526. (pdev->soc, pdev,
  2527. &pdev->rx_mac_buf_ring[i],
  2528. RXDMA_BUF,
  2529. &soc_srngs_state->ring_state[j]);
  2530. if (status == QDF_STATUS_SUCCESS)
  2531. qdf_assert_always(++j < DP_MAX_SRNGS);
  2532. }
  2533. for (mac_id = 0;
  2534. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2535. mac_id++) {
  2536. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2537. mac_id, pdev->pdev_id);
  2538. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2539. soc_srngs_state);
  2540. status = dp_get_srng_ring_state_from_hal
  2541. (pdev->soc, pdev,
  2542. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2543. RXDMA_MONITOR_STATUS,
  2544. &soc_srngs_state->ring_state[j]);
  2545. if (status == QDF_STATUS_SUCCESS)
  2546. qdf_assert_always(++j < DP_MAX_SRNGS);
  2547. }
  2548. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2549. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2550. i, pdev->pdev_id);
  2551. status = dp_get_srng_ring_state_from_hal
  2552. (pdev->soc, pdev,
  2553. &pdev->soc->rxdma_err_dst_ring
  2554. [lmac_id],
  2555. RXDMA_DST,
  2556. &soc_srngs_state->ring_state[j]);
  2557. if (status == QDF_STATUS_SUCCESS)
  2558. qdf_assert_always(++j < DP_MAX_SRNGS);
  2559. }
  2560. soc_srngs_state->max_ring_id = j;
  2561. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2562. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2563. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2564. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2565. qdf_assert_always(drop_srngs_state);
  2566. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2567. list_elem);
  2568. qdf_mem_free(drop_srngs_state);
  2569. pdev->bkp_stats.queue_depth--;
  2570. }
  2571. pdev->bkp_stats.queue_depth++;
  2572. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2573. list_elem);
  2574. pdev->bkp_stats.seq_num++;
  2575. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2576. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2577. &pdev->bkp_stats.work);
  2578. }
  2579. /*
  2580. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2581. * @msg_word: htt packet context
  2582. * @htt_soc: HTT SOC handle
  2583. *
  2584. * Return: after attempting to print stats
  2585. */
  2586. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2587. {
  2588. u_int8_t ring_type;
  2589. u_int8_t pdev_id;
  2590. uint8_t target_pdev_id;
  2591. u_int8_t ring_id;
  2592. u_int16_t hp_idx;
  2593. u_int16_t tp_idx;
  2594. u_int32_t bkp_time;
  2595. u_int32_t th_time;
  2596. enum htt_t2h_msg_type msg_type;
  2597. struct dp_soc *dpsoc;
  2598. struct dp_pdev *pdev;
  2599. struct dp_htt_timestamp *radio_tt;
  2600. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2601. if (!soc)
  2602. return;
  2603. dpsoc = (struct dp_soc *)soc->dp_soc;
  2604. soc_cfg_ctx = dpsoc->wlan_cfg_ctx;
  2605. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2606. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2607. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2608. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2609. target_pdev_id);
  2610. if (pdev_id >= MAX_PDEV_CNT) {
  2611. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2612. return;
  2613. }
  2614. th_time = wlan_cfg_time_control_bp(soc_cfg_ctx);
  2615. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2616. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2617. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2618. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2619. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2620. radio_tt = &soc->pdevid_tt[pdev_id];
  2621. switch (ring_type) {
  2622. case HTT_SW_RING_TYPE_UMAC:
  2623. if (!time_allow_print(radio_tt->umac_path, ring_id, th_time))
  2624. return;
  2625. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2626. bkp_time, radio_tt->umac_path,
  2627. "HTT_SW_RING_TYPE_UMAC");
  2628. break;
  2629. case HTT_SW_RING_TYPE_LMAC:
  2630. if (!time_allow_print(radio_tt->lmac_path, ring_id, th_time))
  2631. return;
  2632. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2633. bkp_time, radio_tt->lmac_path,
  2634. "HTT_SW_RING_TYPE_LMAC");
  2635. break;
  2636. default:
  2637. dp_alert("Invalid ring type: %d", ring_type);
  2638. break;
  2639. }
  2640. dp_queue_ring_stats(pdev);
  2641. }
  2642. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2643. /*
  2644. * dp_offload_ind_handler() - offload msg handler
  2645. * @htt_soc: HTT SOC handle
  2646. * @msg_word: Pointer to payload
  2647. *
  2648. * Return: None
  2649. */
  2650. static void
  2651. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2652. {
  2653. u_int8_t pdev_id;
  2654. u_int8_t target_pdev_id;
  2655. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2656. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2657. target_pdev_id);
  2658. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2659. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2660. pdev_id);
  2661. }
  2662. #else
  2663. static void
  2664. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2665. {
  2666. }
  2667. #endif
  2668. #ifdef WLAN_FEATURE_11BE_MLO
  2669. #ifdef WLAN_MLO_MULTI_CHIP
  2670. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2671. uint32_t ts_lo, uint32_t ts_hi)
  2672. {
  2673. uint64_t mlo_offset;
  2674. mlo_offset = ((uint64_t)(ts_hi) << 32 | ts_lo);
  2675. soc->cdp_soc.ops->mlo_ops->mlo_update_mlo_ts_offset
  2676. ((struct cdp_soc_t *)soc, mlo_offset);
  2677. }
  2678. #else
  2679. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2680. uint32_t ts_lo, uint32_t ts_hi)
  2681. {}
  2682. #endif
  2683. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2684. uint32_t *msg_word)
  2685. {
  2686. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2687. uint8_t *mlo_peer_mac_addr;
  2688. uint16_t mlo_peer_id;
  2689. uint8_t num_links;
  2690. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2691. struct dp_mlo_link_info mlo_link_info[DP_MAX_MLO_LINKS];
  2692. MLO_PEER_MAP_TLV_TAG_ID tlv_type = 0xff;
  2693. uint16_t tlv_len = 0;
  2694. int i = 0;
  2695. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2696. num_links =
  2697. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2698. mlo_peer_mac_addr =
  2699. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2700. &mac_addr_deswizzle_buf[0]);
  2701. mlo_flow_info[0].ast_idx =
  2702. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2703. mlo_flow_info[0].ast_idx_valid =
  2704. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2705. mlo_flow_info[0].chip_id =
  2706. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2707. mlo_flow_info[0].tidmask =
  2708. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2709. mlo_flow_info[0].cache_set_num =
  2710. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2711. mlo_flow_info[1].ast_idx =
  2712. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2713. mlo_flow_info[1].ast_idx_valid =
  2714. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2715. mlo_flow_info[1].chip_id =
  2716. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2717. mlo_flow_info[1].tidmask =
  2718. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2719. mlo_flow_info[1].cache_set_num =
  2720. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2721. mlo_flow_info[2].ast_idx =
  2722. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2723. mlo_flow_info[2].ast_idx_valid =
  2724. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2725. mlo_flow_info[2].chip_id =
  2726. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2727. mlo_flow_info[2].tidmask =
  2728. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2729. mlo_flow_info[2].cache_set_num =
  2730. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2731. msg_word = msg_word + 8;
  2732. while (msg_word && (i < DP_MAX_MLO_LINKS)) {
  2733. mlo_link_info[i].peer_chip_id = 0xFF;
  2734. mlo_link_info[i].vdev_id = 0xFF;
  2735. tlv_type = HTT_RX_MLO_PEER_MAP_TLV_TAG_GET(*msg_word);
  2736. tlv_len = HTT_RX_MLO_PEER_MAP_TLV_LENGTH_GET(*msg_word);
  2737. if (tlv_len == 0) {
  2738. dp_err("TLV Length is 0");
  2739. break;
  2740. }
  2741. if (tlv_type == MLO_PEER_MAP_TLV_STRUCT_SOC_VDEV_PEER_IDS) {
  2742. mlo_link_info[i].peer_chip_id =
  2743. HTT_RX_MLO_PEER_MAP_CHIP_ID_GET(
  2744. *(msg_word + 1));
  2745. mlo_link_info[i].vdev_id =
  2746. HTT_RX_MLO_PEER_MAP_VDEV_ID_GET(
  2747. *(msg_word + 1));
  2748. }
  2749. /* Add header size to tlv length */
  2750. tlv_len = tlv_len + HTT_TLV_HDR_LEN;
  2751. msg_word = (uint32_t *)(((uint8_t *)msg_word) + tlv_len);
  2752. i++;
  2753. }
  2754. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2755. mlo_peer_mac_addr,
  2756. mlo_flow_info, mlo_link_info);
  2757. }
  2758. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2759. uint32_t *msg_word)
  2760. {
  2761. uint16_t mlo_peer_id;
  2762. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  2763. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  2764. }
  2765. static void
  2766. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  2767. uint32_t *msg_word)
  2768. {
  2769. uint8_t pdev_id;
  2770. uint8_t target_pdev_id;
  2771. struct dp_pdev *pdev;
  2772. if (!soc)
  2773. return;
  2774. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  2775. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  2776. target_pdev_id);
  2777. if (pdev_id >= MAX_PDEV_CNT) {
  2778. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2779. return;
  2780. }
  2781. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  2782. if (!pdev) {
  2783. dp_err("Invalid pdev");
  2784. return;
  2785. }
  2786. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  2787. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  2788. pdev_id);
  2789. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2790. pdev->timestamp.msg_type =
  2791. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  2792. pdev->timestamp.pdev_id = pdev_id;
  2793. pdev->timestamp.chip_id =
  2794. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  2795. pdev->timestamp.mac_clk_freq =
  2796. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  2797. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  2798. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  2799. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  2800. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  2801. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  2802. pdev->timestamp.mlo_comp_us =
  2803. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  2804. *(msg_word + 6));
  2805. pdev->timestamp.mlo_comp_clks =
  2806. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  2807. *(msg_word + 6));
  2808. pdev->timestamp.mlo_comp_timer =
  2809. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  2810. *(msg_word + 7));
  2811. dp_htt_debug("tsf_lo=%d tsf_hi=%d, mlo_ofst_lo=%d, mlo_ofst_hi=%d\n",
  2812. pdev->timestamp.sync_tstmp_lo_us,
  2813. pdev->timestamp.sync_tstmp_hi_us,
  2814. pdev->timestamp.mlo_offset_lo_us,
  2815. pdev->timestamp.mlo_offset_hi_us);
  2816. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  2817. dp_update_mlo_ts_offset(soc,
  2818. pdev->timestamp.mlo_offset_lo_us,
  2819. pdev->timestamp.mlo_offset_hi_us);
  2820. }
  2821. #else
  2822. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2823. uint32_t *msg_word)
  2824. {
  2825. qdf_assert_always(0);
  2826. }
  2827. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2828. uint32_t *msg_word)
  2829. {
  2830. qdf_assert_always(0);
  2831. }
  2832. static void
  2833. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  2834. uint32_t *msg_word)
  2835. {
  2836. qdf_assert_always(0);
  2837. }
  2838. #endif
  2839. /*
  2840. * dp_htt_rx_addba_handler() - RX Addba HTT msg handler
  2841. * @soc: DP Soc handler
  2842. * @peer_id: ID of peer
  2843. * @tid: TID number
  2844. * @win_sz: BA window size
  2845. *
  2846. * Return: None
  2847. */
  2848. static void
  2849. dp_htt_rx_addba_handler(struct dp_soc *soc, uint16_t peer_id,
  2850. uint8_t tid, uint16_t win_sz)
  2851. {
  2852. uint16_t status;
  2853. struct dp_peer *peer;
  2854. peer = dp_peer_get_ref_by_id(soc, peer_id, DP_MOD_ID_HTT);
  2855. if (!peer) {
  2856. dp_err("Peer not found peer id %d", peer_id);
  2857. return;
  2858. }
  2859. status = dp_addba_requestprocess_wifi3((struct cdp_soc_t *)soc,
  2860. peer->mac_addr.raw,
  2861. peer->vdev->vdev_id, 0,
  2862. tid, 0, win_sz, 0xffff);
  2863. dp_addba_resp_tx_completion_wifi3(
  2864. (struct cdp_soc_t *)soc,
  2865. peer->mac_addr.raw, peer->vdev->vdev_id,
  2866. tid,
  2867. status);
  2868. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  2869. dp_info("PeerID %d BAW %d TID %d stat %d",
  2870. peer_id, win_sz, tid, status);
  2871. }
  2872. /*
  2873. * dp_htt_ppdu_id_fmt_handler() - PPDU ID Format handler
  2874. * @htt_soc: HTT SOC handle
  2875. * @msg_word: Pointer to payload
  2876. *
  2877. * Return: None
  2878. */
  2879. static void
  2880. dp_htt_ppdu_id_fmt_handler(struct dp_soc *soc, uint32_t *msg_word)
  2881. {
  2882. uint8_t msg_type, valid, bits, offset;
  2883. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2884. msg_word += HTT_PPDU_ID_FMT_IND_LINK_ID_OFFSET;
  2885. valid = HTT_PPDU_ID_FMT_IND_VALID_GET_BITS31_16(*msg_word);
  2886. bits = HTT_PPDU_ID_FMT_IND_BITS_GET_BITS31_16(*msg_word);
  2887. offset = HTT_PPDU_ID_FMT_IND_OFFSET_GET_BITS31_16(*msg_word);
  2888. dp_info("link_id: valid %u bits %u offset %u", valid, bits, offset);
  2889. if (valid) {
  2890. soc->link_id_offset = offset;
  2891. soc->link_id_bits = bits;
  2892. }
  2893. }
  2894. /*
  2895. * dp_htt_t2h_msg_handler() - Generic Target to host Msg/event handler
  2896. * @context: Opaque context (HTT SOC handle)
  2897. * @pkt: HTC packet
  2898. */
  2899. static void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  2900. {
  2901. struct htt_soc *soc = (struct htt_soc *) context;
  2902. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  2903. u_int32_t *msg_word;
  2904. enum htt_t2h_msg_type msg_type;
  2905. bool free_buf = true;
  2906. /* check for successful message reception */
  2907. if (pkt->Status != QDF_STATUS_SUCCESS) {
  2908. if (pkt->Status != QDF_STATUS_E_CANCELED)
  2909. soc->stats.htc_err_cnt++;
  2910. qdf_nbuf_free(htt_t2h_msg);
  2911. return;
  2912. }
  2913. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  2914. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  2915. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2916. htt_event_record(soc->htt_logger_handle,
  2917. msg_type, (uint8_t *)msg_word);
  2918. switch (msg_type) {
  2919. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  2920. {
  2921. dp_htt_bkp_event_alert(msg_word, soc);
  2922. break;
  2923. }
  2924. case HTT_T2H_MSG_TYPE_PEER_MAP:
  2925. {
  2926. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2927. u_int8_t *peer_mac_addr;
  2928. u_int16_t peer_id;
  2929. u_int16_t hw_peer_id;
  2930. u_int8_t vdev_id;
  2931. u_int8_t is_wds;
  2932. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2933. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  2934. hw_peer_id =
  2935. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  2936. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  2937. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  2938. (u_int8_t *) (msg_word+1),
  2939. &mac_addr_deswizzle_buf[0]);
  2940. QDF_TRACE(QDF_MODULE_ID_TXRX,
  2941. QDF_TRACE_LEVEL_DEBUG,
  2942. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  2943. peer_id, vdev_id);
  2944. /*
  2945. * check if peer already exists for this peer_id, if so
  2946. * this peer map event is in response for a wds peer add
  2947. * wmi command sent during wds source port learning.
  2948. * in this case just add the ast entry to the existing
  2949. * peer ast_list.
  2950. */
  2951. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  2952. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  2953. vdev_id, peer_mac_addr, 0,
  2954. is_wds);
  2955. break;
  2956. }
  2957. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  2958. {
  2959. u_int16_t peer_id;
  2960. u_int8_t vdev_id;
  2961. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  2962. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  2963. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  2964. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  2965. vdev_id, mac_addr, 0,
  2966. DP_PEER_WDS_COUNT_INVALID);
  2967. break;
  2968. }
  2969. case HTT_T2H_MSG_TYPE_SEC_IND:
  2970. {
  2971. u_int16_t peer_id;
  2972. enum cdp_sec_type sec_type;
  2973. int is_unicast;
  2974. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  2975. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  2976. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  2977. /* point to the first part of the Michael key */
  2978. msg_word++;
  2979. dp_rx_sec_ind_handler(
  2980. soc->dp_soc, peer_id, sec_type, is_unicast,
  2981. msg_word, msg_word + 2);
  2982. break;
  2983. }
  2984. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  2985. {
  2986. free_buf =
  2987. dp_monitor_ppdu_stats_ind_handler(soc,
  2988. msg_word,
  2989. htt_t2h_msg);
  2990. break;
  2991. }
  2992. case HTT_T2H_MSG_TYPE_PKTLOG:
  2993. {
  2994. dp_pktlog_msg_handler(soc, msg_word);
  2995. break;
  2996. }
  2997. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  2998. {
  2999. /*
  3000. * HTC maintains runtime pm count for H2T messages that
  3001. * have a response msg from FW. This count ensures that
  3002. * in the case FW does not sent out the response or host
  3003. * did not process this indication runtime_put happens
  3004. * properly in the cleanup path.
  3005. */
  3006. if (htc_dec_return_runtime_cnt(soc->htc_soc) >= 0)
  3007. htc_pm_runtime_put(soc->htc_soc);
  3008. else
  3009. soc->stats.htt_ver_req_put_skip++;
  3010. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3011. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3012. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  3013. "target uses HTT version %d.%d; host uses %d.%d",
  3014. soc->tgt_ver.major, soc->tgt_ver.minor,
  3015. HTT_CURRENT_VERSION_MAJOR,
  3016. HTT_CURRENT_VERSION_MINOR);
  3017. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3018. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3019. QDF_TRACE_LEVEL_WARN,
  3020. "*** Incompatible host/target HTT versions!");
  3021. }
  3022. /* abort if the target is incompatible with the host */
  3023. qdf_assert(soc->tgt_ver.major ==
  3024. HTT_CURRENT_VERSION_MAJOR);
  3025. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  3026. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3027. QDF_TRACE_LEVEL_INFO_LOW,
  3028. "*** Warning: host/target HTT versions"
  3029. " are different, though compatible!");
  3030. }
  3031. break;
  3032. }
  3033. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3034. {
  3035. uint16_t peer_id;
  3036. uint8_t tid;
  3037. uint16_t win_sz;
  3038. /*
  3039. * Update REO Queue Desc with new values
  3040. */
  3041. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3042. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3043. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3044. /*
  3045. * Window size needs to be incremented by 1
  3046. * since fw needs to represent a value of 256
  3047. * using just 8 bits
  3048. */
  3049. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3050. tid, win_sz + 1);
  3051. break;
  3052. }
  3053. case HTT_T2H_MSG_TYPE_RX_ADDBA_EXTN:
  3054. {
  3055. uint16_t peer_id;
  3056. uint8_t tid;
  3057. uint16_t win_sz;
  3058. peer_id = HTT_RX_ADDBA_EXTN_PEER_ID_GET(*msg_word);
  3059. tid = HTT_RX_ADDBA_EXTN_TID_GET(*msg_word);
  3060. msg_word++;
  3061. win_sz = HTT_RX_ADDBA_EXTN_WIN_SIZE_GET(*msg_word);
  3062. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3063. tid, win_sz);
  3064. break;
  3065. }
  3066. case HTT_T2H_PPDU_ID_FMT_IND:
  3067. {
  3068. dp_htt_ppdu_id_fmt_handler(soc->dp_soc, msg_word);
  3069. break;
  3070. }
  3071. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3072. {
  3073. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3074. break;
  3075. }
  3076. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3077. {
  3078. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3079. u_int8_t *peer_mac_addr;
  3080. u_int16_t peer_id;
  3081. u_int16_t hw_peer_id;
  3082. u_int8_t vdev_id;
  3083. bool is_wds;
  3084. u_int16_t ast_hash;
  3085. struct dp_ast_flow_override_info ast_flow_info;
  3086. qdf_mem_set(&ast_flow_info, 0,
  3087. sizeof(struct dp_ast_flow_override_info));
  3088. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3089. hw_peer_id =
  3090. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3091. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3092. peer_mac_addr =
  3093. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3094. &mac_addr_deswizzle_buf[0]);
  3095. is_wds =
  3096. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3097. ast_hash =
  3098. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3099. /*
  3100. * Update 4 ast_index per peer, ast valid mask
  3101. * and TID flow valid mask.
  3102. * AST valid mask is 3 bit field corresponds to
  3103. * ast_index[3:1]. ast_index 0 is always valid.
  3104. */
  3105. ast_flow_info.ast_valid_mask =
  3106. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  3107. ast_flow_info.ast_idx[0] = hw_peer_id;
  3108. ast_flow_info.ast_flow_mask[0] =
  3109. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  3110. ast_flow_info.ast_idx[1] =
  3111. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  3112. ast_flow_info.ast_flow_mask[1] =
  3113. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  3114. ast_flow_info.ast_idx[2] =
  3115. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  3116. ast_flow_info.ast_flow_mask[2] =
  3117. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  3118. ast_flow_info.ast_idx[3] =
  3119. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  3120. ast_flow_info.ast_flow_mask[3] =
  3121. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  3122. /*
  3123. * TID valid mask is applicable only
  3124. * for HI and LOW priority flows.
  3125. * tid_valid_mas is 8 bit field corresponds
  3126. * to TID[7:0]
  3127. */
  3128. ast_flow_info.tid_valid_low_pri_mask =
  3129. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  3130. ast_flow_info.tid_valid_hi_pri_mask =
  3131. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  3132. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3133. QDF_TRACE_LEVEL_DEBUG,
  3134. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3135. peer_id, vdev_id);
  3136. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3137. QDF_TRACE_LEVEL_INFO,
  3138. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  3139. ast_flow_info.ast_idx[0],
  3140. ast_flow_info.ast_idx[1],
  3141. ast_flow_info.ast_idx[2],
  3142. ast_flow_info.ast_idx[3]);
  3143. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3144. hw_peer_id, vdev_id,
  3145. peer_mac_addr, ast_hash,
  3146. is_wds);
  3147. /*
  3148. * Update ast indexes for flow override support
  3149. * Applicable only for non wds peers
  3150. */
  3151. if (!soc->dp_soc->ast_offload_support)
  3152. dp_peer_ast_index_flow_queue_map_create(
  3153. soc->dp_soc, is_wds,
  3154. peer_id, peer_mac_addr,
  3155. &ast_flow_info);
  3156. break;
  3157. }
  3158. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3159. {
  3160. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3161. u_int8_t *mac_addr;
  3162. u_int16_t peer_id;
  3163. u_int8_t vdev_id;
  3164. u_int8_t is_wds;
  3165. u_int32_t free_wds_count;
  3166. peer_id =
  3167. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3168. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3169. mac_addr =
  3170. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3171. &mac_addr_deswizzle_buf[0]);
  3172. is_wds =
  3173. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3174. free_wds_count =
  3175. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  3176. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3177. QDF_TRACE_LEVEL_INFO,
  3178. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3179. peer_id, vdev_id);
  3180. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3181. vdev_id, mac_addr,
  3182. is_wds, free_wds_count);
  3183. break;
  3184. }
  3185. case HTT_T2H_MSG_TYPE_RX_DELBA:
  3186. {
  3187. uint16_t peer_id;
  3188. uint8_t tid;
  3189. uint8_t win_sz;
  3190. QDF_STATUS status;
  3191. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  3192. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  3193. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  3194. status = dp_rx_delba_ind_handler(
  3195. soc->dp_soc,
  3196. peer_id, tid, win_sz);
  3197. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3198. QDF_TRACE_LEVEL_INFO,
  3199. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  3200. peer_id, win_sz, tid, status);
  3201. break;
  3202. }
  3203. case HTT_T2H_MSG_TYPE_RX_DELBA_EXTN:
  3204. {
  3205. uint16_t peer_id;
  3206. uint8_t tid;
  3207. uint16_t win_sz;
  3208. QDF_STATUS status;
  3209. peer_id = HTT_RX_DELBA_EXTN_PEER_ID_GET(*msg_word);
  3210. tid = HTT_RX_DELBA_EXTN_TID_GET(*msg_word);
  3211. msg_word++;
  3212. win_sz = HTT_RX_DELBA_EXTN_WIN_SIZE_GET(*msg_word);
  3213. status = dp_rx_delba_ind_handler(soc->dp_soc,
  3214. peer_id, tid,
  3215. win_sz);
  3216. dp_info("DELBA PeerID %d BAW %d TID %d stat %d",
  3217. peer_id, win_sz, tid, status);
  3218. break;
  3219. }
  3220. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  3221. {
  3222. uint16_t num_entries;
  3223. uint32_t cmem_ba_lo;
  3224. uint32_t cmem_ba_hi;
  3225. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  3226. cmem_ba_lo = *(msg_word + 1);
  3227. cmem_ba_hi = *(msg_word + 2);
  3228. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3229. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  3230. num_entries, cmem_ba_lo, cmem_ba_hi);
  3231. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  3232. cmem_ba_lo, cmem_ba_hi);
  3233. break;
  3234. }
  3235. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  3236. {
  3237. dp_offload_ind_handler(soc, msg_word);
  3238. break;
  3239. }
  3240. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  3241. {
  3242. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3243. u_int8_t *peer_mac_addr;
  3244. u_int16_t peer_id;
  3245. u_int16_t hw_peer_id;
  3246. u_int8_t vdev_id;
  3247. uint8_t is_wds;
  3248. u_int16_t ast_hash = 0;
  3249. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  3250. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  3251. peer_mac_addr =
  3252. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3253. &mac_addr_deswizzle_buf[0]);
  3254. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3255. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3256. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3257. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3258. peer_id, vdev_id);
  3259. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3260. hw_peer_id, vdev_id,
  3261. peer_mac_addr, ast_hash,
  3262. is_wds);
  3263. break;
  3264. }
  3265. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3266. {
  3267. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3268. break;
  3269. }
  3270. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3271. {
  3272. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3273. break;
  3274. }
  3275. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3276. {
  3277. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3278. break;
  3279. }
  3280. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3281. {
  3282. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3283. break;
  3284. }
  3285. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3286. {
  3287. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3288. htt_t2h_msg);
  3289. break;
  3290. }
  3291. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3292. {
  3293. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3294. break;
  3295. }
  3296. case HTT_T2H_MSG_TYPE_STREAMING_STATS_IND:
  3297. {
  3298. dp_sawf_mpdu_stats_handler(soc, htt_t2h_msg);
  3299. break;
  3300. }
  3301. default:
  3302. break;
  3303. };
  3304. /* Free the indication buffer */
  3305. if (free_buf)
  3306. qdf_nbuf_free(htt_t2h_msg);
  3307. }
  3308. /*
  3309. * dp_htt_h2t_full() - Send full handler (called from HTC)
  3310. * @context: Opaque context (HTT SOC handle)
  3311. * @pkt: HTC packet
  3312. *
  3313. * Return: enum htc_send_full_action
  3314. */
  3315. static enum htc_send_full_action
  3316. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3317. {
  3318. return HTC_SEND_FULL_KEEP;
  3319. }
  3320. /*
  3321. * dp_htt_hif_t2h_hp_callback() - HIF callback for high priority T2H messages
  3322. * @context: Opaque context (HTT SOC handle)
  3323. * @nbuf: nbuf containing T2H message
  3324. * @pipe_id: HIF pipe ID
  3325. *
  3326. * Return: QDF_STATUS
  3327. *
  3328. * TODO: Temporary change to bypass HTC connection for this new HIF pipe, which
  3329. * will be used for packet log and other high-priority HTT messages. Proper
  3330. * HTC connection to be added later once required FW changes are available
  3331. */
  3332. static QDF_STATUS
  3333. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3334. {
  3335. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3336. HTC_PACKET htc_pkt;
  3337. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3338. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3339. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3340. htc_pkt.pPktContext = (void *)nbuf;
  3341. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3342. return rc;
  3343. }
  3344. /*
  3345. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3346. * @htt_soc: HTT SOC handle
  3347. *
  3348. * Return: QDF_STATUS
  3349. */
  3350. static QDF_STATUS
  3351. htt_htc_soc_attach(struct htt_soc *soc)
  3352. {
  3353. struct htc_service_connect_req connect;
  3354. struct htc_service_connect_resp response;
  3355. QDF_STATUS status;
  3356. struct dp_soc *dpsoc = soc->dp_soc;
  3357. qdf_mem_zero(&connect, sizeof(connect));
  3358. qdf_mem_zero(&response, sizeof(response));
  3359. connect.pMetaData = NULL;
  3360. connect.MetaDataLength = 0;
  3361. connect.EpCallbacks.pContext = soc;
  3362. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3363. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3364. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3365. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3366. connect.EpCallbacks.EpRecvRefill = NULL;
  3367. /* N/A, fill is done by HIF */
  3368. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3369. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3370. /*
  3371. * Specify how deep to let a queue get before htc_send_pkt will
  3372. * call the EpSendFull function due to excessive send queue depth.
  3373. */
  3374. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3375. /* disable flow control for HTT data message service */
  3376. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3377. /* connect to control service */
  3378. connect.service_id = HTT_DATA_MSG_SVC;
  3379. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3380. if (status != QDF_STATUS_SUCCESS)
  3381. return status;
  3382. soc->htc_endpoint = response.Endpoint;
  3383. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3384. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3385. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3386. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3387. return QDF_STATUS_SUCCESS; /* success */
  3388. }
  3389. /*
  3390. * htt_soc_initialize() - SOC level HTT initialization
  3391. * @htt_soc: Opaque htt SOC handle
  3392. * @ctrl_psoc: Opaque ctrl SOC handle
  3393. * @htc_soc: SOC level HTC handle
  3394. * @hal_soc: Opaque HAL SOC handle
  3395. * @osdev: QDF device
  3396. *
  3397. * Return: HTT handle on success; NULL on failure
  3398. */
  3399. void *
  3400. htt_soc_initialize(struct htt_soc *htt_soc,
  3401. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3402. HTC_HANDLE htc_soc,
  3403. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3404. {
  3405. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3406. soc->osdev = osdev;
  3407. soc->ctrl_psoc = ctrl_psoc;
  3408. soc->htc_soc = htc_soc;
  3409. soc->hal_soc = hal_soc_hdl;
  3410. if (htt_htc_soc_attach(soc))
  3411. goto fail2;
  3412. return soc;
  3413. fail2:
  3414. return NULL;
  3415. }
  3416. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3417. {
  3418. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3419. htt_htc_misc_pkt_pool_free(htt_handle);
  3420. htt_htc_pkt_pool_free(htt_handle);
  3421. }
  3422. /*
  3423. * htt_soc_htc_prealloc() - HTC memory prealloc
  3424. * @htt_soc: SOC level HTT handle
  3425. *
  3426. * Return: QDF_STATUS_SUCCESS on Success or
  3427. * QDF_STATUS_E_NOMEM on allocation failure
  3428. */
  3429. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3430. {
  3431. int i;
  3432. soc->htt_htc_pkt_freelist = NULL;
  3433. /* pre-allocate some HTC_PACKET objects */
  3434. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3435. struct dp_htt_htc_pkt_union *pkt;
  3436. pkt = qdf_mem_malloc(sizeof(*pkt));
  3437. if (!pkt)
  3438. return QDF_STATUS_E_NOMEM;
  3439. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3440. }
  3441. return QDF_STATUS_SUCCESS;
  3442. }
  3443. /*
  3444. * htt_soc_detach() - Free SOC level HTT handle
  3445. * @htt_hdl: HTT SOC handle
  3446. */
  3447. void htt_soc_detach(struct htt_soc *htt_hdl)
  3448. {
  3449. int i;
  3450. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3451. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3452. qdf_mem_free(htt_handle->pdevid_tt[i].umac_path);
  3453. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_path);
  3454. }
  3455. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3456. qdf_mem_free(htt_handle);
  3457. }
  3458. /**
  3459. * dp_h2t_ext_stats_msg_send(): function to construct HTT message to pass to FW
  3460. * @pdev: DP PDEV handle
  3461. * @stats_type_upload_mask: stats type requested by user
  3462. * @config_param_0: extra configuration parameters
  3463. * @config_param_1: extra configuration parameters
  3464. * @config_param_2: extra configuration parameters
  3465. * @config_param_3: extra configuration parameters
  3466. * @mac_id: mac number
  3467. *
  3468. * return: QDF STATUS
  3469. */
  3470. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3471. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3472. uint32_t config_param_1, uint32_t config_param_2,
  3473. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3474. uint8_t mac_id)
  3475. {
  3476. struct htt_soc *soc = pdev->soc->htt_handle;
  3477. struct dp_htt_htc_pkt *pkt;
  3478. qdf_nbuf_t msg;
  3479. uint32_t *msg_word;
  3480. uint8_t pdev_mask = 0;
  3481. uint8_t *htt_logger_bufp;
  3482. int mac_for_pdev;
  3483. int target_pdev_id;
  3484. QDF_STATUS status;
  3485. msg = qdf_nbuf_alloc(
  3486. soc->osdev,
  3487. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3488. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3489. if (!msg)
  3490. return QDF_STATUS_E_NOMEM;
  3491. /*TODO:Add support for SOC stats
  3492. * Bit 0: SOC Stats
  3493. * Bit 1: Pdev stats for pdev id 0
  3494. * Bit 2: Pdev stats for pdev id 1
  3495. * Bit 3: Pdev stats for pdev id 2
  3496. */
  3497. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3498. target_pdev_id =
  3499. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3500. pdev_mask = 1 << target_pdev_id;
  3501. /*
  3502. * Set the length of the message.
  3503. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3504. * separately during the below call to qdf_nbuf_push_head.
  3505. * The contribution from the HTC header is added separately inside HTC.
  3506. */
  3507. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3508. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3509. "Failed to expand head for HTT_EXT_STATS");
  3510. qdf_nbuf_free(msg);
  3511. return QDF_STATUS_E_FAILURE;
  3512. }
  3513. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3514. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3515. htt_logger_bufp = (uint8_t *)msg_word;
  3516. *msg_word = 0;
  3517. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3518. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3519. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3520. /* word 1 */
  3521. msg_word++;
  3522. *msg_word = 0;
  3523. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3524. /* word 2 */
  3525. msg_word++;
  3526. *msg_word = 0;
  3527. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3528. /* word 3 */
  3529. msg_word++;
  3530. *msg_word = 0;
  3531. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3532. /* word 4 */
  3533. msg_word++;
  3534. *msg_word = 0;
  3535. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3536. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3537. /* word 5 */
  3538. msg_word++;
  3539. /* word 6 */
  3540. msg_word++;
  3541. *msg_word = 0;
  3542. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3543. /* word 7 */
  3544. msg_word++;
  3545. *msg_word = 0;
  3546. /* Currently Using last 2 bits for pdev_id
  3547. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3548. */
  3549. cookie_msb = (cookie_msb | pdev->pdev_id);
  3550. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3551. pkt = htt_htc_pkt_alloc(soc);
  3552. if (!pkt) {
  3553. qdf_nbuf_free(msg);
  3554. return QDF_STATUS_E_NOMEM;
  3555. }
  3556. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3557. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3558. dp_htt_h2t_send_complete_free_netbuf,
  3559. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3560. soc->htc_endpoint,
  3561. /* tag for FW response msg not guaranteed */
  3562. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3563. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3564. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3565. htt_logger_bufp);
  3566. if (status != QDF_STATUS_SUCCESS) {
  3567. qdf_nbuf_free(msg);
  3568. htt_htc_pkt_free(soc, pkt);
  3569. }
  3570. return status;
  3571. }
  3572. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3573. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3574. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3575. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3576. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3577. uint8_t pdev_id, bool enable,
  3578. bool reset, uint64_t reset_bitmask)
  3579. {
  3580. struct htt_soc *soc = dpsoc->htt_handle;
  3581. struct dp_htt_htc_pkt *pkt;
  3582. qdf_nbuf_t msg;
  3583. uint32_t *msg_word;
  3584. uint8_t *htt_logger_bufp;
  3585. QDF_STATUS status;
  3586. int duration;
  3587. uint32_t bitmask;
  3588. int target_pdev_id;
  3589. msg = qdf_nbuf_alloc(
  3590. soc->osdev,
  3591. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3592. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3593. if (!msg) {
  3594. dp_htt_err("%pK: Fail to allocate "
  3595. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3596. return QDF_STATUS_E_NOMEM;
  3597. }
  3598. if (pdev_id != INVALID_PDEV_ID)
  3599. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3600. else
  3601. target_pdev_id = 0;
  3602. duration =
  3603. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3604. /*
  3605. * Set the length of the message.
  3606. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3607. * separately during the below call to qdf_nbuf_push_head.
  3608. * The contribution from the HTC header is added separately inside HTC.
  3609. */
  3610. if (!qdf_nbuf_put_tail(msg,
  3611. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  3612. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  3613. , dpsoc);
  3614. qdf_nbuf_free(msg);
  3615. return QDF_STATUS_E_FAILURE;
  3616. }
  3617. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3618. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3619. htt_logger_bufp = (uint8_t *)msg_word;
  3620. *msg_word = 0;
  3621. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  3622. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  3623. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  3624. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  3625. (duration >> 3));
  3626. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  3627. msg_word++;
  3628. *msg_word = 0;
  3629. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  3630. *msg_word = bitmask;
  3631. msg_word++;
  3632. *msg_word = 0;
  3633. bitmask =
  3634. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  3635. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  3636. *msg_word = bitmask;
  3637. pkt = htt_htc_pkt_alloc(soc);
  3638. if (!pkt) {
  3639. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  3640. dpsoc);
  3641. qdf_assert(0);
  3642. qdf_nbuf_free(msg);
  3643. return QDF_STATUS_E_NOMEM;
  3644. }
  3645. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3646. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3647. dp_htt_h2t_send_complete_free_netbuf,
  3648. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3649. soc->htc_endpoint,
  3650. /* tag for no FW response msg */
  3651. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3652. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3653. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3654. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  3655. htt_logger_bufp);
  3656. if (status != QDF_STATUS_SUCCESS) {
  3657. qdf_nbuf_free(msg);
  3658. htt_htc_pkt_free(soc, pkt);
  3659. }
  3660. return status;
  3661. }
  3662. #else
  3663. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3664. uint8_t pdev_id, bool enable,
  3665. bool reset, uint64_t reset_bitmask)
  3666. {
  3667. return QDF_STATUS_SUCCESS;
  3668. }
  3669. #endif
  3670. /**
  3671. * dp_h2t_3tuple_config_send(): function to construct 3 tuple configuration
  3672. * HTT message to pass to FW
  3673. * @pdev: DP PDEV handle
  3674. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  3675. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  3676. *
  3677. * tuple_mask[1:0]:
  3678. * 00 - Do not report 3 tuple hash value
  3679. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  3680. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  3681. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  3682. *
  3683. * return: QDF STATUS
  3684. */
  3685. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  3686. uint32_t tuple_mask, uint8_t mac_id)
  3687. {
  3688. struct htt_soc *soc = pdev->soc->htt_handle;
  3689. struct dp_htt_htc_pkt *pkt;
  3690. qdf_nbuf_t msg;
  3691. uint32_t *msg_word;
  3692. uint8_t *htt_logger_bufp;
  3693. int mac_for_pdev;
  3694. int target_pdev_id;
  3695. msg = qdf_nbuf_alloc(
  3696. soc->osdev,
  3697. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  3698. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3699. if (!msg)
  3700. return QDF_STATUS_E_NOMEM;
  3701. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3702. target_pdev_id =
  3703. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3704. /*
  3705. * Set the length of the message.
  3706. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3707. * separately during the below call to qdf_nbuf_push_head.
  3708. * The contribution from the HTC header is added separately inside HTC.
  3709. */
  3710. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  3711. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3712. "Failed to expand head for HTT_3TUPLE_CONFIG");
  3713. qdf_nbuf_free(msg);
  3714. return QDF_STATUS_E_FAILURE;
  3715. }
  3716. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  3717. pdev->soc, tuple_mask, target_pdev_id);
  3718. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3719. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3720. htt_logger_bufp = (uint8_t *)msg_word;
  3721. *msg_word = 0;
  3722. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  3723. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  3724. msg_word++;
  3725. *msg_word = 0;
  3726. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3727. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3728. pkt = htt_htc_pkt_alloc(soc);
  3729. if (!pkt) {
  3730. qdf_nbuf_free(msg);
  3731. return QDF_STATUS_E_NOMEM;
  3732. }
  3733. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3734. SET_HTC_PACKET_INFO_TX(
  3735. &pkt->htc_pkt,
  3736. dp_htt_h2t_send_complete_free_netbuf,
  3737. qdf_nbuf_data(msg),
  3738. qdf_nbuf_len(msg),
  3739. soc->htc_endpoint,
  3740. /* tag for no FW response msg */
  3741. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3742. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3743. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  3744. htt_logger_bufp);
  3745. return QDF_STATUS_SUCCESS;
  3746. }
  3747. /* This macro will revert once proper HTT header will define for
  3748. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  3749. * */
  3750. #if defined(WDI_EVENT_ENABLE)
  3751. /**
  3752. * dp_h2t_cfg_stats_msg_send(): function to construct HTT message to pass to FW
  3753. * @pdev: DP PDEV handle
  3754. * @stats_type_upload_mask: stats type requested by user
  3755. * @mac_id: Mac id number
  3756. *
  3757. * return: QDF STATUS
  3758. */
  3759. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  3760. uint32_t stats_type_upload_mask, uint8_t mac_id)
  3761. {
  3762. struct htt_soc *soc = pdev->soc->htt_handle;
  3763. struct dp_htt_htc_pkt *pkt;
  3764. qdf_nbuf_t msg;
  3765. uint32_t *msg_word;
  3766. uint8_t pdev_mask;
  3767. QDF_STATUS status;
  3768. msg = qdf_nbuf_alloc(
  3769. soc->osdev,
  3770. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  3771. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3772. if (!msg) {
  3773. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  3774. , pdev->soc);
  3775. qdf_assert(0);
  3776. return QDF_STATUS_E_NOMEM;
  3777. }
  3778. /*TODO:Add support for SOC stats
  3779. * Bit 0: SOC Stats
  3780. * Bit 1: Pdev stats for pdev id 0
  3781. * Bit 2: Pdev stats for pdev id 1
  3782. * Bit 3: Pdev stats for pdev id 2
  3783. */
  3784. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  3785. mac_id);
  3786. /*
  3787. * Set the length of the message.
  3788. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3789. * separately during the below call to qdf_nbuf_push_head.
  3790. * The contribution from the HTC header is added separately inside HTC.
  3791. */
  3792. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  3793. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  3794. , pdev->soc);
  3795. qdf_nbuf_free(msg);
  3796. return QDF_STATUS_E_FAILURE;
  3797. }
  3798. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3799. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3800. *msg_word = 0;
  3801. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  3802. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  3803. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  3804. stats_type_upload_mask);
  3805. pkt = htt_htc_pkt_alloc(soc);
  3806. if (!pkt) {
  3807. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  3808. qdf_assert(0);
  3809. qdf_nbuf_free(msg);
  3810. return QDF_STATUS_E_NOMEM;
  3811. }
  3812. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3813. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3814. dp_htt_h2t_send_complete_free_netbuf,
  3815. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3816. soc->htc_endpoint,
  3817. /* tag for no FW response msg */
  3818. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3819. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3820. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  3821. (uint8_t *)msg_word);
  3822. if (status != QDF_STATUS_SUCCESS) {
  3823. qdf_nbuf_free(msg);
  3824. htt_htc_pkt_free(soc, pkt);
  3825. }
  3826. return status;
  3827. }
  3828. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  3829. #endif
  3830. void
  3831. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  3832. uint32_t *tag_buf)
  3833. {
  3834. struct dp_peer *peer = NULL;
  3835. switch (tag_type) {
  3836. case HTT_STATS_PEER_DETAILS_TAG:
  3837. {
  3838. htt_peer_details_tlv *dp_stats_buf =
  3839. (htt_peer_details_tlv *)tag_buf;
  3840. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  3841. }
  3842. break;
  3843. case HTT_STATS_PEER_STATS_CMN_TAG:
  3844. {
  3845. htt_peer_stats_cmn_tlv *dp_stats_buf =
  3846. (htt_peer_stats_cmn_tlv *)tag_buf;
  3847. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  3848. DP_MOD_ID_HTT);
  3849. if (peer && !peer->bss_peer) {
  3850. peer->stats.tx.inactive_time =
  3851. dp_stats_buf->inactive_time;
  3852. qdf_event_set(&pdev->fw_peer_stats_event);
  3853. }
  3854. if (peer)
  3855. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3856. }
  3857. break;
  3858. default:
  3859. qdf_err("Invalid tag_type");
  3860. }
  3861. }
  3862. /**
  3863. * dp_htt_rx_flow_fst_setup(): Send HTT Rx FST setup message to FW
  3864. * @pdev: DP pdev handle
  3865. * @fse_setup_info: FST setup parameters
  3866. *
  3867. * Return: Success when HTT message is sent, error on failure
  3868. */
  3869. QDF_STATUS
  3870. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  3871. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  3872. {
  3873. struct htt_soc *soc = pdev->soc->htt_handle;
  3874. struct dp_htt_htc_pkt *pkt;
  3875. qdf_nbuf_t msg;
  3876. u_int32_t *msg_word;
  3877. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  3878. uint8_t *htt_logger_bufp;
  3879. u_int32_t *key;
  3880. QDF_STATUS status;
  3881. msg = qdf_nbuf_alloc(
  3882. soc->osdev,
  3883. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  3884. /* reserve room for the HTC header */
  3885. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3886. if (!msg)
  3887. return QDF_STATUS_E_NOMEM;
  3888. /*
  3889. * Set the length of the message.
  3890. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3891. * separately during the below call to qdf_nbuf_push_head.
  3892. * The contribution from the HTC header is added separately inside HTC.
  3893. */
  3894. if (!qdf_nbuf_put_tail(msg,
  3895. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  3896. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  3897. return QDF_STATUS_E_FAILURE;
  3898. }
  3899. /* fill in the message contents */
  3900. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  3901. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  3902. /* rewind beyond alignment pad to get to the HTC header reserved area */
  3903. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3904. htt_logger_bufp = (uint8_t *)msg_word;
  3905. *msg_word = 0;
  3906. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  3907. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  3908. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  3909. msg_word++;
  3910. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  3911. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  3912. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  3913. fse_setup_info->ip_da_sa_prefix);
  3914. msg_word++;
  3915. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  3916. fse_setup_info->base_addr_lo);
  3917. msg_word++;
  3918. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  3919. fse_setup_info->base_addr_hi);
  3920. key = (u_int32_t *)fse_setup_info->hash_key;
  3921. fse_setup->toeplitz31_0 = *key++;
  3922. fse_setup->toeplitz63_32 = *key++;
  3923. fse_setup->toeplitz95_64 = *key++;
  3924. fse_setup->toeplitz127_96 = *key++;
  3925. fse_setup->toeplitz159_128 = *key++;
  3926. fse_setup->toeplitz191_160 = *key++;
  3927. fse_setup->toeplitz223_192 = *key++;
  3928. fse_setup->toeplitz255_224 = *key++;
  3929. fse_setup->toeplitz287_256 = *key++;
  3930. fse_setup->toeplitz314_288 = *key;
  3931. msg_word++;
  3932. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  3933. msg_word++;
  3934. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  3935. msg_word++;
  3936. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  3937. msg_word++;
  3938. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  3939. msg_word++;
  3940. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  3941. msg_word++;
  3942. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  3943. msg_word++;
  3944. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  3945. msg_word++;
  3946. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  3947. msg_word++;
  3948. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  3949. msg_word++;
  3950. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  3951. fse_setup->toeplitz314_288);
  3952. pkt = htt_htc_pkt_alloc(soc);
  3953. if (!pkt) {
  3954. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  3955. qdf_assert(0);
  3956. qdf_nbuf_free(msg);
  3957. return QDF_STATUS_E_RESOURCES; /* failure */
  3958. }
  3959. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3960. SET_HTC_PACKET_INFO_TX(
  3961. &pkt->htc_pkt,
  3962. dp_htt_h2t_send_complete_free_netbuf,
  3963. qdf_nbuf_data(msg),
  3964. qdf_nbuf_len(msg),
  3965. soc->htc_endpoint,
  3966. /* tag for no FW response msg */
  3967. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3968. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3969. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3970. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  3971. htt_logger_bufp);
  3972. if (status == QDF_STATUS_SUCCESS) {
  3973. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  3974. fse_setup_info->pdev_id);
  3975. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  3976. (void *)fse_setup_info->hash_key,
  3977. fse_setup_info->hash_key_len);
  3978. } else {
  3979. qdf_nbuf_free(msg);
  3980. htt_htc_pkt_free(soc, pkt);
  3981. }
  3982. return status;
  3983. }
  3984. /**
  3985. * dp_htt_rx_flow_fse_operation(): Send HTT Flow Search Entry msg to
  3986. * add/del a flow in HW
  3987. * @pdev: DP pdev handle
  3988. * @fse_op_info: Flow entry parameters
  3989. *
  3990. * Return: Success when HTT message is sent, error on failure
  3991. */
  3992. QDF_STATUS
  3993. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  3994. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  3995. {
  3996. struct htt_soc *soc = pdev->soc->htt_handle;
  3997. struct dp_htt_htc_pkt *pkt;
  3998. qdf_nbuf_t msg;
  3999. u_int32_t *msg_word;
  4000. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4001. uint8_t *htt_logger_bufp;
  4002. QDF_STATUS status;
  4003. msg = qdf_nbuf_alloc(
  4004. soc->osdev,
  4005. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4006. /* reserve room for the HTC header */
  4007. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4008. if (!msg)
  4009. return QDF_STATUS_E_NOMEM;
  4010. /*
  4011. * Set the length of the message.
  4012. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4013. * separately during the below call to qdf_nbuf_push_head.
  4014. * The contribution from the HTC header is added separately inside HTC.
  4015. */
  4016. if (!qdf_nbuf_put_tail(msg,
  4017. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4018. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4019. qdf_nbuf_free(msg);
  4020. return QDF_STATUS_E_FAILURE;
  4021. }
  4022. /* fill in the message contents */
  4023. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4024. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4025. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4026. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4027. htt_logger_bufp = (uint8_t *)msg_word;
  4028. *msg_word = 0;
  4029. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4030. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4031. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4032. msg_word++;
  4033. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4034. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4035. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4036. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4037. msg_word++;
  4038. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4039. *msg_word,
  4040. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4041. msg_word++;
  4042. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4043. *msg_word,
  4044. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4045. msg_word++;
  4046. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4047. *msg_word,
  4048. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4049. msg_word++;
  4050. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4051. *msg_word,
  4052. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4053. msg_word++;
  4054. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4055. *msg_word,
  4056. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4057. msg_word++;
  4058. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4059. *msg_word,
  4060. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4061. msg_word++;
  4062. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4063. *msg_word,
  4064. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4065. msg_word++;
  4066. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4067. *msg_word,
  4068. qdf_htonl(
  4069. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4070. msg_word++;
  4071. HTT_RX_FSE_SOURCEPORT_SET(
  4072. *msg_word,
  4073. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4074. HTT_RX_FSE_DESTPORT_SET(
  4075. *msg_word,
  4076. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4077. msg_word++;
  4078. HTT_RX_FSE_L4_PROTO_SET(
  4079. *msg_word,
  4080. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4081. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4082. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4083. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4084. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4085. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4086. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4087. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4088. }
  4089. pkt = htt_htc_pkt_alloc(soc);
  4090. if (!pkt) {
  4091. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4092. qdf_assert(0);
  4093. qdf_nbuf_free(msg);
  4094. return QDF_STATUS_E_RESOURCES; /* failure */
  4095. }
  4096. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4097. SET_HTC_PACKET_INFO_TX(
  4098. &pkt->htc_pkt,
  4099. dp_htt_h2t_send_complete_free_netbuf,
  4100. qdf_nbuf_data(msg),
  4101. qdf_nbuf_len(msg),
  4102. soc->htc_endpoint,
  4103. /* tag for no FW response msg */
  4104. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4105. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4106. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4107. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4108. htt_logger_bufp);
  4109. if (status == QDF_STATUS_SUCCESS) {
  4110. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4111. fse_op_info->pdev_id);
  4112. } else {
  4113. qdf_nbuf_free(msg);
  4114. htt_htc_pkt_free(soc, pkt);
  4115. }
  4116. return status;
  4117. }
  4118. /**
  4119. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4120. * @pdev: DP pdev handle
  4121. * @fse_op_info: Flow entry parameters
  4122. *
  4123. * Return: Success when HTT message is sent, error on failure
  4124. */
  4125. QDF_STATUS
  4126. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4127. struct dp_htt_rx_fisa_cfg *fisa_config)
  4128. {
  4129. struct htt_soc *soc = pdev->soc->htt_handle;
  4130. struct dp_htt_htc_pkt *pkt;
  4131. qdf_nbuf_t msg;
  4132. u_int32_t *msg_word;
  4133. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4134. uint8_t *htt_logger_bufp;
  4135. uint32_t len;
  4136. QDF_STATUS status;
  4137. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4138. msg = qdf_nbuf_alloc(soc->osdev,
  4139. len,
  4140. /* reserve room for the HTC header */
  4141. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4142. 4,
  4143. TRUE);
  4144. if (!msg)
  4145. return QDF_STATUS_E_NOMEM;
  4146. /*
  4147. * Set the length of the message.
  4148. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4149. * separately during the below call to qdf_nbuf_push_head.
  4150. * The contribution from the HTC header is added separately inside HTC.
  4151. */
  4152. if (!qdf_nbuf_put_tail(msg,
  4153. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4154. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4155. qdf_nbuf_free(msg);
  4156. return QDF_STATUS_E_FAILURE;
  4157. }
  4158. /* fill in the message contents */
  4159. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4160. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4161. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4162. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4163. htt_logger_bufp = (uint8_t *)msg_word;
  4164. *msg_word = 0;
  4165. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4166. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4167. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4168. msg_word++;
  4169. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4170. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  4171. msg_word++;
  4172. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4173. pkt = htt_htc_pkt_alloc(soc);
  4174. if (!pkt) {
  4175. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4176. qdf_assert(0);
  4177. qdf_nbuf_free(msg);
  4178. return QDF_STATUS_E_RESOURCES; /* failure */
  4179. }
  4180. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4181. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4182. dp_htt_h2t_send_complete_free_netbuf,
  4183. qdf_nbuf_data(msg),
  4184. qdf_nbuf_len(msg),
  4185. soc->htc_endpoint,
  4186. /* tag for no FW response msg */
  4187. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4188. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4189. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4190. htt_logger_bufp);
  4191. if (status == QDF_STATUS_SUCCESS) {
  4192. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4193. fisa_config->pdev_id);
  4194. } else {
  4195. qdf_nbuf_free(msg);
  4196. htt_htc_pkt_free(soc, pkt);
  4197. }
  4198. return status;
  4199. }
  4200. #ifdef WLAN_SUPPORT_PPEDS
  4201. /**
  4202. * dp_htt_rxdma_rxole_ppe_cfg_set() - Send RxOLE and RxDMA PPE config
  4203. * @dp_osc: Data path SoC handle
  4204. * @cfg: RxDMA and RxOLE PPE config
  4205. *
  4206. * Return: Success when HTT message is sent, error on failure
  4207. */
  4208. QDF_STATUS
  4209. dp_htt_rxdma_rxole_ppe_cfg_set(struct dp_soc *soc,
  4210. struct dp_htt_rxdma_rxole_ppe_config *cfg)
  4211. {
  4212. struct htt_soc *htt_handle = soc->htt_handle;
  4213. uint32_t len;
  4214. qdf_nbuf_t msg;
  4215. u_int32_t *msg_word;
  4216. QDF_STATUS status;
  4217. uint8_t *htt_logger_bufp;
  4218. struct dp_htt_htc_pkt *pkt;
  4219. len = HTT_MSG_BUF_SIZE(
  4220. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4221. msg = qdf_nbuf_alloc(soc->osdev,
  4222. len,
  4223. /* reserve room for the HTC header */
  4224. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4225. 4,
  4226. TRUE);
  4227. if (!msg)
  4228. return QDF_STATUS_E_NOMEM;
  4229. /*
  4230. * Set the length of the message.
  4231. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4232. * separately during the below call to qdf_nbuf_push_head.
  4233. * The contribution from the HTC header is added separately inside HTC.
  4234. */
  4235. if (!qdf_nbuf_put_tail(
  4236. msg, sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t))) {
  4237. qdf_err("Failed to expand head for HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG msg");
  4238. qdf_nbuf_free(msg);
  4239. return QDF_STATUS_E_FAILURE;
  4240. }
  4241. /* fill in the message contents */
  4242. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4243. memset(msg_word, 0,
  4244. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4245. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4246. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4247. htt_logger_bufp = (uint8_t *)msg_word;
  4248. *msg_word = 0;
  4249. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG);
  4250. HTT_PPE_CFG_OVERRIDE_SET(*msg_word, cfg->override);
  4251. HTT_PPE_CFG_REO_DEST_IND_SET(
  4252. *msg_word, cfg->reo_destination_indication);
  4253. HTT_PPE_CFG_MULTI_BUF_MSDU_OVERRIDE_EN_SET(
  4254. *msg_word, cfg->multi_buffer_msdu_override_en);
  4255. HTT_PPE_CFG_INTRA_BSS_OVERRIDE_EN_SET(
  4256. *msg_word, cfg->intra_bss_override);
  4257. HTT_PPE_CFG_DECAP_RAW_OVERRIDE_EN_SET(
  4258. *msg_word, cfg->decap_raw_override);
  4259. HTT_PPE_CFG_DECAP_NWIFI_OVERRIDE_EN_SET(
  4260. *msg_word, cfg->decap_nwifi_override);
  4261. HTT_PPE_CFG_IP_FRAG_OVERRIDE_EN_SET(
  4262. *msg_word, cfg->ip_frag_override);
  4263. pkt = htt_htc_pkt_alloc(htt_handle);
  4264. if (!pkt) {
  4265. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4266. qdf_assert(0);
  4267. qdf_nbuf_free(msg);
  4268. return QDF_STATUS_E_RESOURCES; /* failure */
  4269. }
  4270. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4271. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4272. dp_htt_h2t_send_complete_free_netbuf,
  4273. qdf_nbuf_data(msg),
  4274. qdf_nbuf_len(msg),
  4275. htt_handle->htc_endpoint,
  4276. /* tag for no FW response msg */
  4277. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4278. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4279. status = DP_HTT_SEND_HTC_PKT(htt_handle, pkt,
  4280. HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG,
  4281. htt_logger_bufp);
  4282. if (status != QDF_STATUS_SUCCESS) {
  4283. qdf_nbuf_free(msg);
  4284. htt_htc_pkt_free(htt_handle, pkt);
  4285. return status;
  4286. }
  4287. dp_info("HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG sent");
  4288. return status;
  4289. }
  4290. #endif /* WLAN_SUPPORT_PPEDS */
  4291. /**
  4292. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  4293. * stats
  4294. *
  4295. * @context : argument to work function
  4296. */
  4297. static void dp_bk_pressure_stats_handler(void *context)
  4298. {
  4299. struct dp_pdev *pdev = (struct dp_pdev *)context;
  4300. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  4301. const char *ring_name;
  4302. int i;
  4303. struct dp_srng_ring_state *ring_state;
  4304. bool empty_flag;
  4305. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4306. /* Extract only first entry for printing in one work event */
  4307. if (pdev->bkp_stats.queue_depth &&
  4308. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  4309. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  4310. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  4311. list_elem);
  4312. pdev->bkp_stats.queue_depth--;
  4313. }
  4314. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  4315. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4316. if (soc_srngs_state) {
  4317. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  4318. soc_srngs_state->seq_num);
  4319. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  4320. ring_state = &soc_srngs_state->ring_state[i];
  4321. ring_name = dp_srng_get_str_from_hal_ring_type
  4322. (ring_state->ring_type);
  4323. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  4324. ring_name,
  4325. ring_state->sw_head,
  4326. ring_state->sw_tail);
  4327. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  4328. ring_name,
  4329. ring_state->hw_head,
  4330. ring_state->hw_tail);
  4331. }
  4332. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  4333. soc_srngs_state->seq_num);
  4334. qdf_mem_free(soc_srngs_state);
  4335. }
  4336. dp_print_napi_stats(pdev->soc);
  4337. /* Schedule work again if queue is not empty */
  4338. if (!empty_flag)
  4339. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  4340. &pdev->bkp_stats.work);
  4341. }
  4342. /*
  4343. * dp_pdev_bkp_stats_detach() - detach resources for back pressure stats
  4344. * processing
  4345. * @pdev: Datapath PDEV handle
  4346. *
  4347. */
  4348. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4349. {
  4350. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4351. if (!pdev->bkp_stats.work_queue)
  4352. return;
  4353. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4354. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4355. qdf_flush_work(&pdev->bkp_stats.work);
  4356. qdf_disable_work(&pdev->bkp_stats.work);
  4357. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4358. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4359. list_elem, ring_state_next) {
  4360. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4361. list_elem);
  4362. qdf_mem_free(ring_state);
  4363. }
  4364. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4365. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4366. }
  4367. /*
  4368. * dp_pdev_bkp_stats_attach() - attach resources for back pressure stats
  4369. * processing
  4370. * @pdev: Datapath PDEV handle
  4371. *
  4372. * Return: QDF_STATUS_SUCCESS: Success
  4373. * QDF_STATUS_E_NOMEM: Error
  4374. */
  4375. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4376. {
  4377. TAILQ_INIT(&pdev->bkp_stats.list);
  4378. pdev->bkp_stats.seq_num = 0;
  4379. pdev->bkp_stats.queue_depth = 0;
  4380. qdf_create_work(0, &pdev->bkp_stats.work,
  4381. dp_bk_pressure_stats_handler, pdev);
  4382. pdev->bkp_stats.work_queue =
  4383. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4384. if (!pdev->bkp_stats.work_queue)
  4385. goto fail;
  4386. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4387. return QDF_STATUS_SUCCESS;
  4388. fail:
  4389. dp_htt_alert("BKP stats attach failed");
  4390. qdf_flush_work(&pdev->bkp_stats.work);
  4391. qdf_disable_work(&pdev->bkp_stats.work);
  4392. return QDF_STATUS_E_FAILURE;
  4393. }
  4394. #ifdef DP_UMAC_HW_RESET_SUPPORT
  4395. QDF_STATUS dp_htt_umac_reset_send_setup_cmd(
  4396. struct dp_soc *soc,
  4397. const struct dp_htt_umac_reset_setup_cmd_params *setup_params)
  4398. {
  4399. struct htt_soc *htt_handle = soc->htt_handle;
  4400. uint32_t len;
  4401. qdf_nbuf_t msg;
  4402. u_int32_t *msg_word;
  4403. QDF_STATUS status;
  4404. uint8_t *htt_logger_bufp;
  4405. struct dp_htt_htc_pkt *pkt;
  4406. len = HTT_MSG_BUF_SIZE(
  4407. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4408. msg = qdf_nbuf_alloc(soc->osdev,
  4409. len,
  4410. /* reserve room for the HTC header */
  4411. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4412. 4,
  4413. TRUE);
  4414. if (!msg)
  4415. return QDF_STATUS_E_NOMEM;
  4416. /*
  4417. * Set the length of the message.
  4418. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4419. * separately during the below call to qdf_nbuf_push_head.
  4420. * The contribution from the HTC header is added separately inside HTC.
  4421. */
  4422. if (!qdf_nbuf_put_tail(
  4423. msg, HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES)) {
  4424. dp_htt_err("Failed to expand head");
  4425. qdf_nbuf_free(msg);
  4426. return QDF_STATUS_E_FAILURE;
  4427. }
  4428. /* fill in the message contents */
  4429. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4430. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4431. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4432. htt_logger_bufp = (uint8_t *)msg_word;
  4433. qdf_mem_zero(msg_word,
  4434. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4435. HTT_H2T_MSG_TYPE_SET(
  4436. *msg_word,
  4437. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP);
  4438. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_T2H_MSG_METHOD_SET(
  4439. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4440. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_H2T_MSG_METHOD_SET(
  4441. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4442. msg_word++;
  4443. *msg_word = setup_params->msi_data;
  4444. msg_word++;
  4445. *msg_word = sizeof(htt_umac_hang_recovery_msg_shmem_t);
  4446. msg_word++;
  4447. *msg_word = setup_params->shmem_addr_low;
  4448. msg_word++;
  4449. *msg_word = setup_params->shmem_addr_high;
  4450. pkt = htt_htc_pkt_alloc(htt_handle);
  4451. if (!pkt) {
  4452. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4453. qdf_assert(0);
  4454. qdf_nbuf_free(msg);
  4455. return QDF_STATUS_E_NOMEM;
  4456. }
  4457. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4458. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4459. dp_htt_h2t_send_complete_free_netbuf,
  4460. qdf_nbuf_data(msg),
  4461. qdf_nbuf_len(msg),
  4462. htt_handle->htc_endpoint,
  4463. /* tag for no FW response msg */
  4464. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4465. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4466. status = DP_HTT_SEND_HTC_PKT(
  4467. htt_handle, pkt,
  4468. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP,
  4469. htt_logger_bufp);
  4470. if (QDF_IS_STATUS_ERROR(status)) {
  4471. qdf_nbuf_free(msg);
  4472. htt_htc_pkt_free(htt_handle, pkt);
  4473. return status;
  4474. }
  4475. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP sent");
  4476. return status;
  4477. }
  4478. #endif