dp_htt.c 139 KB

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