dp_htt.c 137 KB

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