dp_htt.c 132 KB

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