dp_htt.c 134 KB

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