dp_htt.c 149 KB

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