dp_htt.c 124 KB

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