dp_htt.c 163 KB

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