dp_htt.c 126 KB

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