dp_htt.c 144 KB

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