dp_htt.c 130 KB

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