dp_htt.c 144 KB

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