dp_htt.c 147 KB

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