dp_htt.c 136 KB

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