dp_htt.c 138 KB

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