dp_htt.c 134 KB

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