dp_htt.c 147 KB

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