dp_htt.c 142 KB

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