dp_htt.c 153 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475
  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_SUPPORT_PRIMARY_LINK_MIGRATE
  2143. QDF_STATUS
  2144. dp_h2t_ptqm_migration_msg_send(struct dp_soc *dp_soc, uint16_t vdev_id,
  2145. uint8_t pdev_id,
  2146. uint8_t chip_id, uint16_t peer_id,
  2147. uint16_t ml_peer_id, uint16_t src_info,
  2148. QDF_STATUS status)
  2149. {
  2150. struct htt_soc *soc = dp_soc->htt_handle;
  2151. struct dp_htt_htc_pkt *pkt;
  2152. uint8_t *htt_logger_bufp;
  2153. qdf_nbuf_t msg;
  2154. uint32_t *msg_word;
  2155. QDF_STATUS ret = QDF_STATUS_SUCCESS;
  2156. msg = qdf_nbuf_alloc(
  2157. soc->osdev,
  2158. HTT_MSG_BUF_SIZE(HTT_H2T_REO_MIGRATION_RESP_MSG_SZ),
  2159. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  2160. if (!msg)
  2161. return QDF_STATUS_E_NOMEM;
  2162. /*
  2163. * Set the length of the message.
  2164. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  2165. * separately during the below call to qdf_nbuf_push_head.
  2166. * The contribution from the HTC header is added separately inside HTC.
  2167. */
  2168. if (qdf_nbuf_put_tail(msg, HTT_H2T_REO_MIGRATION_RESP_MSG_SZ)
  2169. == NULL) {
  2170. dp_htt_err("Failed to expand head for"
  2171. "HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP");
  2172. qdf_nbuf_free(msg);
  2173. return QDF_STATUS_E_FAILURE;
  2174. }
  2175. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  2176. memset(msg_word, 0, HTT_H2T_REO_MIGRATION_RESP_MSG_SZ);
  2177. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  2178. htt_logger_bufp = (uint8_t *)msg_word;
  2179. *msg_word = 0;
  2180. HTT_H2T_MSG_TYPE_SET(*msg_word,
  2181. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP);
  2182. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_SET(*msg_word, pdev_id);
  2183. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_SET(*msg_word, chip_id);
  2184. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_SET(*msg_word, vdev_id);
  2185. /* word 1 */
  2186. msg_word++;
  2187. *msg_word = 0;
  2188. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_SET(*msg_word,
  2189. peer_id);
  2190. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_SET(*msg_word,
  2191. ml_peer_id);
  2192. /* word 1 */
  2193. msg_word++;
  2194. *msg_word = 0;
  2195. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_SRCINFO_SET(*msg_word,
  2196. src_info);
  2197. HTT_H2T_PRIMARY_LINK_PEER_MIGRATE_STATUS_SET(*msg_word,
  2198. status);
  2199. pkt = htt_htc_pkt_alloc(soc);
  2200. if (!pkt) {
  2201. dp_htt_err("Fail to allocate dp_htt_htc_pkt buffer");
  2202. qdf_nbuf_free(msg);
  2203. return QDF_STATUS_E_NOMEM;
  2204. }
  2205. pkt->soc_ctxt = NULL;
  2206. /* macro to set packet parameters for TX */
  2207. SET_HTC_PACKET_INFO_TX(
  2208. &pkt->htc_pkt,
  2209. dp_htt_h2t_send_complete_free_netbuf,
  2210. qdf_nbuf_data(msg),
  2211. qdf_nbuf_len(msg),
  2212. soc->htc_endpoint,
  2213. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  2214. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  2215. ret = DP_HTT_SEND_HTC_PKT(
  2216. soc, pkt,
  2217. HTT_H2T_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_RESP,
  2218. htt_logger_bufp);
  2219. if (ret != QDF_STATUS_SUCCESS) {
  2220. qdf_nbuf_free(msg);
  2221. htt_htc_pkt_free(soc, pkt);
  2222. }
  2223. return ret;
  2224. }
  2225. #endif
  2226. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  2227. /**
  2228. * dp_vdev_txrx_hw_stats_handler - Handle vdev stats received from FW
  2229. * @soc: htt soc handle
  2230. * @msg_word: buffer containing stats
  2231. *
  2232. * Return: void
  2233. */
  2234. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2235. uint32_t *msg_word)
  2236. {
  2237. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  2238. uint8_t pdev_id;
  2239. uint8_t vdev_id;
  2240. uint8_t target_pdev_id;
  2241. uint16_t payload_size;
  2242. struct dp_pdev *pdev;
  2243. struct dp_vdev *vdev;
  2244. uint8_t *tlv_buf;
  2245. uint32_t *tlv_buf_temp;
  2246. uint32_t *tag_buf;
  2247. htt_tlv_tag_t tlv_type;
  2248. uint16_t tlv_length;
  2249. uint64_t pkt_count = 0;
  2250. uint64_t byte_count = 0;
  2251. uint64_t soc_drop_cnt = 0;
  2252. struct cdp_pkt_info tx_comp = { 0 };
  2253. struct cdp_pkt_info tx_failed = { 0 };
  2254. target_pdev_id =
  2255. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PDEV_ID_GET(*msg_word);
  2256. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(dpsoc,
  2257. target_pdev_id);
  2258. if (pdev_id >= MAX_PDEV_CNT)
  2259. return;
  2260. pdev = dpsoc->pdev_list[pdev_id];
  2261. if (!pdev) {
  2262. dp_err("PDEV is NULL for pdev_id:%d", pdev_id);
  2263. return;
  2264. }
  2265. payload_size =
  2266. HTT_T2H_VDEVS_TXRX_STATS_PERIODIC_IND_PAYLOAD_SIZE_GET(*msg_word);
  2267. qdf_trace_hex_dump(QDF_MODULE_ID_DP_HTT, QDF_TRACE_LEVEL_INFO,
  2268. (void *)msg_word, payload_size + 16);
  2269. /* Adjust msg_word to point to the first TLV in buffer */
  2270. msg_word = msg_word + 4;
  2271. /* Parse the received buffer till payload size reaches 0 */
  2272. while (payload_size > 0) {
  2273. tlv_buf = (uint8_t *)msg_word;
  2274. tlv_buf_temp = msg_word;
  2275. tlv_type = HTT_STATS_TLV_TAG_GET(*msg_word);
  2276. tlv_length = HTT_STATS_TLV_LENGTH_GET(*msg_word);
  2277. /* Add header size to tlv length*/
  2278. tlv_length += 4;
  2279. switch (tlv_type) {
  2280. case HTT_STATS_SOC_TXRX_STATS_COMMON_TAG:
  2281. {
  2282. tag_buf = tlv_buf_temp +
  2283. HTT_VDEV_STATS_GET_INDEX(SOC_DROP_CNT);
  2284. soc_drop_cnt = HTT_VDEV_GET_STATS_U64(tag_buf);
  2285. DP_STATS_UPD(dpsoc, tx.tqm_drop_no_peer, soc_drop_cnt);
  2286. break;
  2287. }
  2288. case HTT_STATS_VDEV_TXRX_STATS_HW_STATS_TAG:
  2289. {
  2290. tag_buf = tlv_buf_temp +
  2291. HTT_VDEV_STATS_GET_INDEX(VDEV_ID);
  2292. vdev_id = (uint8_t)(*tag_buf);
  2293. vdev = dp_vdev_get_ref_by_id(dpsoc, vdev_id,
  2294. DP_MOD_ID_HTT);
  2295. if (!vdev)
  2296. goto invalid_vdev;
  2297. /* Extract received packet count from buffer */
  2298. tag_buf = tlv_buf_temp +
  2299. HTT_VDEV_STATS_GET_INDEX(RX_PKT_CNT);
  2300. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2301. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.num, pkt_count);
  2302. /* Extract received packet byte count from buffer */
  2303. tag_buf = tlv_buf_temp +
  2304. HTT_VDEV_STATS_GET_INDEX(RX_BYTE_CNT);
  2305. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2306. DP_STATS_UPD(vdev, rx_i.reo_rcvd_pkt.bytes, byte_count);
  2307. /* Extract tx success packet count from buffer */
  2308. tag_buf = tlv_buf_temp +
  2309. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_PKT_CNT);
  2310. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2311. tx_comp.num = pkt_count;
  2312. /* Extract tx success packet byte count from buffer */
  2313. tag_buf = tlv_buf_temp +
  2314. HTT_VDEV_STATS_GET_INDEX(TX_SUCCESS_BYTE_CNT);
  2315. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2316. tx_comp.bytes = byte_count;
  2317. /* Extract tx retry packet count from buffer */
  2318. tag_buf = tlv_buf_temp +
  2319. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_PKT_CNT);
  2320. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2321. tx_comp.num += pkt_count;
  2322. tx_failed.num = pkt_count;
  2323. /* Extract tx retry packet byte count from buffer */
  2324. tag_buf = tlv_buf_temp +
  2325. HTT_VDEV_STATS_GET_INDEX(TX_RETRY_BYTE_CNT);
  2326. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2327. tx_comp.bytes += byte_count;
  2328. tx_failed.bytes = byte_count;
  2329. /* Extract tx drop packet count from buffer */
  2330. tag_buf = tlv_buf_temp +
  2331. HTT_VDEV_STATS_GET_INDEX(TX_DROP_PKT_CNT);
  2332. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2333. tx_comp.num += pkt_count;
  2334. tx_failed.num += pkt_count;
  2335. /* Extract tx drop packet byte count from buffer */
  2336. tag_buf = tlv_buf_temp +
  2337. HTT_VDEV_STATS_GET_INDEX(TX_DROP_BYTE_CNT);
  2338. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2339. tx_comp.bytes += byte_count;
  2340. tx_failed.bytes += byte_count;
  2341. /* Extract tx age-out packet count from buffer */
  2342. tag_buf = tlv_buf_temp +
  2343. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_PKT_CNT);
  2344. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2345. tx_comp.num += pkt_count;
  2346. tx_failed.num += pkt_count;
  2347. /* Extract tx age-out packet byte count from buffer */
  2348. tag_buf = tlv_buf_temp +
  2349. HTT_VDEV_STATS_GET_INDEX(TX_AGE_OUT_BYTE_CNT);
  2350. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2351. tx_comp.bytes += byte_count;
  2352. tx_failed.bytes += byte_count;
  2353. /* Extract tqm bypass packet count from buffer */
  2354. tag_buf = tlv_buf_temp +
  2355. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_PKT_CNT);
  2356. pkt_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2357. tx_comp.num += pkt_count;
  2358. /* Extract tx bypass packet byte count from buffer */
  2359. tag_buf = tlv_buf_temp +
  2360. HTT_VDEV_STATS_GET_INDEX(TX_TQM_BYPASS_BYTE_CNT);
  2361. byte_count = HTT_VDEV_GET_STATS_U64(tag_buf);
  2362. tx_comp.bytes += byte_count;
  2363. DP_STATS_UPD(vdev, tx.comp_pkt.num, tx_comp.num);
  2364. DP_STATS_UPD(vdev, tx.comp_pkt.bytes, tx_comp.bytes);
  2365. DP_STATS_UPD(vdev, tx.tx_failed, tx_failed.num);
  2366. dp_vdev_unref_delete(dpsoc, vdev, DP_MOD_ID_HTT);
  2367. break;
  2368. }
  2369. default:
  2370. qdf_assert(0);
  2371. }
  2372. invalid_vdev:
  2373. msg_word = (uint32_t *)((uint8_t *)tlv_buf + tlv_length);
  2374. payload_size -= tlv_length;
  2375. }
  2376. }
  2377. #else
  2378. static void dp_vdev_txrx_hw_stats_handler(struct htt_soc *soc,
  2379. uint32_t *msg_word)
  2380. {}
  2381. #endif
  2382. #ifdef CONFIG_SAWF_DEF_QUEUES
  2383. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2384. uint32_t *msg_word,
  2385. qdf_nbuf_t htt_t2h_msg)
  2386. {
  2387. dp_htt_sawf_def_queues_map_report_conf(soc, msg_word, htt_t2h_msg);
  2388. }
  2389. #else
  2390. static void dp_sawf_def_queues_update_map_report_conf(struct htt_soc *soc,
  2391. uint32_t *msg_word,
  2392. qdf_nbuf_t htt_t2h_msg)
  2393. {}
  2394. #endif
  2395. #ifdef CONFIG_SAWF
  2396. /**
  2397. * dp_sawf_msduq_map() - Msdu queue creation information received
  2398. * from target
  2399. * @soc: soc handle.
  2400. * @msg_word: Pointer to htt msg word.
  2401. * @htt_t2h_msg: HTT message nbuf
  2402. *
  2403. * Return: void
  2404. */
  2405. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2406. qdf_nbuf_t htt_t2h_msg)
  2407. {
  2408. dp_htt_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  2409. }
  2410. /**
  2411. * dp_sawf_mpdu_stats_handler() - HTT message handler for MPDU stats
  2412. * @soc: soc handle.
  2413. * @htt_t2h_msg: HTT message nbuf
  2414. *
  2415. * Return: void
  2416. */
  2417. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2418. qdf_nbuf_t htt_t2h_msg)
  2419. {
  2420. dp_sawf_htt_mpdu_stats_handler(soc, htt_t2h_msg);
  2421. }
  2422. #else
  2423. static void dp_sawf_msduq_map(struct htt_soc *soc, uint32_t *msg_word,
  2424. qdf_nbuf_t htt_t2h_msg)
  2425. {}
  2426. static void dp_sawf_mpdu_stats_handler(struct htt_soc *soc,
  2427. qdf_nbuf_t htt_t2h_msg)
  2428. {}
  2429. #endif
  2430. /**
  2431. * time_allow_print() - time allow print
  2432. * @htt_bp_handler: backpressure handler
  2433. * @ring_id: ring_id (index)
  2434. * @th_time: threshold time
  2435. *
  2436. * Return: 1 for successfully saving timestamp in array
  2437. * and 0 for timestamp falling within 2 seconds after last one
  2438. */
  2439. static bool time_allow_print(struct bp_handler *htt_bp_handler,
  2440. u_int8_t ring_id, u_int32_t th_time)
  2441. {
  2442. unsigned long tstamp;
  2443. struct bp_handler *path = &htt_bp_handler[ring_id];
  2444. tstamp = qdf_get_system_timestamp();
  2445. if (!path)
  2446. return 0; //unable to print backpressure messages
  2447. if (path->bp_start_tt == -1) {
  2448. path->bp_start_tt = tstamp;
  2449. path->bp_duration = 0;
  2450. path->bp_last_tt = tstamp;
  2451. path->bp_counter = 1;
  2452. return 1;
  2453. }
  2454. path->bp_duration = tstamp - path->bp_start_tt;
  2455. path->bp_last_tt = tstamp;
  2456. path->bp_counter++;
  2457. if (path->bp_duration >= th_time) {
  2458. path->bp_start_tt = -1;
  2459. return 1;
  2460. }
  2461. return 0;
  2462. }
  2463. static void dp_htt_alert_print(enum htt_t2h_msg_type msg_type,
  2464. struct dp_pdev *pdev, u_int8_t ring_id,
  2465. u_int16_t hp_idx, u_int16_t tp_idx,
  2466. u_int32_t bkp_time,
  2467. struct bp_handler *htt_bp_handler,
  2468. char *ring_stype)
  2469. {
  2470. dp_alert("seq_num %u msg_type: %d pdev_id: %d ring_type: %s ",
  2471. pdev->bkp_stats.seq_num, msg_type, pdev->pdev_id, ring_stype);
  2472. dp_alert("ring_id: %d hp_idx: %d tp_idx: %d bkpressure_time_ms: %d ",
  2473. ring_id, hp_idx, tp_idx, bkp_time);
  2474. dp_alert("last_bp_event: %ld, total_bp_duration: %ld, bp_counter: %ld",
  2475. htt_bp_handler[ring_id].bp_last_tt,
  2476. htt_bp_handler[ring_id].bp_duration,
  2477. htt_bp_handler[ring_id].bp_counter);
  2478. }
  2479. /**
  2480. * dp_get_srng_ring_state_from_hal(): Get hal level ring stats
  2481. * @soc: DP_SOC handle
  2482. * @pdev: DP pdev handle
  2483. * @srng: DP_SRNG handle
  2484. * @ring_type: srng src/dst ring
  2485. * @state: ring state
  2486. * @pdev: pdev
  2487. * @srng: DP_SRNG handle
  2488. * @ring_type: srng src/dst ring
  2489. * @state: ring_state
  2490. *
  2491. * Return: void
  2492. */
  2493. static QDF_STATUS
  2494. dp_get_srng_ring_state_from_hal(struct dp_soc *soc,
  2495. struct dp_pdev *pdev,
  2496. struct dp_srng *srng,
  2497. enum hal_ring_type ring_type,
  2498. struct dp_srng_ring_state *state)
  2499. {
  2500. struct hal_soc *hal_soc;
  2501. if (!soc || !srng || !srng->hal_srng || !state)
  2502. return QDF_STATUS_E_INVAL;
  2503. hal_soc = (struct hal_soc *)soc->hal_soc;
  2504. hal_get_sw_hptp(soc->hal_soc, srng->hal_srng, &state->sw_tail,
  2505. &state->sw_head);
  2506. hal_get_hw_hptp(soc->hal_soc, srng->hal_srng, &state->hw_head,
  2507. &state->hw_tail, ring_type);
  2508. state->ring_type = ring_type;
  2509. return QDF_STATUS_SUCCESS;
  2510. }
  2511. #ifdef QCA_MONITOR_PKT_SUPPORT
  2512. static void
  2513. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2514. int lmac_id, uint32_t *num_srng,
  2515. struct dp_soc_srngs_state *soc_srngs_state)
  2516. {
  2517. QDF_STATUS status;
  2518. if (pdev->soc->wlan_cfg_ctx->rxdma1_enable) {
  2519. status = dp_get_srng_ring_state_from_hal
  2520. (pdev->soc, pdev,
  2521. &pdev->soc->rxdma_mon_buf_ring[lmac_id],
  2522. RXDMA_MONITOR_BUF,
  2523. &soc_srngs_state->ring_state[*num_srng]);
  2524. if (status == QDF_STATUS_SUCCESS)
  2525. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2526. status = dp_get_srng_ring_state_from_hal
  2527. (pdev->soc, pdev,
  2528. &pdev->soc->rxdma_mon_dst_ring[lmac_id],
  2529. RXDMA_MONITOR_DST,
  2530. &soc_srngs_state->ring_state[*num_srng]);
  2531. if (status == QDF_STATUS_SUCCESS)
  2532. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2533. status = dp_get_srng_ring_state_from_hal
  2534. (pdev->soc, pdev,
  2535. &pdev->soc->rxdma_mon_desc_ring[lmac_id],
  2536. RXDMA_MONITOR_DESC,
  2537. &soc_srngs_state->ring_state[*num_srng]);
  2538. if (status == QDF_STATUS_SUCCESS)
  2539. qdf_assert_always(++(*num_srng) < DP_MAX_SRNGS);
  2540. }
  2541. }
  2542. #else
  2543. static void
  2544. dp_queue_mon_ring_stats(struct dp_pdev *pdev,
  2545. int lmac_id, uint32_t *num_srng,
  2546. struct dp_soc_srngs_state *soc_srngs_state)
  2547. {
  2548. }
  2549. #endif
  2550. #ifndef WLAN_DP_DISABLE_TCL_CMD_CRED_SRNG
  2551. static inline QDF_STATUS
  2552. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2553. struct dp_srng_ring_state *ring_state)
  2554. {
  2555. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2556. &pdev->soc->tcl_cmd_credit_ring,
  2557. TCL_CMD_CREDIT, ring_state);
  2558. }
  2559. #else
  2560. static inline QDF_STATUS
  2561. dp_get_tcl_cmd_cred_ring_state_from_hal(struct dp_pdev *pdev,
  2562. struct dp_srng_ring_state *ring_state)
  2563. {
  2564. return QDF_STATUS_SUCCESS;
  2565. }
  2566. #endif
  2567. #ifndef WLAN_DP_DISABLE_TCL_STATUS_SRNG
  2568. static inline QDF_STATUS
  2569. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2570. struct dp_srng_ring_state *ring_state)
  2571. {
  2572. return dp_get_srng_ring_state_from_hal(pdev->soc, pdev,
  2573. &pdev->soc->tcl_status_ring,
  2574. TCL_STATUS, ring_state);
  2575. }
  2576. #else
  2577. static inline QDF_STATUS
  2578. dp_get_tcl_status_ring_state_from_hal(struct dp_pdev *pdev,
  2579. struct dp_srng_ring_state *ring_state)
  2580. {
  2581. return QDF_STATUS_SUCCESS;
  2582. }
  2583. #endif
  2584. /**
  2585. * dp_queue_ring_stats() - Print pdev hal level ring stats
  2586. * dp_queue_ring_stats(): Print pdev hal level ring stats
  2587. * @pdev: DP_pdev handle
  2588. *
  2589. * Return: void
  2590. */
  2591. static void dp_queue_ring_stats(struct dp_pdev *pdev)
  2592. {
  2593. uint32_t i;
  2594. int mac_id;
  2595. int lmac_id;
  2596. uint32_t j = 0;
  2597. struct dp_soc *soc = pdev->soc;
  2598. struct dp_soc_srngs_state * soc_srngs_state = NULL;
  2599. struct dp_soc_srngs_state *drop_srngs_state = NULL;
  2600. QDF_STATUS status;
  2601. soc_srngs_state = qdf_mem_malloc(sizeof(struct dp_soc_srngs_state));
  2602. if (!soc_srngs_state) {
  2603. dp_htt_alert("Memory alloc failed for back pressure event");
  2604. return;
  2605. }
  2606. status = dp_get_srng_ring_state_from_hal
  2607. (pdev->soc, pdev,
  2608. &pdev->soc->reo_exception_ring,
  2609. REO_EXCEPTION,
  2610. &soc_srngs_state->ring_state[j]);
  2611. if (status == QDF_STATUS_SUCCESS)
  2612. qdf_assert_always(++j < DP_MAX_SRNGS);
  2613. status = dp_get_srng_ring_state_from_hal
  2614. (pdev->soc, pdev,
  2615. &pdev->soc->reo_reinject_ring,
  2616. REO_REINJECT,
  2617. &soc_srngs_state->ring_state[j]);
  2618. if (status == QDF_STATUS_SUCCESS)
  2619. qdf_assert_always(++j < DP_MAX_SRNGS);
  2620. status = dp_get_srng_ring_state_from_hal
  2621. (pdev->soc, pdev,
  2622. &pdev->soc->reo_cmd_ring,
  2623. REO_CMD,
  2624. &soc_srngs_state->ring_state[j]);
  2625. if (status == QDF_STATUS_SUCCESS)
  2626. qdf_assert_always(++j < DP_MAX_SRNGS);
  2627. status = dp_get_srng_ring_state_from_hal
  2628. (pdev->soc, pdev,
  2629. &pdev->soc->reo_status_ring,
  2630. REO_STATUS,
  2631. &soc_srngs_state->ring_state[j]);
  2632. if (status == QDF_STATUS_SUCCESS)
  2633. qdf_assert_always(++j < DP_MAX_SRNGS);
  2634. status = dp_get_srng_ring_state_from_hal
  2635. (pdev->soc, pdev,
  2636. &pdev->soc->rx_rel_ring,
  2637. WBM2SW_RELEASE,
  2638. &soc_srngs_state->ring_state[j]);
  2639. if (status == QDF_STATUS_SUCCESS)
  2640. qdf_assert_always(++j < DP_MAX_SRNGS);
  2641. status = dp_get_tcl_cmd_cred_ring_state_from_hal
  2642. (pdev, &soc_srngs_state->ring_state[j]);
  2643. if (status == QDF_STATUS_SUCCESS)
  2644. qdf_assert_always(++j < DP_MAX_SRNGS);
  2645. status = dp_get_tcl_status_ring_state_from_hal
  2646. (pdev, &soc_srngs_state->ring_state[j]);
  2647. if (status == QDF_STATUS_SUCCESS)
  2648. qdf_assert_always(++j < DP_MAX_SRNGS);
  2649. status = dp_get_srng_ring_state_from_hal
  2650. (pdev->soc, pdev,
  2651. &pdev->soc->wbm_desc_rel_ring,
  2652. SW2WBM_RELEASE,
  2653. &soc_srngs_state->ring_state[j]);
  2654. if (status == QDF_STATUS_SUCCESS)
  2655. qdf_assert_always(++j < DP_MAX_SRNGS);
  2656. for (i = 0; i < MAX_REO_DEST_RINGS; i++) {
  2657. status = dp_get_srng_ring_state_from_hal
  2658. (pdev->soc, pdev,
  2659. &pdev->soc->reo_dest_ring[i],
  2660. REO_DST,
  2661. &soc_srngs_state->ring_state[j]);
  2662. if (status == QDF_STATUS_SUCCESS)
  2663. qdf_assert_always(++j < DP_MAX_SRNGS);
  2664. }
  2665. for (i = 0; i < pdev->soc->num_tcl_data_rings; i++) {
  2666. status = dp_get_srng_ring_state_from_hal
  2667. (pdev->soc, pdev,
  2668. &pdev->soc->tcl_data_ring[i],
  2669. TCL_DATA,
  2670. &soc_srngs_state->ring_state[j]);
  2671. if (status == QDF_STATUS_SUCCESS)
  2672. qdf_assert_always(++j < DP_MAX_SRNGS);
  2673. }
  2674. for (i = 0; i < MAX_TCL_DATA_RINGS; i++) {
  2675. status = dp_get_srng_ring_state_from_hal
  2676. (pdev->soc, pdev,
  2677. &pdev->soc->tx_comp_ring[i],
  2678. WBM2SW_RELEASE,
  2679. &soc_srngs_state->ring_state[j]);
  2680. if (status == QDF_STATUS_SUCCESS)
  2681. qdf_assert_always(++j < DP_MAX_SRNGS);
  2682. }
  2683. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc, 0, pdev->pdev_id);
  2684. status = dp_get_srng_ring_state_from_hal
  2685. (pdev->soc, pdev,
  2686. &pdev->soc->rx_refill_buf_ring
  2687. [lmac_id],
  2688. RXDMA_BUF,
  2689. &soc_srngs_state->ring_state[j]);
  2690. if (status == QDF_STATUS_SUCCESS)
  2691. qdf_assert_always(++j < DP_MAX_SRNGS);
  2692. status = dp_get_srng_ring_state_from_hal
  2693. (pdev->soc, pdev,
  2694. &pdev->rx_refill_buf_ring2,
  2695. RXDMA_BUF,
  2696. &soc_srngs_state->ring_state[j]);
  2697. if (status == QDF_STATUS_SUCCESS)
  2698. qdf_assert_always(++j < DP_MAX_SRNGS);
  2699. for (i = 0; i < MAX_RX_MAC_RINGS; i++) {
  2700. dp_get_srng_ring_state_from_hal
  2701. (pdev->soc, pdev,
  2702. &pdev->rx_mac_buf_ring[i],
  2703. RXDMA_BUF,
  2704. &soc_srngs_state->ring_state[j]);
  2705. if (status == QDF_STATUS_SUCCESS)
  2706. qdf_assert_always(++j < DP_MAX_SRNGS);
  2707. }
  2708. for (mac_id = 0;
  2709. mac_id < soc->wlan_cfg_ctx->num_rxdma_status_rings_per_pdev;
  2710. mac_id++) {
  2711. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2712. mac_id, pdev->pdev_id);
  2713. dp_queue_mon_ring_stats(pdev, lmac_id, &j,
  2714. soc_srngs_state);
  2715. status = dp_get_srng_ring_state_from_hal
  2716. (pdev->soc, pdev,
  2717. &pdev->soc->rxdma_mon_status_ring[lmac_id],
  2718. RXDMA_MONITOR_STATUS,
  2719. &soc_srngs_state->ring_state[j]);
  2720. if (status == QDF_STATUS_SUCCESS)
  2721. qdf_assert_always(++j < DP_MAX_SRNGS);
  2722. }
  2723. for (i = 0; i < soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev; i++) {
  2724. lmac_id = dp_get_lmac_id_for_pdev_id(pdev->soc,
  2725. i, pdev->pdev_id);
  2726. status = dp_get_srng_ring_state_from_hal
  2727. (pdev->soc, pdev,
  2728. &pdev->soc->rxdma_err_dst_ring
  2729. [lmac_id],
  2730. RXDMA_DST,
  2731. &soc_srngs_state->ring_state[j]);
  2732. if (status == QDF_STATUS_SUCCESS)
  2733. qdf_assert_always(++j < DP_MAX_SRNGS);
  2734. }
  2735. soc_srngs_state->max_ring_id = j;
  2736. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  2737. soc_srngs_state->seq_num = pdev->bkp_stats.seq_num;
  2738. if (pdev->bkp_stats.queue_depth >= HTT_BKP_STATS_MAX_QUEUE_DEPTH) {
  2739. drop_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  2740. qdf_assert_always(drop_srngs_state);
  2741. TAILQ_REMOVE(&pdev->bkp_stats.list, drop_srngs_state,
  2742. list_elem);
  2743. qdf_mem_free(drop_srngs_state);
  2744. pdev->bkp_stats.queue_depth--;
  2745. }
  2746. pdev->bkp_stats.queue_depth++;
  2747. TAILQ_INSERT_TAIL(&pdev->bkp_stats.list, soc_srngs_state,
  2748. list_elem);
  2749. pdev->bkp_stats.seq_num++;
  2750. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  2751. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  2752. &pdev->bkp_stats.work);
  2753. }
  2754. /**
  2755. * dp_htt_bkp_event_alert() - htt backpressure event alert
  2756. * @msg_word: htt packet context
  2757. * @soc: HTT SOC handle
  2758. *
  2759. * Return: after attempting to print stats
  2760. */
  2761. static void dp_htt_bkp_event_alert(u_int32_t *msg_word, struct htt_soc *soc)
  2762. {
  2763. u_int8_t ring_type;
  2764. u_int8_t pdev_id;
  2765. uint8_t target_pdev_id;
  2766. u_int8_t ring_id;
  2767. u_int16_t hp_idx;
  2768. u_int16_t tp_idx;
  2769. u_int32_t bkp_time;
  2770. u_int32_t th_time;
  2771. enum htt_t2h_msg_type msg_type;
  2772. struct dp_soc *dpsoc;
  2773. struct dp_pdev *pdev;
  2774. struct dp_htt_timestamp *radio_tt;
  2775. struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
  2776. if (!soc)
  2777. return;
  2778. dpsoc = (struct dp_soc *)soc->dp_soc;
  2779. soc_cfg_ctx = dpsoc->wlan_cfg_ctx;
  2780. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  2781. ring_type = HTT_T2H_RX_BKPRESSURE_RING_TYPE_GET(*msg_word);
  2782. target_pdev_id = HTT_T2H_RX_BKPRESSURE_PDEV_ID_GET(*msg_word);
  2783. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2784. target_pdev_id);
  2785. if (pdev_id >= MAX_PDEV_CNT) {
  2786. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2787. return;
  2788. }
  2789. th_time = wlan_cfg_time_control_bp(soc_cfg_ctx);
  2790. pdev = (struct dp_pdev *)dpsoc->pdev_list[pdev_id];
  2791. ring_id = HTT_T2H_RX_BKPRESSURE_RINGID_GET(*msg_word);
  2792. hp_idx = HTT_T2H_RX_BKPRESSURE_HEAD_IDX_GET(*(msg_word + 1));
  2793. tp_idx = HTT_T2H_RX_BKPRESSURE_TAIL_IDX_GET(*(msg_word + 1));
  2794. bkp_time = HTT_T2H_RX_BKPRESSURE_TIME_MS_GET(*(msg_word + 2));
  2795. radio_tt = &soc->pdevid_tt[pdev_id];
  2796. switch (ring_type) {
  2797. case HTT_SW_RING_TYPE_UMAC:
  2798. if (!time_allow_print(radio_tt->umac_path, ring_id, th_time))
  2799. return;
  2800. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2801. bkp_time, radio_tt->umac_path,
  2802. "HTT_SW_RING_TYPE_UMAC");
  2803. break;
  2804. case HTT_SW_RING_TYPE_LMAC:
  2805. if (!time_allow_print(radio_tt->lmac_path, ring_id, th_time))
  2806. return;
  2807. dp_htt_alert_print(msg_type, pdev, ring_id, hp_idx, tp_idx,
  2808. bkp_time, radio_tt->lmac_path,
  2809. "HTT_SW_RING_TYPE_LMAC");
  2810. break;
  2811. default:
  2812. dp_alert("Invalid ring type: %d", ring_type);
  2813. break;
  2814. }
  2815. dp_queue_ring_stats(pdev);
  2816. }
  2817. #ifdef WLAN_FEATURE_PKT_CAPTURE_V2
  2818. /**
  2819. * dp_offload_ind_handler() - offload msg handler
  2820. * @soc: HTT SOC handle
  2821. * @msg_word: Pointer to payload
  2822. *
  2823. * Return: None
  2824. */
  2825. static void
  2826. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2827. {
  2828. u_int8_t pdev_id;
  2829. u_int8_t target_pdev_id;
  2830. target_pdev_id = HTT_T2H_PPDU_STATS_PDEV_ID_GET(*msg_word);
  2831. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc->dp_soc,
  2832. target_pdev_id);
  2833. dp_wdi_event_handler(WDI_EVENT_PKT_CAPTURE_OFFLOAD_TX_DATA, soc->dp_soc,
  2834. msg_word, HTT_INVALID_VDEV, WDI_NO_VAL,
  2835. pdev_id);
  2836. }
  2837. #else
  2838. static void
  2839. dp_offload_ind_handler(struct htt_soc *soc, uint32_t *msg_word)
  2840. {
  2841. }
  2842. #endif
  2843. #ifdef WLAN_FEATURE_11BE_MLO
  2844. #ifdef WLAN_MLO_MULTI_CHIP
  2845. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2846. uint32_t ts_lo, uint32_t ts_hi)
  2847. {
  2848. uint64_t mlo_offset;
  2849. mlo_offset = ((uint64_t)(ts_hi) << 32 | ts_lo);
  2850. soc->cdp_soc.ops->mlo_ops->mlo_update_mlo_ts_offset
  2851. ((struct cdp_soc_t *)soc, mlo_offset);
  2852. }
  2853. #else
  2854. static inline void dp_update_mlo_ts_offset(struct dp_soc *soc,
  2855. uint32_t ts_lo, uint32_t ts_hi)
  2856. {}
  2857. #endif
  2858. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  2859. uint32_t *msg_word)
  2860. {
  2861. uint8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  2862. uint8_t *mlo_peer_mac_addr;
  2863. uint16_t mlo_peer_id;
  2864. uint8_t num_links;
  2865. struct dp_mlo_flow_override_info mlo_flow_info[DP_MLO_FLOW_INFO_MAX];
  2866. struct dp_mlo_link_info mlo_link_info[DP_MAX_MLO_LINKS];
  2867. MLO_PEER_MAP_TLV_TAG_ID tlv_type = 0xff;
  2868. uint16_t tlv_len = 0;
  2869. int i = 0;
  2870. mlo_peer_id = HTT_RX_MLO_PEER_MAP_MLO_PEER_ID_GET(*msg_word);
  2871. num_links =
  2872. HTT_RX_MLO_PEER_MAP_NUM_LOGICAL_LINKS_GET(*msg_word);
  2873. mlo_peer_mac_addr =
  2874. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  2875. &mac_addr_deswizzle_buf[0]);
  2876. mlo_flow_info[0].ast_idx =
  2877. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2878. mlo_flow_info[0].ast_idx_valid =
  2879. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2880. mlo_flow_info[0].chip_id =
  2881. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2882. mlo_flow_info[0].tidmask =
  2883. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2884. mlo_flow_info[0].cache_set_num =
  2885. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2886. mlo_flow_info[1].ast_idx =
  2887. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2888. mlo_flow_info[1].ast_idx_valid =
  2889. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2890. mlo_flow_info[1].chip_id =
  2891. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2892. mlo_flow_info[1].tidmask =
  2893. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2894. mlo_flow_info[1].cache_set_num =
  2895. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2896. mlo_flow_info[2].ast_idx =
  2897. HTT_RX_MLO_PEER_MAP_PRIMARY_AST_INDEX_GET(*(msg_word + 3));
  2898. mlo_flow_info[2].ast_idx_valid =
  2899. HTT_RX_MLO_PEER_MAP_AST_INDEX_VALID_FLAG_GET(*(msg_word + 3));
  2900. mlo_flow_info[2].chip_id =
  2901. HTT_RX_MLO_PEER_MAP_CHIP_ID_AST_INDEX_GET(*(msg_word + 3));
  2902. mlo_flow_info[2].tidmask =
  2903. HTT_RX_MLO_PEER_MAP_TIDMASK_AST_INDEX_GET(*(msg_word + 3));
  2904. mlo_flow_info[2].cache_set_num =
  2905. HTT_RX_MLO_PEER_MAP_CACHE_SET_NUM_AST_INDEX_GET(*(msg_word + 3));
  2906. msg_word = msg_word + 8;
  2907. while (msg_word && (i < DP_MAX_MLO_LINKS)) {
  2908. mlo_link_info[i].peer_chip_id = 0xFF;
  2909. mlo_link_info[i].vdev_id = 0xFF;
  2910. tlv_type = HTT_RX_MLO_PEER_MAP_TLV_TAG_GET(*msg_word);
  2911. tlv_len = HTT_RX_MLO_PEER_MAP_TLV_LENGTH_GET(*msg_word);
  2912. if (tlv_len == 0) {
  2913. dp_err("TLV Length is 0");
  2914. break;
  2915. }
  2916. if (tlv_type == MLO_PEER_MAP_TLV_STRUCT_SOC_VDEV_PEER_IDS) {
  2917. mlo_link_info[i].peer_chip_id =
  2918. HTT_RX_MLO_PEER_MAP_CHIP_ID_GET(
  2919. *(msg_word + 1));
  2920. mlo_link_info[i].vdev_id =
  2921. HTT_RX_MLO_PEER_MAP_VDEV_ID_GET(
  2922. *(msg_word + 1));
  2923. }
  2924. /* Add header size to tlv length */
  2925. tlv_len = tlv_len + HTT_TLV_HDR_LEN;
  2926. msg_word = (uint32_t *)(((uint8_t *)msg_word) + tlv_len);
  2927. i++;
  2928. }
  2929. dp_rx_mlo_peer_map_handler(soc->dp_soc, mlo_peer_id,
  2930. mlo_peer_mac_addr,
  2931. mlo_flow_info, mlo_link_info);
  2932. }
  2933. #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
  2934. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  2935. uint32_t *msg_word)
  2936. {
  2937. u_int16_t peer_id;
  2938. u_int16_t ml_peer_id;
  2939. u_int16_t vdev_id;
  2940. u_int8_t pdev_id;
  2941. u_int8_t chip_id;
  2942. vdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_VDEV_ID_GET(
  2943. *msg_word);
  2944. pdev_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_PDEV_ID_GET(
  2945. *msg_word);
  2946. chip_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_CHIP_ID_GET(
  2947. *msg_word);
  2948. ml_peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_ML_PEER_ID_GET(
  2949. *(msg_word + 1));
  2950. peer_id = HTT_T2H_PRIMARY_LINK_PEER_MIGRATE_SW_LINK_PEER_ID_GET(
  2951. *(msg_word + 1));
  2952. dp_htt_info("HTT_T2H_MSG_TYPE_PRIMARY_PEER_MIGRATE_IND msg"
  2953. "for peer id %d vdev id %d", peer_id, vdev_id);
  2954. dp_htt_reo_migration(soc->dp_soc, peer_id, ml_peer_id,
  2955. vdev_id, pdev_id, chip_id);
  2956. }
  2957. #else
  2958. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  2959. uint32_t *msg_word)
  2960. {
  2961. }
  2962. #endif
  2963. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  2964. uint32_t *msg_word)
  2965. {
  2966. uint16_t mlo_peer_id;
  2967. mlo_peer_id = HTT_RX_MLO_PEER_UNMAP_MLO_PEER_ID_GET(*msg_word);
  2968. dp_rx_mlo_peer_unmap_handler(soc->dp_soc, mlo_peer_id);
  2969. }
  2970. static void
  2971. dp_rx_mlo_timestamp_ind_handler(struct dp_soc *soc,
  2972. uint32_t *msg_word)
  2973. {
  2974. uint8_t pdev_id;
  2975. uint8_t target_pdev_id;
  2976. struct dp_pdev *pdev;
  2977. if (!soc)
  2978. return;
  2979. target_pdev_id = HTT_T2H_MLO_TIMESTAMP_OFFSET_PDEV_ID_GET(*msg_word);
  2980. pdev_id = dp_get_host_pdev_id_for_target_pdev_id(soc,
  2981. target_pdev_id);
  2982. if (pdev_id >= MAX_PDEV_CNT) {
  2983. dp_htt_debug("%pK: pdev id %d is invalid", soc, pdev_id);
  2984. return;
  2985. }
  2986. pdev = (struct dp_pdev *)soc->pdev_list[pdev_id];
  2987. if (!pdev) {
  2988. dp_err("Invalid pdev");
  2989. return;
  2990. }
  2991. dp_wdi_event_handler(WDI_EVENT_MLO_TSTMP, soc,
  2992. msg_word, HTT_INVALID_PEER, WDI_NO_VAL,
  2993. pdev_id);
  2994. qdf_spin_lock_bh(&soc->htt_stats.lock);
  2995. pdev->timestamp.msg_type =
  2996. HTT_T2H_MLO_TIMESTAMP_OFFSET_MSG_TYPE_GET(*msg_word);
  2997. pdev->timestamp.pdev_id = pdev_id;
  2998. pdev->timestamp.chip_id =
  2999. HTT_T2H_MLO_TIMESTAMP_OFFSET_CHIP_ID_GET(*msg_word);
  3000. pdev->timestamp.mac_clk_freq =
  3001. HTT_T2H_MLO_TIMESTAMP_OFFSET_MAC_CLK_FREQ_MHZ_GET(*msg_word);
  3002. pdev->timestamp.sync_tstmp_lo_us = *(msg_word + 1);
  3003. pdev->timestamp.sync_tstmp_hi_us = *(msg_word + 2);
  3004. pdev->timestamp.mlo_offset_lo_us = *(msg_word + 3);
  3005. pdev->timestamp.mlo_offset_hi_us = *(msg_word + 4);
  3006. pdev->timestamp.mlo_offset_clks = *(msg_word + 5);
  3007. pdev->timestamp.mlo_comp_us =
  3008. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_US_GET(
  3009. *(msg_word + 6));
  3010. pdev->timestamp.mlo_comp_clks =
  3011. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_CLKS_GET(
  3012. *(msg_word + 6));
  3013. pdev->timestamp.mlo_comp_timer =
  3014. HTT_T2H_MLO_TIMESTAMP_OFFSET_MLO_TIMESTAMP_COMP_PERIOD_US_GET(
  3015. *(msg_word + 7));
  3016. dp_htt_debug("tsf_lo=%d tsf_hi=%d, mlo_ofst_lo=%d, mlo_ofst_hi=%d\n",
  3017. pdev->timestamp.sync_tstmp_lo_us,
  3018. pdev->timestamp.sync_tstmp_hi_us,
  3019. pdev->timestamp.mlo_offset_lo_us,
  3020. pdev->timestamp.mlo_offset_hi_us);
  3021. qdf_spin_unlock_bh(&soc->htt_stats.lock);
  3022. dp_update_mlo_ts_offset(soc,
  3023. pdev->timestamp.mlo_offset_lo_us,
  3024. pdev->timestamp.mlo_offset_hi_us);
  3025. }
  3026. #else
  3027. static void dp_htt_mlo_peer_map_handler(struct htt_soc *soc,
  3028. uint32_t *msg_word)
  3029. {
  3030. qdf_assert_always(0);
  3031. }
  3032. static void dp_htt_mlo_peer_unmap_handler(struct htt_soc *soc,
  3033. uint32_t *msg_word)
  3034. {
  3035. qdf_assert_always(0);
  3036. }
  3037. static void
  3038. dp_rx_mlo_timestamp_ind_handler(void *soc_handle,
  3039. uint32_t *msg_word)
  3040. {
  3041. qdf_assert_always(0);
  3042. }
  3043. static void dp_htt_t2h_primary_link_migration(struct htt_soc *soc,
  3044. uint32_t *msg_word)
  3045. {
  3046. }
  3047. #endif
  3048. /**
  3049. * dp_htt_rx_addba_handler() - RX Addba HTT msg handler
  3050. * @soc: DP Soc handler
  3051. * @peer_id: ID of peer
  3052. * @tid: TID number
  3053. * @win_sz: BA window size
  3054. *
  3055. * Return: None
  3056. */
  3057. static void
  3058. dp_htt_rx_addba_handler(struct dp_soc *soc, uint16_t peer_id,
  3059. uint8_t tid, uint16_t win_sz)
  3060. {
  3061. uint16_t status;
  3062. struct dp_peer *peer;
  3063. peer = dp_peer_get_ref_by_id(soc, peer_id, DP_MOD_ID_HTT);
  3064. if (!peer) {
  3065. dp_err("Peer not found peer id %d", peer_id);
  3066. return;
  3067. }
  3068. status = dp_addba_requestprocess_wifi3((struct cdp_soc_t *)soc,
  3069. peer->mac_addr.raw,
  3070. peer->vdev->vdev_id, 0,
  3071. tid, 0, win_sz, 0xffff);
  3072. dp_addba_resp_tx_completion_wifi3(
  3073. (struct cdp_soc_t *)soc,
  3074. peer->mac_addr.raw, peer->vdev->vdev_id,
  3075. tid,
  3076. status);
  3077. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  3078. dp_info("PeerID %d BAW %d TID %d stat %d",
  3079. peer_id, win_sz, tid, status);
  3080. }
  3081. /**
  3082. * dp_htt_ppdu_id_fmt_handler() - PPDU ID Format handler
  3083. * @soc: HTT SOC handle
  3084. * @msg_word: Pointer to payload
  3085. *
  3086. * Return: None
  3087. */
  3088. static void
  3089. dp_htt_ppdu_id_fmt_handler(struct dp_soc *soc, uint32_t *msg_word)
  3090. {
  3091. uint8_t msg_type, valid, bits, offset;
  3092. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3093. msg_word += HTT_PPDU_ID_FMT_IND_LINK_ID_OFFSET;
  3094. valid = HTT_PPDU_ID_FMT_IND_VALID_GET_BITS31_16(*msg_word);
  3095. bits = HTT_PPDU_ID_FMT_IND_BITS_GET_BITS31_16(*msg_word);
  3096. offset = HTT_PPDU_ID_FMT_IND_OFFSET_GET_BITS31_16(*msg_word);
  3097. dp_info("link_id: valid %u bits %u offset %u", valid, bits, offset);
  3098. if (valid) {
  3099. soc->link_id_offset = offset;
  3100. soc->link_id_bits = bits;
  3101. }
  3102. }
  3103. #ifdef IPA_OPT_WIFI_DP
  3104. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3105. uint32_t *msg_word)
  3106. {
  3107. uint8_t pdev_id = 0;
  3108. uint8_t resp_type = 0;
  3109. uint8_t is_rules_enough = 0;
  3110. uint8_t num_rules_avail = 0;
  3111. int filter0_result = 0, filter1_result = 0;
  3112. bool is_success = false;
  3113. pdev_id = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_PDEV_ID_GET(*msg_word);
  3114. resp_type = HTT_RX_CCE_SUPER_RULE_SETUP_DONE_RESPONSE_TYPE_GET(
  3115. *msg_word);
  3116. dp_info("opt_dp:: cce_super_rule_rsp pdev_id: %d resp_type: %d",
  3117. pdev_id, resp_type);
  3118. switch (resp_type) {
  3119. case HTT_RX_CCE_SUPER_RULE_SETUP_REQ_RESPONSE:
  3120. {
  3121. is_rules_enough =
  3122. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_IS_RULE_ENOUGH_GET(
  3123. *msg_word);
  3124. num_rules_avail =
  3125. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_AVAIL_RULE_NUM_GET(
  3126. *msg_word);
  3127. if (is_rules_enough == 1) {
  3128. is_success = true;
  3129. reserve_fail_cnt = 0;
  3130. } else {
  3131. is_success = false;
  3132. soc->reserve_fail_cnt++;
  3133. if (soc->reserve_fail_cnt > MAX_RESERVE_FAIL_ATTEMPT) {
  3134. /*
  3135. * IPA will retry only after an hour by default
  3136. * after MAX_RESERVE_FAIL_ATTEMPT
  3137. */
  3138. soc->abort_count++;
  3139. soc->reserve_fail_cnt = 0;
  3140. dp_info(
  3141. "opt_dp: Filter reserve failed max attempts");
  3142. }
  3143. dp_info("opt_dp:: Filter reserve failed. Rules avail %d",
  3144. num_rules_avail);
  3145. }
  3146. dp_ipa_wdi_opt_dpath_notify_flt_rsvd_per_inst(is_success);
  3147. break;
  3148. }
  3149. case HTT_RX_CCE_SUPER_RULE_INSTALL_RESPONSE:
  3150. {
  3151. filter0_result =
  3152. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3153. *msg_word);
  3154. filter1_result =
  3155. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3156. *msg_word);
  3157. dp_ipa_wdi_opt_dpath_notify_flt_add_rem_cb(filter0_result,
  3158. filter1_result);
  3159. break;
  3160. }
  3161. case HTT_RX_CCE_SUPER_RULE_RELEASE_RESPONSE:
  3162. {
  3163. filter0_result =
  3164. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_0_GET(
  3165. *msg_word);
  3166. filter1_result =
  3167. HTT_RX_CCE_SUPER_RULE_SETUP_DONE_CFG_RESULT_1_GET(
  3168. *msg_word);
  3169. dp_ipa_wdi_opt_dpath_notify_flt_rlsd_per_inst(filter0_result,
  3170. filter1_result);
  3171. break;
  3172. }
  3173. default:
  3174. dp_info("opt_dp:: Wrong Super rule setup response");
  3175. };
  3176. dp_info("opt_dp:: cce super rule resp type: %d, is_rules_enough: %d,",
  3177. resp_type, is_rules_enough);
  3178. dp_info("num_rules_avail: %d, rslt0: %d, rslt1: %d",
  3179. num_rules_avail, filter0_result, filter1_result);
  3180. }
  3181. #else
  3182. static void dp_ipa_rx_cce_super_rule_setup_done_handler(struct htt_soc *soc,
  3183. uint32_t *msg_word)
  3184. {
  3185. }
  3186. #endif
  3187. void dp_htt_t2h_msg_handler(void *context, HTC_PACKET *pkt)
  3188. {
  3189. struct htt_soc *soc = (struct htt_soc *) context;
  3190. qdf_nbuf_t htt_t2h_msg = (qdf_nbuf_t) pkt->pPktContext;
  3191. u_int32_t *msg_word;
  3192. enum htt_t2h_msg_type msg_type;
  3193. bool free_buf = true;
  3194. /* check for successful message reception */
  3195. if (pkt->Status != QDF_STATUS_SUCCESS) {
  3196. if (pkt->Status != QDF_STATUS_E_CANCELED)
  3197. soc->stats.htc_err_cnt++;
  3198. qdf_nbuf_free(htt_t2h_msg);
  3199. return;
  3200. }
  3201. /* TODO: Check if we should pop the HTC/HTT header alignment padding */
  3202. msg_word = (u_int32_t *) qdf_nbuf_data(htt_t2h_msg);
  3203. msg_type = HTT_T2H_MSG_TYPE_GET(*msg_word);
  3204. htt_event_record(soc->htt_logger_handle,
  3205. msg_type, (uint8_t *)msg_word);
  3206. switch (msg_type) {
  3207. case HTT_T2H_MSG_TYPE_BKPRESSURE_EVENT_IND:
  3208. {
  3209. dp_htt_bkp_event_alert(msg_word, soc);
  3210. break;
  3211. }
  3212. case HTT_T2H_MSG_TYPE_PEER_MAP:
  3213. {
  3214. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3215. u_int8_t *peer_mac_addr;
  3216. u_int16_t peer_id;
  3217. u_int16_t hw_peer_id;
  3218. u_int8_t vdev_id;
  3219. u_int8_t is_wds;
  3220. struct dp_soc *dpsoc = (struct dp_soc *)soc->dp_soc;
  3221. peer_id = HTT_RX_PEER_MAP_PEER_ID_GET(*msg_word);
  3222. hw_peer_id =
  3223. HTT_RX_PEER_MAP_HW_PEER_ID_GET(*(msg_word+2));
  3224. vdev_id = HTT_RX_PEER_MAP_VDEV_ID_GET(*msg_word);
  3225. peer_mac_addr = htt_t2h_mac_addr_deswizzle(
  3226. (u_int8_t *) (msg_word+1),
  3227. &mac_addr_deswizzle_buf[0]);
  3228. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3229. QDF_TRACE_LEVEL_DEBUG,
  3230. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3231. peer_id, vdev_id);
  3232. /*
  3233. * check if peer already exists for this peer_id, if so
  3234. * this peer map event is in response for a wds peer add
  3235. * wmi command sent during wds source port learning.
  3236. * in this case just add the ast entry to the existing
  3237. * peer ast_list.
  3238. */
  3239. is_wds = !!(dpsoc->peer_id_to_obj_map[peer_id]);
  3240. dp_rx_peer_map_handler(soc->dp_soc, peer_id, hw_peer_id,
  3241. vdev_id, peer_mac_addr, 0,
  3242. is_wds);
  3243. break;
  3244. }
  3245. case HTT_T2H_MSG_TYPE_PEER_UNMAP:
  3246. {
  3247. u_int16_t peer_id;
  3248. u_int8_t vdev_id;
  3249. u_int8_t mac_addr[QDF_MAC_ADDR_SIZE] = {0};
  3250. peer_id = HTT_RX_PEER_UNMAP_PEER_ID_GET(*msg_word);
  3251. vdev_id = HTT_RX_PEER_UNMAP_VDEV_ID_GET(*msg_word);
  3252. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3253. vdev_id, mac_addr, 0,
  3254. DP_PEER_WDS_COUNT_INVALID);
  3255. break;
  3256. }
  3257. case HTT_T2H_MSG_TYPE_SEC_IND:
  3258. {
  3259. u_int16_t peer_id;
  3260. enum cdp_sec_type sec_type;
  3261. int is_unicast;
  3262. peer_id = HTT_SEC_IND_PEER_ID_GET(*msg_word);
  3263. sec_type = HTT_SEC_IND_SEC_TYPE_GET(*msg_word);
  3264. is_unicast = HTT_SEC_IND_UNICAST_GET(*msg_word);
  3265. /* point to the first part of the Michael key */
  3266. msg_word++;
  3267. dp_rx_sec_ind_handler(
  3268. soc->dp_soc, peer_id, sec_type, is_unicast,
  3269. msg_word, msg_word + 2);
  3270. break;
  3271. }
  3272. case HTT_T2H_MSG_TYPE_PPDU_STATS_IND:
  3273. {
  3274. free_buf =
  3275. dp_monitor_ppdu_stats_ind_handler(soc,
  3276. msg_word,
  3277. htt_t2h_msg);
  3278. break;
  3279. }
  3280. case HTT_T2H_MSG_TYPE_PKTLOG:
  3281. {
  3282. dp_pktlog_msg_handler(soc, msg_word);
  3283. break;
  3284. }
  3285. case HTT_T2H_MSG_TYPE_VERSION_CONF:
  3286. {
  3287. /*
  3288. * HTC maintains runtime pm count for H2T messages that
  3289. * have a response msg from FW. This count ensures that
  3290. * in the case FW does not sent out the response or host
  3291. * did not process this indication runtime_put happens
  3292. * properly in the cleanup path.
  3293. */
  3294. if (htc_dec_return_htt_runtime_cnt(soc->htc_soc) >= 0)
  3295. htc_pm_runtime_put(soc->htc_soc);
  3296. else
  3297. soc->stats.htt_ver_req_put_skip++;
  3298. soc->tgt_ver.major = HTT_VER_CONF_MAJOR_GET(*msg_word);
  3299. soc->tgt_ver.minor = HTT_VER_CONF_MINOR_GET(*msg_word);
  3300. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW,
  3301. "target uses HTT version %d.%d; host uses %d.%d",
  3302. soc->tgt_ver.major, soc->tgt_ver.minor,
  3303. HTT_CURRENT_VERSION_MAJOR,
  3304. HTT_CURRENT_VERSION_MINOR);
  3305. if (soc->tgt_ver.major != HTT_CURRENT_VERSION_MAJOR) {
  3306. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3307. QDF_TRACE_LEVEL_WARN,
  3308. "*** Incompatible host/target HTT versions!");
  3309. }
  3310. /* abort if the target is incompatible with the host */
  3311. qdf_assert(soc->tgt_ver.major ==
  3312. HTT_CURRENT_VERSION_MAJOR);
  3313. if (soc->tgt_ver.minor != HTT_CURRENT_VERSION_MINOR) {
  3314. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3315. QDF_TRACE_LEVEL_INFO_LOW,
  3316. "*** Warning: host/target HTT versions"
  3317. " are different, though compatible!");
  3318. }
  3319. break;
  3320. }
  3321. case HTT_T2H_MSG_TYPE_RX_ADDBA:
  3322. {
  3323. uint16_t peer_id;
  3324. uint8_t tid;
  3325. uint16_t win_sz;
  3326. /*
  3327. * Update REO Queue Desc with new values
  3328. */
  3329. peer_id = HTT_RX_ADDBA_PEER_ID_GET(*msg_word);
  3330. tid = HTT_RX_ADDBA_TID_GET(*msg_word);
  3331. win_sz = HTT_RX_ADDBA_WIN_SIZE_GET(*msg_word);
  3332. /*
  3333. * Window size needs to be incremented by 1
  3334. * since fw needs to represent a value of 256
  3335. * using just 8 bits
  3336. */
  3337. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3338. tid, win_sz + 1);
  3339. break;
  3340. }
  3341. case HTT_T2H_MSG_TYPE_RX_ADDBA_EXTN:
  3342. {
  3343. uint16_t peer_id;
  3344. uint8_t tid;
  3345. uint16_t win_sz;
  3346. peer_id = HTT_RX_ADDBA_EXTN_PEER_ID_GET(*msg_word);
  3347. tid = HTT_RX_ADDBA_EXTN_TID_GET(*msg_word);
  3348. msg_word++;
  3349. win_sz = HTT_RX_ADDBA_EXTN_WIN_SIZE_GET(*msg_word);
  3350. dp_htt_rx_addba_handler(soc->dp_soc, peer_id,
  3351. tid, win_sz);
  3352. break;
  3353. }
  3354. case HTT_T2H_PPDU_ID_FMT_IND:
  3355. {
  3356. dp_htt_ppdu_id_fmt_handler(soc->dp_soc, msg_word);
  3357. break;
  3358. }
  3359. case HTT_T2H_MSG_TYPE_EXT_STATS_CONF:
  3360. {
  3361. dp_txrx_fw_stats_handler(soc->dp_soc, htt_t2h_msg);
  3362. break;
  3363. }
  3364. case HTT_T2H_MSG_TYPE_PEER_MAP_V2:
  3365. {
  3366. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3367. u_int8_t *peer_mac_addr;
  3368. u_int16_t peer_id;
  3369. u_int16_t hw_peer_id;
  3370. u_int8_t vdev_id;
  3371. bool is_wds;
  3372. u_int16_t ast_hash;
  3373. struct dp_ast_flow_override_info ast_flow_info;
  3374. qdf_mem_set(&ast_flow_info, 0,
  3375. sizeof(struct dp_ast_flow_override_info));
  3376. peer_id = HTT_RX_PEER_MAP_V2_SW_PEER_ID_GET(*msg_word);
  3377. hw_peer_id =
  3378. HTT_RX_PEER_MAP_V2_HW_PEER_ID_GET(*(msg_word + 2));
  3379. vdev_id = HTT_RX_PEER_MAP_V2_VDEV_ID_GET(*msg_word);
  3380. peer_mac_addr =
  3381. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3382. &mac_addr_deswizzle_buf[0]);
  3383. is_wds =
  3384. HTT_RX_PEER_MAP_V2_NEXT_HOP_GET(*(msg_word + 3));
  3385. ast_hash =
  3386. HTT_RX_PEER_MAP_V2_AST_HASH_VALUE_GET(*(msg_word + 3));
  3387. /*
  3388. * Update 4 ast_index per peer, ast valid mask
  3389. * and TID flow valid mask.
  3390. * AST valid mask is 3 bit field corresponds to
  3391. * ast_index[3:1]. ast_index 0 is always valid.
  3392. */
  3393. ast_flow_info.ast_valid_mask =
  3394. HTT_RX_PEER_MAP_V2_AST_VALID_MASK_GET(*(msg_word + 3));
  3395. ast_flow_info.ast_idx[0] = hw_peer_id;
  3396. ast_flow_info.ast_flow_mask[0] =
  3397. HTT_RX_PEER_MAP_V2_AST_0_FLOW_MASK_GET(*(msg_word + 4));
  3398. ast_flow_info.ast_idx[1] =
  3399. HTT_RX_PEER_MAP_V2_AST_INDEX_1_GET(*(msg_word + 4));
  3400. ast_flow_info.ast_flow_mask[1] =
  3401. HTT_RX_PEER_MAP_V2_AST_1_FLOW_MASK_GET(*(msg_word + 4));
  3402. ast_flow_info.ast_idx[2] =
  3403. HTT_RX_PEER_MAP_V2_AST_INDEX_2_GET(*(msg_word + 5));
  3404. ast_flow_info.ast_flow_mask[2] =
  3405. HTT_RX_PEER_MAP_V2_AST_2_FLOW_MASK_GET(*(msg_word + 4));
  3406. ast_flow_info.ast_idx[3] =
  3407. HTT_RX_PEER_MAP_V2_AST_INDEX_3_GET(*(msg_word + 6));
  3408. ast_flow_info.ast_flow_mask[3] =
  3409. HTT_RX_PEER_MAP_V2_AST_3_FLOW_MASK_GET(*(msg_word + 4));
  3410. /*
  3411. * TID valid mask is applicable only
  3412. * for HI and LOW priority flows.
  3413. * tid_valid_mas is 8 bit field corresponds
  3414. * to TID[7:0]
  3415. */
  3416. ast_flow_info.tid_valid_low_pri_mask =
  3417. HTT_RX_PEER_MAP_V2_TID_VALID_LOW_PRI_GET(*(msg_word + 5));
  3418. ast_flow_info.tid_valid_hi_pri_mask =
  3419. HTT_RX_PEER_MAP_V2_TID_VALID_HI_PRI_GET(*(msg_word + 5));
  3420. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3421. QDF_TRACE_LEVEL_DEBUG,
  3422. "HTT_T2H_MSG_TYPE_PEER_MAP msg for peer id %d vdev id %d n",
  3423. peer_id, vdev_id);
  3424. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3425. QDF_TRACE_LEVEL_INFO,
  3426. "ast_idx[0] %d ast_idx[1] %d ast_idx[2] %d ast_idx[3] %d n",
  3427. ast_flow_info.ast_idx[0],
  3428. ast_flow_info.ast_idx[1],
  3429. ast_flow_info.ast_idx[2],
  3430. ast_flow_info.ast_idx[3]);
  3431. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3432. hw_peer_id, vdev_id,
  3433. peer_mac_addr, ast_hash,
  3434. is_wds);
  3435. /*
  3436. * Update ast indexes for flow override support
  3437. * Applicable only for non wds peers
  3438. */
  3439. if (!soc->dp_soc->ast_offload_support)
  3440. dp_peer_ast_index_flow_queue_map_create(
  3441. soc->dp_soc, is_wds,
  3442. peer_id, peer_mac_addr,
  3443. &ast_flow_info);
  3444. break;
  3445. }
  3446. case HTT_T2H_MSG_TYPE_PEER_UNMAP_V2:
  3447. {
  3448. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3449. u_int8_t *mac_addr;
  3450. u_int16_t peer_id;
  3451. u_int8_t vdev_id;
  3452. u_int8_t is_wds;
  3453. u_int32_t free_wds_count;
  3454. peer_id =
  3455. HTT_RX_PEER_UNMAP_V2_SW_PEER_ID_GET(*msg_word);
  3456. vdev_id = HTT_RX_PEER_UNMAP_V2_VDEV_ID_GET(*msg_word);
  3457. mac_addr =
  3458. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3459. &mac_addr_deswizzle_buf[0]);
  3460. is_wds =
  3461. HTT_RX_PEER_UNMAP_V2_NEXT_HOP_GET(*(msg_word + 2));
  3462. free_wds_count =
  3463. HTT_RX_PEER_UNMAP_V2_PEER_WDS_FREE_COUNT_GET(*(msg_word + 4));
  3464. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3465. QDF_TRACE_LEVEL_INFO,
  3466. "HTT_T2H_MSG_TYPE_PEER_UNMAP msg for peer id %d vdev id %d n",
  3467. peer_id, vdev_id);
  3468. dp_rx_peer_unmap_handler(soc->dp_soc, peer_id,
  3469. vdev_id, mac_addr,
  3470. is_wds, free_wds_count);
  3471. break;
  3472. }
  3473. case HTT_T2H_MSG_TYPE_RX_DELBA:
  3474. {
  3475. uint16_t peer_id;
  3476. uint8_t tid;
  3477. uint8_t win_sz;
  3478. QDF_STATUS status;
  3479. peer_id = HTT_RX_DELBA_PEER_ID_GET(*msg_word);
  3480. tid = HTT_RX_DELBA_TID_GET(*msg_word);
  3481. win_sz = HTT_RX_DELBA_WIN_SIZE_GET(*msg_word);
  3482. status = dp_rx_delba_ind_handler(
  3483. soc->dp_soc,
  3484. peer_id, tid, win_sz);
  3485. QDF_TRACE(QDF_MODULE_ID_TXRX,
  3486. QDF_TRACE_LEVEL_INFO,
  3487. FL("DELBA PeerID %d BAW %d TID %d stat %d"),
  3488. peer_id, win_sz, tid, status);
  3489. break;
  3490. }
  3491. case HTT_T2H_MSG_TYPE_RX_DELBA_EXTN:
  3492. {
  3493. uint16_t peer_id;
  3494. uint8_t tid;
  3495. uint16_t win_sz;
  3496. QDF_STATUS status;
  3497. peer_id = HTT_RX_DELBA_EXTN_PEER_ID_GET(*msg_word);
  3498. tid = HTT_RX_DELBA_EXTN_TID_GET(*msg_word);
  3499. msg_word++;
  3500. win_sz = HTT_RX_DELBA_EXTN_WIN_SIZE_GET(*msg_word);
  3501. status = dp_rx_delba_ind_handler(soc->dp_soc,
  3502. peer_id, tid,
  3503. win_sz);
  3504. dp_info("DELBA PeerID %d BAW %d TID %d stat %d",
  3505. peer_id, win_sz, tid, status);
  3506. break;
  3507. }
  3508. case HTT_T2H_MSG_TYPE_FSE_CMEM_BASE_SEND:
  3509. {
  3510. uint16_t num_entries;
  3511. uint32_t cmem_ba_lo;
  3512. uint32_t cmem_ba_hi;
  3513. num_entries = HTT_CMEM_BASE_SEND_NUM_ENTRIES_GET(*msg_word);
  3514. cmem_ba_lo = *(msg_word + 1);
  3515. cmem_ba_hi = *(msg_word + 2);
  3516. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO,
  3517. FL("CMEM FSE num_entries %u CMEM BA LO %x HI %x"),
  3518. num_entries, cmem_ba_lo, cmem_ba_hi);
  3519. dp_rx_fst_update_cmem_params(soc->dp_soc, num_entries,
  3520. cmem_ba_lo, cmem_ba_hi);
  3521. break;
  3522. }
  3523. case HTT_T2H_MSG_TYPE_TX_OFFLOAD_DELIVER_IND:
  3524. {
  3525. dp_offload_ind_handler(soc, msg_word);
  3526. break;
  3527. }
  3528. case HTT_T2H_MSG_TYPE_PEER_MAP_V3:
  3529. {
  3530. u_int8_t mac_addr_deswizzle_buf[QDF_MAC_ADDR_SIZE];
  3531. u_int8_t *peer_mac_addr;
  3532. u_int16_t peer_id;
  3533. u_int16_t hw_peer_id;
  3534. u_int8_t vdev_id;
  3535. uint8_t is_wds;
  3536. u_int16_t ast_hash = 0;
  3537. peer_id = HTT_RX_PEER_MAP_V3_SW_PEER_ID_GET(*msg_word);
  3538. vdev_id = HTT_RX_PEER_MAP_V3_VDEV_ID_GET(*msg_word);
  3539. peer_mac_addr =
  3540. htt_t2h_mac_addr_deswizzle((u_int8_t *)(msg_word + 1),
  3541. &mac_addr_deswizzle_buf[0]);
  3542. hw_peer_id = HTT_RX_PEER_MAP_V3_HW_PEER_ID_GET(*(msg_word + 3));
  3543. ast_hash = HTT_RX_PEER_MAP_V3_CACHE_SET_NUM_GET(*(msg_word + 3));
  3544. is_wds = HTT_RX_PEER_MAP_V3_NEXT_HOP_GET(*(msg_word + 4));
  3545. dp_htt_info("HTT_T2H_MSG_TYPE_PEER_MAP_V3 msg for peer id %d vdev id %d n",
  3546. peer_id, vdev_id);
  3547. dp_rx_peer_map_handler(soc->dp_soc, peer_id,
  3548. hw_peer_id, vdev_id,
  3549. peer_mac_addr, ast_hash,
  3550. is_wds);
  3551. break;
  3552. }
  3553. case HTT_T2H_MSG_TYPE_PRIMARY_LINK_PEER_MIGRATE_IND:
  3554. {
  3555. dp_htt_t2h_primary_link_migration(soc, msg_word);
  3556. break;
  3557. }
  3558. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_MAP:
  3559. {
  3560. dp_htt_mlo_peer_map_handler(soc, msg_word);
  3561. break;
  3562. }
  3563. case HTT_T2H_MSG_TYPE_MLO_RX_PEER_UNMAP:
  3564. {
  3565. dp_htt_mlo_peer_unmap_handler(soc, msg_word);
  3566. break;
  3567. }
  3568. case HTT_T2H_MSG_TYPE_MLO_TIMESTAMP_OFFSET_IND:
  3569. {
  3570. dp_rx_mlo_timestamp_ind_handler(soc->dp_soc, msg_word);
  3571. break;
  3572. }
  3573. case HTT_T2H_MSG_TYPE_VDEVS_TXRX_STATS_PERIODIC_IND:
  3574. {
  3575. dp_vdev_txrx_hw_stats_handler(soc, msg_word);
  3576. break;
  3577. }
  3578. case HTT_T2H_SAWF_DEF_QUEUES_MAP_REPORT_CONF:
  3579. {
  3580. dp_sawf_def_queues_update_map_report_conf(soc, msg_word,
  3581. htt_t2h_msg);
  3582. break;
  3583. }
  3584. case HTT_T2H_SAWF_MSDUQ_INFO_IND:
  3585. {
  3586. dp_sawf_msduq_map(soc, msg_word, htt_t2h_msg);
  3587. break;
  3588. }
  3589. case HTT_T2H_MSG_TYPE_STREAMING_STATS_IND:
  3590. {
  3591. dp_sawf_mpdu_stats_handler(soc, htt_t2h_msg);
  3592. break;
  3593. }
  3594. case HTT_T2H_MSG_TYPE_RX_CCE_SUPER_RULE_SETUP_DONE:
  3595. {
  3596. dp_ipa_rx_cce_super_rule_setup_done_handler(soc, msg_word);
  3597. break;
  3598. }
  3599. default:
  3600. break;
  3601. };
  3602. /* Free the indication buffer */
  3603. if (free_buf)
  3604. qdf_nbuf_free(htt_t2h_msg);
  3605. }
  3606. enum htc_send_full_action
  3607. dp_htt_h2t_full(void *context, HTC_PACKET *pkt)
  3608. {
  3609. return HTC_SEND_FULL_KEEP;
  3610. }
  3611. QDF_STATUS
  3612. dp_htt_hif_t2h_hp_callback (void *context, qdf_nbuf_t nbuf, uint8_t pipe_id)
  3613. {
  3614. QDF_STATUS rc = QDF_STATUS_SUCCESS;
  3615. HTC_PACKET htc_pkt;
  3616. qdf_assert_always(pipe_id == DP_HTT_T2H_HP_PIPE);
  3617. qdf_mem_zero(&htc_pkt, sizeof(htc_pkt));
  3618. htc_pkt.Status = QDF_STATUS_SUCCESS;
  3619. htc_pkt.pPktContext = (void *)nbuf;
  3620. dp_htt_t2h_msg_handler(context, &htc_pkt);
  3621. return rc;
  3622. }
  3623. /**
  3624. * htt_htc_soc_attach() - Register SOC level HTT instance with HTC
  3625. * @soc: HTT SOC handle
  3626. *
  3627. * Return: QDF_STATUS
  3628. */
  3629. static QDF_STATUS
  3630. htt_htc_soc_attach(struct htt_soc *soc)
  3631. {
  3632. struct htc_service_connect_req connect;
  3633. struct htc_service_connect_resp response;
  3634. QDF_STATUS status;
  3635. struct dp_soc *dpsoc = soc->dp_soc;
  3636. qdf_mem_zero(&connect, sizeof(connect));
  3637. qdf_mem_zero(&response, sizeof(response));
  3638. connect.pMetaData = NULL;
  3639. connect.MetaDataLength = 0;
  3640. connect.EpCallbacks.pContext = soc;
  3641. connect.EpCallbacks.EpTxComplete = dp_htt_h2t_send_complete;
  3642. connect.EpCallbacks.EpTxCompleteMultiple = NULL;
  3643. connect.EpCallbacks.EpRecv = dp_htt_t2h_msg_handler;
  3644. /* rx buffers currently are provided by HIF, not by EpRecvRefill */
  3645. connect.EpCallbacks.EpRecvRefill = NULL;
  3646. /* N/A, fill is done by HIF */
  3647. connect.EpCallbacks.RecvRefillWaterMark = 1;
  3648. connect.EpCallbacks.EpSendFull = dp_htt_h2t_full;
  3649. /*
  3650. * Specify how deep to let a queue get before htc_send_pkt will
  3651. * call the EpSendFull function due to excessive send queue depth.
  3652. */
  3653. connect.MaxSendQueueDepth = DP_HTT_MAX_SEND_QUEUE_DEPTH;
  3654. /* disable flow control for HTT data message service */
  3655. connect.ConnectionFlags |= HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL;
  3656. /* connect to control service */
  3657. connect.service_id = HTT_DATA_MSG_SVC;
  3658. status = htc_connect_service(soc->htc_soc, &connect, &response);
  3659. if (status != QDF_STATUS_SUCCESS)
  3660. return status;
  3661. soc->htc_endpoint = response.Endpoint;
  3662. hif_save_htc_htt_config_endpoint(dpsoc->hif_handle, soc->htc_endpoint);
  3663. htt_interface_logging_init(&soc->htt_logger_handle, soc->ctrl_psoc);
  3664. dp_hif_update_pipe_callback(soc->dp_soc, (void *)soc,
  3665. dp_htt_hif_t2h_hp_callback, DP_HTT_T2H_HP_PIPE);
  3666. return QDF_STATUS_SUCCESS; /* success */
  3667. }
  3668. void *
  3669. htt_soc_initialize(struct htt_soc *htt_soc,
  3670. struct cdp_ctrl_objmgr_psoc *ctrl_psoc,
  3671. HTC_HANDLE htc_soc,
  3672. hal_soc_handle_t hal_soc_hdl, qdf_device_t osdev)
  3673. {
  3674. struct htt_soc *soc = (struct htt_soc *)htt_soc;
  3675. soc->osdev = osdev;
  3676. soc->ctrl_psoc = ctrl_psoc;
  3677. soc->htc_soc = htc_soc;
  3678. soc->hal_soc = hal_soc_hdl;
  3679. if (htt_htc_soc_attach(soc))
  3680. goto fail2;
  3681. return soc;
  3682. fail2:
  3683. return NULL;
  3684. }
  3685. void htt_soc_htc_dealloc(struct htt_soc *htt_handle)
  3686. {
  3687. htt_interface_logging_deinit(htt_handle->htt_logger_handle);
  3688. htt_htc_misc_pkt_pool_free(htt_handle);
  3689. htt_htc_pkt_pool_free(htt_handle);
  3690. }
  3691. QDF_STATUS htt_soc_htc_prealloc(struct htt_soc *soc)
  3692. {
  3693. int i;
  3694. soc->htt_htc_pkt_freelist = NULL;
  3695. /* pre-allocate some HTC_PACKET objects */
  3696. for (i = 0; i < HTT_HTC_PKT_POOL_INIT_SIZE; i++) {
  3697. struct dp_htt_htc_pkt_union *pkt;
  3698. pkt = qdf_mem_malloc(sizeof(*pkt));
  3699. if (!pkt)
  3700. return QDF_STATUS_E_NOMEM;
  3701. htt_htc_pkt_free(soc, &pkt->u.pkt);
  3702. }
  3703. return QDF_STATUS_SUCCESS;
  3704. }
  3705. void htt_soc_detach(struct htt_soc *htt_hdl)
  3706. {
  3707. int i;
  3708. struct htt_soc *htt_handle = (struct htt_soc *)htt_hdl;
  3709. for (i = 0; i < MAX_PDEV_CNT; i++) {
  3710. qdf_mem_free(htt_handle->pdevid_tt[i].umac_path);
  3711. qdf_mem_free(htt_handle->pdevid_tt[i].lmac_path);
  3712. }
  3713. HTT_TX_MUTEX_DESTROY(&htt_handle->htt_tx_mutex);
  3714. qdf_mem_free(htt_handle);
  3715. }
  3716. /**
  3717. * dp_h2t_ext_stats_msg_send(): function to construct HTT message to pass to FW
  3718. * @pdev: DP PDEV handle
  3719. * @stats_type_upload_mask: stats type requested by user
  3720. * @config_param_0: extra configuration parameters
  3721. * @config_param_1: extra configuration parameters
  3722. * @config_param_2: extra configuration parameters
  3723. * @config_param_3: extra configuration parameters
  3724. * @cookie_val: cookie value
  3725. * @cookie_msb: msb of debug status cookie
  3726. * @mac_id: mac number
  3727. *
  3728. * return: QDF STATUS
  3729. */
  3730. QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
  3731. uint32_t stats_type_upload_mask, uint32_t config_param_0,
  3732. uint32_t config_param_1, uint32_t config_param_2,
  3733. uint32_t config_param_3, int cookie_val, int cookie_msb,
  3734. uint8_t mac_id)
  3735. {
  3736. struct htt_soc *soc = pdev->soc->htt_handle;
  3737. struct dp_htt_htc_pkt *pkt;
  3738. qdf_nbuf_t msg;
  3739. uint32_t *msg_word;
  3740. uint8_t pdev_mask = 0;
  3741. uint8_t *htt_logger_bufp;
  3742. int mac_for_pdev;
  3743. int target_pdev_id;
  3744. QDF_STATUS status;
  3745. msg = qdf_nbuf_alloc(
  3746. soc->osdev,
  3747. HTT_MSG_BUF_SIZE(HTT_H2T_EXT_STATS_REQ_MSG_SZ),
  3748. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3749. if (!msg)
  3750. return QDF_STATUS_E_NOMEM;
  3751. /*TODO:Add support for SOC stats
  3752. * Bit 0: SOC Stats
  3753. * Bit 1: Pdev stats for pdev id 0
  3754. * Bit 2: Pdev stats for pdev id 1
  3755. * Bit 3: Pdev stats for pdev id 2
  3756. */
  3757. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3758. target_pdev_id =
  3759. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3760. pdev_mask = 1 << target_pdev_id;
  3761. /*
  3762. * Set the length of the message.
  3763. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3764. * separately during the below call to qdf_nbuf_push_head.
  3765. * The contribution from the HTC header is added separately inside HTC.
  3766. */
  3767. if (qdf_nbuf_put_tail(msg, HTT_H2T_EXT_STATS_REQ_MSG_SZ) == NULL) {
  3768. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3769. "Failed to expand head for HTT_EXT_STATS");
  3770. qdf_nbuf_free(msg);
  3771. return QDF_STATUS_E_FAILURE;
  3772. }
  3773. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  3774. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3775. htt_logger_bufp = (uint8_t *)msg_word;
  3776. *msg_word = 0;
  3777. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_EXT_STATS_REQ);
  3778. HTT_H2T_EXT_STATS_REQ_PDEV_MASK_SET(*msg_word, pdev_mask);
  3779. HTT_H2T_EXT_STATS_REQ_STATS_TYPE_SET(*msg_word, stats_type_upload_mask);
  3780. /* word 1 */
  3781. msg_word++;
  3782. *msg_word = 0;
  3783. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_0);
  3784. /* word 2 */
  3785. msg_word++;
  3786. *msg_word = 0;
  3787. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_1);
  3788. /* word 3 */
  3789. msg_word++;
  3790. *msg_word = 0;
  3791. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_2);
  3792. /* word 4 */
  3793. msg_word++;
  3794. *msg_word = 0;
  3795. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, config_param_3);
  3796. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, 0);
  3797. /* word 5 */
  3798. msg_word++;
  3799. /* word 6 */
  3800. msg_word++;
  3801. *msg_word = 0;
  3802. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_val);
  3803. /* word 7 */
  3804. msg_word++;
  3805. *msg_word = 0;
  3806. /* Currently Using last 2 bits for pdev_id
  3807. * For future reference, reserving 3 bits in cookie_msb for pdev_id
  3808. */
  3809. cookie_msb = (cookie_msb | pdev->pdev_id);
  3810. HTT_H2T_EXT_STATS_REQ_CONFIG_PARAM_SET(*msg_word, cookie_msb);
  3811. pkt = htt_htc_pkt_alloc(soc);
  3812. if (!pkt) {
  3813. qdf_nbuf_free(msg);
  3814. return QDF_STATUS_E_NOMEM;
  3815. }
  3816. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3817. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3818. dp_htt_h2t_send_complete_free_netbuf,
  3819. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3820. soc->htc_endpoint,
  3821. /* tag for FW response msg not guaranteed */
  3822. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3823. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3824. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_EXT_STATS_REQ,
  3825. htt_logger_bufp);
  3826. if (status != QDF_STATUS_SUCCESS) {
  3827. qdf_nbuf_free(msg);
  3828. htt_htc_pkt_free(soc, pkt);
  3829. }
  3830. return status;
  3831. }
  3832. #ifdef QCA_VDEV_STATS_HW_OFFLOAD_SUPPORT
  3833. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK 0xFFFFFFFF
  3834. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK 0xFFFFFFFF00000000
  3835. #define HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT 32
  3836. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3837. uint8_t pdev_id, bool enable,
  3838. bool reset, uint64_t reset_bitmask)
  3839. {
  3840. struct htt_soc *soc = dpsoc->htt_handle;
  3841. struct dp_htt_htc_pkt *pkt;
  3842. qdf_nbuf_t msg;
  3843. uint32_t *msg_word;
  3844. uint8_t *htt_logger_bufp;
  3845. QDF_STATUS status;
  3846. int duration;
  3847. uint32_t bitmask;
  3848. int target_pdev_id;
  3849. msg = qdf_nbuf_alloc(
  3850. soc->osdev,
  3851. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_vdevs_txrx_stats_cfg)),
  3852. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  3853. if (!msg) {
  3854. dp_htt_err("%pK: Fail to allocate "
  3855. "HTT_H2T_HW_VDEV_TXRX_STATS_CFG_MSG_SZ msg buffer", dpsoc);
  3856. return QDF_STATUS_E_NOMEM;
  3857. }
  3858. if (pdev_id != INVALID_PDEV_ID)
  3859. target_pdev_id = DP_SW2HW_MACID(pdev_id);
  3860. else
  3861. target_pdev_id = 0;
  3862. duration =
  3863. wlan_cfg_get_vdev_stats_hw_offload_timer(dpsoc->wlan_cfg_ctx);
  3864. /*
  3865. * Set the length of the message.
  3866. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3867. * separately during the below call to qdf_nbuf_push_head.
  3868. * The contribution from the HTC header is added separately inside HTC.
  3869. */
  3870. if (!qdf_nbuf_put_tail(msg,
  3871. sizeof(struct htt_h2t_vdevs_txrx_stats_cfg))) {
  3872. dp_htt_err("%pK: Failed to expand head for HTT_HW_VDEV_STATS"
  3873. , dpsoc);
  3874. qdf_nbuf_free(msg);
  3875. return QDF_STATUS_E_FAILURE;
  3876. }
  3877. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3878. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3879. htt_logger_bufp = (uint8_t *)msg_word;
  3880. *msg_word = 0;
  3881. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG);
  3882. HTT_RX_VDEVS_TXRX_STATS_PDEV_ID_SET(*msg_word, target_pdev_id);
  3883. HTT_RX_VDEVS_TXRX_STATS_ENABLE_SET(*msg_word, enable);
  3884. HTT_RX_VDEVS_TXRX_STATS_PERIODIC_INTERVAL_SET(*msg_word,
  3885. (duration >> 3));
  3886. HTT_RX_VDEVS_TXRX_STATS_RESET_STATS_BITS_SET(*msg_word, reset);
  3887. msg_word++;
  3888. *msg_word = 0;
  3889. bitmask = (reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_L32_MASK);
  3890. *msg_word = bitmask;
  3891. msg_word++;
  3892. *msg_word = 0;
  3893. bitmask =
  3894. ((reset_bitmask & HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_MASK) >>
  3895. HTT_VDEV_TXRX_STATS_RESET_BITMASK_U32_SHIFT);
  3896. *msg_word = bitmask;
  3897. pkt = htt_htc_pkt_alloc(soc);
  3898. if (!pkt) {
  3899. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer",
  3900. dpsoc);
  3901. qdf_assert(0);
  3902. qdf_nbuf_free(msg);
  3903. return QDF_STATUS_E_NOMEM;
  3904. }
  3905. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3906. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  3907. dp_htt_h2t_send_complete_free_netbuf,
  3908. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  3909. soc->htc_endpoint,
  3910. /* tag for no FW response msg */
  3911. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  3912. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  3913. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  3914. HTT_H2T_MSG_TYPE_VDEVS_TXRX_STATS_CFG,
  3915. htt_logger_bufp);
  3916. if (status != QDF_STATUS_SUCCESS) {
  3917. qdf_nbuf_free(msg);
  3918. htt_htc_pkt_free(soc, pkt);
  3919. }
  3920. return status;
  3921. }
  3922. #else
  3923. QDF_STATUS dp_h2t_hw_vdev_stats_config_send(struct dp_soc *dpsoc,
  3924. uint8_t pdev_id, bool enable,
  3925. bool reset, uint64_t reset_bitmask)
  3926. {
  3927. return QDF_STATUS_SUCCESS;
  3928. }
  3929. #endif
  3930. /**
  3931. * dp_h2t_3tuple_config_send(): function to construct 3 tuple configuration
  3932. * HTT message to pass to FW
  3933. * @pdev: DP PDEV handle
  3934. * @tuple_mask: tuple configuration to report 3 tuple hash value in either
  3935. * toeplitz_2_or_4 or flow_id_toeplitz in MSDU START TLV.
  3936. * @mac_id: mac id
  3937. *
  3938. * tuple_mask[1:0]:
  3939. * 00 - Do not report 3 tuple hash value
  3940. * 10 - Report 3 tuple hash value in toeplitz_2_or_4
  3941. * 01 - Report 3 tuple hash value in flow_id_toeplitz
  3942. * 11 - Report 3 tuple hash value in both toeplitz_2_or_4 & flow_id_toeplitz
  3943. *
  3944. * return: QDF STATUS
  3945. */
  3946. QDF_STATUS dp_h2t_3tuple_config_send(struct dp_pdev *pdev,
  3947. uint32_t tuple_mask, uint8_t mac_id)
  3948. {
  3949. struct htt_soc *soc = pdev->soc->htt_handle;
  3950. struct dp_htt_htc_pkt *pkt;
  3951. qdf_nbuf_t msg;
  3952. uint32_t *msg_word;
  3953. uint8_t *htt_logger_bufp;
  3954. int mac_for_pdev;
  3955. int target_pdev_id;
  3956. msg = qdf_nbuf_alloc(
  3957. soc->osdev,
  3958. HTT_MSG_BUF_SIZE(HTT_3_TUPLE_HASH_CFG_REQ_BYTES),
  3959. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  3960. if (!msg)
  3961. return QDF_STATUS_E_NOMEM;
  3962. mac_for_pdev = dp_get_mac_id_for_pdev(mac_id, pdev->pdev_id);
  3963. target_pdev_id =
  3964. dp_get_target_pdev_id_for_host_pdev_id(pdev->soc, mac_for_pdev);
  3965. /*
  3966. * Set the length of the message.
  3967. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  3968. * separately during the below call to qdf_nbuf_push_head.
  3969. * The contribution from the HTC header is added separately inside HTC.
  3970. */
  3971. if (!qdf_nbuf_put_tail(msg, HTT_3_TUPLE_HASH_CFG_REQ_BYTES)) {
  3972. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  3973. "Failed to expand head for HTT_3TUPLE_CONFIG");
  3974. qdf_nbuf_free(msg);
  3975. return QDF_STATUS_E_FAILURE;
  3976. }
  3977. dp_htt_info("%pK: config_param_sent 0x%x for target_pdev %d\n -------------",
  3978. pdev->soc, tuple_mask, target_pdev_id);
  3979. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  3980. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  3981. htt_logger_bufp = (uint8_t *)msg_word;
  3982. *msg_word = 0;
  3983. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG);
  3984. HTT_RX_3_TUPLE_HASH_PDEV_ID_SET(*msg_word, target_pdev_id);
  3985. msg_word++;
  3986. *msg_word = 0;
  3987. HTT_H2T_FLOW_ID_TOEPLITZ_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3988. HTT_H2T_TOEPLITZ_2_OR_4_FIELD_CONFIG_SET(*msg_word, tuple_mask);
  3989. pkt = htt_htc_pkt_alloc(soc);
  3990. if (!pkt) {
  3991. qdf_nbuf_free(msg);
  3992. return QDF_STATUS_E_NOMEM;
  3993. }
  3994. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  3995. SET_HTC_PACKET_INFO_TX(
  3996. &pkt->htc_pkt,
  3997. dp_htt_h2t_send_complete_free_netbuf,
  3998. qdf_nbuf_data(msg),
  3999. qdf_nbuf_len(msg),
  4000. soc->htc_endpoint,
  4001. /* tag for no FW response msg */
  4002. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4003. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4004. DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_3_TUPLE_HASH_CFG,
  4005. htt_logger_bufp);
  4006. return QDF_STATUS_SUCCESS;
  4007. }
  4008. /* This macro will revert once proper HTT header will define for
  4009. * HTT_H2T_MSG_TYPE_PPDU_STATS_CFG in htt.h file
  4010. * */
  4011. #if defined(WDI_EVENT_ENABLE)
  4012. QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
  4013. uint32_t stats_type_upload_mask, uint8_t mac_id)
  4014. {
  4015. struct htt_soc *soc = pdev->soc->htt_handle;
  4016. struct dp_htt_htc_pkt *pkt;
  4017. qdf_nbuf_t msg;
  4018. uint32_t *msg_word;
  4019. uint8_t pdev_mask;
  4020. QDF_STATUS status;
  4021. msg = qdf_nbuf_alloc(
  4022. soc->osdev,
  4023. HTT_MSG_BUF_SIZE(HTT_H2T_PPDU_STATS_CFG_MSG_SZ),
  4024. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, true);
  4025. if (!msg) {
  4026. dp_htt_err("%pK: Fail to allocate HTT_H2T_PPDU_STATS_CFG_MSG_SZ msg buffer"
  4027. , pdev->soc);
  4028. qdf_assert(0);
  4029. return QDF_STATUS_E_NOMEM;
  4030. }
  4031. /*TODO:Add support for SOC stats
  4032. * Bit 0: SOC Stats
  4033. * Bit 1: Pdev stats for pdev id 0
  4034. * Bit 2: Pdev stats for pdev id 1
  4035. * Bit 3: Pdev stats for pdev id 2
  4036. */
  4037. pdev_mask = 1 << dp_get_target_pdev_id_for_host_pdev_id(pdev->soc,
  4038. mac_id);
  4039. /*
  4040. * Set the length of the message.
  4041. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4042. * separately during the below call to qdf_nbuf_push_head.
  4043. * The contribution from the HTC header is added separately inside HTC.
  4044. */
  4045. if (qdf_nbuf_put_tail(msg, HTT_H2T_PPDU_STATS_CFG_MSG_SZ) == NULL) {
  4046. dp_htt_err("%pK: Failed to expand head for HTT_CFG_STATS"
  4047. , pdev->soc);
  4048. qdf_nbuf_free(msg);
  4049. return QDF_STATUS_E_FAILURE;
  4050. }
  4051. msg_word = (uint32_t *) qdf_nbuf_data(msg);
  4052. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4053. *msg_word = 0;
  4054. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG);
  4055. HTT_H2T_PPDU_STATS_CFG_PDEV_MASK_SET(*msg_word, pdev_mask);
  4056. HTT_H2T_PPDU_STATS_CFG_TLV_BITMASK_SET(*msg_word,
  4057. stats_type_upload_mask);
  4058. pkt = htt_htc_pkt_alloc(soc);
  4059. if (!pkt) {
  4060. dp_htt_err("%pK: Fail to allocate dp_htt_htc_pkt buffer", pdev->soc);
  4061. qdf_assert(0);
  4062. qdf_nbuf_free(msg);
  4063. return QDF_STATUS_E_NOMEM;
  4064. }
  4065. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4066. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4067. dp_htt_h2t_send_complete_free_netbuf,
  4068. qdf_nbuf_data(msg), qdf_nbuf_len(msg),
  4069. soc->htc_endpoint,
  4070. /* tag for no FW response msg */
  4071. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4072. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4073. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_PPDU_STATS_CFG,
  4074. (uint8_t *)msg_word);
  4075. if (status != QDF_STATUS_SUCCESS) {
  4076. qdf_nbuf_free(msg);
  4077. htt_htc_pkt_free(soc, pkt);
  4078. }
  4079. return status;
  4080. }
  4081. qdf_export_symbol(dp_h2t_cfg_stats_msg_send);
  4082. #endif
  4083. void
  4084. dp_peer_update_inactive_time(struct dp_pdev *pdev, uint32_t tag_type,
  4085. uint32_t *tag_buf)
  4086. {
  4087. struct dp_peer *peer = NULL;
  4088. switch (tag_type) {
  4089. case HTT_STATS_PEER_DETAILS_TAG:
  4090. {
  4091. htt_peer_details_tlv *dp_stats_buf =
  4092. (htt_peer_details_tlv *)tag_buf;
  4093. pdev->fw_stats_peer_id = dp_stats_buf->sw_peer_id;
  4094. }
  4095. break;
  4096. case HTT_STATS_PEER_STATS_CMN_TAG:
  4097. {
  4098. htt_peer_stats_cmn_tlv *dp_stats_buf =
  4099. (htt_peer_stats_cmn_tlv *)tag_buf;
  4100. peer = dp_peer_get_ref_by_id(pdev->soc, pdev->fw_stats_peer_id,
  4101. DP_MOD_ID_HTT);
  4102. if (peer && !peer->bss_peer) {
  4103. peer->stats.tx.inactive_time =
  4104. dp_stats_buf->inactive_time;
  4105. qdf_event_set(&pdev->fw_peer_stats_event);
  4106. }
  4107. if (peer)
  4108. dp_peer_unref_delete(peer, DP_MOD_ID_HTT);
  4109. }
  4110. break;
  4111. default:
  4112. qdf_err("Invalid tag_type");
  4113. }
  4114. }
  4115. QDF_STATUS
  4116. dp_htt_rx_flow_fst_setup(struct dp_pdev *pdev,
  4117. struct dp_htt_rx_flow_fst_setup *fse_setup_info)
  4118. {
  4119. struct htt_soc *soc = pdev->soc->htt_handle;
  4120. struct dp_htt_htc_pkt *pkt;
  4121. qdf_nbuf_t msg;
  4122. u_int32_t *msg_word;
  4123. struct htt_h2t_msg_rx_fse_setup_t *fse_setup;
  4124. uint8_t *htt_logger_bufp;
  4125. u_int32_t *key;
  4126. QDF_STATUS status;
  4127. msg = qdf_nbuf_alloc(
  4128. soc->osdev,
  4129. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_setup_t)),
  4130. /* reserve room for the HTC header */
  4131. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4132. if (!msg)
  4133. return QDF_STATUS_E_NOMEM;
  4134. /*
  4135. * Set the length of the message.
  4136. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4137. * separately during the below call to qdf_nbuf_push_head.
  4138. * The contribution from the HTC header is added separately inside HTC.
  4139. */
  4140. if (!qdf_nbuf_put_tail(msg,
  4141. sizeof(struct htt_h2t_msg_rx_fse_setup_t))) {
  4142. qdf_err("Failed to expand head for HTT RX_FSE_SETUP msg");
  4143. return QDF_STATUS_E_FAILURE;
  4144. }
  4145. /* fill in the message contents */
  4146. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4147. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_setup_t));
  4148. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4149. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4150. htt_logger_bufp = (uint8_t *)msg_word;
  4151. *msg_word = 0;
  4152. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG);
  4153. fse_setup = (struct htt_h2t_msg_rx_fse_setup_t *)msg_word;
  4154. HTT_RX_FSE_SETUP_PDEV_ID_SET(*msg_word, fse_setup_info->pdev_id);
  4155. msg_word++;
  4156. HTT_RX_FSE_SETUP_NUM_REC_SET(*msg_word, fse_setup_info->max_entries);
  4157. HTT_RX_FSE_SETUP_MAX_SEARCH_SET(*msg_word, fse_setup_info->max_search);
  4158. HTT_RX_FSE_SETUP_IP_DA_SA_PREFIX_SET(*msg_word,
  4159. fse_setup_info->ip_da_sa_prefix);
  4160. msg_word++;
  4161. HTT_RX_FSE_SETUP_BASE_ADDR_LO_SET(*msg_word,
  4162. fse_setup_info->base_addr_lo);
  4163. msg_word++;
  4164. HTT_RX_FSE_SETUP_BASE_ADDR_HI_SET(*msg_word,
  4165. fse_setup_info->base_addr_hi);
  4166. key = (u_int32_t *)fse_setup_info->hash_key;
  4167. fse_setup->toeplitz31_0 = *key++;
  4168. fse_setup->toeplitz63_32 = *key++;
  4169. fse_setup->toeplitz95_64 = *key++;
  4170. fse_setup->toeplitz127_96 = *key++;
  4171. fse_setup->toeplitz159_128 = *key++;
  4172. fse_setup->toeplitz191_160 = *key++;
  4173. fse_setup->toeplitz223_192 = *key++;
  4174. fse_setup->toeplitz255_224 = *key++;
  4175. fse_setup->toeplitz287_256 = *key++;
  4176. fse_setup->toeplitz314_288 = *key;
  4177. msg_word++;
  4178. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz31_0);
  4179. msg_word++;
  4180. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz63_32);
  4181. msg_word++;
  4182. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz95_64);
  4183. msg_word++;
  4184. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz127_96);
  4185. msg_word++;
  4186. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz159_128);
  4187. msg_word++;
  4188. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz191_160);
  4189. msg_word++;
  4190. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz223_192);
  4191. msg_word++;
  4192. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz255_224);
  4193. msg_word++;
  4194. HTT_RX_FSE_SETUP_HASH_VALUE_SET(*msg_word, fse_setup->toeplitz287_256);
  4195. msg_word++;
  4196. HTT_RX_FSE_SETUP_HASH_314_288_SET(*msg_word,
  4197. fse_setup->toeplitz314_288);
  4198. pkt = htt_htc_pkt_alloc(soc);
  4199. if (!pkt) {
  4200. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4201. qdf_assert(0);
  4202. qdf_nbuf_free(msg);
  4203. return QDF_STATUS_E_RESOURCES; /* failure */
  4204. }
  4205. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4206. SET_HTC_PACKET_INFO_TX(
  4207. &pkt->htc_pkt,
  4208. dp_htt_h2t_send_complete_free_netbuf,
  4209. qdf_nbuf_data(msg),
  4210. qdf_nbuf_len(msg),
  4211. soc->htc_endpoint,
  4212. /* tag for no FW response msg */
  4213. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4214. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4215. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4216. HTT_H2T_MSG_TYPE_RX_FSE_SETUP_CFG,
  4217. htt_logger_bufp);
  4218. if (status == QDF_STATUS_SUCCESS) {
  4219. dp_info("HTT_H2T RX_FSE_SETUP sent to FW for pdev = %u",
  4220. fse_setup_info->pdev_id);
  4221. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
  4222. (void *)fse_setup_info->hash_key,
  4223. fse_setup_info->hash_key_len);
  4224. } else {
  4225. qdf_nbuf_free(msg);
  4226. htt_htc_pkt_free(soc, pkt);
  4227. }
  4228. return status;
  4229. }
  4230. QDF_STATUS
  4231. dp_htt_rx_flow_fse_operation(struct dp_pdev *pdev,
  4232. struct dp_htt_rx_flow_fst_operation *fse_op_info)
  4233. {
  4234. struct htt_soc *soc = pdev->soc->htt_handle;
  4235. struct dp_htt_htc_pkt *pkt;
  4236. qdf_nbuf_t msg;
  4237. u_int32_t *msg_word;
  4238. struct htt_h2t_msg_rx_fse_operation_t *fse_operation;
  4239. uint8_t *htt_logger_bufp;
  4240. QDF_STATUS status;
  4241. msg = qdf_nbuf_alloc(
  4242. soc->osdev,
  4243. HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_rx_fse_operation_t)),
  4244. /* reserve room for the HTC header */
  4245. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING, 4, TRUE);
  4246. if (!msg)
  4247. return QDF_STATUS_E_NOMEM;
  4248. /*
  4249. * Set the length of the message.
  4250. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4251. * separately during the below call to qdf_nbuf_push_head.
  4252. * The contribution from the HTC header is added separately inside HTC.
  4253. */
  4254. if (!qdf_nbuf_put_tail(msg,
  4255. sizeof(struct htt_h2t_msg_rx_fse_operation_t))) {
  4256. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4257. qdf_nbuf_free(msg);
  4258. return QDF_STATUS_E_FAILURE;
  4259. }
  4260. /* fill in the message contents */
  4261. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4262. memset(msg_word, 0, sizeof(struct htt_h2t_msg_rx_fse_operation_t));
  4263. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4264. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4265. htt_logger_bufp = (uint8_t *)msg_word;
  4266. *msg_word = 0;
  4267. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG);
  4268. fse_operation = (struct htt_h2t_msg_rx_fse_operation_t *)msg_word;
  4269. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, fse_op_info->pdev_id);
  4270. msg_word++;
  4271. HTT_RX_FSE_IPSEC_VALID_SET(*msg_word, false);
  4272. if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_ENTRY) {
  4273. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4274. HTT_RX_FSE_CACHE_INVALIDATE_ENTRY);
  4275. msg_word++;
  4276. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4277. *msg_word,
  4278. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_31_0));
  4279. msg_word++;
  4280. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4281. *msg_word,
  4282. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_63_32));
  4283. msg_word++;
  4284. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4285. *msg_word,
  4286. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_95_64));
  4287. msg_word++;
  4288. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4289. *msg_word,
  4290. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.src_ip_127_96));
  4291. msg_word++;
  4292. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4293. *msg_word,
  4294. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_31_0));
  4295. msg_word++;
  4296. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4297. *msg_word,
  4298. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_63_32));
  4299. msg_word++;
  4300. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4301. *msg_word,
  4302. qdf_htonl(fse_op_info->rx_flow->flow_tuple_info.dest_ip_95_64));
  4303. msg_word++;
  4304. HTT_RX_FSE_OPERATION_IP_ADDR_SET(
  4305. *msg_word,
  4306. qdf_htonl(
  4307. fse_op_info->rx_flow->flow_tuple_info.dest_ip_127_96));
  4308. msg_word++;
  4309. HTT_RX_FSE_SOURCEPORT_SET(
  4310. *msg_word,
  4311. fse_op_info->rx_flow->flow_tuple_info.src_port);
  4312. HTT_RX_FSE_DESTPORT_SET(
  4313. *msg_word,
  4314. fse_op_info->rx_flow->flow_tuple_info.dest_port);
  4315. msg_word++;
  4316. HTT_RX_FSE_L4_PROTO_SET(
  4317. *msg_word,
  4318. fse_op_info->rx_flow->flow_tuple_info.l4_protocol);
  4319. } else if (fse_op_info->op_code == DP_HTT_FST_CACHE_INVALIDATE_FULL) {
  4320. HTT_RX_FSE_OPERATION_SET(*msg_word,
  4321. HTT_RX_FSE_CACHE_INVALIDATE_FULL);
  4322. } else if (fse_op_info->op_code == DP_HTT_FST_DISABLE) {
  4323. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_DISABLE);
  4324. } else if (fse_op_info->op_code == DP_HTT_FST_ENABLE) {
  4325. HTT_RX_FSE_OPERATION_SET(*msg_word, HTT_RX_FSE_ENABLE);
  4326. }
  4327. pkt = htt_htc_pkt_alloc(soc);
  4328. if (!pkt) {
  4329. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4330. qdf_assert(0);
  4331. qdf_nbuf_free(msg);
  4332. return QDF_STATUS_E_RESOURCES; /* failure */
  4333. }
  4334. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4335. SET_HTC_PACKET_INFO_TX(
  4336. &pkt->htc_pkt,
  4337. dp_htt_h2t_send_complete_free_netbuf,
  4338. qdf_nbuf_data(msg),
  4339. qdf_nbuf_len(msg),
  4340. soc->htc_endpoint,
  4341. /* tag for no FW response msg */
  4342. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4343. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4344. status = DP_HTT_SEND_HTC_PKT(soc, pkt,
  4345. HTT_H2T_MSG_TYPE_RX_FSE_OPERATION_CFG,
  4346. htt_logger_bufp);
  4347. if (status == QDF_STATUS_SUCCESS) {
  4348. dp_info("HTT_H2T RX_FSE_OPERATION_CFG sent to FW for pdev = %u",
  4349. fse_op_info->pdev_id);
  4350. } else {
  4351. qdf_nbuf_free(msg);
  4352. htt_htc_pkt_free(soc, pkt);
  4353. }
  4354. return status;
  4355. }
  4356. /**
  4357. * dp_htt_rx_fisa_config(): Send HTT msg to configure FISA
  4358. * @pdev: DP pdev handle
  4359. * @fisa_config: Fisa config struct
  4360. *
  4361. * Return: Success when HTT message is sent, error on failure
  4362. */
  4363. QDF_STATUS
  4364. dp_htt_rx_fisa_config(struct dp_pdev *pdev,
  4365. struct dp_htt_rx_fisa_cfg *fisa_config)
  4366. {
  4367. struct htt_soc *soc = pdev->soc->htt_handle;
  4368. struct dp_htt_htc_pkt *pkt;
  4369. qdf_nbuf_t msg;
  4370. u_int32_t *msg_word;
  4371. struct htt_h2t_msg_type_fisa_config_t *htt_fisa_config;
  4372. uint8_t *htt_logger_bufp;
  4373. uint32_t len;
  4374. QDF_STATUS status;
  4375. len = HTT_MSG_BUF_SIZE(sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4376. msg = qdf_nbuf_alloc(soc->osdev,
  4377. len,
  4378. /* reserve room for the HTC header */
  4379. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4380. 4,
  4381. TRUE);
  4382. if (!msg)
  4383. return QDF_STATUS_E_NOMEM;
  4384. /*
  4385. * Set the length of the message.
  4386. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4387. * separately during the below call to qdf_nbuf_push_head.
  4388. * The contribution from the HTC header is added separately inside HTC.
  4389. */
  4390. if (!qdf_nbuf_put_tail(msg,
  4391. sizeof(struct htt_h2t_msg_type_fisa_config_t))) {
  4392. qdf_err("Failed to expand head for HTT_RX_FSE_OPERATION msg");
  4393. qdf_nbuf_free(msg);
  4394. return QDF_STATUS_E_FAILURE;
  4395. }
  4396. /* fill in the message contents */
  4397. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4398. memset(msg_word, 0, sizeof(struct htt_h2t_msg_type_fisa_config_t));
  4399. /* rewind beyond alignment pad to get to the HTC header reserved area */
  4400. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4401. htt_logger_bufp = (uint8_t *)msg_word;
  4402. *msg_word = 0;
  4403. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RX_FISA_CFG);
  4404. htt_fisa_config = (struct htt_h2t_msg_type_fisa_config_t *)msg_word;
  4405. HTT_RX_FSE_OPERATION_PDEV_ID_SET(*msg_word, htt_fisa_config->pdev_id);
  4406. msg_word++;
  4407. HTT_RX_FISA_CONFIG_FISA_V2_ENABLE_SET(*msg_word, 1);
  4408. HTT_RX_FISA_CONFIG_FISA_V2_AGGR_LIMIT_SET(*msg_word, 0xf);
  4409. msg_word++;
  4410. htt_fisa_config->fisa_timeout_threshold = fisa_config->fisa_timeout;
  4411. pkt = htt_htc_pkt_alloc(soc);
  4412. if (!pkt) {
  4413. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4414. qdf_assert(0);
  4415. qdf_nbuf_free(msg);
  4416. return QDF_STATUS_E_RESOURCES; /* failure */
  4417. }
  4418. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4419. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4420. dp_htt_h2t_send_complete_free_netbuf,
  4421. qdf_nbuf_data(msg),
  4422. qdf_nbuf_len(msg),
  4423. soc->htc_endpoint,
  4424. /* tag for no FW response msg */
  4425. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4426. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4427. status = DP_HTT_SEND_HTC_PKT(soc, pkt, HTT_H2T_MSG_TYPE_RX_FISA_CFG,
  4428. htt_logger_bufp);
  4429. if (status == QDF_STATUS_SUCCESS) {
  4430. dp_info("HTT_H2T_MSG_TYPE_RX_FISA_CFG sent to FW for pdev = %u",
  4431. fisa_config->pdev_id);
  4432. } else {
  4433. qdf_nbuf_free(msg);
  4434. htt_htc_pkt_free(soc, pkt);
  4435. }
  4436. return status;
  4437. }
  4438. #ifdef WLAN_SUPPORT_PPEDS
  4439. /**
  4440. * dp_htt_rxdma_rxole_ppe_cfg_set() - Send RxOLE and RxDMA PPE config
  4441. * @soc: Data path SoC handle
  4442. * @cfg: RxDMA and RxOLE PPE config
  4443. *
  4444. * Return: Success when HTT message is sent, error on failure
  4445. */
  4446. QDF_STATUS
  4447. dp_htt_rxdma_rxole_ppe_cfg_set(struct dp_soc *soc,
  4448. struct dp_htt_rxdma_rxole_ppe_config *cfg)
  4449. {
  4450. struct htt_soc *htt_handle = soc->htt_handle;
  4451. uint32_t len;
  4452. qdf_nbuf_t msg;
  4453. u_int32_t *msg_word;
  4454. QDF_STATUS status;
  4455. uint8_t *htt_logger_bufp;
  4456. struct dp_htt_htc_pkt *pkt;
  4457. len = HTT_MSG_BUF_SIZE(
  4458. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4459. msg = qdf_nbuf_alloc(soc->osdev,
  4460. len,
  4461. /* reserve room for the HTC header */
  4462. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4463. 4,
  4464. TRUE);
  4465. if (!msg)
  4466. return QDF_STATUS_E_NOMEM;
  4467. /*
  4468. * Set the length of the message.
  4469. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4470. * separately during the below call to qdf_nbuf_push_head.
  4471. * The contribution from the HTC header is added separately inside HTC.
  4472. */
  4473. if (!qdf_nbuf_put_tail(
  4474. msg, sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t))) {
  4475. qdf_err("Failed to expand head for HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG msg");
  4476. qdf_nbuf_free(msg);
  4477. return QDF_STATUS_E_FAILURE;
  4478. }
  4479. /* fill in the message contents */
  4480. msg_word = (u_int32_t *)qdf_nbuf_data(msg);
  4481. memset(msg_word, 0,
  4482. sizeof(struct htt_h2t_msg_type_rxdma_rxole_ppe_cfg_t));
  4483. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4484. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4485. htt_logger_bufp = (uint8_t *)msg_word;
  4486. *msg_word = 0;
  4487. HTT_H2T_MSG_TYPE_SET(*msg_word, HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG);
  4488. HTT_PPE_CFG_OVERRIDE_SET(*msg_word, cfg->override);
  4489. HTT_PPE_CFG_REO_DEST_IND_SET(
  4490. *msg_word, cfg->reo_destination_indication);
  4491. HTT_PPE_CFG_MULTI_BUF_MSDU_OVERRIDE_EN_SET(
  4492. *msg_word, cfg->multi_buffer_msdu_override_en);
  4493. HTT_PPE_CFG_INTRA_BSS_OVERRIDE_EN_SET(
  4494. *msg_word, cfg->intra_bss_override);
  4495. HTT_PPE_CFG_DECAP_RAW_OVERRIDE_EN_SET(
  4496. *msg_word, cfg->decap_raw_override);
  4497. HTT_PPE_CFG_DECAP_NWIFI_OVERRIDE_EN_SET(
  4498. *msg_word, cfg->decap_nwifi_override);
  4499. HTT_PPE_CFG_IP_FRAG_OVERRIDE_EN_SET(
  4500. *msg_word, cfg->ip_frag_override);
  4501. pkt = htt_htc_pkt_alloc(htt_handle);
  4502. if (!pkt) {
  4503. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4504. qdf_assert(0);
  4505. qdf_nbuf_free(msg);
  4506. return QDF_STATUS_E_RESOURCES; /* failure */
  4507. }
  4508. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4509. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4510. dp_htt_h2t_send_complete_free_netbuf,
  4511. qdf_nbuf_data(msg),
  4512. qdf_nbuf_len(msg),
  4513. htt_handle->htc_endpoint,
  4514. /* tag for no FW response msg */
  4515. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4516. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4517. status = DP_HTT_SEND_HTC_PKT(htt_handle, pkt,
  4518. HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG,
  4519. htt_logger_bufp);
  4520. if (status != QDF_STATUS_SUCCESS) {
  4521. qdf_nbuf_free(msg);
  4522. htt_htc_pkt_free(htt_handle, pkt);
  4523. return status;
  4524. }
  4525. dp_info("HTT_H2T_MSG_TYPE_RXDMA_RXOLE_PPE_CFG sent");
  4526. return status;
  4527. }
  4528. #endif /* WLAN_SUPPORT_PPEDS */
  4529. /**
  4530. * dp_bk_pressure_stats_handler(): worker function to print back pressure
  4531. * stats
  4532. *
  4533. * @context : argument to work function
  4534. */
  4535. static void dp_bk_pressure_stats_handler(void *context)
  4536. {
  4537. struct dp_pdev *pdev = (struct dp_pdev *)context;
  4538. struct dp_soc_srngs_state *soc_srngs_state = NULL;
  4539. const char *ring_name;
  4540. int i;
  4541. struct dp_srng_ring_state *ring_state;
  4542. bool empty_flag;
  4543. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4544. /* Extract only first entry for printing in one work event */
  4545. if (pdev->bkp_stats.queue_depth &&
  4546. !TAILQ_EMPTY(&pdev->bkp_stats.list)) {
  4547. soc_srngs_state = TAILQ_FIRST(&pdev->bkp_stats.list);
  4548. TAILQ_REMOVE(&pdev->bkp_stats.list, soc_srngs_state,
  4549. list_elem);
  4550. pdev->bkp_stats.queue_depth--;
  4551. }
  4552. empty_flag = TAILQ_EMPTY(&pdev->bkp_stats.list);
  4553. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4554. if (soc_srngs_state) {
  4555. DP_PRINT_STATS("### BKP stats for seq_num %u START ###",
  4556. soc_srngs_state->seq_num);
  4557. for (i = 0; i < soc_srngs_state->max_ring_id; i++) {
  4558. ring_state = &soc_srngs_state->ring_state[i];
  4559. ring_name = dp_srng_get_str_from_hal_ring_type
  4560. (ring_state->ring_type);
  4561. DP_PRINT_STATS("%s: SW:Head pointer = %d Tail Pointer = %d\n",
  4562. ring_name,
  4563. ring_state->sw_head,
  4564. ring_state->sw_tail);
  4565. DP_PRINT_STATS("%s: HW:Head pointer = %d Tail Pointer = %d\n",
  4566. ring_name,
  4567. ring_state->hw_head,
  4568. ring_state->hw_tail);
  4569. }
  4570. DP_PRINT_STATS("### BKP stats for seq_num %u COMPLETE ###",
  4571. soc_srngs_state->seq_num);
  4572. qdf_mem_free(soc_srngs_state);
  4573. }
  4574. dp_print_napi_stats(pdev->soc);
  4575. /* Schedule work again if queue is not empty */
  4576. if (!empty_flag)
  4577. qdf_queue_work(0, pdev->bkp_stats.work_queue,
  4578. &pdev->bkp_stats.work);
  4579. }
  4580. void dp_pdev_bkp_stats_detach(struct dp_pdev *pdev)
  4581. {
  4582. struct dp_soc_srngs_state *ring_state, *ring_state_next;
  4583. if (!pdev->bkp_stats.work_queue)
  4584. return;
  4585. qdf_flush_workqueue(0, pdev->bkp_stats.work_queue);
  4586. qdf_destroy_workqueue(0, pdev->bkp_stats.work_queue);
  4587. qdf_flush_work(&pdev->bkp_stats.work);
  4588. qdf_disable_work(&pdev->bkp_stats.work);
  4589. qdf_spin_lock_bh(&pdev->bkp_stats.list_lock);
  4590. TAILQ_FOREACH_SAFE(ring_state, &pdev->bkp_stats.list,
  4591. list_elem, ring_state_next) {
  4592. TAILQ_REMOVE(&pdev->bkp_stats.list, ring_state,
  4593. list_elem);
  4594. qdf_mem_free(ring_state);
  4595. }
  4596. qdf_spin_unlock_bh(&pdev->bkp_stats.list_lock);
  4597. qdf_spinlock_destroy(&pdev->bkp_stats.list_lock);
  4598. }
  4599. QDF_STATUS dp_pdev_bkp_stats_attach(struct dp_pdev *pdev)
  4600. {
  4601. TAILQ_INIT(&pdev->bkp_stats.list);
  4602. pdev->bkp_stats.seq_num = 0;
  4603. pdev->bkp_stats.queue_depth = 0;
  4604. qdf_create_work(0, &pdev->bkp_stats.work,
  4605. dp_bk_pressure_stats_handler, pdev);
  4606. pdev->bkp_stats.work_queue =
  4607. qdf_alloc_unbound_workqueue("dp_bkp_work_queue");
  4608. if (!pdev->bkp_stats.work_queue)
  4609. goto fail;
  4610. qdf_spinlock_create(&pdev->bkp_stats.list_lock);
  4611. return QDF_STATUS_SUCCESS;
  4612. fail:
  4613. dp_htt_alert("BKP stats attach failed");
  4614. qdf_flush_work(&pdev->bkp_stats.work);
  4615. qdf_disable_work(&pdev->bkp_stats.work);
  4616. return QDF_STATUS_E_FAILURE;
  4617. }
  4618. #ifdef DP_UMAC_HW_RESET_SUPPORT
  4619. QDF_STATUS dp_htt_umac_reset_send_setup_cmd(
  4620. struct dp_soc *soc,
  4621. const struct dp_htt_umac_reset_setup_cmd_params *setup_params)
  4622. {
  4623. struct htt_soc *htt_handle = soc->htt_handle;
  4624. uint32_t len;
  4625. qdf_nbuf_t msg;
  4626. u_int32_t *msg_word;
  4627. QDF_STATUS status;
  4628. uint8_t *htt_logger_bufp;
  4629. struct dp_htt_htc_pkt *pkt;
  4630. len = HTT_MSG_BUF_SIZE(
  4631. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4632. msg = qdf_nbuf_alloc(soc->osdev,
  4633. len,
  4634. /* reserve room for the HTC header */
  4635. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4636. 4,
  4637. TRUE);
  4638. if (!msg)
  4639. return QDF_STATUS_E_NOMEM;
  4640. /*
  4641. * Set the length of the message.
  4642. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4643. * separately during the below call to qdf_nbuf_push_head.
  4644. * The contribution from the HTC header is added separately inside HTC.
  4645. */
  4646. if (!qdf_nbuf_put_tail(
  4647. msg, HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES)) {
  4648. dp_htt_err("Failed to expand head");
  4649. qdf_nbuf_free(msg);
  4650. return QDF_STATUS_E_FAILURE;
  4651. }
  4652. /* fill in the message contents */
  4653. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4654. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4655. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4656. htt_logger_bufp = (uint8_t *)msg_word;
  4657. qdf_mem_zero(msg_word,
  4658. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_BYTES);
  4659. HTT_H2T_MSG_TYPE_SET(
  4660. *msg_word,
  4661. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP);
  4662. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_T2H_MSG_METHOD_SET(
  4663. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4664. HTT_H2T_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP_H2T_MSG_METHOD_SET(
  4665. *msg_word, htt_umac_hang_recovery_msg_t2h_msi_and_h2t_polling);
  4666. msg_word++;
  4667. *msg_word = setup_params->msi_data;
  4668. msg_word++;
  4669. *msg_word = sizeof(htt_umac_hang_recovery_msg_shmem_t);
  4670. msg_word++;
  4671. *msg_word = setup_params->shmem_addr_low;
  4672. msg_word++;
  4673. *msg_word = setup_params->shmem_addr_high;
  4674. pkt = htt_htc_pkt_alloc(htt_handle);
  4675. if (!pkt) {
  4676. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4677. qdf_assert(0);
  4678. qdf_nbuf_free(msg);
  4679. return QDF_STATUS_E_NOMEM;
  4680. }
  4681. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4682. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4683. dp_htt_h2t_send_complete_free_netbuf,
  4684. qdf_nbuf_data(msg),
  4685. qdf_nbuf_len(msg),
  4686. htt_handle->htc_endpoint,
  4687. /* tag for no FW response msg */
  4688. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4689. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4690. status = DP_HTT_SEND_HTC_PKT(
  4691. htt_handle, pkt,
  4692. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP,
  4693. htt_logger_bufp);
  4694. if (QDF_IS_STATUS_ERROR(status)) {
  4695. qdf_nbuf_free(msg);
  4696. htt_htc_pkt_free(htt_handle, pkt);
  4697. return status;
  4698. }
  4699. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_PREREQUISITE_SETUP sent");
  4700. return status;
  4701. }
  4702. QDF_STATUS dp_htt_umac_reset_send_start_pre_reset_cmd(
  4703. struct dp_soc *soc, bool is_initiator, bool is_umac_hang)
  4704. {
  4705. struct htt_soc *htt_handle = soc->htt_handle;
  4706. uint32_t len;
  4707. qdf_nbuf_t msg;
  4708. u_int32_t *msg_word;
  4709. QDF_STATUS status;
  4710. uint8_t *htt_logger_bufp;
  4711. struct dp_htt_htc_pkt *pkt;
  4712. len = HTT_MSG_BUF_SIZE(
  4713. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4714. msg = qdf_nbuf_alloc(soc->osdev,
  4715. len,
  4716. /* reserve room for the HTC header */
  4717. HTC_HEADER_LEN + HTC_HDR_ALIGNMENT_PADDING,
  4718. 4,
  4719. TRUE);
  4720. if (!msg)
  4721. return QDF_STATUS_E_NOMEM;
  4722. /*
  4723. * Set the length of the message.
  4724. * The contribution from the HTC_HDR_ALIGNMENT_PADDING is added
  4725. * separately during the below call to qdf_nbuf_push_head.
  4726. * The contribution from the HTC header is added separately inside HTC.
  4727. */
  4728. if (!qdf_nbuf_put_tail(
  4729. msg, HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES)) {
  4730. dp_htt_err("Failed to expand head");
  4731. qdf_nbuf_free(msg);
  4732. return QDF_STATUS_E_FAILURE;
  4733. }
  4734. /* fill in the message contents */
  4735. msg_word = (uint32_t *)qdf_nbuf_data(msg);
  4736. /* Rewind beyond alignment pad to get to the HTC header reserved area */
  4737. qdf_nbuf_push_head(msg, HTC_HDR_ALIGNMENT_PADDING);
  4738. htt_logger_bufp = (uint8_t *)msg_word;
  4739. qdf_mem_zero(msg_word,
  4740. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_BYTES);
  4741. HTT_H2T_MSG_TYPE_SET(
  4742. *msg_word,
  4743. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET);
  4744. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_INITIATOR_SET(
  4745. *msg_word, is_initiator);
  4746. HTT_H2T_UMAC_HANG_RECOVERY_START_PRE_RESET_IS_UMAC_HANG_SET(
  4747. *msg_word, is_umac_hang);
  4748. pkt = htt_htc_pkt_alloc(htt_handle);
  4749. if (!pkt) {
  4750. qdf_err("Fail to allocate dp_htt_htc_pkt buffer");
  4751. qdf_assert(0);
  4752. qdf_nbuf_free(msg);
  4753. return QDF_STATUS_E_NOMEM;
  4754. }
  4755. pkt->soc_ctxt = NULL; /* not used during send-done callback */
  4756. SET_HTC_PACKET_INFO_TX(&pkt->htc_pkt,
  4757. dp_htt_h2t_send_complete_free_netbuf,
  4758. qdf_nbuf_data(msg),
  4759. qdf_nbuf_len(msg),
  4760. htt_handle->htc_endpoint,
  4761. /* tag for no FW response msg */
  4762. HTC_TX_PACKET_TAG_RUNTIME_PUT);
  4763. SET_HTC_PACKET_NET_BUF_CONTEXT(&pkt->htc_pkt, msg);
  4764. status = DP_HTT_SEND_HTC_PKT(
  4765. htt_handle, pkt,
  4766. HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET,
  4767. htt_logger_bufp);
  4768. if (QDF_IS_STATUS_ERROR(status)) {
  4769. qdf_nbuf_free(msg);
  4770. htt_htc_pkt_free(htt_handle, pkt);
  4771. return status;
  4772. }
  4773. dp_info("HTT_H2T_MSG_TYPE_UMAC_HANG_RECOVERY_SOC_START_PRE_RESET sent");
  4774. return status;
  4775. }
  4776. #endif