ipa_utils.c 250 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <net/ip.h>
  6. #include <linux/genalloc.h> /* gen_pool_alloc() */
  7. #include <linux/io.h>
  8. #include <linux/ratelimit.h>
  9. #include <linux/msm-bus.h>
  10. #include <linux/msm-bus-board.h>
  11. #include <linux/msm_gsi.h>
  12. #include <linux/elf.h>
  13. #include "ipa_i.h"
  14. #include "ipahal/ipahal.h"
  15. #include "ipahal/ipahal_fltrt.h"
  16. #include "ipahal/ipahal_hw_stats.h"
  17. #include "../ipa_rm_i.h"
  18. /*
  19. * The following for adding code (ie. for EMULATION) not found on x86.
  20. */
  21. #if defined(CONFIG_IPA_EMULATION)
  22. # include "ipa_emulation_stubs.h"
  23. #endif
  24. #define IPA_V3_0_CLK_RATE_SVS2 (37.5 * 1000 * 1000UL)
  25. #define IPA_V3_0_CLK_RATE_SVS (75 * 1000 * 1000UL)
  26. #define IPA_V3_0_CLK_RATE_NOMINAL (150 * 1000 * 1000UL)
  27. #define IPA_V3_0_CLK_RATE_TURBO (200 * 1000 * 1000UL)
  28. #define IPA_V3_5_CLK_RATE_SVS2 (100 * 1000 * 1000UL)
  29. #define IPA_V3_5_CLK_RATE_SVS (200 * 1000 * 1000UL)
  30. #define IPA_V3_5_CLK_RATE_NOMINAL (400 * 1000 * 1000UL)
  31. #define IPA_V3_5_CLK_RATE_TURBO (42640 * 10 * 1000UL)
  32. #define IPA_V4_0_CLK_RATE_SVS2 (60 * 1000 * 1000UL)
  33. #define IPA_V4_0_CLK_RATE_SVS (125 * 1000 * 1000UL)
  34. #define IPA_V4_0_CLK_RATE_NOMINAL (220 * 1000 * 1000UL)
  35. #define IPA_V4_0_CLK_RATE_TURBO (250 * 1000 * 1000UL)
  36. #define IPA_V3_0_MAX_HOLB_TMR_VAL (4294967296 - 1)
  37. #define IPA_V3_0_BW_THRESHOLD_TURBO_MBPS (1000)
  38. #define IPA_V3_0_BW_THRESHOLD_NOMINAL_MBPS (600)
  39. #define IPA_V3_0_BW_THRESHOLD_SVS_MBPS (310)
  40. #define IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_BMASK 0xFF0000
  41. #define IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_SHFT 0x10
  42. /* Max pipes + ICs for TAG process */
  43. #define IPA_TAG_MAX_DESC (IPA3_MAX_NUM_PIPES + 6)
  44. #define IPA_TAG_SLEEP_MIN_USEC (1000)
  45. #define IPA_TAG_SLEEP_MAX_USEC (2000)
  46. #define IPA_FORCE_CLOSE_TAG_PROCESS_TIMEOUT (10 * HZ)
  47. #define IPA_BCR_REG_VAL_v3_0 (0x00000001)
  48. #define IPA_BCR_REG_VAL_v3_5 (0x0000003B)
  49. #define IPA_BCR_REG_VAL_v4_0 (0x00000039)
  50. #define IPA_BCR_REG_VAL_v4_2 (0x00000000)
  51. #define IPA_AGGR_GRAN_MIN (1)
  52. #define IPA_AGGR_GRAN_MAX (32)
  53. #define IPA_EOT_COAL_GRAN_MIN (1)
  54. #define IPA_EOT_COAL_GRAN_MAX (16)
  55. #define IPA_FILT_ROUT_HASH_REG_VAL_v4_2 (0x00000000)
  56. #define IPA_DMA_TASK_FOR_GSI_TIMEOUT_MSEC (15)
  57. #define IPA_AGGR_BYTE_LIMIT (\
  58. IPA_ENDP_INIT_AGGR_N_AGGR_BYTE_LIMIT_BMSK >> \
  59. IPA_ENDP_INIT_AGGR_N_AGGR_BYTE_LIMIT_SHFT)
  60. #define IPA_AGGR_PKT_LIMIT (\
  61. IPA_ENDP_INIT_AGGR_n_AGGR_PKT_LIMIT_BMSK >> \
  62. IPA_ENDP_INIT_AGGR_n_AGGR_PKT_LIMIT_SHFT)
  63. /* In IPAv3 only endpoints 0-3 can be configured to deaggregation */
  64. #define IPA_EP_SUPPORTS_DEAGGR(idx) ((idx) >= 0 && (idx) <= 3)
  65. #define IPA_TAG_TIMER_TIMESTAMP_SHFT (14) /* ~0.8msec */
  66. #define IPA_NAT_TIMER_TIMESTAMP_SHFT (24) /* ~0.8sec */
  67. /*
  68. * Units of time per a specific granularity
  69. * The limitation based on H/W HOLB/AGGR time limit field width
  70. */
  71. #define IPA_TIMER_SCALED_TIME_LIMIT 31
  72. /* HPS, DPS sequencers Types*/
  73. /* DMA Only */
  74. #define IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY 0x00000000
  75. /* DMA + decipher */
  76. #define IPA_DPS_HPS_SEQ_TYPE_DMA_DEC 0x00000011
  77. /* Packet Processing + no decipher + uCP (for Ethernet Bridging) */
  78. #define IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP 0x00000002
  79. /* Packet Processing + decipher + uCP */
  80. #define IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_DEC_UCP 0x00000013
  81. /* Packet Processing + no decipher + no uCP */
  82. #define IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP 0x00000006
  83. /* Packet Processing + decipher + no uCP */
  84. #define IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_DEC_NO_UCP 0x00000017
  85. /* 2 Packet Processing pass + no decipher + uCP */
  86. #define IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP 0x00000004
  87. /* 2 Packet Processing pass + decipher + uCP */
  88. #define IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP 0x00000015
  89. /* 2 Packet Processing pass + no decipher + uCP + HPS REP DMA Parser. */
  90. #define IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP 0x00000804
  91. /* Packet Processing + no decipher + no uCP + HPS REP DMA Parser.*/
  92. #define IPA_DPS_HPS_REP_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP_DMAP 0x00000806
  93. /* COMP/DECOMP */
  94. #define IPA_DPS_HPS_SEQ_TYPE_DMA_COMP_DECOMP 0x00000020
  95. /* 2 Packet Processing + no decipher + 2 uCP */
  96. #define IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_2ND_UCP 0x0000000a
  97. /* 2 Packet Processing + decipher + 2 uCP */
  98. #define IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_2ND_UCP 0x0000001b
  99. /* 3 Packet Processing + no decipher + 2 uCP */
  100. #define IPA_DPS_HPS_SEQ_TYPE_3RD_PKT_PROCESS_PASS_NO_DEC_2ND_UCP 0x0000000c
  101. /* 3 Packet Processing + decipher + 2 uCP */
  102. #define IPA_DPS_HPS_SEQ_TYPE_3RD_PKT_PROCESS_PASS_DEC_2ND_UCP 0x0000001d
  103. /* 2 Packet Processing + no decipher + 2 uCP + HPS REP DMA Parser */
  104. #define IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_2ND_UCP_DMAP 0x0000080a
  105. /* 3 Packet Processing + no decipher + 2 uCP + HPS REP DMA Parser */
  106. #define IPA_DPS_HPS_SEQ_TYPE_3RD_PKT_PROCESS_PASS_NO_DEC_2ND_UCP_DMAP 0x0000080c
  107. /* Invalid sequencer type */
  108. #define IPA_DPS_HPS_SEQ_TYPE_INVALID 0xFFFFFFFF
  109. #define IPA_DPS_HPS_SEQ_TYPE_IS_DMA(seq_type) \
  110. (seq_type == IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY || \
  111. seq_type == IPA_DPS_HPS_SEQ_TYPE_DMA_DEC || \
  112. seq_type == IPA_DPS_HPS_SEQ_TYPE_DMA_COMP_DECOMP)
  113. /* Resource Group index*/
  114. #define IPA_v3_0_GROUP_UL (0)
  115. #define IPA_v3_0_GROUP_DL (1)
  116. #define IPA_v3_0_GROUP_DPL IPA_v3_0_GROUP_DL
  117. #define IPA_v3_0_GROUP_DIAG (2)
  118. #define IPA_v3_0_GROUP_DMA (3)
  119. #define IPA_v3_0_GROUP_IMM_CMD IPA_v3_0_GROUP_UL
  120. #define IPA_v3_0_GROUP_Q6ZIP (4)
  121. #define IPA_v3_0_GROUP_Q6ZIP_GENERAL IPA_v3_0_GROUP_Q6ZIP
  122. #define IPA_v3_0_GROUP_UC_RX_Q (5)
  123. #define IPA_v3_0_GROUP_Q6ZIP_ENGINE IPA_v3_0_GROUP_UC_RX_Q
  124. #define IPA_v3_0_GROUP_MAX (6)
  125. #define IPA_v3_5_GROUP_LWA_DL (0) /* currently not used */
  126. #define IPA_v3_5_MHI_GROUP_PCIE IPA_v3_5_GROUP_LWA_DL
  127. #define IPA_v3_5_GROUP_UL_DL (1)
  128. #define IPA_v3_5_MHI_GROUP_DDR IPA_v3_5_GROUP_UL_DL
  129. #define IPA_v3_5_MHI_GROUP_DMA (2)
  130. #define IPA_v3_5_GROUP_UC_RX_Q (3) /* currently not used */
  131. #define IPA_v3_5_SRC_GROUP_MAX (4)
  132. #define IPA_v3_5_DST_GROUP_MAX (3)
  133. #define IPA_v4_0_GROUP_LWA_DL (0)
  134. #define IPA_v4_0_MHI_GROUP_PCIE (0)
  135. #define IPA_v4_0_ETHERNET (0)
  136. #define IPA_v4_0_GROUP_UL_DL (1)
  137. #define IPA_v4_0_MHI_GROUP_DDR (1)
  138. #define IPA_v4_0_MHI_GROUP_DMA (2)
  139. #define IPA_v4_0_GROUP_UC_RX_Q (3)
  140. #define IPA_v4_0_SRC_GROUP_MAX (4)
  141. #define IPA_v4_0_DST_GROUP_MAX (4)
  142. #define IPA_v4_2_GROUP_UL_DL (0)
  143. #define IPA_v4_2_SRC_GROUP_MAX (1)
  144. #define IPA_v4_2_DST_GROUP_MAX (1)
  145. #define IPA_v4_5_MHI_GROUP_PCIE (0)
  146. #define IPA_v4_5_GROUP_UL_DL (1)
  147. #define IPA_v4_5_MHI_GROUP_DDR (1)
  148. #define IPA_v4_5_MHI_GROUP_DMA (2)
  149. #define IPA_v4_5_MHI_GROUP_QDSS (3)
  150. #define IPA_v4_5_GROUP_UC_RX_Q (4)
  151. #define IPA_v4_5_SRC_GROUP_MAX (5)
  152. #define IPA_v4_5_DST_GROUP_MAX (5)
  153. #define IPA_v4_7_GROUP_UL_DL (0)
  154. #define IPA_v4_7_SRC_GROUP_MAX (1)
  155. #define IPA_v4_7_DST_GROUP_MAX (1)
  156. #define IPA_GROUP_MAX IPA_v3_0_GROUP_MAX
  157. enum ipa_rsrc_grp_type_src {
  158. IPA_v3_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS,
  159. IPA_v3_0_RSRC_GRP_TYPE_SRC_HDR_SECTORS,
  160. IPA_v3_0_RSRC_GRP_TYPE_SRC_HDRI1_BUFFER,
  161. IPA_v3_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS,
  162. IPA_v3_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF,
  163. IPA_v3_0_RSRC_GRP_TYPE_SRC_HDRI2_BUFFERS,
  164. IPA_v3_0_RSRC_GRP_TYPE_SRC_HPS_DMARS,
  165. IPA_v3_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES,
  166. IPA_v3_0_RSRC_GRP_TYPE_SRC_MAX,
  167. IPA_v3_5_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS = 0,
  168. IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS,
  169. IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF,
  170. IPA_v3_5_RSRC_GRP_TYPE_SRC_HPS_DMARS,
  171. IPA_v3_5_RSRC_GRP_TYPE_SRC_ACK_ENTRIES,
  172. IPA_v3_5_RSRC_GRP_TYPE_SRC_MAX,
  173. IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS = 0,
  174. IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS,
  175. IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF,
  176. IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS,
  177. IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES,
  178. IPA_v4_0_RSRC_GRP_TYPE_SRC_MAX
  179. };
  180. #define IPA_RSRC_GRP_TYPE_SRC_MAX IPA_v3_0_RSRC_GRP_TYPE_SRC_MAX
  181. enum ipa_rsrc_grp_type_dst {
  182. IPA_v3_0_RSRC_GRP_TYPE_DST_DATA_SECTORS,
  183. IPA_v3_0_RSRC_GRP_TYPE_DST_DATA_SECTOR_LISTS,
  184. IPA_v3_0_RSRC_GRP_TYPE_DST_DPS_DMARS,
  185. IPA_v3_0_RSRC_GRP_TYPE_DST_MAX,
  186. IPA_v3_5_RSRC_GRP_TYPE_DST_DATA_SECTORS = 0,
  187. IPA_v3_5_RSRC_GRP_TYPE_DST_DPS_DMARS,
  188. IPA_v3_5_RSRC_GRP_TYPE_DST_MAX,
  189. IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS = 0,
  190. IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS,
  191. IPA_v4_0_RSRC_GRP_TYPE_DST_MAX,
  192. };
  193. #define IPA_RSRC_GRP_TYPE_DST_MAX IPA_v3_0_RSRC_GRP_TYPE_DST_MAX
  194. enum ipa_rsrc_grp_type_rx {
  195. IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ,
  196. IPA_RSRC_GRP_TYPE_RX_MAX
  197. };
  198. enum ipa_rsrc_grp_rx_hps_weight_config {
  199. IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG,
  200. IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_MAX
  201. };
  202. struct rsrc_min_max {
  203. u32 min;
  204. u32 max;
  205. };
  206. enum ipa_ver {
  207. IPA_3_0,
  208. IPA_3_5,
  209. IPA_3_5_MHI,
  210. IPA_3_5_1,
  211. IPA_4_0,
  212. IPA_4_0_MHI,
  213. IPA_4_1,
  214. IPA_4_1_APQ,
  215. IPA_4_2,
  216. IPA_4_5,
  217. IPA_4_5_MHI,
  218. IPA_4_5_APQ,
  219. IPA_4_7,
  220. IPA_VER_MAX,
  221. };
  222. static const struct rsrc_min_max ipa3_rsrc_src_grp_config
  223. [IPA_VER_MAX][IPA_RSRC_GRP_TYPE_SRC_MAX][IPA_GROUP_MAX] = {
  224. [IPA_3_0] = {
  225. /* UL DL DIAG DMA Not Used uC Rx */
  226. [IPA_v3_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  227. {3, 255}, {3, 255}, {1, 255}, {1, 255}, {1, 255}, {2, 255} },
  228. [IPA_v3_0_RSRC_GRP_TYPE_SRC_HDR_SECTORS] = {
  229. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255} },
  230. [IPA_v3_0_RSRC_GRP_TYPE_SRC_HDRI1_BUFFER] = {
  231. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255} },
  232. [IPA_v3_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  233. {14, 14}, {16, 16}, {5, 5}, {5, 5}, {0, 0}, {8, 8} },
  234. [IPA_v3_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  235. {19, 19}, {26, 26}, {3, 3}, {7, 7}, {0, 0}, {8, 8} },
  236. [IPA_v3_0_RSRC_GRP_TYPE_SRC_HDRI2_BUFFERS] = {
  237. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255} },
  238. [IPA_v3_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  239. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255} },
  240. [IPA_v3_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  241. {14, 14}, {16, 16}, {5, 5}, {5, 5}, {0, 0}, {8, 8} },
  242. },
  243. [IPA_3_5] = {
  244. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  245. [IPA_v3_5_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  246. {0, 0}, {1, 255}, {0, 0}, {1, 255}, {0, 0}, {0, 0} },
  247. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  248. {0, 0}, {10, 10}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  249. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  250. {0, 0}, {14, 14}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  251. [IPA_v3_5_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  252. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 0}, {0, 0} },
  253. [IPA_v3_5_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  254. {0, 0}, {20, 20}, {0, 0}, {14, 14}, {0, 0}, {0, 0} },
  255. },
  256. [IPA_3_5_MHI] = {
  257. /* PCIE DDR DMA unused, other are invalid */
  258. [IPA_v3_5_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  259. {4, 4}, {5, 5}, {1, 1}, {0, 0}, {0, 0}, {0, 0} },
  260. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  261. {10, 10}, {10, 10}, {8, 8}, {0, 0}, {0, 0}, {0, 0} },
  262. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  263. {12, 12}, {12, 12}, {8, 8}, {0, 0}, {0, 0}, {0, 0} },
  264. [IPA_v3_5_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  265. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 0}, {0, 0} },
  266. [IPA_v3_5_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  267. {14, 14}, {14, 14}, {14, 14}, {0, 0}, {0, 0}, {0, 0} },
  268. },
  269. [IPA_3_5_1] = {
  270. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  271. [IPA_v3_5_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  272. {1, 255}, {1, 255}, {0, 0}, {1, 255}, {0, 0}, {0, 0} },
  273. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  274. {10, 10}, {10, 10}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  275. [IPA_v3_5_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  276. {12, 12}, {14, 14}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  277. [IPA_v3_5_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  278. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 0}, {0, 0} },
  279. [IPA_v3_5_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  280. {14, 14}, {20, 20}, {0, 0}, {14, 14}, {0, 0}, {0, 0} },
  281. },
  282. [IPA_4_0] = {
  283. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  284. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  285. {1, 255}, {1, 255}, {0, 0}, {1, 255}, {0, 0}, {0, 0} },
  286. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  287. {10, 10}, {10, 10}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  288. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  289. {12, 12}, {14, 14}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  290. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  291. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 0}, {0, 0} },
  292. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  293. {14, 14}, {20, 20}, {0, 0}, {14, 14}, {0, 0}, {0, 0} },
  294. },
  295. [IPA_4_0_MHI] = {
  296. /* PCIE DDR DMA unused, other are invalid */
  297. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  298. {4, 4}, {5, 5}, {1, 1}, {0, 0}, {0, 0}, {0, 0} },
  299. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  300. {10, 10}, {10, 10}, {8, 8}, {0, 0}, {0, 0}, {0, 0} },
  301. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  302. {12, 12}, {12, 12}, {8, 8}, {0, 0}, {0, 0}, {0, 0} },
  303. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  304. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 0}, {0, 0} },
  305. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  306. {14, 14}, {14, 14}, {14, 14}, {0, 0}, {0, 0}, {0, 0} },
  307. },
  308. [IPA_4_1] = {
  309. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  310. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  311. {1, 63}, {1, 63}, {0, 0}, {1, 63}, {0, 0}, {0, 0} },
  312. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  313. {10, 10}, {10, 10}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  314. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  315. {12, 12}, {14, 14}, {0, 0}, {8, 8}, {0, 0}, {0, 0} },
  316. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  317. {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 0}, {0, 0} },
  318. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  319. {14, 14}, {20, 20}, {0, 0}, {14, 14}, {0, 0}, {0, 0} },
  320. },
  321. [IPA_4_2] = {
  322. /* UL_DL other are invalid */
  323. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  324. {3, 63}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  325. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  326. {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  327. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  328. {10, 10}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  329. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  330. {1, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  331. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  332. {5, 5}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  333. },
  334. [IPA_4_5] = {
  335. /* unused UL_DL unused unused UC_RX_Q N/A */
  336. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  337. {0, 0}, {1, 11}, {0, 0}, {0, 0}, {1, 63}, {0, 0} },
  338. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  339. {0, 0}, {14, 14}, {0, 0}, {0, 0}, {3, 3}, {0, 0} },
  340. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  341. {0, 0}, {18, 18}, {0, 0}, {0, 0}, {8, 8}, {0, 0} },
  342. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  343. {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 0} },
  344. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  345. {0, 0}, {24, 24}, {0, 0}, {0, 0}, {8, 8}, {0, 0} },
  346. },
  347. [IPA_4_5_MHI] = {
  348. /* PCIE DDR DMA QDSS unused N/A */
  349. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  350. {3, 8}, {4, 11}, {1, 1}, {1, 1}, {0, 0}, {0, 0} },
  351. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  352. {9, 9}, {12, 12}, {2, 2}, {2, 2}, {0, 0}, {0, 0} },
  353. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  354. {9, 9}, {14, 14}, {4, 4}, {4, 4}, {0, 0}, {0, 0} },
  355. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  356. {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 0} },
  357. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  358. {22, 22}, {16, 16}, {6, 6}, {2, 2}, {0, 0}, {0, 0} },
  359. },
  360. [IPA_4_5_APQ] = {
  361. /* unused UL_DL unused unused UC_RX_Q N/A */
  362. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  363. {0, 0}, {1, 11}, {0, 0}, {0, 0}, {1, 63}, {0, 0} },
  364. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  365. {0, 0}, {14, 14}, {0, 0}, {0, 0}, {3, 3}, {0, 0} },
  366. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  367. {0, 0}, {18, 18}, {0, 0}, {0, 0}, {8, 8}, {0, 0} },
  368. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  369. {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 63}, {0, 0} },
  370. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  371. {0, 0}, {24, 24}, {0, 0}, {0, 0}, {8, 8}, {0, 0} },
  372. },
  373. [IPA_4_7] = {
  374. /* UL_DL other are invalid */
  375. [IPA_v4_0_RSRC_GRP_TYPE_SRC_PKT_CONTEXTS] = {
  376. {8, 8}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  377. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_LISTS] = {
  378. {8, 8}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  379. [IPA_v4_0_RSRC_GRP_TYPE_SRC_DESCRIPTOR_BUFF] = {
  380. {18, 18}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  381. [IPA_v4_0_RSRC_GRP_TYPE_SRC_HPS_DMARS] = {
  382. {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  383. [IPA_v4_0_RSRC_GRP_TYPE_SRC_ACK_ENTRIES] = {
  384. {15, 15}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  385. },
  386. };
  387. static const struct rsrc_min_max ipa3_rsrc_dst_grp_config
  388. [IPA_VER_MAX][IPA_RSRC_GRP_TYPE_DST_MAX][IPA_GROUP_MAX] = {
  389. [IPA_3_0] = {
  390. /* UL DL/DPL DIAG DMA Q6zip_gen Q6zip_eng */
  391. [IPA_v3_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  392. {2, 2}, {3, 3}, {0, 0}, {2, 2}, {3, 3}, {3, 3} },
  393. [IPA_v3_0_RSRC_GRP_TYPE_DST_DATA_SECTOR_LISTS] = {
  394. {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255}, {0, 255} },
  395. [IPA_v3_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  396. {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {0, 0} },
  397. },
  398. [IPA_3_5] = {
  399. /* unused UL/DL/DPL unused N/A N/A N/A */
  400. [IPA_v3_5_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  401. {4, 4}, {4, 4}, {3, 3}, {0, 0}, {0, 0}, {0, 0} },
  402. [IPA_v3_5_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  403. {2, 255}, {1, 255}, {1, 2}, {0, 0}, {0, 0}, {0, 0} },
  404. },
  405. [IPA_3_5_MHI] = {
  406. /* PCIE DDR DMA N/A N/A N/A */
  407. [IPA_v3_5_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  408. {4, 4}, {4, 4}, {3, 3}, {0, 0}, {0, 0}, {0, 0} },
  409. [IPA_v3_5_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  410. {2, 255}, {1, 255}, {1, 2}, {0, 0}, {0, 0}, {0, 0} },
  411. },
  412. [IPA_3_5_1] = {
  413. /* LWA_DL UL/DL/DPL unused N/A N/A N/A */
  414. [IPA_v3_5_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  415. {4, 4}, {4, 4}, {3, 3}, {0, 0}, {0, 0}, {0, 0} },
  416. [IPA_v3_5_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  417. {2, 255}, {1, 255}, {1, 2}, {0, 0}, {0, 0}, {0, 0} },
  418. },
  419. [IPA_4_0] = {
  420. /* LWA_DL UL/DL/DPL uC, other are invalid */
  421. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  422. {4, 4}, {4, 4}, {3, 3}, {2, 2}, {0, 0}, {0, 0} },
  423. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  424. {2, 255}, {1, 255}, {1, 2}, {0, 2}, {0, 0}, {0, 0} },
  425. },
  426. [IPA_4_0_MHI] = {
  427. /* LWA_DL UL/DL/DPL uC, other are invalid */
  428. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  429. {4, 4}, {4, 4}, {3, 3}, {2, 2}, {0, 0}, {0, 0} },
  430. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  431. {2, 255}, {1, 255}, {1, 2}, {0, 2}, {0, 0}, {0, 0} },
  432. },
  433. [IPA_4_1] = {
  434. /* LWA_DL UL/DL/DPL uC, other are invalid */
  435. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  436. {4, 4}, {4, 4}, {3, 3}, {2, 2}, {0, 0}, {0, 0} },
  437. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  438. {2, 63}, {1, 63}, {1, 2}, {0, 2}, {0, 0}, {0, 0} },
  439. },
  440. [IPA_4_2] = {
  441. /* UL/DL/DPL, other are invalid */
  442. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  443. {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  444. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  445. {1, 63}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  446. },
  447. [IPA_4_5] = {
  448. /* unused UL/DL/DPL unused unused uC N/A */
  449. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  450. {0, 0}, {16, 16}, {2, 2}, {2, 2}, {0, 0}, {0, 0} },
  451. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  452. {0, 0}, {2, 63}, {1, 2}, {1, 2}, {0, 2}, {0, 0} },
  453. },
  454. [IPA_4_5_MHI] = {
  455. /* PCIE/DPL DDR DMA/CV2X QDSS uC N/A */
  456. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  457. {16, 16}, {5, 5}, {2, 2}, {2, 2}, {0, 0}, {0, 0} },
  458. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  459. {2, 63}, {1, 63}, {1, 2}, {1, 2}, {0, 2}, {0, 0} },
  460. },
  461. [IPA_4_5_APQ] = {
  462. /* unused UL/DL/DPL unused unused uC N/A */
  463. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  464. {0, 0}, {16, 16}, {2, 2}, {2, 2}, {0, 0}, {0, 0} },
  465. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  466. {0, 0}, {2, 63}, {1, 2}, {1, 2}, {0, 2}, {0, 0} },
  467. },
  468. [IPA_4_7] = {
  469. /* UL/DL/DPL, other are invalid */
  470. [IPA_v4_0_RSRC_GRP_TYPE_DST_DATA_SECTORS] = {
  471. {7, 7}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  472. [IPA_v4_0_RSRC_GRP_TYPE_DST_DPS_DMARS] = {
  473. {2, 2}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  474. },
  475. };
  476. static const struct rsrc_min_max ipa3_rsrc_rx_grp_config
  477. [IPA_VER_MAX][IPA_RSRC_GRP_TYPE_RX_MAX][IPA_GROUP_MAX] = {
  478. [IPA_3_0] = {
  479. /* UL DL DIAG DMA unused uC Rx */
  480. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  481. {16, 16}, {24, 24}, {8, 8}, {8, 8}, {0, 0}, {8, 8} },
  482. },
  483. [IPA_3_5] = {
  484. /* unused UL_DL unused UC_RX_Q N/A N/A */
  485. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  486. {0, 0}, {7, 7}, {0, 0}, {2, 2}, {0, 0}, {0, 0} },
  487. },
  488. [IPA_3_5_MHI] = {
  489. /* PCIE DDR DMA unused N/A N/A */
  490. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  491. {3, 3}, {7, 7}, {2, 2}, {0, 0}, {0, 0}, {0, 0} },
  492. },
  493. [IPA_3_5_1] = {
  494. /* LWA_DL UL_DL unused UC_RX_Q N/A N/A */
  495. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  496. {3, 3}, {7, 7}, {0, 0}, {2, 2}, {0, 0}, {0, 0} },
  497. },
  498. [IPA_4_0] = {
  499. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  500. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  501. {3, 3}, {7, 7}, {0, 0}, {2, 2}, {0, 0}, {0, 0} },
  502. },
  503. [IPA_4_0_MHI] = {
  504. /* PCIE DDR DMA unused N/A N/A */
  505. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  506. {3, 3}, {7, 7}, {2, 2}, {0, 0}, {0, 0}, {0, 0} },
  507. },
  508. [IPA_4_1] = {
  509. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  510. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  511. {3, 3}, {7, 7}, {0, 0}, {2, 2}, {0, 0}, {0, 0} },
  512. },
  513. [IPA_4_2] = {
  514. /* UL_DL, other are invalid */
  515. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  516. {4, 4}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  517. },
  518. [IPA_4_5] = {
  519. /* unused UL_DL unused unused UC_RX_Q N/A */
  520. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  521. {0, 0}, {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  522. },
  523. [IPA_4_5_MHI] = {
  524. /* PCIE DDR DMA QDSS unused N/A */
  525. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  526. {3, 3}, {3, 3}, {3, 3}, {3, 3}, {0, 0}, {0, 0} },
  527. },
  528. [IPA_4_5_APQ] = {
  529. /* unused UL_DL unused unused UC_RX_Q N/A */
  530. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  531. {0, 0}, {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  532. },
  533. [IPA_4_7] = {
  534. /* unused UL_DL unused unused UC_RX_Q N/A */
  535. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ] = {
  536. {3, 3}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} },
  537. },
  538. };
  539. static const u32 ipa3_rsrc_rx_grp_hps_weight_config
  540. [IPA_VER_MAX][IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_MAX][IPA_GROUP_MAX] = {
  541. [IPA_3_0] = {
  542. /* UL DL DIAG DMA unused uC Rx */
  543. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 0, 0, 0, 0, 0, 0 },
  544. },
  545. [IPA_3_5] = {
  546. /* unused UL_DL unused UC_RX_Q N/A N/A */
  547. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 1, 1, 1, 1, 0, 0 },
  548. },
  549. [IPA_3_5_MHI] = {
  550. /* PCIE DDR DMA unused N/A N/A */
  551. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 3, 5, 1, 1, 0, 0 },
  552. },
  553. [IPA_3_5_1] = {
  554. /* LWA_DL UL_DL unused UC_RX_Q N/A N/A */
  555. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 1, 1, 1, 1, 0, 0 },
  556. },
  557. [IPA_4_0] = {
  558. /* LWA_DL UL_DL unused UC_RX_Q N/A */
  559. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 1, 1, 1, 1, 0, 0 },
  560. },
  561. [IPA_4_0_MHI] = {
  562. /* PCIE DDR DMA unused N/A N/A */
  563. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 3, 5, 1, 1, 0, 0 },
  564. },
  565. [IPA_4_1] = {
  566. /* LWA_DL UL_DL unused UC_RX_Q, other are invalid */
  567. [IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG] = { 1, 1, 1, 1, 0, 0 },
  568. },
  569. };
  570. enum ipa_ees {
  571. IPA_EE_AP = 0,
  572. IPA_EE_Q6 = 1,
  573. IPA_EE_UC = 2,
  574. };
  575. enum ipa_qmb_instance_type {
  576. IPA_QMB_INSTANCE_DDR = 0,
  577. IPA_QMB_INSTANCE_PCIE = 1,
  578. IPA_QMB_INSTANCE_MAX
  579. };
  580. #define QMB_MASTER_SELECT_DDR IPA_QMB_INSTANCE_DDR
  581. #define QMB_MASTER_SELECT_PCIE IPA_QMB_INSTANCE_PCIE
  582. struct ipa_qmb_outstanding {
  583. u16 ot_reads;
  584. u16 ot_writes;
  585. };
  586. static const struct ipa_qmb_outstanding ipa3_qmb_outstanding
  587. [IPA_VER_MAX][IPA_QMB_INSTANCE_MAX] = {
  588. [IPA_3_0][IPA_QMB_INSTANCE_DDR] = {8, 8},
  589. [IPA_3_0][IPA_QMB_INSTANCE_PCIE] = {8, 2},
  590. [IPA_3_5][IPA_QMB_INSTANCE_DDR] = {8, 8},
  591. [IPA_3_5][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  592. [IPA_3_5_MHI][IPA_QMB_INSTANCE_DDR] = {8, 8},
  593. [IPA_3_5_MHI][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  594. [IPA_3_5_1][IPA_QMB_INSTANCE_DDR] = {8, 8},
  595. [IPA_3_5_1][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  596. [IPA_4_0][IPA_QMB_INSTANCE_DDR] = {12, 8},
  597. [IPA_4_0][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  598. [IPA_4_0_MHI][IPA_QMB_INSTANCE_DDR] = {12, 8},
  599. [IPA_4_0_MHI][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  600. [IPA_4_1][IPA_QMB_INSTANCE_DDR] = {12, 8},
  601. [IPA_4_1][IPA_QMB_INSTANCE_PCIE] = {12, 4},
  602. [IPA_4_2][IPA_QMB_INSTANCE_DDR] = {12, 8},
  603. [IPA_4_5][IPA_QMB_INSTANCE_DDR] = {16, 8},
  604. [IPA_4_5][IPA_QMB_INSTANCE_PCIE] = {12, 8},
  605. [IPA_4_5_MHI][IPA_QMB_INSTANCE_DDR] = {16, 8},
  606. [IPA_4_5_MHI][IPA_QMB_INSTANCE_PCIE] = {12, 8},
  607. [IPA_4_5_APQ][IPA_QMB_INSTANCE_DDR] = {16, 8},
  608. [IPA_4_5_APQ][IPA_QMB_INSTANCE_PCIE] = {12, 8},
  609. [IPA_4_7][IPA_QMB_INSTANCE_DDR] = {13, 12},
  610. };
  611. struct ipa_ep_configuration {
  612. bool valid;
  613. int group_num;
  614. bool support_flt;
  615. int sequencer_type;
  616. u8 qmb_master_sel;
  617. struct ipa_gsi_ep_config ipa_gsi_ep_info;
  618. };
  619. /* clients not included in the list below are considered as invalid */
  620. static const struct ipa_ep_configuration ipa3_ep_mapping
  621. [IPA_VER_MAX][IPA_CLIENT_MAX] = {
  622. [IPA_3_0][IPA_CLIENT_WLAN1_PROD] = {
  623. true, IPA_v3_0_GROUP_UL, true,
  624. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  625. QMB_MASTER_SELECT_DDR,
  626. { 10, 1, 8, 16, IPA_EE_UC } },
  627. [IPA_3_0][IPA_CLIENT_USB_PROD] = {
  628. true, IPA_v3_0_GROUP_UL, true,
  629. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  630. QMB_MASTER_SELECT_DDR,
  631. { 1, 3, 8, 16, IPA_EE_AP } },
  632. [IPA_3_0][IPA_CLIENT_APPS_LAN_PROD] = {
  633. true, IPA_v3_0_GROUP_DL, false,
  634. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  635. QMB_MASTER_SELECT_DDR,
  636. { 14, 11, 8, 16, IPA_EE_AP } },
  637. [IPA_3_0][IPA_CLIENT_APPS_WAN_PROD] = {
  638. true, IPA_v3_0_GROUP_UL, true,
  639. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  640. QMB_MASTER_SELECT_DDR,
  641. { 3, 5, 16, 32, IPA_EE_AP } },
  642. [IPA_3_0][IPA_CLIENT_APPS_CMD_PROD] = {
  643. true, IPA_v3_0_GROUP_IMM_CMD, false,
  644. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  645. QMB_MASTER_SELECT_DDR,
  646. { 22, 6, 18, 28, IPA_EE_AP } },
  647. [IPA_3_0][IPA_CLIENT_ODU_PROD] = {
  648. true, IPA_v3_0_GROUP_UL, true,
  649. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  650. QMB_MASTER_SELECT_DDR,
  651. { 12, 9, 8, 16, IPA_EE_AP } },
  652. [IPA_3_0][IPA_CLIENT_MHI_PROD] = {
  653. true, IPA_v3_0_GROUP_UL, true,
  654. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  655. QMB_MASTER_SELECT_PCIE,
  656. { 0, 0, 8, 16, IPA_EE_AP } },
  657. [IPA_3_0][IPA_CLIENT_Q6_LAN_PROD] = {
  658. true, IPA_v3_0_GROUP_UL, false,
  659. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  660. QMB_MASTER_SELECT_DDR,
  661. { 9, 4, 8, 12, IPA_EE_Q6 } },
  662. [IPA_3_0][IPA_CLIENT_Q6_WAN_PROD] = {
  663. true, IPA_v3_0_GROUP_DL, true,
  664. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  665. QMB_MASTER_SELECT_DDR,
  666. { 5, 0, 16, 32, IPA_EE_Q6 } },
  667. [IPA_3_0][IPA_CLIENT_Q6_CMD_PROD] = {
  668. true, IPA_v3_0_GROUP_IMM_CMD, false,
  669. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  670. QMB_MASTER_SELECT_DDR,
  671. { 6, 1, 18, 28, IPA_EE_Q6 } },
  672. [IPA_3_0][IPA_CLIENT_Q6_DECOMP_PROD] = {
  673. true, IPA_v3_0_GROUP_Q6ZIP,
  674. false, IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  675. QMB_MASTER_SELECT_DDR,
  676. { 7, 2, 0, 0, IPA_EE_Q6 } },
  677. [IPA_3_0][IPA_CLIENT_Q6_DECOMP2_PROD] = {
  678. true, IPA_v3_0_GROUP_Q6ZIP,
  679. false, IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  680. QMB_MASTER_SELECT_DDR,
  681. { 8, 3, 0, 0, IPA_EE_Q6 } },
  682. [IPA_3_0][IPA_CLIENT_MEMCPY_DMA_SYNC_PROD] = {
  683. true, IPA_v3_0_GROUP_DMA, false,
  684. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  685. QMB_MASTER_SELECT_PCIE,
  686. { 12, 9, 8, 16, IPA_EE_AP } },
  687. [IPA_3_0][IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD] = {
  688. true, IPA_v3_0_GROUP_DMA, false,
  689. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  690. QMB_MASTER_SELECT_PCIE,
  691. { 13, 10, 8, 16, IPA_EE_AP } },
  692. [IPA_3_0][IPA_CLIENT_ETHERNET_PROD] = {
  693. true, IPA_v3_0_GROUP_UL, true,
  694. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  695. QMB_MASTER_SELECT_DDR,
  696. {2, 0, 8, 16, IPA_EE_UC} },
  697. /* Only for test purpose */
  698. [IPA_3_0][IPA_CLIENT_TEST_PROD] = {
  699. true, IPA_v3_0_GROUP_UL, true,
  700. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  701. QMB_MASTER_SELECT_DDR,
  702. { 1, 3, 8, 16, IPA_EE_AP } },
  703. [IPA_3_0][IPA_CLIENT_TEST1_PROD] = {
  704. true, IPA_v3_0_GROUP_UL, true,
  705. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  706. QMB_MASTER_SELECT_DDR,
  707. { 1, 3, 8, 16, IPA_EE_AP } },
  708. [IPA_3_0][IPA_CLIENT_TEST2_PROD] = {
  709. true, IPA_v3_0_GROUP_UL, true,
  710. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  711. QMB_MASTER_SELECT_DDR,
  712. { 3, 5, 16, 32, IPA_EE_AP } },
  713. [IPA_3_0][IPA_CLIENT_TEST3_PROD] = {
  714. true, IPA_v3_0_GROUP_UL, true,
  715. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  716. QMB_MASTER_SELECT_DDR,
  717. { 12, 9, 8, 16, IPA_EE_AP } },
  718. [IPA_3_0][IPA_CLIENT_TEST4_PROD] = {
  719. true, IPA_v3_0_GROUP_UL, true,
  720. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  721. QMB_MASTER_SELECT_DDR,
  722. { 13, 10, 8, 16, IPA_EE_AP } },
  723. [IPA_3_0][IPA_CLIENT_WLAN1_CONS] = {
  724. true, IPA_v3_0_GROUP_DL, false,
  725. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  726. QMB_MASTER_SELECT_DDR,
  727. { 25, 4, 8, 8, IPA_EE_UC } },
  728. [IPA_3_0][IPA_CLIENT_WLAN2_CONS] = {
  729. true, IPA_v3_0_GROUP_DL, false,
  730. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  731. QMB_MASTER_SELECT_DDR,
  732. { 27, 4, 8, 8, IPA_EE_AP } },
  733. [IPA_3_0][IPA_CLIENT_WLAN3_CONS] = {
  734. true, IPA_v3_0_GROUP_DL, false,
  735. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  736. QMB_MASTER_SELECT_DDR,
  737. { 28, 13, 8, 8, IPA_EE_AP } },
  738. [IPA_3_0][IPA_CLIENT_WLAN4_CONS] = {
  739. true, IPA_v3_0_GROUP_DL, false,
  740. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  741. QMB_MASTER_SELECT_DDR,
  742. { 29, 14, 8, 8, IPA_EE_AP } },
  743. [IPA_3_0][IPA_CLIENT_USB_CONS] = {
  744. true, IPA_v3_0_GROUP_DL, false,
  745. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  746. QMB_MASTER_SELECT_DDR,
  747. { 26, 12, 8, 8, IPA_EE_AP } },
  748. [IPA_3_0][IPA_CLIENT_USB_DPL_CONS] = {
  749. true, IPA_v3_0_GROUP_DPL, false,
  750. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  751. QMB_MASTER_SELECT_DDR,
  752. { 17, 2, 8, 12, IPA_EE_AP } },
  753. [IPA_3_0][IPA_CLIENT_APPS_LAN_CONS] = {
  754. true, IPA_v3_0_GROUP_UL, false,
  755. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  756. QMB_MASTER_SELECT_DDR,
  757. { 15, 7, 8, 12, IPA_EE_AP } },
  758. [IPA_3_0][IPA_CLIENT_APPS_WAN_CONS] = {
  759. true, IPA_v3_0_GROUP_DL, false,
  760. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  761. QMB_MASTER_SELECT_DDR,
  762. { 16, 8, 8, 12, IPA_EE_AP } },
  763. [IPA_3_0][IPA_CLIENT_ODU_EMB_CONS] = {
  764. true, IPA_v3_0_GROUP_DL, false,
  765. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  766. QMB_MASTER_SELECT_DDR,
  767. { 23, 1, 8, 8, IPA_EE_AP } },
  768. [IPA_3_0][IPA_CLIENT_MHI_CONS] = {
  769. true, IPA_v3_0_GROUP_DL, false,
  770. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  771. QMB_MASTER_SELECT_PCIE,
  772. { 23, 1, 8, 8, IPA_EE_AP } },
  773. [IPA_3_0][IPA_CLIENT_Q6_LAN_CONS] = {
  774. true, IPA_v3_0_GROUP_DL, false,
  775. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  776. QMB_MASTER_SELECT_DDR,
  777. { 19, 6, 8, 12, IPA_EE_Q6 } },
  778. [IPA_3_0][IPA_CLIENT_Q6_WAN_CONS] = {
  779. true, IPA_v3_0_GROUP_UL, false,
  780. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  781. QMB_MASTER_SELECT_DDR,
  782. { 18, 5, 8, 12, IPA_EE_Q6 } },
  783. [IPA_3_0][IPA_CLIENT_Q6_DUN_CONS] = {
  784. true, IPA_v3_0_GROUP_DIAG, false,
  785. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  786. QMB_MASTER_SELECT_DDR,
  787. { 30, 7, 4, 4, IPA_EE_Q6 } },
  788. [IPA_3_0][IPA_CLIENT_Q6_DECOMP_CONS] = {
  789. true, IPA_v3_0_GROUP_Q6ZIP, false,
  790. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  791. QMB_MASTER_SELECT_DDR,
  792. { 21, 8, 4, 4, IPA_EE_Q6 } },
  793. [IPA_3_0][IPA_CLIENT_Q6_DECOMP2_CONS] = {
  794. true, IPA_v3_0_GROUP_Q6ZIP, false,
  795. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  796. QMB_MASTER_SELECT_DDR,
  797. { 4, 9, 4, 4, IPA_EE_Q6 } },
  798. [IPA_3_0][IPA_CLIENT_MEMCPY_DMA_SYNC_CONS] = {
  799. true, IPA_v3_0_GROUP_DMA, false,
  800. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  801. QMB_MASTER_SELECT_PCIE,
  802. { 28, 13, 8, 8, IPA_EE_AP } },
  803. [IPA_3_0][IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS] = {
  804. true, IPA_v3_0_GROUP_DMA, false,
  805. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  806. QMB_MASTER_SELECT_PCIE,
  807. { 29, 14, 8, 8, IPA_EE_AP } },
  808. [IPA_3_0][IPA_CLIENT_ETHERNET_CONS] = {
  809. true, IPA_v3_0_GROUP_DL, false,
  810. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  811. QMB_MASTER_SELECT_DDR,
  812. {24, 3, 8, 8, IPA_EE_UC} },
  813. /* Only for test purpose */
  814. [IPA_3_0][IPA_CLIENT_TEST_CONS] = {
  815. true, IPA_v3_0_GROUP_DL, false,
  816. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  817. QMB_MASTER_SELECT_DDR,
  818. { 26, 12, 8, 8, IPA_EE_AP } },
  819. [IPA_3_0][IPA_CLIENT_TEST1_CONS] = {
  820. true, IPA_v3_0_GROUP_DL, false,
  821. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  822. QMB_MASTER_SELECT_DDR,
  823. { 26, 12, 8, 8, IPA_EE_AP } },
  824. [IPA_3_0][IPA_CLIENT_TEST2_CONS] = {
  825. true, IPA_v3_0_GROUP_DL, false,
  826. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  827. QMB_MASTER_SELECT_DDR,
  828. { 27, 4, 8, 8, IPA_EE_AP } },
  829. [IPA_3_0][IPA_CLIENT_TEST3_CONS] = {
  830. true, IPA_v3_0_GROUP_DL, false,
  831. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  832. QMB_MASTER_SELECT_DDR,
  833. { 28, 13, 8, 8, IPA_EE_AP } },
  834. [IPA_3_0][IPA_CLIENT_TEST4_CONS] = {
  835. true, IPA_v3_0_GROUP_DL, false,
  836. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  837. QMB_MASTER_SELECT_DDR,
  838. { 29, 14, 8, 8, IPA_EE_AP } },
  839. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  840. [IPA_3_0][IPA_CLIENT_DUMMY_CONS] = {
  841. true, IPA_v3_0_GROUP_DL, false,
  842. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  843. QMB_MASTER_SELECT_DDR,
  844. { 31, 31, 8, 8, IPA_EE_AP } },
  845. /* IPA_3_5 */
  846. [IPA_3_5][IPA_CLIENT_WLAN1_PROD] = {
  847. true, IPA_v3_5_GROUP_UL_DL, true,
  848. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  849. QMB_MASTER_SELECT_DDR,
  850. { 6, 1, 8, 16, IPA_EE_UC } },
  851. [IPA_3_5][IPA_CLIENT_USB_PROD] = {
  852. true, IPA_v3_5_GROUP_UL_DL, true,
  853. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  854. QMB_MASTER_SELECT_DDR,
  855. { 0, 7, 8, 16, IPA_EE_AP } },
  856. [IPA_3_5][IPA_CLIENT_APPS_LAN_PROD] = {
  857. true, IPA_v3_5_GROUP_UL_DL, false,
  858. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  859. QMB_MASTER_SELECT_DDR,
  860. { 8, 9, 8, 16, IPA_EE_AP } },
  861. [IPA_3_5][IPA_CLIENT_APPS_WAN_PROD] = {
  862. true, IPA_v3_5_GROUP_UL_DL, true,
  863. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  864. QMB_MASTER_SELECT_DDR,
  865. { 2, 3, 16, 32, IPA_EE_AP } },
  866. [IPA_3_5][IPA_CLIENT_APPS_CMD_PROD] = {
  867. true, IPA_v3_5_GROUP_UL_DL, false,
  868. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  869. QMB_MASTER_SELECT_DDR,
  870. { 5, 4, 20, 23, IPA_EE_AP } },
  871. [IPA_3_5][IPA_CLIENT_ODU_PROD] = {
  872. true, IPA_v3_5_GROUP_UL_DL, true,
  873. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  874. QMB_MASTER_SELECT_DDR,
  875. { 1, 0, 8, 16, IPA_EE_UC } },
  876. [IPA_3_5][IPA_CLIENT_Q6_LAN_PROD] = {
  877. true, IPA_v3_5_GROUP_UL_DL, true,
  878. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  879. QMB_MASTER_SELECT_DDR,
  880. { 3, 0, 16, 32, IPA_EE_Q6 } },
  881. [IPA_3_5][IPA_CLIENT_Q6_CMD_PROD] = {
  882. true, IPA_v3_5_GROUP_UL_DL, false,
  883. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  884. QMB_MASTER_SELECT_DDR,
  885. { 4, 1, 20, 23, IPA_EE_Q6 } },
  886. /* Only for test purpose */
  887. [IPA_3_5][IPA_CLIENT_TEST_PROD] = {
  888. true, IPA_v3_5_GROUP_UL_DL, true,
  889. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  890. QMB_MASTER_SELECT_DDR,
  891. {0, 7, 8, 16, IPA_EE_AP } },
  892. [IPA_3_5][IPA_CLIENT_TEST1_PROD] = {
  893. true, IPA_v3_5_GROUP_UL_DL, true,
  894. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  895. QMB_MASTER_SELECT_DDR,
  896. {0, 7, 8, 16, IPA_EE_AP } },
  897. [IPA_3_5][IPA_CLIENT_TEST2_PROD] = {
  898. true, IPA_v3_5_GROUP_UL_DL, true,
  899. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  900. QMB_MASTER_SELECT_DDR,
  901. { 1, 0, 8, 16, IPA_EE_AP } },
  902. [IPA_3_5][IPA_CLIENT_TEST3_PROD] = {
  903. true, IPA_v3_5_GROUP_UL_DL, true,
  904. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  905. QMB_MASTER_SELECT_DDR,
  906. {7, 8, 8, 16, IPA_EE_AP } },
  907. [IPA_3_5][IPA_CLIENT_TEST4_PROD] = {
  908. true, IPA_v3_5_GROUP_UL_DL, true,
  909. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  910. QMB_MASTER_SELECT_DDR,
  911. { 8, 9, 8, 16, IPA_EE_AP } },
  912. [IPA_3_5][IPA_CLIENT_WLAN1_CONS] = {
  913. true, IPA_v3_5_GROUP_UL_DL, false,
  914. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  915. QMB_MASTER_SELECT_DDR,
  916. { 16, 3, 8, 8, IPA_EE_UC } },
  917. [IPA_3_5][IPA_CLIENT_WLAN2_CONS] = {
  918. true, IPA_v3_5_GROUP_UL_DL, false,
  919. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  920. QMB_MASTER_SELECT_DDR,
  921. { 18, 12, 8, 8, IPA_EE_AP } },
  922. [IPA_3_5][IPA_CLIENT_WLAN3_CONS] = {
  923. true, IPA_v3_5_GROUP_UL_DL, false,
  924. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  925. QMB_MASTER_SELECT_DDR,
  926. { 19, 13, 8, 8, IPA_EE_AP } },
  927. [IPA_3_5][IPA_CLIENT_USB_CONS] = {
  928. true, IPA_v3_5_GROUP_UL_DL, false,
  929. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  930. QMB_MASTER_SELECT_PCIE,
  931. { 17, 11, 8, 8, IPA_EE_AP } },
  932. [IPA_3_5][IPA_CLIENT_USB_DPL_CONS] = {
  933. true, IPA_v3_5_GROUP_UL_DL, false,
  934. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  935. QMB_MASTER_SELECT_DDR,
  936. { 14, 10, 4, 6, IPA_EE_AP } },
  937. [IPA_3_5][IPA_CLIENT_APPS_LAN_CONS] = {
  938. true, IPA_v3_5_GROUP_UL_DL, false,
  939. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  940. QMB_MASTER_SELECT_DDR,
  941. { 9, 5, 8, 12, IPA_EE_AP } },
  942. [IPA_3_5][IPA_CLIENT_APPS_WAN_CONS] = {
  943. true, IPA_v3_5_GROUP_UL_DL, false,
  944. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  945. QMB_MASTER_SELECT_DDR,
  946. { 10, 6, 8, 12, IPA_EE_AP } },
  947. [IPA_3_5][IPA_CLIENT_ODU_EMB_CONS] = {
  948. true, IPA_v3_5_GROUP_UL_DL, false,
  949. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  950. QMB_MASTER_SELECT_DDR,
  951. { 15, 1, 8, 8, IPA_EE_AP } },
  952. [IPA_3_5][IPA_CLIENT_Q6_LAN_CONS] = {
  953. true, IPA_v3_5_GROUP_UL_DL, false,
  954. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  955. QMB_MASTER_SELECT_DDR,
  956. { 13, 3, 8, 12, IPA_EE_Q6 } },
  957. [IPA_3_5][IPA_CLIENT_Q6_WAN_CONS] = {
  958. true, IPA_v3_5_GROUP_UL_DL, false,
  959. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  960. QMB_MASTER_SELECT_DDR,
  961. { 12, 2, 8, 12, IPA_EE_Q6 } },
  962. /* Only for test purpose */
  963. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  964. [IPA_3_5][IPA_CLIENT_TEST_CONS] = {
  965. true, IPA_v3_5_GROUP_UL_DL, false,
  966. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  967. QMB_MASTER_SELECT_PCIE,
  968. { 15, 1, 8, 8, IPA_EE_AP } },
  969. [IPA_3_5][IPA_CLIENT_TEST1_CONS] = {
  970. true, IPA_v3_5_GROUP_UL_DL, false,
  971. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  972. QMB_MASTER_SELECT_DDR,
  973. { 15, 1, 8, 8, IPA_EE_AP } },
  974. [IPA_3_5][IPA_CLIENT_TEST2_CONS] = {
  975. true, IPA_v3_5_GROUP_UL_DL, false,
  976. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  977. QMB_MASTER_SELECT_PCIE,
  978. { 17, 11, 8, 8, IPA_EE_AP } },
  979. [IPA_3_5][IPA_CLIENT_TEST3_CONS] = {
  980. true, IPA_v3_5_GROUP_UL_DL, false,
  981. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  982. QMB_MASTER_SELECT_DDR,
  983. { 18, 12, 8, 8, IPA_EE_AP } },
  984. [IPA_3_5][IPA_CLIENT_TEST4_CONS] = {
  985. true, IPA_v3_5_GROUP_UL_DL, false,
  986. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  987. QMB_MASTER_SELECT_PCIE,
  988. { 19, 13, 8, 8, IPA_EE_AP } },
  989. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  990. [IPA_3_5][IPA_CLIENT_DUMMY_CONS] = {
  991. true, IPA_v3_5_GROUP_UL_DL, false,
  992. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  993. QMB_MASTER_SELECT_PCIE,
  994. { 31, 31, 8, 8, IPA_EE_AP } },
  995. /* IPA_3_5_MHI */
  996. [IPA_3_5_MHI][IPA_CLIENT_USB_PROD] = {
  997. false, IPA_EP_NOT_ALLOCATED, false,
  998. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  999. QMB_MASTER_SELECT_DDR,
  1000. { -1, -1, -1, -1, -1 } },
  1001. [IPA_3_5_MHI][IPA_CLIENT_APPS_WAN_PROD] = {
  1002. true, IPA_v3_5_MHI_GROUP_DDR, true,
  1003. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1004. QMB_MASTER_SELECT_DDR,
  1005. { 2, 3, 16, 32, IPA_EE_AP } },
  1006. [IPA_3_5_MHI][IPA_CLIENT_APPS_CMD_PROD] = {
  1007. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1008. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1009. QMB_MASTER_SELECT_DDR,
  1010. { 5, 4, 20, 23, IPA_EE_AP } },
  1011. [IPA_3_5_MHI][IPA_CLIENT_MHI_PROD] = {
  1012. true, IPA_v3_5_MHI_GROUP_PCIE, true,
  1013. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1014. QMB_MASTER_SELECT_PCIE,
  1015. { 1, 0, 8, 16, IPA_EE_AP } },
  1016. [IPA_3_5_MHI][IPA_CLIENT_Q6_LAN_PROD] = {
  1017. true, IPA_v3_5_MHI_GROUP_DDR, true,
  1018. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1019. QMB_MASTER_SELECT_DDR,
  1020. { 3, 0, 16, 32, IPA_EE_Q6 } },
  1021. [IPA_3_5_MHI][IPA_CLIENT_Q6_WAN_PROD] = {
  1022. true, IPA_v3_5_MHI_GROUP_DDR, true,
  1023. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1024. QMB_MASTER_SELECT_DDR,
  1025. { 6, 4, 10, 30, IPA_EE_Q6 } },
  1026. [IPA_3_5_MHI][IPA_CLIENT_Q6_CMD_PROD] = {
  1027. true, IPA_v3_5_MHI_GROUP_PCIE, false,
  1028. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1029. QMB_MASTER_SELECT_DDR,
  1030. { 4, 1, 20, 23, IPA_EE_Q6 } },
  1031. [IPA_3_5_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_PROD] = {
  1032. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1033. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1034. QMB_MASTER_SELECT_DDR,
  1035. { 7, 8, 8, 16, IPA_EE_AP } },
  1036. [IPA_3_5_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD] = {
  1037. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1038. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1039. QMB_MASTER_SELECT_DDR,
  1040. { 8, 9, 8, 16, IPA_EE_AP } },
  1041. /* Only for test purpose */
  1042. [IPA_3_5_MHI][IPA_CLIENT_TEST_PROD] = {
  1043. true, IPA_v3_5_MHI_GROUP_DDR, true,
  1044. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1045. QMB_MASTER_SELECT_DDR,
  1046. {0, 7, 8, 16, IPA_EE_AP } },
  1047. [IPA_3_5_MHI][IPA_CLIENT_TEST1_PROD] = {
  1048. 0, IPA_v3_5_MHI_GROUP_DDR, true,
  1049. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1050. QMB_MASTER_SELECT_DDR,
  1051. {0, 7, 8, 16, IPA_EE_AP } },
  1052. [IPA_3_5_MHI][IPA_CLIENT_TEST2_PROD] = {
  1053. true, IPA_v3_5_MHI_GROUP_PCIE, true,
  1054. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1055. QMB_MASTER_SELECT_PCIE,
  1056. { 1, 0, 8, 16, IPA_EE_AP } },
  1057. [IPA_3_5_MHI][IPA_CLIENT_TEST3_PROD] = {
  1058. true, IPA_v3_5_MHI_GROUP_DMA, true,
  1059. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1060. QMB_MASTER_SELECT_DDR,
  1061. { 7, 8, 8, 16, IPA_EE_AP } },
  1062. [IPA_3_5_MHI][IPA_CLIENT_TEST4_PROD] = {
  1063. true, IPA_v3_5_MHI_GROUP_DMA, true,
  1064. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1065. QMB_MASTER_SELECT_DDR,
  1066. { 8, 9, 8, 16, IPA_EE_AP } },
  1067. [IPA_3_5_MHI][IPA_CLIENT_WLAN1_CONS] = {
  1068. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1069. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1070. QMB_MASTER_SELECT_DDR,
  1071. { 16, 3, 8, 8, IPA_EE_UC } },
  1072. [IPA_3_5_MHI][IPA_CLIENT_USB_CONS] = {
  1073. false, IPA_EP_NOT_ALLOCATED, false,
  1074. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1075. QMB_MASTER_SELECT_DDR,
  1076. { -1, -1, -1, -1, -1 } },
  1077. [IPA_3_5_MHI][IPA_CLIENT_USB_DPL_CONS] = {
  1078. false, IPA_EP_NOT_ALLOCATED, false,
  1079. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1080. QMB_MASTER_SELECT_DDR,
  1081. { -1, -1, -1, -1, -1 } },
  1082. [IPA_3_5_MHI][IPA_CLIENT_APPS_LAN_CONS] = {
  1083. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1084. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1085. QMB_MASTER_SELECT_DDR,
  1086. { 9, 5, 8, 12, IPA_EE_AP } },
  1087. [IPA_3_5_MHI][IPA_CLIENT_APPS_WAN_CONS] = {
  1088. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1089. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1090. QMB_MASTER_SELECT_DDR,
  1091. { 10, 6, 8, 12, IPA_EE_AP } },
  1092. [IPA_3_5_MHI][IPA_CLIENT_MHI_CONS] = {
  1093. true, IPA_v3_5_MHI_GROUP_PCIE, false,
  1094. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1095. QMB_MASTER_SELECT_PCIE,
  1096. { 15, 1, 8, 8, IPA_EE_AP } },
  1097. [IPA_3_5_MHI][IPA_CLIENT_Q6_LAN_CONS] = {
  1098. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1099. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1100. QMB_MASTER_SELECT_DDR,
  1101. { 13, 3, 8, 12, IPA_EE_Q6 } },
  1102. [IPA_3_5_MHI][IPA_CLIENT_Q6_WAN_CONS] = {
  1103. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1104. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1105. QMB_MASTER_SELECT_DDR,
  1106. { 12, 2, 8, 12, IPA_EE_Q6 } },
  1107. [IPA_3_5_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_CONS] = {
  1108. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1109. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1110. QMB_MASTER_SELECT_PCIE,
  1111. { 18, 12, 8, 8, IPA_EE_AP } },
  1112. [IPA_3_5_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS] = {
  1113. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1114. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1115. QMB_MASTER_SELECT_PCIE,
  1116. { 19, 13, 8, 8, IPA_EE_AP } },
  1117. /* Only for test purpose */
  1118. [IPA_3_5_MHI][IPA_CLIENT_TEST_CONS] = {
  1119. true, IPA_v3_5_MHI_GROUP_PCIE, false,
  1120. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1121. QMB_MASTER_SELECT_PCIE,
  1122. { 15, 1, 8, 8, IPA_EE_AP } },
  1123. [IPA_3_5_MHI][IPA_CLIENT_TEST1_CONS] = {
  1124. true, IPA_v3_5_MHI_GROUP_PCIE, false,
  1125. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1126. QMB_MASTER_SELECT_PCIE,
  1127. { 15, 1, 8, 8, IPA_EE_AP } },
  1128. [IPA_3_5_MHI][IPA_CLIENT_TEST2_CONS] = {
  1129. true, IPA_v3_5_MHI_GROUP_DDR, false,
  1130. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1131. QMB_MASTER_SELECT_DDR,
  1132. { 17, 11, 8, 8, IPA_EE_AP } },
  1133. [IPA_3_5_MHI][IPA_CLIENT_TEST3_CONS] = {
  1134. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1135. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1136. QMB_MASTER_SELECT_PCIE,
  1137. { 18, 12, 8, 8, IPA_EE_AP } },
  1138. [IPA_3_5_MHI][IPA_CLIENT_TEST4_CONS] = {
  1139. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1140. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1141. QMB_MASTER_SELECT_PCIE,
  1142. { 19, 13, 8, 8, IPA_EE_AP } },
  1143. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  1144. [IPA_3_5_MHI][IPA_CLIENT_DUMMY_CONS] = {
  1145. true, IPA_v3_5_MHI_GROUP_DMA, false,
  1146. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1147. QMB_MASTER_SELECT_PCIE,
  1148. { 31, 31, 8, 8, IPA_EE_AP } },
  1149. /* IPA_3_5_1 */
  1150. [IPA_3_5_1][IPA_CLIENT_WLAN1_PROD] = {
  1151. true, IPA_v3_5_GROUP_UL_DL, true,
  1152. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1153. QMB_MASTER_SELECT_DDR,
  1154. { 7, 1, 8, 16, IPA_EE_UC } },
  1155. [IPA_3_5_1][IPA_CLIENT_USB_PROD] = {
  1156. true, IPA_v3_5_GROUP_UL_DL, true,
  1157. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1158. QMB_MASTER_SELECT_DDR,
  1159. { 0, 0, 8, 16, IPA_EE_AP } },
  1160. [IPA_3_5_1][IPA_CLIENT_APPS_LAN_PROD] = {
  1161. true, IPA_v3_5_GROUP_UL_DL, false,
  1162. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1163. QMB_MASTER_SELECT_DDR,
  1164. { 8, 7, 8, 16, IPA_EE_AP } },
  1165. [IPA_3_5_1][IPA_CLIENT_APPS_WAN_PROD] = {
  1166. true, IPA_v3_5_GROUP_UL_DL, true,
  1167. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1168. QMB_MASTER_SELECT_DDR,
  1169. { 2, 3, 16, 32, IPA_EE_AP } },
  1170. [IPA_3_5_1][IPA_CLIENT_APPS_CMD_PROD] = {
  1171. true, IPA_v3_5_GROUP_UL_DL, false,
  1172. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1173. QMB_MASTER_SELECT_DDR,
  1174. { 5, 4, 20, 23, IPA_EE_AP } },
  1175. [IPA_3_5_1][IPA_CLIENT_Q6_LAN_PROD] = {
  1176. true, IPA_v3_5_GROUP_UL_DL, true,
  1177. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1178. QMB_MASTER_SELECT_DDR,
  1179. { 3, 0, 16, 32, IPA_EE_Q6 } },
  1180. [IPA_3_5_1][IPA_CLIENT_Q6_WAN_PROD] = {
  1181. true, IPA_v3_5_GROUP_UL_DL, true,
  1182. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1183. QMB_MASTER_SELECT_DDR,
  1184. { 6, 4, 12, 30, IPA_EE_Q6 } },
  1185. [IPA_3_5_1][IPA_CLIENT_Q6_CMD_PROD] = {
  1186. true, IPA_v3_5_GROUP_UL_DL, false,
  1187. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1188. QMB_MASTER_SELECT_DDR,
  1189. { 4, 1, 20, 23, IPA_EE_Q6 } },
  1190. /* Only for test purpose */
  1191. [IPA_3_5_1][IPA_CLIENT_TEST_PROD] = {
  1192. true, IPA_v3_5_GROUP_UL_DL, true,
  1193. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1194. QMB_MASTER_SELECT_DDR,
  1195. { 0, 0, 8, 16, IPA_EE_AP } },
  1196. [IPA_3_5_1][IPA_CLIENT_TEST1_PROD] = {
  1197. true, IPA_v3_5_GROUP_UL_DL, true,
  1198. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1199. QMB_MASTER_SELECT_DDR,
  1200. { 0, 0, 8, 16, IPA_EE_AP } },
  1201. [IPA_3_5_1][IPA_CLIENT_TEST2_PROD] = {
  1202. true, IPA_v3_5_GROUP_UL_DL, true,
  1203. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1204. QMB_MASTER_SELECT_DDR,
  1205. { 2, 3, 16, 32, IPA_EE_AP } },
  1206. [IPA_3_5_1][IPA_CLIENT_TEST3_PROD] = {
  1207. true, IPA_v3_5_GROUP_UL_DL, true,
  1208. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1209. QMB_MASTER_SELECT_DDR,
  1210. { 4, 1, 20, 23, IPA_EE_Q6 } },
  1211. [IPA_3_5_1][IPA_CLIENT_TEST4_PROD] = {
  1212. true, IPA_v3_5_GROUP_UL_DL, true,
  1213. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1214. QMB_MASTER_SELECT_DDR,
  1215. { 1, 0, 8, 16, IPA_EE_UC } },
  1216. [IPA_3_5_1][IPA_CLIENT_WLAN1_CONS] = {
  1217. true, IPA_v3_5_GROUP_UL_DL, false,
  1218. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1219. QMB_MASTER_SELECT_DDR,
  1220. { 16, 11, 8, 8, IPA_EE_UC } },
  1221. [IPA_3_5_1][IPA_CLIENT_WLAN2_CONS] = {
  1222. true, IPA_v3_5_GROUP_UL_DL, false,
  1223. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1224. QMB_MASTER_SELECT_DDR,
  1225. { 18, 9, 8, 8, IPA_EE_AP } },
  1226. [IPA_3_5_1][IPA_CLIENT_WLAN3_CONS] = {
  1227. true, IPA_v3_5_GROUP_UL_DL, false,
  1228. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1229. QMB_MASTER_SELECT_DDR,
  1230. { 19, 10, 8, 8, IPA_EE_AP } },
  1231. [IPA_3_5_1][IPA_CLIENT_USB_CONS] = {
  1232. true, IPA_v3_5_GROUP_UL_DL, false,
  1233. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1234. QMB_MASTER_SELECT_DDR,
  1235. { 17, 8, 8, 8, IPA_EE_AP } },
  1236. [IPA_3_5_1][IPA_CLIENT_USB_DPL_CONS] = {
  1237. true, IPA_v3_5_GROUP_UL_DL, false,
  1238. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1239. QMB_MASTER_SELECT_DDR,
  1240. { 11, 2, 4, 6, IPA_EE_AP } },
  1241. [IPA_3_5_1][IPA_CLIENT_APPS_LAN_CONS] = {
  1242. true, IPA_v3_5_GROUP_UL_DL, false,
  1243. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1244. QMB_MASTER_SELECT_DDR,
  1245. { 9, 5, 8, 12, IPA_EE_AP } },
  1246. [IPA_3_5_1][IPA_CLIENT_APPS_WAN_CONS] = {
  1247. true, IPA_v3_5_GROUP_UL_DL, false,
  1248. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1249. QMB_MASTER_SELECT_DDR,
  1250. { 10, 6, 8, 12, IPA_EE_AP } },
  1251. [IPA_3_5_1][IPA_CLIENT_Q6_LAN_CONS] = {
  1252. true, IPA_v3_5_GROUP_UL_DL, false,
  1253. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1254. QMB_MASTER_SELECT_DDR,
  1255. { 13, 3, 8, 12, IPA_EE_Q6 } },
  1256. [IPA_3_5_1][IPA_CLIENT_Q6_WAN_CONS] = {
  1257. true, IPA_v3_5_GROUP_UL_DL, false,
  1258. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1259. QMB_MASTER_SELECT_DDR,
  1260. { 12, 2, 8, 12, IPA_EE_Q6 } },
  1261. /* Only for test purpose */
  1262. [IPA_3_5_1][IPA_CLIENT_TEST_CONS] = {
  1263. true, IPA_v3_5_GROUP_UL_DL,
  1264. false,
  1265. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1266. QMB_MASTER_SELECT_DDR,
  1267. { 17, 8, 8, 8, IPA_EE_AP } },
  1268. [IPA_3_5_1][IPA_CLIENT_TEST1_CONS] = {
  1269. true, IPA_v3_5_GROUP_UL_DL,
  1270. false,
  1271. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1272. QMB_MASTER_SELECT_DDR,
  1273. { 17, 8, 8, 8, IPA_EE_AP } },
  1274. [IPA_3_5_1][IPA_CLIENT_TEST2_CONS] = {
  1275. true, IPA_v3_5_GROUP_UL_DL,
  1276. false,
  1277. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1278. QMB_MASTER_SELECT_DDR,
  1279. { 18, 9, 8, 8, IPA_EE_AP } },
  1280. [IPA_3_5_1][IPA_CLIENT_TEST3_CONS] = {
  1281. true, IPA_v3_5_GROUP_UL_DL,
  1282. false,
  1283. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1284. QMB_MASTER_SELECT_DDR,
  1285. { 19, 10, 8, 8, IPA_EE_AP } },
  1286. [IPA_3_5_1][IPA_CLIENT_TEST4_CONS] = {
  1287. true, IPA_v3_5_GROUP_UL_DL,
  1288. false,
  1289. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1290. QMB_MASTER_SELECT_DDR,
  1291. { 11, 2, 4, 6, IPA_EE_AP } },
  1292. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  1293. [IPA_3_5_1][IPA_CLIENT_DUMMY_CONS] = {
  1294. true, IPA_v3_5_GROUP_UL_DL,
  1295. false,
  1296. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1297. QMB_MASTER_SELECT_DDR,
  1298. { 31, 31, 8, 8, IPA_EE_AP } },
  1299. /* IPA_4_0 */
  1300. [IPA_4_0][IPA_CLIENT_WLAN1_PROD] = {
  1301. true, IPA_v4_0_GROUP_UL_DL,
  1302. true,
  1303. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1304. QMB_MASTER_SELECT_DDR,
  1305. { 6, 2, 8, 16, IPA_EE_UC } },
  1306. [IPA_4_0][IPA_CLIENT_USB_PROD] = {
  1307. true, IPA_v4_0_GROUP_UL_DL,
  1308. true,
  1309. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1310. QMB_MASTER_SELECT_DDR,
  1311. { 0, 8, 8, 16, IPA_EE_AP } },
  1312. [IPA_4_0][IPA_CLIENT_APPS_LAN_PROD] = {
  1313. true, IPA_v4_0_GROUP_UL_DL,
  1314. false,
  1315. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1316. QMB_MASTER_SELECT_DDR,
  1317. { 8, 10, 8, 16, IPA_EE_AP } },
  1318. [IPA_4_0][IPA_CLIENT_APPS_WAN_PROD] = {
  1319. true, IPA_v4_0_GROUP_UL_DL,
  1320. true,
  1321. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1322. QMB_MASTER_SELECT_DDR,
  1323. { 2, 3, 16, 32, IPA_EE_AP } },
  1324. [IPA_4_0][IPA_CLIENT_APPS_CMD_PROD] = {
  1325. true, IPA_v4_0_GROUP_UL_DL,
  1326. false,
  1327. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1328. QMB_MASTER_SELECT_DDR,
  1329. { 5, 4, 20, 24, IPA_EE_AP } },
  1330. [IPA_4_0][IPA_CLIENT_ODU_PROD] = {
  1331. true, IPA_v4_0_GROUP_UL_DL,
  1332. true,
  1333. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1334. QMB_MASTER_SELECT_DDR,
  1335. { 1, 0, 8, 16, IPA_EE_AP } },
  1336. [IPA_4_0][IPA_CLIENT_ETHERNET_PROD] = {
  1337. true, IPA_v4_0_GROUP_UL_DL,
  1338. true,
  1339. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1340. QMB_MASTER_SELECT_DDR,
  1341. { 9, 0, 8, 16, IPA_EE_UC } },
  1342. [IPA_4_0][IPA_CLIENT_Q6_WAN_PROD] = {
  1343. true, IPA_v4_0_GROUP_UL_DL,
  1344. true,
  1345. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1346. QMB_MASTER_SELECT_DDR,
  1347. { 3, 0, 16, 32, IPA_EE_Q6 } },
  1348. [IPA_4_0][IPA_CLIENT_Q6_CMD_PROD] = {
  1349. true, IPA_v4_0_GROUP_UL_DL,
  1350. false,
  1351. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1352. QMB_MASTER_SELECT_DDR,
  1353. { 4, 1, 20, 24, IPA_EE_Q6 } },
  1354. /* Only for test purpose */
  1355. [IPA_4_0][IPA_CLIENT_TEST_PROD] = {
  1356. true, IPA_v4_0_GROUP_UL_DL,
  1357. true,
  1358. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1359. QMB_MASTER_SELECT_DDR,
  1360. {0, 8, 8, 16, IPA_EE_AP } },
  1361. [IPA_4_0][IPA_CLIENT_TEST1_PROD] = {
  1362. true, IPA_v4_0_GROUP_UL_DL,
  1363. true,
  1364. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1365. QMB_MASTER_SELECT_DDR,
  1366. {0, 8, 8, 16, IPA_EE_AP } },
  1367. [IPA_4_0][IPA_CLIENT_TEST2_PROD] = {
  1368. true, IPA_v4_0_GROUP_UL_DL,
  1369. true,
  1370. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1371. QMB_MASTER_SELECT_DDR,
  1372. { 1, 0, 8, 16, IPA_EE_AP } },
  1373. [IPA_4_0][IPA_CLIENT_TEST3_PROD] = {
  1374. true, IPA_v4_0_GROUP_UL_DL,
  1375. true,
  1376. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1377. QMB_MASTER_SELECT_DDR,
  1378. { 7, 9, 8, 16, IPA_EE_AP } },
  1379. [IPA_4_0][IPA_CLIENT_TEST4_PROD] = {
  1380. true, IPA_v4_0_GROUP_UL_DL,
  1381. true,
  1382. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1383. QMB_MASTER_SELECT_DDR,
  1384. {8, 10, 8, 16, IPA_EE_AP } },
  1385. [IPA_4_0][IPA_CLIENT_WLAN1_CONS] = {
  1386. true, IPA_v4_0_GROUP_UL_DL,
  1387. false,
  1388. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1389. QMB_MASTER_SELECT_DDR,
  1390. { 18, 3, 6, 9, IPA_EE_UC } },
  1391. [IPA_4_0][IPA_CLIENT_WLAN2_CONS] = {
  1392. true, IPA_v4_0_GROUP_UL_DL,
  1393. false,
  1394. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1395. QMB_MASTER_SELECT_DDR,
  1396. { 20, 13, 9, 9, IPA_EE_AP } },
  1397. [IPA_4_0][IPA_CLIENT_WLAN3_CONS] = {
  1398. true, IPA_v4_0_GROUP_UL_DL,
  1399. false,
  1400. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1401. QMB_MASTER_SELECT_DDR,
  1402. { 21, 14, 9, 9, IPA_EE_AP } },
  1403. [IPA_4_0][IPA_CLIENT_USB_CONS] = {
  1404. true, IPA_v4_0_GROUP_UL_DL,
  1405. false,
  1406. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1407. QMB_MASTER_SELECT_DDR,
  1408. { 19, 12, 9, 9, IPA_EE_AP } },
  1409. [IPA_4_0][IPA_CLIENT_USB_DPL_CONS] = {
  1410. true, IPA_v4_0_GROUP_UL_DL,
  1411. false,
  1412. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1413. QMB_MASTER_SELECT_DDR,
  1414. { 15, 7, 5, 5, IPA_EE_AP } },
  1415. [IPA_4_0][IPA_CLIENT_APPS_LAN_CONS] = {
  1416. true, IPA_v4_0_GROUP_UL_DL,
  1417. false,
  1418. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1419. QMB_MASTER_SELECT_DDR,
  1420. { 10, 5, 9, 9, IPA_EE_AP } },
  1421. [IPA_4_0][IPA_CLIENT_APPS_WAN_CONS] = {
  1422. true, IPA_v4_0_GROUP_UL_DL,
  1423. false,
  1424. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1425. QMB_MASTER_SELECT_DDR,
  1426. { 11, 6, 9, 9, IPA_EE_AP } },
  1427. [IPA_4_0][IPA_CLIENT_ODU_EMB_CONS] = {
  1428. true, IPA_v4_0_GROUP_UL_DL,
  1429. false,
  1430. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1431. QMB_MASTER_SELECT_DDR,
  1432. { 17, 1, 17, 17, IPA_EE_AP } },
  1433. [IPA_4_0][IPA_CLIENT_ETHERNET_CONS] = {
  1434. true, IPA_v4_0_GROUP_UL_DL,
  1435. false,
  1436. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1437. QMB_MASTER_SELECT_DDR,
  1438. { 22, 1, 17, 17, IPA_EE_UC } },
  1439. [IPA_4_0][IPA_CLIENT_Q6_LAN_CONS] = {
  1440. true, IPA_v4_0_GROUP_UL_DL,
  1441. false,
  1442. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1443. QMB_MASTER_SELECT_DDR,
  1444. { 14, 4, 9, 9, IPA_EE_Q6 } },
  1445. [IPA_4_0][IPA_CLIENT_Q6_WAN_CONS] = {
  1446. true, IPA_v4_0_GROUP_UL_DL,
  1447. false,
  1448. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1449. QMB_MASTER_SELECT_DDR,
  1450. { 13, 3, 9, 9, IPA_EE_Q6 } },
  1451. [IPA_4_0][IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS] = {
  1452. true, IPA_v4_0_GROUP_UL_DL,
  1453. false,
  1454. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1455. QMB_MASTER_SELECT_DDR,
  1456. { 16, 5, 9, 9, IPA_EE_Q6 } },
  1457. /* Only for test purpose */
  1458. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  1459. [IPA_4_0][IPA_CLIENT_TEST_CONS] = {
  1460. true, IPA_v4_0_GROUP_UL_DL,
  1461. false,
  1462. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1463. QMB_MASTER_SELECT_DDR,
  1464. { 11, 6, 9, 9, IPA_EE_AP } },
  1465. [IPA_4_0][IPA_CLIENT_TEST1_CONS] = {
  1466. true, IPA_v4_0_GROUP_UL_DL,
  1467. false,
  1468. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1469. QMB_MASTER_SELECT_DDR,
  1470. { 11, 6, 9, 9, IPA_EE_AP } },
  1471. [IPA_4_0][IPA_CLIENT_TEST2_CONS] = {
  1472. true, IPA_v4_0_GROUP_UL_DL,
  1473. false,
  1474. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1475. QMB_MASTER_SELECT_DDR,
  1476. { 12, 2, 5, 5, IPA_EE_AP } },
  1477. [IPA_4_0][IPA_CLIENT_TEST3_CONS] = {
  1478. true, IPA_v4_0_GROUP_UL_DL,
  1479. false,
  1480. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1481. QMB_MASTER_SELECT_DDR,
  1482. { 19, 12, 9, 9, IPA_EE_AP } },
  1483. [IPA_4_0][IPA_CLIENT_TEST4_CONS] = {
  1484. true, IPA_v4_0_GROUP_UL_DL,
  1485. false,
  1486. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1487. QMB_MASTER_SELECT_DDR,
  1488. { 21, 14, 9, 9, IPA_EE_AP } },
  1489. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  1490. [IPA_4_0][IPA_CLIENT_DUMMY_CONS] = {
  1491. true, IPA_v4_0_GROUP_UL_DL,
  1492. false,
  1493. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1494. QMB_MASTER_SELECT_DDR,
  1495. { 31, 31, 8, 8, IPA_EE_AP } },
  1496. /* IPA_4_0_MHI */
  1497. [IPA_4_0_MHI][IPA_CLIENT_APPS_WAN_PROD] = {
  1498. true, IPA_v4_0_MHI_GROUP_DDR,
  1499. true,
  1500. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1501. QMB_MASTER_SELECT_DDR,
  1502. { 2, 3, 16, 32, IPA_EE_AP } },
  1503. [IPA_4_0_MHI][IPA_CLIENT_APPS_CMD_PROD] = {
  1504. true, IPA_v4_0_MHI_GROUP_DDR,
  1505. false,
  1506. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1507. QMB_MASTER_SELECT_DDR,
  1508. { 5, 4, 20, 24, IPA_EE_AP } },
  1509. [IPA_4_0_MHI][IPA_CLIENT_MHI_PROD] = {
  1510. true, IPA_v4_0_MHI_GROUP_PCIE,
  1511. true,
  1512. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1513. QMB_MASTER_SELECT_PCIE,
  1514. { 1, 0, 8, 16, IPA_EE_AP } },
  1515. [IPA_4_0_MHI][IPA_CLIENT_Q6_WAN_PROD] = {
  1516. true, IPA_v4_0_GROUP_UL_DL,
  1517. true,
  1518. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1519. QMB_MASTER_SELECT_DDR,
  1520. { 3, 0, 16, 32, IPA_EE_Q6 } },
  1521. [IPA_4_0_MHI][IPA_CLIENT_Q6_CMD_PROD] = {
  1522. true, IPA_v4_0_MHI_GROUP_PCIE,
  1523. false,
  1524. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1525. QMB_MASTER_SELECT_DDR,
  1526. { 4, 1, 20, 24, IPA_EE_Q6 } },
  1527. [IPA_4_0_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_PROD] = {
  1528. true, IPA_v4_0_MHI_GROUP_DMA,
  1529. false,
  1530. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1531. QMB_MASTER_SELECT_DDR,
  1532. { 7, 9, 8, 16, IPA_EE_AP } },
  1533. [IPA_4_0_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD] = {
  1534. true, IPA_v4_0_MHI_GROUP_DMA,
  1535. false,
  1536. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1537. QMB_MASTER_SELECT_DDR,
  1538. { 8, 10, 8, 16, IPA_EE_AP } },
  1539. /* Only for test purpose */
  1540. [IPA_4_0_MHI][IPA_CLIENT_TEST_PROD] = {
  1541. true, IPA_v4_0_GROUP_UL_DL,
  1542. true,
  1543. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1544. QMB_MASTER_SELECT_DDR,
  1545. {0, 8, 8, 16, IPA_EE_AP } },
  1546. [IPA_4_0][IPA_CLIENT_TEST1_PROD] = {
  1547. true, IPA_v4_0_GROUP_UL_DL,
  1548. true,
  1549. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1550. QMB_MASTER_SELECT_DDR,
  1551. {0, 8, 8, 16, IPA_EE_AP } },
  1552. [IPA_4_0_MHI][IPA_CLIENT_TEST2_PROD] = {
  1553. true, IPA_v4_0_GROUP_UL_DL,
  1554. true,
  1555. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1556. QMB_MASTER_SELECT_DDR,
  1557. { 1, 0, 8, 16, IPA_EE_AP } },
  1558. [IPA_4_0_MHI][IPA_CLIENT_TEST3_PROD] = {
  1559. true, IPA_v4_0_GROUP_UL_DL,
  1560. true,
  1561. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1562. QMB_MASTER_SELECT_DDR,
  1563. { 7, 9, 8, 16, IPA_EE_AP } },
  1564. [IPA_4_0_MHI][IPA_CLIENT_TEST4_PROD] = {
  1565. true, IPA_v4_0_GROUP_UL_DL,
  1566. true,
  1567. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1568. QMB_MASTER_SELECT_DDR,
  1569. { 8, 10, 8, 16, IPA_EE_AP } },
  1570. [IPA_4_0_MHI][IPA_CLIENT_APPS_LAN_CONS] = {
  1571. true, IPA_v4_0_MHI_GROUP_DDR,
  1572. false,
  1573. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1574. QMB_MASTER_SELECT_DDR,
  1575. { 10, 5, 9, 9, IPA_EE_AP } },
  1576. [IPA_4_0_MHI][IPA_CLIENT_APPS_WAN_CONS] = {
  1577. true, IPA_v4_0_MHI_GROUP_DDR,
  1578. false,
  1579. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1580. QMB_MASTER_SELECT_DDR,
  1581. { 11, 6, 9, 9, IPA_EE_AP } },
  1582. [IPA_4_0_MHI][IPA_CLIENT_MHI_CONS] = {
  1583. true, IPA_v4_0_MHI_GROUP_PCIE,
  1584. false,
  1585. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1586. QMB_MASTER_SELECT_PCIE,
  1587. { 17, 1, 17, 17, IPA_EE_AP } },
  1588. [IPA_4_0_MHI][IPA_CLIENT_Q6_LAN_CONS] = {
  1589. true, IPA_v4_0_MHI_GROUP_DDR,
  1590. false,
  1591. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1592. QMB_MASTER_SELECT_DDR,
  1593. { 14, 4, 9, 9, IPA_EE_Q6 } },
  1594. [IPA_4_0_MHI][IPA_CLIENT_Q6_WAN_CONS] = {
  1595. true, IPA_v4_0_MHI_GROUP_DDR,
  1596. false,
  1597. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1598. QMB_MASTER_SELECT_DDR,
  1599. { 13, 3, 9, 9, IPA_EE_Q6 } },
  1600. [IPA_4_0_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_CONS] = {
  1601. true, IPA_v4_0_MHI_GROUP_DMA,
  1602. false,
  1603. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1604. QMB_MASTER_SELECT_PCIE,
  1605. { 20, 13, 9, 9, IPA_EE_AP } },
  1606. [IPA_4_0_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS] = {
  1607. true, IPA_v4_0_MHI_GROUP_DMA,
  1608. false,
  1609. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1610. QMB_MASTER_SELECT_PCIE,
  1611. { 21, 14, 9, 9, IPA_EE_AP } },
  1612. [IPA_4_0_MHI][IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS] = {
  1613. true, IPA_v4_0_GROUP_UL_DL,
  1614. false,
  1615. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1616. QMB_MASTER_SELECT_DDR,
  1617. { 16, 5, 9, 9, IPA_EE_Q6 } },
  1618. [IPA_4_0_MHI][IPA_CLIENT_USB_DPL_CONS] = {
  1619. true, IPA_v4_0_MHI_GROUP_DDR,
  1620. false,
  1621. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1622. QMB_MASTER_SELECT_DDR,
  1623. { 15, 7, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY } },
  1624. [IPA_4_0_MHI][IPA_CLIENT_MHI_DPL_CONS] = {
  1625. true, IPA_v4_0_MHI_GROUP_PCIE,
  1626. false,
  1627. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1628. QMB_MASTER_SELECT_PCIE,
  1629. { 12, 2, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY } },
  1630. /* Only for test purpose */
  1631. [IPA_4_0_MHI][IPA_CLIENT_TEST_CONS] = {
  1632. true, IPA_v4_0_GROUP_UL_DL,
  1633. false,
  1634. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1635. QMB_MASTER_SELECT_PCIE,
  1636. { 11, 6, 9, 9, IPA_EE_AP } },
  1637. [IPA_4_0_MHI][IPA_CLIENT_TEST1_CONS] = {
  1638. true, IPA_v4_0_GROUP_UL_DL,
  1639. false,
  1640. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1641. QMB_MASTER_SELECT_PCIE,
  1642. { 11, 6, 9, 9, IPA_EE_AP } },
  1643. [IPA_4_0_MHI][IPA_CLIENT_TEST2_CONS] = {
  1644. true, IPA_v4_0_GROUP_UL_DL,
  1645. false,
  1646. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1647. QMB_MASTER_SELECT_DDR,
  1648. { 12, 2, 5, 5, IPA_EE_AP } },
  1649. [IPA_4_0_MHI][IPA_CLIENT_TEST3_CONS] = {
  1650. true, IPA_v4_0_GROUP_UL_DL,
  1651. false,
  1652. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1653. QMB_MASTER_SELECT_PCIE,
  1654. { 19, 12, 9, 9, IPA_EE_AP } },
  1655. [IPA_4_0_MHI][IPA_CLIENT_TEST4_CONS] = {
  1656. true, IPA_v4_0_GROUP_UL_DL,
  1657. false,
  1658. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1659. QMB_MASTER_SELECT_PCIE,
  1660. { 21, 14, 9, 9, IPA_EE_AP } },
  1661. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  1662. [IPA_4_0_MHI][IPA_CLIENT_DUMMY_CONS] = {
  1663. true, IPA_v4_0_GROUP_UL_DL,
  1664. false,
  1665. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1666. QMB_MASTER_SELECT_DDR,
  1667. { 31, 31, 8, 8, IPA_EE_AP } },
  1668. /* IPA_4_1 */
  1669. [IPA_4_1][IPA_CLIENT_WLAN1_PROD] = {
  1670. true, IPA_v4_0_GROUP_UL_DL,
  1671. true,
  1672. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1673. QMB_MASTER_SELECT_DDR,
  1674. { 6, 2, 8, 16, IPA_EE_UC } },
  1675. [IPA_4_1][IPA_CLIENT_WLAN2_PROD] = {
  1676. true, IPA_v4_0_GROUP_UL_DL,
  1677. true,
  1678. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1679. QMB_MASTER_SELECT_DDR,
  1680. { 7, 9, 8, 16, IPA_EE_AP } },
  1681. [IPA_4_1][IPA_CLIENT_USB_PROD] = {
  1682. true, IPA_v4_0_GROUP_UL_DL,
  1683. true,
  1684. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1685. QMB_MASTER_SELECT_DDR,
  1686. { 0, 8, 8, 16, IPA_EE_AP } },
  1687. [IPA_4_1][IPA_CLIENT_APPS_LAN_PROD] = {
  1688. true, IPA_v4_0_GROUP_UL_DL,
  1689. false,
  1690. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1691. QMB_MASTER_SELECT_DDR,
  1692. { 8, 10, 8, 16, IPA_EE_AP } },
  1693. [IPA_4_1][IPA_CLIENT_APPS_WAN_PROD] = {
  1694. true, IPA_v4_0_GROUP_UL_DL,
  1695. true,
  1696. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1697. QMB_MASTER_SELECT_DDR,
  1698. { 2, 3, 16, 32, IPA_EE_AP } },
  1699. [IPA_4_1][IPA_CLIENT_APPS_CMD_PROD] = {
  1700. true, IPA_v4_0_GROUP_UL_DL,
  1701. false,
  1702. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1703. QMB_MASTER_SELECT_DDR,
  1704. { 5, 4, 20, 24, IPA_EE_AP } },
  1705. [IPA_4_1][IPA_CLIENT_ODU_PROD] = {
  1706. true, IPA_v4_0_GROUP_UL_DL,
  1707. true,
  1708. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1709. QMB_MASTER_SELECT_DDR,
  1710. { 1, 0, 8, 16, IPA_EE_AP } },
  1711. [IPA_4_1][IPA_CLIENT_ETHERNET_PROD] = {
  1712. true, IPA_v4_0_GROUP_UL_DL,
  1713. true,
  1714. IPA_DPS_HPS_REP_SEQ_TYPE_2PKT_PROC_PASS_NO_DEC_UCP_DMAP,
  1715. QMB_MASTER_SELECT_DDR,
  1716. { 9, 0, 8, 16, IPA_EE_UC } },
  1717. [IPA_4_1][IPA_CLIENT_Q6_WAN_PROD] = {
  1718. true, IPA_v4_0_GROUP_UL_DL,
  1719. true,
  1720. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1721. QMB_MASTER_SELECT_DDR,
  1722. { 3, 0, 16, 32, IPA_EE_Q6 } },
  1723. [IPA_4_1][IPA_CLIENT_Q6_CMD_PROD] = {
  1724. true, IPA_v4_0_GROUP_UL_DL,
  1725. false,
  1726. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  1727. QMB_MASTER_SELECT_DDR,
  1728. { 4, 1, 20, 24, IPA_EE_Q6 } },
  1729. /* Only for test purpose */
  1730. [IPA_4_1][IPA_CLIENT_TEST_PROD] = {
  1731. true, IPA_v4_0_GROUP_UL_DL,
  1732. true,
  1733. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1734. QMB_MASTER_SELECT_DDR,
  1735. {0, 8, 8, 16, IPA_EE_AP } },
  1736. [IPA_4_1][IPA_CLIENT_TEST1_PROD] = {
  1737. true, IPA_v4_0_GROUP_UL_DL,
  1738. true,
  1739. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1740. QMB_MASTER_SELECT_DDR,
  1741. { 0, 8, 8, 16, IPA_EE_AP } },
  1742. [IPA_4_1][IPA_CLIENT_TEST2_PROD] = {
  1743. true, IPA_v4_0_GROUP_UL_DL,
  1744. true,
  1745. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1746. QMB_MASTER_SELECT_DDR,
  1747. { 1, 0, 8, 16, IPA_EE_AP } },
  1748. [IPA_4_1][IPA_CLIENT_TEST3_PROD] = {
  1749. true, IPA_v4_0_GROUP_UL_DL,
  1750. true,
  1751. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1752. QMB_MASTER_SELECT_DDR,
  1753. {7, 9, 8, 16, IPA_EE_AP } },
  1754. [IPA_4_1][IPA_CLIENT_TEST4_PROD] = {
  1755. true, IPA_v4_0_GROUP_UL_DL,
  1756. true,
  1757. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1758. QMB_MASTER_SELECT_DDR,
  1759. { 8, 10, 8, 16, IPA_EE_AP } },
  1760. [IPA_4_1][IPA_CLIENT_WLAN1_CONS] = {
  1761. true, IPA_v4_0_GROUP_UL_DL,
  1762. false,
  1763. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1764. QMB_MASTER_SELECT_DDR,
  1765. { 18, 3, 9, 9, IPA_EE_UC } },
  1766. [IPA_4_1][IPA_CLIENT_WLAN2_CONS] = {
  1767. true, IPA_v4_0_GROUP_UL_DL,
  1768. false,
  1769. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1770. QMB_MASTER_SELECT_DDR,
  1771. { 17, 1, 8, 13, IPA_EE_AP } },
  1772. [IPA_4_1][IPA_CLIENT_WLAN3_CONS] = {
  1773. true, IPA_v4_0_GROUP_UL_DL,
  1774. false,
  1775. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1776. QMB_MASTER_SELECT_DDR,
  1777. { 21, 14, 9, 9, IPA_EE_AP } },
  1778. [IPA_4_1][IPA_CLIENT_USB_CONS] = {
  1779. true, IPA_v4_0_GROUP_UL_DL,
  1780. false,
  1781. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1782. QMB_MASTER_SELECT_DDR,
  1783. { 19, 12, 9, 9, IPA_EE_AP } },
  1784. [IPA_4_1][IPA_CLIENT_USB_DPL_CONS] = {
  1785. true, IPA_v4_0_GROUP_UL_DL,
  1786. false,
  1787. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1788. QMB_MASTER_SELECT_DDR,
  1789. { 15, 7, 5, 5, IPA_EE_AP } },
  1790. [IPA_4_1][IPA_CLIENT_APPS_LAN_CONS] = {
  1791. true, IPA_v4_0_GROUP_UL_DL,
  1792. false,
  1793. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1794. QMB_MASTER_SELECT_DDR,
  1795. { 10, 5, 9, 9, IPA_EE_AP } },
  1796. [IPA_4_1][IPA_CLIENT_APPS_WAN_CONS] = {
  1797. true, IPA_v4_0_GROUP_UL_DL,
  1798. false,
  1799. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1800. QMB_MASTER_SELECT_DDR,
  1801. { 11, 6, 9, 9, IPA_EE_AP } },
  1802. [IPA_4_1][IPA_CLIENT_ODL_DPL_CONS] = {
  1803. true, IPA_v4_0_GROUP_UL_DL,
  1804. false,
  1805. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1806. QMB_MASTER_SELECT_DDR,
  1807. { 12, 2, 9, 9, IPA_EE_AP } },
  1808. [IPA_4_1][IPA_CLIENT_ETHERNET_CONS] = {
  1809. true, IPA_v4_0_GROUP_UL_DL,
  1810. false,
  1811. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1812. QMB_MASTER_SELECT_DDR,
  1813. { 22, 1, 9, 9, IPA_EE_UC } },
  1814. [IPA_4_1][IPA_CLIENT_Q6_LAN_CONS] = {
  1815. true, IPA_v4_0_GROUP_UL_DL,
  1816. false,
  1817. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1818. QMB_MASTER_SELECT_DDR,
  1819. { 14, 4, 9, 9, IPA_EE_Q6 } },
  1820. [IPA_4_1][IPA_CLIENT_Q6_WAN_CONS] = {
  1821. true, IPA_v4_0_GROUP_UL_DL,
  1822. false,
  1823. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1824. QMB_MASTER_SELECT_DDR,
  1825. { 13, 3, 9, 9, IPA_EE_Q6 } },
  1826. [IPA_4_1][IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS] = {
  1827. true, IPA_v4_0_GROUP_UL_DL,
  1828. false,
  1829. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1830. QMB_MASTER_SELECT_DDR,
  1831. { 16, 5, 9, 9, IPA_EE_Q6 } },
  1832. /* Only for test purpose */
  1833. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  1834. [IPA_4_1][IPA_CLIENT_TEST_CONS] = {
  1835. true, IPA_v4_0_GROUP_UL_DL,
  1836. false,
  1837. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1838. QMB_MASTER_SELECT_DDR,
  1839. { 11, 6, 9, 9, IPA_EE_AP } },
  1840. [IPA_4_1][IPA_CLIENT_TEST1_CONS] = {
  1841. true, IPA_v4_0_GROUP_UL_DL,
  1842. false,
  1843. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1844. QMB_MASTER_SELECT_DDR,
  1845. { 11, 6, 9, 9, IPA_EE_AP } },
  1846. [IPA_4_1][IPA_CLIENT_TEST2_CONS] = {
  1847. true, IPA_v4_0_GROUP_UL_DL,
  1848. false,
  1849. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1850. QMB_MASTER_SELECT_DDR,
  1851. { 12, 2, 9, 9, IPA_EE_AP } },
  1852. [IPA_4_1][IPA_CLIENT_TEST3_CONS] = {
  1853. true, IPA_v4_0_GROUP_UL_DL,
  1854. false,
  1855. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1856. QMB_MASTER_SELECT_DDR,
  1857. { 19, 12, 9, 9, IPA_EE_AP } },
  1858. [IPA_4_1][IPA_CLIENT_TEST4_CONS] = {
  1859. true, IPA_v4_0_GROUP_UL_DL,
  1860. false,
  1861. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1862. QMB_MASTER_SELECT_DDR,
  1863. { 21, 14, 9, 9, IPA_EE_AP } },
  1864. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  1865. [IPA_4_1][IPA_CLIENT_DUMMY_CONS] = {
  1866. true, IPA_v4_0_GROUP_UL_DL,
  1867. false,
  1868. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1869. QMB_MASTER_SELECT_DDR,
  1870. { 31, 31, 8, 8, IPA_EE_AP } },
  1871. /* MHI PRIME PIPES - Client producer / IPA Consumer pipes */
  1872. [IPA_4_1_APQ][IPA_CLIENT_MHI_PRIME_DPL_PROD] = {
  1873. true, IPA_v4_0_GROUP_UL_DL,
  1874. true,
  1875. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1876. QMB_MASTER_SELECT_DDR,
  1877. {7, 9, 8, 16, IPA_EE_AP } },
  1878. [IPA_4_1_APQ][IPA_CLIENT_MHI_PRIME_TETH_PROD] = {
  1879. true, IPA_v4_0_GROUP_UL_DL,
  1880. true,
  1881. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  1882. QMB_MASTER_SELECT_DDR,
  1883. { 1, 0, 8, 16, IPA_EE_AP } },
  1884. [IPA_4_1_APQ][IPA_CLIENT_MHI_PRIME_RMNET_PROD] = {
  1885. true, IPA_v4_0_GROUP_UL_DL,
  1886. true,
  1887. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1888. QMB_MASTER_SELECT_DDR,
  1889. { 2, 3, 16, 32, IPA_EE_AP } },
  1890. /* MHI PRIME PIPES - Client Consumer / IPA Producer pipes */
  1891. [IPA_4_1_APQ][IPA_CLIENT_MHI_PRIME_TETH_CONS] = {
  1892. true, IPA_v4_0_GROUP_UL_DL,
  1893. false,
  1894. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1895. QMB_MASTER_SELECT_DDR,
  1896. { 20, 13, 9, 9, IPA_EE_AP } },
  1897. [IPA_4_1_APQ][IPA_CLIENT_MHI_PRIME_RMNET_CONS] = {
  1898. true, IPA_v4_0_GROUP_UL_DL,
  1899. false,
  1900. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1901. QMB_MASTER_SELECT_DDR,
  1902. { 17, 14, 9, 9, IPA_EE_AP } },
  1903. /* IPA_4_2 */
  1904. [IPA_4_2][IPA_CLIENT_WLAN1_PROD] = {
  1905. true, IPA_v4_2_GROUP_UL_DL,
  1906. true,
  1907. IPA_DPS_HPS_REP_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP_DMAP,
  1908. QMB_MASTER_SELECT_DDR,
  1909. { 3, 7, 6, 7, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  1910. [IPA_4_2][IPA_CLIENT_USB_PROD] = {
  1911. true, IPA_v4_2_GROUP_UL_DL,
  1912. true,
  1913. IPA_DPS_HPS_REP_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP_DMAP,
  1914. QMB_MASTER_SELECT_DDR,
  1915. { 0, 5, 8, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1916. [IPA_4_2][IPA_CLIENT_APPS_LAN_PROD] = {
  1917. true, IPA_v4_2_GROUP_UL_DL,
  1918. false,
  1919. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1920. QMB_MASTER_SELECT_DDR,
  1921. { 2, 6, 8, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1922. [IPA_4_2][IPA_CLIENT_APPS_WAN_PROD] = {
  1923. true, IPA_v4_2_GROUP_UL_DL,
  1924. true,
  1925. IPA_DPS_HPS_REP_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP_DMAP,
  1926. QMB_MASTER_SELECT_DDR,
  1927. { 1, 0, 8, 12, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1928. [IPA_4_2][IPA_CLIENT_APPS_CMD_PROD] = {
  1929. true, IPA_v4_2_GROUP_UL_DL,
  1930. false,
  1931. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  1932. QMB_MASTER_SELECT_DDR,
  1933. { 6, 1, 20, 20, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  1934. [IPA_4_2][IPA_CLIENT_Q6_WAN_PROD] = {
  1935. true, IPA_v4_2_GROUP_UL_DL,
  1936. true,
  1937. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1938. QMB_MASTER_SELECT_DDR,
  1939. { 4, 0, 8, 12, IPA_EE_Q6, GSI_USE_PREFETCH_BUFS} },
  1940. [IPA_4_2][IPA_CLIENT_Q6_CMD_PROD] = {
  1941. true, IPA_v4_2_GROUP_UL_DL,
  1942. false,
  1943. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1944. QMB_MASTER_SELECT_DDR,
  1945. { 5, 1, 20, 20, IPA_EE_Q6, GSI_USE_PREFETCH_BUFS} },
  1946. [IPA_4_2][IPA_CLIENT_ETHERNET_PROD] = {
  1947. true, IPA_v4_2_GROUP_UL_DL,
  1948. true,
  1949. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1950. QMB_MASTER_SELECT_DDR,
  1951. { 7, 0, 8, 10, IPA_EE_UC, GSI_USE_PREFETCH_BUFS} },
  1952. /* Only for test purpose */
  1953. [IPA_4_2][IPA_CLIENT_TEST_PROD] = {
  1954. true, IPA_v4_2_GROUP_UL_DL,
  1955. true,
  1956. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1957. QMB_MASTER_SELECT_DDR,
  1958. {0, 5, 8, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1959. [IPA_4_2][IPA_CLIENT_TEST1_PROD] = {
  1960. true, IPA_v4_2_GROUP_UL_DL,
  1961. true,
  1962. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1963. QMB_MASTER_SELECT_DDR,
  1964. { 0, 5, 8, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1965. [IPA_4_2][IPA_CLIENT_TEST2_PROD] = {
  1966. true, IPA_v4_2_GROUP_UL_DL,
  1967. true,
  1968. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1969. QMB_MASTER_SELECT_DDR,
  1970. { 3, 7, 6, 7, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  1971. [IPA_4_2][IPA_CLIENT_TEST3_PROD] = {
  1972. true, IPA_v4_2_GROUP_UL_DL,
  1973. true,
  1974. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1975. QMB_MASTER_SELECT_DDR,
  1976. {1, 0, 8, 12, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1977. [IPA_4_2][IPA_CLIENT_TEST4_PROD] = {
  1978. true, IPA_v4_2_GROUP_UL_DL,
  1979. true,
  1980. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP,
  1981. QMB_MASTER_SELECT_DDR,
  1982. { 7, 0, 8, 10, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  1983. [IPA_4_2][IPA_CLIENT_WLAN1_CONS] = {
  1984. true, IPA_v4_2_GROUP_UL_DL,
  1985. false,
  1986. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1987. QMB_MASTER_SELECT_DDR,
  1988. { 14, 8, 6, 9, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  1989. [IPA_4_2][IPA_CLIENT_USB_CONS] = {
  1990. true, IPA_v4_2_GROUP_UL_DL,
  1991. false,
  1992. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1993. QMB_MASTER_SELECT_DDR,
  1994. { 15, 9, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  1995. [IPA_4_2][IPA_CLIENT_USB_DPL_CONS] = {
  1996. true, IPA_v4_2_GROUP_UL_DL,
  1997. false,
  1998. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  1999. QMB_MASTER_SELECT_DDR,
  2000. { 12, 4, 4, 4, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2001. [IPA_4_2][IPA_CLIENT_APPS_LAN_CONS] = {
  2002. true, IPA_v4_2_GROUP_UL_DL,
  2003. false,
  2004. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2005. QMB_MASTER_SELECT_DDR,
  2006. { 8, 2, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2007. [IPA_4_2][IPA_CLIENT_APPS_WAN_CONS] = {
  2008. true, IPA_v4_2_GROUP_UL_DL,
  2009. false,
  2010. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2011. QMB_MASTER_SELECT_DDR,
  2012. { 9, 3, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2013. [IPA_4_2][IPA_CLIENT_Q6_LAN_CONS] = {
  2014. true, IPA_v4_2_GROUP_UL_DL,
  2015. false,
  2016. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2017. QMB_MASTER_SELECT_DDR,
  2018. { 11, 3, 6, 6, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY} },
  2019. [IPA_4_2][IPA_CLIENT_Q6_WAN_CONS] = {
  2020. true, IPA_v4_2_GROUP_UL_DL,
  2021. false,
  2022. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2023. QMB_MASTER_SELECT_DDR,
  2024. { 10, 2, 6, 6, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY} },
  2025. [IPA_4_2][IPA_CLIENT_Q6_LTE_WIFI_AGGR_CONS] = {
  2026. true, IPA_v4_2_GROUP_UL_DL,
  2027. false,
  2028. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2029. QMB_MASTER_SELECT_DDR,
  2030. { 13, 4, 6, 6, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY} },
  2031. [IPA_4_2][IPA_CLIENT_ETHERNET_CONS] = {
  2032. true, IPA_v4_2_GROUP_UL_DL,
  2033. false,
  2034. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2035. QMB_MASTER_SELECT_DDR,
  2036. { 16, 1, 6, 6, IPA_EE_UC, GSI_USE_PREFETCH_BUFS} },
  2037. /* Only for test purpose */
  2038. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  2039. [IPA_4_2][IPA_CLIENT_TEST_CONS] = {
  2040. true, IPA_v4_2_GROUP_UL_DL,
  2041. false,
  2042. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2043. QMB_MASTER_SELECT_DDR,
  2044. { 15, 9, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2045. [IPA_4_2][IPA_CLIENT_TEST1_CONS] = {
  2046. true, IPA_v4_2_GROUP_UL_DL,
  2047. false,
  2048. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2049. QMB_MASTER_SELECT_DDR,
  2050. { 15, 9, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2051. [IPA_4_2][IPA_CLIENT_TEST2_CONS] = {
  2052. true, IPA_v4_2_GROUP_UL_DL,
  2053. false,
  2054. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2055. QMB_MASTER_SELECT_DDR,
  2056. { 12, 4, 4, 4, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2057. [IPA_4_2][IPA_CLIENT_TEST3_CONS] = {
  2058. true, IPA_v4_2_GROUP_UL_DL,
  2059. false,
  2060. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2061. QMB_MASTER_SELECT_DDR,
  2062. { 14, 8, 6, 9, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  2063. [IPA_4_2][IPA_CLIENT_TEST4_CONS] = {
  2064. true, IPA_v4_2_GROUP_UL_DL,
  2065. false,
  2066. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2067. QMB_MASTER_SELECT_DDR,
  2068. { 9, 3, 6, 6, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY} },
  2069. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  2070. [IPA_4_2][IPA_CLIENT_DUMMY_CONS] = {
  2071. true, IPA_v4_2_GROUP_UL_DL,
  2072. false,
  2073. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2074. QMB_MASTER_SELECT_DDR,
  2075. { 31, 31, 8, 8, IPA_EE_AP, GSI_USE_PREFETCH_BUFS} },
  2076. /* IPA_4_5 */
  2077. [IPA_4_5][IPA_CLIENT_WLAN2_PROD] = {
  2078. true, IPA_v4_5_GROUP_UL_DL,
  2079. true,
  2080. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2081. QMB_MASTER_SELECT_DDR,
  2082. { 9, 12, 8, 16, IPA_EE_AP, GSI_FREE_PRE_FETCH, 2 } },
  2083. [IPA_4_5][IPA_CLIENT_USB_PROD] = {
  2084. true, IPA_v4_5_GROUP_UL_DL,
  2085. true,
  2086. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2087. QMB_MASTER_SELECT_DDR,
  2088. { 1, 0, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2089. [IPA_4_5][IPA_CLIENT_APPS_LAN_PROD] = {
  2090. true, IPA_v4_5_GROUP_UL_DL,
  2091. false,
  2092. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2093. QMB_MASTER_SELECT_DDR,
  2094. { 11, 14, 10, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 2 } },
  2095. [IPA_4_5][IPA_CLIENT_APPS_WAN_PROD] = {
  2096. true, IPA_v4_5_GROUP_UL_DL,
  2097. true,
  2098. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2099. QMB_MASTER_SELECT_DDR,
  2100. { 2, 7, 16, 32, IPA_EE_AP, GSI_SMART_PRE_FETCH, 7 } },
  2101. [IPA_4_5][IPA_CLIENT_APPS_CMD_PROD] = {
  2102. true, IPA_v4_5_GROUP_UL_DL,
  2103. false,
  2104. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2105. QMB_MASTER_SELECT_DDR,
  2106. { 7, 9, 20, 24, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2107. [IPA_4_5][IPA_CLIENT_ODU_PROD] = {
  2108. true, IPA_v4_5_GROUP_UL_DL,
  2109. true,
  2110. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2111. QMB_MASTER_SELECT_DDR,
  2112. { 3, 5, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2113. [IPA_4_5][IPA_CLIENT_ETHERNET_PROD] = {
  2114. true, IPA_v4_5_GROUP_UL_DL,
  2115. true,
  2116. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2117. QMB_MASTER_SELECT_DDR,
  2118. { 12, 0, 8, 16, IPA_EE_UC, GSI_SMART_PRE_FETCH, 3 } },
  2119. [IPA_4_5][IPA_CLIENT_Q6_WAN_PROD] = {
  2120. true, IPA_v4_5_GROUP_UL_DL,
  2121. true,
  2122. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2123. QMB_MASTER_SELECT_DDR,
  2124. { 5, 0, 16, 28, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2125. [IPA_4_5][IPA_CLIENT_Q6_CMD_PROD] = {
  2126. true, IPA_v4_5_GROUP_UL_DL,
  2127. false,
  2128. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  2129. QMB_MASTER_SELECT_DDR,
  2130. { 6, 1, 20, 24, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2131. [IPA_4_5][IPA_CLIENT_Q6_DL_NLO_DATA_PROD] = {
  2132. true, IPA_v4_5_GROUP_UL_DL,
  2133. true,
  2134. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2135. QMB_MASTER_SELECT_DDR,
  2136. { 8, 2, 27, 32, IPA_EE_Q6, GSI_FREE_PRE_FETCH, 3 } },
  2137. /* Only for test purpose */
  2138. [IPA_4_5][IPA_CLIENT_TEST_PROD] = {
  2139. true, IPA_v4_5_GROUP_UL_DL,
  2140. true,
  2141. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2142. QMB_MASTER_SELECT_DDR,
  2143. { 1, 0, 8, 16, IPA_EE_AP } },
  2144. [IPA_4_5][IPA_CLIENT_TEST1_PROD] = {
  2145. true, IPA_v4_5_GROUP_UL_DL,
  2146. true,
  2147. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2148. QMB_MASTER_SELECT_DDR,
  2149. { 1, 0, 8, 16, IPA_EE_AP } },
  2150. [IPA_4_5][IPA_CLIENT_TEST2_PROD] = {
  2151. true, IPA_v4_5_GROUP_UL_DL,
  2152. true,
  2153. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2154. QMB_MASTER_SELECT_DDR,
  2155. { 3, 5, 8, 16, IPA_EE_AP } },
  2156. [IPA_4_5][IPA_CLIENT_TEST3_PROD] = {
  2157. true, IPA_v4_5_GROUP_UL_DL,
  2158. true,
  2159. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2160. QMB_MASTER_SELECT_DDR,
  2161. { 9, 12, 8, 16, IPA_EE_AP } },
  2162. [IPA_4_5][IPA_CLIENT_TEST4_PROD] = {
  2163. true, IPA_v4_5_GROUP_UL_DL,
  2164. true,
  2165. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2166. QMB_MASTER_SELECT_DDR,
  2167. { 11, 14, 8, 16, IPA_EE_AP } },
  2168. [IPA_4_5][IPA_CLIENT_WLAN2_CONS] = {
  2169. true, IPA_v4_5_GROUP_UL_DL,
  2170. false,
  2171. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2172. QMB_MASTER_SELECT_DDR,
  2173. { 24, 3, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2174. [IPA_4_5][IPA_CLIENT_USB_CONS] = {
  2175. true, IPA_v4_5_GROUP_UL_DL,
  2176. false,
  2177. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2178. QMB_MASTER_SELECT_DDR,
  2179. { 26, 17, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2180. [IPA_4_5][IPA_CLIENT_USB_DPL_CONS] = {
  2181. true, IPA_v4_5_GROUP_UL_DL,
  2182. false,
  2183. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2184. QMB_MASTER_SELECT_DDR,
  2185. { 15, 15, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2186. [IPA_4_5][IPA_CLIENT_ODL_DPL_CONS] = {
  2187. true, IPA_v4_5_GROUP_UL_DL,
  2188. false,
  2189. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2190. QMB_MASTER_SELECT_DDR,
  2191. { 22, 2, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2192. [IPA_4_5][IPA_CLIENT_APPS_LAN_CONS] = {
  2193. true, IPA_v4_5_GROUP_UL_DL,
  2194. false,
  2195. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2196. QMB_MASTER_SELECT_DDR,
  2197. { 16, 10, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2198. [IPA_4_5][IPA_CLIENT_APPS_WAN_COAL_CONS] = {
  2199. true, IPA_v4_5_GROUP_UL_DL,
  2200. false,
  2201. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2202. QMB_MASTER_SELECT_DDR,
  2203. { 13, 4, 8, 11, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2204. [IPA_4_5][IPA_CLIENT_APPS_WAN_CONS] = {
  2205. true, IPA_v4_5_GROUP_UL_DL,
  2206. false,
  2207. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2208. QMB_MASTER_SELECT_DDR,
  2209. { 14, 1, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2210. [IPA_4_5][IPA_CLIENT_ODU_EMB_CONS] = {
  2211. true, IPA_v4_5_GROUP_UL_DL,
  2212. false,
  2213. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2214. QMB_MASTER_SELECT_DDR,
  2215. { 30, 6, 9, 9, IPA_EE_AP, GSI_SMART_PRE_FETCH, 4 } },
  2216. [IPA_4_5][IPA_CLIENT_ETHERNET_CONS] = {
  2217. true, IPA_v4_5_GROUP_UL_DL,
  2218. false,
  2219. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2220. QMB_MASTER_SELECT_DDR,
  2221. { 28, 1, 9, 9, IPA_EE_UC, GSI_SMART_PRE_FETCH, 4 } },
  2222. [IPA_4_5][IPA_CLIENT_Q6_LAN_CONS] = {
  2223. true, IPA_v4_5_GROUP_UL_DL,
  2224. false,
  2225. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2226. QMB_MASTER_SELECT_DDR,
  2227. { 17, 3, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2228. [IPA_4_5][IPA_CLIENT_Q6_WAN_CONS] = {
  2229. true, IPA_v4_5_GROUP_UL_DL,
  2230. false,
  2231. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2232. QMB_MASTER_SELECT_DDR,
  2233. { 21, 7, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2234. [IPA_4_5][IPA_CLIENT_Q6_UL_NLO_DATA_CONS] = {
  2235. true, IPA_v4_5_GROUP_UL_DL,
  2236. false,
  2237. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2238. QMB_MASTER_SELECT_DDR,
  2239. { 19, 5, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2240. [IPA_4_5][IPA_CLIENT_Q6_UL_NLO_ACK_CONS] = {
  2241. true, IPA_v4_5_GROUP_UL_DL,
  2242. false,
  2243. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2244. QMB_MASTER_SELECT_DDR,
  2245. { 20, 6, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2246. [IPA_4_5][IPA_CLIENT_Q6_QBAP_STATUS_CONS] = {
  2247. true, IPA_v4_5_GROUP_UL_DL,
  2248. false,
  2249. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2250. QMB_MASTER_SELECT_DDR,
  2251. { 18, 4, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2252. /* Only for test purpose */
  2253. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  2254. [IPA_4_5][IPA_CLIENT_TEST_CONS] = {
  2255. true, IPA_v4_5_GROUP_UL_DL,
  2256. false,
  2257. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2258. QMB_MASTER_SELECT_DDR,
  2259. { 14, 1, 9, 9, IPA_EE_AP } },
  2260. [IPA_4_5][IPA_CLIENT_TEST1_CONS] = {
  2261. true, IPA_v4_5_GROUP_UL_DL,
  2262. false,
  2263. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2264. QMB_MASTER_SELECT_DDR,
  2265. { 14, 1, 9, 9, IPA_EE_AP } },
  2266. [IPA_4_5][IPA_CLIENT_TEST2_CONS] = {
  2267. true, IPA_v4_5_GROUP_UL_DL,
  2268. false,
  2269. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2270. QMB_MASTER_SELECT_DDR,
  2271. { 24, 3, 8, 14, IPA_EE_AP } },
  2272. [IPA_4_5][IPA_CLIENT_TEST3_CONS] = {
  2273. true, IPA_v4_5_GROUP_UL_DL,
  2274. false,
  2275. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2276. QMB_MASTER_SELECT_DDR,
  2277. { 26, 17, 9, 9, IPA_EE_AP } },
  2278. [IPA_4_5][IPA_CLIENT_TEST4_CONS] = {
  2279. true, IPA_v4_5_GROUP_UL_DL,
  2280. false,
  2281. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2282. QMB_MASTER_SELECT_DDR,
  2283. { 27, 18, 9, 9, IPA_EE_AP } },
  2284. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  2285. [IPA_4_5][IPA_CLIENT_DUMMY_CONS] = {
  2286. true, IPA_v4_5_GROUP_UL_DL,
  2287. false,
  2288. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2289. QMB_MASTER_SELECT_DDR,
  2290. { 31, 31, 8, 8, IPA_EE_AP } },
  2291. /* IPA_4_5_MHI */
  2292. [IPA_4_5_MHI][IPA_CLIENT_APPS_CMD_PROD] = {
  2293. true, IPA_v4_5_MHI_GROUP_DDR,
  2294. false,
  2295. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2296. QMB_MASTER_SELECT_DDR,
  2297. { 7, 9, 20, 24, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2298. [IPA_4_5_MHI][IPA_CLIENT_Q6_WAN_PROD] = {
  2299. true, IPA_v4_5_MHI_GROUP_DDR,
  2300. true,
  2301. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2302. QMB_MASTER_SELECT_DDR,
  2303. { 5, 0, 16, 28, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2304. [IPA_4_5_MHI][IPA_CLIENT_Q6_CMD_PROD] = {
  2305. true, IPA_v4_5_MHI_GROUP_PCIE,
  2306. false,
  2307. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  2308. QMB_MASTER_SELECT_DDR,
  2309. { 6, 1, 20, 24, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2310. [IPA_4_5_MHI][IPA_CLIENT_Q6_DL_NLO_DATA_PROD] = {
  2311. true, IPA_v4_5_MHI_GROUP_DDR,
  2312. true,
  2313. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2314. QMB_MASTER_SELECT_DDR,
  2315. { 8, 2, 27, 32, IPA_EE_Q6, GSI_FREE_PRE_FETCH, 3 } },
  2316. [IPA_4_5_MHI][IPA_CLIENT_Q6_AUDIO_DMA_MHI_PROD] = {
  2317. true, IPA_v4_5_MHI_GROUP_DMA,
  2318. false,
  2319. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2320. QMB_MASTER_SELECT_DDR,
  2321. { 4, 8, 8, 16, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 3 } },
  2322. [IPA_4_5_MHI][IPA_CLIENT_MHI_PROD] = {
  2323. true, IPA_v4_5_MHI_GROUP_PCIE,
  2324. true,
  2325. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2326. QMB_MASTER_SELECT_PCIE,
  2327. { 1, 0, 16, 20, IPA_EE_AP, GSI_SMART_PRE_FETCH, 7 } },
  2328. [IPA_4_5_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_PROD] = {
  2329. true, IPA_v4_5_MHI_GROUP_DMA,
  2330. false,
  2331. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2332. QMB_MASTER_SELECT_DDR,
  2333. { 9, 12, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2334. [IPA_4_5_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_PROD] = {
  2335. true, IPA_v4_5_MHI_GROUP_DMA,
  2336. false,
  2337. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2338. QMB_MASTER_SELECT_DDR,
  2339. { 10, 13, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2340. /* Only for test purpose */
  2341. [IPA_4_5_MHI][IPA_CLIENT_TEST_PROD] = {
  2342. true, QMB_MASTER_SELECT_DDR,
  2343. true,
  2344. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2345. QMB_MASTER_SELECT_DDR,
  2346. { 1, 0, 8, 16, IPA_EE_AP } },
  2347. [IPA_4_5_MHI][IPA_CLIENT_APPS_LAN_CONS] = {
  2348. true, IPA_v4_5_MHI_GROUP_DDR,
  2349. false,
  2350. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2351. QMB_MASTER_SELECT_DDR,
  2352. { 16, 10, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2353. [IPA_4_5][IPA_CLIENT_USB_DPL_CONS] = {
  2354. true, IPA_v4_5_MHI_GROUP_DDR,
  2355. false,
  2356. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2357. QMB_MASTER_SELECT_DDR,
  2358. { 15, 15, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2359. [IPA_4_5_MHI][IPA_CLIENT_Q6_LAN_CONS] = {
  2360. true, IPA_v4_5_MHI_GROUP_DDR,
  2361. false,
  2362. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2363. QMB_MASTER_SELECT_DDR,
  2364. { 17, 3, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2365. [IPA_4_5_MHI][IPA_CLIENT_Q6_WAN_CONS] = {
  2366. true, IPA_v4_5_MHI_GROUP_DDR,
  2367. false,
  2368. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2369. QMB_MASTER_SELECT_DDR,
  2370. { 21, 7, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2371. [IPA_4_5_MHI][IPA_CLIENT_Q6_UL_NLO_DATA_CONS] = {
  2372. true, IPA_v4_5_MHI_GROUP_DDR,
  2373. false,
  2374. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2375. QMB_MASTER_SELECT_DDR,
  2376. { 19, 5, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2377. [IPA_4_5_MHI][IPA_CLIENT_Q6_UL_NLO_ACK_CONS] = {
  2378. true, IPA_v4_5_MHI_GROUP_DDR,
  2379. false,
  2380. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2381. QMB_MASTER_SELECT_DDR,
  2382. { 20, 6, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2383. [IPA_4_5_MHI][IPA_CLIENT_Q6_QBAP_STATUS_CONS] = {
  2384. true, IPA_v4_5_MHI_GROUP_DDR,
  2385. false,
  2386. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2387. QMB_MASTER_SELECT_DDR,
  2388. { 18, 4, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2389. [IPA_4_5_MHI][IPA_CLIENT_Q6_AUDIO_DMA_MHI_CONS] = {
  2390. true, IPA_v4_5_MHI_GROUP_DMA,
  2391. false,
  2392. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2393. QMB_MASTER_SELECT_PCIE,
  2394. { 29, 9, 9, 9, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 4 } },
  2395. [IPA_4_5_MHI][IPA_CLIENT_MEMCPY_DMA_SYNC_CONS] = {
  2396. true, IPA_v4_5_MHI_GROUP_DMA,
  2397. false,
  2398. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2399. QMB_MASTER_SELECT_PCIE,
  2400. { 26, 17, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2401. [IPA_4_5_MHI][IPA_CLIENT_MEMCPY_DMA_ASYNC_CONS] = {
  2402. true, IPA_v4_5_MHI_GROUP_DMA,
  2403. false,
  2404. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2405. QMB_MASTER_SELECT_PCIE,
  2406. { 27, 18, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2407. [IPA_4_5_MHI][IPA_CLIENT_MHI_CONS] = {
  2408. true, IPA_v4_5_MHI_GROUP_PCIE,
  2409. false,
  2410. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2411. QMB_MASTER_SELECT_PCIE,
  2412. { 14, 1, 9, 9, IPA_EE_AP, GSI_SMART_PRE_FETCH, 4 } },
  2413. [IPA_4_5_MHI][IPA_CLIENT_MHI_DPL_CONS] = {
  2414. true, IPA_v4_5_MHI_GROUP_PCIE,
  2415. false,
  2416. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2417. QMB_MASTER_SELECT_PCIE,
  2418. { 22, 2, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2419. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  2420. [IPA_4_5_MHI][IPA_CLIENT_DUMMY_CONS] = {
  2421. true, QMB_MASTER_SELECT_DDR,
  2422. false,
  2423. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2424. QMB_MASTER_SELECT_DDR,
  2425. { 31, 31, 8, 8, IPA_EE_AP } },
  2426. /* IPA_4_5 APQ */
  2427. [IPA_4_5_APQ][IPA_CLIENT_WLAN2_PROD] = {
  2428. true, IPA_v4_5_GROUP_UL_DL,
  2429. true,
  2430. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2431. QMB_MASTER_SELECT_DDR,
  2432. { 9, 3, 8, 16, IPA_EE_AP, GSI_FREE_PRE_FETCH, 2 } },
  2433. [IPA_4_5_APQ][IPA_CLIENT_WIGIG_PROD] = {
  2434. true, IPA_v4_5_GROUP_UL_DL,
  2435. true,
  2436. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2437. QMB_MASTER_SELECT_DDR,
  2438. { 1, 1, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2439. [IPA_4_5_APQ][IPA_CLIENT_USB_PROD] = {
  2440. true, IPA_v4_5_GROUP_UL_DL,
  2441. true,
  2442. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2443. QMB_MASTER_SELECT_DDR,
  2444. { 0, 0, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2445. [IPA_4_5_APQ][IPA_CLIENT_APPS_LAN_PROD] = {
  2446. true, IPA_v4_5_GROUP_UL_DL,
  2447. false,
  2448. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2449. QMB_MASTER_SELECT_DDR,
  2450. { 11, 4, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2451. [IPA_4_5_APQ][IPA_CLIENT_APPS_CMD_PROD] = {
  2452. true, IPA_v4_5_GROUP_UL_DL,
  2453. false,
  2454. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2455. QMB_MASTER_SELECT_DDR,
  2456. { 7, 12, 20, 24, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2457. /* MHI PRIME PIPES - Client producer / IPA Consumer pipes */
  2458. [IPA_4_5_APQ][IPA_CLIENT_MHI_PRIME_DPL_PROD] = {
  2459. true, IPA_v4_5_GROUP_UL_DL,
  2460. true,
  2461. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2462. QMB_MASTER_SELECT_DDR,
  2463. {3, 2, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2464. [IPA_4_5_APQ][IPA_CLIENT_MHI_PRIME_TETH_PROD] = {
  2465. true, IPA_v4_5_GROUP_UL_DL,
  2466. true,
  2467. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2468. QMB_MASTER_SELECT_DDR,
  2469. { 2, 7, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2470. [IPA_4_5_APQ][IPA_CLIENT_MHI_PRIME_RMNET_PROD] = {
  2471. true, IPA_v4_5_GROUP_UL_DL,
  2472. true,
  2473. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2474. QMB_MASTER_SELECT_DDR,
  2475. { 4, 11, 16, 32, IPA_EE_AP, GSI_SMART_PRE_FETCH, 7 } },
  2476. /* Only for test purpose */
  2477. [IPA_4_5_APQ][IPA_CLIENT_TEST_PROD] = {
  2478. true, IPA_v4_5_GROUP_UL_DL,
  2479. true,
  2480. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2481. QMB_MASTER_SELECT_DDR,
  2482. { 0, 0, 8, 16, IPA_EE_AP } },
  2483. [IPA_4_5_APQ][IPA_CLIENT_TEST1_PROD] = {
  2484. true, IPA_v4_5_GROUP_UL_DL,
  2485. true,
  2486. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2487. QMB_MASTER_SELECT_DDR,
  2488. { 0, 0, 8, 16, IPA_EE_AP } },
  2489. [IPA_4_5_APQ][IPA_CLIENT_TEST2_PROD] = {
  2490. true, IPA_v4_5_GROUP_UL_DL,
  2491. true,
  2492. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2493. QMB_MASTER_SELECT_DDR,
  2494. { 1, 1, 8, 16, IPA_EE_AP } },
  2495. [IPA_4_5_APQ][IPA_CLIENT_TEST3_PROD] = {
  2496. true, IPA_v4_5_GROUP_UL_DL,
  2497. true,
  2498. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2499. QMB_MASTER_SELECT_DDR,
  2500. { 9, 3, 8, 16, IPA_EE_AP } },
  2501. [IPA_4_5_APQ][IPA_CLIENT_TEST4_PROD] = {
  2502. true, IPA_v4_5_GROUP_UL_DL,
  2503. true,
  2504. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2505. QMB_MASTER_SELECT_DDR,
  2506. { 10, 10, 8, 16, IPA_EE_AP } },
  2507. [IPA_4_5_APQ][IPA_CLIENT_WLAN2_CONS] = {
  2508. true, IPA_v4_5_GROUP_UL_DL,
  2509. false,
  2510. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2511. QMB_MASTER_SELECT_DDR,
  2512. { 23, 8, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2513. [IPA_4_5_APQ][IPA_CLIENT_WIGIG1_CONS] = {
  2514. true, IPA_v4_5_GROUP_UL_DL,
  2515. false,
  2516. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2517. QMB_MASTER_SELECT_DDR,
  2518. { 14, 14, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2519. [IPA_4_5_APQ][IPA_CLIENT_WIGIG2_CONS] = {
  2520. true, IPA_v4_5_GROUP_UL_DL,
  2521. false,
  2522. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2523. QMB_MASTER_SELECT_DDR,
  2524. { 20, 18, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2525. [IPA_4_5_APQ][IPA_CLIENT_WIGIG3_CONS] = {
  2526. true, IPA_v4_5_GROUP_UL_DL,
  2527. false,
  2528. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2529. QMB_MASTER_SELECT_DDR,
  2530. { 22, 5, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2531. [IPA_4_5_APQ][IPA_CLIENT_WIGIG4_CONS] = {
  2532. true, IPA_v4_5_GROUP_UL_DL,
  2533. false,
  2534. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2535. QMB_MASTER_SELECT_DDR,
  2536. { 29, 10, 8, 14, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2537. [IPA_4_5_APQ][IPA_CLIENT_USB_CONS] = {
  2538. true, IPA_v4_5_GROUP_UL_DL,
  2539. false,
  2540. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2541. QMB_MASTER_SELECT_DDR,
  2542. { 24, 9, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2543. [IPA_4_5_APQ][IPA_CLIENT_USB_DPL_CONS] = {
  2544. true, IPA_v4_5_GROUP_UL_DL,
  2545. false,
  2546. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2547. QMB_MASTER_SELECT_DDR,
  2548. { 16, 16, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2549. [IPA_4_5_APQ][IPA_CLIENT_APPS_LAN_CONS] = {
  2550. true, IPA_v4_5_GROUP_UL_DL,
  2551. false,
  2552. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2553. QMB_MASTER_SELECT_DDR,
  2554. { 13, 13, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2555. [IPA_4_5_APQ][IPA_CLIENT_ODL_DPL_CONS] = {
  2556. true, IPA_v4_5_GROUP_UL_DL,
  2557. false,
  2558. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2559. QMB_MASTER_SELECT_DDR,
  2560. { 21, 19, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2561. /* MHI PRIME PIPES - Client Consumer / IPA Producer pipes */
  2562. [IPA_4_5_APQ][IPA_CLIENT_MHI_PRIME_TETH_CONS] = {
  2563. true, IPA_v4_5_GROUP_UL_DL,
  2564. false,
  2565. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2566. QMB_MASTER_SELECT_DDR,
  2567. { 28, 6, 8, 9, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2568. [IPA_4_5_APQ][IPA_CLIENT_MHI_PRIME_RMNET_CONS] = {
  2569. true, IPA_v4_5_GROUP_UL_DL,
  2570. false,
  2571. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2572. QMB_MASTER_SELECT_DDR,
  2573. { 17, 17, 8, 9, IPA_EE_AP, GSI_SMART_PRE_FETCH, 4 } },
  2574. /* Only for test purpose */
  2575. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  2576. [IPA_4_5_APQ][IPA_CLIENT_TEST_CONS] = {
  2577. true, IPA_v4_5_GROUP_UL_DL,
  2578. false,
  2579. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2580. QMB_MASTER_SELECT_DDR,
  2581. { 16, 16, 5, 5, IPA_EE_AP } },
  2582. [IPA_4_5_APQ][IPA_CLIENT_TEST1_CONS] = {
  2583. true, IPA_v4_5_GROUP_UL_DL,
  2584. false,
  2585. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2586. QMB_MASTER_SELECT_DDR,
  2587. { 16, 16, 5, 5, IPA_EE_AP } },
  2588. [IPA_4_5_APQ][IPA_CLIENT_TEST2_CONS] = {
  2589. true, IPA_v4_5_GROUP_UL_DL,
  2590. false,
  2591. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2592. QMB_MASTER_SELECT_DDR,
  2593. { 22, 5, 9, 9, IPA_EE_AP } },
  2594. [IPA_4_5_APQ][IPA_CLIENT_TEST3_CONS] = {
  2595. true, IPA_v4_5_GROUP_UL_DL,
  2596. false,
  2597. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2598. QMB_MASTER_SELECT_DDR,
  2599. { 24, 9, 9, 9, IPA_EE_AP } },
  2600. [IPA_4_5_APQ][IPA_CLIENT_TEST4_CONS] = {
  2601. true, IPA_v4_5_GROUP_UL_DL,
  2602. false,
  2603. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2604. QMB_MASTER_SELECT_DDR,
  2605. { 23, 8, 8, 13, IPA_EE_AP } },
  2606. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  2607. [IPA_4_5_APQ][IPA_CLIENT_DUMMY_CONS] = {
  2608. true, IPA_v4_5_GROUP_UL_DL,
  2609. false,
  2610. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2611. QMB_MASTER_SELECT_DDR,
  2612. { 31, 31, 8, 8, IPA_EE_AP } },
  2613. /* IPA_4_7 */
  2614. [IPA_4_7][IPA_CLIENT_WLAN1_PROD] = {
  2615. true, IPA_v4_7_GROUP_UL_DL,
  2616. true,
  2617. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2618. QMB_MASTER_SELECT_DDR,
  2619. { 3, 3, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2620. [IPA_4_7][IPA_CLIENT_USB_PROD] = {
  2621. true, IPA_v4_7_GROUP_UL_DL,
  2622. true,
  2623. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2624. QMB_MASTER_SELECT_DDR,
  2625. { 0, 0, 8, 16, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2626. [IPA_4_7][IPA_CLIENT_APPS_LAN_PROD] = {
  2627. true, IPA_v4_7_GROUP_UL_DL,
  2628. false,
  2629. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2630. QMB_MASTER_SELECT_DDR,
  2631. { 4, 4, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2632. [IPA_4_7][IPA_CLIENT_APPS_WAN_PROD] = {
  2633. true, IPA_v4_7_GROUP_UL_DL,
  2634. true,
  2635. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2636. QMB_MASTER_SELECT_DDR,
  2637. { 2, 2, 16, 32, IPA_EE_AP, GSI_SMART_PRE_FETCH, 7 } },
  2638. [IPA_4_7][IPA_CLIENT_APPS_CMD_PROD] = {
  2639. true, IPA_v4_7_GROUP_UL_DL,
  2640. false,
  2641. IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY,
  2642. QMB_MASTER_SELECT_DDR,
  2643. { 7, 5, 20, 24, IPA_EE_AP, GSI_SMART_PRE_FETCH, 8 } },
  2644. [IPA_4_7][IPA_CLIENT_Q6_WAN_PROD] = {
  2645. true, IPA_v4_7_GROUP_UL_DL,
  2646. true,
  2647. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2648. QMB_MASTER_SELECT_DDR,
  2649. { 5, 0, 16, 28, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2650. [IPA_4_7][IPA_CLIENT_Q6_CMD_PROD] = {
  2651. true, IPA_v4_7_GROUP_UL_DL,
  2652. false,
  2653. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
  2654. QMB_MASTER_SELECT_DDR,
  2655. { 6, 1, 20, 24, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 8 } },
  2656. [IPA_4_7][IPA_CLIENT_Q6_DL_NLO_DATA_PROD] = {
  2657. true, IPA_v4_7_GROUP_UL_DL,
  2658. true,
  2659. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_DEC_UCP,
  2660. QMB_MASTER_SELECT_DDR,
  2661. { 8, 2, 27, 32, IPA_EE_Q6, GSI_FREE_PRE_FETCH, 3 } },
  2662. /* Only for test purpose */
  2663. [IPA_4_7][IPA_CLIENT_TEST_PROD] = {
  2664. true, IPA_v4_7_GROUP_UL_DL,
  2665. true,
  2666. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2667. QMB_MASTER_SELECT_DDR,
  2668. { 0, 0, 8, 16, IPA_EE_AP } },
  2669. [IPA_4_7][IPA_CLIENT_TEST1_PROD] = {
  2670. true, IPA_v4_7_GROUP_UL_DL,
  2671. true,
  2672. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2673. QMB_MASTER_SELECT_DDR,
  2674. { 0, 0, 8, 16, IPA_EE_AP } },
  2675. [IPA_4_7][IPA_CLIENT_TEST2_PROD] = {
  2676. true, IPA_v4_7_GROUP_UL_DL,
  2677. true,
  2678. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2679. QMB_MASTER_SELECT_DDR,
  2680. { 1, 1, 8, 16, IPA_EE_AP } },
  2681. [IPA_4_7][IPA_CLIENT_TEST3_PROD] = {
  2682. true, IPA_v4_7_GROUP_UL_DL,
  2683. true,
  2684. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2685. QMB_MASTER_SELECT_DDR,
  2686. { 2, 2, 16, 32, IPA_EE_AP } },
  2687. [IPA_4_7][IPA_CLIENT_TEST4_PROD] = {
  2688. true, IPA_v4_7_GROUP_UL_DL,
  2689. true,
  2690. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
  2691. QMB_MASTER_SELECT_DDR,
  2692. { 1, 1, 8, 16, IPA_EE_AP } },
  2693. [IPA_4_7][IPA_CLIENT_WLAN1_CONS] = {
  2694. true, IPA_v4_7_GROUP_UL_DL,
  2695. false,
  2696. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2697. QMB_MASTER_SELECT_DDR,
  2698. { 18, 9, 8, 13, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2699. [IPA_4_7][IPA_CLIENT_USB_CONS] = {
  2700. true, IPA_v4_7_GROUP_UL_DL,
  2701. false,
  2702. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2703. QMB_MASTER_SELECT_DDR,
  2704. { 19, 10, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2705. [IPA_4_7][IPA_CLIENT_USB_DPL_CONS] = {
  2706. true, IPA_v4_7_GROUP_UL_DL,
  2707. false,
  2708. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2709. QMB_MASTER_SELECT_DDR,
  2710. { 17, 8, 5, 5, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2711. [IPA_4_7][IPA_CLIENT_ODL_DPL_CONS] = {
  2712. true, IPA_v4_7_GROUP_UL_DL,
  2713. false,
  2714. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2715. QMB_MASTER_SELECT_DDR,
  2716. { 22, 13, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2717. [IPA_4_7][IPA_CLIENT_APPS_LAN_CONS] = {
  2718. true, IPA_v4_7_GROUP_UL_DL,
  2719. false,
  2720. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2721. QMB_MASTER_SELECT_DDR,
  2722. { 9, 14, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2723. [IPA_4_7][IPA_CLIENT_APPS_WAN_CONS] = {
  2724. true, IPA_v4_7_GROUP_UL_DL,
  2725. false,
  2726. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2727. QMB_MASTER_SELECT_DDR,
  2728. { 16, 7, 9, 9, IPA_EE_AP, GSI_ESCAPE_BUF_ONLY, 0 } },
  2729. [IPA_4_7][IPA_CLIENT_APPS_WAN_COAL_CONS] = {
  2730. true, IPA_v4_7_GROUP_UL_DL,
  2731. false,
  2732. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2733. QMB_MASTER_SELECT_DDR,
  2734. { 15, 6, 8, 11, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 } },
  2735. [IPA_4_7][IPA_CLIENT_Q6_LAN_CONS] = {
  2736. true, IPA_v4_7_GROUP_UL_DL,
  2737. false,
  2738. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2739. QMB_MASTER_SELECT_DDR,
  2740. { 10, 3, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2741. [IPA_4_7][IPA_CLIENT_Q6_WAN_CONS] = {
  2742. true, IPA_v4_7_GROUP_UL_DL,
  2743. false,
  2744. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2745. QMB_MASTER_SELECT_DDR,
  2746. { 14, 7, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2747. [IPA_4_7][IPA_CLIENT_Q6_UL_NLO_DATA_CONS] = {
  2748. true, IPA_v4_7_GROUP_UL_DL,
  2749. false,
  2750. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2751. QMB_MASTER_SELECT_DDR,
  2752. { 12, 5, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2753. [IPA_4_7][IPA_CLIENT_Q6_UL_NLO_ACK_CONS] = {
  2754. true, IPA_v4_7_GROUP_UL_DL,
  2755. false,
  2756. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2757. QMB_MASTER_SELECT_DDR,
  2758. { 13, 6, 5, 5, IPA_EE_Q6, GSI_SMART_PRE_FETCH, 2 } },
  2759. [IPA_4_7][IPA_CLIENT_Q6_QBAP_STATUS_CONS] = {
  2760. true, IPA_v4_7_GROUP_UL_DL,
  2761. false,
  2762. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2763. QMB_MASTER_SELECT_DDR,
  2764. { 11, 4, 9, 9, IPA_EE_Q6, GSI_ESCAPE_BUF_ONLY, 0 } },
  2765. /* Only for test purpose */
  2766. /* MBIM aggregation test pipes should have the same QMB as USB_CONS */
  2767. [IPA_4_7][IPA_CLIENT_TEST_CONS] = {
  2768. true, IPA_v4_7_GROUP_UL_DL,
  2769. false,
  2770. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2771. QMB_MASTER_SELECT_DDR,
  2772. { 16, 7, 9, 9, IPA_EE_AP } },
  2773. [IPA_4_7][IPA_CLIENT_TEST1_CONS] = {
  2774. true, IPA_v4_7_GROUP_UL_DL,
  2775. false,
  2776. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2777. QMB_MASTER_SELECT_DDR,
  2778. { 16, 7, 9, 9, IPA_EE_AP } },
  2779. [IPA_4_7][IPA_CLIENT_TEST2_CONS] = {
  2780. true, IPA_v4_7_GROUP_UL_DL,
  2781. false,
  2782. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2783. QMB_MASTER_SELECT_DDR,
  2784. { 21, 12, 9, 9, IPA_EE_AP } },
  2785. [IPA_4_7][IPA_CLIENT_TEST3_CONS] = {
  2786. true, IPA_v4_7_GROUP_UL_DL,
  2787. false,
  2788. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2789. QMB_MASTER_SELECT_DDR,
  2790. { 19, 10, 9, 9, IPA_EE_AP } },
  2791. [IPA_4_7][IPA_CLIENT_TEST4_CONS] = {
  2792. true, IPA_v4_7_GROUP_UL_DL,
  2793. false,
  2794. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2795. QMB_MASTER_SELECT_DDR,
  2796. { 20, 11, 9, 9, IPA_EE_AP } },
  2797. /* Dummy consumer (pipe 31) is used in L2TP rt rule */
  2798. [IPA_4_7][IPA_CLIENT_DUMMY_CONS] = {
  2799. true, IPA_v4_7_GROUP_UL_DL,
  2800. false,
  2801. IPA_DPS_HPS_SEQ_TYPE_INVALID,
  2802. QMB_MASTER_SELECT_DDR,
  2803. { 31, 31, 8, 8, IPA_EE_AP } },
  2804. };
  2805. static struct ipa3_mem_partition ipa_4_1_mem_part = {
  2806. .ofst_start = 0x280,
  2807. .v4_flt_hash_ofst = 0x288,
  2808. .v4_flt_hash_size = 0x78,
  2809. .v4_flt_hash_size_ddr = 0x4000,
  2810. .v4_flt_nhash_ofst = 0x308,
  2811. .v4_flt_nhash_size = 0x78,
  2812. .v4_flt_nhash_size_ddr = 0x4000,
  2813. .v6_flt_hash_ofst = 0x388,
  2814. .v6_flt_hash_size = 0x78,
  2815. .v6_flt_hash_size_ddr = 0x4000,
  2816. .v6_flt_nhash_ofst = 0x408,
  2817. .v6_flt_nhash_size = 0x78,
  2818. .v6_flt_nhash_size_ddr = 0x4000,
  2819. .v4_rt_num_index = 0xf,
  2820. .v4_modem_rt_index_lo = 0x0,
  2821. .v4_modem_rt_index_hi = 0x7,
  2822. .v4_apps_rt_index_lo = 0x8,
  2823. .v4_apps_rt_index_hi = 0xe,
  2824. .v4_rt_hash_ofst = 0x488,
  2825. .v4_rt_hash_size = 0x78,
  2826. .v4_rt_hash_size_ddr = 0x4000,
  2827. .v4_rt_nhash_ofst = 0x508,
  2828. .v4_rt_nhash_size = 0x78,
  2829. .v4_rt_nhash_size_ddr = 0x4000,
  2830. .v6_rt_num_index = 0xf,
  2831. .v6_modem_rt_index_lo = 0x0,
  2832. .v6_modem_rt_index_hi = 0x7,
  2833. .v6_apps_rt_index_lo = 0x8,
  2834. .v6_apps_rt_index_hi = 0xe,
  2835. .v6_rt_hash_ofst = 0x588,
  2836. .v6_rt_hash_size = 0x78,
  2837. .v6_rt_hash_size_ddr = 0x4000,
  2838. .v6_rt_nhash_ofst = 0x608,
  2839. .v6_rt_nhash_size = 0x78,
  2840. .v6_rt_nhash_size_ddr = 0x4000,
  2841. .modem_hdr_ofst = 0x688,
  2842. .modem_hdr_size = 0x140,
  2843. .apps_hdr_ofst = 0x7c8,
  2844. .apps_hdr_size = 0x0,
  2845. .apps_hdr_size_ddr = 0x800,
  2846. .modem_hdr_proc_ctx_ofst = 0x7d0,
  2847. .modem_hdr_proc_ctx_size = 0x200,
  2848. .apps_hdr_proc_ctx_ofst = 0x9d0,
  2849. .apps_hdr_proc_ctx_size = 0x200,
  2850. .apps_hdr_proc_ctx_size_ddr = 0x0,
  2851. .modem_comp_decomp_ofst = 0x0,
  2852. .modem_comp_decomp_size = 0x0,
  2853. .modem_ofst = 0x13f0,
  2854. .modem_size = 0x100c,
  2855. .apps_v4_flt_hash_ofst = 0x23fc,
  2856. .apps_v4_flt_hash_size = 0x0,
  2857. .apps_v4_flt_nhash_ofst = 0x23fc,
  2858. .apps_v4_flt_nhash_size = 0x0,
  2859. .apps_v6_flt_hash_ofst = 0x23fc,
  2860. .apps_v6_flt_hash_size = 0x0,
  2861. .apps_v6_flt_nhash_ofst = 0x23fc,
  2862. .apps_v6_flt_nhash_size = 0x0,
  2863. .uc_info_ofst = 0x80,
  2864. .uc_info_size = 0x200,
  2865. .end_ofst = 0x2800,
  2866. .apps_v4_rt_hash_ofst = 0x23fc,
  2867. .apps_v4_rt_hash_size = 0x0,
  2868. .apps_v4_rt_nhash_ofst = 0x23fc,
  2869. .apps_v4_rt_nhash_size = 0x0,
  2870. .apps_v6_rt_hash_ofst = 0x23fc,
  2871. .apps_v6_rt_hash_size = 0x0,
  2872. .apps_v6_rt_nhash_ofst = 0x23fc,
  2873. .apps_v6_rt_nhash_size = 0x0,
  2874. .uc_descriptor_ram_ofst = 0x2400,
  2875. .uc_descriptor_ram_size = 0x400,
  2876. .pdn_config_ofst = 0xbd8,
  2877. .pdn_config_size = 0x50,
  2878. .stats_quota_ofst = 0xc30,
  2879. .stats_quota_size = 0x60,
  2880. .stats_tethering_ofst = 0xc90,
  2881. .stats_tethering_size = 0x140,
  2882. .stats_flt_v4_ofst = 0xdd0,
  2883. .stats_flt_v4_size = 0x180,
  2884. .stats_flt_v6_ofst = 0xf50,
  2885. .stats_flt_v6_size = 0x180,
  2886. .stats_rt_v4_ofst = 0x10d0,
  2887. .stats_rt_v4_size = 0x180,
  2888. .stats_rt_v6_ofst = 0x1250,
  2889. .stats_rt_v6_size = 0x180,
  2890. .stats_drop_ofst = 0x13d0,
  2891. .stats_drop_size = 0x20,
  2892. };
  2893. static struct ipa3_mem_partition ipa_4_2_mem_part = {
  2894. .ofst_start = 0x280,
  2895. .v4_flt_hash_ofst = 0x288,
  2896. .v4_flt_hash_size = 0x0,
  2897. .v4_flt_hash_size_ddr = 0x0,
  2898. .v4_flt_nhash_ofst = 0x290,
  2899. .v4_flt_nhash_size = 0x78,
  2900. .v4_flt_nhash_size_ddr = 0x4000,
  2901. .v6_flt_hash_ofst = 0x310,
  2902. .v6_flt_hash_size = 0x0,
  2903. .v6_flt_hash_size_ddr = 0x0,
  2904. .v6_flt_nhash_ofst = 0x318,
  2905. .v6_flt_nhash_size = 0x78,
  2906. .v6_flt_nhash_size_ddr = 0x4000,
  2907. .v4_rt_num_index = 0xf,
  2908. .v4_modem_rt_index_lo = 0x0,
  2909. .v4_modem_rt_index_hi = 0x7,
  2910. .v4_apps_rt_index_lo = 0x8,
  2911. .v4_apps_rt_index_hi = 0xe,
  2912. .v4_rt_hash_ofst = 0x398,
  2913. .v4_rt_hash_size = 0x0,
  2914. .v4_rt_hash_size_ddr = 0x0,
  2915. .v4_rt_nhash_ofst = 0x3A0,
  2916. .v4_rt_nhash_size = 0x78,
  2917. .v4_rt_nhash_size_ddr = 0x4000,
  2918. .v6_rt_num_index = 0xf,
  2919. .v6_modem_rt_index_lo = 0x0,
  2920. .v6_modem_rt_index_hi = 0x7,
  2921. .v6_apps_rt_index_lo = 0x8,
  2922. .v6_apps_rt_index_hi = 0xe,
  2923. .v6_rt_hash_ofst = 0x420,
  2924. .v6_rt_hash_size = 0x0,
  2925. .v6_rt_hash_size_ddr = 0x0,
  2926. .v6_rt_nhash_ofst = 0x428,
  2927. .v6_rt_nhash_size = 0x78,
  2928. .v6_rt_nhash_size_ddr = 0x4000,
  2929. .modem_hdr_ofst = 0x4A8,
  2930. .modem_hdr_size = 0x140,
  2931. .apps_hdr_ofst = 0x5E8,
  2932. .apps_hdr_size = 0x0,
  2933. .apps_hdr_size_ddr = 0x800,
  2934. .modem_hdr_proc_ctx_ofst = 0x5F0,
  2935. .modem_hdr_proc_ctx_size = 0x200,
  2936. .apps_hdr_proc_ctx_ofst = 0x7F0,
  2937. .apps_hdr_proc_ctx_size = 0x200,
  2938. .apps_hdr_proc_ctx_size_ddr = 0x0,
  2939. .modem_comp_decomp_ofst = 0x0,
  2940. .modem_comp_decomp_size = 0x0,
  2941. .modem_ofst = 0xbf0,
  2942. .modem_size = 0x140c,
  2943. .apps_v4_flt_hash_ofst = 0x1bfc,
  2944. .apps_v4_flt_hash_size = 0x0,
  2945. .apps_v4_flt_nhash_ofst = 0x1bfc,
  2946. .apps_v4_flt_nhash_size = 0x0,
  2947. .apps_v6_flt_hash_ofst = 0x1bfc,
  2948. .apps_v6_flt_hash_size = 0x0,
  2949. .apps_v6_flt_nhash_ofst = 0x1bfc,
  2950. .apps_v6_flt_nhash_size = 0x0,
  2951. .uc_info_ofst = 0x80,
  2952. .uc_info_size = 0x200,
  2953. .end_ofst = 0x2000,
  2954. .apps_v4_rt_hash_ofst = 0x1bfc,
  2955. .apps_v4_rt_hash_size = 0x0,
  2956. .apps_v4_rt_nhash_ofst = 0x1bfc,
  2957. .apps_v4_rt_nhash_size = 0x0,
  2958. .apps_v6_rt_hash_ofst = 0x1bfc,
  2959. .apps_v6_rt_hash_size = 0x0,
  2960. .apps_v6_rt_nhash_ofst = 0x1bfc,
  2961. .apps_v6_rt_nhash_size = 0x0,
  2962. .uc_descriptor_ram_ofst = 0x2000,
  2963. .uc_descriptor_ram_size = 0x0,
  2964. .pdn_config_ofst = 0x9F8,
  2965. .pdn_config_size = 0x50,
  2966. .stats_quota_ofst = 0xa50,
  2967. .stats_quota_size = 0x60,
  2968. .stats_tethering_ofst = 0xab0,
  2969. .stats_tethering_size = 0x140,
  2970. .stats_flt_v4_ofst = 0xbf0,
  2971. .stats_flt_v4_size = 0x0,
  2972. .stats_flt_v6_ofst = 0xbf0,
  2973. .stats_flt_v6_size = 0x0,
  2974. .stats_rt_v4_ofst = 0xbf0,
  2975. .stats_rt_v4_size = 0x0,
  2976. .stats_rt_v6_ofst = 0xbf0,
  2977. .stats_rt_v6_size = 0x0,
  2978. .stats_drop_ofst = 0xbf0,
  2979. .stats_drop_size = 0x0,
  2980. };
  2981. static struct ipa3_mem_partition ipa_4_5_mem_part = {
  2982. .uc_info_ofst = 0x80,
  2983. .uc_info_size = 0x200,
  2984. .ofst_start = 0x280,
  2985. .v4_flt_hash_ofst = 0x288,
  2986. .v4_flt_hash_size = 0x78,
  2987. .v4_flt_hash_size_ddr = 0x4000,
  2988. .v4_flt_nhash_ofst = 0x308,
  2989. .v4_flt_nhash_size = 0x78,
  2990. .v4_flt_nhash_size_ddr = 0x4000,
  2991. .v6_flt_hash_ofst = 0x388,
  2992. .v6_flt_hash_size = 0x78,
  2993. .v6_flt_hash_size_ddr = 0x4000,
  2994. .v6_flt_nhash_ofst = 0x408,
  2995. .v6_flt_nhash_size = 0x78,
  2996. .v6_flt_nhash_size_ddr = 0x4000,
  2997. .v4_rt_num_index = 0xf,
  2998. .v4_modem_rt_index_lo = 0x0,
  2999. .v4_modem_rt_index_hi = 0x7,
  3000. .v4_apps_rt_index_lo = 0x8,
  3001. .v4_apps_rt_index_hi = 0xe,
  3002. .v4_rt_hash_ofst = 0x488,
  3003. .v4_rt_hash_size = 0x78,
  3004. .v4_rt_hash_size_ddr = 0x4000,
  3005. .v4_rt_nhash_ofst = 0x508,
  3006. .v4_rt_nhash_size = 0x78,
  3007. .v4_rt_nhash_size_ddr = 0x4000,
  3008. .v6_rt_num_index = 0xf,
  3009. .v6_modem_rt_index_lo = 0x0,
  3010. .v6_modem_rt_index_hi = 0x7,
  3011. .v6_apps_rt_index_lo = 0x8,
  3012. .v6_apps_rt_index_hi = 0xe,
  3013. .v6_rt_hash_ofst = 0x588,
  3014. .v6_rt_hash_size = 0x78,
  3015. .v6_rt_hash_size_ddr = 0x4000,
  3016. .v6_rt_nhash_ofst = 0x608,
  3017. .v6_rt_nhash_size = 0x78,
  3018. .v6_rt_nhash_size_ddr = 0x4000,
  3019. .modem_hdr_ofst = 0x688,
  3020. .modem_hdr_size = 0x240,
  3021. .apps_hdr_ofst = 0x8c8,
  3022. .apps_hdr_size = 0x200,
  3023. .apps_hdr_size_ddr = 0x800,
  3024. .modem_hdr_proc_ctx_ofst = 0xad0,
  3025. .modem_hdr_proc_ctx_size = 0xb20,
  3026. .apps_hdr_proc_ctx_ofst = 0x15f0,
  3027. .apps_hdr_proc_ctx_size = 0x200,
  3028. .apps_hdr_proc_ctx_size_ddr = 0x0,
  3029. .nat_tbl_ofst = 0x1800,
  3030. .nat_tbl_size = 0x800,
  3031. .nat_index_tbl_ofst = 0x2000,
  3032. .nat_index_tbl_size = 0x100,
  3033. .nat_exp_tbl_ofst = 0x2100,
  3034. .nat_exp_tbl_size = 0x400,
  3035. .stats_quota_ofst = 0x2510,
  3036. .stats_quota_size = 0x78,
  3037. .stats_tethering_ofst = 0x2588,
  3038. .stats_tethering_size = 0x238,
  3039. .stats_flt_v4_ofst = 0,
  3040. .stats_flt_v4_size = 0,
  3041. .stats_flt_v6_ofst = 0,
  3042. .stats_flt_v6_size = 0,
  3043. .stats_rt_v4_ofst = 0,
  3044. .stats_rt_v4_size = 0,
  3045. .stats_rt_v6_ofst = 0,
  3046. .stats_rt_v6_size = 0,
  3047. .stats_fnr_ofst = 0x27c0,
  3048. .stats_fnr_size = 0x800,
  3049. .stats_drop_ofst = 0x2fc0,
  3050. .stats_drop_size = 0x20,
  3051. .modem_comp_decomp_ofst = 0x0,
  3052. .modem_comp_decomp_size = 0x0,
  3053. .modem_ofst = 0x2fe8,
  3054. .modem_size = 0x800,
  3055. .apps_v4_flt_hash_ofst = 0x2718,
  3056. .apps_v4_flt_hash_size = 0x0,
  3057. .apps_v4_flt_nhash_ofst = 0x2718,
  3058. .apps_v4_flt_nhash_size = 0x0,
  3059. .apps_v6_flt_hash_ofst = 0x2718,
  3060. .apps_v6_flt_hash_size = 0x0,
  3061. .apps_v6_flt_nhash_ofst = 0x2718,
  3062. .apps_v6_flt_nhash_size = 0x0,
  3063. .apps_v4_rt_hash_ofst = 0x2718,
  3064. .apps_v4_rt_hash_size = 0x0,
  3065. .apps_v4_rt_nhash_ofst = 0x2718,
  3066. .apps_v4_rt_nhash_size = 0x0,
  3067. .apps_v6_rt_hash_ofst = 0x2718,
  3068. .apps_v6_rt_hash_size = 0x0,
  3069. .apps_v6_rt_nhash_ofst = 0x2718,
  3070. .apps_v6_rt_nhash_size = 0x0,
  3071. .uc_descriptor_ram_ofst = 0x3800,
  3072. .uc_descriptor_ram_size = 0x1000,
  3073. .pdn_config_ofst = 0x4800,
  3074. .pdn_config_size = 0x50,
  3075. .end_ofst = 0x4850,
  3076. };
  3077. static struct ipa3_mem_partition ipa_4_7_mem_part = {
  3078. .uc_info_ofst = 0x80,
  3079. .uc_info_size = 0x200,
  3080. .ofst_start = 0x280,
  3081. .v4_flt_hash_ofst = 0x288,
  3082. .v4_flt_hash_size = 0x78,
  3083. .v4_flt_hash_size_ddr = 0x4000,
  3084. .v4_flt_nhash_ofst = 0x308,
  3085. .v4_flt_nhash_size = 0x78,
  3086. .v4_flt_nhash_size_ddr = 0x4000,
  3087. .v6_flt_hash_ofst = 0x388,
  3088. .v6_flt_hash_size = 0x78,
  3089. .v6_flt_hash_size_ddr = 0x4000,
  3090. .v6_flt_nhash_ofst = 0x408,
  3091. .v6_flt_nhash_size = 0x78,
  3092. .v6_flt_nhash_size_ddr = 0x4000,
  3093. .v4_rt_num_index = 0xf,
  3094. .v4_modem_rt_index_lo = 0x0,
  3095. .v4_modem_rt_index_hi = 0x7,
  3096. .v4_apps_rt_index_lo = 0x8,
  3097. .v4_apps_rt_index_hi = 0xe,
  3098. .v4_rt_hash_ofst = 0x488,
  3099. .v4_rt_hash_size = 0x78,
  3100. .v4_rt_hash_size_ddr = 0x4000,
  3101. .v4_rt_nhash_ofst = 0x508,
  3102. .v4_rt_nhash_size = 0x78,
  3103. .v4_rt_nhash_size_ddr = 0x4000,
  3104. .v6_rt_num_index = 0xf,
  3105. .v6_modem_rt_index_lo = 0x0,
  3106. .v6_modem_rt_index_hi = 0x7,
  3107. .v6_apps_rt_index_lo = 0x8,
  3108. .v6_apps_rt_index_hi = 0xe,
  3109. .v6_rt_hash_ofst = 0x588,
  3110. .v6_rt_hash_size = 0x78,
  3111. .v6_rt_hash_size_ddr = 0x4000,
  3112. .v6_rt_nhash_ofst = 0x608,
  3113. .v6_rt_nhash_size = 0x78,
  3114. .v6_rt_nhash_size_ddr = 0x4000,
  3115. .modem_hdr_ofst = 0x688,
  3116. .modem_hdr_size = 0x240,
  3117. .apps_hdr_ofst = 0x8c8,
  3118. .apps_hdr_size = 0x200,
  3119. .apps_hdr_size_ddr = 0x800,
  3120. .modem_hdr_proc_ctx_ofst = 0xad0,
  3121. .modem_hdr_proc_ctx_size = 0x200,
  3122. .apps_hdr_proc_ctx_ofst = 0xcd0,
  3123. .apps_hdr_proc_ctx_size = 0x200,
  3124. .apps_hdr_proc_ctx_size_ddr = 0x0,
  3125. .nat_tbl_ofst = 0xee0,
  3126. .nat_tbl_size = 0x800,
  3127. .nat_index_tbl_ofst = 0x16e0,
  3128. .nat_index_tbl_size = 0x100,
  3129. .nat_exp_tbl_ofst = 0x17e0,
  3130. .nat_exp_tbl_size = 0x400,
  3131. .pdn_config_ofst = 0x1be8,
  3132. .pdn_config_size = 0x50,
  3133. .stats_quota_ofst = 0x1c40,
  3134. .stats_quota_size = 0x78,
  3135. .stats_tethering_ofst = 0x1cb8,
  3136. .stats_tethering_size = 0x238,
  3137. .stats_flt_v4_ofst = 0,
  3138. .stats_flt_v4_size = 0,
  3139. .stats_flt_v6_ofst = 0,
  3140. .stats_flt_v6_size = 0,
  3141. .stats_rt_v4_ofst = 0,
  3142. .stats_rt_v4_size = 0,
  3143. .stats_rt_v6_ofst = 0,
  3144. .stats_rt_v6_size = 0,
  3145. .stats_fnr_ofst = 0x1ef0,
  3146. .stats_fnr_size = 0x0,
  3147. .stats_drop_ofst = 0x1ef0,
  3148. .stats_drop_size = 0x20,
  3149. .modem_comp_decomp_ofst = 0x0,
  3150. .modem_comp_decomp_size = 0x0,
  3151. .modem_ofst = 0x1f18,
  3152. .modem_size = 0x100c,
  3153. .apps_v4_flt_hash_ofst = 0x1f18,
  3154. .apps_v4_flt_hash_size = 0x0,
  3155. .apps_v4_flt_nhash_ofst = 0x1f18,
  3156. .apps_v4_flt_nhash_size = 0x0,
  3157. .apps_v6_flt_hash_ofst = 0x1f18,
  3158. .apps_v6_flt_hash_size = 0x0,
  3159. .apps_v6_flt_nhash_ofst = 0x1f18,
  3160. .apps_v6_flt_nhash_size = 0x0,
  3161. .apps_v4_rt_hash_ofst = 0x1f18,
  3162. .apps_v4_rt_hash_size = 0x0,
  3163. .apps_v4_rt_nhash_ofst = 0x1f18,
  3164. .apps_v4_rt_nhash_size = 0x0,
  3165. .apps_v6_rt_hash_ofst = 0x1f18,
  3166. .apps_v6_rt_hash_size = 0x0,
  3167. .apps_v6_rt_nhash_ofst = 0x1f18,
  3168. .apps_v6_rt_nhash_size = 0x0,
  3169. .uc_descriptor_ram_ofst = 0x3000,
  3170. .uc_descriptor_ram_size = 0x0000,
  3171. .end_ofst = 0x3000,
  3172. };
  3173. /**
  3174. * ipa3_get_clients_from_rm_resource() - get IPA clients which are related to an
  3175. * IPA_RM resource
  3176. *
  3177. * @resource: [IN] IPA Resource Manager resource
  3178. * @clients: [OUT] Empty array which will contain the list of clients. The
  3179. * caller must initialize this array.
  3180. *
  3181. * Return codes: 0 on success, negative on failure.
  3182. */
  3183. int ipa3_get_clients_from_rm_resource(
  3184. enum ipa_rm_resource_name resource,
  3185. struct ipa3_client_names *clients)
  3186. {
  3187. int i = 0;
  3188. if (resource < 0 ||
  3189. resource >= IPA_RM_RESOURCE_MAX ||
  3190. !clients) {
  3191. IPAERR("Bad parameters\n");
  3192. return -EINVAL;
  3193. }
  3194. switch (resource) {
  3195. case IPA_RM_RESOURCE_USB_CONS:
  3196. if (ipa3_get_ep_mapping(IPA_CLIENT_USB_CONS) != -1)
  3197. clients->names[i++] = IPA_CLIENT_USB_CONS;
  3198. break;
  3199. case IPA_RM_RESOURCE_USB_DPL_CONS:
  3200. if (ipa3_get_ep_mapping(IPA_CLIENT_USB_DPL_CONS) != -1)
  3201. clients->names[i++] = IPA_CLIENT_USB_DPL_CONS;
  3202. break;
  3203. case IPA_RM_RESOURCE_HSIC_CONS:
  3204. clients->names[i++] = IPA_CLIENT_HSIC1_CONS;
  3205. break;
  3206. case IPA_RM_RESOURCE_WLAN_CONS:
  3207. clients->names[i++] = IPA_CLIENT_WLAN1_CONS;
  3208. clients->names[i++] = IPA_CLIENT_WLAN2_CONS;
  3209. clients->names[i++] = IPA_CLIENT_WLAN3_CONS;
  3210. break;
  3211. case IPA_RM_RESOURCE_MHI_CONS:
  3212. clients->names[i++] = IPA_CLIENT_MHI_CONS;
  3213. break;
  3214. case IPA_RM_RESOURCE_ODU_ADAPT_CONS:
  3215. clients->names[i++] = IPA_CLIENT_ODU_EMB_CONS;
  3216. clients->names[i++] = IPA_CLIENT_ODU_TETH_CONS;
  3217. break;
  3218. case IPA_RM_RESOURCE_ETHERNET_CONS:
  3219. clients->names[i++] = IPA_CLIENT_ETHERNET_CONS;
  3220. break;
  3221. case IPA_RM_RESOURCE_USB_PROD:
  3222. if (ipa3_get_ep_mapping(IPA_CLIENT_USB_PROD) != -1)
  3223. clients->names[i++] = IPA_CLIENT_USB_PROD;
  3224. break;
  3225. case IPA_RM_RESOURCE_HSIC_PROD:
  3226. clients->names[i++] = IPA_CLIENT_HSIC1_PROD;
  3227. break;
  3228. case IPA_RM_RESOURCE_MHI_PROD:
  3229. clients->names[i++] = IPA_CLIENT_MHI_PROD;
  3230. break;
  3231. case IPA_RM_RESOURCE_ODU_ADAPT_PROD:
  3232. clients->names[i++] = IPA_CLIENT_ODU_PROD;
  3233. break;
  3234. case IPA_RM_RESOURCE_ETHERNET_PROD:
  3235. clients->names[i++] = IPA_CLIENT_ETHERNET_PROD;
  3236. break;
  3237. default:
  3238. break;
  3239. }
  3240. clients->length = i;
  3241. return 0;
  3242. }
  3243. /**
  3244. * ipa3_should_pipe_be_suspended() - returns true when the client's pipe should
  3245. * be suspended during a power save scenario. False otherwise.
  3246. *
  3247. * @client: [IN] IPA client
  3248. */
  3249. bool ipa3_should_pipe_be_suspended(enum ipa_client_type client)
  3250. {
  3251. struct ipa3_ep_context *ep;
  3252. int ipa_ep_idx;
  3253. ipa_ep_idx = ipa3_get_ep_mapping(client);
  3254. if (ipa_ep_idx == -1) {
  3255. IPAERR("Invalid client.\n");
  3256. WARN_ON(1);
  3257. return false;
  3258. }
  3259. ep = &ipa3_ctx->ep[ipa_ep_idx];
  3260. /*
  3261. * starting IPA 4.0 pipe no longer can be suspended. Instead,
  3262. * the corresponding GSI channel should be stopped. Usually client
  3263. * driver will take care of stopping the channel. For client drivers
  3264. * that are not stopping the channel, IPA RM will do that based on
  3265. * ipa3_should_pipe_channel_be_stopped().
  3266. */
  3267. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0)
  3268. return false;
  3269. if (ep->keep_ipa_awake)
  3270. return false;
  3271. if (client == IPA_CLIENT_USB_CONS ||
  3272. client == IPA_CLIENT_USB_DPL_CONS ||
  3273. client == IPA_CLIENT_MHI_CONS ||
  3274. client == IPA_CLIENT_MHI_DPL_CONS ||
  3275. client == IPA_CLIENT_HSIC1_CONS ||
  3276. client == IPA_CLIENT_WLAN1_CONS ||
  3277. client == IPA_CLIENT_WLAN2_CONS ||
  3278. client == IPA_CLIENT_WLAN3_CONS ||
  3279. client == IPA_CLIENT_WLAN4_CONS ||
  3280. client == IPA_CLIENT_ODU_EMB_CONS ||
  3281. client == IPA_CLIENT_ODU_TETH_CONS ||
  3282. client == IPA_CLIENT_ETHERNET_CONS)
  3283. return true;
  3284. return false;
  3285. }
  3286. /**
  3287. * ipa3_should_pipe_channel_be_stopped() - returns true when the client's
  3288. * channel should be stopped during a power save scenario. False otherwise.
  3289. * Most client already stops the GSI channel on suspend, and are not included
  3290. * in the list below.
  3291. *
  3292. * @client: [IN] IPA client
  3293. */
  3294. static bool ipa3_should_pipe_channel_be_stopped(enum ipa_client_type client)
  3295. {
  3296. struct ipa3_ep_context *ep;
  3297. int ipa_ep_idx;
  3298. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_0)
  3299. return false;
  3300. ipa_ep_idx = ipa3_get_ep_mapping(client);
  3301. if (ipa_ep_idx == -1) {
  3302. IPAERR("Invalid client.\n");
  3303. WARN_ON(1);
  3304. return false;
  3305. }
  3306. ep = &ipa3_ctx->ep[ipa_ep_idx];
  3307. if (ep->keep_ipa_awake)
  3308. return false;
  3309. if (client == IPA_CLIENT_ODU_EMB_CONS ||
  3310. client == IPA_CLIENT_ODU_TETH_CONS)
  3311. return true;
  3312. return false;
  3313. }
  3314. /**
  3315. * ipa3_suspend_resource_sync() - suspend client endpoints related to the IPA_RM
  3316. * resource and decrement active clients counter, which may result in clock
  3317. * gating of IPA clocks.
  3318. *
  3319. * @resource: [IN] IPA Resource Manager resource
  3320. *
  3321. * Return codes: 0 on success, negative on failure.
  3322. */
  3323. int ipa3_suspend_resource_sync(enum ipa_rm_resource_name resource)
  3324. {
  3325. struct ipa3_client_names clients;
  3326. int res;
  3327. int index;
  3328. struct ipa_ep_cfg_ctrl suspend;
  3329. enum ipa_client_type client;
  3330. int ipa_ep_idx;
  3331. bool pipe_suspended = false;
  3332. memset(&clients, 0, sizeof(clients));
  3333. res = ipa3_get_clients_from_rm_resource(resource, &clients);
  3334. if (res) {
  3335. IPAERR("Bad params.\n");
  3336. return res;
  3337. }
  3338. for (index = 0; index < clients.length; index++) {
  3339. client = clients.names[index];
  3340. ipa_ep_idx = ipa3_get_ep_mapping(client);
  3341. if (ipa_ep_idx == -1) {
  3342. IPAERR("Invalid client.\n");
  3343. res = -EINVAL;
  3344. continue;
  3345. }
  3346. ipa3_ctx->resume_on_connect[client] = false;
  3347. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3348. ipa3_should_pipe_be_suspended(client)) {
  3349. if (ipa3_ctx->ep[ipa_ep_idx].valid) {
  3350. /* suspend endpoint */
  3351. memset(&suspend, 0, sizeof(suspend));
  3352. suspend.ipa_ep_suspend = true;
  3353. ipa3_cfg_ep_ctrl(ipa_ep_idx, &suspend);
  3354. pipe_suspended = true;
  3355. }
  3356. }
  3357. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3358. ipa3_should_pipe_channel_be_stopped(client)) {
  3359. if (ipa3_ctx->ep[ipa_ep_idx].valid) {
  3360. /* Stop GSI channel */
  3361. res = ipa3_stop_gsi_channel(ipa_ep_idx);
  3362. if (res) {
  3363. IPAERR("failed stop gsi ch %lu\n",
  3364. ipa3_ctx->ep[ipa_ep_idx].gsi_chan_hdl);
  3365. return res;
  3366. }
  3367. }
  3368. }
  3369. }
  3370. /* Sleep ~1 msec */
  3371. if (pipe_suspended)
  3372. usleep_range(1000, 2000);
  3373. /* before gating IPA clocks do TAG process */
  3374. ipa3_ctx->tag_process_before_gating = true;
  3375. IPA_ACTIVE_CLIENTS_DEC_RESOURCE(ipa_rm_resource_str(resource));
  3376. return 0;
  3377. }
  3378. /**
  3379. * ipa3_suspend_resource_no_block() - suspend client endpoints related to the
  3380. * IPA_RM resource and decrement active clients counter. This function is
  3381. * guaranteed to avoid sleeping.
  3382. *
  3383. * @resource: [IN] IPA Resource Manager resource
  3384. *
  3385. * Return codes: 0 on success, negative on failure.
  3386. */
  3387. int ipa3_suspend_resource_no_block(enum ipa_rm_resource_name resource)
  3388. {
  3389. int res;
  3390. struct ipa3_client_names clients;
  3391. int index;
  3392. enum ipa_client_type client;
  3393. struct ipa_ep_cfg_ctrl suspend;
  3394. int ipa_ep_idx;
  3395. struct ipa_active_client_logging_info log_info;
  3396. memset(&clients, 0, sizeof(clients));
  3397. res = ipa3_get_clients_from_rm_resource(resource, &clients);
  3398. if (res) {
  3399. IPAERR(
  3400. "ipa3_get_clients_from_rm_resource() failed, name = %d.\n",
  3401. resource);
  3402. goto bail;
  3403. }
  3404. for (index = 0; index < clients.length; index++) {
  3405. client = clients.names[index];
  3406. ipa_ep_idx = ipa3_get_ep_mapping(client);
  3407. if (ipa_ep_idx == -1) {
  3408. IPAERR("Invalid client.\n");
  3409. res = -EINVAL;
  3410. continue;
  3411. }
  3412. ipa3_ctx->resume_on_connect[client] = false;
  3413. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3414. ipa3_should_pipe_be_suspended(client)) {
  3415. if (ipa3_ctx->ep[ipa_ep_idx].valid) {
  3416. /* suspend endpoint */
  3417. memset(&suspend, 0, sizeof(suspend));
  3418. suspend.ipa_ep_suspend = true;
  3419. ipa3_cfg_ep_ctrl(ipa_ep_idx, &suspend);
  3420. }
  3421. }
  3422. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3423. ipa3_should_pipe_channel_be_stopped(client)) {
  3424. res = -EPERM;
  3425. goto bail;
  3426. }
  3427. }
  3428. if (res == 0) {
  3429. IPA_ACTIVE_CLIENTS_PREP_RESOURCE(log_info,
  3430. ipa_rm_resource_str(resource));
  3431. /* before gating IPA clocks do TAG process */
  3432. ipa3_ctx->tag_process_before_gating = true;
  3433. ipa3_dec_client_disable_clks_no_block(&log_info);
  3434. }
  3435. bail:
  3436. return res;
  3437. }
  3438. /**
  3439. * ipa3_resume_resource() - resume client endpoints related to the IPA_RM
  3440. * resource.
  3441. *
  3442. * @resource: [IN] IPA Resource Manager resource
  3443. *
  3444. * Return codes: 0 on success, negative on failure.
  3445. */
  3446. int ipa3_resume_resource(enum ipa_rm_resource_name resource)
  3447. {
  3448. struct ipa3_client_names clients;
  3449. int res;
  3450. int index;
  3451. struct ipa_ep_cfg_ctrl suspend;
  3452. enum ipa_client_type client;
  3453. int ipa_ep_idx;
  3454. memset(&clients, 0, sizeof(clients));
  3455. res = ipa3_get_clients_from_rm_resource(resource, &clients);
  3456. if (res) {
  3457. IPAERR("ipa3_get_clients_from_rm_resource() failed.\n");
  3458. return res;
  3459. }
  3460. for (index = 0; index < clients.length; index++) {
  3461. client = clients.names[index];
  3462. ipa_ep_idx = ipa3_get_ep_mapping(client);
  3463. if (ipa_ep_idx == -1) {
  3464. IPAERR("Invalid client.\n");
  3465. res = -EINVAL;
  3466. continue;
  3467. }
  3468. /*
  3469. * The related ep, will be resumed on connect
  3470. * while its resource is granted
  3471. */
  3472. ipa3_ctx->resume_on_connect[client] = true;
  3473. IPADBG("%d will be resumed on connect.\n", client);
  3474. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3475. ipa3_should_pipe_be_suspended(client)) {
  3476. if (ipa3_ctx->ep[ipa_ep_idx].valid) {
  3477. memset(&suspend, 0, sizeof(suspend));
  3478. suspend.ipa_ep_suspend = false;
  3479. ipa3_cfg_ep_ctrl(ipa_ep_idx, &suspend);
  3480. }
  3481. }
  3482. if (ipa3_ctx->ep[ipa_ep_idx].client == client &&
  3483. ipa3_should_pipe_channel_be_stopped(client)) {
  3484. if (ipa3_ctx->ep[ipa_ep_idx].valid) {
  3485. res = gsi_start_channel(
  3486. ipa3_ctx->ep[ipa_ep_idx].gsi_chan_hdl);
  3487. if (res) {
  3488. IPAERR("failed to start gsi ch %lu\n",
  3489. ipa3_ctx->ep[ipa_ep_idx].gsi_chan_hdl);
  3490. return res;
  3491. }
  3492. }
  3493. }
  3494. }
  3495. return res;
  3496. }
  3497. /**
  3498. * ipa3_get_hw_type_index() - Get HW type index which is used as the entry index
  3499. * for ep\resource groups related arrays .
  3500. *
  3501. * Return value: HW type index
  3502. */
  3503. static u8 ipa3_get_hw_type_index(void)
  3504. {
  3505. u8 hw_type_index;
  3506. switch (ipa3_ctx->ipa_hw_type) {
  3507. case IPA_HW_v3_0:
  3508. case IPA_HW_v3_1:
  3509. hw_type_index = IPA_3_0;
  3510. break;
  3511. case IPA_HW_v3_5:
  3512. hw_type_index = IPA_3_5;
  3513. /*
  3514. *this flag is initialized only after fw load trigger from
  3515. * user space (ipa3_write)
  3516. */
  3517. if (ipa3_ctx->ipa_config_is_mhi)
  3518. hw_type_index = IPA_3_5_MHI;
  3519. break;
  3520. case IPA_HW_v3_5_1:
  3521. hw_type_index = IPA_3_5_1;
  3522. break;
  3523. case IPA_HW_v4_0:
  3524. hw_type_index = IPA_4_0;
  3525. /*
  3526. *this flag is initialized only after fw load trigger from
  3527. * user space (ipa3_write)
  3528. */
  3529. if (ipa3_ctx->ipa_config_is_mhi)
  3530. hw_type_index = IPA_4_0_MHI;
  3531. break;
  3532. case IPA_HW_v4_1:
  3533. hw_type_index = IPA_4_1;
  3534. break;
  3535. case IPA_HW_v4_2:
  3536. hw_type_index = IPA_4_2;
  3537. break;
  3538. case IPA_HW_v4_5:
  3539. hw_type_index = IPA_4_5;
  3540. if (ipa3_ctx->ipa_config_is_mhi)
  3541. hw_type_index = IPA_4_5_MHI;
  3542. if (ipa3_ctx->platform_type == IPA_PLAT_TYPE_APQ)
  3543. hw_type_index = IPA_4_5_APQ;
  3544. break;
  3545. case IPA_HW_v4_7:
  3546. hw_type_index = IPA_4_7;
  3547. break;
  3548. default:
  3549. IPAERR("Incorrect IPA version %d\n", ipa3_ctx->ipa_hw_type);
  3550. hw_type_index = IPA_3_0;
  3551. break;
  3552. }
  3553. return hw_type_index;
  3554. }
  3555. /**
  3556. * _ipa_sram_settings_read_v3_0() - Read SRAM settings from HW
  3557. *
  3558. * Returns: None
  3559. */
  3560. void _ipa_sram_settings_read_v3_0(void)
  3561. {
  3562. struct ipahal_reg_shared_mem_size smem_sz;
  3563. memset(&smem_sz, 0, sizeof(smem_sz));
  3564. ipahal_read_reg_fields(IPA_SHARED_MEM_SIZE, &smem_sz);
  3565. ipa3_ctx->smem_restricted_bytes = smem_sz.shared_mem_baddr;
  3566. ipa3_ctx->smem_sz = smem_sz.shared_mem_sz;
  3567. /* reg fields are in 8B units */
  3568. ipa3_ctx->smem_restricted_bytes *= 8;
  3569. ipa3_ctx->smem_sz *= 8;
  3570. ipa3_ctx->smem_reqd_sz = IPA_MEM_PART(end_ofst);
  3571. ipa3_ctx->hdr_tbl_lcl = false;
  3572. ipa3_ctx->hdr_proc_ctx_tbl_lcl = true;
  3573. /*
  3574. * when proc ctx table is located in internal memory,
  3575. * modem entries resides first.
  3576. */
  3577. if (ipa3_ctx->hdr_proc_ctx_tbl_lcl) {
  3578. ipa3_ctx->hdr_proc_ctx_tbl.start_offset =
  3579. IPA_MEM_PART(modem_hdr_proc_ctx_size);
  3580. }
  3581. ipa3_ctx->ip4_rt_tbl_hash_lcl = false;
  3582. ipa3_ctx->ip4_rt_tbl_nhash_lcl = false;
  3583. ipa3_ctx->ip6_rt_tbl_hash_lcl = false;
  3584. ipa3_ctx->ip6_rt_tbl_nhash_lcl = false;
  3585. ipa3_ctx->ip4_flt_tbl_hash_lcl = false;
  3586. ipa3_ctx->ip4_flt_tbl_nhash_lcl = false;
  3587. ipa3_ctx->ip6_flt_tbl_hash_lcl = false;
  3588. ipa3_ctx->ip6_flt_tbl_nhash_lcl = false;
  3589. }
  3590. /**
  3591. * ipa3_cfg_route() - configure IPA route
  3592. * @route: IPA route
  3593. *
  3594. * Return codes:
  3595. * 0: success
  3596. */
  3597. int ipa3_cfg_route(struct ipahal_reg_route *route)
  3598. {
  3599. IPADBG("disable_route_block=%d, default_pipe=%d, default_hdr_tbl=%d\n",
  3600. route->route_dis,
  3601. route->route_def_pipe,
  3602. route->route_def_hdr_table);
  3603. IPADBG("default_hdr_ofst=%d, default_frag_pipe=%d\n",
  3604. route->route_def_hdr_ofst,
  3605. route->route_frag_def_pipe);
  3606. IPADBG("default_retain_hdr=%d\n",
  3607. route->route_def_retain_hdr);
  3608. if (route->route_dis) {
  3609. IPAERR("Route disable is not supported!\n");
  3610. return -EPERM;
  3611. }
  3612. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  3613. ipahal_write_reg_fields(IPA_ROUTE, route);
  3614. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  3615. return 0;
  3616. }
  3617. /**
  3618. * ipa3_cfg_filter() - configure filter
  3619. * @disable: disable value
  3620. *
  3621. * Return codes:
  3622. * 0: success
  3623. */
  3624. int ipa3_cfg_filter(u32 disable)
  3625. {
  3626. IPAERR_RL("Filter disable is not supported!\n");
  3627. return -EPERM;
  3628. }
  3629. /**
  3630. * ipa_disable_hashing_rt_flt_v4_2() - Disable filer and route hashing.
  3631. *
  3632. * Return codes: 0 for success, negative value for failure
  3633. */
  3634. static int ipa_disable_hashing_rt_flt_v4_2(void)
  3635. {
  3636. IPADBG("Disable hashing for filter and route table in IPA 4.2 HW\n");
  3637. ipahal_write_reg(IPA_FILT_ROUT_HASH_EN,
  3638. IPA_FILT_ROUT_HASH_REG_VAL_v4_2);
  3639. return 0;
  3640. }
  3641. /**
  3642. * ipa_comp_cfg() - Configure QMB/Master port selection
  3643. *
  3644. * Returns: None
  3645. */
  3646. static void ipa_comp_cfg(void)
  3647. {
  3648. struct ipahal_reg_comp_cfg comp_cfg;
  3649. /* IPAv4 specific, on NON-MHI config*/
  3650. if ((ipa3_ctx->ipa_hw_type == IPA_HW_v4_0) &&
  3651. (!ipa3_ctx->ipa_config_is_mhi)) {
  3652. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3653. IPADBG("Before comp config\n");
  3654. IPADBG("ipa_qmb_select_by_address_global_en = %d\n",
  3655. comp_cfg.ipa_qmb_select_by_address_global_en);
  3656. IPADBG("ipa_qmb_select_by_address_prod_en = %d\n",
  3657. comp_cfg.ipa_qmb_select_by_address_prod_en);
  3658. IPADBG("ipa_qmb_select_by_address_cons_en = %d\n",
  3659. comp_cfg.ipa_qmb_select_by_address_cons_en);
  3660. comp_cfg.ipa_qmb_select_by_address_global_en = false;
  3661. comp_cfg.ipa_qmb_select_by_address_prod_en = false;
  3662. comp_cfg.ipa_qmb_select_by_address_cons_en = false;
  3663. ipahal_write_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3664. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3665. IPADBG("After comp config\n");
  3666. IPADBG("ipa_qmb_select_by_address_global_en = %d\n",
  3667. comp_cfg.ipa_qmb_select_by_address_global_en);
  3668. IPADBG("ipa_qmb_select_by_address_prod_en = %d\n",
  3669. comp_cfg.ipa_qmb_select_by_address_prod_en);
  3670. IPADBG("ipa_qmb_select_by_address_cons_en = %d\n",
  3671. comp_cfg.ipa_qmb_select_by_address_cons_en);
  3672. }
  3673. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  3674. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3675. IPADBG("Before comp config\n");
  3676. IPADBG("gsi_multi_inorder_rd_dis = %d\n",
  3677. comp_cfg.gsi_multi_inorder_rd_dis);
  3678. IPADBG("gsi_multi_inorder_wr_dis = %d\n",
  3679. comp_cfg.gsi_multi_inorder_wr_dis);
  3680. comp_cfg.gsi_multi_inorder_rd_dis = true;
  3681. comp_cfg.gsi_multi_inorder_wr_dis = true;
  3682. ipahal_write_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3683. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3684. IPADBG("After comp config\n");
  3685. IPADBG("gsi_multi_inorder_rd_dis = %d\n",
  3686. comp_cfg.gsi_multi_inorder_rd_dis);
  3687. IPADBG("gsi_multi_inorder_wr_dis = %d\n",
  3688. comp_cfg.gsi_multi_inorder_wr_dis);
  3689. }
  3690. /* set GSI_MULTI_AXI_MASTERS_DIS = true after HW.4.1 */
  3691. if ((ipa3_ctx->ipa_hw_type == IPA_HW_v4_1) ||
  3692. (ipa3_ctx->ipa_hw_type == IPA_HW_v4_2)) {
  3693. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3694. IPADBG("Before comp config\n");
  3695. IPADBG("gsi_multi_axi_masters_dis = %d\n",
  3696. comp_cfg.gsi_multi_axi_masters_dis);
  3697. comp_cfg.gsi_multi_axi_masters_dis = true;
  3698. ipahal_write_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3699. ipahal_read_reg_fields(IPA_COMP_CFG, &comp_cfg);
  3700. IPADBG("After comp config\n");
  3701. IPADBG("gsi_multi_axi_masters_dis = %d\n",
  3702. comp_cfg.gsi_multi_axi_masters_dis);
  3703. }
  3704. }
  3705. /**
  3706. * ipa3_cfg_qsb() - Configure IPA QSB maximal reads and writes
  3707. *
  3708. * Returns: None
  3709. */
  3710. static void ipa3_cfg_qsb(void)
  3711. {
  3712. u8 hw_type_idx;
  3713. const struct ipa_qmb_outstanding *qmb_ot;
  3714. struct ipahal_reg_qsb_max_reads max_reads = { 0 };
  3715. struct ipahal_reg_qsb_max_writes max_writes = { 0 };
  3716. hw_type_idx = ipa3_get_hw_type_index();
  3717. qmb_ot = &(ipa3_qmb_outstanding[hw_type_idx][IPA_QMB_INSTANCE_DDR]);
  3718. max_reads.qmb_0_max_reads = qmb_ot->ot_reads;
  3719. max_writes.qmb_0_max_writes = qmb_ot->ot_writes;
  3720. qmb_ot = &(ipa3_qmb_outstanding[hw_type_idx][IPA_QMB_INSTANCE_PCIE]);
  3721. max_reads.qmb_1_max_reads = qmb_ot->ot_reads;
  3722. max_writes.qmb_1_max_writes = qmb_ot->ot_writes;
  3723. ipahal_write_reg_fields(IPA_QSB_MAX_WRITES, &max_writes);
  3724. ipahal_write_reg_fields(IPA_QSB_MAX_READS, &max_reads);
  3725. }
  3726. /* relevant starting IPA4.5 */
  3727. static void ipa_cfg_qtime(void)
  3728. {
  3729. struct ipahal_reg_qtime_timestamp_cfg ts_cfg;
  3730. struct ipahal_reg_timers_pulse_gran_cfg gran_cfg;
  3731. struct ipahal_reg_timers_xo_clk_div_cfg div_cfg;
  3732. u32 val;
  3733. /* Configure timestamp resolution */
  3734. memset(&ts_cfg, 0, sizeof(ts_cfg));
  3735. ts_cfg.dpl_timestamp_lsb = 0;
  3736. ts_cfg.dpl_timestamp_sel = false; /* DPL: use legacy 1ms resolution */
  3737. ts_cfg.tag_timestamp_lsb = IPA_TAG_TIMER_TIMESTAMP_SHFT;
  3738. ts_cfg.nat_timestamp_lsb = IPA_NAT_TIMER_TIMESTAMP_SHFT;
  3739. val = ipahal_read_reg(IPA_QTIME_TIMESTAMP_CFG);
  3740. IPADBG("qtime timestamp before cfg: 0x%x\n", val);
  3741. ipahal_write_reg_fields(IPA_QTIME_TIMESTAMP_CFG, &ts_cfg);
  3742. val = ipahal_read_reg(IPA_QTIME_TIMESTAMP_CFG);
  3743. IPADBG("qtime timestamp after cfg: 0x%x\n", val);
  3744. /* Configure timers pulse generators granularity */
  3745. memset(&gran_cfg, 0, sizeof(gran_cfg));
  3746. gran_cfg.gran_0 = IPA_TIMERS_TIME_GRAN_100_USEC;
  3747. gran_cfg.gran_1 = IPA_TIMERS_TIME_GRAN_1_MSEC;
  3748. gran_cfg.gran_2 = IPA_TIMERS_TIME_GRAN_1_MSEC;
  3749. val = ipahal_read_reg(IPA_TIMERS_PULSE_GRAN_CFG);
  3750. IPADBG("timer pulse granularity before cfg: 0x%x\n", val);
  3751. ipahal_write_reg_fields(IPA_TIMERS_PULSE_GRAN_CFG, &gran_cfg);
  3752. val = ipahal_read_reg(IPA_TIMERS_PULSE_GRAN_CFG);
  3753. IPADBG("timer pulse granularity after cfg: 0x%x\n", val);
  3754. /* Configure timers XO Clock divider */
  3755. memset(&div_cfg, 0, sizeof(div_cfg));
  3756. ipahal_read_reg_fields(IPA_TIMERS_XO_CLK_DIV_CFG, &div_cfg);
  3757. IPADBG("timer XO clk divider before cfg: enabled=%d divider=%u\n",
  3758. div_cfg.enable, div_cfg.value);
  3759. /* Make sure divider is disabled */
  3760. if (div_cfg.enable) {
  3761. div_cfg.enable = false;
  3762. ipahal_write_reg_fields(IPA_TIMERS_XO_CLK_DIV_CFG, &div_cfg);
  3763. }
  3764. /* At emulation systems XO clock is lower than on real target.
  3765. * (e.g. 19.2Mhz compared to 96Khz)
  3766. * Use lowest possible divider.
  3767. */
  3768. if (ipa3_ctx->ipa3_hw_mode == IPA_HW_MODE_VIRTUAL ||
  3769. ipa3_ctx->ipa3_hw_mode == IPA_HW_MODE_EMULATION) {
  3770. div_cfg.value = 0;
  3771. }
  3772. div_cfg.enable = true; /* Enable the divider */
  3773. ipahal_write_reg_fields(IPA_TIMERS_XO_CLK_DIV_CFG, &div_cfg);
  3774. ipahal_read_reg_fields(IPA_TIMERS_XO_CLK_DIV_CFG, &div_cfg);
  3775. IPADBG("timer XO clk divider after cfg: enabled=%d divider=%u\n",
  3776. div_cfg.enable, div_cfg.value);
  3777. }
  3778. /**
  3779. * ipa3_init_hw() - initialize HW
  3780. *
  3781. * Return codes:
  3782. * 0: success
  3783. */
  3784. int ipa3_init_hw(void)
  3785. {
  3786. u32 ipa_version = 0;
  3787. struct ipahal_reg_counter_cfg cnt_cfg;
  3788. /* Read IPA version and make sure we have access to the registers */
  3789. ipa_version = ipahal_read_reg(IPA_VERSION);
  3790. IPADBG("IPA_VERSION=%u\n", ipa_version);
  3791. if (ipa_version == 0)
  3792. return -EFAULT;
  3793. switch (ipa3_ctx->ipa_hw_type) {
  3794. case IPA_HW_v3_0:
  3795. case IPA_HW_v3_1:
  3796. ipahal_write_reg(IPA_BCR, IPA_BCR_REG_VAL_v3_0);
  3797. break;
  3798. case IPA_HW_v3_5:
  3799. case IPA_HW_v3_5_1:
  3800. ipahal_write_reg(IPA_BCR, IPA_BCR_REG_VAL_v3_5);
  3801. break;
  3802. case IPA_HW_v4_0:
  3803. case IPA_HW_v4_1:
  3804. ipahal_write_reg(IPA_BCR, IPA_BCR_REG_VAL_v4_0);
  3805. break;
  3806. case IPA_HW_v4_2:
  3807. ipahal_write_reg(IPA_BCR, IPA_BCR_REG_VAL_v4_2);
  3808. break;
  3809. default:
  3810. IPADBG("Do not update BCR - hw_type=%d\n",
  3811. ipa3_ctx->ipa_hw_type);
  3812. break;
  3813. }
  3814. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0 &&
  3815. ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  3816. struct ipahal_reg_clkon_cfg clkon_cfg;
  3817. struct ipahal_reg_tx_cfg tx_cfg;
  3818. memset(&clkon_cfg, 0, sizeof(clkon_cfg));
  3819. /*enable open global clocks*/
  3820. clkon_cfg.open_global_2x_clk = true;
  3821. clkon_cfg.open_global = true;
  3822. ipahal_write_reg_fields(IPA_CLKON_CFG, &clkon_cfg);
  3823. ipahal_read_reg_fields(IPA_TX_CFG, &tx_cfg);
  3824. /* disable PA_MASK_EN to allow holb drop */
  3825. tx_cfg.pa_mask_en = 0;
  3826. ipahal_write_reg_fields(IPA_TX_CFG, &tx_cfg);
  3827. }
  3828. ipa3_cfg_qsb();
  3829. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  3830. /* set aggr granularity for 0.5 msec*/
  3831. cnt_cfg.aggr_granularity = GRAN_VALUE_500_USEC;
  3832. ipahal_write_reg_fields(IPA_COUNTER_CFG, &cnt_cfg);
  3833. } else {
  3834. ipa_cfg_qtime();
  3835. }
  3836. ipa_comp_cfg();
  3837. /*
  3838. * In IPA 4.2 filter and routing hashing not supported
  3839. * disabling hash enable register.
  3840. */
  3841. if (ipa3_ctx->ipa_fltrt_not_hashable)
  3842. ipa_disable_hashing_rt_flt_v4_2();
  3843. return 0;
  3844. }
  3845. /**
  3846. * ipa3_get_ep_mapping() - provide endpoint mapping
  3847. * @client: client type
  3848. *
  3849. * Return value: endpoint mapping
  3850. */
  3851. int ipa3_get_ep_mapping(enum ipa_client_type client)
  3852. {
  3853. int ipa_ep_idx;
  3854. u8 hw_idx = ipa3_get_hw_type_index();
  3855. if (client >= IPA_CLIENT_MAX || client < 0) {
  3856. IPAERR_RL("Bad client number! client =%d\n", client);
  3857. return IPA_EP_NOT_ALLOCATED;
  3858. }
  3859. if (!ipa3_ep_mapping[hw_idx][client].valid)
  3860. return IPA_EP_NOT_ALLOCATED;
  3861. ipa_ep_idx =
  3862. ipa3_ep_mapping[hw_idx][client].ipa_gsi_ep_info.ipa_ep_num;
  3863. if (ipa_ep_idx < 0 || (ipa_ep_idx >= IPA3_MAX_NUM_PIPES
  3864. && client != IPA_CLIENT_DUMMY_CONS))
  3865. return IPA_EP_NOT_ALLOCATED;
  3866. return ipa_ep_idx;
  3867. }
  3868. /**
  3869. * ipa3_get_gsi_ep_info() - provide gsi ep information
  3870. * @client: IPA client value
  3871. *
  3872. * Return value: pointer to ipa_gsi_ep_info
  3873. */
  3874. const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
  3875. (enum ipa_client_type client)
  3876. {
  3877. int ep_idx;
  3878. ep_idx = ipa3_get_ep_mapping(client);
  3879. if (ep_idx == IPA_EP_NOT_ALLOCATED)
  3880. return NULL;
  3881. if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
  3882. return NULL;
  3883. return &(ipa3_ep_mapping[ipa3_get_hw_type_index()]
  3884. [client].ipa_gsi_ep_info);
  3885. }
  3886. /**
  3887. * ipa_get_ep_group() - provide endpoint group by client
  3888. * @client: client type
  3889. *
  3890. * Return value: endpoint group
  3891. */
  3892. int ipa_get_ep_group(enum ipa_client_type client)
  3893. {
  3894. if (client >= IPA_CLIENT_MAX || client < 0) {
  3895. IPAERR("Bad client number! client =%d\n", client);
  3896. return -EINVAL;
  3897. }
  3898. if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
  3899. return -EINVAL;
  3900. return ipa3_ep_mapping[ipa3_get_hw_type_index()][client].group_num;
  3901. }
  3902. /**
  3903. * ipa3_get_qmb_master_sel() - provide QMB master selection for the client
  3904. * @client: client type
  3905. *
  3906. * Return value: QMB master index
  3907. */
  3908. u8 ipa3_get_qmb_master_sel(enum ipa_client_type client)
  3909. {
  3910. if (client >= IPA_CLIENT_MAX || client < 0) {
  3911. IPAERR("Bad client number! client =%d\n", client);
  3912. return -EINVAL;
  3913. }
  3914. if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
  3915. return -EINVAL;
  3916. return ipa3_ep_mapping[ipa3_get_hw_type_index()]
  3917. [client].qmb_master_sel;
  3918. }
  3919. /* ipa3_set_client() - provide client mapping
  3920. * @client: client type
  3921. *
  3922. * Return value: none
  3923. */
  3924. void ipa3_set_client(int index, enum ipacm_client_enum client, bool uplink)
  3925. {
  3926. if (client > IPACM_CLIENT_MAX || client < IPACM_CLIENT_USB) {
  3927. IPAERR("Bad client number! client =%d\n", client);
  3928. } else if (index >= IPA3_MAX_NUM_PIPES || index < 0) {
  3929. IPAERR("Bad pipe index! index =%d\n", index);
  3930. } else {
  3931. ipa3_ctx->ipacm_client[index].client_enum = client;
  3932. ipa3_ctx->ipacm_client[index].uplink = uplink;
  3933. }
  3934. }
  3935. /* ipa3_get_wlan_stats() - get ipa wifi stats
  3936. *
  3937. * Return value: success or failure
  3938. */
  3939. int ipa3_get_wlan_stats(struct ipa_get_wdi_sap_stats *wdi_sap_stats)
  3940. {
  3941. if (ipa3_ctx->uc_wdi_ctx.stats_notify) {
  3942. ipa3_ctx->uc_wdi_ctx.stats_notify(IPA_GET_WDI_SAP_STATS,
  3943. wdi_sap_stats);
  3944. } else {
  3945. IPAERR_RL("uc_wdi_ctx.stats_notify NULL\n");
  3946. return -EFAULT;
  3947. }
  3948. return 0;
  3949. }
  3950. int ipa3_set_wlan_quota(struct ipa_set_wifi_quota *wdi_quota)
  3951. {
  3952. if (ipa3_ctx->uc_wdi_ctx.stats_notify) {
  3953. ipa3_ctx->uc_wdi_ctx.stats_notify(IPA_SET_WIFI_QUOTA,
  3954. wdi_quota);
  3955. } else {
  3956. IPAERR("uc_wdi_ctx.stats_notify NULL\n");
  3957. return -EFAULT;
  3958. }
  3959. return 0;
  3960. }
  3961. /**
  3962. * ipa3_get_client() - provide client mapping
  3963. * @client: client type
  3964. *
  3965. * Return value: client mapping enum
  3966. */
  3967. enum ipacm_client_enum ipa3_get_client(int pipe_idx)
  3968. {
  3969. if (pipe_idx >= IPA3_MAX_NUM_PIPES || pipe_idx < 0) {
  3970. IPAERR("Bad pipe index! pipe_idx =%d\n", pipe_idx);
  3971. return IPACM_CLIENT_MAX;
  3972. } else {
  3973. return ipa3_ctx->ipacm_client[pipe_idx].client_enum;
  3974. }
  3975. }
  3976. /**
  3977. * ipa2_get_client_uplink() - provide client mapping
  3978. * @client: client type
  3979. *
  3980. * Return value: none
  3981. */
  3982. bool ipa3_get_client_uplink(int pipe_idx)
  3983. {
  3984. if (pipe_idx < 0 || pipe_idx >= IPA3_MAX_NUM_PIPES) {
  3985. IPAERR("invalid pipe idx %d\n", pipe_idx);
  3986. return false;
  3987. }
  3988. return ipa3_ctx->ipacm_client[pipe_idx].uplink;
  3989. }
  3990. /**
  3991. * ipa3_get_rm_resource_from_ep() - get the IPA_RM resource which is related to
  3992. * the supplied pipe index.
  3993. *
  3994. * @pipe_idx:
  3995. *
  3996. * Return value: IPA_RM resource related to the pipe, -1 if a resource was not
  3997. * found.
  3998. */
  3999. enum ipa_rm_resource_name ipa3_get_rm_resource_from_ep(int pipe_idx)
  4000. {
  4001. int i;
  4002. int j;
  4003. enum ipa_client_type client;
  4004. struct ipa3_client_names clients;
  4005. bool found = false;
  4006. if (pipe_idx >= ipa3_ctx->ipa_num_pipes || pipe_idx < 0) {
  4007. IPAERR("Bad pipe index!\n");
  4008. return -EINVAL;
  4009. }
  4010. client = ipa3_ctx->ep[pipe_idx].client;
  4011. for (i = 0; i < IPA_RM_RESOURCE_MAX; i++) {
  4012. memset(&clients, 0, sizeof(clients));
  4013. ipa3_get_clients_from_rm_resource(i, &clients);
  4014. for (j = 0; j < clients.length; j++) {
  4015. if (clients.names[j] == client) {
  4016. found = true;
  4017. break;
  4018. }
  4019. }
  4020. if (found)
  4021. break;
  4022. }
  4023. if (!found)
  4024. return -EFAULT;
  4025. return i;
  4026. }
  4027. /**
  4028. * ipa3_get_client_mapping() - provide client mapping
  4029. * @pipe_idx: IPA end-point number
  4030. *
  4031. * Return value: client mapping
  4032. */
  4033. enum ipa_client_type ipa3_get_client_mapping(int pipe_idx)
  4034. {
  4035. if (pipe_idx >= ipa3_ctx->ipa_num_pipes || pipe_idx < 0) {
  4036. IPAERR("Bad pipe index!\n");
  4037. WARN_ON(1);
  4038. return -EINVAL;
  4039. }
  4040. return ipa3_ctx->ep[pipe_idx].client;
  4041. }
  4042. /**
  4043. * ipa3_get_client_by_pipe() - return client type relative to pipe
  4044. * index
  4045. * @pipe_idx: IPA end-point number
  4046. *
  4047. * Return value: client type
  4048. */
  4049. enum ipa_client_type ipa3_get_client_by_pipe(int pipe_idx)
  4050. {
  4051. int j = 0;
  4052. for (j = 0; j < IPA_CLIENT_MAX; j++) {
  4053. const struct ipa_ep_configuration *iec_ptr =
  4054. &(ipa3_ep_mapping[ipa3_get_hw_type_index()][j]);
  4055. if (iec_ptr->valid &&
  4056. iec_ptr->ipa_gsi_ep_info.ipa_ep_num == pipe_idx)
  4057. break;
  4058. }
  4059. if (j == IPA_CLIENT_MAX)
  4060. IPADBG("Got to IPA_CLIENT_MAX (%d) while searching for (%d)\n",
  4061. j, pipe_idx);
  4062. return j;
  4063. }
  4064. /**
  4065. * ipa_init_ep_flt_bitmap() - Initialize the bitmap
  4066. * that represents the End-points that supports filtering
  4067. */
  4068. void ipa_init_ep_flt_bitmap(void)
  4069. {
  4070. enum ipa_client_type cl;
  4071. u8 hw_idx = ipa3_get_hw_type_index();
  4072. u32 bitmap;
  4073. u32 pipe_num;
  4074. const struct ipa_gsi_ep_config *gsi_ep_ptr;
  4075. bitmap = 0;
  4076. if (ipa3_ctx->ep_flt_bitmap) {
  4077. WARN_ON(1);
  4078. return;
  4079. }
  4080. for (cl = 0; cl < IPA_CLIENT_MAX ; cl++) {
  4081. if (ipa3_ep_mapping[hw_idx][cl].support_flt) {
  4082. gsi_ep_ptr =
  4083. &ipa3_ep_mapping[hw_idx][cl].ipa_gsi_ep_info;
  4084. pipe_num =
  4085. gsi_ep_ptr->ipa_ep_num;
  4086. bitmap |= (1U << pipe_num);
  4087. if (bitmap != ipa3_ctx->ep_flt_bitmap) {
  4088. ipa3_ctx->ep_flt_bitmap = bitmap;
  4089. ipa3_ctx->ep_flt_num++;
  4090. }
  4091. }
  4092. }
  4093. }
  4094. /**
  4095. * ipa_is_ep_support_flt() - Given an End-point check
  4096. * whether it supports filtering or not.
  4097. *
  4098. * @pipe_idx:
  4099. *
  4100. * Return values:
  4101. * true if supports and false if not
  4102. */
  4103. bool ipa_is_ep_support_flt(int pipe_idx)
  4104. {
  4105. if (pipe_idx >= ipa3_ctx->ipa_num_pipes || pipe_idx < 0) {
  4106. IPAERR("Bad pipe index!\n");
  4107. return false;
  4108. }
  4109. return ipa3_ctx->ep_flt_bitmap & (1U<<pipe_idx);
  4110. }
  4111. /**
  4112. * ipa3_cfg_ep_seq() - IPA end-point HPS/DPS sequencer type configuration
  4113. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4114. *
  4115. * Returns: 0 on success, negative on failure
  4116. *
  4117. * Note: Should not be called from atomic context
  4118. */
  4119. int ipa3_cfg_ep_seq(u32 clnt_hdl, const struct ipa_ep_cfg_seq *seq_cfg)
  4120. {
  4121. int type;
  4122. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4123. ipa3_ctx->ep[clnt_hdl].valid == 0) {
  4124. IPAERR("bad param, clnt_hdl = %d", clnt_hdl);
  4125. return -EINVAL;
  4126. }
  4127. if (IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client)) {
  4128. IPAERR("SEQ does not apply to IPA consumer EP %d\n", clnt_hdl);
  4129. return -EINVAL;
  4130. }
  4131. /*
  4132. * Skip Configure sequencers type for test clients.
  4133. * These are configured dynamically in ipa3_cfg_ep_mode
  4134. */
  4135. if (IPA_CLIENT_IS_TEST(ipa3_ctx->ep[clnt_hdl].client)) {
  4136. IPADBG("Skip sequencers configuration for test clients\n");
  4137. return 0;
  4138. }
  4139. if (seq_cfg->set_dynamic)
  4140. type = seq_cfg->seq_type;
  4141. else
  4142. type = ipa3_ep_mapping[ipa3_get_hw_type_index()]
  4143. [ipa3_ctx->ep[clnt_hdl].client].sequencer_type;
  4144. if (type != IPA_DPS_HPS_SEQ_TYPE_INVALID) {
  4145. if (ipa3_ctx->ep[clnt_hdl].cfg.mode.mode == IPA_DMA &&
  4146. !IPA_DPS_HPS_SEQ_TYPE_IS_DMA(type)) {
  4147. IPAERR("Configuring non-DMA SEQ type to DMA pipe\n");
  4148. WARN_ON(1);
  4149. return -EINVAL;
  4150. }
  4151. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4152. /* Configure sequencers type*/
  4153. IPADBG("set sequencers to sequence 0x%x, ep = %d\n", type,
  4154. clnt_hdl);
  4155. ipahal_write_reg_n(IPA_ENDP_INIT_SEQ_n, clnt_hdl, type);
  4156. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4157. } else {
  4158. IPADBG("should not set sequencer type of ep = %d\n", clnt_hdl);
  4159. }
  4160. return 0;
  4161. }
  4162. /**
  4163. * ipa3_cfg_ep - IPA end-point configuration
  4164. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4165. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4166. *
  4167. * This includes nat, IPv6CT, header, mode, aggregation and route settings and
  4168. * is a one shot API to configure the IPA end-point fully
  4169. *
  4170. * Returns: 0 on success, negative on failure
  4171. *
  4172. * Note: Should not be called from atomic context
  4173. */
  4174. int ipa3_cfg_ep(u32 clnt_hdl, const struct ipa_ep_cfg *ipa_ep_cfg)
  4175. {
  4176. int result = -EINVAL;
  4177. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4178. ipa3_ctx->ep[clnt_hdl].valid == 0 || ipa_ep_cfg == NULL) {
  4179. IPAERR("bad parm.\n");
  4180. return -EINVAL;
  4181. }
  4182. result = ipa3_cfg_ep_hdr(clnt_hdl, &ipa_ep_cfg->hdr);
  4183. if (result)
  4184. return result;
  4185. result = ipa3_cfg_ep_hdr_ext(clnt_hdl, &ipa_ep_cfg->hdr_ext);
  4186. if (result)
  4187. return result;
  4188. result = ipa3_cfg_ep_aggr(clnt_hdl, &ipa_ep_cfg->aggr);
  4189. if (result)
  4190. return result;
  4191. result = ipa3_cfg_ep_cfg(clnt_hdl, &ipa_ep_cfg->cfg);
  4192. if (result)
  4193. return result;
  4194. if (IPA_CLIENT_IS_PROD(ipa3_ctx->ep[clnt_hdl].client)) {
  4195. result = ipa3_cfg_ep_nat(clnt_hdl, &ipa_ep_cfg->nat);
  4196. if (result)
  4197. return result;
  4198. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  4199. result = ipa3_cfg_ep_conn_track(clnt_hdl,
  4200. &ipa_ep_cfg->conn_track);
  4201. if (result)
  4202. return result;
  4203. }
  4204. result = ipa3_cfg_ep_mode(clnt_hdl, &ipa_ep_cfg->mode);
  4205. if (result)
  4206. return result;
  4207. result = ipa3_cfg_ep_seq(clnt_hdl, &ipa_ep_cfg->seq);
  4208. if (result)
  4209. return result;
  4210. result = ipa3_cfg_ep_route(clnt_hdl, &ipa_ep_cfg->route);
  4211. if (result)
  4212. return result;
  4213. result = ipa3_cfg_ep_deaggr(clnt_hdl, &ipa_ep_cfg->deaggr);
  4214. if (result)
  4215. return result;
  4216. } else {
  4217. result = ipa3_cfg_ep_metadata_mask(clnt_hdl,
  4218. &ipa_ep_cfg->metadata_mask);
  4219. if (result)
  4220. return result;
  4221. }
  4222. return 0;
  4223. }
  4224. static const char *ipa3_get_nat_en_str(enum ipa_nat_en_type nat_en)
  4225. {
  4226. switch (nat_en) {
  4227. case (IPA_BYPASS_NAT):
  4228. return "NAT disabled";
  4229. case (IPA_SRC_NAT):
  4230. return "Source NAT";
  4231. case (IPA_DST_NAT):
  4232. return "Dst NAT";
  4233. }
  4234. return "undefined";
  4235. }
  4236. static const char *ipa3_get_ipv6ct_en_str(enum ipa_ipv6ct_en_type ipv6ct_en)
  4237. {
  4238. switch (ipv6ct_en) {
  4239. case (IPA_BYPASS_IPV6CT):
  4240. return "ipv6ct disabled";
  4241. case (IPA_ENABLE_IPV6CT):
  4242. return "ipv6ct enabled";
  4243. }
  4244. return "undefined";
  4245. }
  4246. /**
  4247. * ipa3_cfg_ep_nat() - IPA end-point NAT configuration
  4248. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4249. * @ep_nat: [in] IPA NAT end-point configuration params
  4250. *
  4251. * Returns: 0 on success, negative on failure
  4252. *
  4253. * Note: Should not be called from atomic context
  4254. */
  4255. int ipa3_cfg_ep_nat(u32 clnt_hdl, const struct ipa_ep_cfg_nat *ep_nat)
  4256. {
  4257. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4258. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_nat == NULL) {
  4259. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4260. clnt_hdl,
  4261. ipa3_ctx->ep[clnt_hdl].valid);
  4262. return -EINVAL;
  4263. }
  4264. if (IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client)) {
  4265. IPAERR("NAT does not apply to IPA out EP %d\n", clnt_hdl);
  4266. return -EINVAL;
  4267. }
  4268. IPADBG("pipe=%d, nat_en=%d(%s)\n",
  4269. clnt_hdl,
  4270. ep_nat->nat_en,
  4271. ipa3_get_nat_en_str(ep_nat->nat_en));
  4272. /* copy over EP cfg */
  4273. ipa3_ctx->ep[clnt_hdl].cfg.nat = *ep_nat;
  4274. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4275. ipahal_write_reg_n_fields(IPA_ENDP_INIT_NAT_n, clnt_hdl, ep_nat);
  4276. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4277. return 0;
  4278. }
  4279. /**
  4280. * ipa3_cfg_ep_conn_track() - IPA end-point IPv6CT configuration
  4281. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4282. * @ep_conn_track: [in] IPA IPv6CT end-point configuration params
  4283. *
  4284. * Returns: 0 on success, negative on failure
  4285. *
  4286. * Note: Should not be called from atomic context
  4287. */
  4288. int ipa3_cfg_ep_conn_track(u32 clnt_hdl,
  4289. const struct ipa_ep_cfg_conn_track *ep_conn_track)
  4290. {
  4291. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4292. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_conn_track == NULL) {
  4293. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4294. clnt_hdl,
  4295. ipa3_ctx->ep[clnt_hdl].valid);
  4296. return -EINVAL;
  4297. }
  4298. if (IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client)) {
  4299. IPAERR("IPv6CT does not apply to IPA out EP %d\n", clnt_hdl);
  4300. return -EINVAL;
  4301. }
  4302. IPADBG("pipe=%d, conn_track_en=%d(%s)\n",
  4303. clnt_hdl,
  4304. ep_conn_track->conn_track_en,
  4305. ipa3_get_ipv6ct_en_str(ep_conn_track->conn_track_en));
  4306. /* copy over EP cfg */
  4307. ipa3_ctx->ep[clnt_hdl].cfg.conn_track = *ep_conn_track;
  4308. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4309. ipahal_write_reg_n_fields(IPA_ENDP_INIT_CONN_TRACK_n, clnt_hdl,
  4310. ep_conn_track);
  4311. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4312. return 0;
  4313. }
  4314. /**
  4315. * ipa3_cfg_ep_status() - IPA end-point status configuration
  4316. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4317. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4318. *
  4319. * Returns: 0 on success, negative on failure
  4320. *
  4321. * Note: Should not be called from atomic context
  4322. */
  4323. int ipa3_cfg_ep_status(u32 clnt_hdl,
  4324. const struct ipahal_reg_ep_cfg_status *ep_status)
  4325. {
  4326. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4327. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_status == NULL) {
  4328. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4329. clnt_hdl,
  4330. ipa3_ctx->ep[clnt_hdl].valid);
  4331. return -EINVAL;
  4332. }
  4333. IPADBG("pipe=%d, status_en=%d status_ep=%d status_location=%d\n",
  4334. clnt_hdl,
  4335. ep_status->status_en,
  4336. ep_status->status_ep,
  4337. ep_status->status_location);
  4338. /* copy over EP cfg */
  4339. ipa3_ctx->ep[clnt_hdl].status = *ep_status;
  4340. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4341. ipahal_write_reg_n_fields(IPA_ENDP_STATUS_n, clnt_hdl, ep_status);
  4342. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4343. return 0;
  4344. }
  4345. /**
  4346. * ipa3_cfg_ep_cfg() - IPA end-point cfg configuration
  4347. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4348. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4349. *
  4350. * Returns: 0 on success, negative on failure
  4351. *
  4352. * Note: Should not be called from atomic context
  4353. */
  4354. int ipa3_cfg_ep_cfg(u32 clnt_hdl, const struct ipa_ep_cfg_cfg *cfg)
  4355. {
  4356. u8 qmb_master_sel;
  4357. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4358. ipa3_ctx->ep[clnt_hdl].valid == 0 || cfg == NULL) {
  4359. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4360. clnt_hdl,
  4361. ipa3_ctx->ep[clnt_hdl].valid);
  4362. return -EINVAL;
  4363. }
  4364. /* copy over EP cfg */
  4365. ipa3_ctx->ep[clnt_hdl].cfg.cfg = *cfg;
  4366. /* Override QMB master selection */
  4367. qmb_master_sel = ipa3_get_qmb_master_sel(ipa3_ctx->ep[clnt_hdl].client);
  4368. ipa3_ctx->ep[clnt_hdl].cfg.cfg.gen_qmb_master_sel = qmb_master_sel;
  4369. IPADBG(
  4370. "pipe=%d, frag_ofld_en=%d cs_ofld_en=%d mdata_hdr_ofst=%d gen_qmb_master_sel=%d\n",
  4371. clnt_hdl,
  4372. ipa3_ctx->ep[clnt_hdl].cfg.cfg.frag_offload_en,
  4373. ipa3_ctx->ep[clnt_hdl].cfg.cfg.cs_offload_en,
  4374. ipa3_ctx->ep[clnt_hdl].cfg.cfg.cs_metadata_hdr_offset,
  4375. ipa3_ctx->ep[clnt_hdl].cfg.cfg.gen_qmb_master_sel);
  4376. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4377. ipahal_write_reg_n_fields(IPA_ENDP_INIT_CFG_n, clnt_hdl,
  4378. &ipa3_ctx->ep[clnt_hdl].cfg.cfg);
  4379. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4380. return 0;
  4381. }
  4382. /**
  4383. * ipa3_cfg_ep_metadata_mask() - IPA end-point meta-data mask configuration
  4384. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4385. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4386. *
  4387. * Returns: 0 on success, negative on failure
  4388. *
  4389. * Note: Should not be called from atomic context
  4390. */
  4391. int ipa3_cfg_ep_metadata_mask(u32 clnt_hdl,
  4392. const struct ipa_ep_cfg_metadata_mask
  4393. *metadata_mask)
  4394. {
  4395. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4396. ipa3_ctx->ep[clnt_hdl].valid == 0 || metadata_mask == NULL) {
  4397. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4398. clnt_hdl,
  4399. ipa3_ctx->ep[clnt_hdl].valid);
  4400. return -EINVAL;
  4401. }
  4402. IPADBG("pipe=%d, metadata_mask=0x%x\n",
  4403. clnt_hdl,
  4404. metadata_mask->metadata_mask);
  4405. /* copy over EP cfg */
  4406. ipa3_ctx->ep[clnt_hdl].cfg.metadata_mask = *metadata_mask;
  4407. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4408. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HDR_METADATA_MASK_n,
  4409. clnt_hdl, metadata_mask);
  4410. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4411. return 0;
  4412. }
  4413. /**
  4414. * ipa3_cfg_ep_hdr() - IPA end-point header configuration
  4415. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4416. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4417. *
  4418. * Returns: 0 on success, negative on failure
  4419. *
  4420. * Note: Should not be called from atomic context
  4421. */
  4422. int ipa3_cfg_ep_hdr(u32 clnt_hdl, const struct ipa_ep_cfg_hdr *ep_hdr)
  4423. {
  4424. struct ipa3_ep_context *ep;
  4425. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4426. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_hdr == NULL) {
  4427. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4428. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4429. return -EINVAL;
  4430. }
  4431. IPADBG("pipe=%d metadata_reg_valid=%d\n",
  4432. clnt_hdl,
  4433. ep_hdr->hdr_metadata_reg_valid);
  4434. IPADBG("remove_additional=%d, a5_mux=%d, ofst_pkt_size=0x%x\n",
  4435. ep_hdr->hdr_remove_additional,
  4436. ep_hdr->hdr_a5_mux,
  4437. ep_hdr->hdr_ofst_pkt_size);
  4438. IPADBG("ofst_pkt_size_valid=%d, additional_const_len=0x%x\n",
  4439. ep_hdr->hdr_ofst_pkt_size_valid,
  4440. ep_hdr->hdr_additional_const_len);
  4441. IPADBG("ofst_metadata=0x%x, ofst_metadata_valid=%d, len=0x%x\n",
  4442. ep_hdr->hdr_ofst_metadata,
  4443. ep_hdr->hdr_ofst_metadata_valid,
  4444. ep_hdr->hdr_len);
  4445. ep = &ipa3_ctx->ep[clnt_hdl];
  4446. /* copy over EP cfg */
  4447. ep->cfg.hdr = *ep_hdr;
  4448. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4449. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HDR_n, clnt_hdl, &ep->cfg.hdr);
  4450. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4451. return 0;
  4452. }
  4453. /**
  4454. * ipa3_cfg_ep_hdr_ext() - IPA end-point extended header configuration
  4455. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4456. * @ep_hdr_ext: [in] IPA end-point configuration params
  4457. *
  4458. * Returns: 0 on success, negative on failure
  4459. *
  4460. * Note: Should not be called from atomic context
  4461. */
  4462. int ipa3_cfg_ep_hdr_ext(u32 clnt_hdl,
  4463. const struct ipa_ep_cfg_hdr_ext *ep_hdr_ext)
  4464. {
  4465. struct ipa3_ep_context *ep;
  4466. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4467. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_hdr_ext == NULL) {
  4468. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4469. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4470. return -EINVAL;
  4471. }
  4472. IPADBG("pipe=%d hdr_pad_to_alignment=%d\n",
  4473. clnt_hdl,
  4474. ep_hdr_ext->hdr_pad_to_alignment);
  4475. IPADBG("hdr_total_len_or_pad_offset=%d\n",
  4476. ep_hdr_ext->hdr_total_len_or_pad_offset);
  4477. IPADBG("hdr_payload_len_inc_padding=%d hdr_total_len_or_pad=%d\n",
  4478. ep_hdr_ext->hdr_payload_len_inc_padding,
  4479. ep_hdr_ext->hdr_total_len_or_pad);
  4480. IPADBG("hdr_total_len_or_pad_valid=%d hdr_little_endian=%d\n",
  4481. ep_hdr_ext->hdr_total_len_or_pad_valid,
  4482. ep_hdr_ext->hdr_little_endian);
  4483. ep = &ipa3_ctx->ep[clnt_hdl];
  4484. /* copy over EP cfg */
  4485. ep->cfg.hdr_ext = *ep_hdr_ext;
  4486. ep->cfg.hdr_ext.hdr = &ep->cfg.hdr;
  4487. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4488. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HDR_EXT_n, clnt_hdl,
  4489. &ep->cfg.hdr_ext);
  4490. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4491. return 0;
  4492. }
  4493. /**
  4494. * ipa3_cfg_ep_ctrl() - IPA end-point Control configuration
  4495. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4496. * @ipa_ep_cfg_ctrl: [in] IPA end-point configuration params
  4497. *
  4498. * Returns: 0 on success, negative on failure
  4499. */
  4500. int ipa3_cfg_ep_ctrl(u32 clnt_hdl, const struct ipa_ep_cfg_ctrl *ep_ctrl)
  4501. {
  4502. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes || ep_ctrl == NULL) {
  4503. IPAERR("bad parm, clnt_hdl = %d\n", clnt_hdl);
  4504. return -EINVAL;
  4505. }
  4506. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0 && ep_ctrl->ipa_ep_suspend) {
  4507. IPAERR("pipe suspend is not supported\n");
  4508. WARN_ON(1);
  4509. return -EPERM;
  4510. }
  4511. if (ipa3_ctx->ipa_endp_delay_wa) {
  4512. IPAERR("pipe setting delay is not supported\n");
  4513. return 0;
  4514. }
  4515. IPADBG("pipe=%d ep_suspend=%d, ep_delay=%d\n",
  4516. clnt_hdl,
  4517. ep_ctrl->ipa_ep_suspend,
  4518. ep_ctrl->ipa_ep_delay);
  4519. ipahal_write_reg_n_fields(IPA_ENDP_INIT_CTRL_n, clnt_hdl, ep_ctrl);
  4520. if (ep_ctrl->ipa_ep_suspend == true &&
  4521. IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client))
  4522. ipa3_suspend_active_aggr_wa(clnt_hdl);
  4523. return 0;
  4524. }
  4525. const char *ipa3_get_mode_type_str(enum ipa_mode_type mode)
  4526. {
  4527. switch (mode) {
  4528. case (IPA_BASIC):
  4529. return "Basic";
  4530. case (IPA_ENABLE_FRAMING_HDLC):
  4531. return "HDLC framing";
  4532. case (IPA_ENABLE_DEFRAMING_HDLC):
  4533. return "HDLC de-framing";
  4534. case (IPA_DMA):
  4535. return "DMA";
  4536. }
  4537. return "undefined";
  4538. }
  4539. /**
  4540. * ipa3_cfg_ep_mode() - IPA end-point mode configuration
  4541. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4542. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4543. *
  4544. * Returns: 0 on success, negative on failure
  4545. *
  4546. * Note: Should not be called from atomic context
  4547. */
  4548. int ipa3_cfg_ep_mode(u32 clnt_hdl, const struct ipa_ep_cfg_mode *ep_mode)
  4549. {
  4550. int ep;
  4551. int type;
  4552. struct ipahal_reg_endp_init_mode init_mode;
  4553. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4554. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_mode == NULL) {
  4555. IPAERR("bad params clnt_hdl=%d , ep_valid=%d ep_mode=%pK\n",
  4556. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid,
  4557. ep_mode);
  4558. return -EINVAL;
  4559. }
  4560. if (IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client)) {
  4561. IPAERR("MODE does not apply to IPA out EP %d\n", clnt_hdl);
  4562. return -EINVAL;
  4563. }
  4564. ep = ipa3_get_ep_mapping(ep_mode->dst);
  4565. if (ep == -1 && ep_mode->mode == IPA_DMA) {
  4566. IPAERR("dst %d does not exist in DMA mode\n", ep_mode->dst);
  4567. return -EINVAL;
  4568. }
  4569. WARN_ON(ep_mode->mode == IPA_DMA && IPA_CLIENT_IS_PROD(ep_mode->dst));
  4570. if (!IPA_CLIENT_IS_CONS(ep_mode->dst))
  4571. ep = ipa3_get_ep_mapping(IPA_CLIENT_APPS_LAN_CONS);
  4572. IPADBG("pipe=%d mode=%d(%s), dst_client_number=%d\n",
  4573. clnt_hdl,
  4574. ep_mode->mode,
  4575. ipa3_get_mode_type_str(ep_mode->mode),
  4576. ep_mode->dst);
  4577. /* copy over EP cfg */
  4578. ipa3_ctx->ep[clnt_hdl].cfg.mode = *ep_mode;
  4579. ipa3_ctx->ep[clnt_hdl].dst_pipe_index = ep;
  4580. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4581. init_mode.dst_pipe_number = ipa3_ctx->ep[clnt_hdl].dst_pipe_index;
  4582. init_mode.ep_mode = *ep_mode;
  4583. ipahal_write_reg_n_fields(IPA_ENDP_INIT_MODE_n, clnt_hdl, &init_mode);
  4584. /* Configure sequencers type for test clients*/
  4585. if (IPA_CLIENT_IS_TEST(ipa3_ctx->ep[clnt_hdl].client)) {
  4586. if (ep_mode->mode == IPA_DMA)
  4587. type = IPA_DPS_HPS_SEQ_TYPE_DMA_ONLY;
  4588. else
  4589. /* In IPA4.2 only single pass only supported*/
  4590. if (ipa3_ctx->ipa_hw_type == IPA_HW_v4_2)
  4591. type =
  4592. IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_NO_UCP;
  4593. else
  4594. type =
  4595. IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP;
  4596. IPADBG(" set sequencers to sequance 0x%x, ep = %d\n", type,
  4597. clnt_hdl);
  4598. ipahal_write_reg_n(IPA_ENDP_INIT_SEQ_n, clnt_hdl, type);
  4599. }
  4600. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4601. return 0;
  4602. }
  4603. const char *ipa3_get_aggr_enable_str(enum ipa_aggr_en_type aggr_en)
  4604. {
  4605. switch (aggr_en) {
  4606. case (IPA_BYPASS_AGGR):
  4607. return "no aggregation";
  4608. case (IPA_ENABLE_AGGR):
  4609. return "aggregation enabled";
  4610. case (IPA_ENABLE_DEAGGR):
  4611. return "de-aggregation enabled";
  4612. }
  4613. return "undefined";
  4614. }
  4615. const char *ipa3_get_aggr_type_str(enum ipa_aggr_type aggr_type)
  4616. {
  4617. switch (aggr_type) {
  4618. case (IPA_MBIM_16):
  4619. return "MBIM_16";
  4620. case (IPA_HDLC):
  4621. return "HDLC";
  4622. case (IPA_TLP):
  4623. return "TLP";
  4624. case (IPA_RNDIS):
  4625. return "RNDIS";
  4626. case (IPA_GENERIC):
  4627. return "GENERIC";
  4628. case (IPA_QCMAP):
  4629. return "QCMAP";
  4630. case (IPA_COALESCE):
  4631. return "COALESCE";
  4632. }
  4633. return "undefined";
  4634. }
  4635. static u32 ipa3_time_gran_usec_step(enum ipa_timers_time_gran_type gran)
  4636. {
  4637. switch (gran) {
  4638. case IPA_TIMERS_TIME_GRAN_10_USEC: return 10;
  4639. case IPA_TIMERS_TIME_GRAN_20_USEC: return 20;
  4640. case IPA_TIMERS_TIME_GRAN_50_USEC: return 50;
  4641. case IPA_TIMERS_TIME_GRAN_100_USEC: return 100;
  4642. case IPA_TIMERS_TIME_GRAN_1_MSEC: return 1000;
  4643. case IPA_TIMERS_TIME_GRAN_10_MSEC: return 10000;
  4644. case IPA_TIMERS_TIME_GRAN_100_MSEC: return 100000;
  4645. case IPA_TIMERS_TIME_GRAN_NEAR_HALF_SEC: return 655350;
  4646. default:
  4647. IPAERR("Invalid granularity time unit %d\n", gran);
  4648. ipa_assert();
  4649. break;
  4650. }
  4651. return 100;
  4652. }
  4653. /*
  4654. * ipa3_process_timer_cfg() - Check and produce timer config
  4655. *
  4656. * Relevant for IPA 4.5 and above
  4657. *
  4658. * Assumes clocks are voted
  4659. */
  4660. static int ipa3_process_timer_cfg(u32 time_us,
  4661. u8 *pulse_gen, u8 *time_units)
  4662. {
  4663. struct ipahal_reg_timers_pulse_gran_cfg gran_cfg;
  4664. u32 gran0_step, gran1_step;
  4665. IPADBG("time in usec=%u\n", time_us);
  4666. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  4667. IPAERR("Invalid IPA version %d\n", ipa3_ctx->ipa_hw_type);
  4668. return -EPERM;
  4669. }
  4670. if (!time_us) {
  4671. *pulse_gen = 0;
  4672. *time_units = 0;
  4673. return 0;
  4674. }
  4675. ipahal_read_reg_fields(IPA_TIMERS_PULSE_GRAN_CFG, &gran_cfg);
  4676. gran0_step = ipa3_time_gran_usec_step(gran_cfg.gran_0);
  4677. gran1_step = ipa3_time_gran_usec_step(gran_cfg.gran_1);
  4678. /* gran_2 is not used by AP */
  4679. IPADBG("gran0 usec step=%u gran1 usec step=%u\n",
  4680. gran0_step, gran1_step);
  4681. /* Lets try pulse generator #0 granularity */
  4682. if (!(time_us % gran0_step)) {
  4683. if ((time_us / gran0_step) <= IPA_TIMER_SCALED_TIME_LIMIT) {
  4684. *pulse_gen = 0;
  4685. *time_units = time_us / gran0_step;
  4686. IPADBG("Matched: generator=0, units=%u\n",
  4687. *time_units);
  4688. return 0;
  4689. }
  4690. IPADBG("gran0 cannot be used due to range limit\n");
  4691. }
  4692. /* Lets try pulse generator #1 granularity */
  4693. if (!(time_us % gran1_step)) {
  4694. if ((time_us / gran1_step) <= IPA_TIMER_SCALED_TIME_LIMIT) {
  4695. *pulse_gen = 1;
  4696. *time_units = time_us / gran1_step;
  4697. IPADBG("Matched: generator=1, units=%u\n",
  4698. *time_units);
  4699. return 0;
  4700. }
  4701. IPADBG("gran1 cannot be used due to range limit\n");
  4702. }
  4703. IPAERR("Cannot match requested time to configured granularities\n");
  4704. return -EPERM;
  4705. }
  4706. /**
  4707. * ipa3_cfg_ep_aggr() - IPA end-point aggregation configuration
  4708. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4709. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4710. *
  4711. * Returns: 0 on success, negative on failure
  4712. *
  4713. * Note: Should not be called from atomic context
  4714. */
  4715. int ipa3_cfg_ep_aggr(u32 clnt_hdl, const struct ipa_ep_cfg_aggr *ep_aggr)
  4716. {
  4717. int res = 0;
  4718. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4719. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_aggr == NULL) {
  4720. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4721. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4722. return -EINVAL;
  4723. }
  4724. if (ep_aggr->aggr_en == IPA_ENABLE_DEAGGR &&
  4725. !IPA_EP_SUPPORTS_DEAGGR(clnt_hdl)) {
  4726. IPAERR("pipe=%d cannot be configured to DEAGGR\n", clnt_hdl);
  4727. WARN_ON(1);
  4728. return -EINVAL;
  4729. }
  4730. IPADBG("pipe=%d en=%d(%s), type=%d(%s), byte_limit=%d, time_limit=%d\n",
  4731. clnt_hdl,
  4732. ep_aggr->aggr_en,
  4733. ipa3_get_aggr_enable_str(ep_aggr->aggr_en),
  4734. ep_aggr->aggr,
  4735. ipa3_get_aggr_type_str(ep_aggr->aggr),
  4736. ep_aggr->aggr_byte_limit,
  4737. ep_aggr->aggr_time_limit);
  4738. IPADBG("hard_byte_limit_en=%d aggr_sw_eof_active=%d\n",
  4739. ep_aggr->aggr_hard_byte_limit_en,
  4740. ep_aggr->aggr_sw_eof_active);
  4741. /* copy over EP cfg */
  4742. ipa3_ctx->ep[clnt_hdl].cfg.aggr = *ep_aggr;
  4743. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4744. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5) {
  4745. res = ipa3_process_timer_cfg(ep_aggr->aggr_time_limit,
  4746. &ipa3_ctx->ep[clnt_hdl].cfg.aggr.pulse_generator,
  4747. &ipa3_ctx->ep[clnt_hdl].cfg.aggr.scaled_time);
  4748. if (res) {
  4749. IPAERR("failed to process AGGR timer tmr=%u\n",
  4750. ep_aggr->aggr_time_limit);
  4751. ipa_assert();
  4752. res = -EINVAL;
  4753. goto complete;
  4754. }
  4755. /*
  4756. * HW bug on IPA4.5 where gran is used from pipe 0 instead of
  4757. * coal pipe. Add this check to make sure that RSC pipe will use
  4758. * gran 0 per the requested time needed; pipe 0 will use always
  4759. * gran 0 as gran 0 is the POR value of it and s/w never change
  4760. * it.
  4761. */
  4762. if (ipa3_ctx->ipa_hw_type == IPA_HW_v4_5 &&
  4763. ipa3_get_client_mapping(clnt_hdl) ==
  4764. IPA_CLIENT_APPS_WAN_COAL_CONS &&
  4765. ipa3_ctx->ep[clnt_hdl].cfg.aggr.pulse_generator != 0) {
  4766. IPAERR("coal pipe using GRAN_SEL = %d\n",
  4767. ipa3_ctx->ep[clnt_hdl].cfg.aggr.pulse_generator);
  4768. ipa_assert();
  4769. }
  4770. } else {
  4771. /*
  4772. * Global aggregation granularity is 0.5msec.
  4773. * So if H/W programmed with 1msec, it will be
  4774. * 0.5msec defacto.
  4775. * So finest granularity is 0.5msec
  4776. */
  4777. if (ep_aggr->aggr_time_limit % 500) {
  4778. IPAERR("given time limit %u is not in 0.5msec\n",
  4779. ep_aggr->aggr_time_limit);
  4780. WARN_ON(1);
  4781. res = -EINVAL;
  4782. goto complete;
  4783. }
  4784. /* Due to described above global granularity */
  4785. ipa3_ctx->ep[clnt_hdl].cfg.aggr.aggr_time_limit *= 2;
  4786. }
  4787. ipahal_write_reg_n_fields(IPA_ENDP_INIT_AGGR_n, clnt_hdl,
  4788. &ipa3_ctx->ep[clnt_hdl].cfg.aggr);
  4789. complete:
  4790. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4791. return res;
  4792. }
  4793. /**
  4794. * ipa3_cfg_ep_route() - IPA end-point routing configuration
  4795. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4796. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4797. *
  4798. * Returns: 0 on success, negative on failure
  4799. *
  4800. * Note: Should not be called from atomic context
  4801. */
  4802. int ipa3_cfg_ep_route(u32 clnt_hdl, const struct ipa_ep_cfg_route *ep_route)
  4803. {
  4804. struct ipahal_reg_endp_init_route init_rt;
  4805. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4806. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_route == NULL) {
  4807. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4808. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4809. return -EINVAL;
  4810. }
  4811. if (IPA_CLIENT_IS_CONS(ipa3_ctx->ep[clnt_hdl].client)) {
  4812. IPAERR("ROUTE does not apply to IPA out EP %d\n",
  4813. clnt_hdl);
  4814. return -EINVAL;
  4815. }
  4816. /*
  4817. * if DMA mode was configured previously for this EP, return with
  4818. * success
  4819. */
  4820. if (ipa3_ctx->ep[clnt_hdl].cfg.mode.mode == IPA_DMA) {
  4821. IPADBG("DMA enabled for ep %d, dst pipe is part of DMA\n",
  4822. clnt_hdl);
  4823. return 0;
  4824. }
  4825. if (ep_route->rt_tbl_hdl)
  4826. IPAERR("client specified non-zero RT TBL hdl - ignore it\n");
  4827. IPADBG("pipe=%d, rt_tbl_hdl=%d\n",
  4828. clnt_hdl,
  4829. ep_route->rt_tbl_hdl);
  4830. /* always use "default" routing table when programming EP ROUTE reg */
  4831. ipa3_ctx->ep[clnt_hdl].rt_tbl_idx =
  4832. IPA_MEM_PART(v4_apps_rt_index_lo);
  4833. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_0) {
  4834. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4835. init_rt.route_table_index = ipa3_ctx->ep[clnt_hdl].rt_tbl_idx;
  4836. ipahal_write_reg_n_fields(IPA_ENDP_INIT_ROUTE_n,
  4837. clnt_hdl, &init_rt);
  4838. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4839. }
  4840. return 0;
  4841. }
  4842. #define MAX_ALLOWED_BASE_VAL 0x1f
  4843. #define MAX_ALLOWED_SCALE_VAL 0x1f
  4844. /**
  4845. * ipa3_cal_ep_holb_scale_base_val - calculate base and scale value from tmr_val
  4846. *
  4847. * In IPA4.2 HW version need configure base and scale value in HOL timer reg
  4848. * @tmr_val: [in] timer value for HOL timer
  4849. * @ipa_ep_cfg: [out] Fill IPA end-point configuration base and scale value
  4850. * and return
  4851. */
  4852. void ipa3_cal_ep_holb_scale_base_val(u32 tmr_val,
  4853. struct ipa_ep_cfg_holb *ep_holb)
  4854. {
  4855. u32 base_val, scale, scale_val = 1, base = 2;
  4856. for (scale = 0; scale <= MAX_ALLOWED_SCALE_VAL; scale++) {
  4857. base_val = tmr_val/scale_val;
  4858. if (scale != 0)
  4859. scale_val *= base;
  4860. if (base_val <= MAX_ALLOWED_BASE_VAL)
  4861. break;
  4862. }
  4863. ep_holb->base_val = base_val;
  4864. ep_holb->scale = scale_val;
  4865. }
  4866. /**
  4867. * ipa3_cfg_ep_holb() - IPA end-point holb configuration
  4868. *
  4869. * If an IPA producer pipe is full, IPA HW by default will block
  4870. * indefinitely till space opens up. During this time no packets
  4871. * including those from unrelated pipes will be processed. Enabling
  4872. * HOLB means IPA HW will be allowed to drop packets as/when needed
  4873. * and indefinite blocking is avoided.
  4874. *
  4875. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4876. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4877. *
  4878. * Returns: 0 on success, negative on failure
  4879. */
  4880. int ipa3_cfg_ep_holb(u32 clnt_hdl, const struct ipa_ep_cfg_holb *ep_holb)
  4881. {
  4882. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4883. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_holb == NULL ||
  4884. ep_holb->tmr_val > ipa3_ctx->ctrl->max_holb_tmr_val ||
  4885. ep_holb->en > 1) {
  4886. IPAERR("bad parm.\n");
  4887. return -EINVAL;
  4888. }
  4889. if (IPA_CLIENT_IS_PROD(ipa3_ctx->ep[clnt_hdl].client)) {
  4890. IPAERR("HOLB does not apply to IPA in EP %d\n", clnt_hdl);
  4891. return -EINVAL;
  4892. }
  4893. ipa3_ctx->ep[clnt_hdl].holb = *ep_holb;
  4894. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4895. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HOL_BLOCK_EN_n, clnt_hdl,
  4896. ep_holb);
  4897. /* IPA4.5 issue requires HOLB_EN to be written twice */
  4898. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5)
  4899. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HOL_BLOCK_EN_n,
  4900. clnt_hdl, ep_holb);
  4901. /* Configure timer */
  4902. if (ipa3_ctx->ipa_hw_type == IPA_HW_v4_2) {
  4903. ipa3_cal_ep_holb_scale_base_val(ep_holb->tmr_val,
  4904. &ipa3_ctx->ep[clnt_hdl].holb);
  4905. goto success;
  4906. }
  4907. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5) {
  4908. int res;
  4909. res = ipa3_process_timer_cfg(ep_holb->tmr_val * 1000,
  4910. &ipa3_ctx->ep[clnt_hdl].holb.pulse_generator,
  4911. &ipa3_ctx->ep[clnt_hdl].holb.scaled_time);
  4912. if (res) {
  4913. IPAERR("failed to process HOLB timer tmr=%u\n",
  4914. ep_holb->tmr_val);
  4915. ipa_assert();
  4916. return res;
  4917. }
  4918. }
  4919. success:
  4920. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HOL_BLOCK_TIMER_n,
  4921. clnt_hdl, &ipa3_ctx->ep[clnt_hdl].holb);
  4922. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4923. IPADBG("cfg holb %u ep=%d tmr=%d\n", ep_holb->en, clnt_hdl,
  4924. ep_holb->tmr_val);
  4925. return 0;
  4926. }
  4927. /**
  4928. * ipa3_cfg_ep_holb_by_client() - IPA end-point holb configuration
  4929. *
  4930. * Wrapper function for ipa3_cfg_ep_holb() with client name instead of
  4931. * client handle. This function is used for clients that does not have
  4932. * client handle.
  4933. *
  4934. * @client: [in] client name
  4935. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4936. *
  4937. * Returns: 0 on success, negative on failure
  4938. */
  4939. int ipa3_cfg_ep_holb_by_client(enum ipa_client_type client,
  4940. const struct ipa_ep_cfg_holb *ep_holb)
  4941. {
  4942. return ipa3_cfg_ep_holb(ipa3_get_ep_mapping(client), ep_holb);
  4943. }
  4944. /**
  4945. * ipa3_cfg_ep_deaggr() - IPA end-point deaggregation configuration
  4946. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4947. * @ep_deaggr: [in] IPA end-point configuration params
  4948. *
  4949. * Returns: 0 on success, negative on failure
  4950. *
  4951. * Note: Should not be called from atomic context
  4952. */
  4953. int ipa3_cfg_ep_deaggr(u32 clnt_hdl,
  4954. const struct ipa_ep_cfg_deaggr *ep_deaggr)
  4955. {
  4956. struct ipa3_ep_context *ep;
  4957. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4958. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_deaggr == NULL) {
  4959. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4960. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4961. return -EINVAL;
  4962. }
  4963. IPADBG("pipe=%d deaggr_hdr_len=%d\n",
  4964. clnt_hdl,
  4965. ep_deaggr->deaggr_hdr_len);
  4966. IPADBG("packet_offset_valid=%d\n",
  4967. ep_deaggr->packet_offset_valid);
  4968. IPADBG("packet_offset_location=%d max_packet_len=%d\n",
  4969. ep_deaggr->packet_offset_location,
  4970. ep_deaggr->max_packet_len);
  4971. ep = &ipa3_ctx->ep[clnt_hdl];
  4972. /* copy over EP cfg */
  4973. ep->cfg.deaggr = *ep_deaggr;
  4974. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  4975. ipahal_write_reg_n_fields(IPA_ENDP_INIT_DEAGGR_n, clnt_hdl,
  4976. &ep->cfg.deaggr);
  4977. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  4978. return 0;
  4979. }
  4980. /**
  4981. * ipa3_cfg_ep_metadata() - IPA end-point metadata configuration
  4982. * @clnt_hdl: [in] opaque client handle assigned by IPA to client
  4983. * @ipa_ep_cfg: [in] IPA end-point configuration params
  4984. *
  4985. * Returns: 0 on success, negative on failure
  4986. *
  4987. * Note: Should not be called from atomic context
  4988. */
  4989. int ipa3_cfg_ep_metadata(u32 clnt_hdl, const struct ipa_ep_cfg_metadata *ep_md)
  4990. {
  4991. u32 qmap_id = 0;
  4992. struct ipa_ep_cfg_metadata ep_md_reg_wrt;
  4993. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  4994. ipa3_ctx->ep[clnt_hdl].valid == 0 || ep_md == NULL) {
  4995. IPAERR("bad parm, clnt_hdl = %d , ep_valid = %d\n",
  4996. clnt_hdl, ipa3_ctx->ep[clnt_hdl].valid);
  4997. return -EINVAL;
  4998. }
  4999. IPADBG("pipe=%d, mux id=%d\n", clnt_hdl, ep_md->qmap_id);
  5000. /* copy over EP cfg */
  5001. ipa3_ctx->ep[clnt_hdl].cfg.meta = *ep_md;
  5002. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  5003. ep_md_reg_wrt = *ep_md;
  5004. qmap_id = (ep_md->qmap_id <<
  5005. IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_SHFT) &
  5006. IPA_ENDP_INIT_HDR_METADATA_n_MUX_ID_BMASK;
  5007. /* mark tethering bit for remote modem */
  5008. if (ipa3_ctx->ipa_hw_type == IPA_HW_v4_1)
  5009. qmap_id |= IPA_QMAP_TETH_BIT;
  5010. ep_md_reg_wrt.qmap_id = qmap_id;
  5011. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HDR_METADATA_n, clnt_hdl,
  5012. &ep_md_reg_wrt);
  5013. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  5014. ipa3_ctx->ep[clnt_hdl].cfg.hdr.hdr_metadata_reg_valid = 1;
  5015. ipahal_write_reg_n_fields(IPA_ENDP_INIT_HDR_n, clnt_hdl,
  5016. &ipa3_ctx->ep[clnt_hdl].cfg.hdr);
  5017. }
  5018. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  5019. return 0;
  5020. }
  5021. int ipa3_write_qmap_id(struct ipa_ioc_write_qmapid *param_in)
  5022. {
  5023. struct ipa_ep_cfg_metadata meta;
  5024. struct ipa3_ep_context *ep;
  5025. int ipa_ep_idx;
  5026. int result = -EINVAL;
  5027. if (param_in->client >= IPA_CLIENT_MAX) {
  5028. IPAERR_RL("bad parm client:%d\n", param_in->client);
  5029. goto fail;
  5030. }
  5031. ipa_ep_idx = ipa3_get_ep_mapping(param_in->client);
  5032. if (ipa_ep_idx == -1) {
  5033. IPAERR_RL("Invalid client.\n");
  5034. goto fail;
  5035. }
  5036. ep = &ipa3_ctx->ep[ipa_ep_idx];
  5037. if (!ep->valid) {
  5038. IPAERR_RL("EP not allocated.\n");
  5039. goto fail;
  5040. }
  5041. meta.qmap_id = param_in->qmap_id;
  5042. if (param_in->client == IPA_CLIENT_USB_PROD ||
  5043. param_in->client == IPA_CLIENT_HSIC1_PROD ||
  5044. param_in->client == IPA_CLIENT_ODU_PROD ||
  5045. param_in->client == IPA_CLIENT_ETHERNET_PROD ||
  5046. param_in->client == IPA_CLIENT_WIGIG_PROD) {
  5047. result = ipa3_cfg_ep_metadata(ipa_ep_idx, &meta);
  5048. } else if (param_in->client == IPA_CLIENT_WLAN1_PROD ||
  5049. param_in->client == IPA_CLIENT_WLAN2_PROD) {
  5050. ipa3_ctx->ep[ipa_ep_idx].cfg.meta = meta;
  5051. if (param_in->client == IPA_CLIENT_WLAN2_PROD)
  5052. result = ipa3_write_qmapid_wdi3_gsi_pipe(
  5053. ipa_ep_idx, meta.qmap_id);
  5054. else
  5055. result = ipa3_write_qmapid_wdi_pipe(
  5056. ipa_ep_idx, meta.qmap_id);
  5057. if (result)
  5058. IPAERR_RL("qmap_id %d write failed on ep=%d\n",
  5059. meta.qmap_id, ipa_ep_idx);
  5060. result = 0;
  5061. }
  5062. fail:
  5063. return result;
  5064. }
  5065. /**
  5066. * ipa3_dump_buff_internal() - dumps buffer for debug purposes
  5067. * @base: buffer base address
  5068. * @phy_base: buffer physical base address
  5069. * @size: size of the buffer
  5070. */
  5071. void ipa3_dump_buff_internal(void *base, dma_addr_t phy_base, u32 size)
  5072. {
  5073. int i;
  5074. u32 *cur = (u32 *)base;
  5075. u8 *byt;
  5076. IPADBG("system phys addr=%pa len=%u\n", &phy_base, size);
  5077. for (i = 0; i < size / 4; i++) {
  5078. byt = (u8 *)(cur + i);
  5079. IPADBG("%2d %08x %02x %02x %02x %02x\n", i, *(cur + i),
  5080. byt[0], byt[1], byt[2], byt[3]);
  5081. }
  5082. IPADBG("END\n");
  5083. }
  5084. /**
  5085. * ipa3_set_aggr_mode() - Set the aggregation mode which is a global setting
  5086. * @mode: [in] the desired aggregation mode for e.g. straight MBIM, QCNCM,
  5087. * etc
  5088. *
  5089. * Returns: 0 on success
  5090. */
  5091. int ipa3_set_aggr_mode(enum ipa_aggr_mode mode)
  5092. {
  5093. struct ipahal_reg_qcncm qcncm;
  5094. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  5095. if (mode != IPA_MBIM_AGGR) {
  5096. IPAERR("Only MBIM mode is supported staring 4.0\n");
  5097. return -EPERM;
  5098. }
  5099. } else {
  5100. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  5101. ipahal_read_reg_fields(IPA_QCNCM, &qcncm);
  5102. qcncm.mode_en = mode;
  5103. ipahal_write_reg_fields(IPA_QCNCM, &qcncm);
  5104. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  5105. }
  5106. return 0;
  5107. }
  5108. /**
  5109. * ipa3_set_qcncm_ndp_sig() - Set the NDP signature used for QCNCM aggregation
  5110. * mode
  5111. * @sig: [in] the first 3 bytes of QCNCM NDP signature (expected to be
  5112. * "QND")
  5113. *
  5114. * Set the NDP signature used for QCNCM aggregation mode. The fourth byte
  5115. * (expected to be 'P') needs to be set using the header addition mechanism
  5116. *
  5117. * Returns: 0 on success, negative on failure
  5118. */
  5119. int ipa3_set_qcncm_ndp_sig(char sig[3])
  5120. {
  5121. struct ipahal_reg_qcncm qcncm;
  5122. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  5123. IPAERR("QCNCM mode is not supported staring 4.0\n");
  5124. return -EPERM;
  5125. }
  5126. if (sig == NULL) {
  5127. IPAERR("bad argument\n");
  5128. return -EINVAL;
  5129. }
  5130. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  5131. ipahal_read_reg_fields(IPA_QCNCM, &qcncm);
  5132. qcncm.mode_val = ((sig[0] << 16) | (sig[1] << 8) | sig[2]);
  5133. ipahal_write_reg_fields(IPA_QCNCM, &qcncm);
  5134. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  5135. return 0;
  5136. }
  5137. /**
  5138. * ipa3_set_single_ndp_per_mbim() - Enable/disable single NDP per MBIM frame
  5139. * configuration
  5140. * @enable: [in] true for single NDP/MBIM; false otherwise
  5141. *
  5142. * Returns: 0 on success
  5143. */
  5144. int ipa3_set_single_ndp_per_mbim(bool enable)
  5145. {
  5146. struct ipahal_reg_single_ndp_mode mode;
  5147. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  5148. IPAERR("QCNCM mode is not supported staring 4.0\n");
  5149. return -EPERM;
  5150. }
  5151. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  5152. ipahal_read_reg_fields(IPA_SINGLE_NDP_MODE, &mode);
  5153. mode.single_ndp_en = enable;
  5154. ipahal_write_reg_fields(IPA_SINGLE_NDP_MODE, &mode);
  5155. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  5156. return 0;
  5157. }
  5158. /**
  5159. * ipa3_straddle_boundary() - Checks whether a memory buffer straddles a
  5160. * boundary
  5161. * @start: start address of the memory buffer
  5162. * @end: end address of the memory buffer
  5163. * @boundary: boundary
  5164. *
  5165. * Return value:
  5166. * 1: if the interval [start, end] straddles boundary
  5167. * 0: otherwise
  5168. */
  5169. int ipa3_straddle_boundary(u32 start, u32 end, u32 boundary)
  5170. {
  5171. u32 next_start;
  5172. u32 prev_end;
  5173. IPADBG("start=%u end=%u boundary=%u\n", start, end, boundary);
  5174. next_start = (start + (boundary - 1)) & ~(boundary - 1);
  5175. prev_end = ((end + (boundary - 1)) & ~(boundary - 1)) - boundary;
  5176. while (next_start < prev_end)
  5177. next_start += boundary;
  5178. if (next_start == prev_end)
  5179. return 1;
  5180. else
  5181. return 0;
  5182. }
  5183. /**
  5184. * ipa3_init_mem_partition() - Assigns the static memory partition
  5185. * based on the IPA version
  5186. *
  5187. * Returns: 0 on success
  5188. */
  5189. int ipa3_init_mem_partition(enum ipa_hw_type type)
  5190. {
  5191. switch (type) {
  5192. case IPA_HW_v4_1:
  5193. ipa3_ctx->ctrl->mem_partition = &ipa_4_1_mem_part;
  5194. break;
  5195. case IPA_HW_v4_2:
  5196. ipa3_ctx->ctrl->mem_partition = &ipa_4_2_mem_part;
  5197. break;
  5198. case IPA_HW_v4_5:
  5199. ipa3_ctx->ctrl->mem_partition = &ipa_4_5_mem_part;
  5200. break;
  5201. case IPA_HW_v4_7:
  5202. ipa3_ctx->ctrl->mem_partition = &ipa_4_7_mem_part;
  5203. break;
  5204. case IPA_HW_None:
  5205. case IPA_HW_v1_0:
  5206. case IPA_HW_v1_1:
  5207. case IPA_HW_v2_0:
  5208. case IPA_HW_v2_1:
  5209. case IPA_HW_v2_5:
  5210. case IPA_HW_v2_6L:
  5211. case IPA_HW_v3_0:
  5212. case IPA_HW_v3_1:
  5213. case IPA_HW_v3_5:
  5214. case IPA_HW_v3_5_1:
  5215. case IPA_HW_v4_0:
  5216. IPAERR("unsupported version %d\n", type);
  5217. return -EPERM;
  5218. }
  5219. if (IPA_MEM_PART(uc_info_ofst) & 3) {
  5220. IPAERR("UC INFO OFST 0x%x is unaligned\n",
  5221. IPA_MEM_PART(uc_info_ofst));
  5222. return -ENODEV;
  5223. }
  5224. IPADBG("UC INFO OFST 0x%x SIZE 0x%x\n",
  5225. IPA_MEM_PART(uc_info_ofst), IPA_MEM_PART(uc_info_size));
  5226. IPADBG("RAM OFST 0x%x\n", IPA_MEM_PART(ofst_start));
  5227. if (IPA_MEM_PART(v4_flt_hash_ofst) & 7) {
  5228. IPAERR("V4 FLT HASHABLE OFST 0x%x is unaligned\n",
  5229. IPA_MEM_PART(v4_flt_hash_ofst));
  5230. return -ENODEV;
  5231. }
  5232. IPADBG("V4 FLT HASHABLE OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5233. IPA_MEM_PART(v4_flt_hash_ofst),
  5234. IPA_MEM_PART(v4_flt_hash_size),
  5235. IPA_MEM_PART(v4_flt_hash_size_ddr));
  5236. if (IPA_MEM_PART(v4_flt_nhash_ofst) & 7) {
  5237. IPAERR("V4 FLT NON-HASHABLE OFST 0x%x is unaligned\n",
  5238. IPA_MEM_PART(v4_flt_nhash_ofst));
  5239. return -ENODEV;
  5240. }
  5241. IPADBG("V4 FLT NON-HASHABLE OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5242. IPA_MEM_PART(v4_flt_nhash_ofst),
  5243. IPA_MEM_PART(v4_flt_nhash_size),
  5244. IPA_MEM_PART(v4_flt_nhash_size_ddr));
  5245. if (IPA_MEM_PART(v6_flt_hash_ofst) & 7) {
  5246. IPAERR("V6 FLT HASHABLE OFST 0x%x is unaligned\n",
  5247. IPA_MEM_PART(v6_flt_hash_ofst));
  5248. return -ENODEV;
  5249. }
  5250. IPADBG("V6 FLT HASHABLE OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5251. IPA_MEM_PART(v6_flt_hash_ofst), IPA_MEM_PART(v6_flt_hash_size),
  5252. IPA_MEM_PART(v6_flt_hash_size_ddr));
  5253. if (IPA_MEM_PART(v6_flt_nhash_ofst) & 7) {
  5254. IPAERR("V6 FLT NON-HASHABLE OFST 0x%x is unaligned\n",
  5255. IPA_MEM_PART(v6_flt_nhash_ofst));
  5256. return -ENODEV;
  5257. }
  5258. IPADBG("V6 FLT NON-HASHABLE OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5259. IPA_MEM_PART(v6_flt_nhash_ofst),
  5260. IPA_MEM_PART(v6_flt_nhash_size),
  5261. IPA_MEM_PART(v6_flt_nhash_size_ddr));
  5262. IPADBG("V4 RT NUM INDEX 0x%x\n", IPA_MEM_PART(v4_rt_num_index));
  5263. IPADBG("V4 RT MODEM INDEXES 0x%x - 0x%x\n",
  5264. IPA_MEM_PART(v4_modem_rt_index_lo),
  5265. IPA_MEM_PART(v4_modem_rt_index_hi));
  5266. IPADBG("V4 RT APPS INDEXES 0x%x - 0x%x\n",
  5267. IPA_MEM_PART(v4_apps_rt_index_lo),
  5268. IPA_MEM_PART(v4_apps_rt_index_hi));
  5269. if (IPA_MEM_PART(v4_rt_hash_ofst) & 7) {
  5270. IPAERR("V4 RT HASHABLE OFST 0x%x is unaligned\n",
  5271. IPA_MEM_PART(v4_rt_hash_ofst));
  5272. return -ENODEV;
  5273. }
  5274. IPADBG("V4 RT HASHABLE OFST 0x%x\n", IPA_MEM_PART(v4_rt_hash_ofst));
  5275. IPADBG("V4 RT HASHABLE SIZE 0x%x DDR SIZE 0x%x\n",
  5276. IPA_MEM_PART(v4_rt_hash_size),
  5277. IPA_MEM_PART(v4_rt_hash_size_ddr));
  5278. if (IPA_MEM_PART(v4_rt_nhash_ofst) & 7) {
  5279. IPAERR("V4 RT NON-HASHABLE OFST 0x%x is unaligned\n",
  5280. IPA_MEM_PART(v4_rt_nhash_ofst));
  5281. return -ENODEV;
  5282. }
  5283. IPADBG("V4 RT NON-HASHABLE OFST 0x%x\n",
  5284. IPA_MEM_PART(v4_rt_nhash_ofst));
  5285. IPADBG("V4 RT HASHABLE SIZE 0x%x DDR SIZE 0x%x\n",
  5286. IPA_MEM_PART(v4_rt_nhash_size),
  5287. IPA_MEM_PART(v4_rt_nhash_size_ddr));
  5288. IPADBG("V6 RT NUM INDEX 0x%x\n", IPA_MEM_PART(v6_rt_num_index));
  5289. IPADBG("V6 RT MODEM INDEXES 0x%x - 0x%x\n",
  5290. IPA_MEM_PART(v6_modem_rt_index_lo),
  5291. IPA_MEM_PART(v6_modem_rt_index_hi));
  5292. IPADBG("V6 RT APPS INDEXES 0x%x - 0x%x\n",
  5293. IPA_MEM_PART(v6_apps_rt_index_lo),
  5294. IPA_MEM_PART(v6_apps_rt_index_hi));
  5295. if (IPA_MEM_PART(v6_rt_hash_ofst) & 7) {
  5296. IPAERR("V6 RT HASHABLE OFST 0x%x is unaligned\n",
  5297. IPA_MEM_PART(v6_rt_hash_ofst));
  5298. return -ENODEV;
  5299. }
  5300. IPADBG("V6 RT HASHABLE OFST 0x%x\n", IPA_MEM_PART(v6_rt_hash_ofst));
  5301. IPADBG("V6 RT HASHABLE SIZE 0x%x DDR SIZE 0x%x\n",
  5302. IPA_MEM_PART(v6_rt_hash_size),
  5303. IPA_MEM_PART(v6_rt_hash_size_ddr));
  5304. if (IPA_MEM_PART(v6_rt_nhash_ofst) & 7) {
  5305. IPAERR("V6 RT NON-HASHABLE OFST 0x%x is unaligned\n",
  5306. IPA_MEM_PART(v6_rt_nhash_ofst));
  5307. return -ENODEV;
  5308. }
  5309. IPADBG("V6 RT NON-HASHABLE OFST 0x%x\n",
  5310. IPA_MEM_PART(v6_rt_nhash_ofst));
  5311. IPADBG("V6 RT NON-HASHABLE SIZE 0x%x DDR SIZE 0x%x\n",
  5312. IPA_MEM_PART(v6_rt_nhash_size),
  5313. IPA_MEM_PART(v6_rt_nhash_size_ddr));
  5314. if (IPA_MEM_PART(modem_hdr_ofst) & 7) {
  5315. IPAERR("MODEM HDR OFST 0x%x is unaligned\n",
  5316. IPA_MEM_PART(modem_hdr_ofst));
  5317. return -ENODEV;
  5318. }
  5319. IPADBG("MODEM HDR OFST 0x%x SIZE 0x%x\n",
  5320. IPA_MEM_PART(modem_hdr_ofst), IPA_MEM_PART(modem_hdr_size));
  5321. if (IPA_MEM_PART(apps_hdr_ofst) & 7) {
  5322. IPAERR("APPS HDR OFST 0x%x is unaligned\n",
  5323. IPA_MEM_PART(apps_hdr_ofst));
  5324. return -ENODEV;
  5325. }
  5326. IPADBG("APPS HDR OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5327. IPA_MEM_PART(apps_hdr_ofst), IPA_MEM_PART(apps_hdr_size),
  5328. IPA_MEM_PART(apps_hdr_size_ddr));
  5329. if (IPA_MEM_PART(modem_hdr_proc_ctx_ofst) & 7) {
  5330. IPAERR("MODEM HDR PROC CTX OFST 0x%x is unaligned\n",
  5331. IPA_MEM_PART(modem_hdr_proc_ctx_ofst));
  5332. return -ENODEV;
  5333. }
  5334. IPADBG("MODEM HDR PROC CTX OFST 0x%x SIZE 0x%x\n",
  5335. IPA_MEM_PART(modem_hdr_proc_ctx_ofst),
  5336. IPA_MEM_PART(modem_hdr_proc_ctx_size));
  5337. if (IPA_MEM_PART(apps_hdr_proc_ctx_ofst) & 7) {
  5338. IPAERR("APPS HDR PROC CTX OFST 0x%x is unaligned\n",
  5339. IPA_MEM_PART(apps_hdr_proc_ctx_ofst));
  5340. return -ENODEV;
  5341. }
  5342. IPADBG("APPS HDR PROC CTX OFST 0x%x SIZE 0x%x DDR SIZE 0x%x\n",
  5343. IPA_MEM_PART(apps_hdr_proc_ctx_ofst),
  5344. IPA_MEM_PART(apps_hdr_proc_ctx_size),
  5345. IPA_MEM_PART(apps_hdr_proc_ctx_size_ddr));
  5346. if (IPA_MEM_PART(pdn_config_ofst) & 7) {
  5347. IPAERR("PDN CONFIG OFST 0x%x is unaligned\n",
  5348. IPA_MEM_PART(pdn_config_ofst));
  5349. return -ENODEV;
  5350. }
  5351. /*
  5352. * Routing rules points to hdr_proc_ctx in 32byte offsets from base.
  5353. * Base is modem hdr_proc_ctx first address.
  5354. * AP driver install APPS hdr_proc_ctx starting at the beginning of
  5355. * apps hdr_proc_ctx part.
  5356. * So first apps hdr_proc_ctx offset at some routing
  5357. * rule will be modem_hdr_proc_ctx_size >> 5 (32B).
  5358. */
  5359. if (IPA_MEM_PART(modem_hdr_proc_ctx_size) & 31) {
  5360. IPAERR("MODEM HDR PROC CTX SIZE 0x%x is not 32B aligned\n",
  5361. IPA_MEM_PART(modem_hdr_proc_ctx_size));
  5362. return -ENODEV;
  5363. }
  5364. /*
  5365. * AP driver when installing routing rule, it calcs the hdr_proc_ctx
  5366. * offset by local offset (from base of apps part) +
  5367. * modem_hdr_proc_ctx_size. This is to get offset from modem part base.
  5368. * Thus apps part must be adjacent to modem part
  5369. */
  5370. if (IPA_MEM_PART(apps_hdr_proc_ctx_ofst) !=
  5371. IPA_MEM_PART(modem_hdr_proc_ctx_ofst) +
  5372. IPA_MEM_PART(modem_hdr_proc_ctx_size)) {
  5373. IPAERR("APPS HDR PROC CTX SIZE not adjacent to MODEM one!\n");
  5374. return -ENODEV;
  5375. }
  5376. IPADBG("NAT TBL OFST 0x%x SIZE 0x%x\n",
  5377. IPA_MEM_PART(nat_tbl_ofst),
  5378. IPA_MEM_PART(nat_tbl_size));
  5379. if (IPA_MEM_PART(nat_tbl_ofst) & 31) {
  5380. IPAERR("NAT TBL OFST 0x%x is unaligned\n",
  5381. IPA_MEM_PART(nat_tbl_ofst));
  5382. return -ENODEV;
  5383. }
  5384. IPADBG("NAT INDEX TBL OFST 0x%x SIZE 0x%x\n",
  5385. IPA_MEM_PART(nat_index_tbl_ofst),
  5386. IPA_MEM_PART(nat_index_tbl_size));
  5387. if (IPA_MEM_PART(nat_index_tbl_ofst) & 3) {
  5388. IPAERR("NAT INDEX TBL OFST 0x%x is unaligned\n",
  5389. IPA_MEM_PART(nat_index_tbl_ofst));
  5390. return -ENODEV;
  5391. }
  5392. IPADBG("NAT EXP TBL OFST 0x%x SIZE 0x%x\n",
  5393. IPA_MEM_PART(nat_exp_tbl_ofst),
  5394. IPA_MEM_PART(nat_exp_tbl_size));
  5395. if (IPA_MEM_PART(nat_exp_tbl_ofst) & 31) {
  5396. IPAERR("NAT EXP TBL OFST 0x%x is unaligned\n",
  5397. IPA_MEM_PART(nat_exp_tbl_ofst));
  5398. return -ENODEV;
  5399. }
  5400. IPADBG("PDN CONFIG OFST 0x%x SIZE 0x%x\n",
  5401. IPA_MEM_PART(pdn_config_ofst),
  5402. IPA_MEM_PART(pdn_config_size));
  5403. if (IPA_MEM_PART(pdn_config_ofst) & 7) {
  5404. IPAERR("PDN CONFIG OFST 0x%x is unaligned\n",
  5405. IPA_MEM_PART(pdn_config_ofst));
  5406. return -ENODEV;
  5407. }
  5408. IPADBG("QUOTA STATS OFST 0x%x SIZE 0x%x\n",
  5409. IPA_MEM_PART(stats_quota_ofst),
  5410. IPA_MEM_PART(stats_quota_size));
  5411. if (IPA_MEM_PART(stats_quota_ofst) & 7) {
  5412. IPAERR("QUOTA STATS OFST 0x%x is unaligned\n",
  5413. IPA_MEM_PART(stats_quota_ofst));
  5414. return -ENODEV;
  5415. }
  5416. IPADBG("TETHERING STATS OFST 0x%x SIZE 0x%x\n",
  5417. IPA_MEM_PART(stats_tethering_ofst),
  5418. IPA_MEM_PART(stats_tethering_size));
  5419. if (IPA_MEM_PART(stats_tethering_ofst) & 7) {
  5420. IPAERR("TETHERING STATS OFST 0x%x is unaligned\n",
  5421. IPA_MEM_PART(stats_tethering_ofst));
  5422. return -ENODEV;
  5423. }
  5424. IPADBG("FILTER AND ROUTING STATS OFST 0x%x SIZE 0x%x\n",
  5425. IPA_MEM_PART(stats_fnr_ofst),
  5426. IPA_MEM_PART(stats_fnr_size));
  5427. if (IPA_MEM_PART(stats_fnr_ofst) & 7) {
  5428. IPAERR("FILTER AND ROUTING STATS OFST 0x%x is unaligned\n",
  5429. IPA_MEM_PART(stats_fnr_ofst));
  5430. return -ENODEV;
  5431. }
  5432. IPADBG("DROP STATS OFST 0x%x SIZE 0x%x\n",
  5433. IPA_MEM_PART(stats_drop_ofst),
  5434. IPA_MEM_PART(stats_drop_size));
  5435. if (IPA_MEM_PART(stats_drop_ofst) & 7) {
  5436. IPAERR("DROP STATS OFST 0x%x is unaligned\n",
  5437. IPA_MEM_PART(stats_drop_ofst));
  5438. return -ENODEV;
  5439. }
  5440. IPADBG("V4 APPS HASHABLE FLT OFST 0x%x SIZE 0x%x\n",
  5441. IPA_MEM_PART(apps_v4_flt_hash_ofst),
  5442. IPA_MEM_PART(apps_v4_flt_hash_size));
  5443. IPADBG("V4 APPS NON-HASHABLE FLT OFST 0x%x SIZE 0x%x\n",
  5444. IPA_MEM_PART(apps_v4_flt_nhash_ofst),
  5445. IPA_MEM_PART(apps_v4_flt_nhash_size));
  5446. IPADBG("V6 APPS HASHABLE FLT OFST 0x%x SIZE 0x%x\n",
  5447. IPA_MEM_PART(apps_v6_flt_hash_ofst),
  5448. IPA_MEM_PART(apps_v6_flt_hash_size));
  5449. IPADBG("V6 APPS NON-HASHABLE FLT OFST 0x%x SIZE 0x%x\n",
  5450. IPA_MEM_PART(apps_v6_flt_nhash_ofst),
  5451. IPA_MEM_PART(apps_v6_flt_nhash_size));
  5452. IPADBG("RAM END OFST 0x%x\n",
  5453. IPA_MEM_PART(end_ofst));
  5454. IPADBG("V4 APPS HASHABLE RT OFST 0x%x SIZE 0x%x\n",
  5455. IPA_MEM_PART(apps_v4_rt_hash_ofst),
  5456. IPA_MEM_PART(apps_v4_rt_hash_size));
  5457. IPADBG("V4 APPS NON-HASHABLE RT OFST 0x%x SIZE 0x%x\n",
  5458. IPA_MEM_PART(apps_v4_rt_nhash_ofst),
  5459. IPA_MEM_PART(apps_v4_rt_nhash_size));
  5460. IPADBG("V6 APPS HASHABLE RT OFST 0x%x SIZE 0x%x\n",
  5461. IPA_MEM_PART(apps_v6_rt_hash_ofst),
  5462. IPA_MEM_PART(apps_v6_rt_hash_size));
  5463. IPADBG("V6 APPS NON-HASHABLE RT OFST 0x%x SIZE 0x%x\n",
  5464. IPA_MEM_PART(apps_v6_rt_nhash_ofst),
  5465. IPA_MEM_PART(apps_v6_rt_nhash_size));
  5466. if (IPA_MEM_PART(modem_ofst) & 7) {
  5467. IPAERR("MODEM OFST 0x%x is unaligned\n",
  5468. IPA_MEM_PART(modem_ofst));
  5469. return -ENODEV;
  5470. }
  5471. IPADBG("MODEM OFST 0x%x SIZE 0x%x\n", IPA_MEM_PART(modem_ofst),
  5472. IPA_MEM_PART(modem_size));
  5473. if (IPA_MEM_PART(uc_descriptor_ram_ofst) & 1023) {
  5474. IPAERR("UC DESCRIPTOR RAM OFST 0x%x is unaligned\n",
  5475. IPA_MEM_PART(uc_descriptor_ram_ofst));
  5476. return -ENODEV;
  5477. }
  5478. IPADBG("UC DESCRIPTOR RAM OFST 0x%x SIZE 0x%x\n",
  5479. IPA_MEM_PART(uc_descriptor_ram_ofst),
  5480. IPA_MEM_PART(uc_descriptor_ram_size));
  5481. return 0;
  5482. }
  5483. /**
  5484. * ipa_ctrl_static_bind() - set the appropriate methods for
  5485. * IPA Driver based on the HW version
  5486. *
  5487. * @ctrl: data structure which holds the function pointers
  5488. * @hw_type: the HW type in use
  5489. *
  5490. * This function can avoid the runtime assignment by using C99 special
  5491. * struct initialization - hard decision... time.vs.mem
  5492. */
  5493. int ipa3_controller_static_bind(struct ipa3_controller *ctrl,
  5494. enum ipa_hw_type hw_type)
  5495. {
  5496. if (hw_type >= IPA_HW_v4_0) {
  5497. ctrl->ipa_clk_rate_turbo = IPA_V4_0_CLK_RATE_TURBO;
  5498. ctrl->ipa_clk_rate_nominal = IPA_V4_0_CLK_RATE_NOMINAL;
  5499. ctrl->ipa_clk_rate_svs = IPA_V4_0_CLK_RATE_SVS;
  5500. ctrl->ipa_clk_rate_svs2 = IPA_V4_0_CLK_RATE_SVS2;
  5501. } else if (hw_type >= IPA_HW_v3_5) {
  5502. ctrl->ipa_clk_rate_turbo = IPA_V3_5_CLK_RATE_TURBO;
  5503. ctrl->ipa_clk_rate_nominal = IPA_V3_5_CLK_RATE_NOMINAL;
  5504. ctrl->ipa_clk_rate_svs = IPA_V3_5_CLK_RATE_SVS;
  5505. ctrl->ipa_clk_rate_svs2 = IPA_V3_5_CLK_RATE_SVS2;
  5506. } else {
  5507. ctrl->ipa_clk_rate_turbo = IPA_V3_0_CLK_RATE_TURBO;
  5508. ctrl->ipa_clk_rate_nominal = IPA_V3_0_CLK_RATE_NOMINAL;
  5509. ctrl->ipa_clk_rate_svs = IPA_V3_0_CLK_RATE_SVS;
  5510. ctrl->ipa_clk_rate_svs2 = IPA_V3_0_CLK_RATE_SVS2;
  5511. }
  5512. ctrl->ipa_init_rt4 = _ipa_init_rt4_v3;
  5513. ctrl->ipa_init_rt6 = _ipa_init_rt6_v3;
  5514. ctrl->ipa_init_flt4 = _ipa_init_flt4_v3;
  5515. ctrl->ipa_init_flt6 = _ipa_init_flt6_v3;
  5516. ctrl->ipa3_read_ep_reg = _ipa_read_ep_reg_v3_0;
  5517. ctrl->ipa3_commit_flt = __ipa_commit_flt_v3;
  5518. ctrl->ipa3_commit_rt = __ipa_commit_rt_v3;
  5519. ctrl->ipa3_commit_hdr = __ipa_commit_hdr_v3_0;
  5520. ctrl->ipa3_enable_clks = _ipa_enable_clks_v3_0;
  5521. ctrl->ipa3_disable_clks = _ipa_disable_clks_v3_0;
  5522. ctrl->clock_scaling_bw_threshold_svs =
  5523. IPA_V3_0_BW_THRESHOLD_SVS_MBPS;
  5524. ctrl->clock_scaling_bw_threshold_nominal =
  5525. IPA_V3_0_BW_THRESHOLD_NOMINAL_MBPS;
  5526. ctrl->clock_scaling_bw_threshold_turbo =
  5527. IPA_V3_0_BW_THRESHOLD_TURBO_MBPS;
  5528. ctrl->ipa_reg_base_ofst = ipahal_get_reg_base();
  5529. ctrl->ipa_init_sram = _ipa_init_sram_v3;
  5530. ctrl->ipa_sram_read_settings = _ipa_sram_settings_read_v3_0;
  5531. ctrl->ipa_init_hdr = _ipa_init_hdr_v3_0;
  5532. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0)
  5533. ctrl->ipa3_read_ep_reg = _ipa_read_ep_reg_v4_0;
  5534. return 0;
  5535. }
  5536. void ipa3_skb_recycle(struct sk_buff *skb)
  5537. {
  5538. struct skb_shared_info *shinfo;
  5539. shinfo = skb_shinfo(skb);
  5540. memset(shinfo, 0, offsetof(struct skb_shared_info, dataref));
  5541. atomic_set(&shinfo->dataref, 1);
  5542. memset(skb, 0, offsetof(struct sk_buff, tail));
  5543. skb->data = skb->head + NET_SKB_PAD;
  5544. skb_reset_tail_pointer(skb);
  5545. }
  5546. int ipa3_alloc_rule_id(struct idr *rule_ids)
  5547. {
  5548. /* There is two groups of rule-Ids, Modem ones and Apps ones.
  5549. * Distinction by high bit: Modem Ids are high bit asserted.
  5550. */
  5551. return idr_alloc(rule_ids, NULL,
  5552. ipahal_get_low_rule_id(),
  5553. ipahal_get_rule_id_hi_bit(),
  5554. GFP_KERNEL);
  5555. }
  5556. static int __ipa3_alloc_counter_hdl
  5557. (struct ipa_ioc_flt_rt_counter_alloc *counter)
  5558. {
  5559. int id;
  5560. /* assign a handle using idr to this counter block */
  5561. id = idr_alloc(&ipa3_ctx->flt_rt_counters.hdl, counter,
  5562. ipahal_get_low_hdl_id(), ipahal_get_high_hdl_id(),
  5563. GFP_ATOMIC);
  5564. return id;
  5565. }
  5566. int ipa3_alloc_counter_id(struct ipa_ioc_flt_rt_counter_alloc *counter)
  5567. {
  5568. int i, unused_cnt, unused_max, unused_start_id;
  5569. idr_preload(GFP_KERNEL);
  5570. spin_lock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5571. /* allocate hw counters */
  5572. counter->hw_counter.start_id = 0;
  5573. counter->hw_counter.end_id = 0;
  5574. unused_cnt = 0;
  5575. unused_max = 0;
  5576. unused_start_id = 0;
  5577. if (counter->hw_counter.num_counters == 0)
  5578. goto sw_counter_alloc;
  5579. /* find the start id which can be used for the block */
  5580. for (i = 0; i < IPA_FLT_RT_HW_COUNTER; i++) {
  5581. if (!ipa3_ctx->flt_rt_counters.used_hw[i])
  5582. unused_cnt++;
  5583. else {
  5584. /* tracking max unused block in case allow less */
  5585. if (unused_cnt > unused_max) {
  5586. unused_start_id = i - unused_cnt + 2;
  5587. unused_max = unused_cnt;
  5588. }
  5589. unused_cnt = 0;
  5590. }
  5591. /* find it, break and use this 1st possible block */
  5592. if (unused_cnt == counter->hw_counter.num_counters) {
  5593. counter->hw_counter.start_id = i - unused_cnt + 2;
  5594. counter->hw_counter.end_id = i + 1;
  5595. break;
  5596. }
  5597. }
  5598. if (counter->hw_counter.start_id == 0) {
  5599. /* if not able to find such a block but allow less */
  5600. if (counter->hw_counter.allow_less && unused_max) {
  5601. /* give the max possible unused blocks */
  5602. counter->hw_counter.num_counters = unused_max;
  5603. counter->hw_counter.start_id = unused_start_id;
  5604. counter->hw_counter.end_id =
  5605. unused_start_id + unused_max - 1;
  5606. } else {
  5607. /* not able to find such a block */
  5608. counter->hw_counter.num_counters = 0;
  5609. counter->hw_counter.start_id = 0;
  5610. counter->hw_counter.end_id = 0;
  5611. goto err;
  5612. }
  5613. }
  5614. sw_counter_alloc:
  5615. /* allocate sw counters */
  5616. counter->sw_counter.start_id = 0;
  5617. counter->sw_counter.end_id = 0;
  5618. unused_cnt = 0;
  5619. unused_max = 0;
  5620. unused_start_id = 0;
  5621. if (counter->sw_counter.num_counters == 0)
  5622. goto mark_hw_cnt;
  5623. /* find the start id which can be used for the block */
  5624. for (i = 0; i < IPA_FLT_RT_SW_COUNTER; i++) {
  5625. if (!ipa3_ctx->flt_rt_counters.used_sw[i])
  5626. unused_cnt++;
  5627. else {
  5628. /* tracking max unused block in case allow less */
  5629. if (unused_cnt > unused_max) {
  5630. unused_start_id = i - unused_cnt +
  5631. 2 + IPA_FLT_RT_HW_COUNTER;
  5632. unused_max = unused_cnt;
  5633. }
  5634. unused_cnt = 0;
  5635. }
  5636. /* find it, break and use this 1st possible block */
  5637. if (unused_cnt == counter->sw_counter.num_counters) {
  5638. counter->sw_counter.start_id = i - unused_cnt +
  5639. 2 + IPA_FLT_RT_HW_COUNTER;
  5640. counter->sw_counter.end_id =
  5641. i + 1 + IPA_FLT_RT_HW_COUNTER;
  5642. break;
  5643. }
  5644. }
  5645. if (counter->sw_counter.start_id == 0) {
  5646. /* if not able to find such a block but allow less */
  5647. if (counter->sw_counter.allow_less && unused_max) {
  5648. /* give the max possible unused blocks */
  5649. counter->sw_counter.num_counters = unused_max;
  5650. counter->sw_counter.start_id = unused_start_id;
  5651. counter->sw_counter.end_id =
  5652. unused_start_id + unused_max - 1;
  5653. } else {
  5654. /* not able to find such a block */
  5655. counter->sw_counter.num_counters = 0;
  5656. counter->sw_counter.start_id = 0;
  5657. counter->sw_counter.end_id = 0;
  5658. goto err;
  5659. }
  5660. }
  5661. mark_hw_cnt:
  5662. /* add hw counters, set used to 1 */
  5663. if (counter->hw_counter.num_counters == 0)
  5664. goto mark_sw_cnt;
  5665. unused_start_id = counter->hw_counter.start_id;
  5666. if (unused_start_id < 1 ||
  5667. unused_start_id > IPA_FLT_RT_HW_COUNTER) {
  5668. IPAERR("unexpected hw_counter start id %d\n",
  5669. unused_start_id);
  5670. goto err;
  5671. }
  5672. for (i = 0; i < counter->hw_counter.num_counters; i++)
  5673. ipa3_ctx->flt_rt_counters.used_hw[unused_start_id + i - 1]
  5674. = true;
  5675. mark_sw_cnt:
  5676. /* add sw counters, set used to 1 */
  5677. if (counter->sw_counter.num_counters == 0)
  5678. goto done;
  5679. unused_start_id = counter->sw_counter.start_id
  5680. - IPA_FLT_RT_HW_COUNTER;
  5681. if (unused_start_id < 1 ||
  5682. unused_start_id > IPA_FLT_RT_SW_COUNTER) {
  5683. IPAERR("unexpected sw_counter start id %d\n",
  5684. unused_start_id);
  5685. goto err;
  5686. }
  5687. for (i = 0; i < counter->sw_counter.num_counters; i++)
  5688. ipa3_ctx->flt_rt_counters.used_sw[unused_start_id + i - 1]
  5689. = true;
  5690. done:
  5691. /* get a handle from idr for dealloc */
  5692. counter->hdl = __ipa3_alloc_counter_hdl(counter);
  5693. spin_unlock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5694. idr_preload_end();
  5695. return 0;
  5696. err:
  5697. counter->hdl = -1;
  5698. spin_unlock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5699. idr_preload_end();
  5700. return -ENOMEM;
  5701. }
  5702. void ipa3_counter_remove_hdl(int hdl)
  5703. {
  5704. struct ipa_ioc_flt_rt_counter_alloc *counter;
  5705. int offset = 0;
  5706. spin_lock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5707. counter = idr_find(&ipa3_ctx->flt_rt_counters.hdl, hdl);
  5708. if (counter == NULL) {
  5709. IPAERR("unexpected hdl %d\n", hdl);
  5710. goto err;
  5711. }
  5712. /* remove counters belong to this hdl, set used back to 0 */
  5713. offset = counter->hw_counter.start_id - 1;
  5714. if (offset >= 0 && offset + counter->hw_counter.num_counters
  5715. < IPA_FLT_RT_HW_COUNTER) {
  5716. memset(&ipa3_ctx->flt_rt_counters.used_hw + offset,
  5717. 0, counter->hw_counter.num_counters * sizeof(bool));
  5718. } else {
  5719. IPAERR("unexpected hdl %d\n", hdl);
  5720. goto err;
  5721. }
  5722. offset = counter->sw_counter.start_id - 1 - IPA_FLT_RT_HW_COUNTER;
  5723. if (offset >= 0 && offset + counter->sw_counter.num_counters
  5724. < IPA_FLT_RT_SW_COUNTER) {
  5725. memset(&ipa3_ctx->flt_rt_counters.used_sw + offset,
  5726. 0, counter->sw_counter.num_counters * sizeof(bool));
  5727. } else {
  5728. IPAERR("unexpected hdl %d\n", hdl);
  5729. goto err;
  5730. }
  5731. /* remove the handle */
  5732. idr_remove(&ipa3_ctx->flt_rt_counters.hdl, hdl);
  5733. err:
  5734. spin_unlock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5735. }
  5736. void ipa3_counter_id_remove_all(void)
  5737. {
  5738. struct ipa_ioc_flt_rt_counter_alloc *counter;
  5739. int hdl;
  5740. spin_lock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5741. /* remove all counters, set used back to 0 */
  5742. memset(&ipa3_ctx->flt_rt_counters.used_hw, 0,
  5743. sizeof(ipa3_ctx->flt_rt_counters.used_hw));
  5744. memset(&ipa3_ctx->flt_rt_counters.used_sw, 0,
  5745. sizeof(ipa3_ctx->flt_rt_counters.used_sw));
  5746. /* remove all handles */
  5747. idr_for_each_entry(&ipa3_ctx->flt_rt_counters.hdl, counter, hdl)
  5748. idr_remove(&ipa3_ctx->flt_rt_counters.hdl, hdl);
  5749. spin_unlock(&ipa3_ctx->flt_rt_counters.hdl_lock);
  5750. }
  5751. int ipa3_id_alloc(void *ptr)
  5752. {
  5753. int id;
  5754. idr_preload(GFP_KERNEL);
  5755. spin_lock(&ipa3_ctx->idr_lock);
  5756. id = idr_alloc(&ipa3_ctx->ipa_idr, ptr, 0, 0, GFP_NOWAIT);
  5757. spin_unlock(&ipa3_ctx->idr_lock);
  5758. idr_preload_end();
  5759. return id;
  5760. }
  5761. void *ipa3_id_find(u32 id)
  5762. {
  5763. void *ptr;
  5764. spin_lock(&ipa3_ctx->idr_lock);
  5765. ptr = idr_find(&ipa3_ctx->ipa_idr, id);
  5766. spin_unlock(&ipa3_ctx->idr_lock);
  5767. return ptr;
  5768. }
  5769. void ipa3_id_remove(u32 id)
  5770. {
  5771. spin_lock(&ipa3_ctx->idr_lock);
  5772. idr_remove(&ipa3_ctx->ipa_idr, id);
  5773. spin_unlock(&ipa3_ctx->idr_lock);
  5774. }
  5775. void ipa3_tag_destroy_imm(void *user1, int user2)
  5776. {
  5777. ipahal_destroy_imm_cmd(user1);
  5778. }
  5779. static void ipa3_tag_free_skb(void *user1, int user2)
  5780. {
  5781. dev_kfree_skb_any((struct sk_buff *)user1);
  5782. }
  5783. #define REQUIRED_TAG_PROCESS_DESCRIPTORS 4
  5784. #define MAX_RETRY_ALLOC 10
  5785. #define ALLOC_MIN_SLEEP_RX 100000
  5786. #define ALLOC_MAX_SLEEP_RX 200000
  5787. /* ipa3_tag_process() - Initiates a tag process. Incorporates the input
  5788. * descriptors
  5789. *
  5790. * @desc: descriptors with commands for IC
  5791. * @desc_size: amount of descriptors in the above variable
  5792. *
  5793. * Note: The descriptors are copied (if there's room), the client needs to
  5794. * free his descriptors afterwards
  5795. *
  5796. * Return: 0 or negative in case of failure
  5797. */
  5798. int ipa3_tag_process(struct ipa3_desc desc[],
  5799. int descs_num,
  5800. unsigned long timeout)
  5801. {
  5802. struct ipa3_sys_context *sys;
  5803. struct ipa3_desc *tag_desc;
  5804. int desc_idx = 0;
  5805. struct ipahal_imm_cmd_ip_packet_init pktinit_cmd;
  5806. struct ipahal_imm_cmd_pyld *cmd_pyld = NULL;
  5807. struct ipahal_imm_cmd_ip_packet_tag_status status;
  5808. int i;
  5809. struct sk_buff *dummy_skb;
  5810. int res;
  5811. struct ipa3_tag_completion *comp;
  5812. int ep_idx;
  5813. u32 retry_cnt = 0;
  5814. /* Not enough room for the required descriptors for the tag process */
  5815. if (IPA_TAG_MAX_DESC - descs_num < REQUIRED_TAG_PROCESS_DESCRIPTORS) {
  5816. IPAERR("up to %d descriptors are allowed (received %d)\n",
  5817. IPA_TAG_MAX_DESC - REQUIRED_TAG_PROCESS_DESCRIPTORS,
  5818. descs_num);
  5819. return -ENOMEM;
  5820. }
  5821. ep_idx = ipa3_get_ep_mapping(IPA_CLIENT_APPS_CMD_PROD);
  5822. if (-1 == ep_idx) {
  5823. IPAERR("Client %u is not mapped\n",
  5824. IPA_CLIENT_APPS_CMD_PROD);
  5825. return -EFAULT;
  5826. }
  5827. sys = ipa3_ctx->ep[ep_idx].sys;
  5828. tag_desc = kzalloc(sizeof(*tag_desc) * IPA_TAG_MAX_DESC, GFP_KERNEL);
  5829. if (!tag_desc) {
  5830. IPAERR("failed to allocate memory\n");
  5831. return -ENOMEM;
  5832. }
  5833. /* Copy the required descriptors from the client now */
  5834. if (desc) {
  5835. memcpy(&(tag_desc[0]), desc, descs_num *
  5836. sizeof(tag_desc[0]));
  5837. desc_idx += descs_num;
  5838. }
  5839. /* NO-OP IC for ensuring that IPA pipeline is empty */
  5840. cmd_pyld = ipahal_construct_nop_imm_cmd(
  5841. false, IPAHAL_FULL_PIPELINE_CLEAR, false);
  5842. if (!cmd_pyld) {
  5843. IPAERR("failed to construct NOP imm cmd\n");
  5844. res = -ENOMEM;
  5845. goto fail_free_tag_desc;
  5846. }
  5847. ipa3_init_imm_cmd_desc(&tag_desc[desc_idx], cmd_pyld);
  5848. tag_desc[desc_idx].callback = ipa3_tag_destroy_imm;
  5849. tag_desc[desc_idx].user1 = cmd_pyld;
  5850. ++desc_idx;
  5851. /* IP_PACKET_INIT IC for tag status to be sent to apps */
  5852. pktinit_cmd.destination_pipe_index =
  5853. ipa3_get_ep_mapping(IPA_CLIENT_APPS_LAN_CONS);
  5854. cmd_pyld = ipahal_construct_imm_cmd(
  5855. IPA_IMM_CMD_IP_PACKET_INIT, &pktinit_cmd, false);
  5856. if (!cmd_pyld) {
  5857. IPAERR("failed to construct ip_packet_init imm cmd\n");
  5858. res = -ENOMEM;
  5859. goto fail_free_desc;
  5860. }
  5861. ipa3_init_imm_cmd_desc(&tag_desc[desc_idx], cmd_pyld);
  5862. tag_desc[desc_idx].callback = ipa3_tag_destroy_imm;
  5863. tag_desc[desc_idx].user1 = cmd_pyld;
  5864. ++desc_idx;
  5865. /* status IC */
  5866. status.tag = IPA_COOKIE;
  5867. cmd_pyld = ipahal_construct_imm_cmd(
  5868. IPA_IMM_CMD_IP_PACKET_TAG_STATUS, &status, false);
  5869. if (!cmd_pyld) {
  5870. IPAERR("failed to construct ip_packet_tag_status imm cmd\n");
  5871. res = -ENOMEM;
  5872. goto fail_free_desc;
  5873. }
  5874. ipa3_init_imm_cmd_desc(&tag_desc[desc_idx], cmd_pyld);
  5875. tag_desc[desc_idx].callback = ipa3_tag_destroy_imm;
  5876. tag_desc[desc_idx].user1 = cmd_pyld;
  5877. ++desc_idx;
  5878. comp = kzalloc(sizeof(*comp), GFP_KERNEL);
  5879. if (!comp) {
  5880. IPAERR("no mem\n");
  5881. res = -ENOMEM;
  5882. goto fail_free_desc;
  5883. }
  5884. init_completion(&comp->comp);
  5885. /* completion needs to be released from both here and rx handler */
  5886. atomic_set(&comp->cnt, 2);
  5887. /* dummy packet to send to IPA. packet payload is a completion object */
  5888. dummy_skb = alloc_skb(sizeof(comp), GFP_KERNEL);
  5889. if (!dummy_skb) {
  5890. IPAERR("failed to allocate memory\n");
  5891. res = -ENOMEM;
  5892. goto fail_free_comp;
  5893. }
  5894. memcpy(skb_put(dummy_skb, sizeof(comp)), &comp, sizeof(comp));
  5895. if (desc_idx >= IPA_TAG_MAX_DESC) {
  5896. IPAERR("number of commands is out of range\n");
  5897. res = -ENOBUFS;
  5898. goto fail_free_skb;
  5899. }
  5900. tag_desc[desc_idx].pyld = dummy_skb->data;
  5901. tag_desc[desc_idx].len = dummy_skb->len;
  5902. tag_desc[desc_idx].type = IPA_DATA_DESC_SKB;
  5903. tag_desc[desc_idx].callback = ipa3_tag_free_skb;
  5904. tag_desc[desc_idx].user1 = dummy_skb;
  5905. desc_idx++;
  5906. retry_alloc:
  5907. /* send all descriptors to IPA with single EOT */
  5908. res = ipa3_send(sys, desc_idx, tag_desc, true);
  5909. if (res) {
  5910. if (res == -ENOMEM) {
  5911. if (retry_cnt < MAX_RETRY_ALLOC) {
  5912. IPADBG(
  5913. "failed to alloc memory retry cnt = %d\n",
  5914. retry_cnt);
  5915. retry_cnt++;
  5916. usleep_range(ALLOC_MIN_SLEEP_RX,
  5917. ALLOC_MAX_SLEEP_RX);
  5918. goto retry_alloc;
  5919. }
  5920. }
  5921. IPAERR("failed to send TAG packets %d\n", res);
  5922. res = -ENOMEM;
  5923. goto fail_free_skb;
  5924. }
  5925. kfree(tag_desc);
  5926. tag_desc = NULL;
  5927. ipa3_ctx->tag_process_before_gating = false;
  5928. IPADBG("waiting for TAG response\n");
  5929. res = wait_for_completion_timeout(&comp->comp, timeout);
  5930. if (res == 0) {
  5931. IPAERR("timeout (%lu msec) on waiting for TAG response\n",
  5932. timeout);
  5933. WARN_ON(1);
  5934. if (atomic_dec_return(&comp->cnt) == 0)
  5935. kfree(comp);
  5936. return -ETIME;
  5937. }
  5938. IPADBG("TAG response arrived!\n");
  5939. if (atomic_dec_return(&comp->cnt) == 0)
  5940. kfree(comp);
  5941. /*
  5942. * sleep for short period to ensure IPA wrote all packets to
  5943. * the transport
  5944. */
  5945. usleep_range(IPA_TAG_SLEEP_MIN_USEC, IPA_TAG_SLEEP_MAX_USEC);
  5946. return 0;
  5947. fail_free_skb:
  5948. kfree_skb(dummy_skb);
  5949. fail_free_comp:
  5950. kfree(comp);
  5951. fail_free_desc:
  5952. /*
  5953. * Free only the first descriptors allocated here.
  5954. * [nop, pkt_init, status, dummy_skb]
  5955. * The user is responsible to free his allocations
  5956. * in case of failure.
  5957. * The min is required because we may fail during
  5958. * of the initial allocations above
  5959. */
  5960. for (i = descs_num;
  5961. i < min(REQUIRED_TAG_PROCESS_DESCRIPTORS, desc_idx); i++)
  5962. if (tag_desc[i].callback)
  5963. tag_desc[i].callback(tag_desc[i].user1,
  5964. tag_desc[i].user2);
  5965. fail_free_tag_desc:
  5966. kfree(tag_desc);
  5967. return res;
  5968. }
  5969. /**
  5970. * ipa3_tag_generate_force_close_desc() - generate descriptors for force close
  5971. * immediate command
  5972. *
  5973. * @desc: descriptors for IC
  5974. * @desc_size: desc array size
  5975. * @start_pipe: first pipe to close aggregation
  5976. * @end_pipe: last (non-inclusive) pipe to close aggregation
  5977. *
  5978. * Return: number of descriptors written or negative in case of failure
  5979. */
  5980. static int ipa3_tag_generate_force_close_desc(struct ipa3_desc desc[],
  5981. int desc_size, int start_pipe, int end_pipe)
  5982. {
  5983. int i;
  5984. struct ipa_ep_cfg_aggr ep_aggr;
  5985. int desc_idx = 0;
  5986. int res;
  5987. struct ipahal_imm_cmd_register_write reg_write_agg_close;
  5988. struct ipahal_imm_cmd_pyld *cmd_pyld;
  5989. struct ipahal_reg_valmask valmask;
  5990. for (i = start_pipe; i < end_pipe; i++) {
  5991. ipahal_read_reg_n_fields(IPA_ENDP_INIT_AGGR_n, i, &ep_aggr);
  5992. if (!ep_aggr.aggr_en)
  5993. continue;
  5994. IPADBG("Force close ep: %d\n", i);
  5995. if (desc_idx + 1 > desc_size) {
  5996. IPAERR("Internal error - no descriptors\n");
  5997. res = -EFAULT;
  5998. goto fail_no_desc;
  5999. }
  6000. reg_write_agg_close.skip_pipeline_clear = false;
  6001. reg_write_agg_close.pipeline_clear_options =
  6002. IPAHAL_FULL_PIPELINE_CLEAR;
  6003. reg_write_agg_close.offset =
  6004. ipahal_get_reg_ofst(IPA_AGGR_FORCE_CLOSE);
  6005. ipahal_get_aggr_force_close_valmask(i, &valmask);
  6006. reg_write_agg_close.value = valmask.val;
  6007. reg_write_agg_close.value_mask = valmask.mask;
  6008. cmd_pyld = ipahal_construct_imm_cmd(IPA_IMM_CMD_REGISTER_WRITE,
  6009. &reg_write_agg_close, false);
  6010. if (!cmd_pyld) {
  6011. IPAERR("failed to construct register_write imm cmd\n");
  6012. res = -ENOMEM;
  6013. goto fail_alloc_reg_write_agg_close;
  6014. }
  6015. ipa3_init_imm_cmd_desc(&desc[desc_idx], cmd_pyld);
  6016. desc[desc_idx].callback = ipa3_tag_destroy_imm;
  6017. desc[desc_idx].user1 = cmd_pyld;
  6018. ++desc_idx;
  6019. }
  6020. return desc_idx;
  6021. fail_alloc_reg_write_agg_close:
  6022. for (i = 0; i < desc_idx; ++i)
  6023. if (desc[desc_idx].callback)
  6024. desc[desc_idx].callback(desc[desc_idx].user1,
  6025. desc[desc_idx].user2);
  6026. fail_no_desc:
  6027. return res;
  6028. }
  6029. /**
  6030. * ipa3_tag_aggr_force_close() - Force close aggregation
  6031. *
  6032. * @pipe_num: pipe number or -1 for all pipes
  6033. */
  6034. int ipa3_tag_aggr_force_close(int pipe_num)
  6035. {
  6036. struct ipa3_desc *desc;
  6037. int res = -1;
  6038. int start_pipe;
  6039. int end_pipe;
  6040. int num_descs;
  6041. int num_aggr_descs;
  6042. if (pipe_num < -1 || pipe_num >= (int)ipa3_ctx->ipa_num_pipes) {
  6043. IPAERR("Invalid pipe number %d\n", pipe_num);
  6044. return -EINVAL;
  6045. }
  6046. if (pipe_num == -1) {
  6047. start_pipe = 0;
  6048. end_pipe = ipa3_ctx->ipa_num_pipes;
  6049. } else {
  6050. start_pipe = pipe_num;
  6051. end_pipe = pipe_num + 1;
  6052. }
  6053. num_descs = end_pipe - start_pipe;
  6054. desc = kcalloc(num_descs, sizeof(*desc), GFP_KERNEL);
  6055. if (!desc) {
  6056. IPAERR("no mem\n");
  6057. return -ENOMEM;
  6058. }
  6059. /* Force close aggregation on all valid pipes with aggregation */
  6060. num_aggr_descs = ipa3_tag_generate_force_close_desc(desc, num_descs,
  6061. start_pipe, end_pipe);
  6062. if (num_aggr_descs < 0) {
  6063. IPAERR("ipa3_tag_generate_force_close_desc failed %d\n",
  6064. num_aggr_descs);
  6065. goto fail_free_desc;
  6066. }
  6067. res = ipa3_tag_process(desc, num_aggr_descs,
  6068. IPA_FORCE_CLOSE_TAG_PROCESS_TIMEOUT);
  6069. fail_free_desc:
  6070. kfree(desc);
  6071. return res;
  6072. }
  6073. /**
  6074. * ipa3_is_ready() - check if IPA module was initialized
  6075. * successfully
  6076. *
  6077. * Return value: true for yes; false for no
  6078. */
  6079. bool ipa3_is_ready(void)
  6080. {
  6081. bool complete;
  6082. if (ipa3_ctx == NULL)
  6083. return false;
  6084. mutex_lock(&ipa3_ctx->lock);
  6085. complete = ipa3_ctx->ipa_initialization_complete;
  6086. mutex_unlock(&ipa3_ctx->lock);
  6087. return complete;
  6088. }
  6089. /**
  6090. * ipa3_is_client_handle_valid() - check if IPA client handle is valid handle
  6091. *
  6092. * Return value: true for yes; false for no
  6093. */
  6094. bool ipa3_is_client_handle_valid(u32 clnt_hdl)
  6095. {
  6096. if (clnt_hdl >= 0 && clnt_hdl < ipa3_ctx->ipa_num_pipes)
  6097. return true;
  6098. return false;
  6099. }
  6100. /**
  6101. * ipa3_proxy_clk_unvote() - called to remove IPA clock proxy vote
  6102. *
  6103. * Return value: none
  6104. */
  6105. void ipa3_proxy_clk_unvote(void)
  6106. {
  6107. if (ipa3_ctx == NULL)
  6108. return;
  6109. mutex_lock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
  6110. if (ipa3_ctx->q6_proxy_clk_vote_valid) {
  6111. IPA_ACTIVE_CLIENTS_DEC_SPECIAL("PROXY_CLK_VOTE");
  6112. ipa3_ctx->q6_proxy_clk_vote_cnt--;
  6113. if (ipa3_ctx->q6_proxy_clk_vote_cnt == 0)
  6114. ipa3_ctx->q6_proxy_clk_vote_valid = false;
  6115. }
  6116. mutex_unlock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
  6117. }
  6118. /**
  6119. * ipa3_proxy_clk_vote() - called to add IPA clock proxy vote
  6120. *
  6121. * Return value: none
  6122. */
  6123. void ipa3_proxy_clk_vote(void)
  6124. {
  6125. if (ipa3_ctx == NULL)
  6126. return;
  6127. mutex_lock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
  6128. if (!ipa3_ctx->q6_proxy_clk_vote_valid ||
  6129. (ipa3_ctx->q6_proxy_clk_vote_cnt > 0)) {
  6130. IPA_ACTIVE_CLIENTS_INC_SPECIAL("PROXY_CLK_VOTE");
  6131. ipa3_ctx->q6_proxy_clk_vote_cnt++;
  6132. ipa3_ctx->q6_proxy_clk_vote_valid = true;
  6133. }
  6134. mutex_unlock(&ipa3_ctx->q6_proxy_clk_vote_mutex);
  6135. }
  6136. /**
  6137. * ipa3_get_smem_restr_bytes()- Return IPA smem restricted bytes
  6138. *
  6139. * Return value: u16 - number of IPA smem restricted bytes
  6140. */
  6141. u16 ipa3_get_smem_restr_bytes(void)
  6142. {
  6143. if (ipa3_ctx)
  6144. return ipa3_ctx->smem_restricted_bytes;
  6145. IPAERR("IPA Driver not initialized\n");
  6146. return 0;
  6147. }
  6148. /**
  6149. * ipa3_get_modem_cfg_emb_pipe_flt()- Return ipa3_ctx->modem_cfg_emb_pipe_flt
  6150. *
  6151. * Return value: true if modem configures embedded pipe flt, false otherwise
  6152. */
  6153. bool ipa3_get_modem_cfg_emb_pipe_flt(void)
  6154. {
  6155. if (ipa3_ctx)
  6156. return ipa3_ctx->modem_cfg_emb_pipe_flt;
  6157. IPAERR("IPA driver has not been initialized\n");
  6158. return false;
  6159. }
  6160. /**
  6161. * ipa3_get_transport_type()
  6162. *
  6163. * Return value: enum ipa_transport_type
  6164. */
  6165. enum ipa_transport_type ipa3_get_transport_type(void)
  6166. {
  6167. return IPA_TRANSPORT_TYPE_GSI;
  6168. }
  6169. u32 ipa3_get_num_pipes(void)
  6170. {
  6171. return ipahal_read_reg(IPA_ENABLED_PIPES);
  6172. }
  6173. /**
  6174. * ipa3_disable_apps_wan_cons_deaggr()-
  6175. * set ipa_ctx->ipa_client_apps_wan_cons_agg_gro
  6176. *
  6177. * Return value: 0 or negative in case of failure
  6178. */
  6179. int ipa3_disable_apps_wan_cons_deaggr(uint32_t agg_size, uint32_t agg_count)
  6180. {
  6181. int res = -1;
  6182. /* ipahal will adjust limits based on HW capabilities */
  6183. if (ipa3_ctx) {
  6184. ipa3_ctx->ipa_client_apps_wan_cons_agg_gro = true;
  6185. return 0;
  6186. }
  6187. return res;
  6188. }
  6189. static void *ipa3_get_ipc_logbuf(void)
  6190. {
  6191. if (ipa3_ctx)
  6192. return ipa3_ctx->logbuf;
  6193. return NULL;
  6194. }
  6195. static void *ipa3_get_ipc_logbuf_low(void)
  6196. {
  6197. if (ipa3_ctx)
  6198. return ipa3_ctx->logbuf_low;
  6199. return NULL;
  6200. }
  6201. static void ipa3_get_holb(int ep_idx, struct ipa_ep_cfg_holb *holb)
  6202. {
  6203. *holb = ipa3_ctx->ep[ep_idx].holb;
  6204. }
  6205. static void ipa3_set_tag_process_before_gating(bool val)
  6206. {
  6207. ipa3_ctx->tag_process_before_gating = val;
  6208. }
  6209. /**
  6210. * ipa3_is_vlan_mode - check if a LAN driver should load in VLAN mode
  6211. * @iface - type of vlan capable device
  6212. * @res - query result: true for vlan mode, false for non vlan mode
  6213. *
  6214. * API must be called after ipa_is_ready() returns true, otherwise it will fail
  6215. *
  6216. * Returns: 0 on success, negative on failure
  6217. */
  6218. int ipa3_is_vlan_mode(enum ipa_vlan_ifaces iface, bool *res)
  6219. {
  6220. if (!res) {
  6221. IPAERR("NULL out param\n");
  6222. return -EINVAL;
  6223. }
  6224. if (iface < 0 || iface >= IPA_VLAN_IF_MAX) {
  6225. IPAERR("invalid iface %d\n", iface);
  6226. return -EINVAL;
  6227. }
  6228. if (!ipa3_is_ready()) {
  6229. IPAERR("IPA is not ready yet\n");
  6230. return -ENODEV;
  6231. }
  6232. *res = ipa3_ctx->vlan_mode_iface[iface];
  6233. IPADBG("Driver %d vlan mode is %d\n", iface, *res);
  6234. return 0;
  6235. }
  6236. static bool ipa3_pm_is_used(void)
  6237. {
  6238. return (ipa3_ctx) ? ipa3_ctx->use_ipa_pm : false;
  6239. }
  6240. int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
  6241. struct ipa_api_controller *api_ctrl)
  6242. {
  6243. if (ipa_hw_type < IPA_HW_v3_0) {
  6244. IPAERR("Unsupported IPA HW version %d\n", ipa_hw_type);
  6245. WARN_ON(1);
  6246. return -EPERM;
  6247. }
  6248. api_ctrl->ipa_reset_endpoint = NULL;
  6249. api_ctrl->ipa_clear_endpoint_delay = ipa3_clear_endpoint_delay;
  6250. api_ctrl->ipa_disable_endpoint = NULL;
  6251. api_ctrl->ipa_cfg_ep = ipa3_cfg_ep;
  6252. api_ctrl->ipa_cfg_ep_nat = ipa3_cfg_ep_nat;
  6253. api_ctrl->ipa_cfg_ep_conn_track = ipa3_cfg_ep_conn_track;
  6254. api_ctrl->ipa_cfg_ep_hdr = ipa3_cfg_ep_hdr;
  6255. api_ctrl->ipa_cfg_ep_hdr_ext = ipa3_cfg_ep_hdr_ext;
  6256. api_ctrl->ipa_cfg_ep_mode = ipa3_cfg_ep_mode;
  6257. api_ctrl->ipa_cfg_ep_aggr = ipa3_cfg_ep_aggr;
  6258. api_ctrl->ipa_cfg_ep_deaggr = ipa3_cfg_ep_deaggr;
  6259. api_ctrl->ipa_cfg_ep_route = ipa3_cfg_ep_route;
  6260. api_ctrl->ipa_cfg_ep_holb = ipa3_cfg_ep_holb;
  6261. api_ctrl->ipa_get_holb = ipa3_get_holb;
  6262. api_ctrl->ipa_set_tag_process_before_gating =
  6263. ipa3_set_tag_process_before_gating;
  6264. api_ctrl->ipa_cfg_ep_cfg = ipa3_cfg_ep_cfg;
  6265. api_ctrl->ipa_cfg_ep_metadata_mask = ipa3_cfg_ep_metadata_mask;
  6266. api_ctrl->ipa_cfg_ep_holb_by_client = ipa3_cfg_ep_holb_by_client;
  6267. api_ctrl->ipa_cfg_ep_ctrl = ipa3_cfg_ep_ctrl;
  6268. api_ctrl->ipa_add_hdr = ipa3_add_hdr;
  6269. api_ctrl->ipa_add_hdr_usr = ipa3_add_hdr_usr;
  6270. api_ctrl->ipa_del_hdr = ipa3_del_hdr;
  6271. api_ctrl->ipa_commit_hdr = ipa3_commit_hdr;
  6272. api_ctrl->ipa_reset_hdr = ipa3_reset_hdr;
  6273. api_ctrl->ipa_get_hdr = ipa3_get_hdr;
  6274. api_ctrl->ipa_put_hdr = ipa3_put_hdr;
  6275. api_ctrl->ipa_copy_hdr = ipa3_copy_hdr;
  6276. api_ctrl->ipa_add_hdr_proc_ctx = ipa3_add_hdr_proc_ctx;
  6277. api_ctrl->ipa_del_hdr_proc_ctx = ipa3_del_hdr_proc_ctx;
  6278. api_ctrl->ipa_add_rt_rule = ipa3_add_rt_rule;
  6279. api_ctrl->ipa_add_rt_rule_v2 = ipa3_add_rt_rule_v2;
  6280. api_ctrl->ipa_add_rt_rule_usr = ipa3_add_rt_rule_usr;
  6281. api_ctrl->ipa_add_rt_rule_usr_v2 = ipa3_add_rt_rule_usr_v2;
  6282. api_ctrl->ipa_del_rt_rule = ipa3_del_rt_rule;
  6283. api_ctrl->ipa_commit_rt = ipa3_commit_rt;
  6284. api_ctrl->ipa_reset_rt = ipa3_reset_rt;
  6285. api_ctrl->ipa_get_rt_tbl = ipa3_get_rt_tbl;
  6286. api_ctrl->ipa_put_rt_tbl = ipa3_put_rt_tbl;
  6287. api_ctrl->ipa_query_rt_index = ipa3_query_rt_index;
  6288. api_ctrl->ipa_mdfy_rt_rule = ipa3_mdfy_rt_rule;
  6289. api_ctrl->ipa_mdfy_rt_rule_v2 = ipa3_mdfy_rt_rule_v2;
  6290. api_ctrl->ipa_add_flt_rule = ipa3_add_flt_rule;
  6291. api_ctrl->ipa_add_flt_rule_v2 = ipa3_add_flt_rule_v2;
  6292. api_ctrl->ipa_add_flt_rule_usr = ipa3_add_flt_rule_usr;
  6293. api_ctrl->ipa_add_flt_rule_usr_v2 = ipa3_add_flt_rule_usr_v2;
  6294. api_ctrl->ipa_del_flt_rule = ipa3_del_flt_rule;
  6295. api_ctrl->ipa_mdfy_flt_rule = ipa3_mdfy_flt_rule;
  6296. api_ctrl->ipa_mdfy_flt_rule_v2 = ipa3_mdfy_flt_rule_v2;
  6297. api_ctrl->ipa_commit_flt = ipa3_commit_flt;
  6298. api_ctrl->ipa_reset_flt = ipa3_reset_flt;
  6299. api_ctrl->ipa_allocate_nat_device = ipa3_allocate_nat_device;
  6300. api_ctrl->ipa_allocate_nat_table = ipa3_allocate_nat_table;
  6301. api_ctrl->ipa_allocate_ipv6ct_table = ipa3_allocate_ipv6ct_table;
  6302. api_ctrl->ipa_nat_init_cmd = ipa3_nat_init_cmd;
  6303. api_ctrl->ipa_ipv6ct_init_cmd = ipa3_ipv6ct_init_cmd;
  6304. api_ctrl->ipa_nat_dma_cmd = ipa3_nat_dma_cmd;
  6305. api_ctrl->ipa_table_dma_cmd = ipa3_table_dma_cmd;
  6306. api_ctrl->ipa_nat_del_cmd = ipa3_nat_del_cmd;
  6307. api_ctrl->ipa_del_nat_table = ipa3_del_nat_table;
  6308. api_ctrl->ipa_del_ipv6ct_table = ipa3_del_ipv6ct_table;
  6309. api_ctrl->ipa_nat_mdfy_pdn = ipa3_nat_mdfy_pdn;
  6310. api_ctrl->ipa_send_msg = ipa3_send_msg;
  6311. api_ctrl->ipa_register_pull_msg = ipa3_register_pull_msg;
  6312. api_ctrl->ipa_deregister_pull_msg = ipa3_deregister_pull_msg;
  6313. api_ctrl->ipa_register_intf = ipa3_register_intf;
  6314. api_ctrl->ipa_register_intf_ext = ipa3_register_intf_ext;
  6315. api_ctrl->ipa_deregister_intf = ipa3_deregister_intf;
  6316. api_ctrl->ipa_set_aggr_mode = ipa3_set_aggr_mode;
  6317. api_ctrl->ipa_set_qcncm_ndp_sig = ipa3_set_qcncm_ndp_sig;
  6318. api_ctrl->ipa_set_single_ndp_per_mbim = ipa3_set_single_ndp_per_mbim;
  6319. api_ctrl->ipa_tx_dp = ipa3_tx_dp;
  6320. api_ctrl->ipa_tx_dp_mul = ipa3_tx_dp_mul;
  6321. api_ctrl->ipa_free_skb = ipa3_free_skb;
  6322. api_ctrl->ipa_setup_sys_pipe = ipa3_setup_sys_pipe;
  6323. api_ctrl->ipa_teardown_sys_pipe = ipa3_teardown_sys_pipe;
  6324. api_ctrl->ipa_sys_setup = ipa3_sys_setup;
  6325. api_ctrl->ipa_sys_teardown = ipa3_sys_teardown;
  6326. api_ctrl->ipa_sys_update_gsi_hdls = ipa3_sys_update_gsi_hdls;
  6327. api_ctrl->ipa_connect_wdi_pipe = ipa3_connect_wdi_pipe;
  6328. api_ctrl->ipa_disconnect_wdi_pipe = ipa3_disconnect_wdi_pipe;
  6329. api_ctrl->ipa_enable_wdi_pipe = ipa3_enable_wdi_pipe;
  6330. api_ctrl->ipa_disable_wdi_pipe = ipa3_disable_wdi_pipe;
  6331. api_ctrl->ipa_resume_wdi_pipe = ipa3_resume_wdi_pipe;
  6332. api_ctrl->ipa_suspend_wdi_pipe = ipa3_suspend_wdi_pipe;
  6333. api_ctrl->ipa_get_wdi_stats = ipa3_get_wdi_stats;
  6334. api_ctrl->ipa_get_smem_restr_bytes = ipa3_get_smem_restr_bytes;
  6335. api_ctrl->ipa_broadcast_wdi_quota_reach_ind =
  6336. ipa3_broadcast_wdi_quota_reach_ind;
  6337. api_ctrl->ipa_uc_wdi_get_dbpa = ipa3_uc_wdi_get_dbpa;
  6338. api_ctrl->ipa_uc_reg_rdyCB = ipa3_uc_reg_rdyCB;
  6339. api_ctrl->ipa_uc_dereg_rdyCB = ipa3_uc_dereg_rdyCB;
  6340. api_ctrl->teth_bridge_init = ipa3_teth_bridge_init;
  6341. api_ctrl->teth_bridge_disconnect = ipa3_teth_bridge_disconnect;
  6342. api_ctrl->teth_bridge_connect = ipa3_teth_bridge_connect;
  6343. api_ctrl->ipa_set_client = ipa3_set_client;
  6344. api_ctrl->ipa_get_client = ipa3_get_client;
  6345. api_ctrl->ipa_get_client_uplink = ipa3_get_client_uplink;
  6346. api_ctrl->ipa_dma_init = ipa3_dma_init;
  6347. api_ctrl->ipa_dma_enable = ipa3_dma_enable;
  6348. api_ctrl->ipa_dma_disable = ipa3_dma_disable;
  6349. api_ctrl->ipa_dma_sync_memcpy = ipa3_dma_sync_memcpy;
  6350. api_ctrl->ipa_dma_async_memcpy = ipa3_dma_async_memcpy;
  6351. api_ctrl->ipa_dma_uc_memcpy = ipa3_dma_uc_memcpy;
  6352. api_ctrl->ipa_dma_destroy = ipa3_dma_destroy;
  6353. api_ctrl->ipa_mhi_init_engine = ipa3_mhi_init_engine;
  6354. api_ctrl->ipa_connect_mhi_pipe = ipa3_connect_mhi_pipe;
  6355. api_ctrl->ipa_disconnect_mhi_pipe = ipa3_disconnect_mhi_pipe;
  6356. api_ctrl->ipa_mhi_stop_gsi_channel = ipa3_mhi_stop_gsi_channel;
  6357. api_ctrl->ipa_uc_mhi_reset_channel = ipa3_uc_mhi_reset_channel;
  6358. api_ctrl->ipa_qmi_enable_force_clear_datapath_send =
  6359. ipa3_qmi_enable_force_clear_datapath_send;
  6360. api_ctrl->ipa_qmi_disable_force_clear_datapath_send =
  6361. ipa3_qmi_disable_force_clear_datapath_send;
  6362. api_ctrl->ipa_mhi_reset_channel_internal =
  6363. ipa3_mhi_reset_channel_internal;
  6364. api_ctrl->ipa_mhi_start_channel_internal =
  6365. ipa3_mhi_start_channel_internal;
  6366. api_ctrl->ipa_mhi_query_ch_info = ipa3_mhi_query_ch_info;
  6367. api_ctrl->ipa_mhi_resume_channels_internal =
  6368. ipa3_mhi_resume_channels_internal;
  6369. api_ctrl->ipa_has_open_aggr_frame = ipa3_has_open_aggr_frame;
  6370. api_ctrl->ipa_mhi_destroy_channel = ipa3_mhi_destroy_channel;
  6371. api_ctrl->ipa_uc_mhi_send_dl_ul_sync_info =
  6372. ipa3_uc_mhi_send_dl_ul_sync_info;
  6373. api_ctrl->ipa_uc_mhi_init = ipa3_uc_mhi_init;
  6374. api_ctrl->ipa_uc_mhi_suspend_channel = ipa3_uc_mhi_suspend_channel;
  6375. api_ctrl->ipa_uc_mhi_stop_event_update_channel =
  6376. ipa3_uc_mhi_stop_event_update_channel;
  6377. api_ctrl->ipa_uc_mhi_cleanup = ipa3_uc_mhi_cleanup;
  6378. api_ctrl->ipa_uc_state_check = ipa3_uc_state_check;
  6379. api_ctrl->ipa_write_qmap_id = ipa3_write_qmap_id;
  6380. api_ctrl->ipa_add_interrupt_handler = ipa3_add_interrupt_handler;
  6381. api_ctrl->ipa_remove_interrupt_handler = ipa3_remove_interrupt_handler;
  6382. api_ctrl->ipa_restore_suspend_handler = ipa3_restore_suspend_handler;
  6383. api_ctrl->ipa_bam_reg_dump = NULL;
  6384. api_ctrl->ipa_get_ep_mapping = ipa3_get_ep_mapping;
  6385. api_ctrl->ipa_is_ready = ipa3_is_ready;
  6386. api_ctrl->ipa_proxy_clk_vote = ipa3_proxy_clk_vote;
  6387. api_ctrl->ipa_proxy_clk_unvote = ipa3_proxy_clk_unvote;
  6388. api_ctrl->ipa_is_client_handle_valid = ipa3_is_client_handle_valid;
  6389. api_ctrl->ipa_get_client_mapping = ipa3_get_client_mapping;
  6390. api_ctrl->ipa_get_rm_resource_from_ep = ipa3_get_rm_resource_from_ep;
  6391. api_ctrl->ipa_get_modem_cfg_emb_pipe_flt =
  6392. ipa3_get_modem_cfg_emb_pipe_flt;
  6393. api_ctrl->ipa_get_transport_type = ipa3_get_transport_type;
  6394. api_ctrl->ipa_ap_suspend = ipa3_ap_suspend;
  6395. api_ctrl->ipa_ap_resume = ipa3_ap_resume;
  6396. api_ctrl->ipa_get_smmu_domain = ipa3_get_smmu_domain;
  6397. api_ctrl->ipa_disable_apps_wan_cons_deaggr =
  6398. ipa3_disable_apps_wan_cons_deaggr;
  6399. api_ctrl->ipa_get_dma_dev = ipa3_get_dma_dev;
  6400. api_ctrl->ipa_release_wdi_mapping = ipa3_release_wdi_mapping;
  6401. api_ctrl->ipa_create_wdi_mapping = ipa3_create_wdi_mapping;
  6402. api_ctrl->ipa_get_gsi_ep_info = ipa3_get_gsi_ep_info;
  6403. api_ctrl->ipa_stop_gsi_channel = ipa3_stop_gsi_channel;
  6404. api_ctrl->ipa_start_gsi_channel = ipa3_start_gsi_channel;
  6405. api_ctrl->ipa_register_ipa_ready_cb = ipa3_register_ipa_ready_cb;
  6406. api_ctrl->ipa_inc_client_enable_clks = ipa3_inc_client_enable_clks;
  6407. api_ctrl->ipa_dec_client_disable_clks = ipa3_dec_client_disable_clks;
  6408. api_ctrl->ipa_inc_client_enable_clks_no_block =
  6409. ipa3_inc_client_enable_clks_no_block;
  6410. api_ctrl->ipa_suspend_resource_no_block =
  6411. ipa3_suspend_resource_no_block;
  6412. api_ctrl->ipa_resume_resource = ipa3_resume_resource;
  6413. api_ctrl->ipa_suspend_resource_sync = ipa3_suspend_resource_sync;
  6414. api_ctrl->ipa_set_required_perf_profile =
  6415. ipa3_set_required_perf_profile;
  6416. api_ctrl->ipa_get_ipc_logbuf = ipa3_get_ipc_logbuf;
  6417. api_ctrl->ipa_get_ipc_logbuf_low = ipa3_get_ipc_logbuf_low;
  6418. api_ctrl->ipa_rx_poll = ipa3_rx_poll;
  6419. api_ctrl->ipa_setup_uc_ntn_pipes = ipa3_setup_uc_ntn_pipes;
  6420. api_ctrl->ipa_tear_down_uc_offload_pipes =
  6421. ipa3_tear_down_uc_offload_pipes;
  6422. api_ctrl->ipa_get_pdev = ipa3_get_pdev;
  6423. api_ctrl->ipa_ntn_uc_reg_rdyCB = ipa3_ntn_uc_reg_rdyCB;
  6424. api_ctrl->ipa_ntn_uc_dereg_rdyCB = ipa3_ntn_uc_dereg_rdyCB;
  6425. api_ctrl->ipa_conn_wdi_pipes = ipa3_conn_wdi3_pipes;
  6426. api_ctrl->ipa_disconn_wdi_pipes = ipa3_disconn_wdi3_pipes;
  6427. api_ctrl->ipa_enable_wdi_pipes = ipa3_enable_wdi3_pipes;
  6428. api_ctrl->ipa_disable_wdi_pipes = ipa3_disable_wdi3_pipes;
  6429. api_ctrl->ipa_tz_unlock_reg = ipa3_tz_unlock_reg;
  6430. api_ctrl->ipa_get_smmu_params = ipa3_get_smmu_params;
  6431. api_ctrl->ipa_is_vlan_mode = ipa3_is_vlan_mode;
  6432. api_ctrl->ipa_pm_is_used = ipa3_pm_is_used;
  6433. api_ctrl->ipa_wigig_uc_init = ipa3_wigig_uc_init;
  6434. api_ctrl->ipa_conn_wigig_rx_pipe_i = ipa3_conn_wigig_rx_pipe_i;
  6435. api_ctrl->ipa_conn_wigig_client_i = ipa3_conn_wigig_client_i;
  6436. api_ctrl->ipa_disconn_wigig_pipe_i = ipa3_disconn_wigig_pipe_i;
  6437. api_ctrl->ipa_wigig_uc_msi_init = ipa3_wigig_uc_msi_init;
  6438. api_ctrl->ipa_enable_wigig_pipe_i = ipa3_enable_wigig_pipe_i;
  6439. api_ctrl->ipa_disable_wigig_pipe_i = ipa3_disable_wigig_pipe_i;
  6440. api_ctrl->ipa_register_client_callback =
  6441. ipa3_register_client_callback;
  6442. api_ctrl->ipa_deregister_client_callback =
  6443. ipa3_deregister_client_callback;
  6444. return 0;
  6445. }
  6446. /**
  6447. * ipa_is_modem_pipe()- Checks if pipe is owned by the modem
  6448. *
  6449. * @pipe_idx: pipe number
  6450. * Return value: true if owned by modem, false otherwize
  6451. */
  6452. bool ipa_is_modem_pipe(int pipe_idx)
  6453. {
  6454. int client_idx;
  6455. if (pipe_idx >= ipa3_ctx->ipa_num_pipes || pipe_idx < 0) {
  6456. IPAERR("Bad pipe index!\n");
  6457. return false;
  6458. }
  6459. for (client_idx = 0; client_idx < IPA_CLIENT_MAX; client_idx++) {
  6460. if (!IPA_CLIENT_IS_Q6_CONS(client_idx) &&
  6461. !IPA_CLIENT_IS_Q6_PROD(client_idx))
  6462. continue;
  6463. if (ipa3_get_ep_mapping(client_idx) == pipe_idx)
  6464. return true;
  6465. }
  6466. return false;
  6467. }
  6468. static void ipa3_write_rsrc_grp_type_reg(int group_index,
  6469. enum ipa_rsrc_grp_type_src n, bool src,
  6470. struct ipahal_reg_rsrc_grp_cfg *val)
  6471. {
  6472. u8 hw_type_idx;
  6473. hw_type_idx = ipa3_get_hw_type_index();
  6474. switch (hw_type_idx) {
  6475. case IPA_3_0:
  6476. if (src) {
  6477. switch (group_index) {
  6478. case IPA_v3_0_GROUP_UL:
  6479. case IPA_v3_0_GROUP_DL:
  6480. ipahal_write_reg_n_fields(
  6481. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6482. n, val);
  6483. break;
  6484. case IPA_v3_0_GROUP_DIAG:
  6485. case IPA_v3_0_GROUP_DMA:
  6486. ipahal_write_reg_n_fields(
  6487. IPA_SRC_RSRC_GRP_23_RSRC_TYPE_n,
  6488. n, val);
  6489. break;
  6490. case IPA_v3_0_GROUP_Q6ZIP:
  6491. case IPA_v3_0_GROUP_UC_RX_Q:
  6492. ipahal_write_reg_n_fields(
  6493. IPA_SRC_RSRC_GRP_45_RSRC_TYPE_n,
  6494. n, val);
  6495. break;
  6496. default:
  6497. IPAERR(
  6498. " Invalid source resource group,index #%d\n",
  6499. group_index);
  6500. break;
  6501. }
  6502. } else {
  6503. switch (group_index) {
  6504. case IPA_v3_0_GROUP_UL:
  6505. case IPA_v3_0_GROUP_DL:
  6506. ipahal_write_reg_n_fields(
  6507. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6508. n, val);
  6509. break;
  6510. case IPA_v3_0_GROUP_DIAG:
  6511. case IPA_v3_0_GROUP_DMA:
  6512. ipahal_write_reg_n_fields(
  6513. IPA_DST_RSRC_GRP_23_RSRC_TYPE_n,
  6514. n, val);
  6515. break;
  6516. case IPA_v3_0_GROUP_Q6ZIP_GENERAL:
  6517. case IPA_v3_0_GROUP_Q6ZIP_ENGINE:
  6518. ipahal_write_reg_n_fields(
  6519. IPA_DST_RSRC_GRP_45_RSRC_TYPE_n,
  6520. n, val);
  6521. break;
  6522. default:
  6523. IPAERR(
  6524. " Invalid destination resource group,index #%d\n",
  6525. group_index);
  6526. break;
  6527. }
  6528. }
  6529. break;
  6530. case IPA_3_5:
  6531. case IPA_3_5_MHI:
  6532. case IPA_3_5_1:
  6533. if (src) {
  6534. switch (group_index) {
  6535. case IPA_v3_5_GROUP_LWA_DL:
  6536. case IPA_v3_5_GROUP_UL_DL:
  6537. ipahal_write_reg_n_fields(
  6538. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6539. n, val);
  6540. break;
  6541. case IPA_v3_5_MHI_GROUP_DMA:
  6542. case IPA_v3_5_GROUP_UC_RX_Q:
  6543. ipahal_write_reg_n_fields(
  6544. IPA_SRC_RSRC_GRP_23_RSRC_TYPE_n,
  6545. n, val);
  6546. break;
  6547. default:
  6548. IPAERR(
  6549. " Invalid source resource group,index #%d\n",
  6550. group_index);
  6551. break;
  6552. }
  6553. } else {
  6554. switch (group_index) {
  6555. case IPA_v3_5_GROUP_LWA_DL:
  6556. case IPA_v3_5_GROUP_UL_DL:
  6557. ipahal_write_reg_n_fields(
  6558. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6559. n, val);
  6560. break;
  6561. case IPA_v3_5_MHI_GROUP_DMA:
  6562. ipahal_write_reg_n_fields(
  6563. IPA_DST_RSRC_GRP_23_RSRC_TYPE_n,
  6564. n, val);
  6565. break;
  6566. default:
  6567. IPAERR(
  6568. " Invalid destination resource group,index #%d\n",
  6569. group_index);
  6570. break;
  6571. }
  6572. }
  6573. break;
  6574. case IPA_4_0:
  6575. case IPA_4_0_MHI:
  6576. case IPA_4_1:
  6577. if (src) {
  6578. switch (group_index) {
  6579. case IPA_v4_0_GROUP_LWA_DL:
  6580. case IPA_v4_0_GROUP_UL_DL:
  6581. ipahal_write_reg_n_fields(
  6582. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6583. n, val);
  6584. break;
  6585. case IPA_v4_0_MHI_GROUP_DMA:
  6586. case IPA_v4_0_GROUP_UC_RX_Q:
  6587. ipahal_write_reg_n_fields(
  6588. IPA_SRC_RSRC_GRP_23_RSRC_TYPE_n,
  6589. n, val);
  6590. break;
  6591. default:
  6592. IPAERR(
  6593. " Invalid source resource group,index #%d\n",
  6594. group_index);
  6595. break;
  6596. }
  6597. } else {
  6598. switch (group_index) {
  6599. case IPA_v4_0_GROUP_LWA_DL:
  6600. case IPA_v4_0_GROUP_UL_DL:
  6601. ipahal_write_reg_n_fields(
  6602. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6603. n, val);
  6604. break;
  6605. case IPA_v4_0_MHI_GROUP_DMA:
  6606. ipahal_write_reg_n_fields(
  6607. IPA_DST_RSRC_GRP_23_RSRC_TYPE_n,
  6608. n, val);
  6609. break;
  6610. default:
  6611. IPAERR(
  6612. " Invalid destination resource group,index #%d\n",
  6613. group_index);
  6614. break;
  6615. }
  6616. }
  6617. break;
  6618. case IPA_4_2:
  6619. if (src) {
  6620. switch (group_index) {
  6621. case IPA_v4_2_GROUP_UL_DL:
  6622. ipahal_write_reg_n_fields(
  6623. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6624. n, val);
  6625. break;
  6626. default:
  6627. IPAERR(
  6628. " Invalid source resource group,index #%d\n",
  6629. group_index);
  6630. break;
  6631. }
  6632. } else {
  6633. switch (group_index) {
  6634. case IPA_v4_2_GROUP_UL_DL:
  6635. ipahal_write_reg_n_fields(
  6636. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6637. n, val);
  6638. break;
  6639. default:
  6640. IPAERR(
  6641. " Invalid destination resource group,index #%d\n",
  6642. group_index);
  6643. break;
  6644. }
  6645. }
  6646. break;
  6647. case IPA_4_5:
  6648. case IPA_4_5_MHI:
  6649. case IPA_4_5_APQ:
  6650. if (src) {
  6651. switch (group_index) {
  6652. case IPA_v4_5_MHI_GROUP_PCIE:
  6653. case IPA_v4_5_GROUP_UL_DL:
  6654. ipahal_write_reg_n_fields(
  6655. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6656. n, val);
  6657. break;
  6658. case IPA_v4_5_MHI_GROUP_DMA:
  6659. case IPA_v4_5_MHI_GROUP_QDSS:
  6660. ipahal_write_reg_n_fields(
  6661. IPA_SRC_RSRC_GRP_23_RSRC_TYPE_n,
  6662. n, val);
  6663. break;
  6664. case IPA_v4_5_GROUP_UC_RX_Q:
  6665. ipahal_write_reg_n_fields(
  6666. IPA_SRC_RSRC_GRP_45_RSRC_TYPE_n,
  6667. n, val);
  6668. break;
  6669. default:
  6670. IPAERR(
  6671. " Invalid source resource group,index #%d\n",
  6672. group_index);
  6673. break;
  6674. }
  6675. } else {
  6676. switch (group_index) {
  6677. case IPA_v4_5_MHI_GROUP_PCIE:
  6678. case IPA_v4_5_GROUP_UL_DL:
  6679. ipahal_write_reg_n_fields(
  6680. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6681. n, val);
  6682. break;
  6683. case IPA_v4_5_MHI_GROUP_DMA:
  6684. case IPA_v4_5_MHI_GROUP_QDSS:
  6685. ipahal_write_reg_n_fields(
  6686. IPA_DST_RSRC_GRP_23_RSRC_TYPE_n,
  6687. n, val);
  6688. break;
  6689. case IPA_v4_5_GROUP_UC_RX_Q:
  6690. ipahal_write_reg_n_fields(
  6691. IPA_DST_RSRC_GRP_45_RSRC_TYPE_n,
  6692. n, val);
  6693. break;
  6694. default:
  6695. IPAERR(
  6696. " Invalid destination resource group,index #%d\n",
  6697. group_index);
  6698. break;
  6699. }
  6700. }
  6701. break;
  6702. case IPA_4_7:
  6703. if (src) {
  6704. switch (group_index) {
  6705. case IPA_v4_7_GROUP_UL_DL:
  6706. ipahal_write_reg_n_fields(
  6707. IPA_SRC_RSRC_GRP_01_RSRC_TYPE_n,
  6708. n, val);
  6709. break;
  6710. default:
  6711. IPAERR(
  6712. " Invalid source resource group,index #%d\n",
  6713. group_index);
  6714. break;
  6715. }
  6716. } else {
  6717. switch (group_index) {
  6718. case IPA_v4_7_GROUP_UL_DL:
  6719. ipahal_write_reg_n_fields(
  6720. IPA_DST_RSRC_GRP_01_RSRC_TYPE_n,
  6721. n, val);
  6722. break;
  6723. default:
  6724. IPAERR(
  6725. " Invalid destination resource group,index #%d\n",
  6726. group_index);
  6727. break;
  6728. }
  6729. }
  6730. break;
  6731. default:
  6732. IPAERR("invalid hw type\n");
  6733. WARN_ON(1);
  6734. return;
  6735. }
  6736. }
  6737. static void ipa3_configure_rx_hps_clients(int depth,
  6738. int max_clnt_in_depth, int base_index, bool min)
  6739. {
  6740. int i;
  6741. struct ipahal_reg_rx_hps_clients val;
  6742. u8 hw_type_idx;
  6743. hw_type_idx = ipa3_get_hw_type_index();
  6744. for (i = 0 ; i < max_clnt_in_depth ; i++) {
  6745. if (min)
  6746. val.client_minmax[i] =
  6747. ipa3_rsrc_rx_grp_config
  6748. [hw_type_idx]
  6749. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ]
  6750. [i + base_index].min;
  6751. else
  6752. val.client_minmax[i] =
  6753. ipa3_rsrc_rx_grp_config
  6754. [hw_type_idx]
  6755. [IPA_RSRC_GRP_TYPE_RX_HPS_CMDQ]
  6756. [i + base_index].max;
  6757. }
  6758. if (depth) {
  6759. ipahal_write_reg_fields(min ? IPA_RX_HPS_CLIENTS_MIN_DEPTH_1 :
  6760. IPA_RX_HPS_CLIENTS_MAX_DEPTH_1,
  6761. &val);
  6762. } else {
  6763. ipahal_write_reg_fields(min ? IPA_RX_HPS_CLIENTS_MIN_DEPTH_0 :
  6764. IPA_RX_HPS_CLIENTS_MAX_DEPTH_0,
  6765. &val);
  6766. }
  6767. }
  6768. static void ipa3_configure_rx_hps_weight(void)
  6769. {
  6770. struct ipahal_reg_rx_hps_weights val;
  6771. u8 hw_type_idx;
  6772. hw_type_idx = ipa3_get_hw_type_index();
  6773. val.hps_queue_weight_0 =
  6774. ipa3_rsrc_rx_grp_hps_weight_config
  6775. [hw_type_idx][IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG]
  6776. [0];
  6777. val.hps_queue_weight_1 =
  6778. ipa3_rsrc_rx_grp_hps_weight_config
  6779. [hw_type_idx][IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG]
  6780. [1];
  6781. val.hps_queue_weight_2 =
  6782. ipa3_rsrc_rx_grp_hps_weight_config
  6783. [hw_type_idx][IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG]
  6784. [2];
  6785. val.hps_queue_weight_3 =
  6786. ipa3_rsrc_rx_grp_hps_weight_config
  6787. [hw_type_idx][IPA_RSRC_GRP_TYPE_RX_HPS_WEIGHT_CONFIG]
  6788. [3];
  6789. ipahal_write_reg_fields(IPA_HPS_FTCH_ARB_QUEUE_WEIGHT, &val);
  6790. }
  6791. static void ipa3_configure_rx_hps(void)
  6792. {
  6793. int rx_hps_max_clnt_in_depth0;
  6794. IPADBG("Assign RX_HPS CMDQ rsrc groups min-max limits\n");
  6795. /* Starting IPA4.5 we have 5 RX_HPS_CMDQ */
  6796. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5)
  6797. rx_hps_max_clnt_in_depth0 = 4;
  6798. else
  6799. rx_hps_max_clnt_in_depth0 = 5;
  6800. ipa3_configure_rx_hps_clients(0, rx_hps_max_clnt_in_depth0, 0, true);
  6801. ipa3_configure_rx_hps_clients(0, rx_hps_max_clnt_in_depth0, 0, false);
  6802. /*
  6803. * IPA 3.0/3.1 uses 6 RX_HPS_CMDQ and needs depths1 for that
  6804. * which has two clients
  6805. */
  6806. if (ipa3_ctx->ipa_hw_type <= IPA_HW_v3_1) {
  6807. ipa3_configure_rx_hps_clients(1, 2, rx_hps_max_clnt_in_depth0,
  6808. true);
  6809. ipa3_configure_rx_hps_clients(1, 2, rx_hps_max_clnt_in_depth0,
  6810. false);
  6811. }
  6812. /* Starting IPA4.2 no support to HPS weight config */
  6813. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v3_5 &&
  6814. (ipa3_ctx->ipa_hw_type < IPA_HW_v4_2))
  6815. ipa3_configure_rx_hps_weight();
  6816. }
  6817. void ipa3_set_resorce_groups_min_max_limits(void)
  6818. {
  6819. int i;
  6820. int j;
  6821. int src_rsrc_type_max;
  6822. int dst_rsrc_type_max;
  6823. int src_grp_idx_max;
  6824. int dst_grp_idx_max;
  6825. struct ipahal_reg_rsrc_grp_cfg val;
  6826. u8 hw_type_idx;
  6827. IPADBG("ENTER\n");
  6828. hw_type_idx = ipa3_get_hw_type_index();
  6829. switch (hw_type_idx) {
  6830. case IPA_3_0:
  6831. src_rsrc_type_max = IPA_v3_0_RSRC_GRP_TYPE_SRC_MAX;
  6832. dst_rsrc_type_max = IPA_v3_0_RSRC_GRP_TYPE_DST_MAX;
  6833. src_grp_idx_max = IPA_v3_0_GROUP_MAX;
  6834. dst_grp_idx_max = IPA_v3_0_GROUP_MAX;
  6835. break;
  6836. case IPA_3_5:
  6837. case IPA_3_5_MHI:
  6838. case IPA_3_5_1:
  6839. src_rsrc_type_max = IPA_v3_5_RSRC_GRP_TYPE_SRC_MAX;
  6840. dst_rsrc_type_max = IPA_v3_5_RSRC_GRP_TYPE_DST_MAX;
  6841. src_grp_idx_max = IPA_v3_5_SRC_GROUP_MAX;
  6842. dst_grp_idx_max = IPA_v3_5_DST_GROUP_MAX;
  6843. break;
  6844. case IPA_4_0:
  6845. case IPA_4_0_MHI:
  6846. case IPA_4_1:
  6847. src_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_SRC_MAX;
  6848. dst_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_DST_MAX;
  6849. src_grp_idx_max = IPA_v4_0_SRC_GROUP_MAX;
  6850. dst_grp_idx_max = IPA_v4_0_DST_GROUP_MAX;
  6851. break;
  6852. case IPA_4_2:
  6853. src_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_SRC_MAX;
  6854. dst_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_DST_MAX;
  6855. src_grp_idx_max = IPA_v4_2_SRC_GROUP_MAX;
  6856. dst_grp_idx_max = IPA_v4_2_DST_GROUP_MAX;
  6857. break;
  6858. case IPA_4_5:
  6859. case IPA_4_5_MHI:
  6860. case IPA_4_5_APQ:
  6861. src_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_SRC_MAX;
  6862. dst_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_DST_MAX;
  6863. src_grp_idx_max = IPA_v4_5_SRC_GROUP_MAX;
  6864. dst_grp_idx_max = IPA_v4_5_DST_GROUP_MAX;
  6865. break;
  6866. case IPA_4_7:
  6867. src_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_SRC_MAX;
  6868. dst_rsrc_type_max = IPA_v4_0_RSRC_GRP_TYPE_DST_MAX;
  6869. src_grp_idx_max = IPA_v4_7_SRC_GROUP_MAX;
  6870. dst_grp_idx_max = IPA_v4_7_DST_GROUP_MAX;
  6871. break;
  6872. default:
  6873. IPAERR("invalid hw type index\n");
  6874. WARN_ON(1);
  6875. return;
  6876. }
  6877. IPADBG("Assign source rsrc groups min-max limits\n");
  6878. for (i = 0; i < src_rsrc_type_max; i++) {
  6879. for (j = 0; j < src_grp_idx_max; j = j + 2) {
  6880. val.x_min =
  6881. ipa3_rsrc_src_grp_config[hw_type_idx][i][j].min;
  6882. val.x_max =
  6883. ipa3_rsrc_src_grp_config[hw_type_idx][i][j].max;
  6884. val.y_min =
  6885. ipa3_rsrc_src_grp_config[hw_type_idx][i][j + 1].min;
  6886. val.y_max =
  6887. ipa3_rsrc_src_grp_config[hw_type_idx][i][j + 1].max;
  6888. ipa3_write_rsrc_grp_type_reg(j, i, true, &val);
  6889. }
  6890. }
  6891. IPADBG("Assign destination rsrc groups min-max limits\n");
  6892. for (i = 0; i < dst_rsrc_type_max; i++) {
  6893. for (j = 0; j < dst_grp_idx_max; j = j + 2) {
  6894. val.x_min =
  6895. ipa3_rsrc_dst_grp_config[hw_type_idx][i][j].min;
  6896. val.x_max =
  6897. ipa3_rsrc_dst_grp_config[hw_type_idx][i][j].max;
  6898. val.y_min =
  6899. ipa3_rsrc_dst_grp_config[hw_type_idx][i][j + 1].min;
  6900. val.y_max =
  6901. ipa3_rsrc_dst_grp_config[hw_type_idx][i][j + 1].max;
  6902. ipa3_write_rsrc_grp_type_reg(j, i, false, &val);
  6903. }
  6904. }
  6905. /* move rx_hps resource group configuration from HLOS to TZ
  6906. * on real platform with IPA 3.1 or later
  6907. */
  6908. if (ipa3_ctx->ipa_hw_type < IPA_HW_v3_1 ||
  6909. ipa3_ctx->ipa3_hw_mode == IPA_HW_MODE_VIRTUAL ||
  6910. ipa3_ctx->ipa3_hw_mode == IPA_HW_MODE_EMULATION) {
  6911. ipa3_configure_rx_hps();
  6912. }
  6913. IPADBG("EXIT\n");
  6914. }
  6915. static void ipa3_gsi_poll_after_suspend(struct ipa3_ep_context *ep)
  6916. {
  6917. bool empty;
  6918. IPADBG("switch ch %ld to poll\n", ep->gsi_chan_hdl);
  6919. gsi_config_channel_mode(ep->gsi_chan_hdl, GSI_CHAN_MODE_POLL);
  6920. gsi_is_channel_empty(ep->gsi_chan_hdl, &empty);
  6921. if (!empty) {
  6922. IPADBG("ch %ld not empty\n", ep->gsi_chan_hdl);
  6923. /* queue a work to start polling if don't have one */
  6924. atomic_set(&ipa3_ctx->transport_pm.eot_activity, 1);
  6925. if (!atomic_read(&ep->sys->curr_polling_state))
  6926. __ipa_gsi_irq_rx_scedule_poll(ep->sys);
  6927. }
  6928. }
  6929. static int __ipa3_stop_gsi_channel(u32 clnt_hdl)
  6930. {
  6931. struct ipa_mem_buffer mem;
  6932. int res = 0;
  6933. int i;
  6934. struct ipa3_ep_context *ep;
  6935. enum ipa_client_type client_type;
  6936. struct IpaHwOffloadStatsAllocCmdData_t *gsi_info;
  6937. if (clnt_hdl >= ipa3_ctx->ipa_num_pipes ||
  6938. ipa3_ctx->ep[clnt_hdl].valid == 0) {
  6939. IPAERR("bad parm.\n");
  6940. return -EINVAL;
  6941. }
  6942. ep = &ipa3_ctx->ep[clnt_hdl];
  6943. client_type = ipa3_get_client_mapping(clnt_hdl);
  6944. memset(&mem, 0, sizeof(mem));
  6945. /* stop uC gsi dbg stats monitor */
  6946. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_5 &&
  6947. ipa3_ctx->ipa_hw_type != IPA_HW_v4_7) {
  6948. switch (client_type) {
  6949. case IPA_CLIENT_MHI_PRIME_TETH_PROD:
  6950. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_MHIP];
  6951. gsi_info->ch_id_info[0].ch_id = 0xff;
  6952. gsi_info->ch_id_info[0].dir = DIR_PRODUCER;
  6953. ipa3_uc_debug_stats_alloc(*gsi_info);
  6954. break;
  6955. case IPA_CLIENT_MHI_PRIME_TETH_CONS:
  6956. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_MHIP];
  6957. gsi_info->ch_id_info[1].ch_id = 0xff;
  6958. gsi_info->ch_id_info[1].dir = DIR_CONSUMER;
  6959. ipa3_uc_debug_stats_alloc(*gsi_info);
  6960. break;
  6961. case IPA_CLIENT_MHI_PRIME_RMNET_PROD:
  6962. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_MHIP];
  6963. gsi_info->ch_id_info[2].ch_id = 0xff;
  6964. gsi_info->ch_id_info[2].dir = DIR_PRODUCER;
  6965. ipa3_uc_debug_stats_alloc(*gsi_info);
  6966. break;
  6967. case IPA_CLIENT_MHI_PRIME_RMNET_CONS:
  6968. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_MHIP];
  6969. gsi_info->ch_id_info[3].ch_id = 0xff;
  6970. gsi_info->ch_id_info[3].dir = DIR_CONSUMER;
  6971. ipa3_uc_debug_stats_alloc(*gsi_info);
  6972. break;
  6973. case IPA_CLIENT_USB_PROD:
  6974. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_USB];
  6975. gsi_info->ch_id_info[0].ch_id = 0xff;
  6976. gsi_info->ch_id_info[0].dir = DIR_PRODUCER;
  6977. ipa3_uc_debug_stats_alloc(*gsi_info);
  6978. break;
  6979. case IPA_CLIENT_USB_CONS:
  6980. gsi_info = &ipa3_ctx->gsi_info[IPA_HW_PROTOCOL_USB];
  6981. gsi_info->ch_id_info[1].ch_id = 0xff;
  6982. gsi_info->ch_id_info[1].dir = DIR_CONSUMER;
  6983. ipa3_uc_debug_stats_alloc(*gsi_info);
  6984. break;
  6985. default:
  6986. IPADBG("client_type %d not supported\n",
  6987. client_type);
  6988. }
  6989. }
  6990. if (IPA_CLIENT_IS_PROD(ep->client)) {
  6991. IPADBG("Calling gsi_stop_channel ch:%lu\n",
  6992. ep->gsi_chan_hdl);
  6993. res = gsi_stop_channel(ep->gsi_chan_hdl);
  6994. IPADBG("gsi_stop_channel ch: %lu returned %d\n",
  6995. ep->gsi_chan_hdl, res);
  6996. return res;
  6997. }
  6998. for (i = 0; i < IPA_GSI_CHANNEL_STOP_MAX_RETRY; i++) {
  6999. IPADBG("Calling gsi_stop_channel ch:%lu\n",
  7000. ep->gsi_chan_hdl);
  7001. res = gsi_stop_channel(ep->gsi_chan_hdl);
  7002. IPADBG("gsi_stop_channel ch: %lu returned %d\n",
  7003. ep->gsi_chan_hdl, res);
  7004. if (res != -GSI_STATUS_AGAIN && res != -GSI_STATUS_TIMED_OUT)
  7005. return res;
  7006. /*
  7007. * From >=IPA4.0 version not required to send dma send command,
  7008. * this issue was fixed in latest versions.
  7009. */
  7010. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_0) {
  7011. IPADBG("Inject a DMA_TASK with 1B packet to IPA\n");
  7012. /* Send a 1B packet DMA_TASK to IPA and try again */
  7013. res = ipa3_inject_dma_task_for_gsi();
  7014. if (res) {
  7015. IPAERR("Failed to inject DMA TASk for GSI\n");
  7016. return res;
  7017. }
  7018. }
  7019. /* sleep for short period to flush IPA */
  7020. usleep_range(IPA_GSI_CHANNEL_STOP_SLEEP_MIN_USEC,
  7021. IPA_GSI_CHANNEL_STOP_SLEEP_MAX_USEC);
  7022. }
  7023. IPAERR("Failed to stop GSI channel with retries\n");
  7024. return -EFAULT;
  7025. }
  7026. /**
  7027. * ipa3_stop_gsi_channel()- Stops a GSI channel in IPA
  7028. * @chan_hdl: GSI channel handle
  7029. *
  7030. * This function implements the sequence to stop a GSI channel
  7031. * in IPA. This function returns when the channel is in STOP state.
  7032. *
  7033. * Return value: 0 on success, negative otherwise
  7034. */
  7035. int ipa3_stop_gsi_channel(u32 clnt_hdl)
  7036. {
  7037. int res;
  7038. IPA_ACTIVE_CLIENTS_INC_EP(ipa3_get_client_mapping(clnt_hdl));
  7039. res = __ipa3_stop_gsi_channel(clnt_hdl);
  7040. IPA_ACTIVE_CLIENTS_DEC_EP(ipa3_get_client_mapping(clnt_hdl));
  7041. return res;
  7042. }
  7043. void ipa3_suspend_apps_pipes(bool suspend)
  7044. {
  7045. struct ipa_ep_cfg_ctrl cfg;
  7046. int ipa_ep_idx;
  7047. struct ipa3_ep_context *ep;
  7048. int res;
  7049. memset(&cfg, 0, sizeof(cfg));
  7050. cfg.ipa_ep_suspend = suspend;
  7051. ipa_ep_idx = ipa3_get_ep_mapping(IPA_CLIENT_APPS_LAN_CONS);
  7052. if (ipa_ep_idx < 0) {
  7053. IPAERR("IPA client mapping failed\n");
  7054. ipa_assert();
  7055. return;
  7056. }
  7057. ep = &ipa3_ctx->ep[ipa_ep_idx];
  7058. if (ep->valid) {
  7059. IPADBG("%s pipe %d\n", suspend ? "suspend" : "unsuspend",
  7060. ipa_ep_idx);
  7061. /*
  7062. * move the channel to callback mode.
  7063. * This needs to happen before starting the channel to make
  7064. * sure we don't loose any interrupt
  7065. */
  7066. if (!suspend && !atomic_read(&ep->sys->curr_polling_state))
  7067. gsi_config_channel_mode(ep->gsi_chan_hdl,
  7068. GSI_CHAN_MODE_CALLBACK);
  7069. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  7070. if (suspend) {
  7071. res = __ipa3_stop_gsi_channel(ipa_ep_idx);
  7072. if (res) {
  7073. IPAERR("failed to stop LAN channel\n");
  7074. ipa_assert();
  7075. }
  7076. } else {
  7077. res = gsi_start_channel(ep->gsi_chan_hdl);
  7078. if (res) {
  7079. IPAERR("failed to start LAN channel\n");
  7080. ipa_assert();
  7081. }
  7082. }
  7083. } else {
  7084. ipa3_cfg_ep_ctrl(ipa_ep_idx, &cfg);
  7085. }
  7086. if (suspend)
  7087. ipa3_gsi_poll_after_suspend(ep);
  7088. }
  7089. ipa_ep_idx = ipa_get_ep_mapping(IPA_CLIENT_APPS_WAN_CONS);
  7090. /* Considering the case for SSR. */
  7091. if (ipa_ep_idx == -1) {
  7092. IPADBG("Invalid mapping for IPA_CLIENT_APPS_WAN_CONS\n");
  7093. return;
  7094. }
  7095. ep = &ipa3_ctx->ep[ipa_ep_idx];
  7096. if (ep->valid) {
  7097. IPADBG("%s pipe %d\n", suspend ? "suspend" : "unsuspend",
  7098. ipa_ep_idx);
  7099. /*
  7100. * move the channel to callback mode.
  7101. * This needs to happen before starting the channel to make
  7102. * sure we don't loose any interrupt
  7103. */
  7104. if (!suspend && !atomic_read(&ep->sys->curr_polling_state))
  7105. gsi_config_channel_mode(ep->gsi_chan_hdl,
  7106. GSI_CHAN_MODE_CALLBACK);
  7107. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  7108. if (suspend) {
  7109. res = __ipa3_stop_gsi_channel(ipa_ep_idx);
  7110. if (res) {
  7111. IPAERR("failed to stop WAN channel\n");
  7112. ipa_assert();
  7113. }
  7114. } else if (!atomic_read(&ipa3_ctx->is_ssr)) {
  7115. /* If SSR was alreday started not required to
  7116. * start WAN channel,Because in SSR will stop
  7117. * channel and reset the channel.
  7118. */
  7119. res = gsi_start_channel(ep->gsi_chan_hdl);
  7120. if (res) {
  7121. IPAERR("failed to start WAN channel\n");
  7122. ipa_assert();
  7123. }
  7124. }
  7125. } else {
  7126. ipa3_cfg_ep_ctrl(ipa_ep_idx, &cfg);
  7127. }
  7128. if (suspend)
  7129. ipa3_gsi_poll_after_suspend(ep);
  7130. }
  7131. ipa_ep_idx = ipa_get_ep_mapping(IPA_CLIENT_ODL_DPL_CONS);
  7132. /* Considering the case for SSR. */
  7133. if (ipa_ep_idx == -1) {
  7134. IPADBG("Invalid mapping for IPA_CLIENT_ODL_DPL_CONS\n");
  7135. return;
  7136. }
  7137. ep = &ipa3_ctx->ep[ipa_ep_idx];
  7138. if (ep->valid) {
  7139. IPADBG("%s pipe %d\n", suspend ? "suspend" : "unsuspend",
  7140. ipa_ep_idx);
  7141. /*
  7142. * move the channel to callback mode.
  7143. * This needs to happen before starting the channel to make
  7144. * sure we don't loose any interrupt
  7145. */
  7146. if (!suspend && !atomic_read(&ep->sys->curr_polling_state))
  7147. gsi_config_channel_mode(ep->gsi_chan_hdl,
  7148. GSI_CHAN_MODE_CALLBACK);
  7149. if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_0) {
  7150. if (suspend) {
  7151. res = __ipa3_stop_gsi_channel(ipa_ep_idx);
  7152. if (res) {
  7153. IPAERR("failed to stop ODL channel\n");
  7154. ipa_assert();
  7155. }
  7156. } else if (!atomic_read(&ipa3_ctx->is_ssr)) {
  7157. /* If SSR was alreday started not required to
  7158. * start WAN channel,Because in SSR will stop
  7159. * channel and reset the channel.
  7160. */
  7161. res = gsi_start_channel(ep->gsi_chan_hdl);
  7162. if (res) {
  7163. IPAERR("failed to start ODL channel\n");
  7164. ipa_assert();
  7165. }
  7166. }
  7167. } else {
  7168. ipa3_cfg_ep_ctrl(ipa_ep_idx, &cfg);
  7169. }
  7170. if (suspend)
  7171. ipa3_gsi_poll_after_suspend(ep);
  7172. }
  7173. }
  7174. int ipa3_allocate_dma_task_for_gsi(void)
  7175. {
  7176. struct ipahal_imm_cmd_dma_task_32b_addr cmd = { 0 };
  7177. IPADBG("Allocate mem\n");
  7178. ipa3_ctx->dma_task_info.mem.size = IPA_GSI_CHANNEL_STOP_PKT_SIZE;
  7179. ipa3_ctx->dma_task_info.mem.base = dma_alloc_coherent(ipa3_ctx->pdev,
  7180. ipa3_ctx->dma_task_info.mem.size,
  7181. &ipa3_ctx->dma_task_info.mem.phys_base,
  7182. GFP_KERNEL);
  7183. if (!ipa3_ctx->dma_task_info.mem.base) {
  7184. IPAERR("no mem\n");
  7185. return -EFAULT;
  7186. }
  7187. cmd.flsh = true;
  7188. cmd.size1 = ipa3_ctx->dma_task_info.mem.size;
  7189. cmd.addr1 = ipa3_ctx->dma_task_info.mem.phys_base;
  7190. cmd.packet_size = ipa3_ctx->dma_task_info.mem.size;
  7191. ipa3_ctx->dma_task_info.cmd_pyld = ipahal_construct_imm_cmd(
  7192. IPA_IMM_CMD_DMA_TASK_32B_ADDR, &cmd, false);
  7193. if (!ipa3_ctx->dma_task_info.cmd_pyld) {
  7194. IPAERR("failed to construct dma_task_32b_addr cmd\n");
  7195. dma_free_coherent(ipa3_ctx->pdev,
  7196. ipa3_ctx->dma_task_info.mem.size,
  7197. ipa3_ctx->dma_task_info.mem.base,
  7198. ipa3_ctx->dma_task_info.mem.phys_base);
  7199. memset(&ipa3_ctx->dma_task_info, 0,
  7200. sizeof(ipa3_ctx->dma_task_info));
  7201. return -EFAULT;
  7202. }
  7203. return 0;
  7204. }
  7205. void ipa3_free_dma_task_for_gsi(void)
  7206. {
  7207. dma_free_coherent(ipa3_ctx->pdev,
  7208. ipa3_ctx->dma_task_info.mem.size,
  7209. ipa3_ctx->dma_task_info.mem.base,
  7210. ipa3_ctx->dma_task_info.mem.phys_base);
  7211. ipahal_destroy_imm_cmd(ipa3_ctx->dma_task_info.cmd_pyld);
  7212. memset(&ipa3_ctx->dma_task_info, 0, sizeof(ipa3_ctx->dma_task_info));
  7213. }
  7214. /**
  7215. * ipa3_inject_dma_task_for_gsi()- Send DMA_TASK to IPA for GSI stop channel
  7216. *
  7217. * Send a DMA_TASK of 1B to IPA to unblock GSI channel in STOP_IN_PROG.
  7218. * Return value: 0 on success, negative otherwise
  7219. */
  7220. int ipa3_inject_dma_task_for_gsi(void)
  7221. {
  7222. struct ipa3_desc desc;
  7223. ipa3_init_imm_cmd_desc(&desc, ipa3_ctx->dma_task_info.cmd_pyld);
  7224. IPADBG("sending 1B packet to IPA\n");
  7225. if (ipa3_send_cmd_timeout(1, &desc,
  7226. IPA_DMA_TASK_FOR_GSI_TIMEOUT_MSEC)) {
  7227. IPAERR("ipa3_send_cmd failed\n");
  7228. return -EFAULT;
  7229. }
  7230. return 0;
  7231. }
  7232. static int ipa3_load_single_fw(const struct firmware *firmware,
  7233. const struct elf32_phdr *phdr)
  7234. {
  7235. uint32_t *fw_mem_base;
  7236. int index;
  7237. const uint32_t *elf_data_ptr;
  7238. if (phdr->p_offset > firmware->size) {
  7239. IPAERR("Invalid ELF: offset=%u is beyond elf_size=%zu\n",
  7240. phdr->p_offset, firmware->size);
  7241. return -EINVAL;
  7242. }
  7243. if ((firmware->size - phdr->p_offset) < phdr->p_filesz) {
  7244. IPAERR("Invalid ELF: offset=%u filesz=%u elf_size=%zu\n",
  7245. phdr->p_offset, phdr->p_filesz, firmware->size);
  7246. return -EINVAL;
  7247. }
  7248. if (phdr->p_memsz % sizeof(uint32_t)) {
  7249. IPAERR("FW mem size %u doesn't align to 32bit\n",
  7250. phdr->p_memsz);
  7251. return -EFAULT;
  7252. }
  7253. if (phdr->p_filesz > phdr->p_memsz) {
  7254. IPAERR("FW image too big src_size=%u dst_size=%u\n",
  7255. phdr->p_filesz, phdr->p_memsz);
  7256. return -EFAULT;
  7257. }
  7258. fw_mem_base = ioremap(phdr->p_vaddr, phdr->p_memsz);
  7259. if (!fw_mem_base) {
  7260. IPAERR("Failed to map 0x%x for the size of %u\n",
  7261. phdr->p_vaddr, phdr->p_memsz);
  7262. return -ENOMEM;
  7263. }
  7264. /* Set the entire region to 0s */
  7265. memset(fw_mem_base, 0, phdr->p_memsz);
  7266. elf_data_ptr = (uint32_t *)(firmware->data + phdr->p_offset);
  7267. /* Write the FW */
  7268. for (index = 0; index < phdr->p_filesz/sizeof(uint32_t); index++) {
  7269. writel_relaxed(*elf_data_ptr, &fw_mem_base[index]);
  7270. elf_data_ptr++;
  7271. }
  7272. iounmap(fw_mem_base);
  7273. return 0;
  7274. }
  7275. struct ipa3_hps_dps_areas_info {
  7276. u32 dps_abs_addr;
  7277. u32 dps_sz;
  7278. u32 hps_abs_addr;
  7279. u32 hps_sz;
  7280. };
  7281. static void ipa3_get_hps_dps_areas_absolute_addr_and_sz(
  7282. struct ipa3_hps_dps_areas_info *info)
  7283. {
  7284. u32 dps_area_start;
  7285. u32 dps_area_end;
  7286. u32 hps_area_start;
  7287. u32 hps_area_end;
  7288. if (ipa3_ctx->ipa_hw_type < IPA_HW_v4_5) {
  7289. dps_area_start = ipahal_get_reg_ofst(IPA_DPS_SEQUENCER_FIRST);
  7290. dps_area_end = ipahal_get_reg_ofst(IPA_DPS_SEQUENCER_LAST);
  7291. hps_area_start = ipahal_get_reg_ofst(IPA_HPS_SEQUENCER_FIRST);
  7292. hps_area_end = ipahal_get_reg_ofst(IPA_HPS_SEQUENCER_LAST);
  7293. info->dps_abs_addr = ipa3_ctx->ipa_wrapper_base +
  7294. ipahal_get_reg_base() + dps_area_start;
  7295. info->hps_abs_addr = ipa3_ctx->ipa_wrapper_base +
  7296. ipahal_get_reg_base() + hps_area_start;
  7297. } else {
  7298. dps_area_start = ipahal_read_reg(IPA_DPS_SEQUENCER_FIRST);
  7299. dps_area_end = ipahal_read_reg(IPA_DPS_SEQUENCER_LAST);
  7300. hps_area_start = ipahal_read_reg(IPA_HPS_SEQUENCER_FIRST);
  7301. hps_area_end = ipahal_read_reg(IPA_HPS_SEQUENCER_LAST);
  7302. info->dps_abs_addr = ipa3_ctx->ipa_wrapper_base +
  7303. dps_area_start;
  7304. info->hps_abs_addr = ipa3_ctx->ipa_wrapper_base +
  7305. hps_area_start;
  7306. }
  7307. info->dps_sz = dps_area_end - dps_area_start + sizeof(u32);
  7308. info->hps_sz = hps_area_end - hps_area_start + sizeof(u32);
  7309. IPADBG("dps area: start offset=0x%x end offset=0x%x\n",
  7310. dps_area_start, dps_area_end);
  7311. IPADBG("hps area: start offset=0x%x end offset=0x%x\n",
  7312. hps_area_start, hps_area_end);
  7313. }
  7314. /**
  7315. * emulator_load_single_fw() - load firmware into emulator's memory
  7316. *
  7317. * @firmware: Structure which contains the FW data from the user space.
  7318. * @phdr: ELF program header
  7319. * @loc_to_map: physical location to map into virtual space
  7320. * @size_to_map: the size of memory to map into virtual space
  7321. *
  7322. * Return value: 0 on success, negative otherwise
  7323. */
  7324. static int emulator_load_single_fw(
  7325. const struct firmware *firmware,
  7326. const struct elf32_phdr *phdr,
  7327. u32 loc_to_map,
  7328. u32 size_to_map)
  7329. {
  7330. int index;
  7331. uint32_t ofb;
  7332. const uint32_t *elf_data_ptr;
  7333. void __iomem *fw_base;
  7334. IPADBG("firmware(%pK) phdr(%pK) loc_to_map(0x%X) size_to_map(%u)\n",
  7335. firmware, phdr, loc_to_map, size_to_map);
  7336. if (phdr->p_offset > firmware->size) {
  7337. IPAERR("Invalid ELF: offset=%u is beyond elf_size=%zu\n",
  7338. phdr->p_offset, firmware->size);
  7339. return -EINVAL;
  7340. }
  7341. if ((firmware->size - phdr->p_offset) < phdr->p_filesz) {
  7342. IPAERR("Invalid ELF: offset=%u filesz=%u elf_size=%zu\n",
  7343. phdr->p_offset, phdr->p_filesz, firmware->size);
  7344. return -EINVAL;
  7345. }
  7346. if (phdr->p_memsz % sizeof(uint32_t)) {
  7347. IPAERR("FW mem size %u doesn't align to 32bit\n",
  7348. phdr->p_memsz);
  7349. return -EFAULT;
  7350. }
  7351. if (phdr->p_filesz > phdr->p_memsz) {
  7352. IPAERR("FW image too big src_size=%u dst_size=%u\n",
  7353. phdr->p_filesz, phdr->p_memsz);
  7354. return -EFAULT;
  7355. }
  7356. IPADBG("ELF: p_memsz(0x%x) p_filesz(0x%x) p_filesz/4(0x%x)\n",
  7357. (uint32_t) phdr->p_memsz,
  7358. (uint32_t) phdr->p_filesz,
  7359. (uint32_t) (phdr->p_filesz/sizeof(uint32_t)));
  7360. fw_base = ioremap(loc_to_map, size_to_map);
  7361. if (!fw_base) {
  7362. IPAERR("Failed to map 0x%X for the size of %u\n",
  7363. loc_to_map, size_to_map);
  7364. return -ENOMEM;
  7365. }
  7366. IPADBG("Physical base(0x%X) mapped to virtual (%pK) with len (%u)\n",
  7367. loc_to_map,
  7368. fw_base,
  7369. size_to_map);
  7370. /* Set the entire region to 0s */
  7371. ofb = 0;
  7372. for (index = 0; index < phdr->p_memsz/sizeof(uint32_t); index++) {
  7373. writel_relaxed(0, fw_base + ofb);
  7374. ofb += sizeof(uint32_t);
  7375. }
  7376. elf_data_ptr = (uint32_t *)(firmware->data + phdr->p_offset);
  7377. /* Write the FW */
  7378. ofb = 0;
  7379. for (index = 0; index < phdr->p_filesz/sizeof(uint32_t); index++) {
  7380. writel_relaxed(*elf_data_ptr, fw_base + ofb);
  7381. elf_data_ptr++;
  7382. ofb += sizeof(uint32_t);
  7383. }
  7384. iounmap(fw_base);
  7385. return 0;
  7386. }
  7387. /**
  7388. * ipa3_load_fws() - Load the IPAv3 FWs into IPA&GSI SRAM.
  7389. *
  7390. * @firmware: Structure which contains the FW data from the user space.
  7391. * @gsi_mem_base: GSI base address
  7392. * @gsi_ver: GSI Version
  7393. *
  7394. * Return value: 0 on success, negative otherwise
  7395. *
  7396. */
  7397. int ipa3_load_fws(const struct firmware *firmware, phys_addr_t gsi_mem_base,
  7398. enum gsi_ver gsi_ver)
  7399. {
  7400. const struct elf32_hdr *ehdr;
  7401. const struct elf32_phdr *phdr;
  7402. unsigned long gsi_iram_ofst;
  7403. unsigned long gsi_iram_size;
  7404. int rc;
  7405. struct ipa3_hps_dps_areas_info dps_hps_info;
  7406. if (gsi_ver == GSI_VER_ERR) {
  7407. IPAERR("Invalid GSI Version\n");
  7408. return -EINVAL;
  7409. }
  7410. if (!gsi_mem_base) {
  7411. IPAERR("Invalid GSI base address\n");
  7412. return -EINVAL;
  7413. }
  7414. ipa_assert_on(!firmware);
  7415. /* One program header per FW image: GSI, DPS and HPS */
  7416. if (firmware->size < (sizeof(*ehdr) + 3 * sizeof(*phdr))) {
  7417. IPAERR("Missing ELF and Program headers firmware size=%zu\n",
  7418. firmware->size);
  7419. return -EINVAL;
  7420. }
  7421. ehdr = (struct elf32_hdr *) firmware->data;
  7422. ipa_assert_on(!ehdr);
  7423. if (ehdr->e_phnum != 3) {
  7424. IPAERR("Unexpected number of ELF program headers\n");
  7425. return -EINVAL;
  7426. }
  7427. phdr = (struct elf32_phdr *)(firmware->data + sizeof(*ehdr));
  7428. /*
  7429. * Each ELF program header represents a FW image and contains:
  7430. * p_vaddr : The starting address to which the FW needs to loaded.
  7431. * p_memsz : The size of the IRAM (where the image loaded)
  7432. * p_filesz: The size of the FW image embedded inside the ELF
  7433. * p_offset: Absolute offset to the image from the head of the ELF
  7434. */
  7435. /* Load GSI FW image */
  7436. gsi_get_inst_ram_offset_and_size(&gsi_iram_ofst, &gsi_iram_size,
  7437. gsi_ver);
  7438. if (phdr->p_vaddr != (gsi_mem_base + gsi_iram_ofst)) {
  7439. IPAERR(
  7440. "Invalid GSI FW img load addr vaddr=0x%x gsi_mem_base=%pa gsi_iram_ofst=0x%lx\n"
  7441. , phdr->p_vaddr, &gsi_mem_base, gsi_iram_ofst);
  7442. return -EINVAL;
  7443. }
  7444. if (phdr->p_memsz > gsi_iram_size) {
  7445. IPAERR("Invalid GSI FW img size memsz=%d gsi_iram_size=%lu\n",
  7446. phdr->p_memsz, gsi_iram_size);
  7447. return -EINVAL;
  7448. }
  7449. rc = ipa3_load_single_fw(firmware, phdr);
  7450. if (rc)
  7451. return rc;
  7452. phdr++;
  7453. ipa3_get_hps_dps_areas_absolute_addr_and_sz(&dps_hps_info);
  7454. /* Load IPA DPS FW image */
  7455. if (phdr->p_vaddr != dps_hps_info.dps_abs_addr) {
  7456. IPAERR(
  7457. "Invalid IPA DPS img load addr vaddr=0x%x dps_abs_addr=0x%x\n"
  7458. , phdr->p_vaddr, dps_hps_info.dps_abs_addr);
  7459. return -EINVAL;
  7460. }
  7461. if (phdr->p_memsz > dps_hps_info.dps_sz) {
  7462. IPAERR("Invalid IPA DPS img size memsz=%d dps_area_size=%u\n",
  7463. phdr->p_memsz, dps_hps_info.dps_sz);
  7464. return -EINVAL;
  7465. }
  7466. rc = ipa3_load_single_fw(firmware, phdr);
  7467. if (rc)
  7468. return rc;
  7469. phdr++;
  7470. /* Load IPA HPS FW image */
  7471. if (phdr->p_vaddr != dps_hps_info.hps_abs_addr) {
  7472. IPAERR(
  7473. "Invalid IPA HPS img load addr vaddr=0x%x hps_abs_addr=0x%x\n"
  7474. , phdr->p_vaddr, dps_hps_info.hps_abs_addr);
  7475. return -EINVAL;
  7476. }
  7477. if (phdr->p_memsz > dps_hps_info.hps_sz) {
  7478. IPAERR("Invalid IPA HPS img size memsz=%d hps_area_size=%u\n",
  7479. phdr->p_memsz, dps_hps_info.hps_sz);
  7480. return -EINVAL;
  7481. }
  7482. rc = ipa3_load_single_fw(firmware, phdr);
  7483. if (rc)
  7484. return rc;
  7485. IPADBG("IPA FWs (GSI FW, DPS and HPS) loaded successfully\n");
  7486. return 0;
  7487. }
  7488. /*
  7489. * The following needed for the EMULATION system. On a non-emulation
  7490. * system (ie. the real UE), this functionality is done in the
  7491. * TZ...
  7492. */
  7493. static void ipa_gsi_setup_reg(void)
  7494. {
  7495. u32 reg_val, start;
  7496. int i;
  7497. const struct ipa_gsi_ep_config *gsi_ep_info_cfg;
  7498. enum ipa_client_type type;
  7499. IPADBG("Setting up registers in preparation for firmware download\n");
  7500. /* setup IPA_ENDP_GSI_CFG_TLV_n reg */
  7501. start = 0;
  7502. ipa3_ctx->ipa_num_pipes = ipa3_get_num_pipes();
  7503. IPADBG("ipa_num_pipes=%u\n", ipa3_ctx->ipa_num_pipes);
  7504. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
  7505. type = ipa3_get_client_by_pipe(i);
  7506. gsi_ep_info_cfg = ipa3_get_gsi_ep_info(type);
  7507. IPAERR("for ep %d client is %d gsi_ep_info_cfg=%pK\n",
  7508. i, type, gsi_ep_info_cfg);
  7509. if (!gsi_ep_info_cfg)
  7510. continue;
  7511. reg_val = ((gsi_ep_info_cfg->ipa_if_tlv << 16) & 0x00FF0000);
  7512. reg_val += (start & 0xFFFF);
  7513. start += gsi_ep_info_cfg->ipa_if_tlv;
  7514. ipahal_write_reg_n(IPA_ENDP_GSI_CFG_TLV_n, i, reg_val);
  7515. }
  7516. /* setup IPA_ENDP_GSI_CFG_AOS_n reg */
  7517. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
  7518. type = ipa3_get_client_by_pipe(i);
  7519. gsi_ep_info_cfg = ipa3_get_gsi_ep_info(type);
  7520. if (!gsi_ep_info_cfg)
  7521. continue;
  7522. reg_val = ((gsi_ep_info_cfg->ipa_if_aos << 16) & 0x00FF0000);
  7523. reg_val += (start & 0xFFFF);
  7524. start += gsi_ep_info_cfg->ipa_if_aos;
  7525. ipahal_write_reg_n(IPA_ENDP_GSI_CFG_AOS_n, i, reg_val);
  7526. }
  7527. /* setup GSI_MAP_EE_n_CH_k_VP_TABLE reg */
  7528. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
  7529. type = ipa3_get_client_by_pipe(i);
  7530. gsi_ep_info_cfg = ipa3_get_gsi_ep_info(type);
  7531. if (!gsi_ep_info_cfg)
  7532. continue;
  7533. reg_val = i & 0x1F;
  7534. gsi_map_virtual_ch_to_per_ep(
  7535. gsi_ep_info_cfg->ee,
  7536. gsi_ep_info_cfg->ipa_gsi_chan_num,
  7537. reg_val);
  7538. }
  7539. /* setup IPA_ENDP_GSI_CFG1_n reg */
  7540. for (i = 0; i < ipa3_ctx->ipa_num_pipes; i++) {
  7541. type = ipa3_get_client_by_pipe(i);
  7542. gsi_ep_info_cfg = ipa3_get_gsi_ep_info(type);
  7543. if (!gsi_ep_info_cfg)
  7544. continue;
  7545. reg_val = (1 << 31) + (1 << 16);
  7546. ipahal_write_reg_n(IPA_ENDP_GSI_CFG1_n, i, 1<<16);
  7547. ipahal_write_reg_n(IPA_ENDP_GSI_CFG1_n, i, reg_val);
  7548. ipahal_write_reg_n(IPA_ENDP_GSI_CFG1_n, i, 1<<16);
  7549. }
  7550. }
  7551. /**
  7552. * emulator_load_fws() - Load the IPAv3 FWs into IPA&GSI SRAM.
  7553. *
  7554. * @firmware: Structure which contains the FW data from the user space.
  7555. * @transport_mem_base: Where to load
  7556. * @transport_mem_size: Space available to load into
  7557. * @gsi_ver: Version of the gsi
  7558. *
  7559. * Return value: 0 on success, negative otherwise
  7560. */
  7561. int emulator_load_fws(
  7562. const struct firmware *firmware,
  7563. u32 transport_mem_base,
  7564. u32 transport_mem_size,
  7565. enum gsi_ver gsi_ver)
  7566. {
  7567. const struct elf32_hdr *ehdr;
  7568. const struct elf32_phdr *phdr;
  7569. unsigned long gsi_offset, gsi_ram_size;
  7570. struct ipa3_hps_dps_areas_info dps_hps_info;
  7571. int rc;
  7572. IPADBG("Loading firmware(%pK)\n", firmware);
  7573. if (!firmware) {
  7574. IPAERR("firmware pointer passed to function is NULL\n");
  7575. return -EINVAL;
  7576. }
  7577. /* One program header per FW image: GSI, DPS and HPS */
  7578. if (firmware->size < (sizeof(*ehdr) + 3 * sizeof(*phdr))) {
  7579. IPAERR(
  7580. "Missing ELF and Program headers firmware size=%zu\n",
  7581. firmware->size);
  7582. return -EINVAL;
  7583. }
  7584. ehdr = (struct elf32_hdr *) firmware->data;
  7585. ipa_assert_on(!ehdr);
  7586. if (ehdr->e_phnum != 3) {
  7587. IPAERR("Unexpected number of ELF program headers\n");
  7588. return -EINVAL;
  7589. }
  7590. ipa3_get_hps_dps_areas_absolute_addr_and_sz(&dps_hps_info);
  7591. /*
  7592. * Each ELF program header represents a FW image and contains:
  7593. * p_vaddr : The starting address to which the FW needs to loaded.
  7594. * p_memsz : The size of the IRAM (where the image loaded)
  7595. * p_filesz: The size of the FW image embedded inside the ELF
  7596. * p_offset: Absolute offset to the image from the head of the ELF
  7597. *
  7598. * NOTE WELL: On the emulation platform, the p_vaddr address
  7599. * is not relevant and is unused. This is because
  7600. * on the emulation platform, the registers'
  7601. * address location is mutable, since it's mapped
  7602. * in via a PCIe probe. Given this, it is the
  7603. * mapped address info that's used while p_vaddr is
  7604. * ignored.
  7605. */
  7606. phdr = (struct elf32_phdr *)(firmware->data + sizeof(*ehdr));
  7607. phdr += 2;
  7608. /*
  7609. * Attempt to load IPA HPS FW image
  7610. */
  7611. if (phdr->p_memsz > dps_hps_info.hps_sz) {
  7612. IPAERR("Invalid IPA HPS img size memsz=%d hps_size=%u\n",
  7613. phdr->p_memsz, dps_hps_info.hps_sz);
  7614. return -EINVAL;
  7615. }
  7616. IPADBG("Loading HPS FW\n");
  7617. rc = emulator_load_single_fw(
  7618. firmware, phdr,
  7619. dps_hps_info.hps_abs_addr, dps_hps_info.hps_sz);
  7620. if (rc)
  7621. return rc;
  7622. IPADBG("Loading HPS FW complete\n");
  7623. --phdr;
  7624. /*
  7625. * Attempt to load IPA DPS FW image
  7626. */
  7627. if (phdr->p_memsz > dps_hps_info.dps_sz) {
  7628. IPAERR("Invalid IPA DPS img size memsz=%d dps_size=%u\n",
  7629. phdr->p_memsz, dps_hps_info.dps_sz);
  7630. return -EINVAL;
  7631. }
  7632. IPADBG("Loading DPS FW\n");
  7633. rc = emulator_load_single_fw(
  7634. firmware, phdr,
  7635. dps_hps_info.dps_abs_addr, dps_hps_info.dps_sz);
  7636. if (rc)
  7637. return rc;
  7638. IPADBG("Loading DPS FW complete\n");
  7639. /*
  7640. * Run gsi register setup which is normally done in TZ on
  7641. * non-EMULATION systems...
  7642. */
  7643. ipa_gsi_setup_reg();
  7644. --phdr;
  7645. gsi_get_inst_ram_offset_and_size(&gsi_offset, &gsi_ram_size, gsi_ver);
  7646. /*
  7647. * Attempt to load GSI FW image
  7648. */
  7649. if (phdr->p_memsz > gsi_ram_size) {
  7650. IPAERR(
  7651. "Invalid GSI FW img size memsz=%d gsi_ram_size=%lu\n",
  7652. phdr->p_memsz, gsi_ram_size);
  7653. return -EINVAL;
  7654. }
  7655. IPADBG("Loading GSI FW\n");
  7656. rc = emulator_load_single_fw(
  7657. firmware, phdr,
  7658. transport_mem_base + (u32) gsi_offset, gsi_ram_size);
  7659. if (rc)
  7660. return rc;
  7661. IPADBG("Loading GSI FW complete\n");
  7662. IPADBG("IPA FWs (GSI FW, DPS and HPS) loaded successfully\n");
  7663. return 0;
  7664. }
  7665. /**
  7666. * ipa3_is_apq() - indicate apq platform or not
  7667. *
  7668. * Return value: true if apq, false if not apq platform
  7669. *
  7670. */
  7671. bool ipa3_is_apq(void)
  7672. {
  7673. if (ipa3_ctx->platform_type == IPA_PLAT_TYPE_APQ)
  7674. return true;
  7675. else
  7676. return false;
  7677. }
  7678. /**
  7679. * ipa3_disable_prefetch() - disable\enable tx prefetch
  7680. *
  7681. * @client: the client which is related to the TX where prefetch will be
  7682. * disabled
  7683. *
  7684. * Return value: Non applicable
  7685. *
  7686. */
  7687. void ipa3_disable_prefetch(enum ipa_client_type client)
  7688. {
  7689. struct ipahal_reg_tx_cfg cfg;
  7690. u8 qmb;
  7691. qmb = ipa3_get_qmb_master_sel(client);
  7692. IPADBG("disabling prefetch for qmb %d\n", (int)qmb);
  7693. ipahal_read_reg_fields(IPA_TX_CFG, &cfg);
  7694. /* QMB0 (DDR) correlates with TX0, QMB1(PCIE) correlates with TX1 */
  7695. if (qmb == QMB_MASTER_SELECT_DDR)
  7696. cfg.tx0_prefetch_disable = true;
  7697. else
  7698. cfg.tx1_prefetch_disable = true;
  7699. ipahal_write_reg_fields(IPA_TX_CFG, &cfg);
  7700. }
  7701. /**
  7702. * ipa3_get_pdev() - return a pointer to IPA dev struct
  7703. *
  7704. * Return value: a pointer to IPA dev struct
  7705. *
  7706. */
  7707. struct device *ipa3_get_pdev(void)
  7708. {
  7709. if (!ipa3_ctx)
  7710. return NULL;
  7711. return ipa3_ctx->pdev;
  7712. }
  7713. /**
  7714. * ipa3_enable_dcd() - enable dynamic clock division on IPA
  7715. *
  7716. * Return value: Non applicable
  7717. *
  7718. */
  7719. void ipa3_enable_dcd(void)
  7720. {
  7721. struct ipahal_reg_idle_indication_cfg idle_indication_cfg;
  7722. /* recommended values for IPA 3.5 according to IPA HPG */
  7723. idle_indication_cfg.const_non_idle_enable = false;
  7724. idle_indication_cfg.enter_idle_debounce_thresh = 256;
  7725. ipahal_write_reg_fields(IPA_IDLE_INDICATION_CFG,
  7726. &idle_indication_cfg);
  7727. }
  7728. void ipa3_init_imm_cmd_desc(struct ipa3_desc *desc,
  7729. struct ipahal_imm_cmd_pyld *cmd_pyld)
  7730. {
  7731. memset(desc, 0, sizeof(*desc));
  7732. desc->opcode = cmd_pyld->opcode;
  7733. desc->pyld = cmd_pyld->data;
  7734. desc->len = cmd_pyld->len;
  7735. desc->type = IPA_IMM_CMD_DESC;
  7736. }
  7737. u32 ipa3_get_r_rev_version(void)
  7738. {
  7739. static u32 r_rev;
  7740. if (r_rev != 0)
  7741. return r_rev;
  7742. IPA_ACTIVE_CLIENTS_INC_SIMPLE();
  7743. r_rev = ipahal_read_reg(IPA_VERSION);
  7744. IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
  7745. return r_rev;
  7746. }