dp_htt.c 156 KB

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