dp_htt.c 133 KB

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