reg.h 372 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937
  1. /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
  2. /* Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved */
  3. #ifndef _MLXSW_REG_H
  4. #define _MLXSW_REG_H
  5. #include <linux/kernel.h>
  6. #include <linux/string.h>
  7. #include <linux/bitops.h>
  8. #include <linux/if_vlan.h>
  9. #include "item.h"
  10. #include "port.h"
  11. struct mlxsw_reg_info {
  12. u16 id;
  13. u16 len; /* In u8 */
  14. const char *name;
  15. };
  16. #define MLXSW_REG_DEFINE(_name, _id, _len) \
  17. static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
  18. .id = _id, \
  19. .len = _len, \
  20. .name = #_name, \
  21. }
  22. #define MLXSW_REG(type) (&mlxsw_reg_##type)
  23. #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
  24. #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
  25. /* SGCR - Switch General Configuration Register
  26. * --------------------------------------------
  27. * This register is used for configuration of the switch capabilities.
  28. */
  29. #define MLXSW_REG_SGCR_ID 0x2000
  30. #define MLXSW_REG_SGCR_LEN 0x10
  31. MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
  32. /* reg_sgcr_llb
  33. * Link Local Broadcast (Default=0)
  34. * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
  35. * packets and ignore the IGMP snooping entries.
  36. * Access: RW
  37. */
  38. MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
  39. static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
  40. {
  41. MLXSW_REG_ZERO(sgcr, payload);
  42. mlxsw_reg_sgcr_llb_set(payload, !!llb);
  43. }
  44. /* SPAD - Switch Physical Address Register
  45. * ---------------------------------------
  46. * The SPAD register configures the switch physical MAC address.
  47. */
  48. #define MLXSW_REG_SPAD_ID 0x2002
  49. #define MLXSW_REG_SPAD_LEN 0x10
  50. MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
  51. /* reg_spad_base_mac
  52. * Base MAC address for the switch partitions.
  53. * Per switch partition MAC address is equal to:
  54. * base_mac + swid
  55. * Access: RW
  56. */
  57. MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
  58. /* SSPR - Switch System Port Record Register
  59. * -----------------------------------------
  60. * Configures the system port to local port mapping.
  61. */
  62. #define MLXSW_REG_SSPR_ID 0x2008
  63. #define MLXSW_REG_SSPR_LEN 0x8
  64. MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
  65. /* reg_sspr_m
  66. * Master - if set, then the record describes the master system port.
  67. * This is needed in case a local port is mapped into several system ports
  68. * (for multipathing). That number will be reported as the source system
  69. * port when packets are forwarded to the CPU. Only one master port is allowed
  70. * per local port.
  71. *
  72. * Note: Must be set for Spectrum.
  73. * Access: RW
  74. */
  75. MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
  76. /* reg_sspr_local_port
  77. * Local port number.
  78. *
  79. * Access: RW
  80. */
  81. MLXSW_ITEM32_LP(reg, sspr, 0x00, 16, 0x00, 12);
  82. /* reg_sspr_system_port
  83. * Unique identifier within the stacking domain that represents all the ports
  84. * that are available in the system (external ports).
  85. *
  86. * Currently, only single-ASIC configurations are supported, so we default to
  87. * 1:1 mapping between system ports and local ports.
  88. * Access: Index
  89. */
  90. MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
  91. static inline void mlxsw_reg_sspr_pack(char *payload, u16 local_port)
  92. {
  93. MLXSW_REG_ZERO(sspr, payload);
  94. mlxsw_reg_sspr_m_set(payload, 1);
  95. mlxsw_reg_sspr_local_port_set(payload, local_port);
  96. mlxsw_reg_sspr_system_port_set(payload, local_port);
  97. }
  98. /* SFDAT - Switch Filtering Database Aging Time
  99. * --------------------------------------------
  100. * Controls the Switch aging time. Aging time is able to be set per Switch
  101. * Partition.
  102. */
  103. #define MLXSW_REG_SFDAT_ID 0x2009
  104. #define MLXSW_REG_SFDAT_LEN 0x8
  105. MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
  106. /* reg_sfdat_swid
  107. * Switch partition ID.
  108. * Access: Index
  109. */
  110. MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
  111. /* reg_sfdat_age_time
  112. * Aging time in seconds
  113. * Min - 10 seconds
  114. * Max - 1,000,000 seconds
  115. * Default is 300 seconds.
  116. * Access: RW
  117. */
  118. MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
  119. static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
  120. {
  121. MLXSW_REG_ZERO(sfdat, payload);
  122. mlxsw_reg_sfdat_swid_set(payload, 0);
  123. mlxsw_reg_sfdat_age_time_set(payload, age_time);
  124. }
  125. /* SFD - Switch Filtering Database
  126. * -------------------------------
  127. * The following register defines the access to the filtering database.
  128. * The register supports querying, adding, removing and modifying the database.
  129. * The access is optimized for bulk updates in which case more than one
  130. * FDB record is present in the same command.
  131. */
  132. #define MLXSW_REG_SFD_ID 0x200A
  133. #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
  134. #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
  135. #define MLXSW_REG_SFD_REC_MAX_COUNT 64
  136. #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
  137. MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
  138. MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
  139. /* reg_sfd_swid
  140. * Switch partition ID for queries. Reserved on Write.
  141. * Access: Index
  142. */
  143. MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
  144. enum mlxsw_reg_sfd_op {
  145. /* Dump entire FDB a (process according to record_locator) */
  146. MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
  147. /* Query records by {MAC, VID/FID} value */
  148. MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
  149. /* Query and clear activity. Query records by {MAC, VID/FID} value */
  150. MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
  151. /* Test. Response indicates if each of the records could be
  152. * added to the FDB.
  153. */
  154. MLXSW_REG_SFD_OP_WRITE_TEST = 0,
  155. /* Add/modify. Aged-out records cannot be added. This command removes
  156. * the learning notification of the {MAC, VID/FID}. Response includes
  157. * the entries that were added to the FDB.
  158. */
  159. MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
  160. /* Remove record by {MAC, VID/FID}. This command also removes
  161. * the learning notification and aged-out notifications
  162. * of the {MAC, VID/FID}. The response provides current (pre-removal)
  163. * entries as non-aged-out.
  164. */
  165. MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
  166. /* Remove learned notification by {MAC, VID/FID}. The response provides
  167. * the removed learning notification.
  168. */
  169. MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
  170. };
  171. /* reg_sfd_op
  172. * Operation.
  173. * Access: OP
  174. */
  175. MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
  176. /* reg_sfd_record_locator
  177. * Used for querying the FDB. Use record_locator=0 to initiate the
  178. * query. When a record is returned, a new record_locator is
  179. * returned to be used in the subsequent query.
  180. * Reserved for database update.
  181. * Access: Index
  182. */
  183. MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
  184. /* reg_sfd_num_rec
  185. * Request: Number of records to read/add/modify/remove
  186. * Response: Number of records read/added/replaced/removed
  187. * See above description for more details.
  188. * Ranges 0..64
  189. * Access: RW
  190. */
  191. MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
  192. static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
  193. u32 record_locator)
  194. {
  195. MLXSW_REG_ZERO(sfd, payload);
  196. mlxsw_reg_sfd_op_set(payload, op);
  197. mlxsw_reg_sfd_record_locator_set(payload, record_locator);
  198. }
  199. /* reg_sfd_rec_swid
  200. * Switch partition ID.
  201. * Access: Index
  202. */
  203. MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
  204. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  205. enum mlxsw_reg_sfd_rec_type {
  206. MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
  207. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
  208. MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
  209. MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL = 0xC,
  210. };
  211. /* reg_sfd_rec_type
  212. * FDB record type.
  213. * Access: RW
  214. */
  215. MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
  216. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  217. enum mlxsw_reg_sfd_rec_policy {
  218. /* Replacement disabled, aging disabled. */
  219. MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
  220. /* (mlag remote): Replacement enabled, aging disabled,
  221. * learning notification enabled on this port.
  222. */
  223. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
  224. /* (ingress device): Replacement enabled, aging enabled. */
  225. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
  226. };
  227. /* reg_sfd_rec_policy
  228. * Policy.
  229. * Access: RW
  230. */
  231. MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
  232. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  233. /* reg_sfd_rec_a
  234. * Activity. Set for new static entries. Set for static entries if a frame SMAC
  235. * lookup hits on the entry.
  236. * To clear the a bit, use "query and clear activity" op.
  237. * Access: RO
  238. */
  239. MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
  240. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  241. /* reg_sfd_rec_mac
  242. * MAC address.
  243. * Access: Index
  244. */
  245. MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
  246. MLXSW_REG_SFD_REC_LEN, 0x02);
  247. enum mlxsw_reg_sfd_rec_action {
  248. /* forward */
  249. MLXSW_REG_SFD_REC_ACTION_NOP = 0,
  250. /* forward and trap, trap_id is FDB_TRAP */
  251. MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
  252. /* trap and do not forward, trap_id is FDB_TRAP */
  253. MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
  254. /* forward to IP router */
  255. MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
  256. MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
  257. };
  258. /* reg_sfd_rec_action
  259. * Action to apply on the packet.
  260. * Note: Dynamic entries can only be configured with NOP action.
  261. * Access: RW
  262. */
  263. MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
  264. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  265. /* reg_sfd_uc_sub_port
  266. * VEPA channel on local port.
  267. * Valid only if local port is a non-stacking port. Must be 0 if multichannel
  268. * VEPA is not enabled.
  269. * Access: RW
  270. */
  271. MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  272. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  273. /* reg_sfd_uc_set_vid
  274. * Set VID.
  275. * 0 - Do not update VID.
  276. * 1 - Set VID.
  277. * For Spectrum-2 when set_vid=0 and smpe_valid=1, the smpe will modify the vid.
  278. * Access: RW
  279. *
  280. * Note: Reserved when legacy bridge model is used.
  281. */
  282. MLXSW_ITEM32_INDEXED(reg, sfd, uc_set_vid, MLXSW_REG_SFD_BASE_LEN, 31, 1,
  283. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  284. /* reg_sfd_uc_fid_vid
  285. * Filtering ID or VLAN ID
  286. * For SwitchX and SwitchX-2:
  287. * - Dynamic entries (policy 2,3) use FID
  288. * - Static entries (policy 0) use VID
  289. * - When independent learning is configured, VID=FID
  290. * For Spectrum: use FID for both Dynamic and Static entries.
  291. * VID should not be used.
  292. * Access: Index
  293. */
  294. MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  295. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  296. /* reg_sfd_uc_vid
  297. * New VID when set_vid=1.
  298. * Access: RW
  299. *
  300. * Note: Reserved when legacy bridge model is used and when set_vid=0.
  301. */
  302. MLXSW_ITEM32_INDEXED(reg, sfd, uc_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
  303. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  304. /* reg_sfd_uc_system_port
  305. * Unique port identifier for the final destination of the packet.
  306. * Access: RW
  307. */
  308. MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  309. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  310. static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
  311. enum mlxsw_reg_sfd_rec_type rec_type,
  312. const char *mac,
  313. enum mlxsw_reg_sfd_rec_action action)
  314. {
  315. u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
  316. if (rec_index >= num_rec)
  317. mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
  318. mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
  319. mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
  320. mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
  321. mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
  322. }
  323. static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
  324. enum mlxsw_reg_sfd_rec_policy policy,
  325. const char *mac, u16 fid_vid, u16 vid,
  326. enum mlxsw_reg_sfd_rec_action action,
  327. u16 local_port)
  328. {
  329. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  330. MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
  331. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  332. mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
  333. mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
  334. mlxsw_reg_sfd_uc_set_vid_set(payload, rec_index, vid ? true : false);
  335. mlxsw_reg_sfd_uc_vid_set(payload, rec_index, vid);
  336. mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
  337. }
  338. /* reg_sfd_uc_lag_sub_port
  339. * LAG sub port.
  340. * Must be 0 if multichannel VEPA is not enabled.
  341. * Access: RW
  342. */
  343. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  344. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  345. /* reg_sfd_uc_lag_set_vid
  346. * Set VID.
  347. * 0 - Do not update VID.
  348. * 1 - Set VID.
  349. * For Spectrum-2 when set_vid=0 and smpe_valid=1, the smpe will modify the vid.
  350. * Access: RW
  351. *
  352. * Note: Reserved when legacy bridge model is used.
  353. */
  354. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_set_vid, MLXSW_REG_SFD_BASE_LEN, 31, 1,
  355. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  356. /* reg_sfd_uc_lag_fid_vid
  357. * Filtering ID or VLAN ID
  358. * For SwitchX and SwitchX-2:
  359. * - Dynamic entries (policy 2,3) use FID
  360. * - Static entries (policy 0) use VID
  361. * - When independent learning is configured, VID=FID
  362. * For Spectrum: use FID for both Dynamic and Static entries.
  363. * VID should not be used.
  364. * Access: Index
  365. */
  366. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  367. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  368. /* reg_sfd_uc_lag_lag_vid
  369. * New vlan ID.
  370. * Access: RW
  371. *
  372. * Note: Reserved when legacy bridge model is used and set_vid=0.
  373. */
  374. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
  375. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  376. /* reg_sfd_uc_lag_lag_id
  377. * LAG Identifier - pointer into the LAG descriptor table.
  378. * Access: RW
  379. */
  380. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
  381. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  382. static inline void
  383. mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
  384. enum mlxsw_reg_sfd_rec_policy policy,
  385. const char *mac, u16 fid_vid,
  386. enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
  387. u16 lag_id)
  388. {
  389. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  390. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
  391. mac, action);
  392. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  393. mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
  394. mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
  395. mlxsw_reg_sfd_uc_lag_set_vid_set(payload, rec_index, true);
  396. mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
  397. mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
  398. }
  399. /* reg_sfd_mc_pgi
  400. *
  401. * Multicast port group index - index into the port group table.
  402. * Value 0x1FFF indicates the pgi should point to the MID entry.
  403. * For Spectrum this value must be set to 0x1FFF
  404. * Access: RW
  405. */
  406. MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
  407. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  408. /* reg_sfd_mc_fid_vid
  409. *
  410. * Filtering ID or VLAN ID
  411. * Access: Index
  412. */
  413. MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  414. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  415. /* reg_sfd_mc_mid
  416. *
  417. * Multicast identifier - global identifier that represents the multicast
  418. * group across all devices.
  419. * Access: RW
  420. */
  421. MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  422. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  423. static inline void
  424. mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
  425. const char *mac, u16 fid_vid,
  426. enum mlxsw_reg_sfd_rec_action action, u16 mid)
  427. {
  428. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  429. MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
  430. mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
  431. mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
  432. mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
  433. }
  434. /* reg_sfd_uc_tunnel_uip_msb
  435. * When protocol is IPv4, the most significant byte of the underlay IPv4
  436. * destination IP.
  437. * When protocol is IPv6, reserved.
  438. * Access: RW
  439. */
  440. MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_msb, MLXSW_REG_SFD_BASE_LEN, 24,
  441. 8, MLXSW_REG_SFD_REC_LEN, 0x08, false);
  442. /* reg_sfd_uc_tunnel_fid
  443. * Filtering ID.
  444. * Access: Index
  445. */
  446. MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_fid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  447. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  448. enum mlxsw_reg_sfd_uc_tunnel_protocol {
  449. MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4,
  450. MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6,
  451. };
  452. /* reg_sfd_uc_tunnel_protocol
  453. * IP protocol.
  454. * Access: RW
  455. */
  456. MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_protocol, MLXSW_REG_SFD_BASE_LEN, 27,
  457. 1, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  458. /* reg_sfd_uc_tunnel_uip_lsb
  459. * When protocol is IPv4, the least significant bytes of the underlay
  460. * IPv4 destination IP.
  461. * When protocol is IPv6, pointer to the underlay IPv6 destination IP
  462. * which is configured by RIPS.
  463. * Access: RW
  464. */
  465. MLXSW_ITEM32_INDEXED(reg, sfd, uc_tunnel_uip_lsb, MLXSW_REG_SFD_BASE_LEN, 0,
  466. 24, MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  467. static inline void
  468. mlxsw_reg_sfd_uc_tunnel_pack(char *payload, int rec_index,
  469. enum mlxsw_reg_sfd_rec_policy policy,
  470. const char *mac, u16 fid,
  471. enum mlxsw_reg_sfd_rec_action action,
  472. enum mlxsw_reg_sfd_uc_tunnel_protocol proto)
  473. {
  474. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  475. MLXSW_REG_SFD_REC_TYPE_UNICAST_TUNNEL, mac,
  476. action);
  477. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  478. mlxsw_reg_sfd_uc_tunnel_fid_set(payload, rec_index, fid);
  479. mlxsw_reg_sfd_uc_tunnel_protocol_set(payload, rec_index, proto);
  480. }
  481. static inline void
  482. mlxsw_reg_sfd_uc_tunnel_pack4(char *payload, int rec_index,
  483. enum mlxsw_reg_sfd_rec_policy policy,
  484. const char *mac, u16 fid,
  485. enum mlxsw_reg_sfd_rec_action action, u32 uip)
  486. {
  487. mlxsw_reg_sfd_uc_tunnel_uip_msb_set(payload, rec_index, uip >> 24);
  488. mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip);
  489. mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index, policy, mac, fid,
  490. action,
  491. MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4);
  492. }
  493. static inline void
  494. mlxsw_reg_sfd_uc_tunnel_pack6(char *payload, int rec_index, const char *mac,
  495. u16 fid, enum mlxsw_reg_sfd_rec_action action,
  496. u32 uip_ptr)
  497. {
  498. mlxsw_reg_sfd_uc_tunnel_uip_lsb_set(payload, rec_index, uip_ptr);
  499. /* Only static policy is supported for IPv6 unicast tunnel entry. */
  500. mlxsw_reg_sfd_uc_tunnel_pack(payload, rec_index,
  501. MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY,
  502. mac, fid, action,
  503. MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV6);
  504. }
  505. enum mlxsw_reg_tunnel_port {
  506. MLXSW_REG_TUNNEL_PORT_NVE,
  507. MLXSW_REG_TUNNEL_PORT_VPLS,
  508. MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL0,
  509. MLXSW_REG_TUNNEL_PORT_FLEX_TUNNEL1,
  510. };
  511. /* SFN - Switch FDB Notification Register
  512. * -------------------------------------------
  513. * The switch provides notifications on newly learned FDB entries and
  514. * aged out entries. The notifications can be polled by software.
  515. */
  516. #define MLXSW_REG_SFN_ID 0x200B
  517. #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
  518. #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
  519. #define MLXSW_REG_SFN_REC_MAX_COUNT 64
  520. #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
  521. MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
  522. MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
  523. /* reg_sfn_swid
  524. * Switch partition ID.
  525. * Access: Index
  526. */
  527. MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
  528. /* reg_sfn_end
  529. * Forces the current session to end.
  530. * Access: OP
  531. */
  532. MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
  533. /* reg_sfn_num_rec
  534. * Request: Number of learned notifications and aged-out notification
  535. * records requested.
  536. * Response: Number of notification records returned (must be smaller
  537. * than or equal to the value requested)
  538. * Ranges 0..64
  539. * Access: OP
  540. */
  541. MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
  542. static inline void mlxsw_reg_sfn_pack(char *payload)
  543. {
  544. MLXSW_REG_ZERO(sfn, payload);
  545. mlxsw_reg_sfn_swid_set(payload, 0);
  546. mlxsw_reg_sfn_end_set(payload, 0);
  547. mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
  548. }
  549. /* reg_sfn_rec_swid
  550. * Switch partition ID.
  551. * Access: RO
  552. */
  553. MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
  554. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  555. enum mlxsw_reg_sfn_rec_type {
  556. /* MAC addresses learned on a regular port. */
  557. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
  558. /* MAC addresses learned on a LAG port. */
  559. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
  560. /* Aged-out MAC address on a regular port. */
  561. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
  562. /* Aged-out MAC address on a LAG port. */
  563. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
  564. /* Learned unicast tunnel record. */
  565. MLXSW_REG_SFN_REC_TYPE_LEARNED_UNICAST_TUNNEL = 0xD,
  566. /* Aged-out unicast tunnel record. */
  567. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_UNICAST_TUNNEL = 0xE,
  568. };
  569. /* reg_sfn_rec_type
  570. * Notification record type.
  571. * Access: RO
  572. */
  573. MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
  574. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  575. /* reg_sfn_rec_mac
  576. * MAC address.
  577. * Access: RO
  578. */
  579. MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
  580. MLXSW_REG_SFN_REC_LEN, 0x02);
  581. /* reg_sfn_mac_sub_port
  582. * VEPA channel on the local port.
  583. * 0 if multichannel VEPA is not enabled.
  584. * Access: RO
  585. */
  586. MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
  587. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  588. /* reg_sfn_mac_fid
  589. * Filtering identifier.
  590. * Access: RO
  591. */
  592. MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  593. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  594. /* reg_sfn_mac_system_port
  595. * Unique port identifier for the final destination of the packet.
  596. * Access: RO
  597. */
  598. MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  599. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  600. static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
  601. char *mac, u16 *p_vid,
  602. u16 *p_local_port)
  603. {
  604. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  605. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  606. *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
  607. }
  608. /* reg_sfn_mac_lag_lag_id
  609. * LAG ID (pointer into the LAG descriptor table).
  610. * Access: RO
  611. */
  612. MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
  613. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  614. static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
  615. char *mac, u16 *p_vid,
  616. u16 *p_lag_id)
  617. {
  618. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  619. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  620. *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
  621. }
  622. /* reg_sfn_uc_tunnel_uip_msb
  623. * When protocol is IPv4, the most significant byte of the underlay IPv4
  624. * address of the remote VTEP.
  625. * When protocol is IPv6, reserved.
  626. * Access: RO
  627. */
  628. MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_msb, MLXSW_REG_SFN_BASE_LEN, 24,
  629. 8, MLXSW_REG_SFN_REC_LEN, 0x08, false);
  630. enum mlxsw_reg_sfn_uc_tunnel_protocol {
  631. MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV4,
  632. MLXSW_REG_SFN_UC_TUNNEL_PROTOCOL_IPV6,
  633. };
  634. /* reg_sfn_uc_tunnel_protocol
  635. * IP protocol.
  636. * Access: RO
  637. */
  638. MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_protocol, MLXSW_REG_SFN_BASE_LEN, 27,
  639. 1, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  640. /* reg_sfn_uc_tunnel_uip_lsb
  641. * When protocol is IPv4, the least significant bytes of the underlay
  642. * IPv4 address of the remote VTEP.
  643. * When protocol is IPv6, ipv6_id to be queried from TNIPSD.
  644. * Access: RO
  645. */
  646. MLXSW_ITEM32_INDEXED(reg, sfn, uc_tunnel_uip_lsb, MLXSW_REG_SFN_BASE_LEN, 0,
  647. 24, MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  648. /* reg_sfn_uc_tunnel_port
  649. * Tunnel port.
  650. * Reserved on Spectrum.
  651. * Access: RO
  652. */
  653. MLXSW_ITEM32_INDEXED(reg, sfn, tunnel_port, MLXSW_REG_SFN_BASE_LEN, 0, 4,
  654. MLXSW_REG_SFN_REC_LEN, 0x10, false);
  655. static inline void
  656. mlxsw_reg_sfn_uc_tunnel_unpack(char *payload, int rec_index, char *mac,
  657. u16 *p_fid, u32 *p_uip,
  658. enum mlxsw_reg_sfn_uc_tunnel_protocol *p_proto)
  659. {
  660. u32 uip_msb, uip_lsb;
  661. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  662. *p_fid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  663. uip_msb = mlxsw_reg_sfn_uc_tunnel_uip_msb_get(payload, rec_index);
  664. uip_lsb = mlxsw_reg_sfn_uc_tunnel_uip_lsb_get(payload, rec_index);
  665. *p_uip = uip_msb << 24 | uip_lsb;
  666. *p_proto = mlxsw_reg_sfn_uc_tunnel_protocol_get(payload, rec_index);
  667. }
  668. /* SPMS - Switch Port MSTP/RSTP State Register
  669. * -------------------------------------------
  670. * Configures the spanning tree state of a physical port.
  671. */
  672. #define MLXSW_REG_SPMS_ID 0x200D
  673. #define MLXSW_REG_SPMS_LEN 0x404
  674. MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
  675. /* reg_spms_local_port
  676. * Local port number.
  677. * Access: Index
  678. */
  679. MLXSW_ITEM32_LP(reg, spms, 0x00, 16, 0x00, 12);
  680. enum mlxsw_reg_spms_state {
  681. MLXSW_REG_SPMS_STATE_NO_CHANGE,
  682. MLXSW_REG_SPMS_STATE_DISCARDING,
  683. MLXSW_REG_SPMS_STATE_LEARNING,
  684. MLXSW_REG_SPMS_STATE_FORWARDING,
  685. };
  686. /* reg_spms_state
  687. * Spanning tree state of each VLAN ID (VID) of the local port.
  688. * 0 - Do not change spanning tree state (used only when writing).
  689. * 1 - Discarding. No learning or forwarding to/from this port (default).
  690. * 2 - Learning. Port is learning, but not forwarding.
  691. * 3 - Forwarding. Port is learning and forwarding.
  692. * Access: RW
  693. */
  694. MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
  695. static inline void mlxsw_reg_spms_pack(char *payload, u16 local_port)
  696. {
  697. MLXSW_REG_ZERO(spms, payload);
  698. mlxsw_reg_spms_local_port_set(payload, local_port);
  699. }
  700. static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
  701. enum mlxsw_reg_spms_state state)
  702. {
  703. mlxsw_reg_spms_state_set(payload, vid, state);
  704. }
  705. /* SPVID - Switch Port VID
  706. * -----------------------
  707. * The switch port VID configures the default VID for a port.
  708. */
  709. #define MLXSW_REG_SPVID_ID 0x200E
  710. #define MLXSW_REG_SPVID_LEN 0x08
  711. MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
  712. /* reg_spvid_tport
  713. * Port is tunnel port.
  714. * Reserved when SwitchX/-2 or Spectrum-1.
  715. * Access: Index
  716. */
  717. MLXSW_ITEM32(reg, spvid, tport, 0x00, 24, 1);
  718. /* reg_spvid_local_port
  719. * When tport = 0: Local port number. Not supported for CPU port.
  720. * When tport = 1: Tunnel port.
  721. * Access: Index
  722. */
  723. MLXSW_ITEM32_LP(reg, spvid, 0x00, 16, 0x00, 12);
  724. /* reg_spvid_sub_port
  725. * Virtual port within the physical port.
  726. * Should be set to 0 when virtual ports are not enabled on the port.
  727. * Access: Index
  728. */
  729. MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
  730. /* reg_spvid_egr_et_set
  731. * When VLAN is pushed at ingress (for untagged packets or for
  732. * QinQ push mode) then the EtherType is decided at the egress port.
  733. * Reserved when Spectrum-1.
  734. * Access: RW
  735. */
  736. MLXSW_ITEM32(reg, spvid, egr_et_set, 0x04, 24, 1);
  737. /* reg_spvid_et_vlan
  738. * EtherType used for when VLAN is pushed at ingress (for untagged
  739. * packets or for QinQ push mode).
  740. * 0: ether_type0 - (default)
  741. * 1: ether_type1
  742. * 2: ether_type2 - Reserved when Spectrum-1, supported by Spectrum-2
  743. * Ethertype IDs are configured by SVER.
  744. * Reserved when egr_et_set = 1.
  745. * Access: RW
  746. */
  747. MLXSW_ITEM32(reg, spvid, et_vlan, 0x04, 16, 2);
  748. /* reg_spvid_pvid
  749. * Port default VID
  750. * Access: RW
  751. */
  752. MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
  753. static inline void mlxsw_reg_spvid_pack(char *payload, u16 local_port, u16 pvid,
  754. u8 et_vlan)
  755. {
  756. MLXSW_REG_ZERO(spvid, payload);
  757. mlxsw_reg_spvid_local_port_set(payload, local_port);
  758. mlxsw_reg_spvid_pvid_set(payload, pvid);
  759. mlxsw_reg_spvid_et_vlan_set(payload, et_vlan);
  760. }
  761. /* SPVM - Switch Port VLAN Membership
  762. * ----------------------------------
  763. * The Switch Port VLAN Membership register configures the VLAN membership
  764. * of a port in a VLAN denoted by VID. VLAN membership is managed per
  765. * virtual port. The register can be used to add and remove VID(s) from a port.
  766. */
  767. #define MLXSW_REG_SPVM_ID 0x200F
  768. #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
  769. #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
  770. #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
  771. #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
  772. MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
  773. MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
  774. /* reg_spvm_pt
  775. * Priority tagged. If this bit is set, packets forwarded to the port with
  776. * untagged VLAN membership (u bit is set) will be tagged with priority tag
  777. * (VID=0)
  778. * Access: RW
  779. */
  780. MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
  781. /* reg_spvm_pte
  782. * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
  783. * the pt bit will NOT be updated. To update the pt bit, pte must be set.
  784. * Access: WO
  785. */
  786. MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
  787. /* reg_spvm_local_port
  788. * Local port number.
  789. * Access: Index
  790. */
  791. MLXSW_ITEM32_LP(reg, spvm, 0x00, 16, 0x00, 12);
  792. /* reg_spvm_sub_port
  793. * Virtual port within the physical port.
  794. * Should be set to 0 when virtual ports are not enabled on the port.
  795. * Access: Index
  796. */
  797. MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
  798. /* reg_spvm_num_rec
  799. * Number of records to update. Each record contains: i, e, u, vid.
  800. * Access: OP
  801. */
  802. MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
  803. /* reg_spvm_rec_i
  804. * Ingress membership in VLAN ID.
  805. * Access: Index
  806. */
  807. MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
  808. MLXSW_REG_SPVM_BASE_LEN, 14, 1,
  809. MLXSW_REG_SPVM_REC_LEN, 0, false);
  810. /* reg_spvm_rec_e
  811. * Egress membership in VLAN ID.
  812. * Access: Index
  813. */
  814. MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
  815. MLXSW_REG_SPVM_BASE_LEN, 13, 1,
  816. MLXSW_REG_SPVM_REC_LEN, 0, false);
  817. /* reg_spvm_rec_u
  818. * Untagged - port is an untagged member - egress transmission uses untagged
  819. * frames on VID<n>
  820. * Access: Index
  821. */
  822. MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
  823. MLXSW_REG_SPVM_BASE_LEN, 12, 1,
  824. MLXSW_REG_SPVM_REC_LEN, 0, false);
  825. /* reg_spvm_rec_vid
  826. * Egress membership in VLAN ID.
  827. * Access: Index
  828. */
  829. MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
  830. MLXSW_REG_SPVM_BASE_LEN, 0, 12,
  831. MLXSW_REG_SPVM_REC_LEN, 0, false);
  832. static inline void mlxsw_reg_spvm_pack(char *payload, u16 local_port,
  833. u16 vid_begin, u16 vid_end,
  834. bool is_member, bool untagged)
  835. {
  836. int size = vid_end - vid_begin + 1;
  837. int i;
  838. MLXSW_REG_ZERO(spvm, payload);
  839. mlxsw_reg_spvm_local_port_set(payload, local_port);
  840. mlxsw_reg_spvm_num_rec_set(payload, size);
  841. for (i = 0; i < size; i++) {
  842. mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
  843. mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
  844. mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
  845. mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
  846. }
  847. }
  848. /* SPAFT - Switch Port Acceptable Frame Types
  849. * ------------------------------------------
  850. * The Switch Port Acceptable Frame Types register configures the frame
  851. * admittance of the port.
  852. */
  853. #define MLXSW_REG_SPAFT_ID 0x2010
  854. #define MLXSW_REG_SPAFT_LEN 0x08
  855. MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
  856. /* reg_spaft_local_port
  857. * Local port number.
  858. * Access: Index
  859. *
  860. * Note: CPU port is not supported (all tag types are allowed).
  861. */
  862. MLXSW_ITEM32_LP(reg, spaft, 0x00, 16, 0x00, 12);
  863. /* reg_spaft_sub_port
  864. * Virtual port within the physical port.
  865. * Should be set to 0 when virtual ports are not enabled on the port.
  866. * Access: RW
  867. */
  868. MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
  869. /* reg_spaft_allow_untagged
  870. * When set, untagged frames on the ingress are allowed (default).
  871. * Access: RW
  872. */
  873. MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
  874. /* reg_spaft_allow_prio_tagged
  875. * When set, priority tagged frames on the ingress are allowed (default).
  876. * Access: RW
  877. */
  878. MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
  879. /* reg_spaft_allow_tagged
  880. * When set, tagged frames on the ingress are allowed (default).
  881. * Access: RW
  882. */
  883. MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
  884. static inline void mlxsw_reg_spaft_pack(char *payload, u16 local_port,
  885. bool allow_untagged)
  886. {
  887. MLXSW_REG_ZERO(spaft, payload);
  888. mlxsw_reg_spaft_local_port_set(payload, local_port);
  889. mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
  890. mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
  891. mlxsw_reg_spaft_allow_tagged_set(payload, true);
  892. }
  893. /* SFGC - Switch Flooding Group Configuration
  894. * ------------------------------------------
  895. * The following register controls the association of flooding tables and MIDs
  896. * to packet types used for flooding.
  897. */
  898. #define MLXSW_REG_SFGC_ID 0x2011
  899. #define MLXSW_REG_SFGC_LEN 0x14
  900. MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
  901. enum mlxsw_reg_sfgc_type {
  902. MLXSW_REG_SFGC_TYPE_BROADCAST,
  903. MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
  904. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
  905. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
  906. MLXSW_REG_SFGC_TYPE_RESERVED,
  907. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
  908. MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
  909. MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
  910. MLXSW_REG_SFGC_TYPE_MAX,
  911. };
  912. /* reg_sfgc_type
  913. * The traffic type to reach the flooding table.
  914. * Access: Index
  915. */
  916. MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
  917. /* bridge_type is used in SFGC and SFMR. */
  918. enum mlxsw_reg_bridge_type {
  919. MLXSW_REG_BRIDGE_TYPE_0 = 0, /* Used for .1q FIDs. */
  920. MLXSW_REG_BRIDGE_TYPE_1 = 1, /* Used for .1d FIDs. */
  921. };
  922. /* reg_sfgc_bridge_type
  923. * Access: Index
  924. *
  925. * Note: SwitchX-2 only supports 802.1Q mode.
  926. */
  927. MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
  928. enum mlxsw_flood_table_type {
  929. MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
  930. MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
  931. MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
  932. MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
  933. MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
  934. };
  935. /* reg_sfgc_table_type
  936. * See mlxsw_flood_table_type
  937. * Access: RW
  938. *
  939. * Note: FID offset and FID types are not supported in SwitchX-2.
  940. */
  941. MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
  942. /* reg_sfgc_flood_table
  943. * Flooding table index to associate with the specific type on the specific
  944. * switch partition.
  945. * Access: RW
  946. */
  947. MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
  948. /* reg_sfgc_counter_set_type
  949. * Counter Set Type for flow counters.
  950. * Access: RW
  951. */
  952. MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
  953. /* reg_sfgc_counter_index
  954. * Counter Index for flow counters.
  955. * Access: RW
  956. */
  957. MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
  958. /* reg_sfgc_mid_base
  959. * MID Base.
  960. * Access: RW
  961. *
  962. * Note: Reserved when legacy bridge model is used.
  963. */
  964. MLXSW_ITEM32(reg, sfgc, mid_base, 0x10, 0, 16);
  965. static inline void
  966. mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
  967. enum mlxsw_reg_bridge_type bridge_type,
  968. enum mlxsw_flood_table_type table_type,
  969. unsigned int flood_table, u16 mid_base)
  970. {
  971. MLXSW_REG_ZERO(sfgc, payload);
  972. mlxsw_reg_sfgc_type_set(payload, type);
  973. mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
  974. mlxsw_reg_sfgc_table_type_set(payload, table_type);
  975. mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
  976. mlxsw_reg_sfgc_mid_base_set(payload, mid_base);
  977. }
  978. /* SFDF - Switch Filtering DB Flush
  979. * --------------------------------
  980. * The switch filtering DB flush register is used to flush the FDB.
  981. * Note that FDB notifications are flushed as well.
  982. */
  983. #define MLXSW_REG_SFDF_ID 0x2013
  984. #define MLXSW_REG_SFDF_LEN 0x14
  985. MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
  986. /* reg_sfdf_swid
  987. * Switch partition ID.
  988. * Access: Index
  989. */
  990. MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
  991. enum mlxsw_reg_sfdf_flush_type {
  992. MLXSW_REG_SFDF_FLUSH_PER_SWID,
  993. MLXSW_REG_SFDF_FLUSH_PER_FID,
  994. MLXSW_REG_SFDF_FLUSH_PER_PORT,
  995. MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
  996. MLXSW_REG_SFDF_FLUSH_PER_LAG,
  997. MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
  998. MLXSW_REG_SFDF_FLUSH_PER_NVE,
  999. MLXSW_REG_SFDF_FLUSH_PER_NVE_AND_FID,
  1000. };
  1001. /* reg_sfdf_flush_type
  1002. * Flush type.
  1003. * 0 - All SWID dynamic entries are flushed.
  1004. * 1 - All FID dynamic entries are flushed.
  1005. * 2 - All dynamic entries pointing to port are flushed.
  1006. * 3 - All FID dynamic entries pointing to port are flushed.
  1007. * 4 - All dynamic entries pointing to LAG are flushed.
  1008. * 5 - All FID dynamic entries pointing to LAG are flushed.
  1009. * 6 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
  1010. * flushed.
  1011. * 7 - All entries of type "Unicast Tunnel" or "Multicast Tunnel" are
  1012. * flushed, per FID.
  1013. * Access: RW
  1014. */
  1015. MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
  1016. /* reg_sfdf_flush_static
  1017. * Static.
  1018. * 0 - Flush only dynamic entries.
  1019. * 1 - Flush both dynamic and static entries.
  1020. * Access: RW
  1021. */
  1022. MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
  1023. static inline void mlxsw_reg_sfdf_pack(char *payload,
  1024. enum mlxsw_reg_sfdf_flush_type type)
  1025. {
  1026. MLXSW_REG_ZERO(sfdf, payload);
  1027. mlxsw_reg_sfdf_flush_type_set(payload, type);
  1028. mlxsw_reg_sfdf_flush_static_set(payload, true);
  1029. }
  1030. /* reg_sfdf_fid
  1031. * FID to flush.
  1032. * Access: RW
  1033. */
  1034. MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
  1035. /* reg_sfdf_system_port
  1036. * Port to flush.
  1037. * Access: RW
  1038. */
  1039. MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
  1040. /* reg_sfdf_port_fid_system_port
  1041. * Port to flush, pointed to by FID.
  1042. * Access: RW
  1043. */
  1044. MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
  1045. /* reg_sfdf_lag_id
  1046. * LAG ID to flush.
  1047. * Access: RW
  1048. */
  1049. MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
  1050. /* reg_sfdf_lag_fid_lag_id
  1051. * LAG ID to flush, pointed to by FID.
  1052. * Access: RW
  1053. */
  1054. MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
  1055. /* SLDR - Switch LAG Descriptor Register
  1056. * -----------------------------------------
  1057. * The switch LAG descriptor register is populated by LAG descriptors.
  1058. * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
  1059. * max_lag-1.
  1060. */
  1061. #define MLXSW_REG_SLDR_ID 0x2014
  1062. #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
  1063. MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
  1064. enum mlxsw_reg_sldr_op {
  1065. /* Indicates a creation of a new LAG-ID, lag_id must be valid */
  1066. MLXSW_REG_SLDR_OP_LAG_CREATE,
  1067. MLXSW_REG_SLDR_OP_LAG_DESTROY,
  1068. /* Ports that appear in the list have the Distributor enabled */
  1069. MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
  1070. /* Removes ports from the disributor list */
  1071. MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
  1072. };
  1073. /* reg_sldr_op
  1074. * Operation.
  1075. * Access: RW
  1076. */
  1077. MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
  1078. /* reg_sldr_lag_id
  1079. * LAG identifier. The lag_id is the index into the LAG descriptor table.
  1080. * Access: Index
  1081. */
  1082. MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
  1083. static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
  1084. {
  1085. MLXSW_REG_ZERO(sldr, payload);
  1086. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
  1087. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1088. }
  1089. static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
  1090. {
  1091. MLXSW_REG_ZERO(sldr, payload);
  1092. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
  1093. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1094. }
  1095. /* reg_sldr_num_ports
  1096. * The number of member ports of the LAG.
  1097. * Reserved for Create / Destroy operations
  1098. * For Add / Remove operations - indicates the number of ports in the list.
  1099. * Access: RW
  1100. */
  1101. MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
  1102. /* reg_sldr_system_port
  1103. * System port.
  1104. * Access: RW
  1105. */
  1106. MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
  1107. static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
  1108. u16 local_port)
  1109. {
  1110. MLXSW_REG_ZERO(sldr, payload);
  1111. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
  1112. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1113. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1114. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1115. }
  1116. static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
  1117. u16 local_port)
  1118. {
  1119. MLXSW_REG_ZERO(sldr, payload);
  1120. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
  1121. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1122. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1123. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1124. }
  1125. /* SLCR - Switch LAG Configuration 2 Register
  1126. * -------------------------------------------
  1127. * The Switch LAG Configuration register is used for configuring the
  1128. * LAG properties of the switch.
  1129. */
  1130. #define MLXSW_REG_SLCR_ID 0x2015
  1131. #define MLXSW_REG_SLCR_LEN 0x10
  1132. MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
  1133. enum mlxsw_reg_slcr_pp {
  1134. /* Global Configuration (for all ports) */
  1135. MLXSW_REG_SLCR_PP_GLOBAL,
  1136. /* Per port configuration, based on local_port field */
  1137. MLXSW_REG_SLCR_PP_PER_PORT,
  1138. };
  1139. /* reg_slcr_pp
  1140. * Per Port Configuration
  1141. * Note: Reading at Global mode results in reading port 1 configuration.
  1142. * Access: Index
  1143. */
  1144. MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
  1145. /* reg_slcr_local_port
  1146. * Local port number
  1147. * Supported from CPU port
  1148. * Not supported from router port
  1149. * Reserved when pp = Global Configuration
  1150. * Access: Index
  1151. */
  1152. MLXSW_ITEM32_LP(reg, slcr, 0x00, 16, 0x00, 12);
  1153. enum mlxsw_reg_slcr_type {
  1154. MLXSW_REG_SLCR_TYPE_CRC, /* default */
  1155. MLXSW_REG_SLCR_TYPE_XOR,
  1156. MLXSW_REG_SLCR_TYPE_RANDOM,
  1157. };
  1158. /* reg_slcr_type
  1159. * Hash type
  1160. * Access: RW
  1161. */
  1162. MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
  1163. /* Ingress port */
  1164. #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
  1165. /* SMAC - for IPv4 and IPv6 packets */
  1166. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
  1167. /* SMAC - for non-IP packets */
  1168. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
  1169. #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
  1170. (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
  1171. MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
  1172. /* DMAC - for IPv4 and IPv6 packets */
  1173. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
  1174. /* DMAC - for non-IP packets */
  1175. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
  1176. #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
  1177. (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
  1178. MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
  1179. /* Ethertype - for IPv4 and IPv6 packets */
  1180. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
  1181. /* Ethertype - for non-IP packets */
  1182. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
  1183. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
  1184. (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
  1185. MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
  1186. /* VLAN ID - for IPv4 and IPv6 packets */
  1187. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
  1188. /* VLAN ID - for non-IP packets */
  1189. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
  1190. #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
  1191. (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
  1192. MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
  1193. /* Source IP address (can be IPv4 or IPv6) */
  1194. #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
  1195. /* Destination IP address (can be IPv4 or IPv6) */
  1196. #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
  1197. /* TCP/UDP source port */
  1198. #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
  1199. /* TCP/UDP destination port*/
  1200. #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
  1201. /* IPv4 Protocol/IPv6 Next Header */
  1202. #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
  1203. /* IPv6 Flow label */
  1204. #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
  1205. /* SID - FCoE source ID */
  1206. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
  1207. /* DID - FCoE destination ID */
  1208. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
  1209. /* OXID - FCoE originator exchange ID */
  1210. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
  1211. /* Destination QP number - for RoCE packets */
  1212. #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
  1213. /* reg_slcr_lag_hash
  1214. * LAG hashing configuration. This is a bitmask, in which each set
  1215. * bit includes the corresponding item in the LAG hash calculation.
  1216. * The default lag_hash contains SMAC, DMAC, VLANID and
  1217. * Ethertype (for all packet types).
  1218. * Access: RW
  1219. */
  1220. MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
  1221. /* reg_slcr_seed
  1222. * LAG seed value. The seed is the same for all ports.
  1223. * Access: RW
  1224. */
  1225. MLXSW_ITEM32(reg, slcr, seed, 0x08, 0, 32);
  1226. static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash, u32 seed)
  1227. {
  1228. MLXSW_REG_ZERO(slcr, payload);
  1229. mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
  1230. mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
  1231. mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
  1232. mlxsw_reg_slcr_seed_set(payload, seed);
  1233. }
  1234. /* SLCOR - Switch LAG Collector Register
  1235. * -------------------------------------
  1236. * The Switch LAG Collector register controls the Local Port membership
  1237. * in a LAG and enablement of the collector.
  1238. */
  1239. #define MLXSW_REG_SLCOR_ID 0x2016
  1240. #define MLXSW_REG_SLCOR_LEN 0x10
  1241. MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
  1242. enum mlxsw_reg_slcor_col {
  1243. /* Port is added with collector disabled */
  1244. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
  1245. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
  1246. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
  1247. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
  1248. };
  1249. /* reg_slcor_col
  1250. * Collector configuration
  1251. * Access: RW
  1252. */
  1253. MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
  1254. /* reg_slcor_local_port
  1255. * Local port number
  1256. * Not supported for CPU port
  1257. * Access: Index
  1258. */
  1259. MLXSW_ITEM32_LP(reg, slcor, 0x00, 16, 0x00, 12);
  1260. /* reg_slcor_lag_id
  1261. * LAG Identifier. Index into the LAG descriptor table.
  1262. * Access: Index
  1263. */
  1264. MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
  1265. /* reg_slcor_port_index
  1266. * Port index in the LAG list. Only valid on Add Port to LAG col.
  1267. * Valid range is from 0 to cap_max_lag_members-1
  1268. * Access: RW
  1269. */
  1270. MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
  1271. static inline void mlxsw_reg_slcor_pack(char *payload,
  1272. u16 local_port, u16 lag_id,
  1273. enum mlxsw_reg_slcor_col col)
  1274. {
  1275. MLXSW_REG_ZERO(slcor, payload);
  1276. mlxsw_reg_slcor_col_set(payload, col);
  1277. mlxsw_reg_slcor_local_port_set(payload, local_port);
  1278. mlxsw_reg_slcor_lag_id_set(payload, lag_id);
  1279. }
  1280. static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
  1281. u16 local_port, u16 lag_id,
  1282. u8 port_index)
  1283. {
  1284. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1285. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
  1286. mlxsw_reg_slcor_port_index_set(payload, port_index);
  1287. }
  1288. static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
  1289. u16 local_port, u16 lag_id)
  1290. {
  1291. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1292. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
  1293. }
  1294. static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
  1295. u16 local_port, u16 lag_id)
  1296. {
  1297. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1298. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1299. }
  1300. static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
  1301. u16 local_port, u16 lag_id)
  1302. {
  1303. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1304. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1305. }
  1306. /* SPMLR - Switch Port MAC Learning Register
  1307. * -----------------------------------------
  1308. * Controls the Switch MAC learning policy per port.
  1309. */
  1310. #define MLXSW_REG_SPMLR_ID 0x2018
  1311. #define MLXSW_REG_SPMLR_LEN 0x8
  1312. MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
  1313. /* reg_spmlr_local_port
  1314. * Local port number.
  1315. * Access: Index
  1316. */
  1317. MLXSW_ITEM32_LP(reg, spmlr, 0x00, 16, 0x00, 12);
  1318. /* reg_spmlr_sub_port
  1319. * Virtual port within the physical port.
  1320. * Should be set to 0 when virtual ports are not enabled on the port.
  1321. * Access: Index
  1322. */
  1323. MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
  1324. enum mlxsw_reg_spmlr_learn_mode {
  1325. MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
  1326. MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
  1327. MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
  1328. };
  1329. /* reg_spmlr_learn_mode
  1330. * Learning mode on the port.
  1331. * 0 - Learning disabled.
  1332. * 2 - Learning enabled.
  1333. * 3 - Security mode.
  1334. *
  1335. * In security mode the switch does not learn MACs on the port, but uses the
  1336. * SMAC to see if it exists on another ingress port. If so, the packet is
  1337. * classified as a bad packet and is discarded unless the software registers
  1338. * to receive port security error packets usign HPKT.
  1339. */
  1340. MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
  1341. static inline void mlxsw_reg_spmlr_pack(char *payload, u16 local_port,
  1342. enum mlxsw_reg_spmlr_learn_mode mode)
  1343. {
  1344. MLXSW_REG_ZERO(spmlr, payload);
  1345. mlxsw_reg_spmlr_local_port_set(payload, local_port);
  1346. mlxsw_reg_spmlr_sub_port_set(payload, 0);
  1347. mlxsw_reg_spmlr_learn_mode_set(payload, mode);
  1348. }
  1349. /* SVFA - Switch VID to FID Allocation Register
  1350. * --------------------------------------------
  1351. * Controls the VID to FID mapping and {Port, VID} to FID mapping for
  1352. * virtualized ports.
  1353. */
  1354. #define MLXSW_REG_SVFA_ID 0x201C
  1355. #define MLXSW_REG_SVFA_LEN 0x18
  1356. MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
  1357. /* reg_svfa_swid
  1358. * Switch partition ID.
  1359. * Access: Index
  1360. */
  1361. MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
  1362. /* reg_svfa_local_port
  1363. * Local port number.
  1364. * Access: Index
  1365. *
  1366. * Note: Reserved for 802.1Q FIDs.
  1367. */
  1368. MLXSW_ITEM32_LP(reg, svfa, 0x00, 16, 0x00, 12);
  1369. enum mlxsw_reg_svfa_mt {
  1370. MLXSW_REG_SVFA_MT_VID_TO_FID,
  1371. MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
  1372. MLXSW_REG_SVFA_MT_VNI_TO_FID,
  1373. };
  1374. /* reg_svfa_mapping_table
  1375. * Mapping table:
  1376. * 0 - VID to FID
  1377. * 1 - {Port, VID} to FID
  1378. * Access: Index
  1379. *
  1380. * Note: Reserved for SwitchX-2.
  1381. */
  1382. MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
  1383. /* reg_svfa_v
  1384. * Valid.
  1385. * Valid if set.
  1386. * Access: RW
  1387. *
  1388. * Note: Reserved for SwitchX-2.
  1389. */
  1390. MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
  1391. /* reg_svfa_fid
  1392. * Filtering ID.
  1393. * Access: RW
  1394. */
  1395. MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
  1396. /* reg_svfa_vid
  1397. * VLAN ID.
  1398. * Access: Index
  1399. */
  1400. MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
  1401. /* reg_svfa_counter_set_type
  1402. * Counter set type for flow counters.
  1403. * Access: RW
  1404. *
  1405. * Note: Reserved for SwitchX-2.
  1406. */
  1407. MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
  1408. /* reg_svfa_counter_index
  1409. * Counter index for flow counters.
  1410. * Access: RW
  1411. *
  1412. * Note: Reserved for SwitchX-2.
  1413. */
  1414. MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
  1415. /* reg_svfa_vni
  1416. * Virtual Network Identifier.
  1417. * Access: Index
  1418. *
  1419. * Note: Reserved when mapping_table is not 2 (VNI mapping table).
  1420. */
  1421. MLXSW_ITEM32(reg, svfa, vni, 0x10, 0, 24);
  1422. /* reg_svfa_irif_v
  1423. * Ingress RIF valid.
  1424. * 0 - Ingress RIF is not valid, no ingress RIF assigned.
  1425. * 1 - Ingress RIF valid.
  1426. * Must not be set for a non enabled RIF.
  1427. * Access: RW
  1428. *
  1429. * Note: Reserved when legacy bridge model is used.
  1430. */
  1431. MLXSW_ITEM32(reg, svfa, irif_v, 0x14, 24, 1);
  1432. /* reg_svfa_irif
  1433. * Ingress RIF (Router Interface).
  1434. * Range is 0..cap_max_router_interfaces-1.
  1435. * Access: RW
  1436. *
  1437. * Note: Reserved when legacy bridge model is used and when irif_v=0.
  1438. */
  1439. MLXSW_ITEM32(reg, svfa, irif, 0x14, 0, 16);
  1440. static inline void __mlxsw_reg_svfa_pack(char *payload,
  1441. enum mlxsw_reg_svfa_mt mt, bool valid,
  1442. u16 fid, bool irif_v, u16 irif)
  1443. {
  1444. MLXSW_REG_ZERO(svfa, payload);
  1445. mlxsw_reg_svfa_swid_set(payload, 0);
  1446. mlxsw_reg_svfa_mapping_table_set(payload, mt);
  1447. mlxsw_reg_svfa_v_set(payload, valid);
  1448. mlxsw_reg_svfa_fid_set(payload, fid);
  1449. mlxsw_reg_svfa_irif_v_set(payload, irif_v);
  1450. mlxsw_reg_svfa_irif_set(payload, irif_v ? irif : 0);
  1451. }
  1452. static inline void mlxsw_reg_svfa_port_vid_pack(char *payload, u16 local_port,
  1453. bool valid, u16 fid, u16 vid,
  1454. bool irif_v, u16 irif)
  1455. {
  1456. enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_PORT_VID_TO_FID;
  1457. __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
  1458. mlxsw_reg_svfa_local_port_set(payload, local_port);
  1459. mlxsw_reg_svfa_vid_set(payload, vid);
  1460. }
  1461. static inline void mlxsw_reg_svfa_vid_pack(char *payload, bool valid, u16 fid,
  1462. u16 vid, bool irif_v, u16 irif)
  1463. {
  1464. enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_VID_TO_FID;
  1465. __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
  1466. mlxsw_reg_svfa_vid_set(payload, vid);
  1467. }
  1468. static inline void mlxsw_reg_svfa_vni_pack(char *payload, bool valid, u16 fid,
  1469. u32 vni, bool irif_v, u16 irif)
  1470. {
  1471. enum mlxsw_reg_svfa_mt mt = MLXSW_REG_SVFA_MT_VNI_TO_FID;
  1472. __mlxsw_reg_svfa_pack(payload, mt, valid, fid, irif_v, irif);
  1473. mlxsw_reg_svfa_vni_set(payload, vni);
  1474. }
  1475. /* SPVTR - Switch Port VLAN Stacking Register
  1476. * ------------------------------------------
  1477. * The Switch Port VLAN Stacking register configures the VLAN mode of the port
  1478. * to enable VLAN stacking.
  1479. */
  1480. #define MLXSW_REG_SPVTR_ID 0x201D
  1481. #define MLXSW_REG_SPVTR_LEN 0x10
  1482. MLXSW_REG_DEFINE(spvtr, MLXSW_REG_SPVTR_ID, MLXSW_REG_SPVTR_LEN);
  1483. /* reg_spvtr_tport
  1484. * Port is tunnel port.
  1485. * Access: Index
  1486. *
  1487. * Note: Reserved when SwitchX/-2 or Spectrum-1.
  1488. */
  1489. MLXSW_ITEM32(reg, spvtr, tport, 0x00, 24, 1);
  1490. /* reg_spvtr_local_port
  1491. * When tport = 0: local port number (Not supported from/to CPU).
  1492. * When tport = 1: tunnel port.
  1493. * Access: Index
  1494. */
  1495. MLXSW_ITEM32_LP(reg, spvtr, 0x00, 16, 0x00, 12);
  1496. /* reg_spvtr_ippe
  1497. * Ingress Port Prio Mode Update Enable.
  1498. * When set, the Port Prio Mode is updated with the provided ipprio_mode field.
  1499. * Reserved on Get operations.
  1500. * Access: OP
  1501. */
  1502. MLXSW_ITEM32(reg, spvtr, ippe, 0x04, 31, 1);
  1503. /* reg_spvtr_ipve
  1504. * Ingress Port VID Mode Update Enable.
  1505. * When set, the Ingress Port VID Mode is updated with the provided ipvid_mode
  1506. * field.
  1507. * Reserved on Get operations.
  1508. * Access: OP
  1509. */
  1510. MLXSW_ITEM32(reg, spvtr, ipve, 0x04, 30, 1);
  1511. /* reg_spvtr_epve
  1512. * Egress Port VID Mode Update Enable.
  1513. * When set, the Egress Port VID Mode is updated with the provided epvid_mode
  1514. * field.
  1515. * Access: OP
  1516. */
  1517. MLXSW_ITEM32(reg, spvtr, epve, 0x04, 29, 1);
  1518. /* reg_spvtr_ipprio_mode
  1519. * Ingress Port Priority Mode.
  1520. * This controls the PCP and DEI of the new outer VLAN
  1521. * Note: for SwitchX/-2 the DEI is not affected.
  1522. * 0: use port default PCP and DEI (configured by QPDPC).
  1523. * 1: use C-VLAN PCP and DEI.
  1524. * Has no effect when ipvid_mode = 0.
  1525. * Reserved when tport = 1.
  1526. * Access: RW
  1527. */
  1528. MLXSW_ITEM32(reg, spvtr, ipprio_mode, 0x04, 20, 4);
  1529. enum mlxsw_reg_spvtr_ipvid_mode {
  1530. /* IEEE Compliant PVID (default) */
  1531. MLXSW_REG_SPVTR_IPVID_MODE_IEEE_COMPLIANT_PVID,
  1532. /* Push VLAN (for VLAN stacking, except prio tagged packets) */
  1533. MLXSW_REG_SPVTR_IPVID_MODE_PUSH_VLAN_FOR_UNTAGGED_PACKET,
  1534. /* Always push VLAN (also for prio tagged packets) */
  1535. MLXSW_REG_SPVTR_IPVID_MODE_ALWAYS_PUSH_VLAN,
  1536. };
  1537. /* reg_spvtr_ipvid_mode
  1538. * Ingress Port VLAN-ID Mode.
  1539. * For Spectrum family, this affects the values of SPVM.i
  1540. * Access: RW
  1541. */
  1542. MLXSW_ITEM32(reg, spvtr, ipvid_mode, 0x04, 16, 4);
  1543. enum mlxsw_reg_spvtr_epvid_mode {
  1544. /* IEEE Compliant VLAN membership */
  1545. MLXSW_REG_SPVTR_EPVID_MODE_IEEE_COMPLIANT_VLAN_MEMBERSHIP,
  1546. /* Pop VLAN (for VLAN stacking) */
  1547. MLXSW_REG_SPVTR_EPVID_MODE_POP_VLAN,
  1548. };
  1549. /* reg_spvtr_epvid_mode
  1550. * Egress Port VLAN-ID Mode.
  1551. * For Spectrum family, this affects the values of SPVM.e,u,pt.
  1552. * Access: WO
  1553. */
  1554. MLXSW_ITEM32(reg, spvtr, epvid_mode, 0x04, 0, 4);
  1555. static inline void mlxsw_reg_spvtr_pack(char *payload, bool tport,
  1556. u16 local_port,
  1557. enum mlxsw_reg_spvtr_ipvid_mode ipvid_mode)
  1558. {
  1559. MLXSW_REG_ZERO(spvtr, payload);
  1560. mlxsw_reg_spvtr_tport_set(payload, tport);
  1561. mlxsw_reg_spvtr_local_port_set(payload, local_port);
  1562. mlxsw_reg_spvtr_ipvid_mode_set(payload, ipvid_mode);
  1563. mlxsw_reg_spvtr_ipve_set(payload, true);
  1564. }
  1565. /* SVPE - Switch Virtual-Port Enabling Register
  1566. * --------------------------------------------
  1567. * Enables port virtualization.
  1568. */
  1569. #define MLXSW_REG_SVPE_ID 0x201E
  1570. #define MLXSW_REG_SVPE_LEN 0x4
  1571. MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
  1572. /* reg_svpe_local_port
  1573. * Local port number
  1574. * Access: Index
  1575. *
  1576. * Note: CPU port is not supported (uses VLAN mode only).
  1577. */
  1578. MLXSW_ITEM32_LP(reg, svpe, 0x00, 16, 0x00, 12);
  1579. /* reg_svpe_vp_en
  1580. * Virtual port enable.
  1581. * 0 - Disable, VLAN mode (VID to FID).
  1582. * 1 - Enable, Virtual port mode ({Port, VID} to FID).
  1583. * Access: RW
  1584. */
  1585. MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
  1586. static inline void mlxsw_reg_svpe_pack(char *payload, u16 local_port,
  1587. bool enable)
  1588. {
  1589. MLXSW_REG_ZERO(svpe, payload);
  1590. mlxsw_reg_svpe_local_port_set(payload, local_port);
  1591. mlxsw_reg_svpe_vp_en_set(payload, enable);
  1592. }
  1593. /* SFMR - Switch FID Management Register
  1594. * -------------------------------------
  1595. * Creates and configures FIDs.
  1596. */
  1597. #define MLXSW_REG_SFMR_ID 0x201F
  1598. #define MLXSW_REG_SFMR_LEN 0x30
  1599. MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
  1600. enum mlxsw_reg_sfmr_op {
  1601. MLXSW_REG_SFMR_OP_CREATE_FID,
  1602. MLXSW_REG_SFMR_OP_DESTROY_FID,
  1603. };
  1604. /* reg_sfmr_op
  1605. * Operation.
  1606. * 0 - Create or edit FID.
  1607. * 1 - Destroy FID.
  1608. * Access: WO
  1609. */
  1610. MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
  1611. /* reg_sfmr_fid
  1612. * Filtering ID.
  1613. * Access: Index
  1614. */
  1615. MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
  1616. /* reg_sfmr_flood_rsp
  1617. * Router sub-port flooding table.
  1618. * 0 - Regular flooding table.
  1619. * 1 - Router sub-port flooding table. For this FID the flooding is per
  1620. * router-sub-port local_port. Must not be set for a FID which is not a
  1621. * router-sub-port and must be set prior to enabling the relevant RIF.
  1622. * Access: RW
  1623. *
  1624. * Note: Reserved when legacy bridge model is used.
  1625. */
  1626. MLXSW_ITEM32(reg, sfmr, flood_rsp, 0x08, 31, 1);
  1627. /* reg_sfmr_flood_bridge_type
  1628. * Flood bridge type (see SFGC.bridge_type).
  1629. * 0 - type_0.
  1630. * 1 - type_1.
  1631. * Access: RW
  1632. *
  1633. * Note: Reserved when legacy bridge model is used and when flood_rsp=1.
  1634. */
  1635. MLXSW_ITEM32(reg, sfmr, flood_bridge_type, 0x08, 28, 1);
  1636. /* reg_sfmr_fid_offset
  1637. * FID offset.
  1638. * Used to point into the flooding table selected by SFGC register if
  1639. * the table is of type FID-Offset. Otherwise, this field is reserved.
  1640. * Access: RW
  1641. */
  1642. MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
  1643. /* reg_sfmr_vtfp
  1644. * Valid Tunnel Flood Pointer.
  1645. * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
  1646. * Access: RW
  1647. *
  1648. * Note: Reserved for 802.1Q FIDs.
  1649. */
  1650. MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
  1651. /* reg_sfmr_nve_tunnel_flood_ptr
  1652. * Underlay Flooding and BC Pointer.
  1653. * Used as a pointer to the first entry of the group based link lists of
  1654. * flooding or BC entries (for NVE tunnels).
  1655. * Access: RW
  1656. */
  1657. MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
  1658. /* reg_sfmr_vv
  1659. * VNI Valid.
  1660. * If not set, then vni is reserved.
  1661. * Access: RW
  1662. *
  1663. * Note: Reserved for 802.1Q FIDs.
  1664. */
  1665. MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
  1666. /* reg_sfmr_vni
  1667. * Virtual Network Identifier.
  1668. * When legacy bridge model is used, a given VNI can only be assigned to one
  1669. * FID. When unified bridge model is used, it configures only the FID->VNI,
  1670. * the VNI->FID is done by SVFA.
  1671. * Access: RW
  1672. */
  1673. MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
  1674. /* reg_sfmr_irif_v
  1675. * Ingress RIF valid.
  1676. * 0 - Ingress RIF is not valid, no ingress RIF assigned.
  1677. * 1 - Ingress RIF valid.
  1678. * Must not be set for a non valid RIF.
  1679. * Access: RW
  1680. *
  1681. * Note: Reserved when legacy bridge model is used.
  1682. */
  1683. MLXSW_ITEM32(reg, sfmr, irif_v, 0x14, 24, 1);
  1684. /* reg_sfmr_irif
  1685. * Ingress RIF (Router Interface).
  1686. * Range is 0..cap_max_router_interfaces-1.
  1687. * Access: RW
  1688. *
  1689. * Note: Reserved when legacy bridge model is used and when irif_v=0.
  1690. */
  1691. MLXSW_ITEM32(reg, sfmr, irif, 0x14, 0, 16);
  1692. /* reg_sfmr_smpe_valid
  1693. * SMPE is valid.
  1694. * Access: RW
  1695. *
  1696. * Note: Reserved when legacy bridge model is used, when flood_rsp=1 and on
  1697. * Spectrum-1.
  1698. */
  1699. MLXSW_ITEM32(reg, sfmr, smpe_valid, 0x28, 20, 1);
  1700. /* reg_sfmr_smpe
  1701. * Switch multicast port to egress VID.
  1702. * Range is 0..cap_max_rmpe-1
  1703. * Access: RW
  1704. *
  1705. * Note: Reserved when legacy bridge model is used, when flood_rsp=1 and on
  1706. * Spectrum-1.
  1707. */
  1708. MLXSW_ITEM32(reg, sfmr, smpe, 0x28, 0, 16);
  1709. static inline void mlxsw_reg_sfmr_pack(char *payload,
  1710. enum mlxsw_reg_sfmr_op op, u16 fid,
  1711. u16 fid_offset, bool flood_rsp,
  1712. enum mlxsw_reg_bridge_type bridge_type,
  1713. bool smpe_valid, u16 smpe)
  1714. {
  1715. MLXSW_REG_ZERO(sfmr, payload);
  1716. mlxsw_reg_sfmr_op_set(payload, op);
  1717. mlxsw_reg_sfmr_fid_set(payload, fid);
  1718. mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
  1719. mlxsw_reg_sfmr_vtfp_set(payload, false);
  1720. mlxsw_reg_sfmr_vv_set(payload, false);
  1721. mlxsw_reg_sfmr_flood_rsp_set(payload, flood_rsp);
  1722. mlxsw_reg_sfmr_flood_bridge_type_set(payload, bridge_type);
  1723. mlxsw_reg_sfmr_smpe_valid_set(payload, smpe_valid);
  1724. mlxsw_reg_sfmr_smpe_set(payload, smpe);
  1725. }
  1726. /* SPVMLR - Switch Port VLAN MAC Learning Register
  1727. * -----------------------------------------------
  1728. * Controls the switch MAC learning policy per {Port, VID}.
  1729. */
  1730. #define MLXSW_REG_SPVMLR_ID 0x2020
  1731. #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
  1732. #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
  1733. #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
  1734. #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
  1735. MLXSW_REG_SPVMLR_REC_LEN * \
  1736. MLXSW_REG_SPVMLR_REC_MAX_COUNT)
  1737. MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
  1738. /* reg_spvmlr_local_port
  1739. * Local ingress port.
  1740. * Access: Index
  1741. *
  1742. * Note: CPU port is not supported.
  1743. */
  1744. MLXSW_ITEM32_LP(reg, spvmlr, 0x00, 16, 0x00, 12);
  1745. /* reg_spvmlr_num_rec
  1746. * Number of records to update.
  1747. * Access: OP
  1748. */
  1749. MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
  1750. /* reg_spvmlr_rec_learn_enable
  1751. * 0 - Disable learning for {Port, VID}.
  1752. * 1 - Enable learning for {Port, VID}.
  1753. * Access: RW
  1754. */
  1755. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
  1756. 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1757. /* reg_spvmlr_rec_vid
  1758. * VLAN ID to be added/removed from port or for querying.
  1759. * Access: Index
  1760. */
  1761. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
  1762. MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1763. static inline void mlxsw_reg_spvmlr_pack(char *payload, u16 local_port,
  1764. u16 vid_begin, u16 vid_end,
  1765. bool learn_enable)
  1766. {
  1767. int num_rec = vid_end - vid_begin + 1;
  1768. int i;
  1769. WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
  1770. MLXSW_REG_ZERO(spvmlr, payload);
  1771. mlxsw_reg_spvmlr_local_port_set(payload, local_port);
  1772. mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
  1773. for (i = 0; i < num_rec; i++) {
  1774. mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
  1775. mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
  1776. }
  1777. }
  1778. /* SPVC - Switch Port VLAN Classification Register
  1779. * -----------------------------------------------
  1780. * Configures the port to identify packets as untagged / single tagged /
  1781. * double packets based on the packet EtherTypes.
  1782. * Ethertype IDs are configured by SVER.
  1783. */
  1784. #define MLXSW_REG_SPVC_ID 0x2026
  1785. #define MLXSW_REG_SPVC_LEN 0x0C
  1786. MLXSW_REG_DEFINE(spvc, MLXSW_REG_SPVC_ID, MLXSW_REG_SPVC_LEN);
  1787. /* reg_spvc_local_port
  1788. * Local port.
  1789. * Access: Index
  1790. *
  1791. * Note: applies both to Rx port and Tx port, so if a packet traverses
  1792. * through Rx port i and a Tx port j then port i and port j must have the
  1793. * same configuration.
  1794. */
  1795. MLXSW_ITEM32_LP(reg, spvc, 0x00, 16, 0x00, 12);
  1796. /* reg_spvc_inner_et2
  1797. * Vlan Tag1 EtherType2 enable.
  1798. * Packet is initially classified as double VLAN Tag if in addition to
  1799. * being classified with a tag0 VLAN Tag its tag1 EtherType value is
  1800. * equal to ether_type2.
  1801. * 0: disable (default)
  1802. * 1: enable
  1803. * Access: RW
  1804. */
  1805. MLXSW_ITEM32(reg, spvc, inner_et2, 0x08, 17, 1);
  1806. /* reg_spvc_et2
  1807. * Vlan Tag0 EtherType2 enable.
  1808. * Packet is initially classified as VLAN Tag if its tag0 EtherType is
  1809. * equal to ether_type2.
  1810. * 0: disable (default)
  1811. * 1: enable
  1812. * Access: RW
  1813. */
  1814. MLXSW_ITEM32(reg, spvc, et2, 0x08, 16, 1);
  1815. /* reg_spvc_inner_et1
  1816. * Vlan Tag1 EtherType1 enable.
  1817. * Packet is initially classified as double VLAN Tag if in addition to
  1818. * being classified with a tag0 VLAN Tag its tag1 EtherType value is
  1819. * equal to ether_type1.
  1820. * 0: disable
  1821. * 1: enable (default)
  1822. * Access: RW
  1823. */
  1824. MLXSW_ITEM32(reg, spvc, inner_et1, 0x08, 9, 1);
  1825. /* reg_spvc_et1
  1826. * Vlan Tag0 EtherType1 enable.
  1827. * Packet is initially classified as VLAN Tag if its tag0 EtherType is
  1828. * equal to ether_type1.
  1829. * 0: disable
  1830. * 1: enable (default)
  1831. * Access: RW
  1832. */
  1833. MLXSW_ITEM32(reg, spvc, et1, 0x08, 8, 1);
  1834. /* reg_inner_et0
  1835. * Vlan Tag1 EtherType0 enable.
  1836. * Packet is initially classified as double VLAN Tag if in addition to
  1837. * being classified with a tag0 VLAN Tag its tag1 EtherType value is
  1838. * equal to ether_type0.
  1839. * 0: disable
  1840. * 1: enable (default)
  1841. * Access: RW
  1842. */
  1843. MLXSW_ITEM32(reg, spvc, inner_et0, 0x08, 1, 1);
  1844. /* reg_et0
  1845. * Vlan Tag0 EtherType0 enable.
  1846. * Packet is initially classified as VLAN Tag if its tag0 EtherType is
  1847. * equal to ether_type0.
  1848. * 0: disable
  1849. * 1: enable (default)
  1850. * Access: RW
  1851. */
  1852. MLXSW_ITEM32(reg, spvc, et0, 0x08, 0, 1);
  1853. static inline void mlxsw_reg_spvc_pack(char *payload, u16 local_port, bool et1,
  1854. bool et0)
  1855. {
  1856. MLXSW_REG_ZERO(spvc, payload);
  1857. mlxsw_reg_spvc_local_port_set(payload, local_port);
  1858. /* Enable inner_et1 and inner_et0 to enable identification of double
  1859. * tagged packets.
  1860. */
  1861. mlxsw_reg_spvc_inner_et1_set(payload, 1);
  1862. mlxsw_reg_spvc_inner_et0_set(payload, 1);
  1863. mlxsw_reg_spvc_et1_set(payload, et1);
  1864. mlxsw_reg_spvc_et0_set(payload, et0);
  1865. }
  1866. /* SPEVET - Switch Port Egress VLAN EtherType
  1867. * ------------------------------------------
  1868. * The switch port egress VLAN EtherType configures which EtherType to push at
  1869. * egress for packets incoming through a local port for which 'SPVID.egr_et_set'
  1870. * is set.
  1871. */
  1872. #define MLXSW_REG_SPEVET_ID 0x202A
  1873. #define MLXSW_REG_SPEVET_LEN 0x08
  1874. MLXSW_REG_DEFINE(spevet, MLXSW_REG_SPEVET_ID, MLXSW_REG_SPEVET_LEN);
  1875. /* reg_spevet_local_port
  1876. * Egress Local port number.
  1877. * Not supported to CPU port.
  1878. * Access: Index
  1879. */
  1880. MLXSW_ITEM32_LP(reg, spevet, 0x00, 16, 0x00, 12);
  1881. /* reg_spevet_et_vlan
  1882. * Egress EtherType VLAN to push when SPVID.egr_et_set field set for the packet:
  1883. * 0: ether_type0 - (default)
  1884. * 1: ether_type1
  1885. * 2: ether_type2
  1886. * Access: RW
  1887. */
  1888. MLXSW_ITEM32(reg, spevet, et_vlan, 0x04, 16, 2);
  1889. static inline void mlxsw_reg_spevet_pack(char *payload, u16 local_port,
  1890. u8 et_vlan)
  1891. {
  1892. MLXSW_REG_ZERO(spevet, payload);
  1893. mlxsw_reg_spevet_local_port_set(payload, local_port);
  1894. mlxsw_reg_spevet_et_vlan_set(payload, et_vlan);
  1895. }
  1896. /* SMPE - Switch Multicast Port to Egress VID
  1897. * ------------------------------------------
  1898. * The switch multicast port to egress VID maps
  1899. * {egress_port, SMPE index} -> {VID}.
  1900. */
  1901. #define MLXSW_REG_SMPE_ID 0x202B
  1902. #define MLXSW_REG_SMPE_LEN 0x0C
  1903. MLXSW_REG_DEFINE(smpe, MLXSW_REG_SMPE_ID, MLXSW_REG_SMPE_LEN);
  1904. /* reg_smpe_local_port
  1905. * Local port number.
  1906. * CPU port is not supported.
  1907. * Access: Index
  1908. */
  1909. MLXSW_ITEM32_LP(reg, smpe, 0x00, 16, 0x00, 12);
  1910. /* reg_smpe_smpe_index
  1911. * Switch multicast port to egress VID.
  1912. * Range is 0..cap_max_rmpe-1.
  1913. * Access: Index
  1914. */
  1915. MLXSW_ITEM32(reg, smpe, smpe_index, 0x04, 0, 16);
  1916. /* reg_smpe_evid
  1917. * Egress VID.
  1918. * Access: RW
  1919. */
  1920. MLXSW_ITEM32(reg, smpe, evid, 0x08, 0, 12);
  1921. static inline void mlxsw_reg_smpe_pack(char *payload, u16 local_port,
  1922. u16 smpe_index, u16 evid)
  1923. {
  1924. MLXSW_REG_ZERO(smpe, payload);
  1925. mlxsw_reg_smpe_local_port_set(payload, local_port);
  1926. mlxsw_reg_smpe_smpe_index_set(payload, smpe_index);
  1927. mlxsw_reg_smpe_evid_set(payload, evid);
  1928. }
  1929. /* SMID-V2 - Switch Multicast ID Version 2 Register
  1930. * ------------------------------------------------
  1931. * The MID record maps from a MID (Multicast ID), which is a unique identifier
  1932. * of the multicast group within the stacking domain, into a list of local
  1933. * ports into which the packet is replicated.
  1934. */
  1935. #define MLXSW_REG_SMID2_ID 0x2034
  1936. #define MLXSW_REG_SMID2_LEN 0x120
  1937. MLXSW_REG_DEFINE(smid2, MLXSW_REG_SMID2_ID, MLXSW_REG_SMID2_LEN);
  1938. /* reg_smid2_swid
  1939. * Switch partition ID.
  1940. * Access: Index
  1941. */
  1942. MLXSW_ITEM32(reg, smid2, swid, 0x00, 24, 8);
  1943. /* reg_smid2_mid
  1944. * Multicast identifier - global identifier that represents the multicast group
  1945. * across all devices.
  1946. * Access: Index
  1947. */
  1948. MLXSW_ITEM32(reg, smid2, mid, 0x00, 0, 16);
  1949. /* reg_smid2_smpe_valid
  1950. * SMPE is valid.
  1951. * When not valid, the egress VID will not be modified by the SMPE table.
  1952. * Access: RW
  1953. *
  1954. * Note: Reserved when legacy bridge model is used and on Spectrum-2.
  1955. */
  1956. MLXSW_ITEM32(reg, smid2, smpe_valid, 0x08, 20, 1);
  1957. /* reg_smid2_smpe
  1958. * Switch multicast port to egress VID.
  1959. * Access: RW
  1960. *
  1961. * Note: Reserved when legacy bridge model is used and on Spectrum-2.
  1962. */
  1963. MLXSW_ITEM32(reg, smid2, smpe, 0x08, 0, 16);
  1964. /* reg_smid2_port
  1965. * Local port memebership (1 bit per port).
  1966. * Access: RW
  1967. */
  1968. MLXSW_ITEM_BIT_ARRAY(reg, smid2, port, 0x20, 0x80, 1);
  1969. /* reg_smid2_port_mask
  1970. * Local port mask (1 bit per port).
  1971. * Access: WO
  1972. */
  1973. MLXSW_ITEM_BIT_ARRAY(reg, smid2, port_mask, 0xA0, 0x80, 1);
  1974. static inline void mlxsw_reg_smid2_pack(char *payload, u16 mid, u16 port,
  1975. bool set, bool smpe_valid, u16 smpe)
  1976. {
  1977. MLXSW_REG_ZERO(smid2, payload);
  1978. mlxsw_reg_smid2_swid_set(payload, 0);
  1979. mlxsw_reg_smid2_mid_set(payload, mid);
  1980. mlxsw_reg_smid2_port_set(payload, port, set);
  1981. mlxsw_reg_smid2_port_mask_set(payload, port, 1);
  1982. mlxsw_reg_smid2_smpe_valid_set(payload, smpe_valid);
  1983. mlxsw_reg_smid2_smpe_set(payload, smpe_valid ? smpe : 0);
  1984. }
  1985. /* CWTP - Congetion WRED ECN TClass Profile
  1986. * ----------------------------------------
  1987. * Configures the profiles for queues of egress port and traffic class
  1988. */
  1989. #define MLXSW_REG_CWTP_ID 0x2802
  1990. #define MLXSW_REG_CWTP_BASE_LEN 0x28
  1991. #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
  1992. #define MLXSW_REG_CWTP_LEN 0x40
  1993. MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
  1994. /* reg_cwtp_local_port
  1995. * Local port number
  1996. * Not supported for CPU port
  1997. * Access: Index
  1998. */
  1999. MLXSW_ITEM32_LP(reg, cwtp, 0x00, 16, 0x00, 12);
  2000. /* reg_cwtp_traffic_class
  2001. * Traffic Class to configure
  2002. * Access: Index
  2003. */
  2004. MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
  2005. /* reg_cwtp_profile_min
  2006. * Minimum Average Queue Size of the profile in cells.
  2007. * Access: RW
  2008. */
  2009. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
  2010. 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
  2011. /* reg_cwtp_profile_percent
  2012. * Percentage of WRED and ECN marking for maximum Average Queue size
  2013. * Range is 0 to 100, units of integer percentage
  2014. * Access: RW
  2015. */
  2016. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
  2017. 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
  2018. /* reg_cwtp_profile_max
  2019. * Maximum Average Queue size of the profile in cells
  2020. * Access: RW
  2021. */
  2022. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
  2023. 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
  2024. #define MLXSW_REG_CWTP_MIN_VALUE 64
  2025. #define MLXSW_REG_CWTP_MAX_PROFILE 2
  2026. #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
  2027. static inline void mlxsw_reg_cwtp_pack(char *payload, u16 local_port,
  2028. u8 traffic_class)
  2029. {
  2030. int i;
  2031. MLXSW_REG_ZERO(cwtp, payload);
  2032. mlxsw_reg_cwtp_local_port_set(payload, local_port);
  2033. mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
  2034. for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
  2035. mlxsw_reg_cwtp_profile_min_set(payload, i,
  2036. MLXSW_REG_CWTP_MIN_VALUE);
  2037. mlxsw_reg_cwtp_profile_max_set(payload, i,
  2038. MLXSW_REG_CWTP_MIN_VALUE);
  2039. }
  2040. }
  2041. #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
  2042. static inline void
  2043. mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
  2044. u32 probability)
  2045. {
  2046. u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
  2047. mlxsw_reg_cwtp_profile_min_set(payload, index, min);
  2048. mlxsw_reg_cwtp_profile_max_set(payload, index, max);
  2049. mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
  2050. }
  2051. /* CWTPM - Congestion WRED ECN TClass and Pool Mapping
  2052. * ---------------------------------------------------
  2053. * The CWTPM register maps each egress port and traffic class to profile num.
  2054. */
  2055. #define MLXSW_REG_CWTPM_ID 0x2803
  2056. #define MLXSW_REG_CWTPM_LEN 0x44
  2057. MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
  2058. /* reg_cwtpm_local_port
  2059. * Local port number
  2060. * Not supported for CPU port
  2061. * Access: Index
  2062. */
  2063. MLXSW_ITEM32_LP(reg, cwtpm, 0x00, 16, 0x00, 12);
  2064. /* reg_cwtpm_traffic_class
  2065. * Traffic Class to configure
  2066. * Access: Index
  2067. */
  2068. MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
  2069. /* reg_cwtpm_ew
  2070. * Control enablement of WRED for traffic class:
  2071. * 0 - Disable
  2072. * 1 - Enable
  2073. * Access: RW
  2074. */
  2075. MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
  2076. /* reg_cwtpm_ee
  2077. * Control enablement of ECN for traffic class:
  2078. * 0 - Disable
  2079. * 1 - Enable
  2080. * Access: RW
  2081. */
  2082. MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
  2083. /* reg_cwtpm_tcp_g
  2084. * TCP Green Profile.
  2085. * Index of the profile within {port, traffic class} to use.
  2086. * 0 for disabling both WRED and ECN for this type of traffic.
  2087. * Access: RW
  2088. */
  2089. MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
  2090. /* reg_cwtpm_tcp_y
  2091. * TCP Yellow Profile.
  2092. * Index of the profile within {port, traffic class} to use.
  2093. * 0 for disabling both WRED and ECN for this type of traffic.
  2094. * Access: RW
  2095. */
  2096. MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
  2097. /* reg_cwtpm_tcp_r
  2098. * TCP Red Profile.
  2099. * Index of the profile within {port, traffic class} to use.
  2100. * 0 for disabling both WRED and ECN for this type of traffic.
  2101. * Access: RW
  2102. */
  2103. MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
  2104. /* reg_cwtpm_ntcp_g
  2105. * Non-TCP Green Profile.
  2106. * Index of the profile within {port, traffic class} to use.
  2107. * 0 for disabling both WRED and ECN for this type of traffic.
  2108. * Access: RW
  2109. */
  2110. MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
  2111. /* reg_cwtpm_ntcp_y
  2112. * Non-TCP Yellow Profile.
  2113. * Index of the profile within {port, traffic class} to use.
  2114. * 0 for disabling both WRED and ECN for this type of traffic.
  2115. * Access: RW
  2116. */
  2117. MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
  2118. /* reg_cwtpm_ntcp_r
  2119. * Non-TCP Red Profile.
  2120. * Index of the profile within {port, traffic class} to use.
  2121. * 0 for disabling both WRED and ECN for this type of traffic.
  2122. * Access: RW
  2123. */
  2124. MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
  2125. #define MLXSW_REG_CWTPM_RESET_PROFILE 0
  2126. static inline void mlxsw_reg_cwtpm_pack(char *payload, u16 local_port,
  2127. u8 traffic_class, u8 profile,
  2128. bool wred, bool ecn)
  2129. {
  2130. MLXSW_REG_ZERO(cwtpm, payload);
  2131. mlxsw_reg_cwtpm_local_port_set(payload, local_port);
  2132. mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
  2133. mlxsw_reg_cwtpm_ew_set(payload, wred);
  2134. mlxsw_reg_cwtpm_ee_set(payload, ecn);
  2135. mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
  2136. mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
  2137. mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
  2138. mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
  2139. mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
  2140. mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
  2141. }
  2142. /* PGCR - Policy-Engine General Configuration Register
  2143. * ---------------------------------------------------
  2144. * This register configures general Policy-Engine settings.
  2145. */
  2146. #define MLXSW_REG_PGCR_ID 0x3001
  2147. #define MLXSW_REG_PGCR_LEN 0x20
  2148. MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
  2149. /* reg_pgcr_default_action_pointer_base
  2150. * Default action pointer base. Each region has a default action pointer
  2151. * which is equal to default_action_pointer_base + region_id.
  2152. * Access: RW
  2153. */
  2154. MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
  2155. static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
  2156. {
  2157. MLXSW_REG_ZERO(pgcr, payload);
  2158. mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
  2159. }
  2160. /* PPBT - Policy-Engine Port Binding Table
  2161. * ---------------------------------------
  2162. * This register is used for configuration of the Port Binding Table.
  2163. */
  2164. #define MLXSW_REG_PPBT_ID 0x3002
  2165. #define MLXSW_REG_PPBT_LEN 0x14
  2166. MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
  2167. enum mlxsw_reg_pxbt_e {
  2168. MLXSW_REG_PXBT_E_IACL,
  2169. MLXSW_REG_PXBT_E_EACL,
  2170. };
  2171. /* reg_ppbt_e
  2172. * Access: Index
  2173. */
  2174. MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
  2175. enum mlxsw_reg_pxbt_op {
  2176. MLXSW_REG_PXBT_OP_BIND,
  2177. MLXSW_REG_PXBT_OP_UNBIND,
  2178. };
  2179. /* reg_ppbt_op
  2180. * Access: RW
  2181. */
  2182. MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
  2183. /* reg_ppbt_local_port
  2184. * Local port. Not including CPU port.
  2185. * Access: Index
  2186. */
  2187. MLXSW_ITEM32_LP(reg, ppbt, 0x00, 16, 0x00, 12);
  2188. /* reg_ppbt_g
  2189. * group - When set, the binding is of an ACL group. When cleared,
  2190. * the binding is of an ACL.
  2191. * Must be set to 1 for Spectrum.
  2192. * Access: RW
  2193. */
  2194. MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
  2195. /* reg_ppbt_acl_info
  2196. * ACL/ACL group identifier. If the g bit is set, this field should hold
  2197. * the acl_group_id, else it should hold the acl_id.
  2198. * Access: RW
  2199. */
  2200. MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
  2201. static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
  2202. enum mlxsw_reg_pxbt_op op,
  2203. u16 local_port, u16 acl_info)
  2204. {
  2205. MLXSW_REG_ZERO(ppbt, payload);
  2206. mlxsw_reg_ppbt_e_set(payload, e);
  2207. mlxsw_reg_ppbt_op_set(payload, op);
  2208. mlxsw_reg_ppbt_local_port_set(payload, local_port);
  2209. mlxsw_reg_ppbt_g_set(payload, true);
  2210. mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
  2211. }
  2212. /* PACL - Policy-Engine ACL Register
  2213. * ---------------------------------
  2214. * This register is used for configuration of the ACL.
  2215. */
  2216. #define MLXSW_REG_PACL_ID 0x3004
  2217. #define MLXSW_REG_PACL_LEN 0x70
  2218. MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
  2219. /* reg_pacl_v
  2220. * Valid. Setting the v bit makes the ACL valid. It should not be cleared
  2221. * while the ACL is bounded to either a port, VLAN or ACL rule.
  2222. * Access: RW
  2223. */
  2224. MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
  2225. /* reg_pacl_acl_id
  2226. * An identifier representing the ACL (managed by software)
  2227. * Range 0 .. cap_max_acl_regions - 1
  2228. * Access: Index
  2229. */
  2230. MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
  2231. #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
  2232. /* reg_pacl_tcam_region_info
  2233. * Opaque object that represents a TCAM region.
  2234. * Obtained through PTAR register.
  2235. * Access: RW
  2236. */
  2237. MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
  2238. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2239. static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
  2240. bool valid, const char *tcam_region_info)
  2241. {
  2242. MLXSW_REG_ZERO(pacl, payload);
  2243. mlxsw_reg_pacl_acl_id_set(payload, acl_id);
  2244. mlxsw_reg_pacl_v_set(payload, valid);
  2245. mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2246. }
  2247. /* PAGT - Policy-Engine ACL Group Table
  2248. * ------------------------------------
  2249. * This register is used for configuration of the ACL Group Table.
  2250. */
  2251. #define MLXSW_REG_PAGT_ID 0x3005
  2252. #define MLXSW_REG_PAGT_BASE_LEN 0x30
  2253. #define MLXSW_REG_PAGT_ACL_LEN 4
  2254. #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
  2255. #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
  2256. MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
  2257. MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
  2258. /* reg_pagt_size
  2259. * Number of ACLs in the group.
  2260. * Size 0 invalidates a group.
  2261. * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
  2262. * Total number of ACLs in all groups must be lower or equal
  2263. * to cap_max_acl_tot_groups
  2264. * Note: a group which is binded must not be invalidated
  2265. * Access: Index
  2266. */
  2267. MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
  2268. /* reg_pagt_acl_group_id
  2269. * An identifier (numbered from 0..cap_max_acl_groups-1) representing
  2270. * the ACL Group identifier (managed by software).
  2271. * Access: Index
  2272. */
  2273. MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
  2274. /* reg_pagt_multi
  2275. * Multi-ACL
  2276. * 0 - This ACL is the last ACL in the multi-ACL
  2277. * 1 - This ACL is part of a multi-ACL
  2278. * Access: RW
  2279. */
  2280. MLXSW_ITEM32_INDEXED(reg, pagt, multi, 0x30, 31, 1, 0x04, 0x00, false);
  2281. /* reg_pagt_acl_id
  2282. * ACL identifier
  2283. * Access: RW
  2284. */
  2285. MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
  2286. static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
  2287. {
  2288. MLXSW_REG_ZERO(pagt, payload);
  2289. mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
  2290. }
  2291. static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
  2292. u16 acl_id, bool multi)
  2293. {
  2294. u8 size = mlxsw_reg_pagt_size_get(payload);
  2295. if (index >= size)
  2296. mlxsw_reg_pagt_size_set(payload, index + 1);
  2297. mlxsw_reg_pagt_multi_set(payload, index, multi);
  2298. mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
  2299. }
  2300. /* PTAR - Policy-Engine TCAM Allocation Register
  2301. * ---------------------------------------------
  2302. * This register is used for allocation of regions in the TCAM.
  2303. * Note: Query method is not supported on this register.
  2304. */
  2305. #define MLXSW_REG_PTAR_ID 0x3006
  2306. #define MLXSW_REG_PTAR_BASE_LEN 0x20
  2307. #define MLXSW_REG_PTAR_KEY_ID_LEN 1
  2308. #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
  2309. #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
  2310. MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
  2311. MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
  2312. enum mlxsw_reg_ptar_op {
  2313. /* allocate a TCAM region */
  2314. MLXSW_REG_PTAR_OP_ALLOC,
  2315. /* resize a TCAM region */
  2316. MLXSW_REG_PTAR_OP_RESIZE,
  2317. /* deallocate TCAM region */
  2318. MLXSW_REG_PTAR_OP_FREE,
  2319. /* test allocation */
  2320. MLXSW_REG_PTAR_OP_TEST,
  2321. };
  2322. /* reg_ptar_op
  2323. * Access: OP
  2324. */
  2325. MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
  2326. /* reg_ptar_action_set_type
  2327. * Type of action set to be used on this region.
  2328. * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
  2329. * Access: WO
  2330. */
  2331. MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
  2332. enum mlxsw_reg_ptar_key_type {
  2333. MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
  2334. MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
  2335. };
  2336. /* reg_ptar_key_type
  2337. * TCAM key type for the region.
  2338. * Access: WO
  2339. */
  2340. MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
  2341. /* reg_ptar_region_size
  2342. * TCAM region size. When allocating/resizing this is the requested size,
  2343. * the response is the actual size. Note that actual size may be
  2344. * larger than requested.
  2345. * Allowed range 1 .. cap_max_rules-1
  2346. * Reserved during op deallocate.
  2347. * Access: WO
  2348. */
  2349. MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
  2350. /* reg_ptar_region_id
  2351. * Region identifier
  2352. * Range 0 .. cap_max_regions-1
  2353. * Access: Index
  2354. */
  2355. MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
  2356. /* reg_ptar_tcam_region_info
  2357. * Opaque object that represents the TCAM region.
  2358. * Returned when allocating a region.
  2359. * Provided by software for ACL generation and region deallocation and resize.
  2360. * Access: RW
  2361. */
  2362. MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
  2363. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2364. /* reg_ptar_flexible_key_id
  2365. * Identifier of the Flexible Key.
  2366. * Only valid if key_type == "FLEX_KEY"
  2367. * The key size will be rounded up to one of the following values:
  2368. * 9B, 18B, 36B, 54B.
  2369. * This field is reserved for in resize operation.
  2370. * Access: WO
  2371. */
  2372. MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
  2373. MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
  2374. static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
  2375. enum mlxsw_reg_ptar_key_type key_type,
  2376. u16 region_size, u16 region_id,
  2377. const char *tcam_region_info)
  2378. {
  2379. MLXSW_REG_ZERO(ptar, payload);
  2380. mlxsw_reg_ptar_op_set(payload, op);
  2381. mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
  2382. mlxsw_reg_ptar_key_type_set(payload, key_type);
  2383. mlxsw_reg_ptar_region_size_set(payload, region_size);
  2384. mlxsw_reg_ptar_region_id_set(payload, region_id);
  2385. mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2386. }
  2387. static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
  2388. u16 key_id)
  2389. {
  2390. mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
  2391. }
  2392. static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
  2393. {
  2394. mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
  2395. }
  2396. /* PPBS - Policy-Engine Policy Based Switching Register
  2397. * ----------------------------------------------------
  2398. * This register retrieves and sets Policy Based Switching Table entries.
  2399. */
  2400. #define MLXSW_REG_PPBS_ID 0x300C
  2401. #define MLXSW_REG_PPBS_LEN 0x14
  2402. MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
  2403. /* reg_ppbs_pbs_ptr
  2404. * Index into the PBS table.
  2405. * For Spectrum, the index points to the KVD Linear.
  2406. * Access: Index
  2407. */
  2408. MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
  2409. /* reg_ppbs_system_port
  2410. * Unique port identifier for the final destination of the packet.
  2411. * Access: RW
  2412. */
  2413. MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
  2414. static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
  2415. u16 system_port)
  2416. {
  2417. MLXSW_REG_ZERO(ppbs, payload);
  2418. mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
  2419. mlxsw_reg_ppbs_system_port_set(payload, system_port);
  2420. }
  2421. /* PRCR - Policy-Engine Rules Copy Register
  2422. * ----------------------------------------
  2423. * This register is used for accessing rules within a TCAM region.
  2424. */
  2425. #define MLXSW_REG_PRCR_ID 0x300D
  2426. #define MLXSW_REG_PRCR_LEN 0x40
  2427. MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
  2428. enum mlxsw_reg_prcr_op {
  2429. /* Move rules. Moves the rules from "tcam_region_info" starting
  2430. * at offset "offset" to "dest_tcam_region_info"
  2431. * at offset "dest_offset."
  2432. */
  2433. MLXSW_REG_PRCR_OP_MOVE,
  2434. /* Copy rules. Copies the rules from "tcam_region_info" starting
  2435. * at offset "offset" to "dest_tcam_region_info"
  2436. * at offset "dest_offset."
  2437. */
  2438. MLXSW_REG_PRCR_OP_COPY,
  2439. };
  2440. /* reg_prcr_op
  2441. * Access: OP
  2442. */
  2443. MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
  2444. /* reg_prcr_offset
  2445. * Offset within the source region to copy/move from.
  2446. * Access: Index
  2447. */
  2448. MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
  2449. /* reg_prcr_size
  2450. * The number of rules to copy/move.
  2451. * Access: WO
  2452. */
  2453. MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
  2454. /* reg_prcr_tcam_region_info
  2455. * Opaque object that represents the source TCAM region.
  2456. * Access: Index
  2457. */
  2458. MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
  2459. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2460. /* reg_prcr_dest_offset
  2461. * Offset within the source region to copy/move to.
  2462. * Access: Index
  2463. */
  2464. MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
  2465. /* reg_prcr_dest_tcam_region_info
  2466. * Opaque object that represents the destination TCAM region.
  2467. * Access: Index
  2468. */
  2469. MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
  2470. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2471. static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
  2472. const char *src_tcam_region_info,
  2473. u16 src_offset,
  2474. const char *dest_tcam_region_info,
  2475. u16 dest_offset, u16 size)
  2476. {
  2477. MLXSW_REG_ZERO(prcr, payload);
  2478. mlxsw_reg_prcr_op_set(payload, op);
  2479. mlxsw_reg_prcr_offset_set(payload, src_offset);
  2480. mlxsw_reg_prcr_size_set(payload, size);
  2481. mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
  2482. src_tcam_region_info);
  2483. mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
  2484. mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
  2485. dest_tcam_region_info);
  2486. }
  2487. /* PEFA - Policy-Engine Extended Flexible Action Register
  2488. * ------------------------------------------------------
  2489. * This register is used for accessing an extended flexible action entry
  2490. * in the central KVD Linear Database.
  2491. */
  2492. #define MLXSW_REG_PEFA_ID 0x300F
  2493. #define MLXSW_REG_PEFA_LEN 0xB0
  2494. MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
  2495. /* reg_pefa_index
  2496. * Index in the KVD Linear Centralized Database.
  2497. * Access: Index
  2498. */
  2499. MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
  2500. /* reg_pefa_a
  2501. * Index in the KVD Linear Centralized Database.
  2502. * Activity
  2503. * For a new entry: set if ca=0, clear if ca=1
  2504. * Set if a packet lookup has hit on the specific entry
  2505. * Access: RO
  2506. */
  2507. MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
  2508. /* reg_pefa_ca
  2509. * Clear activity
  2510. * When write: activity is according to this field
  2511. * When read: after reading the activity is cleared according to ca
  2512. * Access: OP
  2513. */
  2514. MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
  2515. #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
  2516. /* reg_pefa_flex_action_set
  2517. * Action-set to perform when rule is matched.
  2518. * Must be zero padded if action set is shorter.
  2519. * Access: RW
  2520. */
  2521. MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
  2522. static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
  2523. const char *flex_action_set)
  2524. {
  2525. MLXSW_REG_ZERO(pefa, payload);
  2526. mlxsw_reg_pefa_index_set(payload, index);
  2527. mlxsw_reg_pefa_ca_set(payload, ca);
  2528. if (flex_action_set)
  2529. mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
  2530. flex_action_set);
  2531. }
  2532. static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
  2533. {
  2534. *p_a = mlxsw_reg_pefa_a_get(payload);
  2535. }
  2536. /* PEMRBT - Policy-Engine Multicast Router Binding Table Register
  2537. * --------------------------------------------------------------
  2538. * This register is used for binding Multicast router to an ACL group
  2539. * that serves the MC router.
  2540. * This register is not supported by SwitchX/-2 and Spectrum.
  2541. */
  2542. #define MLXSW_REG_PEMRBT_ID 0x3014
  2543. #define MLXSW_REG_PEMRBT_LEN 0x14
  2544. MLXSW_REG_DEFINE(pemrbt, MLXSW_REG_PEMRBT_ID, MLXSW_REG_PEMRBT_LEN);
  2545. enum mlxsw_reg_pemrbt_protocol {
  2546. MLXSW_REG_PEMRBT_PROTO_IPV4,
  2547. MLXSW_REG_PEMRBT_PROTO_IPV6,
  2548. };
  2549. /* reg_pemrbt_protocol
  2550. * Access: Index
  2551. */
  2552. MLXSW_ITEM32(reg, pemrbt, protocol, 0x00, 0, 1);
  2553. /* reg_pemrbt_group_id
  2554. * ACL group identifier.
  2555. * Range 0..cap_max_acl_groups-1
  2556. * Access: RW
  2557. */
  2558. MLXSW_ITEM32(reg, pemrbt, group_id, 0x10, 0, 16);
  2559. static inline void
  2560. mlxsw_reg_pemrbt_pack(char *payload, enum mlxsw_reg_pemrbt_protocol protocol,
  2561. u16 group_id)
  2562. {
  2563. MLXSW_REG_ZERO(pemrbt, payload);
  2564. mlxsw_reg_pemrbt_protocol_set(payload, protocol);
  2565. mlxsw_reg_pemrbt_group_id_set(payload, group_id);
  2566. }
  2567. /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
  2568. * -----------------------------------------------------
  2569. * This register is used for accessing rules within a TCAM region.
  2570. * It is a new version of PTCE in order to support wider key,
  2571. * mask and action within a TCAM region. This register is not supported
  2572. * by SwitchX and SwitchX-2.
  2573. */
  2574. #define MLXSW_REG_PTCE2_ID 0x3017
  2575. #define MLXSW_REG_PTCE2_LEN 0x1D8
  2576. MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
  2577. /* reg_ptce2_v
  2578. * Valid.
  2579. * Access: RW
  2580. */
  2581. MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
  2582. /* reg_ptce2_a
  2583. * Activity. Set if a packet lookup has hit on the specific entry.
  2584. * To clear the "a" bit, use "clear activity" op or "clear on read" op.
  2585. * Access: RO
  2586. */
  2587. MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
  2588. enum mlxsw_reg_ptce2_op {
  2589. /* Read operation. */
  2590. MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
  2591. /* clear on read operation. Used to read entry
  2592. * and clear Activity bit.
  2593. */
  2594. MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
  2595. /* Write operation. Used to write a new entry to the table.
  2596. * All R/W fields are relevant for new entry. Activity bit is set
  2597. * for new entries - Note write with v = 0 will delete the entry.
  2598. */
  2599. MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
  2600. /* Update action. Only action set will be updated. */
  2601. MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
  2602. /* Clear activity. A bit is cleared for the entry. */
  2603. MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
  2604. };
  2605. /* reg_ptce2_op
  2606. * Access: OP
  2607. */
  2608. MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
  2609. /* reg_ptce2_offset
  2610. * Access: Index
  2611. */
  2612. MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
  2613. /* reg_ptce2_priority
  2614. * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
  2615. * Note: priority does not have to be unique per rule.
  2616. * Within a region, higher priority should have lower offset (no limitation
  2617. * between regions in a multi-region).
  2618. * Access: RW
  2619. */
  2620. MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
  2621. /* reg_ptce2_tcam_region_info
  2622. * Opaque object that represents the TCAM region.
  2623. * Access: Index
  2624. */
  2625. MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
  2626. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2627. #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
  2628. /* reg_ptce2_flex_key_blocks
  2629. * ACL Key.
  2630. * Access: RW
  2631. */
  2632. MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
  2633. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2634. /* reg_ptce2_mask
  2635. * mask- in the same size as key. A bit that is set directs the TCAM
  2636. * to compare the corresponding bit in key. A bit that is clear directs
  2637. * the TCAM to ignore the corresponding bit in key.
  2638. * Access: RW
  2639. */
  2640. MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
  2641. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2642. /* reg_ptce2_flex_action_set
  2643. * ACL action set.
  2644. * Access: RW
  2645. */
  2646. MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
  2647. MLXSW_REG_FLEX_ACTION_SET_LEN);
  2648. static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
  2649. enum mlxsw_reg_ptce2_op op,
  2650. const char *tcam_region_info,
  2651. u16 offset, u32 priority)
  2652. {
  2653. MLXSW_REG_ZERO(ptce2, payload);
  2654. mlxsw_reg_ptce2_v_set(payload, valid);
  2655. mlxsw_reg_ptce2_op_set(payload, op);
  2656. mlxsw_reg_ptce2_offset_set(payload, offset);
  2657. mlxsw_reg_ptce2_priority_set(payload, priority);
  2658. mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2659. }
  2660. /* PERPT - Policy-Engine ERP Table Register
  2661. * ----------------------------------------
  2662. * This register adds and removes eRPs from the eRP table.
  2663. */
  2664. #define MLXSW_REG_PERPT_ID 0x3021
  2665. #define MLXSW_REG_PERPT_LEN 0x80
  2666. MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
  2667. /* reg_perpt_erpt_bank
  2668. * eRP table bank.
  2669. * Range 0 .. cap_max_erp_table_banks - 1
  2670. * Access: Index
  2671. */
  2672. MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
  2673. /* reg_perpt_erpt_index
  2674. * Index to eRP table within the eRP bank.
  2675. * Range is 0 .. cap_max_erp_table_bank_size - 1
  2676. * Access: Index
  2677. */
  2678. MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
  2679. enum mlxsw_reg_perpt_key_size {
  2680. MLXSW_REG_PERPT_KEY_SIZE_2KB,
  2681. MLXSW_REG_PERPT_KEY_SIZE_4KB,
  2682. MLXSW_REG_PERPT_KEY_SIZE_8KB,
  2683. MLXSW_REG_PERPT_KEY_SIZE_12KB,
  2684. };
  2685. /* reg_perpt_key_size
  2686. * Access: OP
  2687. */
  2688. MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
  2689. /* reg_perpt_bf_bypass
  2690. * 0 - The eRP is used only if bloom filter state is set for the given
  2691. * rule.
  2692. * 1 - The eRP is used regardless of bloom filter state.
  2693. * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
  2694. * Access: RW
  2695. */
  2696. MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
  2697. /* reg_perpt_erp_id
  2698. * eRP ID for use by the rules.
  2699. * Access: RW
  2700. */
  2701. MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
  2702. /* reg_perpt_erpt_base_bank
  2703. * Base eRP table bank, points to head of erp_vector
  2704. * Range is 0 .. cap_max_erp_table_banks - 1
  2705. * Access: OP
  2706. */
  2707. MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
  2708. /* reg_perpt_erpt_base_index
  2709. * Base index to eRP table within the eRP bank
  2710. * Range is 0 .. cap_max_erp_table_bank_size - 1
  2711. * Access: OP
  2712. */
  2713. MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
  2714. /* reg_perpt_erp_index_in_vector
  2715. * eRP index in the vector.
  2716. * Access: OP
  2717. */
  2718. MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
  2719. /* reg_perpt_erp_vector
  2720. * eRP vector.
  2721. * Access: OP
  2722. */
  2723. MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
  2724. /* reg_perpt_mask
  2725. * Mask
  2726. * 0 - A-TCAM will ignore the bit in key
  2727. * 1 - A-TCAM will compare the bit in key
  2728. * Access: RW
  2729. */
  2730. MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2731. static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
  2732. unsigned long *erp_vector,
  2733. unsigned long size)
  2734. {
  2735. unsigned long bit;
  2736. for_each_set_bit(bit, erp_vector, size)
  2737. mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
  2738. }
  2739. static inline void
  2740. mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
  2741. enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
  2742. u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
  2743. char *mask)
  2744. {
  2745. MLXSW_REG_ZERO(perpt, payload);
  2746. mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
  2747. mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
  2748. mlxsw_reg_perpt_key_size_set(payload, key_size);
  2749. mlxsw_reg_perpt_bf_bypass_set(payload, false);
  2750. mlxsw_reg_perpt_erp_id_set(payload, erp_id);
  2751. mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
  2752. mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
  2753. mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
  2754. mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
  2755. }
  2756. /* PERAR - Policy-Engine Region Association Register
  2757. * -------------------------------------------------
  2758. * This register associates a hw region for region_id's. Changing on the fly
  2759. * is supported by the device.
  2760. */
  2761. #define MLXSW_REG_PERAR_ID 0x3026
  2762. #define MLXSW_REG_PERAR_LEN 0x08
  2763. MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
  2764. /* reg_perar_region_id
  2765. * Region identifier
  2766. * Range 0 .. cap_max_regions-1
  2767. * Access: Index
  2768. */
  2769. MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
  2770. static inline unsigned int
  2771. mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
  2772. {
  2773. return DIV_ROUND_UP(block_num, 4);
  2774. }
  2775. /* reg_perar_hw_region
  2776. * HW Region
  2777. * Range 0 .. cap_max_regions-1
  2778. * Default: hw_region = region_id
  2779. * For a 8 key block region, 2 consecutive regions are used
  2780. * For a 12 key block region, 3 consecutive regions are used
  2781. * Access: RW
  2782. */
  2783. MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
  2784. static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
  2785. u16 hw_region)
  2786. {
  2787. MLXSW_REG_ZERO(perar, payload);
  2788. mlxsw_reg_perar_region_id_set(payload, region_id);
  2789. mlxsw_reg_perar_hw_region_set(payload, hw_region);
  2790. }
  2791. /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
  2792. * -----------------------------------------------------
  2793. * This register is a new version of PTCE-V2 in order to support the
  2794. * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
  2795. */
  2796. #define MLXSW_REG_PTCE3_ID 0x3027
  2797. #define MLXSW_REG_PTCE3_LEN 0xF0
  2798. MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
  2799. /* reg_ptce3_v
  2800. * Valid.
  2801. * Access: RW
  2802. */
  2803. MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
  2804. enum mlxsw_reg_ptce3_op {
  2805. /* Write operation. Used to write a new entry to the table.
  2806. * All R/W fields are relevant for new entry. Activity bit is set
  2807. * for new entries. Write with v = 0 will delete the entry. Must
  2808. * not be used if an entry exists.
  2809. */
  2810. MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
  2811. /* Update operation */
  2812. MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
  2813. /* Read operation */
  2814. MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
  2815. };
  2816. /* reg_ptce3_op
  2817. * Access: OP
  2818. */
  2819. MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
  2820. /* reg_ptce3_priority
  2821. * Priority of the rule. Higher values win.
  2822. * For Spectrum-2 range is 1..cap_kvd_size - 1
  2823. * Note: Priority does not have to be unique per rule.
  2824. * Access: RW
  2825. */
  2826. MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
  2827. /* reg_ptce3_tcam_region_info
  2828. * Opaque object that represents the TCAM region.
  2829. * Access: Index
  2830. */
  2831. MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
  2832. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2833. /* reg_ptce3_flex2_key_blocks
  2834. * ACL key. The key must be masked according to eRP (if exists) or
  2835. * according to master mask.
  2836. * Access: Index
  2837. */
  2838. MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
  2839. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2840. /* reg_ptce3_erp_id
  2841. * eRP ID.
  2842. * Access: Index
  2843. */
  2844. MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
  2845. /* reg_ptce3_delta_start
  2846. * Start point of delta_value and delta_mask, in bits. Must not exceed
  2847. * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
  2848. * Access: Index
  2849. */
  2850. MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
  2851. /* reg_ptce3_delta_mask
  2852. * Delta mask.
  2853. * 0 - Ignore relevant bit in delta_value
  2854. * 1 - Compare relevant bit in delta_value
  2855. * Delta mask must not be set for reserved fields in the key blocks.
  2856. * Note: No delta when no eRPs. Thus, for regions with
  2857. * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
  2858. * Access: Index
  2859. */
  2860. MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
  2861. /* reg_ptce3_delta_value
  2862. * Delta value.
  2863. * Bits which are masked by delta_mask must be 0.
  2864. * Access: Index
  2865. */
  2866. MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
  2867. /* reg_ptce3_prune_vector
  2868. * Pruning vector relative to the PERPT.erp_id.
  2869. * Used for reducing lookups.
  2870. * 0 - NEED: Do a lookup using the eRP.
  2871. * 1 - PRUNE: Do not perform a lookup using the eRP.
  2872. * Maybe be modified by PEAPBL and PEAPBM.
  2873. * Note: In Spectrum-2, a region of 8 key blocks must be set to either
  2874. * all 1's or all 0's.
  2875. * Access: RW
  2876. */
  2877. MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
  2878. /* reg_ptce3_prune_ctcam
  2879. * Pruning on C-TCAM. Used for reducing lookups.
  2880. * 0 - NEED: Do a lookup in the C-TCAM.
  2881. * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
  2882. * Access: RW
  2883. */
  2884. MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
  2885. /* reg_ptce3_large_exists
  2886. * Large entry key ID exists.
  2887. * Within the region:
  2888. * 0 - SINGLE: The large_entry_key_id is not currently in use.
  2889. * For rule insert: The MSB of the key (blocks 6..11) will be added.
  2890. * For rule delete: The MSB of the key will be removed.
  2891. * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
  2892. * For rule insert: The MSB of the key (blocks 6..11) will not be added.
  2893. * For rule delete: The MSB of the key will not be removed.
  2894. * Access: WO
  2895. */
  2896. MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
  2897. /* reg_ptce3_large_entry_key_id
  2898. * Large entry key ID.
  2899. * A key for 12 key blocks rules. Reserved when region has less than 12 key
  2900. * blocks. Must be different for different keys which have the same common
  2901. * 6 key blocks (MSB, blocks 6..11) key within a region.
  2902. * Range is 0..cap_max_pe_large_key_id - 1
  2903. * Access: RW
  2904. */
  2905. MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
  2906. /* reg_ptce3_action_pointer
  2907. * Pointer to action.
  2908. * Range is 0..cap_max_kvd_action_sets - 1
  2909. * Access: RW
  2910. */
  2911. MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
  2912. static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
  2913. enum mlxsw_reg_ptce3_op op,
  2914. u32 priority,
  2915. const char *tcam_region_info,
  2916. const char *key, u8 erp_id,
  2917. u16 delta_start, u8 delta_mask,
  2918. u8 delta_value, bool large_exists,
  2919. u32 lkey_id, u32 action_pointer)
  2920. {
  2921. MLXSW_REG_ZERO(ptce3, payload);
  2922. mlxsw_reg_ptce3_v_set(payload, valid);
  2923. mlxsw_reg_ptce3_op_set(payload, op);
  2924. mlxsw_reg_ptce3_priority_set(payload, priority);
  2925. mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2926. mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
  2927. mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
  2928. mlxsw_reg_ptce3_delta_start_set(payload, delta_start);
  2929. mlxsw_reg_ptce3_delta_mask_set(payload, delta_mask);
  2930. mlxsw_reg_ptce3_delta_value_set(payload, delta_value);
  2931. mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
  2932. mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
  2933. mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
  2934. }
  2935. /* PERCR - Policy-Engine Region Configuration Register
  2936. * ---------------------------------------------------
  2937. * This register configures the region parameters. The region_id must be
  2938. * allocated.
  2939. */
  2940. #define MLXSW_REG_PERCR_ID 0x302A
  2941. #define MLXSW_REG_PERCR_LEN 0x80
  2942. MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
  2943. /* reg_percr_region_id
  2944. * Region identifier.
  2945. * Range 0..cap_max_regions-1
  2946. * Access: Index
  2947. */
  2948. MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
  2949. /* reg_percr_atcam_ignore_prune
  2950. * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
  2951. * Access: RW
  2952. */
  2953. MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
  2954. /* reg_percr_ctcam_ignore_prune
  2955. * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
  2956. * Access: RW
  2957. */
  2958. MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
  2959. /* reg_percr_bf_bypass
  2960. * Bloom filter bypass.
  2961. * 0 - Bloom filter is used (default)
  2962. * 1 - Bloom filter is bypassed. The bypass is an OR condition of
  2963. * region_id or eRP. See PERPT.bf_bypass
  2964. * Access: RW
  2965. */
  2966. MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
  2967. /* reg_percr_master_mask
  2968. * Master mask. Logical OR mask of all masks of all rules of a region
  2969. * (both A-TCAM and C-TCAM). When there are no eRPs
  2970. * (erpt_pointer_valid = 0), then this provides the mask.
  2971. * Access: RW
  2972. */
  2973. MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
  2974. static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
  2975. {
  2976. MLXSW_REG_ZERO(percr, payload);
  2977. mlxsw_reg_percr_region_id_set(payload, region_id);
  2978. mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
  2979. mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
  2980. mlxsw_reg_percr_bf_bypass_set(payload, false);
  2981. }
  2982. /* PERERP - Policy-Engine Region eRP Register
  2983. * ------------------------------------------
  2984. * This register configures the region eRP. The region_id must be
  2985. * allocated.
  2986. */
  2987. #define MLXSW_REG_PERERP_ID 0x302B
  2988. #define MLXSW_REG_PERERP_LEN 0x1C
  2989. MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
  2990. /* reg_pererp_region_id
  2991. * Region identifier.
  2992. * Range 0..cap_max_regions-1
  2993. * Access: Index
  2994. */
  2995. MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
  2996. /* reg_pererp_ctcam_le
  2997. * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
  2998. * Access: RW
  2999. */
  3000. MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
  3001. /* reg_pererp_erpt_pointer_valid
  3002. * erpt_pointer is valid.
  3003. * Access: RW
  3004. */
  3005. MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
  3006. /* reg_pererp_erpt_bank_pointer
  3007. * Pointer to eRP table bank. May be modified at any time.
  3008. * Range 0..cap_max_erp_table_banks-1
  3009. * Reserved when erpt_pointer_valid = 0
  3010. */
  3011. MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
  3012. /* reg_pererp_erpt_pointer
  3013. * Pointer to eRP table within the eRP bank. Can be changed for an
  3014. * existing region.
  3015. * Range 0..cap_max_erp_table_size-1
  3016. * Reserved when erpt_pointer_valid = 0
  3017. * Access: RW
  3018. */
  3019. MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
  3020. /* reg_pererp_erpt_vector
  3021. * Vector of allowed eRP indexes starting from erpt_pointer within the
  3022. * erpt_bank_pointer. Next entries will be in next bank.
  3023. * Note that eRP index is used and not eRP ID.
  3024. * Reserved when erpt_pointer_valid = 0
  3025. * Access: RW
  3026. */
  3027. MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
  3028. /* reg_pererp_master_rp_id
  3029. * Master RP ID. When there are no eRPs, then this provides the eRP ID
  3030. * for the lookup. Can be changed for an existing region.
  3031. * Reserved when erpt_pointer_valid = 1
  3032. * Access: RW
  3033. */
  3034. MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
  3035. static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
  3036. unsigned long *erp_vector,
  3037. unsigned long size)
  3038. {
  3039. unsigned long bit;
  3040. for_each_set_bit(bit, erp_vector, size)
  3041. mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
  3042. }
  3043. static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
  3044. bool ctcam_le, bool erpt_pointer_valid,
  3045. u8 erpt_bank_pointer, u8 erpt_pointer,
  3046. u8 master_rp_id)
  3047. {
  3048. MLXSW_REG_ZERO(pererp, payload);
  3049. mlxsw_reg_pererp_region_id_set(payload, region_id);
  3050. mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
  3051. mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
  3052. mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
  3053. mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
  3054. mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
  3055. }
  3056. /* PEABFE - Policy-Engine Algorithmic Bloom Filter Entries Register
  3057. * ----------------------------------------------------------------
  3058. * This register configures the Bloom filter entries.
  3059. */
  3060. #define MLXSW_REG_PEABFE_ID 0x3022
  3061. #define MLXSW_REG_PEABFE_BASE_LEN 0x10
  3062. #define MLXSW_REG_PEABFE_BF_REC_LEN 0x4
  3063. #define MLXSW_REG_PEABFE_BF_REC_MAX_COUNT 256
  3064. #define MLXSW_REG_PEABFE_LEN (MLXSW_REG_PEABFE_BASE_LEN + \
  3065. MLXSW_REG_PEABFE_BF_REC_LEN * \
  3066. MLXSW_REG_PEABFE_BF_REC_MAX_COUNT)
  3067. MLXSW_REG_DEFINE(peabfe, MLXSW_REG_PEABFE_ID, MLXSW_REG_PEABFE_LEN);
  3068. /* reg_peabfe_size
  3069. * Number of BF entries to be updated.
  3070. * Range 1..256
  3071. * Access: Op
  3072. */
  3073. MLXSW_ITEM32(reg, peabfe, size, 0x00, 0, 9);
  3074. /* reg_peabfe_bf_entry_state
  3075. * Bloom filter state
  3076. * 0 - Clear
  3077. * 1 - Set
  3078. * Access: RW
  3079. */
  3080. MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_state,
  3081. MLXSW_REG_PEABFE_BASE_LEN, 31, 1,
  3082. MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
  3083. /* reg_peabfe_bf_entry_bank
  3084. * Bloom filter bank ID
  3085. * Range 0..cap_max_erp_table_banks-1
  3086. * Access: Index
  3087. */
  3088. MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_bank,
  3089. MLXSW_REG_PEABFE_BASE_LEN, 24, 4,
  3090. MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
  3091. /* reg_peabfe_bf_entry_index
  3092. * Bloom filter entry index
  3093. * Range 0..2^cap_max_bf_log-1
  3094. * Access: Index
  3095. */
  3096. MLXSW_ITEM32_INDEXED(reg, peabfe, bf_entry_index,
  3097. MLXSW_REG_PEABFE_BASE_LEN, 0, 24,
  3098. MLXSW_REG_PEABFE_BF_REC_LEN, 0x00, false);
  3099. static inline void mlxsw_reg_peabfe_pack(char *payload)
  3100. {
  3101. MLXSW_REG_ZERO(peabfe, payload);
  3102. }
  3103. static inline void mlxsw_reg_peabfe_rec_pack(char *payload, int rec_index,
  3104. u8 state, u8 bank, u32 bf_index)
  3105. {
  3106. u8 num_rec = mlxsw_reg_peabfe_size_get(payload);
  3107. if (rec_index >= num_rec)
  3108. mlxsw_reg_peabfe_size_set(payload, rec_index + 1);
  3109. mlxsw_reg_peabfe_bf_entry_state_set(payload, rec_index, state);
  3110. mlxsw_reg_peabfe_bf_entry_bank_set(payload, rec_index, bank);
  3111. mlxsw_reg_peabfe_bf_entry_index_set(payload, rec_index, bf_index);
  3112. }
  3113. /* IEDR - Infrastructure Entry Delete Register
  3114. * ----------------------------------------------------
  3115. * This register is used for deleting entries from the entry tables.
  3116. * It is legitimate to attempt to delete a nonexisting entry (the device will
  3117. * respond as a good flow).
  3118. */
  3119. #define MLXSW_REG_IEDR_ID 0x3804
  3120. #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
  3121. #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
  3122. #define MLXSW_REG_IEDR_REC_MAX_COUNT 64
  3123. #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
  3124. MLXSW_REG_IEDR_REC_LEN * \
  3125. MLXSW_REG_IEDR_REC_MAX_COUNT)
  3126. MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
  3127. /* reg_iedr_num_rec
  3128. * Number of records.
  3129. * Access: OP
  3130. */
  3131. MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
  3132. /* reg_iedr_rec_type
  3133. * Resource type.
  3134. * Access: OP
  3135. */
  3136. MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
  3137. MLXSW_REG_IEDR_REC_LEN, 0x00, false);
  3138. /* reg_iedr_rec_size
  3139. * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
  3140. * Access: OP
  3141. */
  3142. MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 13,
  3143. MLXSW_REG_IEDR_REC_LEN, 0x00, false);
  3144. /* reg_iedr_rec_index_start
  3145. * Resource index start.
  3146. * Access: OP
  3147. */
  3148. MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
  3149. MLXSW_REG_IEDR_REC_LEN, 0x04, false);
  3150. static inline void mlxsw_reg_iedr_pack(char *payload)
  3151. {
  3152. MLXSW_REG_ZERO(iedr, payload);
  3153. }
  3154. static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
  3155. u8 rec_type, u16 rec_size,
  3156. u32 rec_index_start)
  3157. {
  3158. u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
  3159. if (rec_index >= num_rec)
  3160. mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
  3161. mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
  3162. mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
  3163. mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
  3164. }
  3165. /* QPTS - QoS Priority Trust State Register
  3166. * ----------------------------------------
  3167. * This register controls the port policy to calculate the switch priority and
  3168. * packet color based on incoming packet fields.
  3169. */
  3170. #define MLXSW_REG_QPTS_ID 0x4002
  3171. #define MLXSW_REG_QPTS_LEN 0x8
  3172. MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
  3173. /* reg_qpts_local_port
  3174. * Local port number.
  3175. * Access: Index
  3176. *
  3177. * Note: CPU port is supported.
  3178. */
  3179. MLXSW_ITEM32_LP(reg, qpts, 0x00, 16, 0x00, 12);
  3180. enum mlxsw_reg_qpts_trust_state {
  3181. MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
  3182. MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
  3183. };
  3184. /* reg_qpts_trust_state
  3185. * Trust state for a given port.
  3186. * Access: RW
  3187. */
  3188. MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
  3189. static inline void mlxsw_reg_qpts_pack(char *payload, u16 local_port,
  3190. enum mlxsw_reg_qpts_trust_state ts)
  3191. {
  3192. MLXSW_REG_ZERO(qpts, payload);
  3193. mlxsw_reg_qpts_local_port_set(payload, local_port);
  3194. mlxsw_reg_qpts_trust_state_set(payload, ts);
  3195. }
  3196. /* QPCR - QoS Policer Configuration Register
  3197. * -----------------------------------------
  3198. * The QPCR register is used to create policers - that limit
  3199. * the rate of bytes or packets via some trap group.
  3200. */
  3201. #define MLXSW_REG_QPCR_ID 0x4004
  3202. #define MLXSW_REG_QPCR_LEN 0x28
  3203. MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
  3204. enum mlxsw_reg_qpcr_g {
  3205. MLXSW_REG_QPCR_G_GLOBAL = 2,
  3206. MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
  3207. };
  3208. /* reg_qpcr_g
  3209. * The policer type.
  3210. * Access: Index
  3211. */
  3212. MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
  3213. /* reg_qpcr_pid
  3214. * Policer ID.
  3215. * Access: Index
  3216. */
  3217. MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
  3218. /* reg_qpcr_clear_counter
  3219. * Clear counters.
  3220. * Access: OP
  3221. */
  3222. MLXSW_ITEM32(reg, qpcr, clear_counter, 0x04, 31, 1);
  3223. /* reg_qpcr_color_aware
  3224. * Is the policer aware of colors.
  3225. * Must be 0 (unaware) for cpu port.
  3226. * Access: RW for unbounded policer. RO for bounded policer.
  3227. */
  3228. MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
  3229. /* reg_qpcr_bytes
  3230. * Is policer limit is for bytes per sec or packets per sec.
  3231. * 0 - packets
  3232. * 1 - bytes
  3233. * Access: RW for unbounded policer. RO for bounded policer.
  3234. */
  3235. MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
  3236. enum mlxsw_reg_qpcr_ir_units {
  3237. MLXSW_REG_QPCR_IR_UNITS_M,
  3238. MLXSW_REG_QPCR_IR_UNITS_K,
  3239. };
  3240. /* reg_qpcr_ir_units
  3241. * Policer's units for cir and eir fields (for bytes limits only)
  3242. * 1 - 10^3
  3243. * 0 - 10^6
  3244. * Access: OP
  3245. */
  3246. MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
  3247. enum mlxsw_reg_qpcr_rate_type {
  3248. MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
  3249. MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
  3250. };
  3251. /* reg_qpcr_rate_type
  3252. * Policer can have one limit (single rate) or 2 limits with specific operation
  3253. * for packets that exceed the lower rate but not the upper one.
  3254. * (For cpu port must be single rate)
  3255. * Access: RW for unbounded policer. RO for bounded policer.
  3256. */
  3257. MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
  3258. /* reg_qpc_cbs
  3259. * Policer's committed burst size.
  3260. * The policer is working with time slices of 50 nano sec. By default every
  3261. * slice is granted the proportionate share of the committed rate. If we want to
  3262. * allow a slice to exceed that share (while still keeping the rate per sec) we
  3263. * can allow burst. The burst size is between the default proportionate share
  3264. * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
  3265. * committed rate will result in exceeding the rate). The burst size must be a
  3266. * log of 2 and will be determined by 2^cbs.
  3267. * Access: RW
  3268. */
  3269. MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
  3270. /* reg_qpcr_cir
  3271. * Policer's committed rate.
  3272. * The rate used for sungle rate, the lower rate for double rate.
  3273. * For bytes limits, the rate will be this value * the unit from ir_units.
  3274. * (Resolution error is up to 1%).
  3275. * Access: RW
  3276. */
  3277. MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
  3278. /* reg_qpcr_eir
  3279. * Policer's exceed rate.
  3280. * The higher rate for double rate, reserved for single rate.
  3281. * Lower rate for double rate policer.
  3282. * For bytes limits, the rate will be this value * the unit from ir_units.
  3283. * (Resolution error is up to 1%).
  3284. * Access: RW
  3285. */
  3286. MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
  3287. #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
  3288. /* reg_qpcr_exceed_action.
  3289. * What to do with packets between the 2 limits for double rate.
  3290. * Access: RW for unbounded policer. RO for bounded policer.
  3291. */
  3292. MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
  3293. enum mlxsw_reg_qpcr_action {
  3294. /* Discard */
  3295. MLXSW_REG_QPCR_ACTION_DISCARD = 1,
  3296. /* Forward and set color to red.
  3297. * If the packet is intended to cpu port, it will be dropped.
  3298. */
  3299. MLXSW_REG_QPCR_ACTION_FORWARD = 2,
  3300. };
  3301. /* reg_qpcr_violate_action
  3302. * What to do with packets that cross the cir limit (for single rate) or the eir
  3303. * limit (for double rate).
  3304. * Access: RW for unbounded policer. RO for bounded policer.
  3305. */
  3306. MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
  3307. /* reg_qpcr_violate_count
  3308. * Counts the number of times violate_action happened on this PID.
  3309. * Access: RW
  3310. */
  3311. MLXSW_ITEM64(reg, qpcr, violate_count, 0x20, 0, 64);
  3312. /* Packets */
  3313. #define MLXSW_REG_QPCR_LOWEST_CIR 1
  3314. #define MLXSW_REG_QPCR_HIGHEST_CIR (2 * 1000 * 1000 * 1000) /* 2Gpps */
  3315. #define MLXSW_REG_QPCR_LOWEST_CBS 4
  3316. #define MLXSW_REG_QPCR_HIGHEST_CBS 24
  3317. /* Bandwidth */
  3318. #define MLXSW_REG_QPCR_LOWEST_CIR_BITS 1024 /* bps */
  3319. #define MLXSW_REG_QPCR_HIGHEST_CIR_BITS 2000000000000ULL /* 2Tbps */
  3320. #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP1 4
  3321. #define MLXSW_REG_QPCR_LOWEST_CBS_BITS_SP2 4
  3322. #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP1 25
  3323. #define MLXSW_REG_QPCR_HIGHEST_CBS_BITS_SP2 31
  3324. static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
  3325. enum mlxsw_reg_qpcr_ir_units ir_units,
  3326. bool bytes, u32 cir, u16 cbs)
  3327. {
  3328. MLXSW_REG_ZERO(qpcr, payload);
  3329. mlxsw_reg_qpcr_pid_set(payload, pid);
  3330. mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
  3331. mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
  3332. mlxsw_reg_qpcr_violate_action_set(payload,
  3333. MLXSW_REG_QPCR_ACTION_DISCARD);
  3334. mlxsw_reg_qpcr_cir_set(payload, cir);
  3335. mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
  3336. mlxsw_reg_qpcr_bytes_set(payload, bytes);
  3337. mlxsw_reg_qpcr_cbs_set(payload, cbs);
  3338. }
  3339. /* QTCT - QoS Switch Traffic Class Table
  3340. * -------------------------------------
  3341. * Configures the mapping between the packet switch priority and the
  3342. * traffic class on the transmit port.
  3343. */
  3344. #define MLXSW_REG_QTCT_ID 0x400A
  3345. #define MLXSW_REG_QTCT_LEN 0x08
  3346. MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
  3347. /* reg_qtct_local_port
  3348. * Local port number.
  3349. * Access: Index
  3350. *
  3351. * Note: CPU port is not supported.
  3352. */
  3353. MLXSW_ITEM32_LP(reg, qtct, 0x00, 16, 0x00, 12);
  3354. /* reg_qtct_sub_port
  3355. * Virtual port within the physical port.
  3356. * Should be set to 0 when virtual ports are not enabled on the port.
  3357. * Access: Index
  3358. */
  3359. MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
  3360. /* reg_qtct_switch_prio
  3361. * Switch priority.
  3362. * Access: Index
  3363. */
  3364. MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
  3365. /* reg_qtct_tclass
  3366. * Traffic class.
  3367. * Default values:
  3368. * switch_prio 0 : tclass 1
  3369. * switch_prio 1 : tclass 0
  3370. * switch_prio i : tclass i, for i > 1
  3371. * Access: RW
  3372. */
  3373. MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
  3374. static inline void mlxsw_reg_qtct_pack(char *payload, u16 local_port,
  3375. u8 switch_prio, u8 tclass)
  3376. {
  3377. MLXSW_REG_ZERO(qtct, payload);
  3378. mlxsw_reg_qtct_local_port_set(payload, local_port);
  3379. mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
  3380. mlxsw_reg_qtct_tclass_set(payload, tclass);
  3381. }
  3382. /* QEEC - QoS ETS Element Configuration Register
  3383. * ---------------------------------------------
  3384. * Configures the ETS elements.
  3385. */
  3386. #define MLXSW_REG_QEEC_ID 0x400D
  3387. #define MLXSW_REG_QEEC_LEN 0x20
  3388. MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
  3389. /* reg_qeec_local_port
  3390. * Local port number.
  3391. * Access: Index
  3392. *
  3393. * Note: CPU port is supported.
  3394. */
  3395. MLXSW_ITEM32_LP(reg, qeec, 0x00, 16, 0x00, 12);
  3396. enum mlxsw_reg_qeec_hr {
  3397. MLXSW_REG_QEEC_HR_PORT,
  3398. MLXSW_REG_QEEC_HR_GROUP,
  3399. MLXSW_REG_QEEC_HR_SUBGROUP,
  3400. MLXSW_REG_QEEC_HR_TC,
  3401. };
  3402. /* reg_qeec_element_hierarchy
  3403. * 0 - Port
  3404. * 1 - Group
  3405. * 2 - Subgroup
  3406. * 3 - Traffic Class
  3407. * Access: Index
  3408. */
  3409. MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
  3410. /* reg_qeec_element_index
  3411. * The index of the element in the hierarchy.
  3412. * Access: Index
  3413. */
  3414. MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
  3415. /* reg_qeec_next_element_index
  3416. * The index of the next (lower) element in the hierarchy.
  3417. * Access: RW
  3418. *
  3419. * Note: Reserved for element_hierarchy 0.
  3420. */
  3421. MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
  3422. /* reg_qeec_mise
  3423. * Min shaper configuration enable. Enables configuration of the min
  3424. * shaper on this ETS element
  3425. * 0 - Disable
  3426. * 1 - Enable
  3427. * Access: RW
  3428. */
  3429. MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
  3430. /* reg_qeec_ptps
  3431. * PTP shaper
  3432. * 0: regular shaper mode
  3433. * 1: PTP oriented shaper
  3434. * Allowed only for hierarchy 0
  3435. * Not supported for CPU port
  3436. * Note that ptps mode may affect the shaper rates of all hierarchies
  3437. * Supported only on Spectrum-1
  3438. * Access: RW
  3439. */
  3440. MLXSW_ITEM32(reg, qeec, ptps, 0x0C, 29, 1);
  3441. enum {
  3442. MLXSW_REG_QEEC_BYTES_MODE,
  3443. MLXSW_REG_QEEC_PACKETS_MODE,
  3444. };
  3445. /* reg_qeec_pb
  3446. * Packets or bytes mode.
  3447. * 0 - Bytes mode
  3448. * 1 - Packets mode
  3449. * Access: RW
  3450. *
  3451. * Note: Used for max shaper configuration. For Spectrum, packets mode
  3452. * is supported only for traffic classes of CPU port.
  3453. */
  3454. MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
  3455. /* The smallest permitted min shaper rate. */
  3456. #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
  3457. /* reg_qeec_min_shaper_rate
  3458. * Min shaper information rate.
  3459. * For CPU port, can only be configured for port hierarchy.
  3460. * When in bytes mode, value is specified in units of 1000bps.
  3461. * Access: RW
  3462. */
  3463. MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
  3464. /* reg_qeec_mase
  3465. * Max shaper configuration enable. Enables configuration of the max
  3466. * shaper on this ETS element.
  3467. * 0 - Disable
  3468. * 1 - Enable
  3469. * Access: RW
  3470. */
  3471. MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
  3472. /* The largest max shaper value possible to disable the shaper. */
  3473. #define MLXSW_REG_QEEC_MAS_DIS ((1u << 31) - 1) /* Kbps */
  3474. /* reg_qeec_max_shaper_rate
  3475. * Max shaper information rate.
  3476. * For CPU port, can only be configured for port hierarchy.
  3477. * When in bytes mode, value is specified in units of 1000bps.
  3478. * Access: RW
  3479. */
  3480. MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 31);
  3481. /* reg_qeec_de
  3482. * DWRR configuration enable. Enables configuration of the dwrr and
  3483. * dwrr_weight.
  3484. * 0 - Disable
  3485. * 1 - Enable
  3486. * Access: RW
  3487. */
  3488. MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
  3489. /* reg_qeec_dwrr
  3490. * Transmission selection algorithm to use on the link going down from
  3491. * the ETS element.
  3492. * 0 - Strict priority
  3493. * 1 - DWRR
  3494. * Access: RW
  3495. */
  3496. MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
  3497. /* reg_qeec_dwrr_weight
  3498. * DWRR weight on the link going down from the ETS element. The
  3499. * percentage of bandwidth guaranteed to an ETS element within
  3500. * its hierarchy. The sum of all weights across all ETS elements
  3501. * within one hierarchy should be equal to 100. Reserved when
  3502. * transmission selection algorithm is strict priority.
  3503. * Access: RW
  3504. */
  3505. MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
  3506. /* reg_qeec_max_shaper_bs
  3507. * Max shaper burst size
  3508. * Burst size is 2^max_shaper_bs * 512 bits
  3509. * For Spectrum-1: Range is: 5..25
  3510. * For Spectrum-2: Range is: 11..25
  3511. * Reserved when ptps = 1
  3512. * Access: RW
  3513. */
  3514. MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6);
  3515. #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25
  3516. #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5
  3517. #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11
  3518. #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11
  3519. #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP4 11
  3520. static inline void mlxsw_reg_qeec_pack(char *payload, u16 local_port,
  3521. enum mlxsw_reg_qeec_hr hr, u8 index,
  3522. u8 next_index)
  3523. {
  3524. MLXSW_REG_ZERO(qeec, payload);
  3525. mlxsw_reg_qeec_local_port_set(payload, local_port);
  3526. mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
  3527. mlxsw_reg_qeec_element_index_set(payload, index);
  3528. mlxsw_reg_qeec_next_element_index_set(payload, next_index);
  3529. }
  3530. static inline void mlxsw_reg_qeec_ptps_pack(char *payload, u16 local_port,
  3531. bool ptps)
  3532. {
  3533. MLXSW_REG_ZERO(qeec, payload);
  3534. mlxsw_reg_qeec_local_port_set(payload, local_port);
  3535. mlxsw_reg_qeec_element_hierarchy_set(payload, MLXSW_REG_QEEC_HR_PORT);
  3536. mlxsw_reg_qeec_ptps_set(payload, ptps);
  3537. }
  3538. /* QRWE - QoS ReWrite Enable
  3539. * -------------------------
  3540. * This register configures the rewrite enable per receive port.
  3541. */
  3542. #define MLXSW_REG_QRWE_ID 0x400F
  3543. #define MLXSW_REG_QRWE_LEN 0x08
  3544. MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
  3545. /* reg_qrwe_local_port
  3546. * Local port number.
  3547. * Access: Index
  3548. *
  3549. * Note: CPU port is supported. No support for router port.
  3550. */
  3551. MLXSW_ITEM32_LP(reg, qrwe, 0x00, 16, 0x00, 12);
  3552. /* reg_qrwe_dscp
  3553. * Whether to enable DSCP rewrite (default is 0, don't rewrite).
  3554. * Access: RW
  3555. */
  3556. MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
  3557. /* reg_qrwe_pcp
  3558. * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
  3559. * Access: RW
  3560. */
  3561. MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
  3562. static inline void mlxsw_reg_qrwe_pack(char *payload, u16 local_port,
  3563. bool rewrite_pcp, bool rewrite_dscp)
  3564. {
  3565. MLXSW_REG_ZERO(qrwe, payload);
  3566. mlxsw_reg_qrwe_local_port_set(payload, local_port);
  3567. mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
  3568. mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
  3569. }
  3570. /* QPDSM - QoS Priority to DSCP Mapping
  3571. * ------------------------------------
  3572. * QoS Priority to DSCP Mapping Register
  3573. */
  3574. #define MLXSW_REG_QPDSM_ID 0x4011
  3575. #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
  3576. #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
  3577. #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
  3578. #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
  3579. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
  3580. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
  3581. MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
  3582. /* reg_qpdsm_local_port
  3583. * Local Port. Supported for data packets from CPU port.
  3584. * Access: Index
  3585. */
  3586. MLXSW_ITEM32_LP(reg, qpdsm, 0x00, 16, 0x00, 12);
  3587. /* reg_qpdsm_prio_entry_color0_e
  3588. * Enable update of the entry for color 0 and a given port.
  3589. * Access: WO
  3590. */
  3591. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
  3592. MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
  3593. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3594. /* reg_qpdsm_prio_entry_color0_dscp
  3595. * DSCP field in the outer label of the packet for color 0 and a given port.
  3596. * Reserved when e=0.
  3597. * Access: RW
  3598. */
  3599. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
  3600. MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
  3601. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3602. /* reg_qpdsm_prio_entry_color1_e
  3603. * Enable update of the entry for color 1 and a given port.
  3604. * Access: WO
  3605. */
  3606. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
  3607. MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
  3608. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3609. /* reg_qpdsm_prio_entry_color1_dscp
  3610. * DSCP field in the outer label of the packet for color 1 and a given port.
  3611. * Reserved when e=0.
  3612. * Access: RW
  3613. */
  3614. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
  3615. MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
  3616. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3617. /* reg_qpdsm_prio_entry_color2_e
  3618. * Enable update of the entry for color 2 and a given port.
  3619. * Access: WO
  3620. */
  3621. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
  3622. MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
  3623. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3624. /* reg_qpdsm_prio_entry_color2_dscp
  3625. * DSCP field in the outer label of the packet for color 2 and a given port.
  3626. * Reserved when e=0.
  3627. * Access: RW
  3628. */
  3629. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
  3630. MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
  3631. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  3632. static inline void mlxsw_reg_qpdsm_pack(char *payload, u16 local_port)
  3633. {
  3634. MLXSW_REG_ZERO(qpdsm, payload);
  3635. mlxsw_reg_qpdsm_local_port_set(payload, local_port);
  3636. }
  3637. static inline void
  3638. mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
  3639. {
  3640. mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
  3641. mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
  3642. mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
  3643. mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
  3644. mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
  3645. mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
  3646. }
  3647. /* QPDP - QoS Port DSCP to Priority Mapping Register
  3648. * -------------------------------------------------
  3649. * This register controls the port default Switch Priority and Color. The
  3650. * default Switch Priority and Color are used for frames where the trust state
  3651. * uses default values. All member ports of a LAG should be configured with the
  3652. * same default values.
  3653. */
  3654. #define MLXSW_REG_QPDP_ID 0x4007
  3655. #define MLXSW_REG_QPDP_LEN 0x8
  3656. MLXSW_REG_DEFINE(qpdp, MLXSW_REG_QPDP_ID, MLXSW_REG_QPDP_LEN);
  3657. /* reg_qpdp_local_port
  3658. * Local Port. Supported for data packets from CPU port.
  3659. * Access: Index
  3660. */
  3661. MLXSW_ITEM32_LP(reg, qpdp, 0x00, 16, 0x00, 12);
  3662. /* reg_qpdp_switch_prio
  3663. * Default port Switch Priority (default 0)
  3664. * Access: RW
  3665. */
  3666. MLXSW_ITEM32(reg, qpdp, switch_prio, 0x04, 0, 4);
  3667. static inline void mlxsw_reg_qpdp_pack(char *payload, u16 local_port,
  3668. u8 switch_prio)
  3669. {
  3670. MLXSW_REG_ZERO(qpdp, payload);
  3671. mlxsw_reg_qpdp_local_port_set(payload, local_port);
  3672. mlxsw_reg_qpdp_switch_prio_set(payload, switch_prio);
  3673. }
  3674. /* QPDPM - QoS Port DSCP to Priority Mapping Register
  3675. * --------------------------------------------------
  3676. * This register controls the mapping from DSCP field to
  3677. * Switch Priority for IP packets.
  3678. */
  3679. #define MLXSW_REG_QPDPM_ID 0x4013
  3680. #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
  3681. #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
  3682. #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
  3683. #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
  3684. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
  3685. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
  3686. MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
  3687. /* reg_qpdpm_local_port
  3688. * Local Port. Supported for data packets from CPU port.
  3689. * Access: Index
  3690. */
  3691. MLXSW_ITEM32_LP(reg, qpdpm, 0x00, 16, 0x00, 12);
  3692. /* reg_qpdpm_dscp_e
  3693. * Enable update of the specific entry. When cleared, the switch_prio and color
  3694. * fields are ignored and the previous switch_prio and color values are
  3695. * preserved.
  3696. * Access: WO
  3697. */
  3698. MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
  3699. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  3700. /* reg_qpdpm_dscp_prio
  3701. * The new Switch Priority value for the relevant DSCP value.
  3702. * Access: RW
  3703. */
  3704. MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
  3705. MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
  3706. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  3707. static inline void mlxsw_reg_qpdpm_pack(char *payload, u16 local_port)
  3708. {
  3709. MLXSW_REG_ZERO(qpdpm, payload);
  3710. mlxsw_reg_qpdpm_local_port_set(payload, local_port);
  3711. }
  3712. static inline void
  3713. mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
  3714. {
  3715. mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
  3716. mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
  3717. }
  3718. /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
  3719. * ------------------------------------------------------------------
  3720. * This register configures if the Switch Priority to Traffic Class mapping is
  3721. * based on Multicast packet indication. If so, then multicast packets will get
  3722. * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
  3723. * QTCT.
  3724. * By default, Switch Priority to Traffic Class mapping is not based on
  3725. * Multicast packet indication.
  3726. */
  3727. #define MLXSW_REG_QTCTM_ID 0x401A
  3728. #define MLXSW_REG_QTCTM_LEN 0x08
  3729. MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
  3730. /* reg_qtctm_local_port
  3731. * Local port number.
  3732. * No support for CPU port.
  3733. * Access: Index
  3734. */
  3735. MLXSW_ITEM32_LP(reg, qtctm, 0x00, 16, 0x00, 12);
  3736. /* reg_qtctm_mc
  3737. * Multicast Mode
  3738. * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
  3739. * indication (default is 0, not based on Multicast packet indication).
  3740. */
  3741. MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
  3742. static inline void
  3743. mlxsw_reg_qtctm_pack(char *payload, u16 local_port, bool mc)
  3744. {
  3745. MLXSW_REG_ZERO(qtctm, payload);
  3746. mlxsw_reg_qtctm_local_port_set(payload, local_port);
  3747. mlxsw_reg_qtctm_mc_set(payload, mc);
  3748. }
  3749. /* QPSC - QoS PTP Shaper Configuration Register
  3750. * --------------------------------------------
  3751. * The QPSC allows advanced configuration of the shapers when QEEC.ptps=1.
  3752. * Supported only on Spectrum-1.
  3753. */
  3754. #define MLXSW_REG_QPSC_ID 0x401B
  3755. #define MLXSW_REG_QPSC_LEN 0x28
  3756. MLXSW_REG_DEFINE(qpsc, MLXSW_REG_QPSC_ID, MLXSW_REG_QPSC_LEN);
  3757. enum mlxsw_reg_qpsc_port_speed {
  3758. MLXSW_REG_QPSC_PORT_SPEED_100M,
  3759. MLXSW_REG_QPSC_PORT_SPEED_1G,
  3760. MLXSW_REG_QPSC_PORT_SPEED_10G,
  3761. MLXSW_REG_QPSC_PORT_SPEED_25G,
  3762. };
  3763. /* reg_qpsc_port_speed
  3764. * Port speed.
  3765. * Access: Index
  3766. */
  3767. MLXSW_ITEM32(reg, qpsc, port_speed, 0x00, 0, 4);
  3768. /* reg_qpsc_shaper_time_exp
  3769. * The base-time-interval for updating the shapers tokens (for all hierarchies).
  3770. * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
  3771. * shaper_rate = 64bit * shaper_inc / shaper_update_rate
  3772. * Access: RW
  3773. */
  3774. MLXSW_ITEM32(reg, qpsc, shaper_time_exp, 0x04, 16, 4);
  3775. /* reg_qpsc_shaper_time_mantissa
  3776. * The base-time-interval for updating the shapers tokens (for all hierarchies).
  3777. * shaper_update_rate = 2 ^ shaper_time_exp * (1 + shaper_time_mantissa) * 32nSec
  3778. * shaper_rate = 64bit * shaper_inc / shaper_update_rate
  3779. * Access: RW
  3780. */
  3781. MLXSW_ITEM32(reg, qpsc, shaper_time_mantissa, 0x04, 0, 5);
  3782. /* reg_qpsc_shaper_inc
  3783. * Number of tokens added to shaper on each update.
  3784. * Units of 8B.
  3785. * Access: RW
  3786. */
  3787. MLXSW_ITEM32(reg, qpsc, shaper_inc, 0x08, 0, 5);
  3788. /* reg_qpsc_shaper_bs
  3789. * Max shaper Burst size.
  3790. * Burst size is 2 ^ max_shaper_bs * 512 [bits]
  3791. * Range is: 5..25 (from 2KB..2GB)
  3792. * Access: RW
  3793. */
  3794. MLXSW_ITEM32(reg, qpsc, shaper_bs, 0x0C, 0, 6);
  3795. /* reg_qpsc_ptsc_we
  3796. * Write enable to port_to_shaper_credits.
  3797. * Access: WO
  3798. */
  3799. MLXSW_ITEM32(reg, qpsc, ptsc_we, 0x10, 31, 1);
  3800. /* reg_qpsc_port_to_shaper_credits
  3801. * For split ports: range 1..57
  3802. * For non-split ports: range 1..112
  3803. * Written only when ptsc_we is set.
  3804. * Access: RW
  3805. */
  3806. MLXSW_ITEM32(reg, qpsc, port_to_shaper_credits, 0x10, 0, 8);
  3807. /* reg_qpsc_ing_timestamp_inc
  3808. * Ingress timestamp increment.
  3809. * 2's complement.
  3810. * The timestamp of MTPPTR at ingress will be incremented by this value. Global
  3811. * value for all ports.
  3812. * Same units as used by MTPPTR.
  3813. * Access: RW
  3814. */
  3815. MLXSW_ITEM32(reg, qpsc, ing_timestamp_inc, 0x20, 0, 32);
  3816. /* reg_qpsc_egr_timestamp_inc
  3817. * Egress timestamp increment.
  3818. * 2's complement.
  3819. * The timestamp of MTPPTR at egress will be incremented by this value. Global
  3820. * value for all ports.
  3821. * Same units as used by MTPPTR.
  3822. * Access: RW
  3823. */
  3824. MLXSW_ITEM32(reg, qpsc, egr_timestamp_inc, 0x24, 0, 32);
  3825. static inline void
  3826. mlxsw_reg_qpsc_pack(char *payload, enum mlxsw_reg_qpsc_port_speed port_speed,
  3827. u8 shaper_time_exp, u8 shaper_time_mantissa, u8 shaper_inc,
  3828. u8 shaper_bs, u8 port_to_shaper_credits,
  3829. int ing_timestamp_inc, int egr_timestamp_inc)
  3830. {
  3831. MLXSW_REG_ZERO(qpsc, payload);
  3832. mlxsw_reg_qpsc_port_speed_set(payload, port_speed);
  3833. mlxsw_reg_qpsc_shaper_time_exp_set(payload, shaper_time_exp);
  3834. mlxsw_reg_qpsc_shaper_time_mantissa_set(payload, shaper_time_mantissa);
  3835. mlxsw_reg_qpsc_shaper_inc_set(payload, shaper_inc);
  3836. mlxsw_reg_qpsc_shaper_bs_set(payload, shaper_bs);
  3837. mlxsw_reg_qpsc_ptsc_we_set(payload, true);
  3838. mlxsw_reg_qpsc_port_to_shaper_credits_set(payload, port_to_shaper_credits);
  3839. mlxsw_reg_qpsc_ing_timestamp_inc_set(payload, ing_timestamp_inc);
  3840. mlxsw_reg_qpsc_egr_timestamp_inc_set(payload, egr_timestamp_inc);
  3841. }
  3842. /* PMLP - Ports Module to Local Port Register
  3843. * ------------------------------------------
  3844. * Configures the assignment of modules to local ports.
  3845. */
  3846. #define MLXSW_REG_PMLP_ID 0x5002
  3847. #define MLXSW_REG_PMLP_LEN 0x40
  3848. MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
  3849. /* reg_pmlp_rxtx
  3850. * 0 - Tx value is used for both Tx and Rx.
  3851. * 1 - Rx value is taken from a separte field.
  3852. * Access: RW
  3853. */
  3854. MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
  3855. /* reg_pmlp_local_port
  3856. * Local port number.
  3857. * Access: Index
  3858. */
  3859. MLXSW_ITEM32_LP(reg, pmlp, 0x00, 16, 0x00, 12);
  3860. /* reg_pmlp_width
  3861. * 0 - Unmap local port.
  3862. * 1 - Lane 0 is used.
  3863. * 2 - Lanes 0 and 1 are used.
  3864. * 4 - Lanes 0, 1, 2 and 3 are used.
  3865. * 8 - Lanes 0-7 are used.
  3866. * Access: RW
  3867. */
  3868. MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
  3869. /* reg_pmlp_module
  3870. * Module number.
  3871. * Access: RW
  3872. */
  3873. MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
  3874. /* reg_pmlp_slot_index
  3875. * Module number.
  3876. * Slot_index
  3877. * Slot_index = 0 represent the onboard (motherboard).
  3878. * In case of non-modular system only slot_index = 0 is available.
  3879. * Access: RW
  3880. */
  3881. MLXSW_ITEM32_INDEXED(reg, pmlp, slot_index, 0x04, 8, 4, 0x04, 0x00, false);
  3882. /* reg_pmlp_tx_lane
  3883. * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
  3884. * Access: RW
  3885. */
  3886. MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 4, 0x04, 0x00, false);
  3887. /* reg_pmlp_rx_lane
  3888. * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
  3889. * equal to Tx lane.
  3890. * Access: RW
  3891. */
  3892. MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 4, 0x04, 0x00, false);
  3893. static inline void mlxsw_reg_pmlp_pack(char *payload, u16 local_port)
  3894. {
  3895. MLXSW_REG_ZERO(pmlp, payload);
  3896. mlxsw_reg_pmlp_local_port_set(payload, local_port);
  3897. }
  3898. /* PMTU - Port MTU Register
  3899. * ------------------------
  3900. * Configures and reports the port MTU.
  3901. */
  3902. #define MLXSW_REG_PMTU_ID 0x5003
  3903. #define MLXSW_REG_PMTU_LEN 0x10
  3904. MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
  3905. /* reg_pmtu_local_port
  3906. * Local port number.
  3907. * Access: Index
  3908. */
  3909. MLXSW_ITEM32_LP(reg, pmtu, 0x00, 16, 0x00, 12);
  3910. /* reg_pmtu_max_mtu
  3911. * Maximum MTU.
  3912. * When port type (e.g. Ethernet) is configured, the relevant MTU is
  3913. * reported, otherwise the minimum between the max_mtu of the different
  3914. * types is reported.
  3915. * Access: RO
  3916. */
  3917. MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
  3918. /* reg_pmtu_admin_mtu
  3919. * MTU value to set port to. Must be smaller or equal to max_mtu.
  3920. * Note: If port type is Infiniband, then port must be disabled, when its
  3921. * MTU is set.
  3922. * Access: RW
  3923. */
  3924. MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
  3925. /* reg_pmtu_oper_mtu
  3926. * The actual MTU configured on the port. Packets exceeding this size
  3927. * will be dropped.
  3928. * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
  3929. * oper_mtu might be smaller than admin_mtu.
  3930. * Access: RO
  3931. */
  3932. MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
  3933. static inline void mlxsw_reg_pmtu_pack(char *payload, u16 local_port,
  3934. u16 new_mtu)
  3935. {
  3936. MLXSW_REG_ZERO(pmtu, payload);
  3937. mlxsw_reg_pmtu_local_port_set(payload, local_port);
  3938. mlxsw_reg_pmtu_max_mtu_set(payload, 0);
  3939. mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
  3940. mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
  3941. }
  3942. /* PTYS - Port Type and Speed Register
  3943. * -----------------------------------
  3944. * Configures and reports the port speed type.
  3945. *
  3946. * Note: When set while the link is up, the changes will not take effect
  3947. * until the port transitions from down to up state.
  3948. */
  3949. #define MLXSW_REG_PTYS_ID 0x5004
  3950. #define MLXSW_REG_PTYS_LEN 0x40
  3951. MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
  3952. /* an_disable_admin
  3953. * Auto negotiation disable administrative configuration
  3954. * 0 - Device doesn't support AN disable.
  3955. * 1 - Device supports AN disable.
  3956. * Access: RW
  3957. */
  3958. MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
  3959. /* reg_ptys_local_port
  3960. * Local port number.
  3961. * Access: Index
  3962. */
  3963. MLXSW_ITEM32_LP(reg, ptys, 0x00, 16, 0x00, 12);
  3964. #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
  3965. #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
  3966. /* reg_ptys_proto_mask
  3967. * Protocol mask. Indicates which protocol is used.
  3968. * 0 - Infiniband.
  3969. * 1 - Fibre Channel.
  3970. * 2 - Ethernet.
  3971. * Access: Index
  3972. */
  3973. MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
  3974. enum {
  3975. MLXSW_REG_PTYS_AN_STATUS_NA,
  3976. MLXSW_REG_PTYS_AN_STATUS_OK,
  3977. MLXSW_REG_PTYS_AN_STATUS_FAIL,
  3978. };
  3979. /* reg_ptys_an_status
  3980. * Autonegotiation status.
  3981. * Access: RO
  3982. */
  3983. MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
  3984. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_SGMII_100M BIT(0)
  3985. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_1000BASE_X_SGMII BIT(1)
  3986. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_5GBASE_R BIT(3)
  3987. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XFI_XAUI_1_10G BIT(4)
  3988. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_XLAUI_4_XLPPI_4_40G BIT(5)
  3989. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_25GAUI_1_25GBASE_CR_KR BIT(6)
  3990. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_2_LAUI_2_50GBASE_CR2_KR2 BIT(7)
  3991. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_50GAUI_1_LAUI_1_50GBASE_CR_KR BIT(8)
  3992. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_CAUI_4_100GBASE_CR4_KR4 BIT(9)
  3993. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_100GAUI_2_100GBASE_CR2_KR2 BIT(10)
  3994. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_200GAUI_4_200GBASE_CR4_KR4 BIT(12)
  3995. #define MLXSW_REG_PTYS_EXT_ETH_SPEED_400GAUI_8 BIT(15)
  3996. /* reg_ptys_ext_eth_proto_cap
  3997. * Extended Ethernet port supported speeds and protocols.
  3998. * Access: RO
  3999. */
  4000. MLXSW_ITEM32(reg, ptys, ext_eth_proto_cap, 0x08, 0, 32);
  4001. #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
  4002. #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
  4003. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
  4004. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
  4005. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
  4006. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
  4007. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
  4008. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
  4009. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
  4010. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
  4011. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
  4012. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
  4013. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
  4014. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
  4015. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
  4016. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
  4017. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
  4018. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
  4019. #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(24)
  4020. #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_T BIT(25)
  4021. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
  4022. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
  4023. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
  4024. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
  4025. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
  4026. /* reg_ptys_eth_proto_cap
  4027. * Ethernet port supported speeds and protocols.
  4028. * Access: RO
  4029. */
  4030. MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
  4031. /* reg_ptys_ext_eth_proto_admin
  4032. * Extended speed and protocol to set port to.
  4033. * Access: RW
  4034. */
  4035. MLXSW_ITEM32(reg, ptys, ext_eth_proto_admin, 0x14, 0, 32);
  4036. /* reg_ptys_eth_proto_admin
  4037. * Speed and protocol to set port to.
  4038. * Access: RW
  4039. */
  4040. MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
  4041. /* reg_ptys_ext_eth_proto_oper
  4042. * The extended current speed and protocol configured for the port.
  4043. * Access: RO
  4044. */
  4045. MLXSW_ITEM32(reg, ptys, ext_eth_proto_oper, 0x20, 0, 32);
  4046. /* reg_ptys_eth_proto_oper
  4047. * The current speed and protocol configured for the port.
  4048. * Access: RO
  4049. */
  4050. MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
  4051. enum mlxsw_reg_ptys_connector_type {
  4052. MLXSW_REG_PTYS_CONNECTOR_TYPE_UNKNOWN_OR_NO_CONNECTOR,
  4053. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_NONE,
  4054. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_TP,
  4055. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_AUI,
  4056. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_BNC,
  4057. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_MII,
  4058. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_FIBRE,
  4059. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_DA,
  4060. MLXSW_REG_PTYS_CONNECTOR_TYPE_PORT_OTHER,
  4061. };
  4062. /* reg_ptys_connector_type
  4063. * Connector type indication.
  4064. * Access: RO
  4065. */
  4066. MLXSW_ITEM32(reg, ptys, connector_type, 0x2C, 0, 4);
  4067. static inline void mlxsw_reg_ptys_eth_pack(char *payload, u16 local_port,
  4068. u32 proto_admin, bool autoneg)
  4069. {
  4070. MLXSW_REG_ZERO(ptys, payload);
  4071. mlxsw_reg_ptys_local_port_set(payload, local_port);
  4072. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
  4073. mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
  4074. mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
  4075. }
  4076. static inline void mlxsw_reg_ptys_ext_eth_pack(char *payload, u16 local_port,
  4077. u32 proto_admin, bool autoneg)
  4078. {
  4079. MLXSW_REG_ZERO(ptys, payload);
  4080. mlxsw_reg_ptys_local_port_set(payload, local_port);
  4081. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
  4082. mlxsw_reg_ptys_ext_eth_proto_admin_set(payload, proto_admin);
  4083. mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
  4084. }
  4085. static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
  4086. u32 *p_eth_proto_cap,
  4087. u32 *p_eth_proto_admin,
  4088. u32 *p_eth_proto_oper)
  4089. {
  4090. if (p_eth_proto_cap)
  4091. *p_eth_proto_cap =
  4092. mlxsw_reg_ptys_eth_proto_cap_get(payload);
  4093. if (p_eth_proto_admin)
  4094. *p_eth_proto_admin =
  4095. mlxsw_reg_ptys_eth_proto_admin_get(payload);
  4096. if (p_eth_proto_oper)
  4097. *p_eth_proto_oper =
  4098. mlxsw_reg_ptys_eth_proto_oper_get(payload);
  4099. }
  4100. static inline void mlxsw_reg_ptys_ext_eth_unpack(char *payload,
  4101. u32 *p_eth_proto_cap,
  4102. u32 *p_eth_proto_admin,
  4103. u32 *p_eth_proto_oper)
  4104. {
  4105. if (p_eth_proto_cap)
  4106. *p_eth_proto_cap =
  4107. mlxsw_reg_ptys_ext_eth_proto_cap_get(payload);
  4108. if (p_eth_proto_admin)
  4109. *p_eth_proto_admin =
  4110. mlxsw_reg_ptys_ext_eth_proto_admin_get(payload);
  4111. if (p_eth_proto_oper)
  4112. *p_eth_proto_oper =
  4113. mlxsw_reg_ptys_ext_eth_proto_oper_get(payload);
  4114. }
  4115. /* PPAD - Port Physical Address Register
  4116. * -------------------------------------
  4117. * The PPAD register configures the per port physical MAC address.
  4118. */
  4119. #define MLXSW_REG_PPAD_ID 0x5005
  4120. #define MLXSW_REG_PPAD_LEN 0x10
  4121. MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
  4122. /* reg_ppad_single_base_mac
  4123. * 0: base_mac, local port should be 0 and mac[7:0] is
  4124. * reserved. HW will set incremental
  4125. * 1: single_mac - mac of the local_port
  4126. * Access: RW
  4127. */
  4128. MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
  4129. /* reg_ppad_local_port
  4130. * port number, if single_base_mac = 0 then local_port is reserved
  4131. * Access: RW
  4132. */
  4133. MLXSW_ITEM32_LP(reg, ppad, 0x00, 16, 0x00, 24);
  4134. /* reg_ppad_mac
  4135. * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
  4136. * If single_base_mac = 1 - the per port MAC address
  4137. * Access: RW
  4138. */
  4139. MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
  4140. static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
  4141. u16 local_port)
  4142. {
  4143. MLXSW_REG_ZERO(ppad, payload);
  4144. mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
  4145. mlxsw_reg_ppad_local_port_set(payload, local_port);
  4146. }
  4147. /* PAOS - Ports Administrative and Operational Status Register
  4148. * -----------------------------------------------------------
  4149. * Configures and retrieves per port administrative and operational status.
  4150. */
  4151. #define MLXSW_REG_PAOS_ID 0x5006
  4152. #define MLXSW_REG_PAOS_LEN 0x10
  4153. MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
  4154. /* reg_paos_swid
  4155. * Switch partition ID with which to associate the port.
  4156. * Note: while external ports uses unique local port numbers (and thus swid is
  4157. * redundant), router ports use the same local port number where swid is the
  4158. * only indication for the relevant port.
  4159. * Access: Index
  4160. */
  4161. MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
  4162. /* reg_paos_local_port
  4163. * Local port number.
  4164. * Access: Index
  4165. */
  4166. MLXSW_ITEM32_LP(reg, paos, 0x00, 16, 0x00, 12);
  4167. /* reg_paos_admin_status
  4168. * Port administrative state (the desired state of the port):
  4169. * 1 - Up.
  4170. * 2 - Down.
  4171. * 3 - Up once. This means that in case of link failure, the port won't go
  4172. * into polling mode, but will wait to be re-enabled by software.
  4173. * 4 - Disabled by system. Can only be set by hardware.
  4174. * Access: RW
  4175. */
  4176. MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
  4177. /* reg_paos_oper_status
  4178. * Port operational state (the current state):
  4179. * 1 - Up.
  4180. * 2 - Down.
  4181. * 3 - Down by port failure. This means that the device will not let the
  4182. * port up again until explicitly specified by software.
  4183. * Access: RO
  4184. */
  4185. MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
  4186. /* reg_paos_ase
  4187. * Admin state update enabled.
  4188. * Access: WO
  4189. */
  4190. MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
  4191. /* reg_paos_ee
  4192. * Event update enable. If this bit is set, event generation will be
  4193. * updated based on the e field.
  4194. * Access: WO
  4195. */
  4196. MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
  4197. /* reg_paos_e
  4198. * Event generation on operational state change:
  4199. * 0 - Do not generate event.
  4200. * 1 - Generate Event.
  4201. * 2 - Generate Single Event.
  4202. * Access: RW
  4203. */
  4204. MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
  4205. static inline void mlxsw_reg_paos_pack(char *payload, u16 local_port,
  4206. enum mlxsw_port_admin_status status)
  4207. {
  4208. MLXSW_REG_ZERO(paos, payload);
  4209. mlxsw_reg_paos_swid_set(payload, 0);
  4210. mlxsw_reg_paos_local_port_set(payload, local_port);
  4211. mlxsw_reg_paos_admin_status_set(payload, status);
  4212. mlxsw_reg_paos_oper_status_set(payload, 0);
  4213. mlxsw_reg_paos_ase_set(payload, 1);
  4214. mlxsw_reg_paos_ee_set(payload, 1);
  4215. mlxsw_reg_paos_e_set(payload, 1);
  4216. }
  4217. /* PFCC - Ports Flow Control Configuration Register
  4218. * ------------------------------------------------
  4219. * Configures and retrieves the per port flow control configuration.
  4220. */
  4221. #define MLXSW_REG_PFCC_ID 0x5007
  4222. #define MLXSW_REG_PFCC_LEN 0x20
  4223. MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
  4224. /* reg_pfcc_local_port
  4225. * Local port number.
  4226. * Access: Index
  4227. */
  4228. MLXSW_ITEM32_LP(reg, pfcc, 0x00, 16, 0x00, 12);
  4229. /* reg_pfcc_pnat
  4230. * Port number access type. Determines the way local_port is interpreted:
  4231. * 0 - Local port number.
  4232. * 1 - IB / label port number.
  4233. * Access: Index
  4234. */
  4235. MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
  4236. /* reg_pfcc_shl_cap
  4237. * Send to higher layers capabilities:
  4238. * 0 - No capability of sending Pause and PFC frames to higher layers.
  4239. * 1 - Device has capability of sending Pause and PFC frames to higher
  4240. * layers.
  4241. * Access: RO
  4242. */
  4243. MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
  4244. /* reg_pfcc_shl_opr
  4245. * Send to higher layers operation:
  4246. * 0 - Pause and PFC frames are handled by the port (default).
  4247. * 1 - Pause and PFC frames are handled by the port and also sent to
  4248. * higher layers. Only valid if shl_cap = 1.
  4249. * Access: RW
  4250. */
  4251. MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
  4252. /* reg_pfcc_ppan
  4253. * Pause policy auto negotiation.
  4254. * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
  4255. * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
  4256. * based on the auto-negotiation resolution.
  4257. * Access: RW
  4258. *
  4259. * Note: The auto-negotiation advertisement is set according to pptx and
  4260. * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
  4261. */
  4262. MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
  4263. /* reg_pfcc_prio_mask_tx
  4264. * Bit per priority indicating if Tx flow control policy should be
  4265. * updated based on bit pfctx.
  4266. * Access: WO
  4267. */
  4268. MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
  4269. /* reg_pfcc_prio_mask_rx
  4270. * Bit per priority indicating if Rx flow control policy should be
  4271. * updated based on bit pfcrx.
  4272. * Access: WO
  4273. */
  4274. MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
  4275. /* reg_pfcc_pptx
  4276. * Admin Pause policy on Tx.
  4277. * 0 - Never generate Pause frames (default).
  4278. * 1 - Generate Pause frames according to Rx buffer threshold.
  4279. * Access: RW
  4280. */
  4281. MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
  4282. /* reg_pfcc_aptx
  4283. * Active (operational) Pause policy on Tx.
  4284. * 0 - Never generate Pause frames.
  4285. * 1 - Generate Pause frames according to Rx buffer threshold.
  4286. * Access: RO
  4287. */
  4288. MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
  4289. /* reg_pfcc_pfctx
  4290. * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
  4291. * 0 - Never generate priority Pause frames on the specified priority
  4292. * (default).
  4293. * 1 - Generate priority Pause frames according to Rx buffer threshold on
  4294. * the specified priority.
  4295. * Access: RW
  4296. *
  4297. * Note: pfctx and pptx must be mutually exclusive.
  4298. */
  4299. MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
  4300. /* reg_pfcc_pprx
  4301. * Admin Pause policy on Rx.
  4302. * 0 - Ignore received Pause frames (default).
  4303. * 1 - Respect received Pause frames.
  4304. * Access: RW
  4305. */
  4306. MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
  4307. /* reg_pfcc_aprx
  4308. * Active (operational) Pause policy on Rx.
  4309. * 0 - Ignore received Pause frames.
  4310. * 1 - Respect received Pause frames.
  4311. * Access: RO
  4312. */
  4313. MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
  4314. /* reg_pfcc_pfcrx
  4315. * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
  4316. * 0 - Ignore incoming priority Pause frames on the specified priority
  4317. * (default).
  4318. * 1 - Respect incoming priority Pause frames on the specified priority.
  4319. * Access: RW
  4320. */
  4321. MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
  4322. #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
  4323. static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
  4324. {
  4325. mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  4326. mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  4327. mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
  4328. mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
  4329. }
  4330. static inline void mlxsw_reg_pfcc_pack(char *payload, u16 local_port)
  4331. {
  4332. MLXSW_REG_ZERO(pfcc, payload);
  4333. mlxsw_reg_pfcc_local_port_set(payload, local_port);
  4334. }
  4335. /* PPCNT - Ports Performance Counters Register
  4336. * -------------------------------------------
  4337. * The PPCNT register retrieves per port performance counters.
  4338. */
  4339. #define MLXSW_REG_PPCNT_ID 0x5008
  4340. #define MLXSW_REG_PPCNT_LEN 0x100
  4341. #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
  4342. MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
  4343. /* reg_ppcnt_swid
  4344. * For HCA: must be always 0.
  4345. * Switch partition ID to associate port with.
  4346. * Switch partitions are numbered from 0 to 7 inclusively.
  4347. * Switch partition 254 indicates stacking ports.
  4348. * Switch partition 255 indicates all switch partitions.
  4349. * Only valid on Set() operation with local_port=255.
  4350. * Access: Index
  4351. */
  4352. MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
  4353. /* reg_ppcnt_local_port
  4354. * Local port number.
  4355. * Access: Index
  4356. */
  4357. MLXSW_ITEM32_LP(reg, ppcnt, 0x00, 16, 0x00, 12);
  4358. /* reg_ppcnt_pnat
  4359. * Port number access type:
  4360. * 0 - Local port number
  4361. * 1 - IB port number
  4362. * Access: Index
  4363. */
  4364. MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
  4365. enum mlxsw_reg_ppcnt_grp {
  4366. MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
  4367. MLXSW_REG_PPCNT_RFC_2863_CNT = 0x1,
  4368. MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
  4369. MLXSW_REG_PPCNT_RFC_3635_CNT = 0x3,
  4370. MLXSW_REG_PPCNT_EXT_CNT = 0x5,
  4371. MLXSW_REG_PPCNT_DISCARD_CNT = 0x6,
  4372. MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
  4373. MLXSW_REG_PPCNT_TC_CNT = 0x11,
  4374. MLXSW_REG_PPCNT_TC_CONG_CNT = 0x13,
  4375. };
  4376. /* reg_ppcnt_grp
  4377. * Performance counter group.
  4378. * Group 63 indicates all groups. Only valid on Set() operation with
  4379. * clr bit set.
  4380. * 0x0: IEEE 802.3 Counters
  4381. * 0x1: RFC 2863 Counters
  4382. * 0x2: RFC 2819 Counters
  4383. * 0x3: RFC 3635 Counters
  4384. * 0x5: Ethernet Extended Counters
  4385. * 0x6: Ethernet Discard Counters
  4386. * 0x8: Link Level Retransmission Counters
  4387. * 0x10: Per Priority Counters
  4388. * 0x11: Per Traffic Class Counters
  4389. * 0x12: Physical Layer Counters
  4390. * 0x13: Per Traffic Class Congestion Counters
  4391. * Access: Index
  4392. */
  4393. MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
  4394. /* reg_ppcnt_clr
  4395. * Clear counters. Setting the clr bit will reset the counter value
  4396. * for all counters in the counter group. This bit can be set
  4397. * for both Set() and Get() operation.
  4398. * Access: OP
  4399. */
  4400. MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
  4401. /* reg_ppcnt_lp_gl
  4402. * Local port global variable.
  4403. * 0: local_port 255 = all ports of the device.
  4404. * 1: local_port indicates local port number for all ports.
  4405. * Access: OP
  4406. */
  4407. MLXSW_ITEM32(reg, ppcnt, lp_gl, 0x04, 30, 1);
  4408. /* reg_ppcnt_prio_tc
  4409. * Priority for counter set that support per priority, valid values: 0-7.
  4410. * Traffic class for counter set that support per traffic class,
  4411. * valid values: 0- cap_max_tclass-1 .
  4412. * For HCA: cap_max_tclass is always 8.
  4413. * Otherwise must be 0.
  4414. * Access: Index
  4415. */
  4416. MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
  4417. /* Ethernet IEEE 802.3 Counter Group */
  4418. /* reg_ppcnt_a_frames_transmitted_ok
  4419. * Access: RO
  4420. */
  4421. MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
  4422. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  4423. /* reg_ppcnt_a_frames_received_ok
  4424. * Access: RO
  4425. */
  4426. MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
  4427. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4428. /* reg_ppcnt_a_frame_check_sequence_errors
  4429. * Access: RO
  4430. */
  4431. MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
  4432. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
  4433. /* reg_ppcnt_a_alignment_errors
  4434. * Access: RO
  4435. */
  4436. MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
  4437. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
  4438. /* reg_ppcnt_a_octets_transmitted_ok
  4439. * Access: RO
  4440. */
  4441. MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
  4442. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
  4443. /* reg_ppcnt_a_octets_received_ok
  4444. * Access: RO
  4445. */
  4446. MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
  4447. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
  4448. /* reg_ppcnt_a_multicast_frames_xmitted_ok
  4449. * Access: RO
  4450. */
  4451. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
  4452. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
  4453. /* reg_ppcnt_a_broadcast_frames_xmitted_ok
  4454. * Access: RO
  4455. */
  4456. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
  4457. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
  4458. /* reg_ppcnt_a_multicast_frames_received_ok
  4459. * Access: RO
  4460. */
  4461. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
  4462. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
  4463. /* reg_ppcnt_a_broadcast_frames_received_ok
  4464. * Access: RO
  4465. */
  4466. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
  4467. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
  4468. /* reg_ppcnt_a_in_range_length_errors
  4469. * Access: RO
  4470. */
  4471. MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
  4472. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
  4473. /* reg_ppcnt_a_out_of_range_length_field
  4474. * Access: RO
  4475. */
  4476. MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
  4477. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  4478. /* reg_ppcnt_a_frame_too_long_errors
  4479. * Access: RO
  4480. */
  4481. MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
  4482. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  4483. /* reg_ppcnt_a_symbol_error_during_carrier
  4484. * Access: RO
  4485. */
  4486. MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
  4487. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  4488. /* reg_ppcnt_a_mac_control_frames_transmitted
  4489. * Access: RO
  4490. */
  4491. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
  4492. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  4493. /* reg_ppcnt_a_mac_control_frames_received
  4494. * Access: RO
  4495. */
  4496. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
  4497. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
  4498. /* reg_ppcnt_a_unsupported_opcodes_received
  4499. * Access: RO
  4500. */
  4501. MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
  4502. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
  4503. /* reg_ppcnt_a_pause_mac_ctrl_frames_received
  4504. * Access: RO
  4505. */
  4506. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
  4507. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
  4508. /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
  4509. * Access: RO
  4510. */
  4511. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
  4512. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
  4513. /* Ethernet RFC 2863 Counter Group */
  4514. /* reg_ppcnt_if_in_discards
  4515. * Access: RO
  4516. */
  4517. MLXSW_ITEM64(reg, ppcnt, if_in_discards,
  4518. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
  4519. /* reg_ppcnt_if_out_discards
  4520. * Access: RO
  4521. */
  4522. MLXSW_ITEM64(reg, ppcnt, if_out_discards,
  4523. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
  4524. /* reg_ppcnt_if_out_errors
  4525. * Access: RO
  4526. */
  4527. MLXSW_ITEM64(reg, ppcnt, if_out_errors,
  4528. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
  4529. /* Ethernet RFC 2819 Counter Group */
  4530. /* reg_ppcnt_ether_stats_undersize_pkts
  4531. * Access: RO
  4532. */
  4533. MLXSW_ITEM64(reg, ppcnt, ether_stats_undersize_pkts,
  4534. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
  4535. /* reg_ppcnt_ether_stats_oversize_pkts
  4536. * Access: RO
  4537. */
  4538. MLXSW_ITEM64(reg, ppcnt, ether_stats_oversize_pkts,
  4539. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
  4540. /* reg_ppcnt_ether_stats_fragments
  4541. * Access: RO
  4542. */
  4543. MLXSW_ITEM64(reg, ppcnt, ether_stats_fragments,
  4544. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
  4545. /* reg_ppcnt_ether_stats_pkts64octets
  4546. * Access: RO
  4547. */
  4548. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
  4549. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  4550. /* reg_ppcnt_ether_stats_pkts65to127octets
  4551. * Access: RO
  4552. */
  4553. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
  4554. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  4555. /* reg_ppcnt_ether_stats_pkts128to255octets
  4556. * Access: RO
  4557. */
  4558. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
  4559. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  4560. /* reg_ppcnt_ether_stats_pkts256to511octets
  4561. * Access: RO
  4562. */
  4563. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
  4564. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  4565. /* reg_ppcnt_ether_stats_pkts512to1023octets
  4566. * Access: RO
  4567. */
  4568. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
  4569. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
  4570. /* reg_ppcnt_ether_stats_pkts1024to1518octets
  4571. * Access: RO
  4572. */
  4573. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
  4574. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
  4575. /* reg_ppcnt_ether_stats_pkts1519to2047octets
  4576. * Access: RO
  4577. */
  4578. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
  4579. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
  4580. /* reg_ppcnt_ether_stats_pkts2048to4095octets
  4581. * Access: RO
  4582. */
  4583. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
  4584. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
  4585. /* reg_ppcnt_ether_stats_pkts4096to8191octets
  4586. * Access: RO
  4587. */
  4588. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
  4589. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
  4590. /* reg_ppcnt_ether_stats_pkts8192to10239octets
  4591. * Access: RO
  4592. */
  4593. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
  4594. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
  4595. /* Ethernet RFC 3635 Counter Group */
  4596. /* reg_ppcnt_dot3stats_fcs_errors
  4597. * Access: RO
  4598. */
  4599. MLXSW_ITEM64(reg, ppcnt, dot3stats_fcs_errors,
  4600. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4601. /* reg_ppcnt_dot3stats_symbol_errors
  4602. * Access: RO
  4603. */
  4604. MLXSW_ITEM64(reg, ppcnt, dot3stats_symbol_errors,
  4605. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  4606. /* reg_ppcnt_dot3control_in_unknown_opcodes
  4607. * Access: RO
  4608. */
  4609. MLXSW_ITEM64(reg, ppcnt, dot3control_in_unknown_opcodes,
  4610. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  4611. /* reg_ppcnt_dot3in_pause_frames
  4612. * Access: RO
  4613. */
  4614. MLXSW_ITEM64(reg, ppcnt, dot3in_pause_frames,
  4615. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  4616. /* Ethernet Extended Counter Group Counters */
  4617. /* reg_ppcnt_ecn_marked
  4618. * Access: RO
  4619. */
  4620. MLXSW_ITEM64(reg, ppcnt, ecn_marked,
  4621. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4622. /* Ethernet Discard Counter Group Counters */
  4623. /* reg_ppcnt_ingress_general
  4624. * Access: RO
  4625. */
  4626. MLXSW_ITEM64(reg, ppcnt, ingress_general,
  4627. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  4628. /* reg_ppcnt_ingress_policy_engine
  4629. * Access: RO
  4630. */
  4631. MLXSW_ITEM64(reg, ppcnt, ingress_policy_engine,
  4632. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4633. /* reg_ppcnt_ingress_vlan_membership
  4634. * Access: RO
  4635. */
  4636. MLXSW_ITEM64(reg, ppcnt, ingress_vlan_membership,
  4637. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
  4638. /* reg_ppcnt_ingress_tag_frame_type
  4639. * Access: RO
  4640. */
  4641. MLXSW_ITEM64(reg, ppcnt, ingress_tag_frame_type,
  4642. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
  4643. /* reg_ppcnt_egress_vlan_membership
  4644. * Access: RO
  4645. */
  4646. MLXSW_ITEM64(reg, ppcnt, egress_vlan_membership,
  4647. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
  4648. /* reg_ppcnt_loopback_filter
  4649. * Access: RO
  4650. */
  4651. MLXSW_ITEM64(reg, ppcnt, loopback_filter,
  4652. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
  4653. /* reg_ppcnt_egress_general
  4654. * Access: RO
  4655. */
  4656. MLXSW_ITEM64(reg, ppcnt, egress_general,
  4657. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
  4658. /* reg_ppcnt_egress_hoq
  4659. * Access: RO
  4660. */
  4661. MLXSW_ITEM64(reg, ppcnt, egress_hoq,
  4662. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
  4663. /* reg_ppcnt_egress_policy_engine
  4664. * Access: RO
  4665. */
  4666. MLXSW_ITEM64(reg, ppcnt, egress_policy_engine,
  4667. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
  4668. /* reg_ppcnt_ingress_tx_link_down
  4669. * Access: RO
  4670. */
  4671. MLXSW_ITEM64(reg, ppcnt, ingress_tx_link_down,
  4672. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  4673. /* reg_ppcnt_egress_stp_filter
  4674. * Access: RO
  4675. */
  4676. MLXSW_ITEM64(reg, ppcnt, egress_stp_filter,
  4677. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  4678. /* reg_ppcnt_egress_sll
  4679. * Access: RO
  4680. */
  4681. MLXSW_ITEM64(reg, ppcnt, egress_sll,
  4682. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  4683. /* Ethernet Per Priority Group Counters */
  4684. /* reg_ppcnt_rx_octets
  4685. * Access: RO
  4686. */
  4687. MLXSW_ITEM64(reg, ppcnt, rx_octets,
  4688. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  4689. /* reg_ppcnt_rx_frames
  4690. * Access: RO
  4691. */
  4692. MLXSW_ITEM64(reg, ppcnt, rx_frames,
  4693. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
  4694. /* reg_ppcnt_tx_octets
  4695. * Access: RO
  4696. */
  4697. MLXSW_ITEM64(reg, ppcnt, tx_octets,
  4698. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
  4699. /* reg_ppcnt_tx_frames
  4700. * Access: RO
  4701. */
  4702. MLXSW_ITEM64(reg, ppcnt, tx_frames,
  4703. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
  4704. /* reg_ppcnt_rx_pause
  4705. * Access: RO
  4706. */
  4707. MLXSW_ITEM64(reg, ppcnt, rx_pause,
  4708. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
  4709. /* reg_ppcnt_rx_pause_duration
  4710. * Access: RO
  4711. */
  4712. MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
  4713. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  4714. /* reg_ppcnt_tx_pause
  4715. * Access: RO
  4716. */
  4717. MLXSW_ITEM64(reg, ppcnt, tx_pause,
  4718. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  4719. /* reg_ppcnt_tx_pause_duration
  4720. * Access: RO
  4721. */
  4722. MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
  4723. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  4724. /* reg_ppcnt_rx_pause_transition
  4725. * Access: RO
  4726. */
  4727. MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
  4728. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  4729. /* Ethernet Per Traffic Class Counters */
  4730. /* reg_ppcnt_tc_transmit_queue
  4731. * Contains the transmit queue depth in cells of traffic class
  4732. * selected by prio_tc and the port selected by local_port.
  4733. * The field cannot be cleared.
  4734. * Access: RO
  4735. */
  4736. MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
  4737. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  4738. /* reg_ppcnt_tc_no_buffer_discard_uc
  4739. * The number of unicast packets dropped due to lack of shared
  4740. * buffer resources.
  4741. * Access: RO
  4742. */
  4743. MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
  4744. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4745. /* Ethernet Per Traffic Class Congestion Group Counters */
  4746. /* reg_ppcnt_wred_discard
  4747. * Access: RO
  4748. */
  4749. MLXSW_ITEM64(reg, ppcnt, wred_discard,
  4750. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  4751. /* reg_ppcnt_ecn_marked_tc
  4752. * Access: RO
  4753. */
  4754. MLXSW_ITEM64(reg, ppcnt, ecn_marked_tc,
  4755. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  4756. static inline void mlxsw_reg_ppcnt_pack(char *payload, u16 local_port,
  4757. enum mlxsw_reg_ppcnt_grp grp,
  4758. u8 prio_tc)
  4759. {
  4760. MLXSW_REG_ZERO(ppcnt, payload);
  4761. mlxsw_reg_ppcnt_swid_set(payload, 0);
  4762. mlxsw_reg_ppcnt_local_port_set(payload, local_port);
  4763. mlxsw_reg_ppcnt_pnat_set(payload, 0);
  4764. mlxsw_reg_ppcnt_grp_set(payload, grp);
  4765. mlxsw_reg_ppcnt_clr_set(payload, 0);
  4766. mlxsw_reg_ppcnt_lp_gl_set(payload, 1);
  4767. mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
  4768. }
  4769. /* PPTB - Port Prio To Buffer Register
  4770. * -----------------------------------
  4771. * Configures the switch priority to buffer table.
  4772. */
  4773. #define MLXSW_REG_PPTB_ID 0x500B
  4774. #define MLXSW_REG_PPTB_LEN 0x10
  4775. MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
  4776. enum {
  4777. MLXSW_REG_PPTB_MM_UM,
  4778. MLXSW_REG_PPTB_MM_UNICAST,
  4779. MLXSW_REG_PPTB_MM_MULTICAST,
  4780. };
  4781. /* reg_pptb_mm
  4782. * Mapping mode.
  4783. * 0 - Map both unicast and multicast packets to the same buffer.
  4784. * 1 - Map only unicast packets.
  4785. * 2 - Map only multicast packets.
  4786. * Access: Index
  4787. *
  4788. * Note: SwitchX-2 only supports the first option.
  4789. */
  4790. MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
  4791. /* reg_pptb_local_port
  4792. * Local port number.
  4793. * Access: Index
  4794. */
  4795. MLXSW_ITEM32_LP(reg, pptb, 0x00, 16, 0x00, 12);
  4796. /* reg_pptb_um
  4797. * Enables the update of the untagged_buf field.
  4798. * Access: RW
  4799. */
  4800. MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
  4801. /* reg_pptb_pm
  4802. * Enables the update of the prio_to_buff field.
  4803. * Bit <i> is a flag for updating the mapping for switch priority <i>.
  4804. * Access: RW
  4805. */
  4806. MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
  4807. /* reg_pptb_prio_to_buff
  4808. * Mapping of switch priority <i> to one of the allocated receive port
  4809. * buffers.
  4810. * Access: RW
  4811. */
  4812. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
  4813. /* reg_pptb_pm_msb
  4814. * Enables the update of the prio_to_buff field.
  4815. * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
  4816. * Access: RW
  4817. */
  4818. MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
  4819. /* reg_pptb_untagged_buff
  4820. * Mapping of untagged frames to one of the allocated receive port buffers.
  4821. * Access: RW
  4822. *
  4823. * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
  4824. * Spectrum, as it maps untagged packets based on the default switch priority.
  4825. */
  4826. MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
  4827. /* reg_pptb_prio_to_buff_msb
  4828. * Mapping of switch priority <i+8> to one of the allocated receive port
  4829. * buffers.
  4830. * Access: RW
  4831. */
  4832. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
  4833. #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
  4834. static inline void mlxsw_reg_pptb_pack(char *payload, u16 local_port)
  4835. {
  4836. MLXSW_REG_ZERO(pptb, payload);
  4837. mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
  4838. mlxsw_reg_pptb_local_port_set(payload, local_port);
  4839. mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  4840. mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  4841. }
  4842. static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
  4843. u8 buff)
  4844. {
  4845. mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
  4846. mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
  4847. }
  4848. /* PBMC - Port Buffer Management Control Register
  4849. * ----------------------------------------------
  4850. * The PBMC register configures and retrieves the port packet buffer
  4851. * allocation for different Prios, and the Pause threshold management.
  4852. */
  4853. #define MLXSW_REG_PBMC_ID 0x500C
  4854. #define MLXSW_REG_PBMC_LEN 0x6C
  4855. MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
  4856. /* reg_pbmc_local_port
  4857. * Local port number.
  4858. * Access: Index
  4859. */
  4860. MLXSW_ITEM32_LP(reg, pbmc, 0x00, 16, 0x00, 12);
  4861. /* reg_pbmc_xoff_timer_value
  4862. * When device generates a pause frame, it uses this value as the pause
  4863. * timer (time for the peer port to pause in quota-512 bit time).
  4864. * Access: RW
  4865. */
  4866. MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
  4867. /* reg_pbmc_xoff_refresh
  4868. * The time before a new pause frame should be sent to refresh the pause RW
  4869. * state. Using the same units as xoff_timer_value above (in quota-512 bit
  4870. * time).
  4871. * Access: RW
  4872. */
  4873. MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
  4874. #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
  4875. /* reg_pbmc_buf_lossy
  4876. * The field indicates if the buffer is lossy.
  4877. * 0 - Lossless
  4878. * 1 - Lossy
  4879. * Access: RW
  4880. */
  4881. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
  4882. /* reg_pbmc_buf_epsb
  4883. * Eligible for Port Shared buffer.
  4884. * If epsb is set, packets assigned to buffer are allowed to insert the port
  4885. * shared buffer.
  4886. * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
  4887. * Access: RW
  4888. */
  4889. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
  4890. /* reg_pbmc_buf_size
  4891. * The part of the packet buffer array is allocated for the specific buffer.
  4892. * Units are represented in cells.
  4893. * Access: RW
  4894. */
  4895. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
  4896. /* reg_pbmc_buf_xoff_threshold
  4897. * Once the amount of data in the buffer goes above this value, device
  4898. * starts sending PFC frames for all priorities associated with the
  4899. * buffer. Units are represented in cells. Reserved in case of lossy
  4900. * buffer.
  4901. * Access: RW
  4902. *
  4903. * Note: In Spectrum, reserved for buffer[9].
  4904. */
  4905. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
  4906. 0x08, 0x04, false);
  4907. /* reg_pbmc_buf_xon_threshold
  4908. * When the amount of data in the buffer goes below this value, device
  4909. * stops sending PFC frames for the priorities associated with the
  4910. * buffer. Units are represented in cells. Reserved in case of lossy
  4911. * buffer.
  4912. * Access: RW
  4913. *
  4914. * Note: In Spectrum, reserved for buffer[9].
  4915. */
  4916. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
  4917. 0x08, 0x04, false);
  4918. static inline void mlxsw_reg_pbmc_pack(char *payload, u16 local_port,
  4919. u16 xoff_timer_value, u16 xoff_refresh)
  4920. {
  4921. MLXSW_REG_ZERO(pbmc, payload);
  4922. mlxsw_reg_pbmc_local_port_set(payload, local_port);
  4923. mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
  4924. mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
  4925. }
  4926. static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
  4927. int buf_index,
  4928. u16 size)
  4929. {
  4930. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
  4931. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  4932. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  4933. }
  4934. static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
  4935. int buf_index, u16 size,
  4936. u16 threshold)
  4937. {
  4938. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
  4939. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  4940. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  4941. mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
  4942. mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
  4943. }
  4944. /* PSPA - Port Switch Partition Allocation
  4945. * ---------------------------------------
  4946. * Controls the association of a port with a switch partition and enables
  4947. * configuring ports as stacking ports.
  4948. */
  4949. #define MLXSW_REG_PSPA_ID 0x500D
  4950. #define MLXSW_REG_PSPA_LEN 0x8
  4951. MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
  4952. /* reg_pspa_swid
  4953. * Switch partition ID.
  4954. * Access: RW
  4955. */
  4956. MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
  4957. /* reg_pspa_local_port
  4958. * Local port number.
  4959. * Access: Index
  4960. */
  4961. MLXSW_ITEM32_LP(reg, pspa, 0x00, 16, 0x00, 0);
  4962. /* reg_pspa_sub_port
  4963. * Virtual port within the local port. Set to 0 when virtual ports are
  4964. * disabled on the local port.
  4965. * Access: Index
  4966. */
  4967. MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
  4968. static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u16 local_port)
  4969. {
  4970. MLXSW_REG_ZERO(pspa, payload);
  4971. mlxsw_reg_pspa_swid_set(payload, swid);
  4972. mlxsw_reg_pspa_local_port_set(payload, local_port);
  4973. mlxsw_reg_pspa_sub_port_set(payload, 0);
  4974. }
  4975. /* PMAOS - Ports Module Administrative and Operational Status
  4976. * ----------------------------------------------------------
  4977. * This register configures and retrieves the per module status.
  4978. */
  4979. #define MLXSW_REG_PMAOS_ID 0x5012
  4980. #define MLXSW_REG_PMAOS_LEN 0x10
  4981. MLXSW_REG_DEFINE(pmaos, MLXSW_REG_PMAOS_ID, MLXSW_REG_PMAOS_LEN);
  4982. /* reg_pmaos_rst
  4983. * Module reset toggle.
  4984. * Note: Setting reset while module is plugged-in will result in transition to
  4985. * "initializing" operational state.
  4986. * Access: OP
  4987. */
  4988. MLXSW_ITEM32(reg, pmaos, rst, 0x00, 31, 1);
  4989. /* reg_pmaos_slot_index
  4990. * Slot index.
  4991. * Access: Index
  4992. */
  4993. MLXSW_ITEM32(reg, pmaos, slot_index, 0x00, 24, 4);
  4994. /* reg_pmaos_module
  4995. * Module number.
  4996. * Access: Index
  4997. */
  4998. MLXSW_ITEM32(reg, pmaos, module, 0x00, 16, 8);
  4999. enum mlxsw_reg_pmaos_admin_status {
  5000. MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED = 1,
  5001. MLXSW_REG_PMAOS_ADMIN_STATUS_DISABLED = 2,
  5002. /* If the module is active and then unplugged, or experienced an error
  5003. * event, the operational status should go to "disabled" and can only
  5004. * be enabled upon explicit enable command.
  5005. */
  5006. MLXSW_REG_PMAOS_ADMIN_STATUS_ENABLED_ONCE = 3,
  5007. };
  5008. /* reg_pmaos_admin_status
  5009. * Module administrative state (the desired state of the module).
  5010. * Note: To disable a module, all ports associated with the port must be
  5011. * administatively down first.
  5012. * Access: RW
  5013. */
  5014. MLXSW_ITEM32(reg, pmaos, admin_status, 0x00, 8, 4);
  5015. /* reg_pmaos_ase
  5016. * Admin state update enable.
  5017. * If this bit is set, admin state will be updated based on admin_state field.
  5018. * Only relevant on Set() operations.
  5019. * Access: WO
  5020. */
  5021. MLXSW_ITEM32(reg, pmaos, ase, 0x04, 31, 1);
  5022. /* reg_pmaos_ee
  5023. * Event update enable.
  5024. * If this bit is set, event generation will be updated based on the e field.
  5025. * Only relevant on Set operations.
  5026. * Access: WO
  5027. */
  5028. MLXSW_ITEM32(reg, pmaos, ee, 0x04, 30, 1);
  5029. enum mlxsw_reg_pmaos_e {
  5030. MLXSW_REG_PMAOS_E_DO_NOT_GENERATE_EVENT,
  5031. MLXSW_REG_PMAOS_E_GENERATE_EVENT,
  5032. MLXSW_REG_PMAOS_E_GENERATE_SINGLE_EVENT,
  5033. };
  5034. /* reg_pmaos_e
  5035. * Event Generation on operational state change.
  5036. * Access: RW
  5037. */
  5038. MLXSW_ITEM32(reg, pmaos, e, 0x04, 0, 2);
  5039. static inline void mlxsw_reg_pmaos_pack(char *payload, u8 slot_index, u8 module)
  5040. {
  5041. MLXSW_REG_ZERO(pmaos, payload);
  5042. mlxsw_reg_pmaos_slot_index_set(payload, slot_index);
  5043. mlxsw_reg_pmaos_module_set(payload, module);
  5044. }
  5045. /* PPLR - Port Physical Loopback Register
  5046. * --------------------------------------
  5047. * This register allows configuration of the port's loopback mode.
  5048. */
  5049. #define MLXSW_REG_PPLR_ID 0x5018
  5050. #define MLXSW_REG_PPLR_LEN 0x8
  5051. MLXSW_REG_DEFINE(pplr, MLXSW_REG_PPLR_ID, MLXSW_REG_PPLR_LEN);
  5052. /* reg_pplr_local_port
  5053. * Local port number.
  5054. * Access: Index
  5055. */
  5056. MLXSW_ITEM32_LP(reg, pplr, 0x00, 16, 0x00, 12);
  5057. /* Phy local loopback. When set the port's egress traffic is looped back
  5058. * to the receiver and the port transmitter is disabled.
  5059. */
  5060. #define MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL BIT(1)
  5061. /* reg_pplr_lb_en
  5062. * Loopback enable.
  5063. * Access: RW
  5064. */
  5065. MLXSW_ITEM32(reg, pplr, lb_en, 0x04, 0, 8);
  5066. static inline void mlxsw_reg_pplr_pack(char *payload, u16 local_port,
  5067. bool phy_local)
  5068. {
  5069. MLXSW_REG_ZERO(pplr, payload);
  5070. mlxsw_reg_pplr_local_port_set(payload, local_port);
  5071. mlxsw_reg_pplr_lb_en_set(payload,
  5072. phy_local ?
  5073. MLXSW_REG_PPLR_LB_TYPE_BIT_PHY_LOCAL : 0);
  5074. }
  5075. /* PMTDB - Port Module To local DataBase Register
  5076. * ----------------------------------------------
  5077. * The PMTDB register allows to query the possible module<->local port
  5078. * mapping than can be used in PMLP. It does not represent the actual/current
  5079. * mapping of the local to module. Actual mapping is only defined by PMLP.
  5080. */
  5081. #define MLXSW_REG_PMTDB_ID 0x501A
  5082. #define MLXSW_REG_PMTDB_LEN 0x40
  5083. MLXSW_REG_DEFINE(pmtdb, MLXSW_REG_PMTDB_ID, MLXSW_REG_PMTDB_LEN);
  5084. /* reg_pmtdb_slot_index
  5085. * Slot index (0: Main board).
  5086. * Access: Index
  5087. */
  5088. MLXSW_ITEM32(reg, pmtdb, slot_index, 0x00, 24, 4);
  5089. /* reg_pmtdb_module
  5090. * Module number.
  5091. * Access: Index
  5092. */
  5093. MLXSW_ITEM32(reg, pmtdb, module, 0x00, 16, 8);
  5094. /* reg_pmtdb_ports_width
  5095. * Port's width
  5096. * Access: Index
  5097. */
  5098. MLXSW_ITEM32(reg, pmtdb, ports_width, 0x00, 12, 4);
  5099. /* reg_pmtdb_num_ports
  5100. * Number of ports in a single module (split/breakout)
  5101. * Access: Index
  5102. */
  5103. MLXSW_ITEM32(reg, pmtdb, num_ports, 0x00, 8, 4);
  5104. enum mlxsw_reg_pmtdb_status {
  5105. MLXSW_REG_PMTDB_STATUS_SUCCESS,
  5106. };
  5107. /* reg_pmtdb_status
  5108. * Status
  5109. * Access: RO
  5110. */
  5111. MLXSW_ITEM32(reg, pmtdb, status, 0x00, 0, 4);
  5112. /* reg_pmtdb_port_num
  5113. * The local_port value which can be assigned to the module.
  5114. * In case of more than one port, port<x> represent the /<x> port of
  5115. * the module.
  5116. * Access: RO
  5117. */
  5118. MLXSW_ITEM16_INDEXED(reg, pmtdb, port_num, 0x04, 0, 10, 0x02, 0x00, false);
  5119. static inline void mlxsw_reg_pmtdb_pack(char *payload, u8 slot_index, u8 module,
  5120. u8 ports_width, u8 num_ports)
  5121. {
  5122. MLXSW_REG_ZERO(pmtdb, payload);
  5123. mlxsw_reg_pmtdb_slot_index_set(payload, slot_index);
  5124. mlxsw_reg_pmtdb_module_set(payload, module);
  5125. mlxsw_reg_pmtdb_ports_width_set(payload, ports_width);
  5126. mlxsw_reg_pmtdb_num_ports_set(payload, num_ports);
  5127. }
  5128. /* PMECR - Ports Mapping Event Configuration Register
  5129. * --------------------------------------------------
  5130. * The PMECR register is used to enable/disable event triggering
  5131. * in case of local port mapping change.
  5132. */
  5133. #define MLXSW_REG_PMECR_ID 0x501B
  5134. #define MLXSW_REG_PMECR_LEN 0x20
  5135. MLXSW_REG_DEFINE(pmecr, MLXSW_REG_PMECR_ID, MLXSW_REG_PMECR_LEN);
  5136. /* reg_pmecr_local_port
  5137. * Local port number.
  5138. * Access: Index
  5139. */
  5140. MLXSW_ITEM32_LP(reg, pmecr, 0x00, 16, 0x00, 12);
  5141. /* reg_pmecr_ee
  5142. * Event update enable. If this bit is set, event generation will be updated
  5143. * based on the e field. Only relevant on Set operations.
  5144. * Access: WO
  5145. */
  5146. MLXSW_ITEM32(reg, pmecr, ee, 0x04, 30, 1);
  5147. /* reg_pmecr_eswi
  5148. * Software ignore enable bit. If this bit is set, the value of swi is used.
  5149. * If this bit is clear, the value of swi is ignored.
  5150. * Only relevant on Set operations.
  5151. * Access: WO
  5152. */
  5153. MLXSW_ITEM32(reg, pmecr, eswi, 0x04, 24, 1);
  5154. /* reg_pmecr_swi
  5155. * Software ignore. If this bit is set, the device shouldn't generate events
  5156. * in case of PMLP SET operation but only upon self local port mapping change
  5157. * (if applicable according to e configuration). This is supplementary
  5158. * configuration on top of e value.
  5159. * Access: RW
  5160. */
  5161. MLXSW_ITEM32(reg, pmecr, swi, 0x04, 8, 1);
  5162. enum mlxsw_reg_pmecr_e {
  5163. MLXSW_REG_PMECR_E_DO_NOT_GENERATE_EVENT,
  5164. MLXSW_REG_PMECR_E_GENERATE_EVENT,
  5165. MLXSW_REG_PMECR_E_GENERATE_SINGLE_EVENT,
  5166. };
  5167. /* reg_pmecr_e
  5168. * Event generation on local port mapping change.
  5169. * Access: RW
  5170. */
  5171. MLXSW_ITEM32(reg, pmecr, e, 0x04, 0, 2);
  5172. static inline void mlxsw_reg_pmecr_pack(char *payload, u16 local_port,
  5173. enum mlxsw_reg_pmecr_e e)
  5174. {
  5175. MLXSW_REG_ZERO(pmecr, payload);
  5176. mlxsw_reg_pmecr_local_port_set(payload, local_port);
  5177. mlxsw_reg_pmecr_e_set(payload, e);
  5178. mlxsw_reg_pmecr_ee_set(payload, true);
  5179. mlxsw_reg_pmecr_swi_set(payload, true);
  5180. mlxsw_reg_pmecr_eswi_set(payload, true);
  5181. }
  5182. /* PMPE - Port Module Plug/Unplug Event Register
  5183. * ---------------------------------------------
  5184. * This register reports any operational status change of a module.
  5185. * A change in the module’s state will generate an event only if the change
  5186. * happens after arming the event mechanism. Any changes to the module state
  5187. * while the event mechanism is not armed will not be reported. Software can
  5188. * query the PMPE register for module status.
  5189. */
  5190. #define MLXSW_REG_PMPE_ID 0x5024
  5191. #define MLXSW_REG_PMPE_LEN 0x10
  5192. MLXSW_REG_DEFINE(pmpe, MLXSW_REG_PMPE_ID, MLXSW_REG_PMPE_LEN);
  5193. /* reg_pmpe_slot_index
  5194. * Slot index.
  5195. * Access: Index
  5196. */
  5197. MLXSW_ITEM32(reg, pmpe, slot_index, 0x00, 24, 4);
  5198. /* reg_pmpe_module
  5199. * Module number.
  5200. * Access: Index
  5201. */
  5202. MLXSW_ITEM32(reg, pmpe, module, 0x00, 16, 8);
  5203. enum mlxsw_reg_pmpe_module_status {
  5204. MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ENABLED = 1,
  5205. MLXSW_REG_PMPE_MODULE_STATUS_UNPLUGGED,
  5206. MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_ERROR,
  5207. MLXSW_REG_PMPE_MODULE_STATUS_PLUGGED_DISABLED,
  5208. };
  5209. /* reg_pmpe_module_status
  5210. * Module status.
  5211. * Access: RO
  5212. */
  5213. MLXSW_ITEM32(reg, pmpe, module_status, 0x00, 0, 4);
  5214. /* reg_pmpe_error_type
  5215. * Module error details.
  5216. * Access: RO
  5217. */
  5218. MLXSW_ITEM32(reg, pmpe, error_type, 0x04, 8, 4);
  5219. /* PDDR - Port Diagnostics Database Register
  5220. * -----------------------------------------
  5221. * The PDDR enables to read the Phy debug database
  5222. */
  5223. #define MLXSW_REG_PDDR_ID 0x5031
  5224. #define MLXSW_REG_PDDR_LEN 0x100
  5225. MLXSW_REG_DEFINE(pddr, MLXSW_REG_PDDR_ID, MLXSW_REG_PDDR_LEN);
  5226. /* reg_pddr_local_port
  5227. * Local port number.
  5228. * Access: Index
  5229. */
  5230. MLXSW_ITEM32_LP(reg, pddr, 0x00, 16, 0x00, 12);
  5231. enum mlxsw_reg_pddr_page_select {
  5232. MLXSW_REG_PDDR_PAGE_SELECT_TROUBLESHOOTING_INFO = 1,
  5233. };
  5234. /* reg_pddr_page_select
  5235. * Page select index.
  5236. * Access: Index
  5237. */
  5238. MLXSW_ITEM32(reg, pddr, page_select, 0x04, 0, 8);
  5239. enum mlxsw_reg_pddr_trblsh_group_opcode {
  5240. /* Monitor opcodes */
  5241. MLXSW_REG_PDDR_TRBLSH_GROUP_OPCODE_MONITOR,
  5242. };
  5243. /* reg_pddr_group_opcode
  5244. * Group selector.
  5245. * Access: Index
  5246. */
  5247. MLXSW_ITEM32(reg, pddr, trblsh_group_opcode, 0x08, 0, 16);
  5248. /* reg_pddr_status_opcode
  5249. * Group selector.
  5250. * Access: RO
  5251. */
  5252. MLXSW_ITEM32(reg, pddr, trblsh_status_opcode, 0x0C, 0, 16);
  5253. static inline void mlxsw_reg_pddr_pack(char *payload, u16 local_port,
  5254. u8 page_select)
  5255. {
  5256. MLXSW_REG_ZERO(pddr, payload);
  5257. mlxsw_reg_pddr_local_port_set(payload, local_port);
  5258. mlxsw_reg_pddr_page_select_set(payload, page_select);
  5259. }
  5260. /* PMMP - Port Module Memory Map Properties Register
  5261. * -------------------------------------------------
  5262. * The PMMP register allows to override the module memory map advertisement.
  5263. * The register can only be set when the module is disabled by PMAOS register.
  5264. */
  5265. #define MLXSW_REG_PMMP_ID 0x5044
  5266. #define MLXSW_REG_PMMP_LEN 0x2C
  5267. MLXSW_REG_DEFINE(pmmp, MLXSW_REG_PMMP_ID, MLXSW_REG_PMMP_LEN);
  5268. /* reg_pmmp_module
  5269. * Module number.
  5270. * Access: Index
  5271. */
  5272. MLXSW_ITEM32(reg, pmmp, module, 0x00, 16, 8);
  5273. /* reg_pmmp_slot_index
  5274. * Slot index.
  5275. * Access: Index
  5276. */
  5277. MLXSW_ITEM32(reg, pmmp, slot_index, 0x00, 24, 4);
  5278. /* reg_pmmp_sticky
  5279. * When set, will keep eeprom_override values after plug-out event.
  5280. * Access: OP
  5281. */
  5282. MLXSW_ITEM32(reg, pmmp, sticky, 0x00, 0, 1);
  5283. /* reg_pmmp_eeprom_override_mask
  5284. * Write mask bit (negative polarity).
  5285. * 0 - Allow write
  5286. * 1 - Ignore write
  5287. * On write, indicates which of the bits from eeprom_override field are
  5288. * updated.
  5289. * Access: WO
  5290. */
  5291. MLXSW_ITEM32(reg, pmmp, eeprom_override_mask, 0x04, 16, 16);
  5292. enum {
  5293. /* Set module to low power mode */
  5294. MLXSW_REG_PMMP_EEPROM_OVERRIDE_LOW_POWER_MASK = BIT(8),
  5295. };
  5296. /* reg_pmmp_eeprom_override
  5297. * Override / ignore EEPROM advertisement properties bitmask
  5298. * Access: RW
  5299. */
  5300. MLXSW_ITEM32(reg, pmmp, eeprom_override, 0x04, 0, 16);
  5301. static inline void mlxsw_reg_pmmp_pack(char *payload, u8 slot_index, u8 module)
  5302. {
  5303. MLXSW_REG_ZERO(pmmp, payload);
  5304. mlxsw_reg_pmmp_slot_index_set(payload, slot_index);
  5305. mlxsw_reg_pmmp_module_set(payload, module);
  5306. }
  5307. /* PLLP - Port Local port to Label Port mapping Register
  5308. * -----------------------------------------------------
  5309. * The PLLP register returns the mapping from Local Port into Label Port.
  5310. */
  5311. #define MLXSW_REG_PLLP_ID 0x504A
  5312. #define MLXSW_REG_PLLP_LEN 0x10
  5313. MLXSW_REG_DEFINE(pllp, MLXSW_REG_PLLP_ID, MLXSW_REG_PLLP_LEN);
  5314. /* reg_pllp_local_port
  5315. * Local port number.
  5316. * Access: Index
  5317. */
  5318. MLXSW_ITEM32_LP(reg, pllp, 0x00, 16, 0x00, 12);
  5319. /* reg_pllp_label_port
  5320. * Front panel label of the port.
  5321. * Access: RO
  5322. */
  5323. MLXSW_ITEM32(reg, pllp, label_port, 0x00, 0, 8);
  5324. /* reg_pllp_split_num
  5325. * Label split mapping for local_port.
  5326. * Access: RO
  5327. */
  5328. MLXSW_ITEM32(reg, pllp, split_num, 0x04, 0, 4);
  5329. /* reg_pllp_slot_index
  5330. * Slot index (0: Main board).
  5331. * Access: RO
  5332. */
  5333. MLXSW_ITEM32(reg, pllp, slot_index, 0x08, 0, 4);
  5334. static inline void mlxsw_reg_pllp_pack(char *payload, u16 local_port)
  5335. {
  5336. MLXSW_REG_ZERO(pllp, payload);
  5337. mlxsw_reg_pllp_local_port_set(payload, local_port);
  5338. }
  5339. static inline void mlxsw_reg_pllp_unpack(char *payload, u8 *label_port,
  5340. u8 *split_num, u8 *slot_index)
  5341. {
  5342. *label_port = mlxsw_reg_pllp_label_port_get(payload);
  5343. *split_num = mlxsw_reg_pllp_split_num_get(payload);
  5344. *slot_index = mlxsw_reg_pllp_slot_index_get(payload);
  5345. }
  5346. /* PMTM - Port Module Type Mapping Register
  5347. * ----------------------------------------
  5348. * The PMTM register allows query or configuration of module types.
  5349. * The register can only be set when the module is disabled by PMAOS register
  5350. */
  5351. #define MLXSW_REG_PMTM_ID 0x5067
  5352. #define MLXSW_REG_PMTM_LEN 0x10
  5353. MLXSW_REG_DEFINE(pmtm, MLXSW_REG_PMTM_ID, MLXSW_REG_PMTM_LEN);
  5354. /* reg_pmtm_slot_index
  5355. * Slot index.
  5356. * Access: Index
  5357. */
  5358. MLXSW_ITEM32(reg, pmtm, slot_index, 0x00, 24, 4);
  5359. /* reg_pmtm_module
  5360. * Module number.
  5361. * Access: Index
  5362. */
  5363. MLXSW_ITEM32(reg, pmtm, module, 0x00, 16, 8);
  5364. enum mlxsw_reg_pmtm_module_type {
  5365. MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_4_LANES = 0,
  5366. MLXSW_REG_PMTM_MODULE_TYPE_QSFP = 1,
  5367. MLXSW_REG_PMTM_MODULE_TYPE_SFP = 2,
  5368. MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_SINGLE_LANE = 4,
  5369. MLXSW_REG_PMTM_MODULE_TYPE_BACKPLANE_2_LANES = 8,
  5370. MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP4X = 10,
  5371. MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP2X = 11,
  5372. MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP1X = 12,
  5373. MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD = 14,
  5374. MLXSW_REG_PMTM_MODULE_TYPE_OSFP = 15,
  5375. MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD = 16,
  5376. MLXSW_REG_PMTM_MODULE_TYPE_DSFP = 17,
  5377. MLXSW_REG_PMTM_MODULE_TYPE_CHIP2CHIP8X = 18,
  5378. MLXSW_REG_PMTM_MODULE_TYPE_TWISTED_PAIR = 19,
  5379. };
  5380. /* reg_pmtm_module_type
  5381. * Module type.
  5382. * Access: RW
  5383. */
  5384. MLXSW_ITEM32(reg, pmtm, module_type, 0x04, 0, 5);
  5385. static inline void mlxsw_reg_pmtm_pack(char *payload, u8 slot_index, u8 module)
  5386. {
  5387. MLXSW_REG_ZERO(pmtm, payload);
  5388. mlxsw_reg_pmtm_slot_index_set(payload, slot_index);
  5389. mlxsw_reg_pmtm_module_set(payload, module);
  5390. }
  5391. /* HTGT - Host Trap Group Table
  5392. * ----------------------------
  5393. * Configures the properties for forwarding to CPU.
  5394. */
  5395. #define MLXSW_REG_HTGT_ID 0x7002
  5396. #define MLXSW_REG_HTGT_LEN 0x20
  5397. MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
  5398. /* reg_htgt_swid
  5399. * Switch partition ID.
  5400. * Access: Index
  5401. */
  5402. MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
  5403. #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
  5404. /* reg_htgt_type
  5405. * CPU path type.
  5406. * Access: RW
  5407. */
  5408. MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
  5409. enum mlxsw_reg_htgt_trap_group {
  5410. MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
  5411. MLXSW_REG_HTGT_TRAP_GROUP_CORE_EVENT,
  5412. MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
  5413. MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
  5414. MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
  5415. MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
  5416. MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
  5417. MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
  5418. MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
  5419. MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
  5420. MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
  5421. MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
  5422. MLXSW_REG_HTGT_TRAP_GROUP_SP_EXTERNAL_ROUTE,
  5423. MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
  5424. MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
  5425. MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
  5426. MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
  5427. MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
  5428. MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
  5429. MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
  5430. MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
  5431. MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
  5432. MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
  5433. MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS,
  5434. MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
  5435. MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
  5436. MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
  5437. MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
  5438. MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
  5439. MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
  5440. MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
  5441. MLXSW_REG_HTGT_TRAP_GROUP_SP_BUFFER_DISCARDS,
  5442. __MLXSW_REG_HTGT_TRAP_GROUP_MAX,
  5443. MLXSW_REG_HTGT_TRAP_GROUP_MAX = __MLXSW_REG_HTGT_TRAP_GROUP_MAX - 1
  5444. };
  5445. /* reg_htgt_trap_group
  5446. * Trap group number. User defined number specifying which trap groups
  5447. * should be forwarded to the CPU. The mapping between trap IDs and trap
  5448. * groups is configured using HPKT register.
  5449. * Access: Index
  5450. */
  5451. MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
  5452. enum {
  5453. MLXSW_REG_HTGT_POLICER_DISABLE,
  5454. MLXSW_REG_HTGT_POLICER_ENABLE,
  5455. };
  5456. /* reg_htgt_pide
  5457. * Enable policer ID specified using 'pid' field.
  5458. * Access: RW
  5459. */
  5460. MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
  5461. #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
  5462. /* reg_htgt_pid
  5463. * Policer ID for the trap group.
  5464. * Access: RW
  5465. */
  5466. MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
  5467. #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
  5468. /* reg_htgt_mirror_action
  5469. * Mirror action to use.
  5470. * 0 - Trap to CPU.
  5471. * 1 - Trap to CPU and mirror to a mirroring agent.
  5472. * 2 - Mirror to a mirroring agent and do not trap to CPU.
  5473. * Access: RW
  5474. *
  5475. * Note: Mirroring to a mirroring agent is only supported in Spectrum.
  5476. */
  5477. MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
  5478. /* reg_htgt_mirroring_agent
  5479. * Mirroring agent.
  5480. * Access: RW
  5481. */
  5482. MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
  5483. #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
  5484. /* reg_htgt_priority
  5485. * Trap group priority.
  5486. * In case a packet matches multiple classification rules, the packet will
  5487. * only be trapped once, based on the trap ID associated with the group (via
  5488. * register HPKT) with the highest priority.
  5489. * Supported values are 0-7, with 7 represnting the highest priority.
  5490. * Access: RW
  5491. *
  5492. * Note: In SwitchX-2 this field is ignored and the priority value is replaced
  5493. * by the 'trap_group' field.
  5494. */
  5495. MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
  5496. #define MLXSW_REG_HTGT_DEFAULT_TC 7
  5497. /* reg_htgt_local_path_cpu_tclass
  5498. * CPU ingress traffic class for the trap group.
  5499. * Access: RW
  5500. */
  5501. MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
  5502. enum mlxsw_reg_htgt_local_path_rdq {
  5503. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
  5504. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
  5505. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
  5506. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
  5507. };
  5508. /* reg_htgt_local_path_rdq
  5509. * Receive descriptor queue (RDQ) to use for the trap group.
  5510. * Access: RW
  5511. */
  5512. MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
  5513. static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
  5514. u8 priority, u8 tc)
  5515. {
  5516. MLXSW_REG_ZERO(htgt, payload);
  5517. if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
  5518. mlxsw_reg_htgt_pide_set(payload,
  5519. MLXSW_REG_HTGT_POLICER_DISABLE);
  5520. } else {
  5521. mlxsw_reg_htgt_pide_set(payload,
  5522. MLXSW_REG_HTGT_POLICER_ENABLE);
  5523. mlxsw_reg_htgt_pid_set(payload, policer_id);
  5524. }
  5525. mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
  5526. mlxsw_reg_htgt_trap_group_set(payload, group);
  5527. mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
  5528. mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
  5529. mlxsw_reg_htgt_priority_set(payload, priority);
  5530. mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
  5531. mlxsw_reg_htgt_local_path_rdq_set(payload, group);
  5532. }
  5533. /* HPKT - Host Packet Trap
  5534. * -----------------------
  5535. * Configures trap IDs inside trap groups.
  5536. */
  5537. #define MLXSW_REG_HPKT_ID 0x7003
  5538. #define MLXSW_REG_HPKT_LEN 0x10
  5539. MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
  5540. enum {
  5541. MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
  5542. MLXSW_REG_HPKT_ACK_REQUIRED,
  5543. };
  5544. /* reg_hpkt_ack
  5545. * Require acknowledgements from the host for events.
  5546. * If set, then the device will wait for the event it sent to be acknowledged
  5547. * by the host. This option is only relevant for event trap IDs.
  5548. * Access: RW
  5549. *
  5550. * Note: Currently not supported by firmware.
  5551. */
  5552. MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
  5553. enum mlxsw_reg_hpkt_action {
  5554. MLXSW_REG_HPKT_ACTION_FORWARD,
  5555. MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
  5556. MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
  5557. MLXSW_REG_HPKT_ACTION_DISCARD,
  5558. MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
  5559. MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
  5560. MLXSW_REG_HPKT_ACTION_TRAP_EXCEPTION_TO_CPU,
  5561. MLXSW_REG_HPKT_ACTION_SET_FW_DEFAULT = 15,
  5562. };
  5563. /* reg_hpkt_action
  5564. * Action to perform on packet when trapped.
  5565. * 0 - No action. Forward to CPU based on switching rules.
  5566. * 1 - Trap to CPU (CPU receives sole copy).
  5567. * 2 - Mirror to CPU (CPU receives a replica of the packet).
  5568. * 3 - Discard.
  5569. * 4 - Soft discard (allow other traps to act on the packet).
  5570. * 5 - Trap and soft discard (allow other traps to overwrite this trap).
  5571. * 6 - Trap to CPU (CPU receives sole copy) and count it as error.
  5572. * 15 - Restore the firmware's default action.
  5573. * Access: RW
  5574. *
  5575. * Note: Must be set to 0 (forward) for event trap IDs, as they are already
  5576. * addressed to the CPU.
  5577. */
  5578. MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
  5579. /* reg_hpkt_trap_group
  5580. * Trap group to associate the trap with.
  5581. * Access: RW
  5582. */
  5583. MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
  5584. /* reg_hpkt_trap_id
  5585. * Trap ID.
  5586. * Access: Index
  5587. *
  5588. * Note: A trap ID can only be associated with a single trap group. The device
  5589. * will associate the trap ID with the last trap group configured.
  5590. */
  5591. MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 10);
  5592. enum {
  5593. MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
  5594. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
  5595. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
  5596. };
  5597. /* reg_hpkt_ctrl
  5598. * Configure dedicated buffer resources for control packets.
  5599. * Ignored by SwitchX-2.
  5600. * 0 - Keep factory defaults.
  5601. * 1 - Do not use control buffer for this trap ID.
  5602. * 2 - Use control buffer for this trap ID.
  5603. * Access: RW
  5604. */
  5605. MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
  5606. static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
  5607. enum mlxsw_reg_htgt_trap_group trap_group,
  5608. bool is_ctrl)
  5609. {
  5610. MLXSW_REG_ZERO(hpkt, payload);
  5611. mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
  5612. mlxsw_reg_hpkt_action_set(payload, action);
  5613. mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
  5614. mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
  5615. mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
  5616. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
  5617. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
  5618. }
  5619. /* RGCR - Router General Configuration Register
  5620. * --------------------------------------------
  5621. * The register is used for setting up the router configuration.
  5622. */
  5623. #define MLXSW_REG_RGCR_ID 0x8001
  5624. #define MLXSW_REG_RGCR_LEN 0x28
  5625. MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
  5626. /* reg_rgcr_ipv4_en
  5627. * IPv4 router enable.
  5628. * Access: RW
  5629. */
  5630. MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
  5631. /* reg_rgcr_ipv6_en
  5632. * IPv6 router enable.
  5633. * Access: RW
  5634. */
  5635. MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
  5636. /* reg_rgcr_max_router_interfaces
  5637. * Defines the maximum number of active router interfaces for all virtual
  5638. * routers.
  5639. * Access: RW
  5640. */
  5641. MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
  5642. /* reg_rgcr_usp
  5643. * Update switch priority and packet color.
  5644. * 0 - Preserve the value of Switch Priority and packet color.
  5645. * 1 - Recalculate the value of Switch Priority and packet color.
  5646. * Access: RW
  5647. *
  5648. * Note: Not supported by SwitchX and SwitchX-2.
  5649. */
  5650. MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
  5651. /* reg_rgcr_pcp_rw
  5652. * Indicates how to handle the pcp_rewrite_en value:
  5653. * 0 - Preserve the value of pcp_rewrite_en.
  5654. * 2 - Disable PCP rewrite.
  5655. * 3 - Enable PCP rewrite.
  5656. * Access: RW
  5657. *
  5658. * Note: Not supported by SwitchX and SwitchX-2.
  5659. */
  5660. MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
  5661. /* reg_rgcr_activity_dis
  5662. * Activity disable:
  5663. * 0 - Activity will be set when an entry is hit (default).
  5664. * 1 - Activity will not be set when an entry is hit.
  5665. *
  5666. * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
  5667. * (RALUE).
  5668. * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
  5669. * Entry (RAUHT).
  5670. * Bits 2:7 are reserved.
  5671. * Access: RW
  5672. *
  5673. * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
  5674. */
  5675. MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
  5676. static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
  5677. bool ipv6_en)
  5678. {
  5679. MLXSW_REG_ZERO(rgcr, payload);
  5680. mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
  5681. mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
  5682. }
  5683. /* RITR - Router Interface Table Register
  5684. * --------------------------------------
  5685. * The register is used to configure the router interface table.
  5686. */
  5687. #define MLXSW_REG_RITR_ID 0x8002
  5688. #define MLXSW_REG_RITR_LEN 0x40
  5689. MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
  5690. /* reg_ritr_enable
  5691. * Enables routing on the router interface.
  5692. * Access: RW
  5693. */
  5694. MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
  5695. /* reg_ritr_ipv4
  5696. * IPv4 routing enable. Enables routing of IPv4 traffic on the router
  5697. * interface.
  5698. * Access: RW
  5699. */
  5700. MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
  5701. /* reg_ritr_ipv6
  5702. * IPv6 routing enable. Enables routing of IPv6 traffic on the router
  5703. * interface.
  5704. * Access: RW
  5705. */
  5706. MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
  5707. /* reg_ritr_ipv4_mc
  5708. * IPv4 multicast routing enable.
  5709. * Access: RW
  5710. */
  5711. MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
  5712. /* reg_ritr_ipv6_mc
  5713. * IPv6 multicast routing enable.
  5714. * Access: RW
  5715. */
  5716. MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
  5717. enum mlxsw_reg_ritr_if_type {
  5718. /* VLAN interface. */
  5719. MLXSW_REG_RITR_VLAN_IF,
  5720. /* FID interface. */
  5721. MLXSW_REG_RITR_FID_IF,
  5722. /* Sub-port interface. */
  5723. MLXSW_REG_RITR_SP_IF,
  5724. /* Loopback Interface. */
  5725. MLXSW_REG_RITR_LOOPBACK_IF,
  5726. };
  5727. /* reg_ritr_type
  5728. * Router interface type as per enum mlxsw_reg_ritr_if_type.
  5729. * Access: RW
  5730. */
  5731. MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
  5732. enum {
  5733. MLXSW_REG_RITR_RIF_CREATE,
  5734. MLXSW_REG_RITR_RIF_DEL,
  5735. };
  5736. /* reg_ritr_op
  5737. * Opcode:
  5738. * 0 - Create or edit RIF.
  5739. * 1 - Delete RIF.
  5740. * Reserved for SwitchX-2. For Spectrum, editing of interface properties
  5741. * is not supported. An interface must be deleted and re-created in order
  5742. * to update properties.
  5743. * Access: WO
  5744. */
  5745. MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
  5746. /* reg_ritr_rif
  5747. * Router interface index. A pointer to the Router Interface Table.
  5748. * Access: Index
  5749. */
  5750. MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
  5751. /* reg_ritr_ipv4_fe
  5752. * IPv4 Forwarding Enable.
  5753. * Enables routing of IPv4 traffic on the router interface. When disabled,
  5754. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  5755. * Not supported in SwitchX-2.
  5756. * Access: RW
  5757. */
  5758. MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
  5759. /* reg_ritr_ipv6_fe
  5760. * IPv6 Forwarding Enable.
  5761. * Enables routing of IPv6 traffic on the router interface. When disabled,
  5762. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  5763. * Not supported in SwitchX-2.
  5764. * Access: RW
  5765. */
  5766. MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
  5767. /* reg_ritr_ipv4_mc_fe
  5768. * IPv4 Multicast Forwarding Enable.
  5769. * When disabled, forwarding is blocked but local traffic (traps and IP to me)
  5770. * will be enabled.
  5771. * Access: RW
  5772. */
  5773. MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
  5774. /* reg_ritr_ipv6_mc_fe
  5775. * IPv6 Multicast Forwarding Enable.
  5776. * When disabled, forwarding is blocked but local traffic (traps and IP to me)
  5777. * will be enabled.
  5778. * Access: RW
  5779. */
  5780. MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
  5781. /* reg_ritr_lb_en
  5782. * Loop-back filter enable for unicast packets.
  5783. * If the flag is set then loop-back filter for unicast packets is
  5784. * implemented on the RIF. Multicast packets are always subject to
  5785. * loop-back filtering.
  5786. * Access: RW
  5787. */
  5788. MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
  5789. /* reg_ritr_virtual_router
  5790. * Virtual router ID associated with the router interface.
  5791. * Access: RW
  5792. */
  5793. MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
  5794. /* reg_ritr_mtu
  5795. * Router interface MTU.
  5796. * Access: RW
  5797. */
  5798. MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
  5799. /* reg_ritr_if_swid
  5800. * Switch partition ID.
  5801. * Access: RW
  5802. */
  5803. MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
  5804. /* reg_ritr_if_mac_profile_id
  5805. * MAC msb profile ID.
  5806. * Access: RW
  5807. */
  5808. MLXSW_ITEM32(reg, ritr, if_mac_profile_id, 0x10, 16, 4);
  5809. /* reg_ritr_if_mac
  5810. * Router interface MAC address.
  5811. * In Spectrum, all MAC addresses must have the same 38 MSBits.
  5812. * Access: RW
  5813. */
  5814. MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
  5815. /* reg_ritr_if_vrrp_id_ipv6
  5816. * VRRP ID for IPv6
  5817. * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
  5818. * Access: RW
  5819. */
  5820. MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
  5821. /* reg_ritr_if_vrrp_id_ipv4
  5822. * VRRP ID for IPv4
  5823. * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
  5824. * Access: RW
  5825. */
  5826. MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
  5827. /* VLAN Interface */
  5828. /* reg_ritr_vlan_if_vlan_id
  5829. * VLAN ID.
  5830. * Access: RW
  5831. */
  5832. MLXSW_ITEM32(reg, ritr, vlan_if_vlan_id, 0x08, 0, 12);
  5833. /* reg_ritr_vlan_if_efid
  5834. * Egress FID.
  5835. * Used to connect the RIF to a bridge.
  5836. * Access: RW
  5837. *
  5838. * Note: Reserved when legacy bridge model is used and on Spectrum-1.
  5839. */
  5840. MLXSW_ITEM32(reg, ritr, vlan_if_efid, 0x0C, 0, 16);
  5841. /* FID Interface */
  5842. /* reg_ritr_fid_if_fid
  5843. * Filtering ID. Used to connect a bridge to the router.
  5844. * When legacy bridge model is used, only FIDs from the vFID range are
  5845. * supported. When unified bridge model is used, this is the egress FID for
  5846. * router to bridge.
  5847. * Access: RW
  5848. */
  5849. MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
  5850. /* Sub-port Interface */
  5851. /* reg_ritr_sp_if_lag
  5852. * LAG indication. When this bit is set the system_port field holds the
  5853. * LAG identifier.
  5854. * Access: RW
  5855. */
  5856. MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
  5857. /* reg_ritr_sp_system_port
  5858. * Port unique indentifier. When lag bit is set, this field holds the
  5859. * lag_id in bits 0:9.
  5860. * Access: RW
  5861. */
  5862. MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
  5863. /* reg_ritr_sp_if_efid
  5864. * Egress filtering ID.
  5865. * Used to connect the eRIF to a bridge if eRIF-ACL has modified the DMAC or
  5866. * the VID.
  5867. * Access: RW
  5868. *
  5869. * Note: Reserved when legacy bridge model is used.
  5870. */
  5871. MLXSW_ITEM32(reg, ritr, sp_if_efid, 0x0C, 0, 16);
  5872. /* reg_ritr_sp_if_vid
  5873. * VLAN ID.
  5874. * Access: RW
  5875. */
  5876. MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
  5877. /* Loopback Interface */
  5878. enum mlxsw_reg_ritr_loopback_protocol {
  5879. /* IPinIP IPv4 underlay Unicast */
  5880. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
  5881. /* IPinIP IPv6 underlay Unicast */
  5882. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
  5883. /* IPinIP generic - used for Spectrum-2 underlay RIF */
  5884. MLXSW_REG_RITR_LOOPBACK_GENERIC,
  5885. };
  5886. /* reg_ritr_loopback_protocol
  5887. * Access: RW
  5888. */
  5889. MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
  5890. enum mlxsw_reg_ritr_loopback_ipip_type {
  5891. /* Tunnel is IPinIP. */
  5892. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
  5893. /* Tunnel is GRE, no key. */
  5894. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
  5895. /* Tunnel is GRE, with a key. */
  5896. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
  5897. };
  5898. /* reg_ritr_loopback_ipip_type
  5899. * Encapsulation type.
  5900. * Access: RW
  5901. */
  5902. MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
  5903. enum mlxsw_reg_ritr_loopback_ipip_options {
  5904. /* The key is defined by gre_key. */
  5905. MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
  5906. };
  5907. /* reg_ritr_loopback_ipip_options
  5908. * Access: RW
  5909. */
  5910. MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
  5911. /* reg_ritr_loopback_ipip_uvr
  5912. * Underlay Virtual Router ID.
  5913. * Range is 0..cap_max_virtual_routers-1.
  5914. * Reserved for Spectrum-2.
  5915. * Access: RW
  5916. */
  5917. MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
  5918. /* reg_ritr_loopback_ipip_underlay_rif
  5919. * Underlay ingress router interface.
  5920. * Reserved for Spectrum.
  5921. * Access: RW
  5922. */
  5923. MLXSW_ITEM32(reg, ritr, loopback_ipip_underlay_rif, 0x14, 0, 16);
  5924. /* reg_ritr_loopback_ipip_usip*
  5925. * Encapsulation Underlay source IP.
  5926. * Access: RW
  5927. */
  5928. MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
  5929. MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
  5930. /* reg_ritr_loopback_ipip_gre_key
  5931. * GRE Key.
  5932. * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
  5933. * Access: RW
  5934. */
  5935. MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
  5936. /* Shared between ingress/egress */
  5937. enum mlxsw_reg_ritr_counter_set_type {
  5938. /* No Count. */
  5939. MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
  5940. /* Basic. Used for router interfaces, counting the following:
  5941. * - Error and Discard counters.
  5942. * - Unicast, Multicast and Broadcast counters. Sharing the
  5943. * same set of counters for the different type of traffic
  5944. * (IPv4, IPv6 and mpls).
  5945. */
  5946. MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
  5947. };
  5948. /* reg_ritr_ingress_counter_index
  5949. * Counter Index for flow counter.
  5950. * Access: RW
  5951. */
  5952. MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
  5953. /* reg_ritr_ingress_counter_set_type
  5954. * Igress Counter Set Type for router interface counter.
  5955. * Access: RW
  5956. */
  5957. MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
  5958. /* reg_ritr_egress_counter_index
  5959. * Counter Index for flow counter.
  5960. * Access: RW
  5961. */
  5962. MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
  5963. /* reg_ritr_egress_counter_set_type
  5964. * Egress Counter Set Type for router interface counter.
  5965. * Access: RW
  5966. */
  5967. MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
  5968. static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
  5969. bool enable, bool egress)
  5970. {
  5971. enum mlxsw_reg_ritr_counter_set_type set_type;
  5972. if (enable)
  5973. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
  5974. else
  5975. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
  5976. if (egress) {
  5977. mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
  5978. mlxsw_reg_ritr_egress_counter_index_set(payload, index);
  5979. } else {
  5980. mlxsw_reg_ritr_ingress_counter_set_type_set(payload, set_type);
  5981. mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
  5982. }
  5983. }
  5984. static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
  5985. {
  5986. MLXSW_REG_ZERO(ritr, payload);
  5987. mlxsw_reg_ritr_rif_set(payload, rif);
  5988. }
  5989. static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
  5990. u16 system_port, u16 efid, u16 vid)
  5991. {
  5992. mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
  5993. mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
  5994. mlxsw_reg_ritr_sp_if_efid_set(payload, efid);
  5995. mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
  5996. }
  5997. static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
  5998. enum mlxsw_reg_ritr_if_type type,
  5999. u16 rif, u16 vr_id, u16 mtu)
  6000. {
  6001. bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
  6002. MLXSW_REG_ZERO(ritr, payload);
  6003. mlxsw_reg_ritr_enable_set(payload, enable);
  6004. mlxsw_reg_ritr_ipv4_set(payload, 1);
  6005. mlxsw_reg_ritr_ipv6_set(payload, 1);
  6006. mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
  6007. mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
  6008. mlxsw_reg_ritr_type_set(payload, type);
  6009. mlxsw_reg_ritr_op_set(payload, op);
  6010. mlxsw_reg_ritr_rif_set(payload, rif);
  6011. mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
  6012. mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
  6013. mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
  6014. mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
  6015. mlxsw_reg_ritr_lb_en_set(payload, 1);
  6016. mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
  6017. mlxsw_reg_ritr_mtu_set(payload, mtu);
  6018. }
  6019. static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
  6020. {
  6021. mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
  6022. }
  6023. static inline void
  6024. mlxsw_reg_ritr_vlan_if_pack(char *payload, bool enable, u16 rif, u16 vr_id,
  6025. u16 mtu, const char *mac, u8 mac_profile_id,
  6026. u16 vlan_id, u16 efid)
  6027. {
  6028. enum mlxsw_reg_ritr_if_type type = MLXSW_REG_RITR_VLAN_IF;
  6029. mlxsw_reg_ritr_pack(payload, enable, type, rif, vr_id, mtu);
  6030. mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
  6031. mlxsw_reg_ritr_if_mac_profile_id_set(payload, mac_profile_id);
  6032. mlxsw_reg_ritr_vlan_if_vlan_id_set(payload, vlan_id);
  6033. mlxsw_reg_ritr_vlan_if_efid_set(payload, efid);
  6034. }
  6035. static inline void
  6036. mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
  6037. enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
  6038. enum mlxsw_reg_ritr_loopback_ipip_options options,
  6039. u16 uvr_id, u16 underlay_rif, u32 gre_key)
  6040. {
  6041. mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
  6042. mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
  6043. mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
  6044. mlxsw_reg_ritr_loopback_ipip_underlay_rif_set(payload, underlay_rif);
  6045. mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
  6046. }
  6047. static inline void
  6048. mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
  6049. enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
  6050. enum mlxsw_reg_ritr_loopback_ipip_options options,
  6051. u16 uvr_id, u16 underlay_rif, u32 usip, u32 gre_key)
  6052. {
  6053. mlxsw_reg_ritr_loopback_protocol_set(payload,
  6054. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
  6055. mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
  6056. uvr_id, underlay_rif, gre_key);
  6057. mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
  6058. }
  6059. static inline void
  6060. mlxsw_reg_ritr_loopback_ipip6_pack(char *payload,
  6061. enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
  6062. enum mlxsw_reg_ritr_loopback_ipip_options options,
  6063. u16 uvr_id, u16 underlay_rif,
  6064. const struct in6_addr *usip, u32 gre_key)
  6065. {
  6066. enum mlxsw_reg_ritr_loopback_protocol protocol =
  6067. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6;
  6068. mlxsw_reg_ritr_loopback_protocol_set(payload, protocol);
  6069. mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
  6070. uvr_id, underlay_rif, gre_key);
  6071. mlxsw_reg_ritr_loopback_ipip_usip6_memcpy_to(payload,
  6072. (const char *)usip);
  6073. }
  6074. /* RTAR - Router TCAM Allocation Register
  6075. * --------------------------------------
  6076. * This register is used for allocation of regions in the TCAM table.
  6077. */
  6078. #define MLXSW_REG_RTAR_ID 0x8004
  6079. #define MLXSW_REG_RTAR_LEN 0x20
  6080. MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
  6081. enum mlxsw_reg_rtar_op {
  6082. MLXSW_REG_RTAR_OP_ALLOCATE,
  6083. MLXSW_REG_RTAR_OP_RESIZE,
  6084. MLXSW_REG_RTAR_OP_DEALLOCATE,
  6085. };
  6086. /* reg_rtar_op
  6087. * Access: WO
  6088. */
  6089. MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
  6090. enum mlxsw_reg_rtar_key_type {
  6091. MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
  6092. MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
  6093. };
  6094. /* reg_rtar_key_type
  6095. * TCAM key type for the region.
  6096. * Access: WO
  6097. */
  6098. MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
  6099. /* reg_rtar_region_size
  6100. * TCAM region size. When allocating/resizing this is the requested
  6101. * size, the response is the actual size.
  6102. * Note: Actual size may be larger than requested.
  6103. * Reserved for op = Deallocate
  6104. * Access: WO
  6105. */
  6106. MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
  6107. static inline void mlxsw_reg_rtar_pack(char *payload,
  6108. enum mlxsw_reg_rtar_op op,
  6109. enum mlxsw_reg_rtar_key_type key_type,
  6110. u16 region_size)
  6111. {
  6112. MLXSW_REG_ZERO(rtar, payload);
  6113. mlxsw_reg_rtar_op_set(payload, op);
  6114. mlxsw_reg_rtar_key_type_set(payload, key_type);
  6115. mlxsw_reg_rtar_region_size_set(payload, region_size);
  6116. }
  6117. /* RATR - Router Adjacency Table Register
  6118. * --------------------------------------
  6119. * The RATR register is used to configure the Router Adjacency (next-hop)
  6120. * Table.
  6121. */
  6122. #define MLXSW_REG_RATR_ID 0x8008
  6123. #define MLXSW_REG_RATR_LEN 0x2C
  6124. MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
  6125. enum mlxsw_reg_ratr_op {
  6126. /* Read */
  6127. MLXSW_REG_RATR_OP_QUERY_READ = 0,
  6128. /* Read and clear activity */
  6129. MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
  6130. /* Write Adjacency entry */
  6131. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
  6132. /* Write Adjacency entry only if the activity is cleared.
  6133. * The write may not succeed if the activity is set. There is not
  6134. * direct feedback if the write has succeeded or not, however
  6135. * the get will reveal the actual entry (SW can compare the get
  6136. * response to the set command).
  6137. */
  6138. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
  6139. };
  6140. /* reg_ratr_op
  6141. * Note that Write operation may also be used for updating
  6142. * counter_set_type and counter_index. In this case all other
  6143. * fields must not be updated.
  6144. * Access: OP
  6145. */
  6146. MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
  6147. /* reg_ratr_v
  6148. * Valid bit. Indicates if the adjacency entry is valid.
  6149. * Note: the device may need some time before reusing an invalidated
  6150. * entry. During this time the entry can not be reused. It is
  6151. * recommended to use another entry before reusing an invalidated
  6152. * entry (e.g. software can put it at the end of the list for
  6153. * reusing). Trying to access an invalidated entry not yet cleared
  6154. * by the device results with failure indicating "Try Again" status.
  6155. * When valid is '0' then egress_router_interface,trap_action,
  6156. * adjacency_parameters and counters are reserved
  6157. * Access: RW
  6158. */
  6159. MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
  6160. /* reg_ratr_a
  6161. * Activity. Set for new entries. Set if a packet lookup has hit on
  6162. * the specific entry. To clear the a bit, use "clear activity".
  6163. * Access: RO
  6164. */
  6165. MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
  6166. enum mlxsw_reg_ratr_type {
  6167. /* Ethernet */
  6168. MLXSW_REG_RATR_TYPE_ETHERNET,
  6169. /* IPoIB Unicast without GRH.
  6170. * Reserved for Spectrum.
  6171. */
  6172. MLXSW_REG_RATR_TYPE_IPOIB_UC,
  6173. /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
  6174. * adjacency).
  6175. * Reserved for Spectrum.
  6176. */
  6177. MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
  6178. /* IPoIB Multicast.
  6179. * Reserved for Spectrum.
  6180. */
  6181. MLXSW_REG_RATR_TYPE_IPOIB_MC,
  6182. /* MPLS.
  6183. * Reserved for SwitchX/-2.
  6184. */
  6185. MLXSW_REG_RATR_TYPE_MPLS,
  6186. /* IPinIP Encap.
  6187. * Reserved for SwitchX/-2.
  6188. */
  6189. MLXSW_REG_RATR_TYPE_IPIP,
  6190. };
  6191. /* reg_ratr_type
  6192. * Adjacency entry type.
  6193. * Access: RW
  6194. */
  6195. MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
  6196. /* reg_ratr_adjacency_index_low
  6197. * Bits 15:0 of index into the adjacency table.
  6198. * For SwitchX and SwitchX-2, the adjacency table is linear and
  6199. * used for adjacency entries only.
  6200. * For Spectrum, the index is to the KVD linear.
  6201. * Access: Index
  6202. */
  6203. MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
  6204. /* reg_ratr_egress_router_interface
  6205. * Range is 0 .. cap_max_router_interfaces - 1
  6206. * Access: RW
  6207. */
  6208. MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
  6209. enum mlxsw_reg_ratr_trap_action {
  6210. MLXSW_REG_RATR_TRAP_ACTION_NOP,
  6211. MLXSW_REG_RATR_TRAP_ACTION_TRAP,
  6212. MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
  6213. MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
  6214. MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
  6215. };
  6216. /* reg_ratr_trap_action
  6217. * see mlxsw_reg_ratr_trap_action
  6218. * Access: RW
  6219. */
  6220. MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
  6221. /* reg_ratr_adjacency_index_high
  6222. * Bits 23:16 of the adjacency_index.
  6223. * Access: Index
  6224. */
  6225. MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
  6226. enum mlxsw_reg_ratr_trap_id {
  6227. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
  6228. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
  6229. };
  6230. /* reg_ratr_trap_id
  6231. * Trap ID to be reported to CPU.
  6232. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  6233. * For trap_action of NOP, MIRROR and DISCARD_ERROR
  6234. * Access: RW
  6235. */
  6236. MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
  6237. /* reg_ratr_eth_destination_mac
  6238. * MAC address of the destination next-hop.
  6239. * Access: RW
  6240. */
  6241. MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
  6242. enum mlxsw_reg_ratr_ipip_type {
  6243. /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
  6244. MLXSW_REG_RATR_IPIP_TYPE_IPV4,
  6245. /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
  6246. MLXSW_REG_RATR_IPIP_TYPE_IPV6,
  6247. };
  6248. /* reg_ratr_ipip_type
  6249. * Underlay destination ip type.
  6250. * Note: the type field must match the protocol of the router interface.
  6251. * Access: RW
  6252. */
  6253. MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
  6254. /* reg_ratr_ipip_ipv4_udip
  6255. * Underlay ipv4 dip.
  6256. * Reserved when ipip_type is IPv6.
  6257. * Access: RW
  6258. */
  6259. MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
  6260. /* reg_ratr_ipip_ipv6_ptr
  6261. * Pointer to IPv6 underlay destination ip address.
  6262. * For Spectrum: Pointer to KVD linear space.
  6263. * Access: RW
  6264. */
  6265. MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
  6266. enum mlxsw_reg_flow_counter_set_type {
  6267. /* No count */
  6268. MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
  6269. /* Count packets and bytes */
  6270. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
  6271. /* Count only packets */
  6272. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
  6273. };
  6274. /* reg_ratr_counter_set_type
  6275. * Counter set type for flow counters
  6276. * Access: RW
  6277. */
  6278. MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
  6279. /* reg_ratr_counter_index
  6280. * Counter index for flow counters
  6281. * Access: RW
  6282. */
  6283. MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
  6284. static inline void
  6285. mlxsw_reg_ratr_pack(char *payload,
  6286. enum mlxsw_reg_ratr_op op, bool valid,
  6287. enum mlxsw_reg_ratr_type type,
  6288. u32 adjacency_index, u16 egress_rif)
  6289. {
  6290. MLXSW_REG_ZERO(ratr, payload);
  6291. mlxsw_reg_ratr_op_set(payload, op);
  6292. mlxsw_reg_ratr_v_set(payload, valid);
  6293. mlxsw_reg_ratr_type_set(payload, type);
  6294. mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
  6295. mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
  6296. mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
  6297. }
  6298. static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
  6299. const char *dest_mac)
  6300. {
  6301. mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
  6302. }
  6303. static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
  6304. {
  6305. mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
  6306. mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
  6307. }
  6308. static inline void mlxsw_reg_ratr_ipip6_entry_pack(char *payload, u32 ipv6_ptr)
  6309. {
  6310. mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV6);
  6311. mlxsw_reg_ratr_ipip_ipv6_ptr_set(payload, ipv6_ptr);
  6312. }
  6313. static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
  6314. bool counter_enable)
  6315. {
  6316. enum mlxsw_reg_flow_counter_set_type set_type;
  6317. if (counter_enable)
  6318. set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
  6319. else
  6320. set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
  6321. mlxsw_reg_ratr_counter_index_set(payload, counter_index);
  6322. mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
  6323. }
  6324. /* RDPM - Router DSCP to Priority Mapping
  6325. * --------------------------------------
  6326. * Controls the mapping from DSCP field to switch priority on routed packets
  6327. */
  6328. #define MLXSW_REG_RDPM_ID 0x8009
  6329. #define MLXSW_REG_RDPM_BASE_LEN 0x00
  6330. #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
  6331. #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
  6332. #define MLXSW_REG_RDPM_LEN 0x40
  6333. #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
  6334. MLXSW_REG_RDPM_LEN - \
  6335. MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
  6336. MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
  6337. /* reg_dscp_entry_e
  6338. * Enable update of the specific entry
  6339. * Access: Index
  6340. */
  6341. MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
  6342. -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  6343. /* reg_dscp_entry_prio
  6344. * Switch Priority
  6345. * Access: RW
  6346. */
  6347. MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
  6348. -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  6349. static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
  6350. u8 prio)
  6351. {
  6352. mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
  6353. mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
  6354. }
  6355. /* RICNT - Router Interface Counter Register
  6356. * -----------------------------------------
  6357. * The RICNT register retrieves per port performance counters
  6358. */
  6359. #define MLXSW_REG_RICNT_ID 0x800B
  6360. #define MLXSW_REG_RICNT_LEN 0x100
  6361. MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
  6362. /* reg_ricnt_counter_index
  6363. * Counter index
  6364. * Access: RW
  6365. */
  6366. MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
  6367. enum mlxsw_reg_ricnt_counter_set_type {
  6368. /* No Count. */
  6369. MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
  6370. /* Basic. Used for router interfaces, counting the following:
  6371. * - Error and Discard counters.
  6372. * - Unicast, Multicast and Broadcast counters. Sharing the
  6373. * same set of counters for the different type of traffic
  6374. * (IPv4, IPv6 and mpls).
  6375. */
  6376. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
  6377. };
  6378. /* reg_ricnt_counter_set_type
  6379. * Counter Set Type for router interface counter
  6380. * Access: RW
  6381. */
  6382. MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
  6383. enum mlxsw_reg_ricnt_opcode {
  6384. /* Nop. Supported only for read access*/
  6385. MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
  6386. /* Clear. Setting the clr bit will reset the counter value for
  6387. * all counters of the specified Router Interface.
  6388. */
  6389. MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
  6390. };
  6391. /* reg_ricnt_opcode
  6392. * Opcode
  6393. * Access: RW
  6394. */
  6395. MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
  6396. /* reg_ricnt_good_unicast_packets
  6397. * good unicast packets.
  6398. * Access: RW
  6399. */
  6400. MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
  6401. /* reg_ricnt_good_multicast_packets
  6402. * good multicast packets.
  6403. * Access: RW
  6404. */
  6405. MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
  6406. /* reg_ricnt_good_broadcast_packets
  6407. * good broadcast packets
  6408. * Access: RW
  6409. */
  6410. MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
  6411. /* reg_ricnt_good_unicast_bytes
  6412. * A count of L3 data and padding octets not including L2 headers
  6413. * for good unicast frames.
  6414. * Access: RW
  6415. */
  6416. MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
  6417. /* reg_ricnt_good_multicast_bytes
  6418. * A count of L3 data and padding octets not including L2 headers
  6419. * for good multicast frames.
  6420. * Access: RW
  6421. */
  6422. MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
  6423. /* reg_ritr_good_broadcast_bytes
  6424. * A count of L3 data and padding octets not including L2 headers
  6425. * for good broadcast frames.
  6426. * Access: RW
  6427. */
  6428. MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
  6429. /* reg_ricnt_error_packets
  6430. * A count of errored frames that do not pass the router checks.
  6431. * Access: RW
  6432. */
  6433. MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
  6434. /* reg_ricnt_discrad_packets
  6435. * A count of non-errored frames that do not pass the router checks.
  6436. * Access: RW
  6437. */
  6438. MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
  6439. /* reg_ricnt_error_bytes
  6440. * A count of L3 data and padding octets not including L2 headers
  6441. * for errored frames.
  6442. * Access: RW
  6443. */
  6444. MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
  6445. /* reg_ricnt_discard_bytes
  6446. * A count of L3 data and padding octets not including L2 headers
  6447. * for non-errored frames that do not pass the router checks.
  6448. * Access: RW
  6449. */
  6450. MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
  6451. static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
  6452. enum mlxsw_reg_ricnt_opcode op)
  6453. {
  6454. MLXSW_REG_ZERO(ricnt, payload);
  6455. mlxsw_reg_ricnt_op_set(payload, op);
  6456. mlxsw_reg_ricnt_counter_index_set(payload, index);
  6457. mlxsw_reg_ricnt_counter_set_type_set(payload,
  6458. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
  6459. }
  6460. /* RRCR - Router Rules Copy Register Layout
  6461. * ----------------------------------------
  6462. * This register is used for moving and copying route entry rules.
  6463. */
  6464. #define MLXSW_REG_RRCR_ID 0x800F
  6465. #define MLXSW_REG_RRCR_LEN 0x24
  6466. MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
  6467. enum mlxsw_reg_rrcr_op {
  6468. /* Move rules */
  6469. MLXSW_REG_RRCR_OP_MOVE,
  6470. /* Copy rules */
  6471. MLXSW_REG_RRCR_OP_COPY,
  6472. };
  6473. /* reg_rrcr_op
  6474. * Access: WO
  6475. */
  6476. MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
  6477. /* reg_rrcr_offset
  6478. * Offset within the region from which to copy/move.
  6479. * Access: Index
  6480. */
  6481. MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
  6482. /* reg_rrcr_size
  6483. * The number of rules to copy/move.
  6484. * Access: WO
  6485. */
  6486. MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
  6487. /* reg_rrcr_table_id
  6488. * Identifier of the table on which to perform the operation. Encoding is the
  6489. * same as in RTAR.key_type
  6490. * Access: Index
  6491. */
  6492. MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
  6493. /* reg_rrcr_dest_offset
  6494. * Offset within the region to which to copy/move
  6495. * Access: Index
  6496. */
  6497. MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
  6498. static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
  6499. u16 offset, u16 size,
  6500. enum mlxsw_reg_rtar_key_type table_id,
  6501. u16 dest_offset)
  6502. {
  6503. MLXSW_REG_ZERO(rrcr, payload);
  6504. mlxsw_reg_rrcr_op_set(payload, op);
  6505. mlxsw_reg_rrcr_offset_set(payload, offset);
  6506. mlxsw_reg_rrcr_size_set(payload, size);
  6507. mlxsw_reg_rrcr_table_id_set(payload, table_id);
  6508. mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
  6509. }
  6510. /* RALTA - Router Algorithmic LPM Tree Allocation Register
  6511. * -------------------------------------------------------
  6512. * RALTA is used to allocate the LPM trees of the SHSPM method.
  6513. */
  6514. #define MLXSW_REG_RALTA_ID 0x8010
  6515. #define MLXSW_REG_RALTA_LEN 0x04
  6516. MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
  6517. /* reg_ralta_op
  6518. * opcode (valid for Write, must be 0 on Read)
  6519. * 0 - allocate a tree
  6520. * 1 - deallocate a tree
  6521. * Access: OP
  6522. */
  6523. MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
  6524. enum mlxsw_reg_ralxx_protocol {
  6525. MLXSW_REG_RALXX_PROTOCOL_IPV4,
  6526. MLXSW_REG_RALXX_PROTOCOL_IPV6,
  6527. };
  6528. /* reg_ralta_protocol
  6529. * Protocol.
  6530. * Deallocation opcode: Reserved.
  6531. * Access: RW
  6532. */
  6533. MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
  6534. /* reg_ralta_tree_id
  6535. * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
  6536. * the tree identifier (managed by software).
  6537. * Note that tree_id 0 is allocated for a default-route tree.
  6538. * Access: Index
  6539. */
  6540. MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
  6541. static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
  6542. enum mlxsw_reg_ralxx_protocol protocol,
  6543. u8 tree_id)
  6544. {
  6545. MLXSW_REG_ZERO(ralta, payload);
  6546. mlxsw_reg_ralta_op_set(payload, !alloc);
  6547. mlxsw_reg_ralta_protocol_set(payload, protocol);
  6548. mlxsw_reg_ralta_tree_id_set(payload, tree_id);
  6549. }
  6550. /* RALST - Router Algorithmic LPM Structure Tree Register
  6551. * ------------------------------------------------------
  6552. * RALST is used to set and query the structure of an LPM tree.
  6553. * The structure of the tree must be sorted as a sorted binary tree, while
  6554. * each node is a bin that is tagged as the length of the prefixes the lookup
  6555. * will refer to. Therefore, bin X refers to a set of entries with prefixes
  6556. * of X bits to match with the destination address. The bin 0 indicates
  6557. * the default action, when there is no match of any prefix.
  6558. */
  6559. #define MLXSW_REG_RALST_ID 0x8011
  6560. #define MLXSW_REG_RALST_LEN 0x104
  6561. MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
  6562. /* reg_ralst_root_bin
  6563. * The bin number of the root bin.
  6564. * 0<root_bin=<(length of IP address)
  6565. * For a default-route tree configure 0xff
  6566. * Access: RW
  6567. */
  6568. MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
  6569. /* reg_ralst_tree_id
  6570. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  6571. * Access: Index
  6572. */
  6573. MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
  6574. #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
  6575. #define MLXSW_REG_RALST_BIN_OFFSET 0x04
  6576. #define MLXSW_REG_RALST_BIN_COUNT 128
  6577. /* reg_ralst_left_child_bin
  6578. * Holding the children of the bin according to the stored tree's structure.
  6579. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  6580. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  6581. * Access: RW
  6582. */
  6583. MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
  6584. /* reg_ralst_right_child_bin
  6585. * Holding the children of the bin according to the stored tree's structure.
  6586. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  6587. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  6588. * Access: RW
  6589. */
  6590. MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
  6591. false);
  6592. static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
  6593. {
  6594. MLXSW_REG_ZERO(ralst, payload);
  6595. /* Initialize all bins to have no left or right child */
  6596. memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
  6597. MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
  6598. mlxsw_reg_ralst_root_bin_set(payload, root_bin);
  6599. mlxsw_reg_ralst_tree_id_set(payload, tree_id);
  6600. }
  6601. static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
  6602. u8 left_child_bin,
  6603. u8 right_child_bin)
  6604. {
  6605. int bin_index = bin_number - 1;
  6606. mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
  6607. mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
  6608. right_child_bin);
  6609. }
  6610. /* RALTB - Router Algorithmic LPM Tree Binding Register
  6611. * ----------------------------------------------------
  6612. * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
  6613. */
  6614. #define MLXSW_REG_RALTB_ID 0x8012
  6615. #define MLXSW_REG_RALTB_LEN 0x04
  6616. MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
  6617. /* reg_raltb_virtual_router
  6618. * Virtual Router ID
  6619. * Range is 0..cap_max_virtual_routers-1
  6620. * Access: Index
  6621. */
  6622. MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
  6623. /* reg_raltb_protocol
  6624. * Protocol.
  6625. * Access: Index
  6626. */
  6627. MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
  6628. /* reg_raltb_tree_id
  6629. * Tree to be used for the {virtual_router, protocol}
  6630. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  6631. * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
  6632. * Access: RW
  6633. */
  6634. MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
  6635. static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
  6636. enum mlxsw_reg_ralxx_protocol protocol,
  6637. u8 tree_id)
  6638. {
  6639. MLXSW_REG_ZERO(raltb, payload);
  6640. mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
  6641. mlxsw_reg_raltb_protocol_set(payload, protocol);
  6642. mlxsw_reg_raltb_tree_id_set(payload, tree_id);
  6643. }
  6644. /* RALUE - Router Algorithmic LPM Unicast Entry Register
  6645. * -----------------------------------------------------
  6646. * RALUE is used to configure and query LPM entries that serve
  6647. * the Unicast protocols.
  6648. */
  6649. #define MLXSW_REG_RALUE_ID 0x8013
  6650. #define MLXSW_REG_RALUE_LEN 0x38
  6651. MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
  6652. /* reg_ralue_protocol
  6653. * Protocol.
  6654. * Access: Index
  6655. */
  6656. MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
  6657. enum mlxsw_reg_ralue_op {
  6658. /* Read operation. If entry doesn't exist, the operation fails. */
  6659. MLXSW_REG_RALUE_OP_QUERY_READ = 0,
  6660. /* Clear on read operation. Used to read entry and
  6661. * clear Activity bit.
  6662. */
  6663. MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
  6664. /* Write operation. Used to write a new entry to the table. All RW
  6665. * fields are written for new entry. Activity bit is set
  6666. * for new entries.
  6667. */
  6668. MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
  6669. /* Update operation. Used to update an existing route entry and
  6670. * only update the RW fields that are detailed in the field
  6671. * op_u_mask. If entry doesn't exist, the operation fails.
  6672. */
  6673. MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
  6674. /* Clear activity. The Activity bit (the field a) is cleared
  6675. * for the entry.
  6676. */
  6677. MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
  6678. /* Delete operation. Used to delete an existing entry. If entry
  6679. * doesn't exist, the operation fails.
  6680. */
  6681. MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
  6682. };
  6683. /* reg_ralue_op
  6684. * Operation.
  6685. * Access: OP
  6686. */
  6687. MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
  6688. /* reg_ralue_a
  6689. * Activity. Set for new entries. Set if a packet lookup has hit on the
  6690. * specific entry, only if the entry is a route. To clear the a bit, use
  6691. * "clear activity" op.
  6692. * Enabled by activity_dis in RGCR
  6693. * Access: RO
  6694. */
  6695. MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
  6696. /* reg_ralue_virtual_router
  6697. * Virtual Router ID
  6698. * Range is 0..cap_max_virtual_routers-1
  6699. * Access: Index
  6700. */
  6701. MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
  6702. #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
  6703. #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
  6704. #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
  6705. /* reg_ralue_op_u_mask
  6706. * opcode update mask.
  6707. * On read operation, this field is reserved.
  6708. * This field is valid for update opcode, otherwise - reserved.
  6709. * This field is a bitmask of the fields that should be updated.
  6710. * Access: WO
  6711. */
  6712. MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
  6713. /* reg_ralue_prefix_len
  6714. * Number of bits in the prefix of the LPM route.
  6715. * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
  6716. * two entries in the physical HW table.
  6717. * Access: Index
  6718. */
  6719. MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
  6720. /* reg_ralue_dip*
  6721. * The prefix of the route or of the marker that the object of the LPM
  6722. * is compared with. The most significant bits of the dip are the prefix.
  6723. * The least significant bits must be '0' if the prefix_len is smaller
  6724. * than 128 for IPv6 or smaller than 32 for IPv4.
  6725. * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
  6726. * Access: Index
  6727. */
  6728. MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
  6729. MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
  6730. enum mlxsw_reg_ralue_entry_type {
  6731. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
  6732. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
  6733. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
  6734. };
  6735. /* reg_ralue_entry_type
  6736. * Entry type.
  6737. * Note - for Marker entries, the action_type and action fields are reserved.
  6738. * Access: RW
  6739. */
  6740. MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
  6741. /* reg_ralue_bmp_len
  6742. * The best match prefix length in the case that there is no match for
  6743. * longer prefixes.
  6744. * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
  6745. * Note for any update operation with entry_type modification this
  6746. * field must be set.
  6747. * Access: RW
  6748. */
  6749. MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
  6750. enum mlxsw_reg_ralue_action_type {
  6751. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
  6752. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
  6753. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
  6754. };
  6755. /* reg_ralue_action_type
  6756. * Action Type
  6757. * Indicates how the IP address is connected.
  6758. * It can be connected to a local subnet through local_erif or can be
  6759. * on a remote subnet connected through a next-hop router,
  6760. * or transmitted to the CPU.
  6761. * Reserved when entry_type = MARKER_ENTRY
  6762. * Access: RW
  6763. */
  6764. MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
  6765. enum mlxsw_reg_ralue_trap_action {
  6766. MLXSW_REG_RALUE_TRAP_ACTION_NOP,
  6767. MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
  6768. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
  6769. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
  6770. MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
  6771. };
  6772. /* reg_ralue_trap_action
  6773. * Trap action.
  6774. * For IP2ME action, only NOP and MIRROR are possible.
  6775. * Access: RW
  6776. */
  6777. MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
  6778. /* reg_ralue_trap_id
  6779. * Trap ID to be reported to CPU.
  6780. * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
  6781. * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
  6782. * Access: RW
  6783. */
  6784. MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
  6785. /* reg_ralue_adjacency_index
  6786. * Points to the first entry of the group-based ECMP.
  6787. * Only relevant in case of REMOTE action.
  6788. * Access: RW
  6789. */
  6790. MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
  6791. /* reg_ralue_ecmp_size
  6792. * Amount of sequential entries starting
  6793. * from the adjacency_index (the number of ECMPs).
  6794. * The valid range is 1-64, 512, 1024, 2048 and 4096.
  6795. * Reserved when trap_action is TRAP or DISCARD_ERROR.
  6796. * Only relevant in case of REMOTE action.
  6797. * Access: RW
  6798. */
  6799. MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
  6800. /* reg_ralue_local_erif
  6801. * Egress Router Interface.
  6802. * Only relevant in case of LOCAL action.
  6803. * Access: RW
  6804. */
  6805. MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
  6806. /* reg_ralue_ip2me_v
  6807. * Valid bit for the tunnel_ptr field.
  6808. * If valid = 0 then trap to CPU as IP2ME trap ID.
  6809. * If valid = 1 and the packet format allows NVE or IPinIP tunnel
  6810. * decapsulation then tunnel decapsulation is done.
  6811. * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
  6812. * decapsulation then trap as IP2ME trap ID.
  6813. * Only relevant in case of IP2ME action.
  6814. * Access: RW
  6815. */
  6816. MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
  6817. /* reg_ralue_ip2me_tunnel_ptr
  6818. * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
  6819. * For Spectrum, pointer to KVD Linear.
  6820. * Only relevant in case of IP2ME action.
  6821. * Access: RW
  6822. */
  6823. MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
  6824. static inline void mlxsw_reg_ralue_pack(char *payload,
  6825. enum mlxsw_reg_ralxx_protocol protocol,
  6826. enum mlxsw_reg_ralue_op op,
  6827. u16 virtual_router, u8 prefix_len)
  6828. {
  6829. MLXSW_REG_ZERO(ralue, payload);
  6830. mlxsw_reg_ralue_protocol_set(payload, protocol);
  6831. mlxsw_reg_ralue_op_set(payload, op);
  6832. mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
  6833. mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
  6834. mlxsw_reg_ralue_entry_type_set(payload,
  6835. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
  6836. mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
  6837. }
  6838. static inline void mlxsw_reg_ralue_pack4(char *payload,
  6839. enum mlxsw_reg_ralxx_protocol protocol,
  6840. enum mlxsw_reg_ralue_op op,
  6841. u16 virtual_router, u8 prefix_len,
  6842. u32 dip)
  6843. {
  6844. mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
  6845. mlxsw_reg_ralue_dip4_set(payload, dip);
  6846. }
  6847. static inline void mlxsw_reg_ralue_pack6(char *payload,
  6848. enum mlxsw_reg_ralxx_protocol protocol,
  6849. enum mlxsw_reg_ralue_op op,
  6850. u16 virtual_router, u8 prefix_len,
  6851. const void *dip)
  6852. {
  6853. mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
  6854. mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
  6855. }
  6856. static inline void
  6857. mlxsw_reg_ralue_act_remote_pack(char *payload,
  6858. enum mlxsw_reg_ralue_trap_action trap_action,
  6859. u16 trap_id, u32 adjacency_index, u16 ecmp_size)
  6860. {
  6861. mlxsw_reg_ralue_action_type_set(payload,
  6862. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
  6863. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  6864. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  6865. mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
  6866. mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
  6867. }
  6868. static inline void
  6869. mlxsw_reg_ralue_act_local_pack(char *payload,
  6870. enum mlxsw_reg_ralue_trap_action trap_action,
  6871. u16 trap_id, u16 local_erif)
  6872. {
  6873. mlxsw_reg_ralue_action_type_set(payload,
  6874. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
  6875. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  6876. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  6877. mlxsw_reg_ralue_local_erif_set(payload, local_erif);
  6878. }
  6879. static inline void
  6880. mlxsw_reg_ralue_act_ip2me_pack(char *payload)
  6881. {
  6882. mlxsw_reg_ralue_action_type_set(payload,
  6883. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
  6884. }
  6885. static inline void
  6886. mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
  6887. {
  6888. mlxsw_reg_ralue_action_type_set(payload,
  6889. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
  6890. mlxsw_reg_ralue_ip2me_v_set(payload, 1);
  6891. mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
  6892. }
  6893. /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
  6894. * ----------------------------------------------------------
  6895. * The RAUHT register is used to configure and query the Unicast Host table in
  6896. * devices that implement the Algorithmic LPM.
  6897. */
  6898. #define MLXSW_REG_RAUHT_ID 0x8014
  6899. #define MLXSW_REG_RAUHT_LEN 0x74
  6900. MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
  6901. enum mlxsw_reg_rauht_type {
  6902. MLXSW_REG_RAUHT_TYPE_IPV4,
  6903. MLXSW_REG_RAUHT_TYPE_IPV6,
  6904. };
  6905. /* reg_rauht_type
  6906. * Access: Index
  6907. */
  6908. MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
  6909. enum mlxsw_reg_rauht_op {
  6910. MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
  6911. /* Read operation */
  6912. MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
  6913. /* Clear on read operation. Used to read entry and clear
  6914. * activity bit.
  6915. */
  6916. MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
  6917. /* Add. Used to write a new entry to the table. All R/W fields are
  6918. * relevant for new entry. Activity bit is set for new entries.
  6919. */
  6920. MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
  6921. /* Update action. Used to update an existing route entry and
  6922. * only update the following fields:
  6923. * trap_action, trap_id, mac, counter_set_type, counter_index
  6924. */
  6925. MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
  6926. /* Clear activity. A bit is cleared for the entry. */
  6927. MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
  6928. /* Delete entry */
  6929. MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
  6930. /* Delete all host entries on a RIF. In this command, dip
  6931. * field is reserved.
  6932. */
  6933. };
  6934. /* reg_rauht_op
  6935. * Access: OP
  6936. */
  6937. MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
  6938. /* reg_rauht_a
  6939. * Activity. Set for new entries. Set if a packet lookup has hit on
  6940. * the specific entry.
  6941. * To clear the a bit, use "clear activity" op.
  6942. * Enabled by activity_dis in RGCR
  6943. * Access: RO
  6944. */
  6945. MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
  6946. /* reg_rauht_rif
  6947. * Router Interface
  6948. * Access: Index
  6949. */
  6950. MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
  6951. /* reg_rauht_dip*
  6952. * Destination address.
  6953. * Access: Index
  6954. */
  6955. MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
  6956. MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
  6957. enum mlxsw_reg_rauht_trap_action {
  6958. MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
  6959. MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
  6960. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
  6961. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
  6962. MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
  6963. };
  6964. /* reg_rauht_trap_action
  6965. * Access: RW
  6966. */
  6967. MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
  6968. enum mlxsw_reg_rauht_trap_id {
  6969. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
  6970. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
  6971. };
  6972. /* reg_rauht_trap_id
  6973. * Trap ID to be reported to CPU.
  6974. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  6975. * For trap_action of NOP, MIRROR and DISCARD_ERROR,
  6976. * trap_id is reserved.
  6977. * Access: RW
  6978. */
  6979. MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
  6980. /* reg_rauht_counter_set_type
  6981. * Counter set type for flow counters
  6982. * Access: RW
  6983. */
  6984. MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
  6985. /* reg_rauht_counter_index
  6986. * Counter index for flow counters
  6987. * Access: RW
  6988. */
  6989. MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
  6990. /* reg_rauht_mac
  6991. * MAC address.
  6992. * Access: RW
  6993. */
  6994. MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
  6995. static inline void mlxsw_reg_rauht_pack(char *payload,
  6996. enum mlxsw_reg_rauht_op op, u16 rif,
  6997. const char *mac)
  6998. {
  6999. MLXSW_REG_ZERO(rauht, payload);
  7000. mlxsw_reg_rauht_op_set(payload, op);
  7001. mlxsw_reg_rauht_rif_set(payload, rif);
  7002. mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
  7003. }
  7004. static inline void mlxsw_reg_rauht_pack4(char *payload,
  7005. enum mlxsw_reg_rauht_op op, u16 rif,
  7006. const char *mac, u32 dip)
  7007. {
  7008. mlxsw_reg_rauht_pack(payload, op, rif, mac);
  7009. mlxsw_reg_rauht_dip4_set(payload, dip);
  7010. }
  7011. static inline void mlxsw_reg_rauht_pack6(char *payload,
  7012. enum mlxsw_reg_rauht_op op, u16 rif,
  7013. const char *mac, const char *dip)
  7014. {
  7015. mlxsw_reg_rauht_pack(payload, op, rif, mac);
  7016. mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
  7017. mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
  7018. }
  7019. static inline void mlxsw_reg_rauht_pack_counter(char *payload,
  7020. u64 counter_index)
  7021. {
  7022. mlxsw_reg_rauht_counter_index_set(payload, counter_index);
  7023. mlxsw_reg_rauht_counter_set_type_set(payload,
  7024. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
  7025. }
  7026. /* RALEU - Router Algorithmic LPM ECMP Update Register
  7027. * ---------------------------------------------------
  7028. * The register enables updating the ECMP section in the action for multiple
  7029. * LPM Unicast entries in a single operation. The update is executed to
  7030. * all entries of a {virtual router, protocol} tuple using the same ECMP group.
  7031. */
  7032. #define MLXSW_REG_RALEU_ID 0x8015
  7033. #define MLXSW_REG_RALEU_LEN 0x28
  7034. MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
  7035. /* reg_raleu_protocol
  7036. * Protocol.
  7037. * Access: Index
  7038. */
  7039. MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
  7040. /* reg_raleu_virtual_router
  7041. * Virtual Router ID
  7042. * Range is 0..cap_max_virtual_routers-1
  7043. * Access: Index
  7044. */
  7045. MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
  7046. /* reg_raleu_adjacency_index
  7047. * Adjacency Index used for matching on the existing entries.
  7048. * Access: Index
  7049. */
  7050. MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
  7051. /* reg_raleu_ecmp_size
  7052. * ECMP Size used for matching on the existing entries.
  7053. * Access: Index
  7054. */
  7055. MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
  7056. /* reg_raleu_new_adjacency_index
  7057. * New Adjacency Index.
  7058. * Access: WO
  7059. */
  7060. MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
  7061. /* reg_raleu_new_ecmp_size
  7062. * New ECMP Size.
  7063. * Access: WO
  7064. */
  7065. MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
  7066. static inline void mlxsw_reg_raleu_pack(char *payload,
  7067. enum mlxsw_reg_ralxx_protocol protocol,
  7068. u16 virtual_router,
  7069. u32 adjacency_index, u16 ecmp_size,
  7070. u32 new_adjacency_index,
  7071. u16 new_ecmp_size)
  7072. {
  7073. MLXSW_REG_ZERO(raleu, payload);
  7074. mlxsw_reg_raleu_protocol_set(payload, protocol);
  7075. mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
  7076. mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
  7077. mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
  7078. mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
  7079. mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
  7080. }
  7081. /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
  7082. * ----------------------------------------------------------------
  7083. * The RAUHTD register allows dumping entries from the Router Unicast Host
  7084. * Table. For a given session an entry is dumped no more than one time. The
  7085. * first RAUHTD access after reset is a new session. A session ends when the
  7086. * num_rec response is smaller than num_rec request or for IPv4 when the
  7087. * num_entries is smaller than 4. The clear activity affect the current session
  7088. * or the last session if a new session has not started.
  7089. */
  7090. #define MLXSW_REG_RAUHTD_ID 0x8018
  7091. #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
  7092. #define MLXSW_REG_RAUHTD_REC_LEN 0x20
  7093. #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
  7094. #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
  7095. MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
  7096. #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
  7097. MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
  7098. #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
  7099. #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
  7100. /* reg_rauhtd_filter_fields
  7101. * if a bit is '0' then the relevant field is ignored and dump is done
  7102. * regardless of the field value
  7103. * Bit0 - filter by activity: entry_a
  7104. * Bit3 - filter by entry rip: entry_rif
  7105. * Access: Index
  7106. */
  7107. MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
  7108. enum mlxsw_reg_rauhtd_op {
  7109. MLXSW_REG_RAUHTD_OP_DUMP,
  7110. MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
  7111. };
  7112. /* reg_rauhtd_op
  7113. * Access: OP
  7114. */
  7115. MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
  7116. /* reg_rauhtd_num_rec
  7117. * At request: number of records requested
  7118. * At response: number of records dumped
  7119. * For IPv4, each record has 4 entries at request and up to 4 entries
  7120. * at response
  7121. * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
  7122. * Access: Index
  7123. */
  7124. MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
  7125. /* reg_rauhtd_entry_a
  7126. * Dump only if activity has value of entry_a
  7127. * Reserved if filter_fields bit0 is '0'
  7128. * Access: Index
  7129. */
  7130. MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
  7131. enum mlxsw_reg_rauhtd_type {
  7132. MLXSW_REG_RAUHTD_TYPE_IPV4,
  7133. MLXSW_REG_RAUHTD_TYPE_IPV6,
  7134. };
  7135. /* reg_rauhtd_type
  7136. * Dump only if record type is:
  7137. * 0 - IPv4
  7138. * 1 - IPv6
  7139. * Access: Index
  7140. */
  7141. MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
  7142. /* reg_rauhtd_entry_rif
  7143. * Dump only if RIF has value of entry_rif
  7144. * Reserved if filter_fields bit3 is '0'
  7145. * Access: Index
  7146. */
  7147. MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
  7148. static inline void mlxsw_reg_rauhtd_pack(char *payload,
  7149. enum mlxsw_reg_rauhtd_type type)
  7150. {
  7151. MLXSW_REG_ZERO(rauhtd, payload);
  7152. mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
  7153. mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
  7154. mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
  7155. mlxsw_reg_rauhtd_entry_a_set(payload, 1);
  7156. mlxsw_reg_rauhtd_type_set(payload, type);
  7157. }
  7158. /* reg_rauhtd_ipv4_rec_num_entries
  7159. * Number of valid entries in this record:
  7160. * 0 - 1 valid entry
  7161. * 1 - 2 valid entries
  7162. * 2 - 3 valid entries
  7163. * 3 - 4 valid entries
  7164. * Access: RO
  7165. */
  7166. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
  7167. MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
  7168. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  7169. /* reg_rauhtd_rec_type
  7170. * Record type.
  7171. * 0 - IPv4
  7172. * 1 - IPv6
  7173. * Access: RO
  7174. */
  7175. MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
  7176. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  7177. #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
  7178. /* reg_rauhtd_ipv4_ent_a
  7179. * Activity. Set for new entries. Set if a packet lookup has hit on the
  7180. * specific entry.
  7181. * Access: RO
  7182. */
  7183. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
  7184. MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  7185. /* reg_rauhtd_ipv4_ent_rif
  7186. * Router interface.
  7187. * Access: RO
  7188. */
  7189. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  7190. 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  7191. /* reg_rauhtd_ipv4_ent_dip
  7192. * Destination IPv4 address.
  7193. * Access: RO
  7194. */
  7195. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  7196. 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
  7197. #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
  7198. /* reg_rauhtd_ipv6_ent_a
  7199. * Activity. Set for new entries. Set if a packet lookup has hit on the
  7200. * specific entry.
  7201. * Access: RO
  7202. */
  7203. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
  7204. MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
  7205. /* reg_rauhtd_ipv6_ent_rif
  7206. * Router interface.
  7207. * Access: RO
  7208. */
  7209. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  7210. 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
  7211. /* reg_rauhtd_ipv6_ent_dip
  7212. * Destination IPv6 address.
  7213. * Access: RO
  7214. */
  7215. MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
  7216. 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
  7217. static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
  7218. int ent_index, u16 *p_rif,
  7219. u32 *p_dip)
  7220. {
  7221. *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
  7222. *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
  7223. }
  7224. static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
  7225. int rec_index, u16 *p_rif,
  7226. char *p_dip)
  7227. {
  7228. *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
  7229. mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
  7230. }
  7231. /* RTDP - Routing Tunnel Decap Properties Register
  7232. * -----------------------------------------------
  7233. * The RTDP register is used for configuring the tunnel decap properties of NVE
  7234. * and IPinIP.
  7235. */
  7236. #define MLXSW_REG_RTDP_ID 0x8020
  7237. #define MLXSW_REG_RTDP_LEN 0x44
  7238. MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
  7239. enum mlxsw_reg_rtdp_type {
  7240. MLXSW_REG_RTDP_TYPE_NVE,
  7241. MLXSW_REG_RTDP_TYPE_IPIP,
  7242. };
  7243. /* reg_rtdp_type
  7244. * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
  7245. * Access: RW
  7246. */
  7247. MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
  7248. /* reg_rtdp_tunnel_index
  7249. * Index to the Decap entry.
  7250. * For Spectrum, Index to KVD Linear.
  7251. * Access: Index
  7252. */
  7253. MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
  7254. /* reg_rtdp_egress_router_interface
  7255. * Underlay egress router interface.
  7256. * Valid range is from 0 to cap_max_router_interfaces - 1
  7257. * Access: RW
  7258. */
  7259. MLXSW_ITEM32(reg, rtdp, egress_router_interface, 0x40, 0, 16);
  7260. /* IPinIP */
  7261. /* reg_rtdp_ipip_irif
  7262. * Ingress Router Interface for the overlay router
  7263. * Access: RW
  7264. */
  7265. MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
  7266. enum mlxsw_reg_rtdp_ipip_sip_check {
  7267. /* No sip checks. */
  7268. MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
  7269. /* Filter packet if underlay is not IPv4 or if underlay SIP does not
  7270. * equal ipv4_usip.
  7271. */
  7272. MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
  7273. /* Filter packet if underlay is not IPv6 or if underlay SIP does not
  7274. * equal ipv6_usip.
  7275. */
  7276. MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
  7277. };
  7278. /* reg_rtdp_ipip_sip_check
  7279. * SIP check to perform. If decapsulation failed due to these configurations
  7280. * then trap_id is IPIP_DECAP_ERROR.
  7281. * Access: RW
  7282. */
  7283. MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
  7284. /* If set, allow decapsulation of IPinIP (without GRE). */
  7285. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
  7286. /* If set, allow decapsulation of IPinGREinIP without a key. */
  7287. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
  7288. /* If set, allow decapsulation of IPinGREinIP with a key. */
  7289. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
  7290. /* reg_rtdp_ipip_type_check
  7291. * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
  7292. * these configurations then trap_id is IPIP_DECAP_ERROR.
  7293. * Access: RW
  7294. */
  7295. MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
  7296. /* reg_rtdp_ipip_gre_key_check
  7297. * Whether GRE key should be checked. When check is enabled:
  7298. * - A packet received as IPinIP (without GRE) will always pass.
  7299. * - A packet received as IPinGREinIP without a key will not pass the check.
  7300. * - A packet received as IPinGREinIP with a key will pass the check only if the
  7301. * key in the packet is equal to expected_gre_key.
  7302. * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
  7303. * Access: RW
  7304. */
  7305. MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
  7306. /* reg_rtdp_ipip_ipv4_usip
  7307. * Underlay IPv4 address for ipv4 source address check.
  7308. * Reserved when sip_check is not '1'.
  7309. * Access: RW
  7310. */
  7311. MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
  7312. /* reg_rtdp_ipip_ipv6_usip_ptr
  7313. * This field is valid when sip_check is "sipv6 check explicitly". This is a
  7314. * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
  7315. * is to the KVD linear.
  7316. * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
  7317. * Access: RW
  7318. */
  7319. MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
  7320. /* reg_rtdp_ipip_expected_gre_key
  7321. * GRE key for checking.
  7322. * Reserved when gre_key_check is '0'.
  7323. * Access: RW
  7324. */
  7325. MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
  7326. static inline void mlxsw_reg_rtdp_pack(char *payload,
  7327. enum mlxsw_reg_rtdp_type type,
  7328. u32 tunnel_index)
  7329. {
  7330. MLXSW_REG_ZERO(rtdp, payload);
  7331. mlxsw_reg_rtdp_type_set(payload, type);
  7332. mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
  7333. }
  7334. static inline void
  7335. mlxsw_reg_rtdp_ipip_pack(char *payload, u16 irif,
  7336. enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
  7337. unsigned int type_check, bool gre_key_check,
  7338. u32 expected_gre_key)
  7339. {
  7340. mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
  7341. mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
  7342. mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
  7343. mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
  7344. mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
  7345. }
  7346. static inline void
  7347. mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
  7348. enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
  7349. unsigned int type_check, bool gre_key_check,
  7350. u32 ipv4_usip, u32 expected_gre_key)
  7351. {
  7352. mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
  7353. gre_key_check, expected_gre_key);
  7354. mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
  7355. }
  7356. static inline void
  7357. mlxsw_reg_rtdp_ipip6_pack(char *payload, u16 irif,
  7358. enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
  7359. unsigned int type_check, bool gre_key_check,
  7360. u32 ipv6_usip_ptr, u32 expected_gre_key)
  7361. {
  7362. mlxsw_reg_rtdp_ipip_pack(payload, irif, sip_check, type_check,
  7363. gre_key_check, expected_gre_key);
  7364. mlxsw_reg_rtdp_ipip_ipv6_usip_ptr_set(payload, ipv6_usip_ptr);
  7365. }
  7366. /* RIPS - Router IP version Six Register
  7367. * -------------------------------------
  7368. * The RIPS register is used to store IPv6 addresses for use by the NVE and
  7369. * IPinIP
  7370. */
  7371. #define MLXSW_REG_RIPS_ID 0x8021
  7372. #define MLXSW_REG_RIPS_LEN 0x14
  7373. MLXSW_REG_DEFINE(rips, MLXSW_REG_RIPS_ID, MLXSW_REG_RIPS_LEN);
  7374. /* reg_rips_index
  7375. * Index to IPv6 address.
  7376. * For Spectrum, the index is to the KVD linear.
  7377. * Access: Index
  7378. */
  7379. MLXSW_ITEM32(reg, rips, index, 0x00, 0, 24);
  7380. /* reg_rips_ipv6
  7381. * IPv6 address
  7382. * Access: RW
  7383. */
  7384. MLXSW_ITEM_BUF(reg, rips, ipv6, 0x04, 16);
  7385. static inline void mlxsw_reg_rips_pack(char *payload, u32 index,
  7386. const struct in6_addr *ipv6)
  7387. {
  7388. MLXSW_REG_ZERO(rips, payload);
  7389. mlxsw_reg_rips_index_set(payload, index);
  7390. mlxsw_reg_rips_ipv6_memcpy_to(payload, (const char *)ipv6);
  7391. }
  7392. /* RATRAD - Router Adjacency Table Activity Dump Register
  7393. * ------------------------------------------------------
  7394. * The RATRAD register is used to dump and optionally clear activity bits of
  7395. * router adjacency table entries.
  7396. */
  7397. #define MLXSW_REG_RATRAD_ID 0x8022
  7398. #define MLXSW_REG_RATRAD_LEN 0x210
  7399. MLXSW_REG_DEFINE(ratrad, MLXSW_REG_RATRAD_ID, MLXSW_REG_RATRAD_LEN);
  7400. enum {
  7401. /* Read activity */
  7402. MLXSW_REG_RATRAD_OP_READ_ACTIVITY,
  7403. /* Read and clear activity */
  7404. MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY,
  7405. };
  7406. /* reg_ratrad_op
  7407. * Access: Operation
  7408. */
  7409. MLXSW_ITEM32(reg, ratrad, op, 0x00, 30, 2);
  7410. /* reg_ratrad_ecmp_size
  7411. * ecmp_size is the amount of sequential entries from adjacency_index. Valid
  7412. * ranges:
  7413. * Spectrum-1: 32-64, 512, 1024, 2048, 4096
  7414. * Spectrum-2/3: 32-128, 256, 512, 1024, 2048, 4096
  7415. * Access: Index
  7416. */
  7417. MLXSW_ITEM32(reg, ratrad, ecmp_size, 0x00, 0, 13);
  7418. /* reg_ratrad_adjacency_index
  7419. * Index into the adjacency table.
  7420. * Access: Index
  7421. */
  7422. MLXSW_ITEM32(reg, ratrad, adjacency_index, 0x04, 0, 24);
  7423. /* reg_ratrad_activity_vector
  7424. * Activity bit per adjacency index.
  7425. * Bits higher than ecmp_size are reserved.
  7426. * Access: RO
  7427. */
  7428. MLXSW_ITEM_BIT_ARRAY(reg, ratrad, activity_vector, 0x10, 0x200, 1);
  7429. static inline void mlxsw_reg_ratrad_pack(char *payload, u32 adjacency_index,
  7430. u16 ecmp_size)
  7431. {
  7432. MLXSW_REG_ZERO(ratrad, payload);
  7433. mlxsw_reg_ratrad_op_set(payload,
  7434. MLXSW_REG_RATRAD_OP_READ_CLEAR_ACTIVITY);
  7435. mlxsw_reg_ratrad_ecmp_size_set(payload, ecmp_size);
  7436. mlxsw_reg_ratrad_adjacency_index_set(payload, adjacency_index);
  7437. }
  7438. /* RIGR-V2 - Router Interface Group Register Version 2
  7439. * ---------------------------------------------------
  7440. * The RIGR_V2 register is used to add, remove and query egress interface list
  7441. * of a multicast forwarding entry.
  7442. */
  7443. #define MLXSW_REG_RIGR2_ID 0x8023
  7444. #define MLXSW_REG_RIGR2_LEN 0xB0
  7445. #define MLXSW_REG_RIGR2_MAX_ERIFS 32
  7446. MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
  7447. /* reg_rigr2_rigr_index
  7448. * KVD Linear index.
  7449. * Access: Index
  7450. */
  7451. MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
  7452. /* reg_rigr2_vnext
  7453. * Next RIGR Index is valid.
  7454. * Access: RW
  7455. */
  7456. MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
  7457. /* reg_rigr2_next_rigr_index
  7458. * Next RIGR Index. The index is to the KVD linear.
  7459. * Reserved when vnxet = '0'.
  7460. * Access: RW
  7461. */
  7462. MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
  7463. /* reg_rigr2_vrmid
  7464. * RMID Index is valid.
  7465. * Access: RW
  7466. */
  7467. MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
  7468. /* reg_rigr2_rmid_index
  7469. * RMID Index.
  7470. * Range 0 .. max_mid - 1
  7471. * Reserved when vrmid = '0'.
  7472. * The index is to the Port Group Table (PGT)
  7473. * Access: RW
  7474. */
  7475. MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
  7476. /* reg_rigr2_erif_entry_v
  7477. * Egress Router Interface is valid.
  7478. * Note that low-entries must be set if high-entries are set. For
  7479. * example: if erif_entry[2].v is set then erif_entry[1].v and
  7480. * erif_entry[0].v must be set.
  7481. * Index can be from 0 to cap_mc_erif_list_entries-1
  7482. * Access: RW
  7483. */
  7484. MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
  7485. /* reg_rigr2_erif_entry_erif
  7486. * Egress Router Interface.
  7487. * Valid range is from 0 to cap_max_router_interfaces - 1
  7488. * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
  7489. * Access: RW
  7490. */
  7491. MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
  7492. static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
  7493. bool vnext, u32 next_rigr_index)
  7494. {
  7495. MLXSW_REG_ZERO(rigr2, payload);
  7496. mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
  7497. mlxsw_reg_rigr2_vnext_set(payload, vnext);
  7498. mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
  7499. mlxsw_reg_rigr2_vrmid_set(payload, 0);
  7500. mlxsw_reg_rigr2_rmid_index_set(payload, 0);
  7501. }
  7502. static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
  7503. bool v, u16 erif)
  7504. {
  7505. mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
  7506. mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
  7507. }
  7508. /* RECR-V2 - Router ECMP Configuration Version 2 Register
  7509. * ------------------------------------------------------
  7510. */
  7511. #define MLXSW_REG_RECR2_ID 0x8025
  7512. #define MLXSW_REG_RECR2_LEN 0x38
  7513. MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
  7514. /* reg_recr2_pp
  7515. * Per-port configuration
  7516. * Access: Index
  7517. */
  7518. MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
  7519. /* reg_recr2_sh
  7520. * Symmetric hash
  7521. * Access: RW
  7522. */
  7523. MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
  7524. /* reg_recr2_seed
  7525. * Seed
  7526. * Access: RW
  7527. */
  7528. MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
  7529. enum {
  7530. /* Enable IPv4 fields if packet is not TCP and not UDP */
  7531. MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
  7532. /* Enable IPv4 fields if packet is TCP or UDP */
  7533. MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
  7534. /* Enable IPv6 fields if packet is not TCP and not UDP */
  7535. MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
  7536. /* Enable IPv6 fields if packet is TCP or UDP */
  7537. MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
  7538. /* Enable TCP/UDP header fields if packet is IPv4 */
  7539. MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
  7540. /* Enable TCP/UDP header fields if packet is IPv6 */
  7541. MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
  7542. __MLXSW_REG_RECR2_HEADER_CNT,
  7543. };
  7544. /* reg_recr2_outer_header_enables
  7545. * Bit mask where each bit enables a specific layer to be included in
  7546. * the hash calculation.
  7547. * Access: RW
  7548. */
  7549. MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
  7550. enum {
  7551. /* IPv4 Source IP */
  7552. MLXSW_REG_RECR2_IPV4_SIP0 = 9,
  7553. MLXSW_REG_RECR2_IPV4_SIP3 = 12,
  7554. /* IPv4 Destination IP */
  7555. MLXSW_REG_RECR2_IPV4_DIP0 = 13,
  7556. MLXSW_REG_RECR2_IPV4_DIP3 = 16,
  7557. /* IP Protocol */
  7558. MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
  7559. /* IPv6 Source IP */
  7560. MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
  7561. MLXSW_REG_RECR2_IPV6_SIP8 = 29,
  7562. MLXSW_REG_RECR2_IPV6_SIP15 = 36,
  7563. /* IPv6 Destination IP */
  7564. MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
  7565. MLXSW_REG_RECR2_IPV6_DIP8 = 45,
  7566. MLXSW_REG_RECR2_IPV6_DIP15 = 52,
  7567. /* IPv6 Next Header */
  7568. MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
  7569. /* IPv6 Flow Label */
  7570. MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
  7571. /* TCP/UDP Source Port */
  7572. MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
  7573. /* TCP/UDP Destination Port */
  7574. MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
  7575. __MLXSW_REG_RECR2_FIELD_CNT,
  7576. };
  7577. /* reg_recr2_outer_header_fields_enable
  7578. * Packet fields to enable for ECMP hash subject to outer_header_enable.
  7579. * Access: RW
  7580. */
  7581. MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
  7582. /* reg_recr2_inner_header_enables
  7583. * Bit mask where each bit enables a specific inner layer to be included in the
  7584. * hash calculation. Same values as reg_recr2_outer_header_enables.
  7585. * Access: RW
  7586. */
  7587. MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_enables, 0x2C, 0x04, 1);
  7588. enum {
  7589. /* Inner IPv4 Source IP */
  7590. MLXSW_REG_RECR2_INNER_IPV4_SIP0 = 3,
  7591. MLXSW_REG_RECR2_INNER_IPV4_SIP3 = 6,
  7592. /* Inner IPv4 Destination IP */
  7593. MLXSW_REG_RECR2_INNER_IPV4_DIP0 = 7,
  7594. MLXSW_REG_RECR2_INNER_IPV4_DIP3 = 10,
  7595. /* Inner IP Protocol */
  7596. MLXSW_REG_RECR2_INNER_IPV4_PROTOCOL = 11,
  7597. /* Inner IPv6 Source IP */
  7598. MLXSW_REG_RECR2_INNER_IPV6_SIP0_7 = 12,
  7599. MLXSW_REG_RECR2_INNER_IPV6_SIP8 = 20,
  7600. MLXSW_REG_RECR2_INNER_IPV6_SIP15 = 27,
  7601. /* Inner IPv6 Destination IP */
  7602. MLXSW_REG_RECR2_INNER_IPV6_DIP0_7 = 28,
  7603. MLXSW_REG_RECR2_INNER_IPV6_DIP8 = 36,
  7604. MLXSW_REG_RECR2_INNER_IPV6_DIP15 = 43,
  7605. /* Inner IPv6 Next Header */
  7606. MLXSW_REG_RECR2_INNER_IPV6_NEXT_HEADER = 44,
  7607. /* Inner IPv6 Flow Label */
  7608. MLXSW_REG_RECR2_INNER_IPV6_FLOW_LABEL = 45,
  7609. /* Inner TCP/UDP Source Port */
  7610. MLXSW_REG_RECR2_INNER_TCP_UDP_SPORT = 46,
  7611. /* Inner TCP/UDP Destination Port */
  7612. MLXSW_REG_RECR2_INNER_TCP_UDP_DPORT = 47,
  7613. __MLXSW_REG_RECR2_INNER_FIELD_CNT,
  7614. };
  7615. /* reg_recr2_inner_header_fields_enable
  7616. * Inner packet fields to enable for ECMP hash subject to inner_header_enables.
  7617. * Access: RW
  7618. */
  7619. MLXSW_ITEM_BIT_ARRAY(reg, recr2, inner_header_fields_enable, 0x30, 0x08, 1);
  7620. static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
  7621. {
  7622. MLXSW_REG_ZERO(recr2, payload);
  7623. mlxsw_reg_recr2_pp_set(payload, false);
  7624. mlxsw_reg_recr2_sh_set(payload, true);
  7625. mlxsw_reg_recr2_seed_set(payload, seed);
  7626. }
  7627. /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
  7628. * --------------------------------------------------------------
  7629. * The RMFT_V2 register is used to configure and query the multicast table.
  7630. */
  7631. #define MLXSW_REG_RMFT2_ID 0x8027
  7632. #define MLXSW_REG_RMFT2_LEN 0x174
  7633. MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
  7634. /* reg_rmft2_v
  7635. * Valid
  7636. * Access: RW
  7637. */
  7638. MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
  7639. enum mlxsw_reg_rmft2_type {
  7640. MLXSW_REG_RMFT2_TYPE_IPV4,
  7641. MLXSW_REG_RMFT2_TYPE_IPV6
  7642. };
  7643. /* reg_rmft2_type
  7644. * Access: Index
  7645. */
  7646. MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
  7647. enum mlxsw_sp_reg_rmft2_op {
  7648. /* For Write:
  7649. * Write operation. Used to write a new entry to the table. All RW
  7650. * fields are relevant for new entry. Activity bit is set for new
  7651. * entries - Note write with v (Valid) 0 will delete the entry.
  7652. * For Query:
  7653. * Read operation
  7654. */
  7655. MLXSW_REG_RMFT2_OP_READ_WRITE,
  7656. };
  7657. /* reg_rmft2_op
  7658. * Operation.
  7659. * Access: OP
  7660. */
  7661. MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
  7662. /* reg_rmft2_a
  7663. * Activity. Set for new entries. Set if a packet lookup has hit on the specific
  7664. * entry.
  7665. * Access: RO
  7666. */
  7667. MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
  7668. /* reg_rmft2_offset
  7669. * Offset within the multicast forwarding table to write to.
  7670. * Access: Index
  7671. */
  7672. MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
  7673. /* reg_rmft2_virtual_router
  7674. * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
  7675. * Access: RW
  7676. */
  7677. MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
  7678. enum mlxsw_reg_rmft2_irif_mask {
  7679. MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
  7680. MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
  7681. };
  7682. /* reg_rmft2_irif_mask
  7683. * Ingress RIF mask.
  7684. * Access: RW
  7685. */
  7686. MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
  7687. /* reg_rmft2_irif
  7688. * Ingress RIF index.
  7689. * Access: RW
  7690. */
  7691. MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
  7692. /* reg_rmft2_dip{4,6}
  7693. * Destination IPv4/6 address
  7694. * Access: RW
  7695. */
  7696. MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
  7697. MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
  7698. /* reg_rmft2_dip{4,6}_mask
  7699. * A bit that is set directs the TCAM to compare the corresponding bit in key. A
  7700. * bit that is clear directs the TCAM to ignore the corresponding bit in key.
  7701. * Access: RW
  7702. */
  7703. MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
  7704. MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
  7705. /* reg_rmft2_sip{4,6}
  7706. * Source IPv4/6 address
  7707. * Access: RW
  7708. */
  7709. MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
  7710. MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
  7711. /* reg_rmft2_sip{4,6}_mask
  7712. * A bit that is set directs the TCAM to compare the corresponding bit in key. A
  7713. * bit that is clear directs the TCAM to ignore the corresponding bit in key.
  7714. * Access: RW
  7715. */
  7716. MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
  7717. MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
  7718. /* reg_rmft2_flexible_action_set
  7719. * ACL action set. The only supported action types in this field and in any
  7720. * action-set pointed from here are as follows:
  7721. * 00h: ACTION_NULL
  7722. * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
  7723. * 03h: ACTION_TRAP
  7724. * 06h: ACTION_QOS
  7725. * 08h: ACTION_POLICING_MONITORING
  7726. * 10h: ACTION_ROUTER_MC
  7727. * Access: RW
  7728. */
  7729. MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
  7730. MLXSW_REG_FLEX_ACTION_SET_LEN);
  7731. static inline void
  7732. mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
  7733. u16 virtual_router,
  7734. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  7735. const char *flex_action_set)
  7736. {
  7737. MLXSW_REG_ZERO(rmft2, payload);
  7738. mlxsw_reg_rmft2_v_set(payload, v);
  7739. mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
  7740. mlxsw_reg_rmft2_offset_set(payload, offset);
  7741. mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
  7742. mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
  7743. mlxsw_reg_rmft2_irif_set(payload, irif);
  7744. if (flex_action_set)
  7745. mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
  7746. flex_action_set);
  7747. }
  7748. static inline void
  7749. mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
  7750. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  7751. u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
  7752. const char *flexible_action_set)
  7753. {
  7754. mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
  7755. irif_mask, irif, flexible_action_set);
  7756. mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
  7757. mlxsw_reg_rmft2_dip4_set(payload, dip4);
  7758. mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
  7759. mlxsw_reg_rmft2_sip4_set(payload, sip4);
  7760. mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
  7761. }
  7762. static inline void
  7763. mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
  7764. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  7765. struct in6_addr dip6, struct in6_addr dip6_mask,
  7766. struct in6_addr sip6, struct in6_addr sip6_mask,
  7767. const char *flexible_action_set)
  7768. {
  7769. mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
  7770. irif_mask, irif, flexible_action_set);
  7771. mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
  7772. mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
  7773. mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
  7774. mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
  7775. mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
  7776. }
  7777. /* REIV - Router Egress Interface to VID Register
  7778. * ----------------------------------------------
  7779. * The REIV register maps {eRIF, egress_port} -> VID.
  7780. * This mapping is done at the egress, after the ACLs.
  7781. * This mapping always takes effect after router, regardless of cast
  7782. * (for unicast/multicast/port-base multicast), regardless of eRIF type and
  7783. * regardless of bridge decisions (e.g. SFD for unicast or SMPE).
  7784. * Reserved when the RIF is a loopback RIF.
  7785. *
  7786. * Note: Reserved when legacy bridge model is used.
  7787. */
  7788. #define MLXSW_REG_REIV_ID 0x8034
  7789. #define MLXSW_REG_REIV_BASE_LEN 0x20 /* base length, without records */
  7790. #define MLXSW_REG_REIV_REC_LEN 0x04 /* record length */
  7791. #define MLXSW_REG_REIV_REC_MAX_COUNT 256 /* firmware limitation */
  7792. #define MLXSW_REG_REIV_LEN (MLXSW_REG_REIV_BASE_LEN + \
  7793. MLXSW_REG_REIV_REC_LEN * \
  7794. MLXSW_REG_REIV_REC_MAX_COUNT)
  7795. MLXSW_REG_DEFINE(reiv, MLXSW_REG_REIV_ID, MLXSW_REG_REIV_LEN);
  7796. /* reg_reiv_port_page
  7797. * Port page - elport_record[0] is 256*port_page.
  7798. * Access: Index
  7799. */
  7800. MLXSW_ITEM32(reg, reiv, port_page, 0x00, 0, 4);
  7801. /* reg_reiv_erif
  7802. * Egress RIF.
  7803. * Range is 0..cap_max_router_interfaces-1.
  7804. * Access: Index
  7805. */
  7806. MLXSW_ITEM32(reg, reiv, erif, 0x04, 0, 16);
  7807. /* reg_reiv_rec_update
  7808. * Update enable (when write):
  7809. * 0 - Do not update the entry.
  7810. * 1 - Update the entry.
  7811. * Access: OP
  7812. */
  7813. MLXSW_ITEM32_INDEXED(reg, reiv, rec_update, MLXSW_REG_REIV_BASE_LEN, 31, 1,
  7814. MLXSW_REG_REIV_REC_LEN, 0x00, false);
  7815. /* reg_reiv_rec_evid
  7816. * Egress VID.
  7817. * Range is 0..4095.
  7818. * Access: RW
  7819. */
  7820. MLXSW_ITEM32_INDEXED(reg, reiv, rec_evid, MLXSW_REG_REIV_BASE_LEN, 0, 12,
  7821. MLXSW_REG_REIV_REC_LEN, 0x00, false);
  7822. static inline void mlxsw_reg_reiv_pack(char *payload, u8 port_page, u16 erif)
  7823. {
  7824. MLXSW_REG_ZERO(reiv, payload);
  7825. mlxsw_reg_reiv_port_page_set(payload, port_page);
  7826. mlxsw_reg_reiv_erif_set(payload, erif);
  7827. }
  7828. /* MFCR - Management Fan Control Register
  7829. * --------------------------------------
  7830. * This register controls the settings of the Fan Speed PWM mechanism.
  7831. */
  7832. #define MLXSW_REG_MFCR_ID 0x9001
  7833. #define MLXSW_REG_MFCR_LEN 0x08
  7834. MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
  7835. enum mlxsw_reg_mfcr_pwm_frequency {
  7836. MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
  7837. MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
  7838. MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
  7839. MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
  7840. MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
  7841. MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
  7842. MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
  7843. MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
  7844. };
  7845. /* reg_mfcr_pwm_frequency
  7846. * Controls the frequency of the PWM signal.
  7847. * Access: RW
  7848. */
  7849. MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
  7850. #define MLXSW_MFCR_TACHOS_MAX 10
  7851. /* reg_mfcr_tacho_active
  7852. * Indicates which of the tachometer is active (bit per tachometer).
  7853. * Access: RO
  7854. */
  7855. MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
  7856. #define MLXSW_MFCR_PWMS_MAX 5
  7857. /* reg_mfcr_pwm_active
  7858. * Indicates which of the PWM control is active (bit per PWM).
  7859. * Access: RO
  7860. */
  7861. MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
  7862. static inline void
  7863. mlxsw_reg_mfcr_pack(char *payload,
  7864. enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
  7865. {
  7866. MLXSW_REG_ZERO(mfcr, payload);
  7867. mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
  7868. }
  7869. static inline void
  7870. mlxsw_reg_mfcr_unpack(char *payload,
  7871. enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
  7872. u16 *p_tacho_active, u8 *p_pwm_active)
  7873. {
  7874. *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
  7875. *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
  7876. *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
  7877. }
  7878. /* MFSC - Management Fan Speed Control Register
  7879. * --------------------------------------------
  7880. * This register controls the settings of the Fan Speed PWM mechanism.
  7881. */
  7882. #define MLXSW_REG_MFSC_ID 0x9002
  7883. #define MLXSW_REG_MFSC_LEN 0x08
  7884. MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
  7885. /* reg_mfsc_pwm
  7886. * Fan pwm to control / monitor.
  7887. * Access: Index
  7888. */
  7889. MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
  7890. /* reg_mfsc_pwm_duty_cycle
  7891. * Controls the duty cycle of the PWM. Value range from 0..255 to
  7892. * represent duty cycle of 0%...100%.
  7893. * Access: RW
  7894. */
  7895. MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
  7896. static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
  7897. u8 pwm_duty_cycle)
  7898. {
  7899. MLXSW_REG_ZERO(mfsc, payload);
  7900. mlxsw_reg_mfsc_pwm_set(payload, pwm);
  7901. mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
  7902. }
  7903. /* MFSM - Management Fan Speed Measurement
  7904. * ---------------------------------------
  7905. * This register controls the settings of the Tacho measurements and
  7906. * enables reading the Tachometer measurements.
  7907. */
  7908. #define MLXSW_REG_MFSM_ID 0x9003
  7909. #define MLXSW_REG_MFSM_LEN 0x08
  7910. MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
  7911. /* reg_mfsm_tacho
  7912. * Fan tachometer index.
  7913. * Access: Index
  7914. */
  7915. MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
  7916. /* reg_mfsm_rpm
  7917. * Fan speed (round per minute).
  7918. * Access: RO
  7919. */
  7920. MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
  7921. static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
  7922. {
  7923. MLXSW_REG_ZERO(mfsm, payload);
  7924. mlxsw_reg_mfsm_tacho_set(payload, tacho);
  7925. }
  7926. /* MFSL - Management Fan Speed Limit Register
  7927. * ------------------------------------------
  7928. * The Fan Speed Limit register is used to configure the fan speed
  7929. * event / interrupt notification mechanism. Fan speed threshold are
  7930. * defined for both under-speed and over-speed.
  7931. */
  7932. #define MLXSW_REG_MFSL_ID 0x9004
  7933. #define MLXSW_REG_MFSL_LEN 0x0C
  7934. MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
  7935. /* reg_mfsl_tacho
  7936. * Fan tachometer index.
  7937. * Access: Index
  7938. */
  7939. MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
  7940. /* reg_mfsl_tach_min
  7941. * Tachometer minimum value (minimum RPM).
  7942. * Access: RW
  7943. */
  7944. MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
  7945. /* reg_mfsl_tach_max
  7946. * Tachometer maximum value (maximum RPM).
  7947. * Access: RW
  7948. */
  7949. MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
  7950. static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
  7951. u16 tach_min, u16 tach_max)
  7952. {
  7953. MLXSW_REG_ZERO(mfsl, payload);
  7954. mlxsw_reg_mfsl_tacho_set(payload, tacho);
  7955. mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
  7956. mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
  7957. }
  7958. static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
  7959. u16 *p_tach_min, u16 *p_tach_max)
  7960. {
  7961. if (p_tach_min)
  7962. *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
  7963. if (p_tach_max)
  7964. *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
  7965. }
  7966. /* FORE - Fan Out of Range Event Register
  7967. * --------------------------------------
  7968. * This register reports the status of the controlled fans compared to the
  7969. * range defined by the MFSL register.
  7970. */
  7971. #define MLXSW_REG_FORE_ID 0x9007
  7972. #define MLXSW_REG_FORE_LEN 0x0C
  7973. MLXSW_REG_DEFINE(fore, MLXSW_REG_FORE_ID, MLXSW_REG_FORE_LEN);
  7974. /* fan_under_limit
  7975. * Fan speed is below the low limit defined in MFSL register. Each bit relates
  7976. * to a single tachometer and indicates the specific tachometer reading is
  7977. * below the threshold.
  7978. * Access: RO
  7979. */
  7980. MLXSW_ITEM32(reg, fore, fan_under_limit, 0x00, 16, 10);
  7981. static inline void mlxsw_reg_fore_unpack(char *payload, u8 tacho,
  7982. bool *fault)
  7983. {
  7984. u16 limit;
  7985. if (fault) {
  7986. limit = mlxsw_reg_fore_fan_under_limit_get(payload);
  7987. *fault = limit & BIT(tacho);
  7988. }
  7989. }
  7990. /* MTCAP - Management Temperature Capabilities
  7991. * -------------------------------------------
  7992. * This register exposes the capabilities of the device and
  7993. * system temperature sensing.
  7994. */
  7995. #define MLXSW_REG_MTCAP_ID 0x9009
  7996. #define MLXSW_REG_MTCAP_LEN 0x08
  7997. MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
  7998. /* reg_mtcap_sensor_count
  7999. * Number of sensors supported by the device.
  8000. * This includes the QSFP module sensors (if exists in the QSFP module).
  8001. * Access: RO
  8002. */
  8003. MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
  8004. /* MTMP - Management Temperature
  8005. * -----------------------------
  8006. * This register controls the settings of the temperature measurements
  8007. * and enables reading the temperature measurements. Note that temperature
  8008. * is in 0.125 degrees Celsius.
  8009. */
  8010. #define MLXSW_REG_MTMP_ID 0x900A
  8011. #define MLXSW_REG_MTMP_LEN 0x20
  8012. MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
  8013. /* reg_mtmp_slot_index
  8014. * Slot index (0: Main board).
  8015. * Access: Index
  8016. */
  8017. MLXSW_ITEM32(reg, mtmp, slot_index, 0x00, 16, 4);
  8018. #define MLXSW_REG_MTMP_MODULE_INDEX_MIN 64
  8019. #define MLXSW_REG_MTMP_GBOX_INDEX_MIN 256
  8020. /* reg_mtmp_sensor_index
  8021. * Sensors index to access.
  8022. * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
  8023. * (module 0 is mapped to sensor_index 64).
  8024. * Access: Index
  8025. */
  8026. MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 12);
  8027. /* Convert to milli degrees Celsius */
  8028. #define MLXSW_REG_MTMP_TEMP_TO_MC(val) ({ typeof(val) v_ = (val); \
  8029. ((v_) >= 0) ? ((v_) * 125) : \
  8030. ((s16)((GENMASK(15, 0) + (v_) + 1) \
  8031. * 125)); })
  8032. /* reg_mtmp_max_operational_temperature
  8033. * The highest temperature in the nominal operational range. Reading is in
  8034. * 0.125 Celsius degrees units.
  8035. * In case of module this is SFF critical temperature threshold.
  8036. * Access: RO
  8037. */
  8038. MLXSW_ITEM32(reg, mtmp, max_operational_temperature, 0x04, 16, 16);
  8039. /* reg_mtmp_temperature
  8040. * Temperature reading from the sensor. Reading is in 0.125 Celsius
  8041. * degrees units.
  8042. * Access: RO
  8043. */
  8044. MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
  8045. /* reg_mtmp_mte
  8046. * Max Temperature Enable - enables measuring the max temperature on a sensor.
  8047. * Access: RW
  8048. */
  8049. MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
  8050. /* reg_mtmp_mtr
  8051. * Max Temperature Reset - clears the value of the max temperature register.
  8052. * Access: WO
  8053. */
  8054. MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
  8055. /* reg_mtmp_max_temperature
  8056. * The highest measured temperature from the sensor.
  8057. * When the bit mte is cleared, the field max_temperature is reserved.
  8058. * Access: RO
  8059. */
  8060. MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
  8061. /* reg_mtmp_tee
  8062. * Temperature Event Enable.
  8063. * 0 - Do not generate event
  8064. * 1 - Generate event
  8065. * 2 - Generate single event
  8066. * Access: RW
  8067. */
  8068. enum mlxsw_reg_mtmp_tee {
  8069. MLXSW_REG_MTMP_TEE_NO_EVENT,
  8070. MLXSW_REG_MTMP_TEE_GENERATE_EVENT,
  8071. MLXSW_REG_MTMP_TEE_GENERATE_SINGLE_EVENT,
  8072. };
  8073. MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
  8074. #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
  8075. /* reg_mtmp_temperature_threshold_hi
  8076. * High threshold for Temperature Warning Event. In 0.125 Celsius.
  8077. * Access: RW
  8078. */
  8079. MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
  8080. #define MLXSW_REG_MTMP_HYSTERESIS_TEMP 0x28 /* 5 Celsius */
  8081. /* reg_mtmp_temperature_threshold_lo
  8082. * Low threshold for Temperature Warning Event. In 0.125 Celsius.
  8083. * Access: RW
  8084. */
  8085. MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
  8086. #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
  8087. /* reg_mtmp_sensor_name
  8088. * Sensor Name
  8089. * Access: RO
  8090. */
  8091. MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
  8092. static inline void mlxsw_reg_mtmp_pack(char *payload, u8 slot_index,
  8093. u16 sensor_index, bool max_temp_enable,
  8094. bool max_temp_reset)
  8095. {
  8096. MLXSW_REG_ZERO(mtmp, payload);
  8097. mlxsw_reg_mtmp_slot_index_set(payload, slot_index);
  8098. mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
  8099. mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
  8100. mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
  8101. mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
  8102. MLXSW_REG_MTMP_THRESH_HI);
  8103. }
  8104. static inline void mlxsw_reg_mtmp_unpack(char *payload, int *p_temp,
  8105. int *p_max_temp, int *p_temp_hi,
  8106. int *p_max_oper_temp,
  8107. char *sensor_name)
  8108. {
  8109. s16 temp;
  8110. if (p_temp) {
  8111. temp = mlxsw_reg_mtmp_temperature_get(payload);
  8112. *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  8113. }
  8114. if (p_max_temp) {
  8115. temp = mlxsw_reg_mtmp_max_temperature_get(payload);
  8116. *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  8117. }
  8118. if (p_temp_hi) {
  8119. temp = mlxsw_reg_mtmp_temperature_threshold_hi_get(payload);
  8120. *p_temp_hi = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  8121. }
  8122. if (p_max_oper_temp) {
  8123. temp = mlxsw_reg_mtmp_max_operational_temperature_get(payload);
  8124. *p_max_oper_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  8125. }
  8126. if (sensor_name)
  8127. mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
  8128. }
  8129. /* MTWE - Management Temperature Warning Event
  8130. * -------------------------------------------
  8131. * This register is used for over temperature warning.
  8132. */
  8133. #define MLXSW_REG_MTWE_ID 0x900B
  8134. #define MLXSW_REG_MTWE_LEN 0x10
  8135. MLXSW_REG_DEFINE(mtwe, MLXSW_REG_MTWE_ID, MLXSW_REG_MTWE_LEN);
  8136. /* reg_mtwe_sensor_warning
  8137. * Bit vector indicating which of the sensor reading is above threshold.
  8138. * Address 00h bit31 is sensor_warning[127].
  8139. * Address 0Ch bit0 is sensor_warning[0].
  8140. * Access: RO
  8141. */
  8142. MLXSW_ITEM_BIT_ARRAY(reg, mtwe, sensor_warning, 0x0, 0x10, 1);
  8143. /* MTBR - Management Temperature Bulk Register
  8144. * -------------------------------------------
  8145. * This register is used for bulk temperature reading.
  8146. */
  8147. #define MLXSW_REG_MTBR_ID 0x900F
  8148. #define MLXSW_REG_MTBR_BASE_LEN 0x10 /* base length, without records */
  8149. #define MLXSW_REG_MTBR_REC_LEN 0x04 /* record length */
  8150. #define MLXSW_REG_MTBR_REC_MAX_COUNT 47 /* firmware limitation */
  8151. #define MLXSW_REG_MTBR_LEN (MLXSW_REG_MTBR_BASE_LEN + \
  8152. MLXSW_REG_MTBR_REC_LEN * \
  8153. MLXSW_REG_MTBR_REC_MAX_COUNT)
  8154. MLXSW_REG_DEFINE(mtbr, MLXSW_REG_MTBR_ID, MLXSW_REG_MTBR_LEN);
  8155. /* reg_mtbr_slot_index
  8156. * Slot index (0: Main board).
  8157. * Access: Index
  8158. */
  8159. MLXSW_ITEM32(reg, mtbr, slot_index, 0x00, 16, 4);
  8160. /* reg_mtbr_base_sensor_index
  8161. * Base sensors index to access (0 - ASIC sensor, 1-63 - ambient sensors,
  8162. * 64-127 are mapped to the SFP+/QSFP modules sequentially).
  8163. * Access: Index
  8164. */
  8165. MLXSW_ITEM32(reg, mtbr, base_sensor_index, 0x00, 0, 12);
  8166. /* reg_mtbr_num_rec
  8167. * Request: Number of records to read
  8168. * Response: Number of records read
  8169. * See above description for more details.
  8170. * Range 1..255
  8171. * Access: RW
  8172. */
  8173. MLXSW_ITEM32(reg, mtbr, num_rec, 0x04, 0, 8);
  8174. /* reg_mtbr_rec_max_temp
  8175. * The highest measured temperature from the sensor.
  8176. * When the bit mte is cleared, the field max_temperature is reserved.
  8177. * Access: RO
  8178. */
  8179. MLXSW_ITEM32_INDEXED(reg, mtbr, rec_max_temp, MLXSW_REG_MTBR_BASE_LEN, 16,
  8180. 16, MLXSW_REG_MTBR_REC_LEN, 0x00, false);
  8181. /* reg_mtbr_rec_temp
  8182. * Temperature reading from the sensor. Reading is in 0..125 Celsius
  8183. * degrees units.
  8184. * Access: RO
  8185. */
  8186. MLXSW_ITEM32_INDEXED(reg, mtbr, rec_temp, MLXSW_REG_MTBR_BASE_LEN, 0, 16,
  8187. MLXSW_REG_MTBR_REC_LEN, 0x00, false);
  8188. static inline void mlxsw_reg_mtbr_pack(char *payload, u8 slot_index,
  8189. u16 base_sensor_index, u8 num_rec)
  8190. {
  8191. MLXSW_REG_ZERO(mtbr, payload);
  8192. mlxsw_reg_mtbr_slot_index_set(payload, slot_index);
  8193. mlxsw_reg_mtbr_base_sensor_index_set(payload, base_sensor_index);
  8194. mlxsw_reg_mtbr_num_rec_set(payload, num_rec);
  8195. }
  8196. /* Error codes from temperatute reading */
  8197. enum mlxsw_reg_mtbr_temp_status {
  8198. MLXSW_REG_MTBR_NO_CONN = 0x8000,
  8199. MLXSW_REG_MTBR_NO_TEMP_SENS = 0x8001,
  8200. MLXSW_REG_MTBR_INDEX_NA = 0x8002,
  8201. MLXSW_REG_MTBR_BAD_SENS_INFO = 0x8003,
  8202. };
  8203. /* Base index for reading modules temperature */
  8204. #define MLXSW_REG_MTBR_BASE_MODULE_INDEX 64
  8205. static inline void mlxsw_reg_mtbr_temp_unpack(char *payload, int rec_ind,
  8206. u16 *p_temp, u16 *p_max_temp)
  8207. {
  8208. if (p_temp)
  8209. *p_temp = mlxsw_reg_mtbr_rec_temp_get(payload, rec_ind);
  8210. if (p_max_temp)
  8211. *p_max_temp = mlxsw_reg_mtbr_rec_max_temp_get(payload, rec_ind);
  8212. }
  8213. /* MCIA - Management Cable Info Access
  8214. * -----------------------------------
  8215. * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
  8216. */
  8217. #define MLXSW_REG_MCIA_ID 0x9014
  8218. #define MLXSW_REG_MCIA_LEN 0x40
  8219. MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
  8220. /* reg_mcia_l
  8221. * Lock bit. Setting this bit will lock the access to the specific
  8222. * cable. Used for updating a full page in a cable EPROM. Any access
  8223. * other then subsequence writes will fail while the port is locked.
  8224. * Access: RW
  8225. */
  8226. MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
  8227. /* reg_mcia_module
  8228. * Module number.
  8229. * Access: Index
  8230. */
  8231. MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
  8232. /* reg_mcia_slot_index
  8233. * Slot index (0: Main board)
  8234. * Access: Index
  8235. */
  8236. MLXSW_ITEM32(reg, mcia, slot, 0x00, 12, 4);
  8237. enum {
  8238. MLXSW_REG_MCIA_STATUS_GOOD = 0,
  8239. /* No response from module's EEPROM. */
  8240. MLXSW_REG_MCIA_STATUS_NO_EEPROM_MODULE = 1,
  8241. /* Module type not supported by the device. */
  8242. MLXSW_REG_MCIA_STATUS_MODULE_NOT_SUPPORTED = 2,
  8243. /* No module present indication. */
  8244. MLXSW_REG_MCIA_STATUS_MODULE_NOT_CONNECTED = 3,
  8245. /* Error occurred while trying to access module's EEPROM using I2C. */
  8246. MLXSW_REG_MCIA_STATUS_I2C_ERROR = 9,
  8247. /* Module is disabled. */
  8248. MLXSW_REG_MCIA_STATUS_MODULE_DISABLED = 16,
  8249. };
  8250. /* reg_mcia_status
  8251. * Module status.
  8252. * Access: RO
  8253. */
  8254. MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
  8255. /* reg_mcia_i2c_device_address
  8256. * I2C device address.
  8257. * Access: RW
  8258. */
  8259. MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
  8260. /* reg_mcia_page_number
  8261. * Page number.
  8262. * Access: RW
  8263. */
  8264. MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
  8265. /* reg_mcia_device_address
  8266. * Device address.
  8267. * Access: RW
  8268. */
  8269. MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
  8270. /* reg_mcia_bank_number
  8271. * Bank number.
  8272. * Access: Index
  8273. */
  8274. MLXSW_ITEM32(reg, mcia, bank_number, 0x08, 16, 8);
  8275. /* reg_mcia_size
  8276. * Number of bytes to read/write (up to 48 bytes).
  8277. * Access: RW
  8278. */
  8279. MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
  8280. #define MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH 256
  8281. #define MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH 128
  8282. #define MLXSW_REG_MCIA_EEPROM_SIZE 48
  8283. #define MLXSW_REG_MCIA_I2C_ADDR_LOW 0x50
  8284. #define MLXSW_REG_MCIA_I2C_ADDR_HIGH 0x51
  8285. #define MLXSW_REG_MCIA_PAGE0_LO_OFF 0xa0
  8286. #define MLXSW_REG_MCIA_TH_ITEM_SIZE 2
  8287. #define MLXSW_REG_MCIA_TH_PAGE_NUM 3
  8288. #define MLXSW_REG_MCIA_TH_PAGE_CMIS_NUM 2
  8289. #define MLXSW_REG_MCIA_PAGE0_LO 0
  8290. #define MLXSW_REG_MCIA_TH_PAGE_OFF 0x80
  8291. #define MLXSW_REG_MCIA_EEPROM_CMIS_FLAT_MEMORY BIT(7)
  8292. enum mlxsw_reg_mcia_eeprom_module_info_rev_id {
  8293. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_UNSPC = 0x00,
  8294. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8436 = 0x01,
  8295. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID_8636 = 0x03,
  8296. };
  8297. enum mlxsw_reg_mcia_eeprom_module_info_id {
  8298. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP = 0x03,
  8299. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP = 0x0C,
  8300. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS = 0x0D,
  8301. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 = 0x11,
  8302. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_DD = 0x18,
  8303. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_OSFP = 0x19,
  8304. };
  8305. enum mlxsw_reg_mcia_eeprom_module_info {
  8306. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID,
  8307. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_REV_ID,
  8308. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_TYPE_ID,
  8309. MLXSW_REG_MCIA_EEPROM_MODULE_INFO_SIZE,
  8310. };
  8311. /* reg_mcia_eeprom
  8312. * Bytes to read/write.
  8313. * Access: RW
  8314. */
  8315. MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_REG_MCIA_EEPROM_SIZE);
  8316. /* This is used to access the optional upper pages (1-3) in the QSFP+
  8317. * memory map. Page 1 is available on offset 256 through 383, page 2 -
  8318. * on offset 384 through 511, page 3 - on offset 512 through 639.
  8319. */
  8320. #define MLXSW_REG_MCIA_PAGE_GET(off) (((off) - \
  8321. MLXSW_REG_MCIA_EEPROM_PAGE_LENGTH) / \
  8322. MLXSW_REG_MCIA_EEPROM_UP_PAGE_LENGTH + 1)
  8323. static inline void mlxsw_reg_mcia_pack(char *payload, u8 slot_index, u8 module,
  8324. u8 lock, u8 page_number,
  8325. u16 device_addr, u8 size,
  8326. u8 i2c_device_addr)
  8327. {
  8328. MLXSW_REG_ZERO(mcia, payload);
  8329. mlxsw_reg_mcia_slot_set(payload, slot_index);
  8330. mlxsw_reg_mcia_module_set(payload, module);
  8331. mlxsw_reg_mcia_l_set(payload, lock);
  8332. mlxsw_reg_mcia_page_number_set(payload, page_number);
  8333. mlxsw_reg_mcia_device_address_set(payload, device_addr);
  8334. mlxsw_reg_mcia_size_set(payload, size);
  8335. mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
  8336. }
  8337. /* MPAT - Monitoring Port Analyzer Table
  8338. * -------------------------------------
  8339. * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
  8340. * For an enabled analyzer, all fields except e (enable) cannot be modified.
  8341. */
  8342. #define MLXSW_REG_MPAT_ID 0x901A
  8343. #define MLXSW_REG_MPAT_LEN 0x78
  8344. MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
  8345. /* reg_mpat_pa_id
  8346. * Port Analyzer ID.
  8347. * Access: Index
  8348. */
  8349. MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
  8350. /* reg_mpat_session_id
  8351. * Mirror Session ID.
  8352. * Used for MIRROR_SESSION<i> trap.
  8353. * Access: RW
  8354. */
  8355. MLXSW_ITEM32(reg, mpat, session_id, 0x00, 24, 4);
  8356. /* reg_mpat_system_port
  8357. * A unique port identifier for the final destination of the packet.
  8358. * Access: RW
  8359. */
  8360. MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
  8361. /* reg_mpat_e
  8362. * Enable. Indicating the Port Analyzer is enabled.
  8363. * Access: RW
  8364. */
  8365. MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
  8366. /* reg_mpat_qos
  8367. * Quality Of Service Mode.
  8368. * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
  8369. * PCP, DEI, DSCP or VL) are configured.
  8370. * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
  8371. * same as in the original packet that has triggered the mirroring. For
  8372. * SPAN also the pcp,dei are maintained.
  8373. * Access: RW
  8374. */
  8375. MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
  8376. /* reg_mpat_be
  8377. * Best effort mode. Indicates mirroring traffic should not cause packet
  8378. * drop or back pressure, but will discard the mirrored packets. Mirrored
  8379. * packets will be forwarded on a best effort manner.
  8380. * 0: Do not discard mirrored packets
  8381. * 1: Discard mirrored packets if causing congestion
  8382. * Access: RW
  8383. */
  8384. MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
  8385. enum mlxsw_reg_mpat_span_type {
  8386. /* Local SPAN Ethernet.
  8387. * The original packet is not encapsulated.
  8388. */
  8389. MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
  8390. /* Remote SPAN Ethernet VLAN.
  8391. * The packet is forwarded to the monitoring port on the monitoring
  8392. * VLAN.
  8393. */
  8394. MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
  8395. /* Encapsulated Remote SPAN Ethernet L3 GRE.
  8396. * The packet is encapsulated with GRE header.
  8397. */
  8398. MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
  8399. };
  8400. /* reg_mpat_span_type
  8401. * SPAN type.
  8402. * Access: RW
  8403. */
  8404. MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
  8405. /* reg_mpat_pide
  8406. * Policer enable.
  8407. * Access: RW
  8408. */
  8409. MLXSW_ITEM32(reg, mpat, pide, 0x0C, 15, 1);
  8410. /* reg_mpat_pid
  8411. * Policer ID.
  8412. * Access: RW
  8413. */
  8414. MLXSW_ITEM32(reg, mpat, pid, 0x0C, 0, 14);
  8415. /* Remote SPAN - Ethernet VLAN
  8416. * - - - - - - - - - - - - - -
  8417. */
  8418. /* reg_mpat_eth_rspan_vid
  8419. * Encapsulation header VLAN ID.
  8420. * Access: RW
  8421. */
  8422. MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
  8423. /* Encapsulated Remote SPAN - Ethernet L2
  8424. * - - - - - - - - - - - - - - - - - - -
  8425. */
  8426. enum mlxsw_reg_mpat_eth_rspan_version {
  8427. MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
  8428. };
  8429. /* reg_mpat_eth_rspan_version
  8430. * RSPAN mirror header version.
  8431. * Access: RW
  8432. */
  8433. MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
  8434. /* reg_mpat_eth_rspan_mac
  8435. * Destination MAC address.
  8436. * Access: RW
  8437. */
  8438. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
  8439. /* reg_mpat_eth_rspan_tp
  8440. * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
  8441. * Access: RW
  8442. */
  8443. MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
  8444. /* Encapsulated Remote SPAN - Ethernet L3
  8445. * - - - - - - - - - - - - - - - - - - -
  8446. */
  8447. enum mlxsw_reg_mpat_eth_rspan_protocol {
  8448. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
  8449. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
  8450. };
  8451. /* reg_mpat_eth_rspan_protocol
  8452. * SPAN encapsulation protocol.
  8453. * Access: RW
  8454. */
  8455. MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
  8456. /* reg_mpat_eth_rspan_ttl
  8457. * Encapsulation header Time-to-Live/HopLimit.
  8458. * Access: RW
  8459. */
  8460. MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
  8461. /* reg_mpat_eth_rspan_smac
  8462. * Source MAC address
  8463. * Access: RW
  8464. */
  8465. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
  8466. /* reg_mpat_eth_rspan_dip*
  8467. * Destination IP address. The IP version is configured by protocol.
  8468. * Access: RW
  8469. */
  8470. MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
  8471. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
  8472. /* reg_mpat_eth_rspan_sip*
  8473. * Source IP address. The IP version is configured by protocol.
  8474. * Access: RW
  8475. */
  8476. MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
  8477. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
  8478. static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
  8479. u16 system_port, bool e,
  8480. enum mlxsw_reg_mpat_span_type span_type)
  8481. {
  8482. MLXSW_REG_ZERO(mpat, payload);
  8483. mlxsw_reg_mpat_pa_id_set(payload, pa_id);
  8484. mlxsw_reg_mpat_system_port_set(payload, system_port);
  8485. mlxsw_reg_mpat_e_set(payload, e);
  8486. mlxsw_reg_mpat_qos_set(payload, 1);
  8487. mlxsw_reg_mpat_be_set(payload, 1);
  8488. mlxsw_reg_mpat_span_type_set(payload, span_type);
  8489. }
  8490. static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
  8491. {
  8492. mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
  8493. }
  8494. static inline void
  8495. mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
  8496. enum mlxsw_reg_mpat_eth_rspan_version version,
  8497. const char *mac,
  8498. bool tp)
  8499. {
  8500. mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
  8501. mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
  8502. mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
  8503. }
  8504. static inline void
  8505. mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
  8506. const char *smac,
  8507. u32 sip, u32 dip)
  8508. {
  8509. mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
  8510. mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
  8511. mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
  8512. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
  8513. mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
  8514. mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
  8515. }
  8516. static inline void
  8517. mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
  8518. const char *smac,
  8519. struct in6_addr sip, struct in6_addr dip)
  8520. {
  8521. mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
  8522. mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
  8523. mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
  8524. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
  8525. mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
  8526. mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
  8527. }
  8528. /* MPAR - Monitoring Port Analyzer Register
  8529. * ----------------------------------------
  8530. * MPAR register is used to query and configure the port analyzer port mirroring
  8531. * properties.
  8532. */
  8533. #define MLXSW_REG_MPAR_ID 0x901B
  8534. #define MLXSW_REG_MPAR_LEN 0x0C
  8535. MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
  8536. /* reg_mpar_local_port
  8537. * The local port to mirror the packets from.
  8538. * Access: Index
  8539. */
  8540. MLXSW_ITEM32_LP(reg, mpar, 0x00, 16, 0x00, 4);
  8541. enum mlxsw_reg_mpar_i_e {
  8542. MLXSW_REG_MPAR_TYPE_EGRESS,
  8543. MLXSW_REG_MPAR_TYPE_INGRESS,
  8544. };
  8545. /* reg_mpar_i_e
  8546. * Ingress/Egress
  8547. * Access: Index
  8548. */
  8549. MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
  8550. /* reg_mpar_enable
  8551. * Enable mirroring
  8552. * By default, port mirroring is disabled for all ports.
  8553. * Access: RW
  8554. */
  8555. MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
  8556. /* reg_mpar_pa_id
  8557. * Port Analyzer ID.
  8558. * Access: RW
  8559. */
  8560. MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
  8561. #define MLXSW_REG_MPAR_RATE_MAX 3500000000UL
  8562. /* reg_mpar_probability_rate
  8563. * Sampling rate.
  8564. * Valid values are: 1 to 3.5*10^9
  8565. * Value of 1 means "sample all". Default is 1.
  8566. * Reserved when Spectrum-1.
  8567. * Access: RW
  8568. */
  8569. MLXSW_ITEM32(reg, mpar, probability_rate, 0x08, 0, 32);
  8570. static inline void mlxsw_reg_mpar_pack(char *payload, u16 local_port,
  8571. enum mlxsw_reg_mpar_i_e i_e,
  8572. bool enable, u8 pa_id,
  8573. u32 probability_rate)
  8574. {
  8575. MLXSW_REG_ZERO(mpar, payload);
  8576. mlxsw_reg_mpar_local_port_set(payload, local_port);
  8577. mlxsw_reg_mpar_enable_set(payload, enable);
  8578. mlxsw_reg_mpar_i_e_set(payload, i_e);
  8579. mlxsw_reg_mpar_pa_id_set(payload, pa_id);
  8580. mlxsw_reg_mpar_probability_rate_set(payload, probability_rate);
  8581. }
  8582. /* MGIR - Management General Information Register
  8583. * ----------------------------------------------
  8584. * MGIR register allows software to query the hardware and firmware general
  8585. * information.
  8586. */
  8587. #define MLXSW_REG_MGIR_ID 0x9020
  8588. #define MLXSW_REG_MGIR_LEN 0x9C
  8589. MLXSW_REG_DEFINE(mgir, MLXSW_REG_MGIR_ID, MLXSW_REG_MGIR_LEN);
  8590. /* reg_mgir_hw_info_device_hw_revision
  8591. * Access: RO
  8592. */
  8593. MLXSW_ITEM32(reg, mgir, hw_info_device_hw_revision, 0x0, 16, 16);
  8594. #define MLXSW_REG_MGIR_FW_INFO_PSID_SIZE 16
  8595. /* reg_mgir_fw_info_psid
  8596. * PSID (ASCII string).
  8597. * Access: RO
  8598. */
  8599. MLXSW_ITEM_BUF(reg, mgir, fw_info_psid, 0x30, MLXSW_REG_MGIR_FW_INFO_PSID_SIZE);
  8600. /* reg_mgir_fw_info_extended_major
  8601. * Access: RO
  8602. */
  8603. MLXSW_ITEM32(reg, mgir, fw_info_extended_major, 0x44, 0, 32);
  8604. /* reg_mgir_fw_info_extended_minor
  8605. * Access: RO
  8606. */
  8607. MLXSW_ITEM32(reg, mgir, fw_info_extended_minor, 0x48, 0, 32);
  8608. /* reg_mgir_fw_info_extended_sub_minor
  8609. * Access: RO
  8610. */
  8611. MLXSW_ITEM32(reg, mgir, fw_info_extended_sub_minor, 0x4C, 0, 32);
  8612. static inline void mlxsw_reg_mgir_pack(char *payload)
  8613. {
  8614. MLXSW_REG_ZERO(mgir, payload);
  8615. }
  8616. static inline void
  8617. mlxsw_reg_mgir_unpack(char *payload, u32 *hw_rev, char *fw_info_psid,
  8618. u32 *fw_major, u32 *fw_minor, u32 *fw_sub_minor)
  8619. {
  8620. *hw_rev = mlxsw_reg_mgir_hw_info_device_hw_revision_get(payload);
  8621. mlxsw_reg_mgir_fw_info_psid_memcpy_from(payload, fw_info_psid);
  8622. *fw_major = mlxsw_reg_mgir_fw_info_extended_major_get(payload);
  8623. *fw_minor = mlxsw_reg_mgir_fw_info_extended_minor_get(payload);
  8624. *fw_sub_minor = mlxsw_reg_mgir_fw_info_extended_sub_minor_get(payload);
  8625. }
  8626. /* MRSR - Management Reset and Shutdown Register
  8627. * ---------------------------------------------
  8628. * MRSR register is used to reset or shutdown the switch or
  8629. * the entire system (when applicable).
  8630. */
  8631. #define MLXSW_REG_MRSR_ID 0x9023
  8632. #define MLXSW_REG_MRSR_LEN 0x08
  8633. MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
  8634. /* reg_mrsr_command
  8635. * Reset/shutdown command
  8636. * 0 - do nothing
  8637. * 1 - software reset
  8638. * Access: WO
  8639. */
  8640. MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
  8641. static inline void mlxsw_reg_mrsr_pack(char *payload)
  8642. {
  8643. MLXSW_REG_ZERO(mrsr, payload);
  8644. mlxsw_reg_mrsr_command_set(payload, 1);
  8645. }
  8646. /* MLCR - Management LED Control Register
  8647. * --------------------------------------
  8648. * Controls the system LEDs.
  8649. */
  8650. #define MLXSW_REG_MLCR_ID 0x902B
  8651. #define MLXSW_REG_MLCR_LEN 0x0C
  8652. MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
  8653. /* reg_mlcr_local_port
  8654. * Local port number.
  8655. * Access: RW
  8656. */
  8657. MLXSW_ITEM32_LP(reg, mlcr, 0x00, 16, 0x00, 24);
  8658. #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
  8659. /* reg_mlcr_beacon_duration
  8660. * Duration of the beacon to be active, in seconds.
  8661. * 0x0 - Will turn off the beacon.
  8662. * 0xFFFF - Will turn on the beacon until explicitly turned off.
  8663. * Access: RW
  8664. */
  8665. MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
  8666. /* reg_mlcr_beacon_remain
  8667. * Remaining duration of the beacon, in seconds.
  8668. * 0xFFFF indicates an infinite amount of time.
  8669. * Access: RO
  8670. */
  8671. MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
  8672. static inline void mlxsw_reg_mlcr_pack(char *payload, u16 local_port,
  8673. bool active)
  8674. {
  8675. MLXSW_REG_ZERO(mlcr, payload);
  8676. mlxsw_reg_mlcr_local_port_set(payload, local_port);
  8677. mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
  8678. MLXSW_REG_MLCR_DURATION_MAX : 0);
  8679. }
  8680. /* MCION - Management Cable IO and Notifications Register
  8681. * ------------------------------------------------------
  8682. * The MCION register is used to query transceiver modules' IO pins and other
  8683. * notifications.
  8684. */
  8685. #define MLXSW_REG_MCION_ID 0x9052
  8686. #define MLXSW_REG_MCION_LEN 0x18
  8687. MLXSW_REG_DEFINE(mcion, MLXSW_REG_MCION_ID, MLXSW_REG_MCION_LEN);
  8688. /* reg_mcion_module
  8689. * Module number.
  8690. * Access: Index
  8691. */
  8692. MLXSW_ITEM32(reg, mcion, module, 0x00, 16, 8);
  8693. /* reg_mcion_slot_index
  8694. * Slot index.
  8695. * Access: Index
  8696. */
  8697. MLXSW_ITEM32(reg, mcion, slot_index, 0x00, 12, 4);
  8698. enum {
  8699. MLXSW_REG_MCION_MODULE_STATUS_BITS_PRESENT_MASK = BIT(0),
  8700. MLXSW_REG_MCION_MODULE_STATUS_BITS_LOW_POWER_MASK = BIT(8),
  8701. };
  8702. /* reg_mcion_module_status_bits
  8703. * Module IO status as defined by SFF.
  8704. * Access: RO
  8705. */
  8706. MLXSW_ITEM32(reg, mcion, module_status_bits, 0x04, 0, 16);
  8707. static inline void mlxsw_reg_mcion_pack(char *payload, u8 slot_index, u8 module)
  8708. {
  8709. MLXSW_REG_ZERO(mcion, payload);
  8710. mlxsw_reg_mcion_slot_index_set(payload, slot_index);
  8711. mlxsw_reg_mcion_module_set(payload, module);
  8712. }
  8713. /* MTPPS - Management Pulse Per Second Register
  8714. * --------------------------------------------
  8715. * This register provides the device PPS capabilities, configure the PPS in and
  8716. * out modules and holds the PPS in time stamp.
  8717. */
  8718. #define MLXSW_REG_MTPPS_ID 0x9053
  8719. #define MLXSW_REG_MTPPS_LEN 0x3C
  8720. MLXSW_REG_DEFINE(mtpps, MLXSW_REG_MTPPS_ID, MLXSW_REG_MTPPS_LEN);
  8721. /* reg_mtpps_enable
  8722. * Enables the PPS functionality the specific pin.
  8723. * A boolean variable.
  8724. * Access: RW
  8725. */
  8726. MLXSW_ITEM32(reg, mtpps, enable, 0x20, 31, 1);
  8727. enum mlxsw_reg_mtpps_pin_mode {
  8728. MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN = 0x2,
  8729. };
  8730. /* reg_mtpps_pin_mode
  8731. * Pin mode to be used. The mode must comply with the supported modes of the
  8732. * requested pin.
  8733. * Access: RW
  8734. */
  8735. MLXSW_ITEM32(reg, mtpps, pin_mode, 0x20, 8, 4);
  8736. #define MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN 7
  8737. /* reg_mtpps_pin
  8738. * Pin to be configured or queried out of the supported pins.
  8739. * Access: Index
  8740. */
  8741. MLXSW_ITEM32(reg, mtpps, pin, 0x20, 0, 8);
  8742. /* reg_mtpps_time_stamp
  8743. * When pin_mode = pps_in, the latched device time when it was triggered from
  8744. * the external GPIO pin.
  8745. * When pin_mode = pps_out or virtual_pin or pps_out_and_virtual_pin, the target
  8746. * time to generate next output signal.
  8747. * Time is in units of device clock.
  8748. * Access: RW
  8749. */
  8750. MLXSW_ITEM64(reg, mtpps, time_stamp, 0x28, 0, 64);
  8751. static inline void
  8752. mlxsw_reg_mtpps_vpin_pack(char *payload, u64 time_stamp)
  8753. {
  8754. MLXSW_REG_ZERO(mtpps, payload);
  8755. mlxsw_reg_mtpps_pin_set(payload, MLXSW_REG_MTPPS_PIN_SP_VIRTUAL_PIN);
  8756. mlxsw_reg_mtpps_pin_mode_set(payload,
  8757. MLXSW_REG_MTPPS_PIN_MODE_VIRTUAL_PIN);
  8758. mlxsw_reg_mtpps_enable_set(payload, true);
  8759. mlxsw_reg_mtpps_time_stamp_set(payload, time_stamp);
  8760. }
  8761. /* MTUTC - Management UTC Register
  8762. * -------------------------------
  8763. * Configures the HW UTC counter.
  8764. */
  8765. #define MLXSW_REG_MTUTC_ID 0x9055
  8766. #define MLXSW_REG_MTUTC_LEN 0x1C
  8767. MLXSW_REG_DEFINE(mtutc, MLXSW_REG_MTUTC_ID, MLXSW_REG_MTUTC_LEN);
  8768. enum mlxsw_reg_mtutc_operation {
  8769. MLXSW_REG_MTUTC_OPERATION_SET_TIME_AT_NEXT_SEC = 0,
  8770. MLXSW_REG_MTUTC_OPERATION_SET_TIME_IMMEDIATE = 1,
  8771. MLXSW_REG_MTUTC_OPERATION_ADJUST_TIME = 2,
  8772. MLXSW_REG_MTUTC_OPERATION_ADJUST_FREQ = 3,
  8773. };
  8774. /* reg_mtutc_operation
  8775. * Operation.
  8776. * Access: OP
  8777. */
  8778. MLXSW_ITEM32(reg, mtutc, operation, 0x00, 0, 4);
  8779. /* reg_mtutc_freq_adjustment
  8780. * Frequency adjustment: Every PPS the HW frequency will be
  8781. * adjusted by this value. Units of HW clock, where HW counts
  8782. * 10^9 HW clocks for 1 HW second. Range is from -50,000,000 to +50,000,000.
  8783. * In Spectrum-2, the field is reversed, positive values mean to decrease the
  8784. * frequency.
  8785. * Access: RW
  8786. */
  8787. MLXSW_ITEM32(reg, mtutc, freq_adjustment, 0x04, 0, 32);
  8788. #define MLXSW_REG_MTUTC_MAX_FREQ_ADJ (50 * 1000 * 1000)
  8789. /* reg_mtutc_utc_sec
  8790. * UTC seconds.
  8791. * Access: WO
  8792. */
  8793. MLXSW_ITEM32(reg, mtutc, utc_sec, 0x10, 0, 32);
  8794. /* reg_mtutc_utc_nsec
  8795. * UTC nSecs.
  8796. * Range 0..(10^9-1)
  8797. * Updated when operation is SET_TIME_IMMEDIATE.
  8798. * Reserved on Spectrum-1.
  8799. * Access: WO
  8800. */
  8801. MLXSW_ITEM32(reg, mtutc, utc_nsec, 0x14, 0, 30);
  8802. /* reg_mtutc_time_adjustment
  8803. * Time adjustment.
  8804. * Units of nSec.
  8805. * Range is from -32768 to +32767.
  8806. * Updated when operation is ADJUST_TIME.
  8807. * Reserved on Spectrum-1.
  8808. * Access: WO
  8809. */
  8810. MLXSW_ITEM32(reg, mtutc, time_adjustment, 0x18, 0, 32);
  8811. static inline void
  8812. mlxsw_reg_mtutc_pack(char *payload, enum mlxsw_reg_mtutc_operation oper,
  8813. u32 freq_adj, u32 utc_sec, u32 utc_nsec, u32 time_adj)
  8814. {
  8815. MLXSW_REG_ZERO(mtutc, payload);
  8816. mlxsw_reg_mtutc_operation_set(payload, oper);
  8817. mlxsw_reg_mtutc_freq_adjustment_set(payload, freq_adj);
  8818. mlxsw_reg_mtutc_utc_sec_set(payload, utc_sec);
  8819. mlxsw_reg_mtutc_utc_nsec_set(payload, utc_nsec);
  8820. mlxsw_reg_mtutc_time_adjustment_set(payload, time_adj);
  8821. }
  8822. /* MCQI - Management Component Query Information
  8823. * ---------------------------------------------
  8824. * This register allows querying information about firmware components.
  8825. */
  8826. #define MLXSW_REG_MCQI_ID 0x9061
  8827. #define MLXSW_REG_MCQI_BASE_LEN 0x18
  8828. #define MLXSW_REG_MCQI_CAP_LEN 0x14
  8829. #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
  8830. MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
  8831. /* reg_mcqi_component_index
  8832. * Index of the accessed component.
  8833. * Access: Index
  8834. */
  8835. MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
  8836. enum mlxfw_reg_mcqi_info_type {
  8837. MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
  8838. };
  8839. /* reg_mcqi_info_type
  8840. * Component properties set.
  8841. * Access: RW
  8842. */
  8843. MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
  8844. /* reg_mcqi_offset
  8845. * The requested/returned data offset from the section start, given in bytes.
  8846. * Must be DWORD aligned.
  8847. * Access: RW
  8848. */
  8849. MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
  8850. /* reg_mcqi_data_size
  8851. * The requested/returned data size, given in bytes. If data_size is not DWORD
  8852. * aligned, the last bytes are zero padded.
  8853. * Access: RW
  8854. */
  8855. MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
  8856. /* reg_mcqi_cap_max_component_size
  8857. * Maximum size for this component, given in bytes.
  8858. * Access: RO
  8859. */
  8860. MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
  8861. /* reg_mcqi_cap_log_mcda_word_size
  8862. * Log 2 of the access word size in bytes. Read and write access must be aligned
  8863. * to the word size. Write access must be done for an integer number of words.
  8864. * Access: RO
  8865. */
  8866. MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
  8867. /* reg_mcqi_cap_mcda_max_write_size
  8868. * Maximal write size for MCDA register
  8869. * Access: RO
  8870. */
  8871. MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
  8872. static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
  8873. {
  8874. MLXSW_REG_ZERO(mcqi, payload);
  8875. mlxsw_reg_mcqi_component_index_set(payload, component_index);
  8876. mlxsw_reg_mcqi_info_type_set(payload,
  8877. MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
  8878. mlxsw_reg_mcqi_offset_set(payload, 0);
  8879. mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
  8880. }
  8881. static inline void mlxsw_reg_mcqi_unpack(char *payload,
  8882. u32 *p_cap_max_component_size,
  8883. u8 *p_cap_log_mcda_word_size,
  8884. u16 *p_cap_mcda_max_write_size)
  8885. {
  8886. *p_cap_max_component_size =
  8887. mlxsw_reg_mcqi_cap_max_component_size_get(payload);
  8888. *p_cap_log_mcda_word_size =
  8889. mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
  8890. *p_cap_mcda_max_write_size =
  8891. mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
  8892. }
  8893. /* MCC - Management Component Control
  8894. * ----------------------------------
  8895. * Controls the firmware component and updates the FSM.
  8896. */
  8897. #define MLXSW_REG_MCC_ID 0x9062
  8898. #define MLXSW_REG_MCC_LEN 0x1C
  8899. MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
  8900. enum mlxsw_reg_mcc_instruction {
  8901. MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
  8902. MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
  8903. MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
  8904. MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
  8905. MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
  8906. MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
  8907. };
  8908. /* reg_mcc_instruction
  8909. * Command to be executed by the FSM.
  8910. * Applicable for write operation only.
  8911. * Access: RW
  8912. */
  8913. MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
  8914. /* reg_mcc_component_index
  8915. * Index of the accessed component. Applicable only for commands that
  8916. * refer to components. Otherwise, this field is reserved.
  8917. * Access: Index
  8918. */
  8919. MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
  8920. /* reg_mcc_update_handle
  8921. * Token representing the current flow executed by the FSM.
  8922. * Access: WO
  8923. */
  8924. MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
  8925. /* reg_mcc_error_code
  8926. * Indicates the successful completion of the instruction, or the reason it
  8927. * failed
  8928. * Access: RO
  8929. */
  8930. MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
  8931. /* reg_mcc_control_state
  8932. * Current FSM state
  8933. * Access: RO
  8934. */
  8935. MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
  8936. /* reg_mcc_component_size
  8937. * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
  8938. * the size may shorten the update time. Value 0x0 means that size is
  8939. * unspecified.
  8940. * Access: WO
  8941. */
  8942. MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
  8943. static inline void mlxsw_reg_mcc_pack(char *payload,
  8944. enum mlxsw_reg_mcc_instruction instr,
  8945. u16 component_index, u32 update_handle,
  8946. u32 component_size)
  8947. {
  8948. MLXSW_REG_ZERO(mcc, payload);
  8949. mlxsw_reg_mcc_instruction_set(payload, instr);
  8950. mlxsw_reg_mcc_component_index_set(payload, component_index);
  8951. mlxsw_reg_mcc_update_handle_set(payload, update_handle);
  8952. mlxsw_reg_mcc_component_size_set(payload, component_size);
  8953. }
  8954. static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
  8955. u8 *p_error_code, u8 *p_control_state)
  8956. {
  8957. if (p_update_handle)
  8958. *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
  8959. if (p_error_code)
  8960. *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
  8961. if (p_control_state)
  8962. *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
  8963. }
  8964. /* MCDA - Management Component Data Access
  8965. * ---------------------------------------
  8966. * This register allows reading and writing a firmware component.
  8967. */
  8968. #define MLXSW_REG_MCDA_ID 0x9063
  8969. #define MLXSW_REG_MCDA_BASE_LEN 0x10
  8970. #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
  8971. #define MLXSW_REG_MCDA_LEN \
  8972. (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
  8973. MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
  8974. /* reg_mcda_update_handle
  8975. * Token representing the current flow executed by the FSM.
  8976. * Access: RW
  8977. */
  8978. MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
  8979. /* reg_mcda_offset
  8980. * Offset of accessed address relative to component start. Accesses must be in
  8981. * accordance to log_mcda_word_size in MCQI reg.
  8982. * Access: RW
  8983. */
  8984. MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
  8985. /* reg_mcda_size
  8986. * Size of the data accessed, given in bytes.
  8987. * Access: RW
  8988. */
  8989. MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
  8990. /* reg_mcda_data
  8991. * Data block accessed.
  8992. * Access: RW
  8993. */
  8994. MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
  8995. static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
  8996. u32 offset, u16 size, u8 *data)
  8997. {
  8998. int i;
  8999. MLXSW_REG_ZERO(mcda, payload);
  9000. mlxsw_reg_mcda_update_handle_set(payload, update_handle);
  9001. mlxsw_reg_mcda_offset_set(payload, offset);
  9002. mlxsw_reg_mcda_size_set(payload, size);
  9003. for (i = 0; i < size / 4; i++)
  9004. mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
  9005. }
  9006. /* MPSC - Monitoring Packet Sampling Configuration Register
  9007. * --------------------------------------------------------
  9008. * MPSC Register is used to configure the Packet Sampling mechanism.
  9009. */
  9010. #define MLXSW_REG_MPSC_ID 0x9080
  9011. #define MLXSW_REG_MPSC_LEN 0x1C
  9012. MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
  9013. /* reg_mpsc_local_port
  9014. * Local port number
  9015. * Not supported for CPU port
  9016. * Access: Index
  9017. */
  9018. MLXSW_ITEM32_LP(reg, mpsc, 0x00, 16, 0x00, 12);
  9019. /* reg_mpsc_e
  9020. * Enable sampling on port local_port
  9021. * Access: RW
  9022. */
  9023. MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
  9024. #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
  9025. /* reg_mpsc_rate
  9026. * Sampling rate = 1 out of rate packets (with randomization around
  9027. * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
  9028. * Access: RW
  9029. */
  9030. MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
  9031. static inline void mlxsw_reg_mpsc_pack(char *payload, u16 local_port, bool e,
  9032. u32 rate)
  9033. {
  9034. MLXSW_REG_ZERO(mpsc, payload);
  9035. mlxsw_reg_mpsc_local_port_set(payload, local_port);
  9036. mlxsw_reg_mpsc_e_set(payload, e);
  9037. mlxsw_reg_mpsc_rate_set(payload, rate);
  9038. }
  9039. /* MGPC - Monitoring General Purpose Counter Set Register
  9040. * The MGPC register retrieves and sets the General Purpose Counter Set.
  9041. */
  9042. #define MLXSW_REG_MGPC_ID 0x9081
  9043. #define MLXSW_REG_MGPC_LEN 0x18
  9044. MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
  9045. /* reg_mgpc_counter_set_type
  9046. * Counter set type.
  9047. * Access: OP
  9048. */
  9049. MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
  9050. /* reg_mgpc_counter_index
  9051. * Counter index.
  9052. * Access: Index
  9053. */
  9054. MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
  9055. enum mlxsw_reg_mgpc_opcode {
  9056. /* Nop */
  9057. MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
  9058. /* Clear counters */
  9059. MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
  9060. };
  9061. /* reg_mgpc_opcode
  9062. * Opcode.
  9063. * Access: OP
  9064. */
  9065. MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
  9066. /* reg_mgpc_byte_counter
  9067. * Byte counter value.
  9068. * Access: RW
  9069. */
  9070. MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
  9071. /* reg_mgpc_packet_counter
  9072. * Packet counter value.
  9073. * Access: RW
  9074. */
  9075. MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
  9076. static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
  9077. enum mlxsw_reg_mgpc_opcode opcode,
  9078. enum mlxsw_reg_flow_counter_set_type set_type)
  9079. {
  9080. MLXSW_REG_ZERO(mgpc, payload);
  9081. mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
  9082. mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
  9083. mlxsw_reg_mgpc_opcode_set(payload, opcode);
  9084. }
  9085. /* MPRS - Monitoring Parsing State Register
  9086. * ----------------------------------------
  9087. * The MPRS register is used for setting up the parsing for hash,
  9088. * policy-engine and routing.
  9089. */
  9090. #define MLXSW_REG_MPRS_ID 0x9083
  9091. #define MLXSW_REG_MPRS_LEN 0x14
  9092. MLXSW_REG_DEFINE(mprs, MLXSW_REG_MPRS_ID, MLXSW_REG_MPRS_LEN);
  9093. /* reg_mprs_parsing_depth
  9094. * Minimum parsing depth.
  9095. * Need to enlarge parsing depth according to L3, MPLS, tunnels, ACL
  9096. * rules, traps, hash, etc. Default is 96 bytes. Reserved when SwitchX-2.
  9097. * Access: RW
  9098. */
  9099. MLXSW_ITEM32(reg, mprs, parsing_depth, 0x00, 0, 16);
  9100. /* reg_mprs_parsing_en
  9101. * Parsing enable.
  9102. * Bit 0 - Enable parsing of NVE of types VxLAN, VxLAN-GPE, GENEVE and
  9103. * NVGRE. Default is enabled. Reserved when SwitchX-2.
  9104. * Access: RW
  9105. */
  9106. MLXSW_ITEM32(reg, mprs, parsing_en, 0x04, 0, 16);
  9107. /* reg_mprs_vxlan_udp_dport
  9108. * VxLAN UDP destination port.
  9109. * Used for identifying VxLAN packets and for dport field in
  9110. * encapsulation. Default is 4789.
  9111. * Access: RW
  9112. */
  9113. MLXSW_ITEM32(reg, mprs, vxlan_udp_dport, 0x10, 0, 16);
  9114. static inline void mlxsw_reg_mprs_pack(char *payload, u16 parsing_depth,
  9115. u16 vxlan_udp_dport)
  9116. {
  9117. MLXSW_REG_ZERO(mprs, payload);
  9118. mlxsw_reg_mprs_parsing_depth_set(payload, parsing_depth);
  9119. mlxsw_reg_mprs_parsing_en_set(payload, true);
  9120. mlxsw_reg_mprs_vxlan_udp_dport_set(payload, vxlan_udp_dport);
  9121. }
  9122. /* MOGCR - Monitoring Global Configuration Register
  9123. * ------------------------------------------------
  9124. */
  9125. #define MLXSW_REG_MOGCR_ID 0x9086
  9126. #define MLXSW_REG_MOGCR_LEN 0x20
  9127. MLXSW_REG_DEFINE(mogcr, MLXSW_REG_MOGCR_ID, MLXSW_REG_MOGCR_LEN);
  9128. /* reg_mogcr_ptp_iftc
  9129. * PTP Ingress FIFO Trap Clear
  9130. * The PTP_ING_FIFO trap provides MTPPTR with clr according
  9131. * to this value. Default 0.
  9132. * Reserved when IB switches and when SwitchX/-2, Spectrum-2
  9133. * Access: RW
  9134. */
  9135. MLXSW_ITEM32(reg, mogcr, ptp_iftc, 0x00, 1, 1);
  9136. /* reg_mogcr_ptp_eftc
  9137. * PTP Egress FIFO Trap Clear
  9138. * The PTP_EGR_FIFO trap provides MTPPTR with clr according
  9139. * to this value. Default 0.
  9140. * Reserved when IB switches and when SwitchX/-2, Spectrum-2
  9141. * Access: RW
  9142. */
  9143. MLXSW_ITEM32(reg, mogcr, ptp_eftc, 0x00, 0, 1);
  9144. /* reg_mogcr_mirroring_pid_base
  9145. * Base policer id for mirroring policers.
  9146. * Must have an even value (e.g. 1000, not 1001).
  9147. * Reserved when SwitchX/-2, Switch-IB/2, Spectrum-1 and Quantum.
  9148. * Access: RW
  9149. */
  9150. MLXSW_ITEM32(reg, mogcr, mirroring_pid_base, 0x0C, 0, 14);
  9151. /* MPAGR - Monitoring Port Analyzer Global Register
  9152. * ------------------------------------------------
  9153. * This register is used for global port analyzer configurations.
  9154. * Note: This register is not supported by current FW versions for Spectrum-1.
  9155. */
  9156. #define MLXSW_REG_MPAGR_ID 0x9089
  9157. #define MLXSW_REG_MPAGR_LEN 0x0C
  9158. MLXSW_REG_DEFINE(mpagr, MLXSW_REG_MPAGR_ID, MLXSW_REG_MPAGR_LEN);
  9159. enum mlxsw_reg_mpagr_trigger {
  9160. MLXSW_REG_MPAGR_TRIGGER_EGRESS,
  9161. MLXSW_REG_MPAGR_TRIGGER_INGRESS,
  9162. MLXSW_REG_MPAGR_TRIGGER_INGRESS_WRED,
  9163. MLXSW_REG_MPAGR_TRIGGER_INGRESS_SHARED_BUFFER,
  9164. MLXSW_REG_MPAGR_TRIGGER_INGRESS_ING_CONG,
  9165. MLXSW_REG_MPAGR_TRIGGER_INGRESS_EGR_CONG,
  9166. MLXSW_REG_MPAGR_TRIGGER_EGRESS_ECN,
  9167. MLXSW_REG_MPAGR_TRIGGER_EGRESS_HIGH_LATENCY,
  9168. };
  9169. /* reg_mpagr_trigger
  9170. * Mirror trigger.
  9171. * Access: Index
  9172. */
  9173. MLXSW_ITEM32(reg, mpagr, trigger, 0x00, 0, 4);
  9174. /* reg_mpagr_pa_id
  9175. * Port analyzer ID.
  9176. * Access: RW
  9177. */
  9178. MLXSW_ITEM32(reg, mpagr, pa_id, 0x04, 0, 4);
  9179. #define MLXSW_REG_MPAGR_RATE_MAX 3500000000UL
  9180. /* reg_mpagr_probability_rate
  9181. * Sampling rate.
  9182. * Valid values are: 1 to 3.5*10^9
  9183. * Value of 1 means "sample all". Default is 1.
  9184. * Access: RW
  9185. */
  9186. MLXSW_ITEM32(reg, mpagr, probability_rate, 0x08, 0, 32);
  9187. static inline void mlxsw_reg_mpagr_pack(char *payload,
  9188. enum mlxsw_reg_mpagr_trigger trigger,
  9189. u8 pa_id, u32 probability_rate)
  9190. {
  9191. MLXSW_REG_ZERO(mpagr, payload);
  9192. mlxsw_reg_mpagr_trigger_set(payload, trigger);
  9193. mlxsw_reg_mpagr_pa_id_set(payload, pa_id);
  9194. mlxsw_reg_mpagr_probability_rate_set(payload, probability_rate);
  9195. }
  9196. /* MOMTE - Monitoring Mirror Trigger Enable Register
  9197. * -------------------------------------------------
  9198. * This register is used to configure the mirror enable for different mirror
  9199. * reasons.
  9200. */
  9201. #define MLXSW_REG_MOMTE_ID 0x908D
  9202. #define MLXSW_REG_MOMTE_LEN 0x10
  9203. MLXSW_REG_DEFINE(momte, MLXSW_REG_MOMTE_ID, MLXSW_REG_MOMTE_LEN);
  9204. /* reg_momte_local_port
  9205. * Local port number.
  9206. * Access: Index
  9207. */
  9208. MLXSW_ITEM32_LP(reg, momte, 0x00, 16, 0x00, 12);
  9209. enum mlxsw_reg_momte_type {
  9210. MLXSW_REG_MOMTE_TYPE_WRED = 0x20,
  9211. MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS = 0x31,
  9212. MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_TCLASS_DESCRIPTORS = 0x32,
  9213. MLXSW_REG_MOMTE_TYPE_SHARED_BUFFER_EGRESS_PORT = 0x33,
  9214. MLXSW_REG_MOMTE_TYPE_ING_CONG = 0x40,
  9215. MLXSW_REG_MOMTE_TYPE_EGR_CONG = 0x50,
  9216. MLXSW_REG_MOMTE_TYPE_ECN = 0x60,
  9217. MLXSW_REG_MOMTE_TYPE_HIGH_LATENCY = 0x70,
  9218. };
  9219. /* reg_momte_type
  9220. * Type of mirroring.
  9221. * Access: Index
  9222. */
  9223. MLXSW_ITEM32(reg, momte, type, 0x04, 0, 8);
  9224. /* reg_momte_tclass_en
  9225. * TClass/PG mirror enable. Each bit represents corresponding tclass.
  9226. * 0: disable (default)
  9227. * 1: enable
  9228. * Access: RW
  9229. */
  9230. MLXSW_ITEM_BIT_ARRAY(reg, momte, tclass_en, 0x08, 0x08, 1);
  9231. static inline void mlxsw_reg_momte_pack(char *payload, u16 local_port,
  9232. enum mlxsw_reg_momte_type type)
  9233. {
  9234. MLXSW_REG_ZERO(momte, payload);
  9235. mlxsw_reg_momte_local_port_set(payload, local_port);
  9236. mlxsw_reg_momte_type_set(payload, type);
  9237. }
  9238. /* MTPPPC - Time Precision Packet Port Configuration
  9239. * -------------------------------------------------
  9240. * This register serves for configuration of which PTP messages should be
  9241. * timestamped. This is a global configuration, despite the register name.
  9242. *
  9243. * Reserved when Spectrum-2.
  9244. */
  9245. #define MLXSW_REG_MTPPPC_ID 0x9090
  9246. #define MLXSW_REG_MTPPPC_LEN 0x28
  9247. MLXSW_REG_DEFINE(mtpppc, MLXSW_REG_MTPPPC_ID, MLXSW_REG_MTPPPC_LEN);
  9248. /* reg_mtpppc_ing_timestamp_message_type
  9249. * Bitwise vector of PTP message types to timestamp at ingress.
  9250. * MessageType field as defined by IEEE 1588
  9251. * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
  9252. * Default all 0
  9253. * Access: RW
  9254. */
  9255. MLXSW_ITEM32(reg, mtpppc, ing_timestamp_message_type, 0x08, 0, 16);
  9256. /* reg_mtpppc_egr_timestamp_message_type
  9257. * Bitwise vector of PTP message types to timestamp at egress.
  9258. * MessageType field as defined by IEEE 1588
  9259. * Each bit corresponds to a value (e.g. Bit0: Sync, Bit1: Delay_Req)
  9260. * Default all 0
  9261. * Access: RW
  9262. */
  9263. MLXSW_ITEM32(reg, mtpppc, egr_timestamp_message_type, 0x0C, 0, 16);
  9264. static inline void mlxsw_reg_mtpppc_pack(char *payload, u16 ing, u16 egr)
  9265. {
  9266. MLXSW_REG_ZERO(mtpppc, payload);
  9267. mlxsw_reg_mtpppc_ing_timestamp_message_type_set(payload, ing);
  9268. mlxsw_reg_mtpppc_egr_timestamp_message_type_set(payload, egr);
  9269. }
  9270. /* MTPPTR - Time Precision Packet Timestamping Reading
  9271. * ---------------------------------------------------
  9272. * The MTPPTR is used for reading the per port PTP timestamp FIFO.
  9273. * There is a trap for packets which are latched to the timestamp FIFO, thus the
  9274. * SW knows which FIFO to read. Note that packets enter the FIFO before been
  9275. * trapped. The sequence number is used to synchronize the timestamp FIFO
  9276. * entries and the trapped packets.
  9277. * Reserved when Spectrum-2.
  9278. */
  9279. #define MLXSW_REG_MTPPTR_ID 0x9091
  9280. #define MLXSW_REG_MTPPTR_BASE_LEN 0x10 /* base length, without records */
  9281. #define MLXSW_REG_MTPPTR_REC_LEN 0x10 /* record length */
  9282. #define MLXSW_REG_MTPPTR_REC_MAX_COUNT 4
  9283. #define MLXSW_REG_MTPPTR_LEN (MLXSW_REG_MTPPTR_BASE_LEN + \
  9284. MLXSW_REG_MTPPTR_REC_LEN * MLXSW_REG_MTPPTR_REC_MAX_COUNT)
  9285. MLXSW_REG_DEFINE(mtpptr, MLXSW_REG_MTPPTR_ID, MLXSW_REG_MTPPTR_LEN);
  9286. /* reg_mtpptr_local_port
  9287. * Not supported for CPU port.
  9288. * Access: Index
  9289. */
  9290. MLXSW_ITEM32_LP(reg, mtpptr, 0x00, 16, 0x00, 12);
  9291. enum mlxsw_reg_mtpptr_dir {
  9292. MLXSW_REG_MTPPTR_DIR_INGRESS,
  9293. MLXSW_REG_MTPPTR_DIR_EGRESS,
  9294. };
  9295. /* reg_mtpptr_dir
  9296. * Direction.
  9297. * Access: Index
  9298. */
  9299. MLXSW_ITEM32(reg, mtpptr, dir, 0x00, 0, 1);
  9300. /* reg_mtpptr_clr
  9301. * Clear the records.
  9302. * Access: OP
  9303. */
  9304. MLXSW_ITEM32(reg, mtpptr, clr, 0x04, 31, 1);
  9305. /* reg_mtpptr_num_rec
  9306. * Number of valid records in the response
  9307. * Range 0.. cap_ptp_timestamp_fifo
  9308. * Access: RO
  9309. */
  9310. MLXSW_ITEM32(reg, mtpptr, num_rec, 0x08, 0, 4);
  9311. /* reg_mtpptr_rec_message_type
  9312. * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
  9313. * (e.g. Bit0: Sync, Bit1: Delay_Req)
  9314. * Access: RO
  9315. */
  9316. MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_message_type,
  9317. MLXSW_REG_MTPPTR_BASE_LEN, 8, 4,
  9318. MLXSW_REG_MTPPTR_REC_LEN, 0, false);
  9319. /* reg_mtpptr_rec_domain_number
  9320. * DomainNumber field as defined by IEEE 1588
  9321. * Access: RO
  9322. */
  9323. MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_domain_number,
  9324. MLXSW_REG_MTPPTR_BASE_LEN, 0, 8,
  9325. MLXSW_REG_MTPPTR_REC_LEN, 0, false);
  9326. /* reg_mtpptr_rec_sequence_id
  9327. * SequenceId field as defined by IEEE 1588
  9328. * Access: RO
  9329. */
  9330. MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_sequence_id,
  9331. MLXSW_REG_MTPPTR_BASE_LEN, 0, 16,
  9332. MLXSW_REG_MTPPTR_REC_LEN, 0x4, false);
  9333. /* reg_mtpptr_rec_timestamp_high
  9334. * Timestamp of when the PTP packet has passed through the port Units of PLL
  9335. * clock time.
  9336. * For Spectrum-1 the PLL clock is 156.25Mhz and PLL clock time is 6.4nSec.
  9337. * Access: RO
  9338. */
  9339. MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_high,
  9340. MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
  9341. MLXSW_REG_MTPPTR_REC_LEN, 0x8, false);
  9342. /* reg_mtpptr_rec_timestamp_low
  9343. * See rec_timestamp_high.
  9344. * Access: RO
  9345. */
  9346. MLXSW_ITEM32_INDEXED(reg, mtpptr, rec_timestamp_low,
  9347. MLXSW_REG_MTPPTR_BASE_LEN, 0, 32,
  9348. MLXSW_REG_MTPPTR_REC_LEN, 0xC, false);
  9349. static inline void mlxsw_reg_mtpptr_unpack(const char *payload,
  9350. unsigned int rec,
  9351. u8 *p_message_type,
  9352. u8 *p_domain_number,
  9353. u16 *p_sequence_id,
  9354. u64 *p_timestamp)
  9355. {
  9356. u32 timestamp_high, timestamp_low;
  9357. *p_message_type = mlxsw_reg_mtpptr_rec_message_type_get(payload, rec);
  9358. *p_domain_number = mlxsw_reg_mtpptr_rec_domain_number_get(payload, rec);
  9359. *p_sequence_id = mlxsw_reg_mtpptr_rec_sequence_id_get(payload, rec);
  9360. timestamp_high = mlxsw_reg_mtpptr_rec_timestamp_high_get(payload, rec);
  9361. timestamp_low = mlxsw_reg_mtpptr_rec_timestamp_low_get(payload, rec);
  9362. *p_timestamp = (u64)timestamp_high << 32 | timestamp_low;
  9363. }
  9364. /* MTPTPT - Monitoring Precision Time Protocol Trap Register
  9365. * ---------------------------------------------------------
  9366. * This register is used for configuring under which trap to deliver PTP
  9367. * packets depending on type of the packet.
  9368. */
  9369. #define MLXSW_REG_MTPTPT_ID 0x9092
  9370. #define MLXSW_REG_MTPTPT_LEN 0x08
  9371. MLXSW_REG_DEFINE(mtptpt, MLXSW_REG_MTPTPT_ID, MLXSW_REG_MTPTPT_LEN);
  9372. enum mlxsw_reg_mtptpt_trap_id {
  9373. MLXSW_REG_MTPTPT_TRAP_ID_PTP0,
  9374. MLXSW_REG_MTPTPT_TRAP_ID_PTP1,
  9375. };
  9376. /* reg_mtptpt_trap_id
  9377. * Trap id.
  9378. * Access: Index
  9379. */
  9380. MLXSW_ITEM32(reg, mtptpt, trap_id, 0x00, 0, 4);
  9381. /* reg_mtptpt_message_type
  9382. * Bitwise vector of PTP message types to trap. This is a necessary but
  9383. * non-sufficient condition since need to enable also per port. See MTPPPC.
  9384. * Message types are defined by IEEE 1588 Each bit corresponds to a value (e.g.
  9385. * Bit0: Sync, Bit1: Delay_Req)
  9386. */
  9387. MLXSW_ITEM32(reg, mtptpt, message_type, 0x04, 0, 16);
  9388. static inline void mlxsw_reg_mtptpt_pack(char *payload,
  9389. enum mlxsw_reg_mtptpt_trap_id trap_id,
  9390. u16 message_type)
  9391. {
  9392. MLXSW_REG_ZERO(mtptpt, payload);
  9393. mlxsw_reg_mtptpt_trap_id_set(payload, trap_id);
  9394. mlxsw_reg_mtptpt_message_type_set(payload, message_type);
  9395. }
  9396. /* MTPCPC - Monitoring Time Precision Correction Port Configuration Register
  9397. * -------------------------------------------------------------------------
  9398. */
  9399. #define MLXSW_REG_MTPCPC_ID 0x9093
  9400. #define MLXSW_REG_MTPCPC_LEN 0x2C
  9401. MLXSW_REG_DEFINE(mtpcpc, MLXSW_REG_MTPCPC_ID, MLXSW_REG_MTPCPC_LEN);
  9402. /* reg_mtpcpc_pport
  9403. * Per port:
  9404. * 0: config is global. When reading - the local_port is 1.
  9405. * 1: config is per port.
  9406. * Access: Index
  9407. */
  9408. MLXSW_ITEM32(reg, mtpcpc, pport, 0x00, 31, 1);
  9409. /* reg_mtpcpc_local_port
  9410. * Local port number.
  9411. * Supported to/from CPU port.
  9412. * Reserved when pport = 0.
  9413. * Access: Index
  9414. */
  9415. MLXSW_ITEM32_LP(reg, mtpcpc, 0x00, 16, 0x00, 12);
  9416. /* reg_mtpcpc_ptp_trap_en
  9417. * Enable PTP traps.
  9418. * The trap_id is configured by MTPTPT.
  9419. * Access: RW
  9420. */
  9421. MLXSW_ITEM32(reg, mtpcpc, ptp_trap_en, 0x04, 0, 1);
  9422. /* reg_mtpcpc_ing_correction_message_type
  9423. * Bitwise vector of PTP message types to update correction-field at ingress.
  9424. * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
  9425. * (e.g. Bit0: Sync, Bit1: Delay_Req). Supported also from CPU port.
  9426. * Default all 0
  9427. * Access: RW
  9428. */
  9429. MLXSW_ITEM32(reg, mtpcpc, ing_correction_message_type, 0x10, 0, 16);
  9430. /* reg_mtpcpc_egr_correction_message_type
  9431. * Bitwise vector of PTP message types to update correction-field at egress.
  9432. * MessageType field as defined by IEEE 1588 Each bit corresponds to a value
  9433. * (e.g. Bit0: Sync, Bit1: Delay_Req). Supported also from CPU port.
  9434. * Default all 0
  9435. * Access: RW
  9436. */
  9437. MLXSW_ITEM32(reg, mtpcpc, egr_correction_message_type, 0x14, 0, 16);
  9438. static inline void mlxsw_reg_mtpcpc_pack(char *payload, bool pport,
  9439. u16 local_port, bool ptp_trap_en,
  9440. u16 ing, u16 egr)
  9441. {
  9442. MLXSW_REG_ZERO(mtpcpc, payload);
  9443. mlxsw_reg_mtpcpc_pport_set(payload, pport);
  9444. mlxsw_reg_mtpcpc_local_port_set(payload, pport ? local_port : 0);
  9445. mlxsw_reg_mtpcpc_ptp_trap_en_set(payload, ptp_trap_en);
  9446. mlxsw_reg_mtpcpc_ing_correction_message_type_set(payload, ing);
  9447. mlxsw_reg_mtpcpc_egr_correction_message_type_set(payload, egr);
  9448. }
  9449. /* MFGD - Monitoring FW General Debug Register
  9450. * -------------------------------------------
  9451. */
  9452. #define MLXSW_REG_MFGD_ID 0x90F0
  9453. #define MLXSW_REG_MFGD_LEN 0x0C
  9454. MLXSW_REG_DEFINE(mfgd, MLXSW_REG_MFGD_ID, MLXSW_REG_MFGD_LEN);
  9455. /* reg_mfgd_fw_fatal_event_mode
  9456. * 0 - don't check FW fatal (default)
  9457. * 1 - check FW fatal - enable MFDE trap
  9458. * Access: RW
  9459. */
  9460. MLXSW_ITEM32(reg, mfgd, fatal_event_mode, 0x00, 9, 2);
  9461. /* reg_mfgd_trigger_test
  9462. * Access: WO
  9463. */
  9464. MLXSW_ITEM32(reg, mfgd, trigger_test, 0x00, 11, 1);
  9465. /* MGPIR - Management General Peripheral Information Register
  9466. * ----------------------------------------------------------
  9467. * MGPIR register allows software to query the hardware and
  9468. * firmware general information of peripheral entities.
  9469. */
  9470. #define MLXSW_REG_MGPIR_ID 0x9100
  9471. #define MLXSW_REG_MGPIR_LEN 0xA0
  9472. MLXSW_REG_DEFINE(mgpir, MLXSW_REG_MGPIR_ID, MLXSW_REG_MGPIR_LEN);
  9473. enum mlxsw_reg_mgpir_device_type {
  9474. MLXSW_REG_MGPIR_DEVICE_TYPE_NONE,
  9475. MLXSW_REG_MGPIR_DEVICE_TYPE_GEARBOX_DIE,
  9476. };
  9477. /* mgpir_slot_index
  9478. * Slot index (0: Main board).
  9479. * Access: Index
  9480. */
  9481. MLXSW_ITEM32(reg, mgpir, slot_index, 0x00, 28, 4);
  9482. /* mgpir_device_type
  9483. * Access: RO
  9484. */
  9485. MLXSW_ITEM32(reg, mgpir, device_type, 0x00, 24, 4);
  9486. /* mgpir_devices_per_flash
  9487. * Number of devices of device_type per flash (can be shared by few devices).
  9488. * Access: RO
  9489. */
  9490. MLXSW_ITEM32(reg, mgpir, devices_per_flash, 0x00, 16, 8);
  9491. /* mgpir_num_of_devices
  9492. * Number of devices of device_type.
  9493. * Access: RO
  9494. */
  9495. MLXSW_ITEM32(reg, mgpir, num_of_devices, 0x00, 0, 8);
  9496. /* max_modules_per_slot
  9497. * Maximum number of modules that can be connected per slot.
  9498. * Access: RO
  9499. */
  9500. MLXSW_ITEM32(reg, mgpir, max_modules_per_slot, 0x04, 16, 8);
  9501. /* mgpir_num_of_slots
  9502. * Number of slots in the system.
  9503. * Access: RO
  9504. */
  9505. MLXSW_ITEM32(reg, mgpir, num_of_slots, 0x04, 8, 8);
  9506. /* mgpir_num_of_modules
  9507. * Number of modules.
  9508. * Access: RO
  9509. */
  9510. MLXSW_ITEM32(reg, mgpir, num_of_modules, 0x04, 0, 8);
  9511. static inline void mlxsw_reg_mgpir_pack(char *payload, u8 slot_index)
  9512. {
  9513. MLXSW_REG_ZERO(mgpir, payload);
  9514. mlxsw_reg_mgpir_slot_index_set(payload, slot_index);
  9515. }
  9516. static inline void
  9517. mlxsw_reg_mgpir_unpack(char *payload, u8 *num_of_devices,
  9518. enum mlxsw_reg_mgpir_device_type *device_type,
  9519. u8 *devices_per_flash, u8 *num_of_modules,
  9520. u8 *num_of_slots)
  9521. {
  9522. if (num_of_devices)
  9523. *num_of_devices = mlxsw_reg_mgpir_num_of_devices_get(payload);
  9524. if (device_type)
  9525. *device_type = mlxsw_reg_mgpir_device_type_get(payload);
  9526. if (devices_per_flash)
  9527. *devices_per_flash =
  9528. mlxsw_reg_mgpir_devices_per_flash_get(payload);
  9529. if (num_of_modules)
  9530. *num_of_modules = mlxsw_reg_mgpir_num_of_modules_get(payload);
  9531. if (num_of_slots)
  9532. *num_of_slots = mlxsw_reg_mgpir_num_of_slots_get(payload);
  9533. }
  9534. /* MBCT - Management Binary Code Transfer Register
  9535. * -----------------------------------------------
  9536. * This register allows to transfer binary codes from the host to
  9537. * the management FW by transferring it by chunks of maximum 1KB.
  9538. */
  9539. #define MLXSW_REG_MBCT_ID 0x9120
  9540. #define MLXSW_REG_MBCT_LEN 0x420
  9541. MLXSW_REG_DEFINE(mbct, MLXSW_REG_MBCT_ID, MLXSW_REG_MBCT_LEN);
  9542. /* reg_mbct_slot_index
  9543. * Slot index. 0 is reserved.
  9544. * Access: Index
  9545. */
  9546. MLXSW_ITEM32(reg, mbct, slot_index, 0x00, 0, 4);
  9547. /* reg_mbct_data_size
  9548. * Actual data field size in bytes for the current data transfer.
  9549. * Access: WO
  9550. */
  9551. MLXSW_ITEM32(reg, mbct, data_size, 0x04, 0, 11);
  9552. enum mlxsw_reg_mbct_op {
  9553. MLXSW_REG_MBCT_OP_ERASE_INI_IMAGE = 1,
  9554. MLXSW_REG_MBCT_OP_DATA_TRANSFER, /* Download */
  9555. MLXSW_REG_MBCT_OP_ACTIVATE,
  9556. MLXSW_REG_MBCT_OP_CLEAR_ERRORS = 6,
  9557. MLXSW_REG_MBCT_OP_QUERY_STATUS,
  9558. };
  9559. /* reg_mbct_op
  9560. * Access: WO
  9561. */
  9562. MLXSW_ITEM32(reg, mbct, op, 0x08, 28, 4);
  9563. /* reg_mbct_last
  9564. * Indicates that the current data field is the last chunk of the INI.
  9565. * Access: WO
  9566. */
  9567. MLXSW_ITEM32(reg, mbct, last, 0x08, 26, 1);
  9568. /* reg_mbct_oee
  9569. * Opcode Event Enable. When set a BCTOE event will be sent once the opcode
  9570. * was executed and the fsm_state has changed.
  9571. * Access: WO
  9572. */
  9573. MLXSW_ITEM32(reg, mbct, oee, 0x08, 25, 1);
  9574. enum mlxsw_reg_mbct_status {
  9575. /* Partial data transfer completed successfully and ready for next
  9576. * data transfer.
  9577. */
  9578. MLXSW_REG_MBCT_STATUS_PART_DATA = 2,
  9579. MLXSW_REG_MBCT_STATUS_LAST_DATA,
  9580. MLXSW_REG_MBCT_STATUS_ERASE_COMPLETE,
  9581. /* Error - trying to erase INI while it being used. */
  9582. MLXSW_REG_MBCT_STATUS_ERROR_INI_IN_USE,
  9583. /* Last data transfer completed, applying magic pattern. */
  9584. MLXSW_REG_MBCT_STATUS_ERASE_FAILED = 7,
  9585. MLXSW_REG_MBCT_STATUS_INI_ERROR,
  9586. MLXSW_REG_MBCT_STATUS_ACTIVATION_FAILED,
  9587. MLXSW_REG_MBCT_STATUS_ILLEGAL_OPERATION = 11,
  9588. };
  9589. /* reg_mbct_status
  9590. * Status.
  9591. * Access: RO
  9592. */
  9593. MLXSW_ITEM32(reg, mbct, status, 0x0C, 24, 5);
  9594. enum mlxsw_reg_mbct_fsm_state {
  9595. MLXSW_REG_MBCT_FSM_STATE_INI_IN_USE = 5,
  9596. MLXSW_REG_MBCT_FSM_STATE_ERROR,
  9597. };
  9598. /* reg_mbct_fsm_state
  9599. * FSM state.
  9600. * Access: RO
  9601. */
  9602. MLXSW_ITEM32(reg, mbct, fsm_state, 0x0C, 16, 4);
  9603. #define MLXSW_REG_MBCT_DATA_LEN 1024
  9604. /* reg_mbct_data
  9605. * Up to 1KB of data.
  9606. * Access: WO
  9607. */
  9608. MLXSW_ITEM_BUF(reg, mbct, data, 0x20, MLXSW_REG_MBCT_DATA_LEN);
  9609. static inline void mlxsw_reg_mbct_pack(char *payload, u8 slot_index,
  9610. enum mlxsw_reg_mbct_op op, bool oee)
  9611. {
  9612. MLXSW_REG_ZERO(mbct, payload);
  9613. mlxsw_reg_mbct_slot_index_set(payload, slot_index);
  9614. mlxsw_reg_mbct_op_set(payload, op);
  9615. mlxsw_reg_mbct_oee_set(payload, oee);
  9616. }
  9617. static inline void mlxsw_reg_mbct_dt_pack(char *payload,
  9618. u16 data_size, bool last,
  9619. const char *data)
  9620. {
  9621. if (WARN_ON(data_size > MLXSW_REG_MBCT_DATA_LEN))
  9622. return;
  9623. mlxsw_reg_mbct_data_size_set(payload, data_size);
  9624. mlxsw_reg_mbct_last_set(payload, last);
  9625. mlxsw_reg_mbct_data_memcpy_to(payload, data);
  9626. }
  9627. static inline void
  9628. mlxsw_reg_mbct_unpack(const char *payload, u8 *p_slot_index,
  9629. enum mlxsw_reg_mbct_status *p_status,
  9630. enum mlxsw_reg_mbct_fsm_state *p_fsm_state)
  9631. {
  9632. if (p_slot_index)
  9633. *p_slot_index = mlxsw_reg_mbct_slot_index_get(payload);
  9634. *p_status = mlxsw_reg_mbct_status_get(payload);
  9635. if (p_fsm_state)
  9636. *p_fsm_state = mlxsw_reg_mbct_fsm_state_get(payload);
  9637. }
  9638. /* MDDT - Management DownStream Device Tunneling Register
  9639. * ------------------------------------------------------
  9640. * This register allows to deliver query and request messages (PRM registers,
  9641. * commands) to a DownStream device.
  9642. */
  9643. #define MLXSW_REG_MDDT_ID 0x9160
  9644. #define MLXSW_REG_MDDT_LEN 0x110
  9645. MLXSW_REG_DEFINE(mddt, MLXSW_REG_MDDT_ID, MLXSW_REG_MDDT_LEN);
  9646. /* reg_mddt_slot_index
  9647. * Slot index.
  9648. * Access: Index
  9649. */
  9650. MLXSW_ITEM32(reg, mddt, slot_index, 0x00, 8, 4);
  9651. /* reg_mddt_device_index
  9652. * Device index.
  9653. * Access: Index
  9654. */
  9655. MLXSW_ITEM32(reg, mddt, device_index, 0x00, 0, 8);
  9656. /* reg_mddt_read_size
  9657. * Read size in D-Words.
  9658. * Access: OP
  9659. */
  9660. MLXSW_ITEM32(reg, mddt, read_size, 0x04, 24, 8);
  9661. /* reg_mddt_write_size
  9662. * Write size in D-Words.
  9663. * Access: OP
  9664. */
  9665. MLXSW_ITEM32(reg, mddt, write_size, 0x04, 16, 8);
  9666. enum mlxsw_reg_mddt_status {
  9667. MLXSW_REG_MDDT_STATUS_OK,
  9668. };
  9669. /* reg_mddt_status
  9670. * Return code of the Downstream Device to the register that was sent.
  9671. * Access: RO
  9672. */
  9673. MLXSW_ITEM32(reg, mddt, status, 0x0C, 24, 8);
  9674. enum mlxsw_reg_mddt_method {
  9675. MLXSW_REG_MDDT_METHOD_QUERY,
  9676. MLXSW_REG_MDDT_METHOD_WRITE,
  9677. };
  9678. /* reg_mddt_method
  9679. * Access: OP
  9680. */
  9681. MLXSW_ITEM32(reg, mddt, method, 0x0C, 22, 2);
  9682. /* reg_mddt_register_id
  9683. * Access: Index
  9684. */
  9685. MLXSW_ITEM32(reg, mddt, register_id, 0x0C, 0, 16);
  9686. #define MLXSW_REG_MDDT_PAYLOAD_OFFSET 0x0C
  9687. #define MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN 4
  9688. static inline char *mlxsw_reg_mddt_inner_payload(char *payload)
  9689. {
  9690. return payload + MLXSW_REG_MDDT_PAYLOAD_OFFSET +
  9691. MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
  9692. }
  9693. static inline void mlxsw_reg_mddt_pack(char *payload, u8 slot_index,
  9694. u8 device_index,
  9695. enum mlxsw_reg_mddt_method method,
  9696. const struct mlxsw_reg_info *reg,
  9697. char **inner_payload)
  9698. {
  9699. int len = reg->len + MLXSW_REG_MDDT_PRM_REGISTER_HEADER_LEN;
  9700. if (WARN_ON(len + MLXSW_REG_MDDT_PAYLOAD_OFFSET > MLXSW_REG_MDDT_LEN))
  9701. len = MLXSW_REG_MDDT_LEN - MLXSW_REG_MDDT_PAYLOAD_OFFSET;
  9702. MLXSW_REG_ZERO(mddt, payload);
  9703. mlxsw_reg_mddt_slot_index_set(payload, slot_index);
  9704. mlxsw_reg_mddt_device_index_set(payload, device_index);
  9705. mlxsw_reg_mddt_method_set(payload, method);
  9706. mlxsw_reg_mddt_register_id_set(payload, reg->id);
  9707. mlxsw_reg_mddt_read_size_set(payload, len / 4);
  9708. mlxsw_reg_mddt_write_size_set(payload, len / 4);
  9709. *inner_payload = mlxsw_reg_mddt_inner_payload(payload);
  9710. }
  9711. /* MDDQ - Management DownStream Device Query Register
  9712. * --------------------------------------------------
  9713. * This register allows to query the DownStream device properties. The desired
  9714. * information is chosen upon the query_type field and is delivered by 32B
  9715. * of data blocks.
  9716. */
  9717. #define MLXSW_REG_MDDQ_ID 0x9161
  9718. #define MLXSW_REG_MDDQ_LEN 0x30
  9719. MLXSW_REG_DEFINE(mddq, MLXSW_REG_MDDQ_ID, MLXSW_REG_MDDQ_LEN);
  9720. /* reg_mddq_sie
  9721. * Slot info event enable.
  9722. * When set to '1', each change in the slot_info.provisioned / sr_valid /
  9723. * active / ready will generate a DSDSC event.
  9724. * Access: RW
  9725. */
  9726. MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
  9727. enum mlxsw_reg_mddq_query_type {
  9728. MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
  9729. MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices
  9730. * on the slot, data_valid
  9731. * will be '0'.
  9732. */
  9733. MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME,
  9734. };
  9735. /* reg_mddq_query_type
  9736. * Access: Index
  9737. */
  9738. MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
  9739. /* reg_mddq_slot_index
  9740. * Slot index. 0 is reserved.
  9741. * Access: Index
  9742. */
  9743. MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
  9744. /* reg_mddq_response_msg_seq
  9745. * Response message sequential number. For a specific request, the response
  9746. * message sequential number is the following one. In addition, the last
  9747. * message should be 0.
  9748. * Access: RO
  9749. */
  9750. MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8);
  9751. /* reg_mddq_request_msg_seq
  9752. * Request message sequential number.
  9753. * The first message number should be 0.
  9754. * Access: Index
  9755. */
  9756. MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8);
  9757. /* reg_mddq_data_valid
  9758. * If set, the data in the data field is valid and contain the information
  9759. * for the queried index.
  9760. * Access: RO
  9761. */
  9762. MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1);
  9763. /* reg_mddq_slot_info_provisioned
  9764. * If set, the INI file is applied and the card is provisioned.
  9765. * Access: RO
  9766. */
  9767. MLXSW_ITEM32(reg, mddq, slot_info_provisioned, 0x10, 31, 1);
  9768. /* reg_mddq_slot_info_sr_valid
  9769. * If set, Shift Register is valid (after being provisioned) and data
  9770. * can be sent from the switch ASIC to the line-card CPLD over Shift-Register.
  9771. * Access: RO
  9772. */
  9773. MLXSW_ITEM32(reg, mddq, slot_info_sr_valid, 0x10, 30, 1);
  9774. enum mlxsw_reg_mddq_slot_info_ready {
  9775. MLXSW_REG_MDDQ_SLOT_INFO_READY_NOT_READY,
  9776. MLXSW_REG_MDDQ_SLOT_INFO_READY_READY,
  9777. MLXSW_REG_MDDQ_SLOT_INFO_READY_ERROR,
  9778. };
  9779. /* reg_mddq_slot_info_lc_ready
  9780. * If set, the LC is powered on, matching the INI version and a new FW
  9781. * version can be burnt (if necessary).
  9782. * Access: RO
  9783. */
  9784. MLXSW_ITEM32(reg, mddq, slot_info_lc_ready, 0x10, 28, 2);
  9785. /* reg_mddq_slot_info_active
  9786. * If set, the FW has completed the MDDC.device_enable command.
  9787. * Access: RO
  9788. */
  9789. MLXSW_ITEM32(reg, mddq, slot_info_active, 0x10, 27, 1);
  9790. /* reg_mddq_slot_info_hw_revision
  9791. * Major user-configured version number of the current INI file.
  9792. * Valid only when active or ready are '1'.
  9793. * Access: RO
  9794. */
  9795. MLXSW_ITEM32(reg, mddq, slot_info_hw_revision, 0x14, 16, 16);
  9796. /* reg_mddq_slot_info_ini_file_version
  9797. * User-configured version number of the current INI file.
  9798. * Valid only when active or lc_ready are '1'.
  9799. * Access: RO
  9800. */
  9801. MLXSW_ITEM32(reg, mddq, slot_info_ini_file_version, 0x14, 0, 16);
  9802. /* reg_mddq_slot_info_card_type
  9803. * Access: RO
  9804. */
  9805. MLXSW_ITEM32(reg, mddq, slot_info_card_type, 0x18, 0, 8);
  9806. static inline void
  9807. __mlxsw_reg_mddq_pack(char *payload, u8 slot_index,
  9808. enum mlxsw_reg_mddq_query_type query_type)
  9809. {
  9810. MLXSW_REG_ZERO(mddq, payload);
  9811. mlxsw_reg_mddq_slot_index_set(payload, slot_index);
  9812. mlxsw_reg_mddq_query_type_set(payload, query_type);
  9813. }
  9814. static inline void
  9815. mlxsw_reg_mddq_slot_info_pack(char *payload, u8 slot_index, bool sie)
  9816. {
  9817. __mlxsw_reg_mddq_pack(payload, slot_index,
  9818. MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO);
  9819. mlxsw_reg_mddq_sie_set(payload, sie);
  9820. }
  9821. static inline void
  9822. mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
  9823. bool *p_provisioned, bool *p_sr_valid,
  9824. enum mlxsw_reg_mddq_slot_info_ready *p_lc_ready,
  9825. bool *p_active, u16 *p_hw_revision,
  9826. u16 *p_ini_file_version,
  9827. u8 *p_card_type)
  9828. {
  9829. *p_slot_index = mlxsw_reg_mddq_slot_index_get(payload);
  9830. *p_provisioned = mlxsw_reg_mddq_slot_info_provisioned_get(payload);
  9831. *p_sr_valid = mlxsw_reg_mddq_slot_info_sr_valid_get(payload);
  9832. *p_lc_ready = mlxsw_reg_mddq_slot_info_lc_ready_get(payload);
  9833. *p_active = mlxsw_reg_mddq_slot_info_active_get(payload);
  9834. *p_hw_revision = mlxsw_reg_mddq_slot_info_hw_revision_get(payload);
  9835. *p_ini_file_version = mlxsw_reg_mddq_slot_info_ini_file_version_get(payload);
  9836. *p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload);
  9837. }
  9838. /* reg_mddq_device_info_flash_owner
  9839. * If set, the device is the flash owner. Otherwise, a shared flash
  9840. * is used by this device (another device is the flash owner).
  9841. * Access: RO
  9842. */
  9843. MLXSW_ITEM32(reg, mddq, device_info_flash_owner, 0x10, 30, 1);
  9844. /* reg_mddq_device_info_device_index
  9845. * Device index. The first device should number 0.
  9846. * Access: RO
  9847. */
  9848. MLXSW_ITEM32(reg, mddq, device_info_device_index, 0x10, 0, 8);
  9849. /* reg_mddq_device_info_fw_major
  9850. * Major FW version number.
  9851. * Access: RO
  9852. */
  9853. MLXSW_ITEM32(reg, mddq, device_info_fw_major, 0x14, 16, 16);
  9854. /* reg_mddq_device_info_fw_minor
  9855. * Minor FW version number.
  9856. * Access: RO
  9857. */
  9858. MLXSW_ITEM32(reg, mddq, device_info_fw_minor, 0x18, 16, 16);
  9859. /* reg_mddq_device_info_fw_sub_minor
  9860. * Sub-minor FW version number.
  9861. * Access: RO
  9862. */
  9863. MLXSW_ITEM32(reg, mddq, device_info_fw_sub_minor, 0x18, 0, 16);
  9864. static inline void
  9865. mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index,
  9866. u8 request_msg_seq)
  9867. {
  9868. __mlxsw_reg_mddq_pack(payload, slot_index,
  9869. MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO);
  9870. mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq);
  9871. }
  9872. static inline void
  9873. mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq,
  9874. bool *p_data_valid, bool *p_flash_owner,
  9875. u8 *p_device_index, u16 *p_fw_major,
  9876. u16 *p_fw_minor, u16 *p_fw_sub_minor)
  9877. {
  9878. *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload);
  9879. *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload);
  9880. *p_flash_owner = mlxsw_reg_mddq_device_info_flash_owner_get(payload);
  9881. *p_device_index = mlxsw_reg_mddq_device_info_device_index_get(payload);
  9882. *p_fw_major = mlxsw_reg_mddq_device_info_fw_major_get(payload);
  9883. *p_fw_minor = mlxsw_reg_mddq_device_info_fw_minor_get(payload);
  9884. *p_fw_sub_minor = mlxsw_reg_mddq_device_info_fw_sub_minor_get(payload);
  9885. }
  9886. #define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20
  9887. /* reg_mddq_slot_ascii_name
  9888. * Slot's ASCII name.
  9889. * Access: RO
  9890. */
  9891. MLXSW_ITEM_BUF(reg, mddq, slot_ascii_name, 0x10,
  9892. MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN);
  9893. static inline void
  9894. mlxsw_reg_mddq_slot_name_pack(char *payload, u8 slot_index)
  9895. {
  9896. __mlxsw_reg_mddq_pack(payload, slot_index,
  9897. MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME);
  9898. }
  9899. static inline void
  9900. mlxsw_reg_mddq_slot_name_unpack(const char *payload, char *slot_ascii_name)
  9901. {
  9902. mlxsw_reg_mddq_slot_ascii_name_memcpy_from(payload, slot_ascii_name);
  9903. }
  9904. /* MDDC - Management DownStream Device Control Register
  9905. * ----------------------------------------------------
  9906. * This register allows to control downstream devices and line cards.
  9907. */
  9908. #define MLXSW_REG_MDDC_ID 0x9163
  9909. #define MLXSW_REG_MDDC_LEN 0x30
  9910. MLXSW_REG_DEFINE(mddc, MLXSW_REG_MDDC_ID, MLXSW_REG_MDDC_LEN);
  9911. /* reg_mddc_slot_index
  9912. * Slot index. 0 is reserved.
  9913. * Access: Index
  9914. */
  9915. MLXSW_ITEM32(reg, mddc, slot_index, 0x00, 0, 4);
  9916. /* reg_mddc_rst
  9917. * Reset request.
  9918. * Access: OP
  9919. */
  9920. MLXSW_ITEM32(reg, mddc, rst, 0x04, 29, 1);
  9921. /* reg_mddc_device_enable
  9922. * When set, FW is the manager and allowed to program the downstream device.
  9923. * Access: RW
  9924. */
  9925. MLXSW_ITEM32(reg, mddc, device_enable, 0x04, 28, 1);
  9926. static inline void mlxsw_reg_mddc_pack(char *payload, u8 slot_index, bool rst,
  9927. bool device_enable)
  9928. {
  9929. MLXSW_REG_ZERO(mddc, payload);
  9930. mlxsw_reg_mddc_slot_index_set(payload, slot_index);
  9931. mlxsw_reg_mddc_rst_set(payload, rst);
  9932. mlxsw_reg_mddc_device_enable_set(payload, device_enable);
  9933. }
  9934. /* MFDE - Monitoring FW Debug Register
  9935. * -----------------------------------
  9936. */
  9937. #define MLXSW_REG_MFDE_ID 0x9200
  9938. #define MLXSW_REG_MFDE_LEN 0x30
  9939. MLXSW_REG_DEFINE(mfde, MLXSW_REG_MFDE_ID, MLXSW_REG_MFDE_LEN);
  9940. /* reg_mfde_irisc_id
  9941. * Which irisc triggered the event
  9942. * Access: RO
  9943. */
  9944. MLXSW_ITEM32(reg, mfde, irisc_id, 0x00, 24, 8);
  9945. enum mlxsw_reg_mfde_severity {
  9946. /* Unrecoverable switch behavior */
  9947. MLXSW_REG_MFDE_SEVERITY_FATL = 2,
  9948. /* Unexpected state with possible systemic failure */
  9949. MLXSW_REG_MFDE_SEVERITY_NRML = 3,
  9950. /* Unexpected state without systemic failure */
  9951. MLXSW_REG_MFDE_SEVERITY_INTR = 5,
  9952. };
  9953. /* reg_mfde_severity
  9954. * The severity of the event.
  9955. * Access: RO
  9956. */
  9957. MLXSW_ITEM32(reg, mfde, severity, 0x00, 16, 8);
  9958. enum mlxsw_reg_mfde_event_id {
  9959. /* CRspace timeout */
  9960. MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO = 1,
  9961. /* KVD insertion machine stopped */
  9962. MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP,
  9963. /* Triggered by MFGD.trigger_test */
  9964. MLXSW_REG_MFDE_EVENT_ID_TEST,
  9965. /* Triggered when firmware hits an assert */
  9966. MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT,
  9967. /* Fatal error interrupt from hardware */
  9968. MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE,
  9969. };
  9970. /* reg_mfde_event_id
  9971. * Access: RO
  9972. */
  9973. MLXSW_ITEM32(reg, mfde, event_id, 0x00, 0, 16);
  9974. enum mlxsw_reg_mfde_method {
  9975. MLXSW_REG_MFDE_METHOD_QUERY,
  9976. MLXSW_REG_MFDE_METHOD_WRITE,
  9977. };
  9978. /* reg_mfde_method
  9979. * Access: RO
  9980. */
  9981. MLXSW_ITEM32(reg, mfde, method, 0x04, 29, 1);
  9982. /* reg_mfde_long_process
  9983. * Indicates if the command is in long_process mode.
  9984. * Access: RO
  9985. */
  9986. MLXSW_ITEM32(reg, mfde, long_process, 0x04, 28, 1);
  9987. enum mlxsw_reg_mfde_command_type {
  9988. MLXSW_REG_MFDE_COMMAND_TYPE_MAD,
  9989. MLXSW_REG_MFDE_COMMAND_TYPE_EMAD,
  9990. MLXSW_REG_MFDE_COMMAND_TYPE_CMDIF,
  9991. };
  9992. /* reg_mfde_command_type
  9993. * Access: RO
  9994. */
  9995. MLXSW_ITEM32(reg, mfde, command_type, 0x04, 24, 2);
  9996. /* reg_mfde_reg_attr_id
  9997. * EMAD - register id, MAD - attibute id
  9998. * Access: RO
  9999. */
  10000. MLXSW_ITEM32(reg, mfde, reg_attr_id, 0x04, 0, 16);
  10001. /* reg_mfde_crspace_to_log_address
  10002. * crspace address accessed, which resulted in timeout.
  10003. * Access: RO
  10004. */
  10005. MLXSW_ITEM32(reg, mfde, crspace_to_log_address, 0x10, 0, 32);
  10006. /* reg_mfde_crspace_to_oe
  10007. * 0 - New event
  10008. * 1 - Old event, occurred before MFGD activation.
  10009. * Access: RO
  10010. */
  10011. MLXSW_ITEM32(reg, mfde, crspace_to_oe, 0x14, 24, 1);
  10012. /* reg_mfde_crspace_to_log_id
  10013. * Which irisc triggered the timeout.
  10014. * Access: RO
  10015. */
  10016. MLXSW_ITEM32(reg, mfde, crspace_to_log_id, 0x14, 0, 4);
  10017. /* reg_mfde_crspace_to_log_ip
  10018. * IP (instruction pointer) that triggered the timeout.
  10019. * Access: RO
  10020. */
  10021. MLXSW_ITEM64(reg, mfde, crspace_to_log_ip, 0x18, 0, 64);
  10022. /* reg_mfde_kvd_im_stop_oe
  10023. * 0 - New event
  10024. * 1 - Old event, occurred before MFGD activation.
  10025. * Access: RO
  10026. */
  10027. MLXSW_ITEM32(reg, mfde, kvd_im_stop_oe, 0x10, 24, 1);
  10028. /* reg_mfde_kvd_im_stop_pipes_mask
  10029. * Bit per kvh pipe.
  10030. * Access: RO
  10031. */
  10032. MLXSW_ITEM32(reg, mfde, kvd_im_stop_pipes_mask, 0x10, 0, 16);
  10033. /* reg_mfde_fw_assert_var0-4
  10034. * Variables passed to assert.
  10035. * Access: RO
  10036. */
  10037. MLXSW_ITEM32(reg, mfde, fw_assert_var0, 0x10, 0, 32);
  10038. MLXSW_ITEM32(reg, mfde, fw_assert_var1, 0x14, 0, 32);
  10039. MLXSW_ITEM32(reg, mfde, fw_assert_var2, 0x18, 0, 32);
  10040. MLXSW_ITEM32(reg, mfde, fw_assert_var3, 0x1C, 0, 32);
  10041. MLXSW_ITEM32(reg, mfde, fw_assert_var4, 0x20, 0, 32);
  10042. /* reg_mfde_fw_assert_existptr
  10043. * The instruction pointer when assert was triggered.
  10044. * Access: RO
  10045. */
  10046. MLXSW_ITEM32(reg, mfde, fw_assert_existptr, 0x24, 0, 32);
  10047. /* reg_mfde_fw_assert_callra
  10048. * The return address after triggering assert.
  10049. * Access: RO
  10050. */
  10051. MLXSW_ITEM32(reg, mfde, fw_assert_callra, 0x28, 0, 32);
  10052. /* reg_mfde_fw_assert_oe
  10053. * 0 - New event
  10054. * 1 - Old event, occurred before MFGD activation.
  10055. * Access: RO
  10056. */
  10057. MLXSW_ITEM32(reg, mfde, fw_assert_oe, 0x2C, 24, 1);
  10058. /* reg_mfde_fw_assert_tile_v
  10059. * 0: The assert was from main
  10060. * 1: The assert was from a tile
  10061. * Access: RO
  10062. */
  10063. MLXSW_ITEM32(reg, mfde, fw_assert_tile_v, 0x2C, 23, 1);
  10064. /* reg_mfde_fw_assert_tile_index
  10065. * When tile_v=1, the tile_index that caused the assert.
  10066. * Access: RO
  10067. */
  10068. MLXSW_ITEM32(reg, mfde, fw_assert_tile_index, 0x2C, 16, 6);
  10069. /* reg_mfde_fw_assert_ext_synd
  10070. * A generated one-to-one identifier which is specific per-assert.
  10071. * Access: RO
  10072. */
  10073. MLXSW_ITEM32(reg, mfde, fw_assert_ext_synd, 0x2C, 0, 16);
  10074. /* reg_mfde_fatal_cause_id
  10075. * HW interrupt cause id.
  10076. * Access: RO
  10077. */
  10078. MLXSW_ITEM32(reg, mfde, fatal_cause_id, 0x10, 0, 18);
  10079. /* reg_mfde_fatal_cause_tile_v
  10080. * 0: The assert was from main
  10081. * 1: The assert was from a tile
  10082. * Access: RO
  10083. */
  10084. MLXSW_ITEM32(reg, mfde, fatal_cause_tile_v, 0x14, 23, 1);
  10085. /* reg_mfde_fatal_cause_tile_index
  10086. * When tile_v=1, the tile_index that caused the assert.
  10087. * Access: RO
  10088. */
  10089. MLXSW_ITEM32(reg, mfde, fatal_cause_tile_index, 0x14, 16, 6);
  10090. /* TNGCR - Tunneling NVE General Configuration Register
  10091. * ----------------------------------------------------
  10092. * The TNGCR register is used for setting up the NVE Tunneling configuration.
  10093. */
  10094. #define MLXSW_REG_TNGCR_ID 0xA001
  10095. #define MLXSW_REG_TNGCR_LEN 0x44
  10096. MLXSW_REG_DEFINE(tngcr, MLXSW_REG_TNGCR_ID, MLXSW_REG_TNGCR_LEN);
  10097. enum mlxsw_reg_tngcr_type {
  10098. MLXSW_REG_TNGCR_TYPE_VXLAN,
  10099. MLXSW_REG_TNGCR_TYPE_VXLAN_GPE,
  10100. MLXSW_REG_TNGCR_TYPE_GENEVE,
  10101. MLXSW_REG_TNGCR_TYPE_NVGRE,
  10102. };
  10103. /* reg_tngcr_type
  10104. * Tunnel type for encapsulation and decapsulation. The types are mutually
  10105. * exclusive.
  10106. * Note: For Spectrum the NVE parsing must be enabled in MPRS.
  10107. * Access: RW
  10108. */
  10109. MLXSW_ITEM32(reg, tngcr, type, 0x00, 0, 4);
  10110. /* reg_tngcr_nve_valid
  10111. * The VTEP is valid. Allows adding FDB entries for tunnel encapsulation.
  10112. * Access: RW
  10113. */
  10114. MLXSW_ITEM32(reg, tngcr, nve_valid, 0x04, 31, 1);
  10115. /* reg_tngcr_nve_ttl_uc
  10116. * The TTL for NVE tunnel encapsulation underlay unicast packets.
  10117. * Access: RW
  10118. */
  10119. MLXSW_ITEM32(reg, tngcr, nve_ttl_uc, 0x04, 0, 8);
  10120. /* reg_tngcr_nve_ttl_mc
  10121. * The TTL for NVE tunnel encapsulation underlay multicast packets.
  10122. * Access: RW
  10123. */
  10124. MLXSW_ITEM32(reg, tngcr, nve_ttl_mc, 0x08, 0, 8);
  10125. enum {
  10126. /* Do not copy flow label. Calculate flow label using nve_flh. */
  10127. MLXSW_REG_TNGCR_FL_NO_COPY,
  10128. /* Copy flow label from inner packet if packet is IPv6 and
  10129. * encapsulation is by IPv6. Otherwise, calculate flow label using
  10130. * nve_flh.
  10131. */
  10132. MLXSW_REG_TNGCR_FL_COPY,
  10133. };
  10134. /* reg_tngcr_nve_flc
  10135. * For NVE tunnel encapsulation: Flow label copy from inner packet.
  10136. * Access: RW
  10137. */
  10138. MLXSW_ITEM32(reg, tngcr, nve_flc, 0x0C, 25, 1);
  10139. enum {
  10140. /* Flow label is static. In Spectrum this means '0'. Spectrum-2
  10141. * uses {nve_fl_prefix, nve_fl_suffix}.
  10142. */
  10143. MLXSW_REG_TNGCR_FL_NO_HASH,
  10144. /* 8 LSBs of the flow label are calculated from ECMP hash of the
  10145. * inner packet. 12 MSBs are configured by nve_fl_prefix.
  10146. */
  10147. MLXSW_REG_TNGCR_FL_HASH,
  10148. };
  10149. /* reg_tngcr_nve_flh
  10150. * NVE flow label hash.
  10151. * Access: RW
  10152. */
  10153. MLXSW_ITEM32(reg, tngcr, nve_flh, 0x0C, 24, 1);
  10154. /* reg_tngcr_nve_fl_prefix
  10155. * NVE flow label prefix. Constant 12 MSBs of the flow label.
  10156. * Access: RW
  10157. */
  10158. MLXSW_ITEM32(reg, tngcr, nve_fl_prefix, 0x0C, 8, 12);
  10159. /* reg_tngcr_nve_fl_suffix
  10160. * NVE flow label suffix. Constant 8 LSBs of the flow label.
  10161. * Reserved when nve_flh=1 and for Spectrum.
  10162. * Access: RW
  10163. */
  10164. MLXSW_ITEM32(reg, tngcr, nve_fl_suffix, 0x0C, 0, 8);
  10165. enum {
  10166. /* Source UDP port is fixed (default '0') */
  10167. MLXSW_REG_TNGCR_UDP_SPORT_NO_HASH,
  10168. /* Source UDP port is calculated based on hash */
  10169. MLXSW_REG_TNGCR_UDP_SPORT_HASH,
  10170. };
  10171. /* reg_tngcr_nve_udp_sport_type
  10172. * NVE UDP source port type.
  10173. * Spectrum uses LAG hash (SLCRv2). Spectrum-2 uses ECMP hash (RECRv2).
  10174. * When the source UDP port is calculated based on hash, then the 8 LSBs
  10175. * are calculated from hash the 8 MSBs are configured by
  10176. * nve_udp_sport_prefix.
  10177. * Access: RW
  10178. */
  10179. MLXSW_ITEM32(reg, tngcr, nve_udp_sport_type, 0x10, 24, 1);
  10180. /* reg_tngcr_nve_udp_sport_prefix
  10181. * NVE UDP source port prefix. Constant 8 MSBs of the UDP source port.
  10182. * Reserved when NVE type is NVGRE.
  10183. * Access: RW
  10184. */
  10185. MLXSW_ITEM32(reg, tngcr, nve_udp_sport_prefix, 0x10, 8, 8);
  10186. /* reg_tngcr_nve_group_size_mc
  10187. * The amount of sequential linked lists of MC entries. The first linked
  10188. * list is configured by SFD.underlay_mc_ptr.
  10189. * Valid values: 1, 2, 4, 8, 16, 32, 64
  10190. * The linked list are configured by TNUMT.
  10191. * The hash is set by LAG hash.
  10192. * Access: RW
  10193. */
  10194. MLXSW_ITEM32(reg, tngcr, nve_group_size_mc, 0x18, 0, 8);
  10195. /* reg_tngcr_nve_group_size_flood
  10196. * The amount of sequential linked lists of flooding entries. The first
  10197. * linked list is configured by SFMR.nve_tunnel_flood_ptr
  10198. * Valid values: 1, 2, 4, 8, 16, 32, 64
  10199. * The linked list are configured by TNUMT.
  10200. * The hash is set by LAG hash.
  10201. * Access: RW
  10202. */
  10203. MLXSW_ITEM32(reg, tngcr, nve_group_size_flood, 0x1C, 0, 8);
  10204. /* reg_tngcr_learn_enable
  10205. * During decapsulation, whether to learn from NVE port.
  10206. * Reserved when Spectrum-2. See TNPC.
  10207. * Access: RW
  10208. */
  10209. MLXSW_ITEM32(reg, tngcr, learn_enable, 0x20, 31, 1);
  10210. /* reg_tngcr_underlay_virtual_router
  10211. * Underlay virtual router.
  10212. * Reserved when Spectrum-2.
  10213. * Access: RW
  10214. */
  10215. MLXSW_ITEM32(reg, tngcr, underlay_virtual_router, 0x20, 0, 16);
  10216. /* reg_tngcr_underlay_rif
  10217. * Underlay ingress router interface. RIF type should be loopback generic.
  10218. * Reserved when Spectrum.
  10219. * Access: RW
  10220. */
  10221. MLXSW_ITEM32(reg, tngcr, underlay_rif, 0x24, 0, 16);
  10222. /* reg_tngcr_usipv4
  10223. * Underlay source IPv4 address of the NVE.
  10224. * Access: RW
  10225. */
  10226. MLXSW_ITEM32(reg, tngcr, usipv4, 0x28, 0, 32);
  10227. /* reg_tngcr_usipv6
  10228. * Underlay source IPv6 address of the NVE. For Spectrum, must not be
  10229. * modified under traffic of NVE tunneling encapsulation.
  10230. * Access: RW
  10231. */
  10232. MLXSW_ITEM_BUF(reg, tngcr, usipv6, 0x30, 16);
  10233. static inline void mlxsw_reg_tngcr_pack(char *payload,
  10234. enum mlxsw_reg_tngcr_type type,
  10235. bool valid, u8 ttl)
  10236. {
  10237. MLXSW_REG_ZERO(tngcr, payload);
  10238. mlxsw_reg_tngcr_type_set(payload, type);
  10239. mlxsw_reg_tngcr_nve_valid_set(payload, valid);
  10240. mlxsw_reg_tngcr_nve_ttl_uc_set(payload, ttl);
  10241. mlxsw_reg_tngcr_nve_ttl_mc_set(payload, ttl);
  10242. mlxsw_reg_tngcr_nve_flc_set(payload, MLXSW_REG_TNGCR_FL_NO_COPY);
  10243. mlxsw_reg_tngcr_nve_flh_set(payload, 0);
  10244. mlxsw_reg_tngcr_nve_udp_sport_type_set(payload,
  10245. MLXSW_REG_TNGCR_UDP_SPORT_HASH);
  10246. mlxsw_reg_tngcr_nve_udp_sport_prefix_set(payload, 0);
  10247. mlxsw_reg_tngcr_nve_group_size_mc_set(payload, 1);
  10248. mlxsw_reg_tngcr_nve_group_size_flood_set(payload, 1);
  10249. }
  10250. /* TNUMT - Tunneling NVE Underlay Multicast Table Register
  10251. * -------------------------------------------------------
  10252. * The TNUMT register is for building the underlay MC table. It is used
  10253. * for MC, flooding and BC traffic into the NVE tunnel.
  10254. */
  10255. #define MLXSW_REG_TNUMT_ID 0xA003
  10256. #define MLXSW_REG_TNUMT_LEN 0x20
  10257. MLXSW_REG_DEFINE(tnumt, MLXSW_REG_TNUMT_ID, MLXSW_REG_TNUMT_LEN);
  10258. enum mlxsw_reg_tnumt_record_type {
  10259. MLXSW_REG_TNUMT_RECORD_TYPE_IPV4,
  10260. MLXSW_REG_TNUMT_RECORD_TYPE_IPV6,
  10261. MLXSW_REG_TNUMT_RECORD_TYPE_LABEL,
  10262. };
  10263. /* reg_tnumt_record_type
  10264. * Record type.
  10265. * Access: RW
  10266. */
  10267. MLXSW_ITEM32(reg, tnumt, record_type, 0x00, 28, 4);
  10268. /* reg_tnumt_tunnel_port
  10269. * Tunnel port.
  10270. * Access: RW
  10271. */
  10272. MLXSW_ITEM32(reg, tnumt, tunnel_port, 0x00, 24, 4);
  10273. /* reg_tnumt_underlay_mc_ptr
  10274. * Index to the underlay multicast table.
  10275. * For Spectrum the index is to the KVD linear.
  10276. * Access: Index
  10277. */
  10278. MLXSW_ITEM32(reg, tnumt, underlay_mc_ptr, 0x00, 0, 24);
  10279. /* reg_tnumt_vnext
  10280. * The next_underlay_mc_ptr is valid.
  10281. * Access: RW
  10282. */
  10283. MLXSW_ITEM32(reg, tnumt, vnext, 0x04, 31, 1);
  10284. /* reg_tnumt_next_underlay_mc_ptr
  10285. * The next index to the underlay multicast table.
  10286. * Access: RW
  10287. */
  10288. MLXSW_ITEM32(reg, tnumt, next_underlay_mc_ptr, 0x04, 0, 24);
  10289. /* reg_tnumt_record_size
  10290. * Number of IP addresses in the record.
  10291. * Range is 1..cap_max_nve_mc_entries_ipv{4,6}
  10292. * Access: RW
  10293. */
  10294. MLXSW_ITEM32(reg, tnumt, record_size, 0x08, 0, 3);
  10295. /* reg_tnumt_udip
  10296. * The underlay IPv4 addresses. udip[i] is reserved if i >= size
  10297. * Access: RW
  10298. */
  10299. MLXSW_ITEM32_INDEXED(reg, tnumt, udip, 0x0C, 0, 32, 0x04, 0x00, false);
  10300. /* reg_tnumt_udip_ptr
  10301. * The pointer to the underlay IPv6 addresses. udip_ptr[i] is reserved if
  10302. * i >= size. The IPv6 addresses are configured by RIPS.
  10303. * Access: RW
  10304. */
  10305. MLXSW_ITEM32_INDEXED(reg, tnumt, udip_ptr, 0x0C, 0, 24, 0x04, 0x00, false);
  10306. static inline void mlxsw_reg_tnumt_pack(char *payload,
  10307. enum mlxsw_reg_tnumt_record_type type,
  10308. enum mlxsw_reg_tunnel_port tport,
  10309. u32 underlay_mc_ptr, bool vnext,
  10310. u32 next_underlay_mc_ptr,
  10311. u8 record_size)
  10312. {
  10313. MLXSW_REG_ZERO(tnumt, payload);
  10314. mlxsw_reg_tnumt_record_type_set(payload, type);
  10315. mlxsw_reg_tnumt_tunnel_port_set(payload, tport);
  10316. mlxsw_reg_tnumt_underlay_mc_ptr_set(payload, underlay_mc_ptr);
  10317. mlxsw_reg_tnumt_vnext_set(payload, vnext);
  10318. mlxsw_reg_tnumt_next_underlay_mc_ptr_set(payload, next_underlay_mc_ptr);
  10319. mlxsw_reg_tnumt_record_size_set(payload, record_size);
  10320. }
  10321. /* TNQCR - Tunneling NVE QoS Configuration Register
  10322. * ------------------------------------------------
  10323. * The TNQCR register configures how QoS is set in encapsulation into the
  10324. * underlay network.
  10325. */
  10326. #define MLXSW_REG_TNQCR_ID 0xA010
  10327. #define MLXSW_REG_TNQCR_LEN 0x0C
  10328. MLXSW_REG_DEFINE(tnqcr, MLXSW_REG_TNQCR_ID, MLXSW_REG_TNQCR_LEN);
  10329. /* reg_tnqcr_enc_set_dscp
  10330. * For encapsulation: How to set DSCP field:
  10331. * 0 - Copy the DSCP from the overlay (inner) IP header to the underlay
  10332. * (outer) IP header. If there is no IP header, use TNQDR.dscp
  10333. * 1 - Set the DSCP field as TNQDR.dscp
  10334. * Access: RW
  10335. */
  10336. MLXSW_ITEM32(reg, tnqcr, enc_set_dscp, 0x04, 28, 1);
  10337. static inline void mlxsw_reg_tnqcr_pack(char *payload)
  10338. {
  10339. MLXSW_REG_ZERO(tnqcr, payload);
  10340. mlxsw_reg_tnqcr_enc_set_dscp_set(payload, 0);
  10341. }
  10342. /* TNQDR - Tunneling NVE QoS Default Register
  10343. * ------------------------------------------
  10344. * The TNQDR register configures the default QoS settings for NVE
  10345. * encapsulation.
  10346. */
  10347. #define MLXSW_REG_TNQDR_ID 0xA011
  10348. #define MLXSW_REG_TNQDR_LEN 0x08
  10349. MLXSW_REG_DEFINE(tnqdr, MLXSW_REG_TNQDR_ID, MLXSW_REG_TNQDR_LEN);
  10350. /* reg_tnqdr_local_port
  10351. * Local port number (receive port). CPU port is supported.
  10352. * Access: Index
  10353. */
  10354. MLXSW_ITEM32_LP(reg, tnqdr, 0x00, 16, 0x00, 12);
  10355. /* reg_tnqdr_dscp
  10356. * For encapsulation, the default DSCP.
  10357. * Access: RW
  10358. */
  10359. MLXSW_ITEM32(reg, tnqdr, dscp, 0x04, 0, 6);
  10360. static inline void mlxsw_reg_tnqdr_pack(char *payload, u16 local_port)
  10361. {
  10362. MLXSW_REG_ZERO(tnqdr, payload);
  10363. mlxsw_reg_tnqdr_local_port_set(payload, local_port);
  10364. mlxsw_reg_tnqdr_dscp_set(payload, 0);
  10365. }
  10366. /* TNEEM - Tunneling NVE Encapsulation ECN Mapping Register
  10367. * --------------------------------------------------------
  10368. * The TNEEM register maps ECN of the IP header at the ingress to the
  10369. * encapsulation to the ECN of the underlay network.
  10370. */
  10371. #define MLXSW_REG_TNEEM_ID 0xA012
  10372. #define MLXSW_REG_TNEEM_LEN 0x0C
  10373. MLXSW_REG_DEFINE(tneem, MLXSW_REG_TNEEM_ID, MLXSW_REG_TNEEM_LEN);
  10374. /* reg_tneem_overlay_ecn
  10375. * ECN of the IP header in the overlay network.
  10376. * Access: Index
  10377. */
  10378. MLXSW_ITEM32(reg, tneem, overlay_ecn, 0x04, 24, 2);
  10379. /* reg_tneem_underlay_ecn
  10380. * ECN of the IP header in the underlay network.
  10381. * Access: RW
  10382. */
  10383. MLXSW_ITEM32(reg, tneem, underlay_ecn, 0x04, 16, 2);
  10384. static inline void mlxsw_reg_tneem_pack(char *payload, u8 overlay_ecn,
  10385. u8 underlay_ecn)
  10386. {
  10387. MLXSW_REG_ZERO(tneem, payload);
  10388. mlxsw_reg_tneem_overlay_ecn_set(payload, overlay_ecn);
  10389. mlxsw_reg_tneem_underlay_ecn_set(payload, underlay_ecn);
  10390. }
  10391. /* TNDEM - Tunneling NVE Decapsulation ECN Mapping Register
  10392. * --------------------------------------------------------
  10393. * The TNDEM register configures the actions that are done in the
  10394. * decapsulation.
  10395. */
  10396. #define MLXSW_REG_TNDEM_ID 0xA013
  10397. #define MLXSW_REG_TNDEM_LEN 0x0C
  10398. MLXSW_REG_DEFINE(tndem, MLXSW_REG_TNDEM_ID, MLXSW_REG_TNDEM_LEN);
  10399. /* reg_tndem_underlay_ecn
  10400. * ECN field of the IP header in the underlay network.
  10401. * Access: Index
  10402. */
  10403. MLXSW_ITEM32(reg, tndem, underlay_ecn, 0x04, 24, 2);
  10404. /* reg_tndem_overlay_ecn
  10405. * ECN field of the IP header in the overlay network.
  10406. * Access: Index
  10407. */
  10408. MLXSW_ITEM32(reg, tndem, overlay_ecn, 0x04, 16, 2);
  10409. /* reg_tndem_eip_ecn
  10410. * Egress IP ECN. ECN field of the IP header of the packet which goes out
  10411. * from the decapsulation.
  10412. * Access: RW
  10413. */
  10414. MLXSW_ITEM32(reg, tndem, eip_ecn, 0x04, 8, 2);
  10415. /* reg_tndem_trap_en
  10416. * Trap enable:
  10417. * 0 - No trap due to decap ECN
  10418. * 1 - Trap enable with trap_id
  10419. * Access: RW
  10420. */
  10421. MLXSW_ITEM32(reg, tndem, trap_en, 0x08, 28, 4);
  10422. /* reg_tndem_trap_id
  10423. * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
  10424. * Reserved when trap_en is '0'.
  10425. * Access: RW
  10426. */
  10427. MLXSW_ITEM32(reg, tndem, trap_id, 0x08, 0, 9);
  10428. static inline void mlxsw_reg_tndem_pack(char *payload, u8 underlay_ecn,
  10429. u8 overlay_ecn, u8 ecn, bool trap_en,
  10430. u16 trap_id)
  10431. {
  10432. MLXSW_REG_ZERO(tndem, payload);
  10433. mlxsw_reg_tndem_underlay_ecn_set(payload, underlay_ecn);
  10434. mlxsw_reg_tndem_overlay_ecn_set(payload, overlay_ecn);
  10435. mlxsw_reg_tndem_eip_ecn_set(payload, ecn);
  10436. mlxsw_reg_tndem_trap_en_set(payload, trap_en);
  10437. mlxsw_reg_tndem_trap_id_set(payload, trap_id);
  10438. }
  10439. /* TNPC - Tunnel Port Configuration Register
  10440. * -----------------------------------------
  10441. * The TNPC register is used for tunnel port configuration.
  10442. * Reserved when Spectrum.
  10443. */
  10444. #define MLXSW_REG_TNPC_ID 0xA020
  10445. #define MLXSW_REG_TNPC_LEN 0x18
  10446. MLXSW_REG_DEFINE(tnpc, MLXSW_REG_TNPC_ID, MLXSW_REG_TNPC_LEN);
  10447. /* reg_tnpc_tunnel_port
  10448. * Tunnel port.
  10449. * Access: Index
  10450. */
  10451. MLXSW_ITEM32(reg, tnpc, tunnel_port, 0x00, 0, 4);
  10452. /* reg_tnpc_learn_enable_v6
  10453. * During IPv6 underlay decapsulation, whether to learn from tunnel port.
  10454. * Access: RW
  10455. */
  10456. MLXSW_ITEM32(reg, tnpc, learn_enable_v6, 0x04, 1, 1);
  10457. /* reg_tnpc_learn_enable_v4
  10458. * During IPv4 underlay decapsulation, whether to learn from tunnel port.
  10459. * Access: RW
  10460. */
  10461. MLXSW_ITEM32(reg, tnpc, learn_enable_v4, 0x04, 0, 1);
  10462. static inline void mlxsw_reg_tnpc_pack(char *payload,
  10463. enum mlxsw_reg_tunnel_port tport,
  10464. bool learn_enable)
  10465. {
  10466. MLXSW_REG_ZERO(tnpc, payload);
  10467. mlxsw_reg_tnpc_tunnel_port_set(payload, tport);
  10468. mlxsw_reg_tnpc_learn_enable_v4_set(payload, learn_enable);
  10469. mlxsw_reg_tnpc_learn_enable_v6_set(payload, learn_enable);
  10470. }
  10471. /* TIGCR - Tunneling IPinIP General Configuration Register
  10472. * -------------------------------------------------------
  10473. * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
  10474. */
  10475. #define MLXSW_REG_TIGCR_ID 0xA801
  10476. #define MLXSW_REG_TIGCR_LEN 0x10
  10477. MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
  10478. /* reg_tigcr_ipip_ttlc
  10479. * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
  10480. * header.
  10481. * Access: RW
  10482. */
  10483. MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
  10484. /* reg_tigcr_ipip_ttl_uc
  10485. * The TTL for IPinIP Tunnel encapsulation of unicast packets if
  10486. * reg_tigcr_ipip_ttlc is unset.
  10487. * Access: RW
  10488. */
  10489. MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
  10490. static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
  10491. {
  10492. MLXSW_REG_ZERO(tigcr, payload);
  10493. mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
  10494. mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
  10495. }
  10496. /* TIEEM - Tunneling IPinIP Encapsulation ECN Mapping Register
  10497. * -----------------------------------------------------------
  10498. * The TIEEM register maps ECN of the IP header at the ingress to the
  10499. * encapsulation to the ECN of the underlay network.
  10500. */
  10501. #define MLXSW_REG_TIEEM_ID 0xA812
  10502. #define MLXSW_REG_TIEEM_LEN 0x0C
  10503. MLXSW_REG_DEFINE(tieem, MLXSW_REG_TIEEM_ID, MLXSW_REG_TIEEM_LEN);
  10504. /* reg_tieem_overlay_ecn
  10505. * ECN of the IP header in the overlay network.
  10506. * Access: Index
  10507. */
  10508. MLXSW_ITEM32(reg, tieem, overlay_ecn, 0x04, 24, 2);
  10509. /* reg_tineem_underlay_ecn
  10510. * ECN of the IP header in the underlay network.
  10511. * Access: RW
  10512. */
  10513. MLXSW_ITEM32(reg, tieem, underlay_ecn, 0x04, 16, 2);
  10514. static inline void mlxsw_reg_tieem_pack(char *payload, u8 overlay_ecn,
  10515. u8 underlay_ecn)
  10516. {
  10517. MLXSW_REG_ZERO(tieem, payload);
  10518. mlxsw_reg_tieem_overlay_ecn_set(payload, overlay_ecn);
  10519. mlxsw_reg_tieem_underlay_ecn_set(payload, underlay_ecn);
  10520. }
  10521. /* TIDEM - Tunneling IPinIP Decapsulation ECN Mapping Register
  10522. * -----------------------------------------------------------
  10523. * The TIDEM register configures the actions that are done in the
  10524. * decapsulation.
  10525. */
  10526. #define MLXSW_REG_TIDEM_ID 0xA813
  10527. #define MLXSW_REG_TIDEM_LEN 0x0C
  10528. MLXSW_REG_DEFINE(tidem, MLXSW_REG_TIDEM_ID, MLXSW_REG_TIDEM_LEN);
  10529. /* reg_tidem_underlay_ecn
  10530. * ECN field of the IP header in the underlay network.
  10531. * Access: Index
  10532. */
  10533. MLXSW_ITEM32(reg, tidem, underlay_ecn, 0x04, 24, 2);
  10534. /* reg_tidem_overlay_ecn
  10535. * ECN field of the IP header in the overlay network.
  10536. * Access: Index
  10537. */
  10538. MLXSW_ITEM32(reg, tidem, overlay_ecn, 0x04, 16, 2);
  10539. /* reg_tidem_eip_ecn
  10540. * Egress IP ECN. ECN field of the IP header of the packet which goes out
  10541. * from the decapsulation.
  10542. * Access: RW
  10543. */
  10544. MLXSW_ITEM32(reg, tidem, eip_ecn, 0x04, 8, 2);
  10545. /* reg_tidem_trap_en
  10546. * Trap enable:
  10547. * 0 - No trap due to decap ECN
  10548. * 1 - Trap enable with trap_id
  10549. * Access: RW
  10550. */
  10551. MLXSW_ITEM32(reg, tidem, trap_en, 0x08, 28, 4);
  10552. /* reg_tidem_trap_id
  10553. * Trap ID. Either DECAP_ECN0 or DECAP_ECN1.
  10554. * Reserved when trap_en is '0'.
  10555. * Access: RW
  10556. */
  10557. MLXSW_ITEM32(reg, tidem, trap_id, 0x08, 0, 9);
  10558. static inline void mlxsw_reg_tidem_pack(char *payload, u8 underlay_ecn,
  10559. u8 overlay_ecn, u8 eip_ecn,
  10560. bool trap_en, u16 trap_id)
  10561. {
  10562. MLXSW_REG_ZERO(tidem, payload);
  10563. mlxsw_reg_tidem_underlay_ecn_set(payload, underlay_ecn);
  10564. mlxsw_reg_tidem_overlay_ecn_set(payload, overlay_ecn);
  10565. mlxsw_reg_tidem_eip_ecn_set(payload, eip_ecn);
  10566. mlxsw_reg_tidem_trap_en_set(payload, trap_en);
  10567. mlxsw_reg_tidem_trap_id_set(payload, trap_id);
  10568. }
  10569. /* SBPR - Shared Buffer Pools Register
  10570. * -----------------------------------
  10571. * The SBPR configures and retrieves the shared buffer pools and configuration.
  10572. */
  10573. #define MLXSW_REG_SBPR_ID 0xB001
  10574. #define MLXSW_REG_SBPR_LEN 0x14
  10575. MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
  10576. /* reg_sbpr_desc
  10577. * When set, configures descriptor buffer.
  10578. * Access: Index
  10579. */
  10580. MLXSW_ITEM32(reg, sbpr, desc, 0x00, 31, 1);
  10581. /* shared direstion enum for SBPR, SBCM, SBPM */
  10582. enum mlxsw_reg_sbxx_dir {
  10583. MLXSW_REG_SBXX_DIR_INGRESS,
  10584. MLXSW_REG_SBXX_DIR_EGRESS,
  10585. };
  10586. /* reg_sbpr_dir
  10587. * Direction.
  10588. * Access: Index
  10589. */
  10590. MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
  10591. /* reg_sbpr_pool
  10592. * Pool index.
  10593. * Access: Index
  10594. */
  10595. MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
  10596. /* reg_sbpr_infi_size
  10597. * Size is infinite.
  10598. * Access: RW
  10599. */
  10600. MLXSW_ITEM32(reg, sbpr, infi_size, 0x04, 31, 1);
  10601. /* reg_sbpr_size
  10602. * Pool size in buffer cells.
  10603. * Reserved when infi_size = 1.
  10604. * Access: RW
  10605. */
  10606. MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
  10607. enum mlxsw_reg_sbpr_mode {
  10608. MLXSW_REG_SBPR_MODE_STATIC,
  10609. MLXSW_REG_SBPR_MODE_DYNAMIC,
  10610. };
  10611. /* reg_sbpr_mode
  10612. * Pool quota calculation mode.
  10613. * Access: RW
  10614. */
  10615. MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
  10616. static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
  10617. enum mlxsw_reg_sbxx_dir dir,
  10618. enum mlxsw_reg_sbpr_mode mode, u32 size,
  10619. bool infi_size)
  10620. {
  10621. MLXSW_REG_ZERO(sbpr, payload);
  10622. mlxsw_reg_sbpr_pool_set(payload, pool);
  10623. mlxsw_reg_sbpr_dir_set(payload, dir);
  10624. mlxsw_reg_sbpr_mode_set(payload, mode);
  10625. mlxsw_reg_sbpr_size_set(payload, size);
  10626. mlxsw_reg_sbpr_infi_size_set(payload, infi_size);
  10627. }
  10628. /* SBCM - Shared Buffer Class Management Register
  10629. * ----------------------------------------------
  10630. * The SBCM register configures and retrieves the shared buffer allocation
  10631. * and configuration according to Port-PG, including the binding to pool
  10632. * and definition of the associated quota.
  10633. */
  10634. #define MLXSW_REG_SBCM_ID 0xB002
  10635. #define MLXSW_REG_SBCM_LEN 0x28
  10636. MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
  10637. /* reg_sbcm_local_port
  10638. * Local port number.
  10639. * For Ingress: excludes CPU port and Router port
  10640. * For Egress: excludes IP Router
  10641. * Access: Index
  10642. */
  10643. MLXSW_ITEM32_LP(reg, sbcm, 0x00, 16, 0x00, 4);
  10644. /* reg_sbcm_pg_buff
  10645. * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
  10646. * For PG buffer: range is 0..cap_max_pg_buffers - 1
  10647. * For traffic class: range is 0..cap_max_tclass - 1
  10648. * Note that when traffic class is in MC aware mode then the traffic
  10649. * classes which are MC aware cannot be configured.
  10650. * Access: Index
  10651. */
  10652. MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
  10653. /* reg_sbcm_dir
  10654. * Direction.
  10655. * Access: Index
  10656. */
  10657. MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
  10658. /* reg_sbcm_min_buff
  10659. * Minimum buffer size for the limiter, in cells.
  10660. * Access: RW
  10661. */
  10662. MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
  10663. /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
  10664. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
  10665. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
  10666. /* reg_sbcm_infi_max
  10667. * Max buffer is infinite.
  10668. * Access: RW
  10669. */
  10670. MLXSW_ITEM32(reg, sbcm, infi_max, 0x1C, 31, 1);
  10671. /* reg_sbcm_max_buff
  10672. * When the pool associated to the port-pg/tclass is configured to
  10673. * static, Maximum buffer size for the limiter configured in cells.
  10674. * When the pool associated to the port-pg/tclass is configured to
  10675. * dynamic, the max_buff holds the "alpha" parameter, supporting
  10676. * the following values:
  10677. * 0: 0
  10678. * i: (1/128)*2^(i-1), for i=1..14
  10679. * 0xFF: Infinity
  10680. * Reserved when infi_max = 1.
  10681. * Access: RW
  10682. */
  10683. MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
  10684. /* reg_sbcm_pool
  10685. * Association of the port-priority to a pool.
  10686. * Access: RW
  10687. */
  10688. MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
  10689. static inline void mlxsw_reg_sbcm_pack(char *payload, u16 local_port, u8 pg_buff,
  10690. enum mlxsw_reg_sbxx_dir dir,
  10691. u32 min_buff, u32 max_buff,
  10692. bool infi_max, u8 pool)
  10693. {
  10694. MLXSW_REG_ZERO(sbcm, payload);
  10695. mlxsw_reg_sbcm_local_port_set(payload, local_port);
  10696. mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
  10697. mlxsw_reg_sbcm_dir_set(payload, dir);
  10698. mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
  10699. mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
  10700. mlxsw_reg_sbcm_infi_max_set(payload, infi_max);
  10701. mlxsw_reg_sbcm_pool_set(payload, pool);
  10702. }
  10703. /* SBPM - Shared Buffer Port Management Register
  10704. * ---------------------------------------------
  10705. * The SBPM register configures and retrieves the shared buffer allocation
  10706. * and configuration according to Port-Pool, including the definition
  10707. * of the associated quota.
  10708. */
  10709. #define MLXSW_REG_SBPM_ID 0xB003
  10710. #define MLXSW_REG_SBPM_LEN 0x28
  10711. MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
  10712. /* reg_sbpm_local_port
  10713. * Local port number.
  10714. * For Ingress: excludes CPU port and Router port
  10715. * For Egress: excludes IP Router
  10716. * Access: Index
  10717. */
  10718. MLXSW_ITEM32_LP(reg, sbpm, 0x00, 16, 0x00, 12);
  10719. /* reg_sbpm_pool
  10720. * The pool associated to quota counting on the local_port.
  10721. * Access: Index
  10722. */
  10723. MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
  10724. /* reg_sbpm_dir
  10725. * Direction.
  10726. * Access: Index
  10727. */
  10728. MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
  10729. /* reg_sbpm_buff_occupancy
  10730. * Current buffer occupancy in cells.
  10731. * Access: RO
  10732. */
  10733. MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
  10734. /* reg_sbpm_clr
  10735. * Clear Max Buffer Occupancy
  10736. * When this bit is set, max_buff_occupancy field is cleared (and a
  10737. * new max value is tracked from the time the clear was performed).
  10738. * Access: OP
  10739. */
  10740. MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
  10741. /* reg_sbpm_max_buff_occupancy
  10742. * Maximum value of buffer occupancy in cells monitored. Cleared by
  10743. * writing to the clr field.
  10744. * Access: RO
  10745. */
  10746. MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
  10747. /* reg_sbpm_min_buff
  10748. * Minimum buffer size for the limiter, in cells.
  10749. * Access: RW
  10750. */
  10751. MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
  10752. /* reg_sbpm_max_buff
  10753. * When the pool associated to the port-pg/tclass is configured to
  10754. * static, Maximum buffer size for the limiter configured in cells.
  10755. * When the pool associated to the port-pg/tclass is configured to
  10756. * dynamic, the max_buff holds the "alpha" parameter, supporting
  10757. * the following values:
  10758. * 0: 0
  10759. * i: (1/128)*2^(i-1), for i=1..14
  10760. * 0xFF: Infinity
  10761. * Access: RW
  10762. */
  10763. MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
  10764. static inline void mlxsw_reg_sbpm_pack(char *payload, u16 local_port, u8 pool,
  10765. enum mlxsw_reg_sbxx_dir dir, bool clr,
  10766. u32 min_buff, u32 max_buff)
  10767. {
  10768. MLXSW_REG_ZERO(sbpm, payload);
  10769. mlxsw_reg_sbpm_local_port_set(payload, local_port);
  10770. mlxsw_reg_sbpm_pool_set(payload, pool);
  10771. mlxsw_reg_sbpm_dir_set(payload, dir);
  10772. mlxsw_reg_sbpm_clr_set(payload, clr);
  10773. mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
  10774. mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
  10775. }
  10776. static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
  10777. u32 *p_max_buff_occupancy)
  10778. {
  10779. *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
  10780. *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
  10781. }
  10782. /* SBMM - Shared Buffer Multicast Management Register
  10783. * --------------------------------------------------
  10784. * The SBMM register configures and retrieves the shared buffer allocation
  10785. * and configuration for MC packets according to Switch-Priority, including
  10786. * the binding to pool and definition of the associated quota.
  10787. */
  10788. #define MLXSW_REG_SBMM_ID 0xB004
  10789. #define MLXSW_REG_SBMM_LEN 0x28
  10790. MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
  10791. /* reg_sbmm_prio
  10792. * Switch Priority.
  10793. * Access: Index
  10794. */
  10795. MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
  10796. /* reg_sbmm_min_buff
  10797. * Minimum buffer size for the limiter, in cells.
  10798. * Access: RW
  10799. */
  10800. MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
  10801. /* reg_sbmm_max_buff
  10802. * When the pool associated to the port-pg/tclass is configured to
  10803. * static, Maximum buffer size for the limiter configured in cells.
  10804. * When the pool associated to the port-pg/tclass is configured to
  10805. * dynamic, the max_buff holds the "alpha" parameter, supporting
  10806. * the following values:
  10807. * 0: 0
  10808. * i: (1/128)*2^(i-1), for i=1..14
  10809. * 0xFF: Infinity
  10810. * Access: RW
  10811. */
  10812. MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
  10813. /* reg_sbmm_pool
  10814. * Association of the port-priority to a pool.
  10815. * Access: RW
  10816. */
  10817. MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
  10818. static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
  10819. u32 max_buff, u8 pool)
  10820. {
  10821. MLXSW_REG_ZERO(sbmm, payload);
  10822. mlxsw_reg_sbmm_prio_set(payload, prio);
  10823. mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
  10824. mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
  10825. mlxsw_reg_sbmm_pool_set(payload, pool);
  10826. }
  10827. /* SBSR - Shared Buffer Status Register
  10828. * ------------------------------------
  10829. * The SBSR register retrieves the shared buffer occupancy according to
  10830. * Port-Pool. Note that this register enables reading a large amount of data.
  10831. * It is the user's responsibility to limit the amount of data to ensure the
  10832. * response can match the maximum transfer unit. In case the response exceeds
  10833. * the maximum transport unit, it will be truncated with no special notice.
  10834. */
  10835. #define MLXSW_REG_SBSR_ID 0xB005
  10836. #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
  10837. #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
  10838. #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
  10839. #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
  10840. MLXSW_REG_SBSR_REC_LEN * \
  10841. MLXSW_REG_SBSR_REC_MAX_COUNT)
  10842. MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
  10843. /* reg_sbsr_clr
  10844. * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
  10845. * field is cleared (and a new max value is tracked from the time the clear
  10846. * was performed).
  10847. * Access: OP
  10848. */
  10849. MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
  10850. #define MLXSW_REG_SBSR_NUM_PORTS_IN_PAGE 256
  10851. /* reg_sbsr_port_page
  10852. * Determines the range of the ports specified in the 'ingress_port_mask'
  10853. * and 'egress_port_mask' bit masks.
  10854. * {ingress,egress}_port_mask[x] is (256 * port_page) + x
  10855. * Access: Index
  10856. */
  10857. MLXSW_ITEM32(reg, sbsr, port_page, 0x04, 0, 4);
  10858. /* reg_sbsr_ingress_port_mask
  10859. * Bit vector for all ingress network ports.
  10860. * Indicates which of the ports (for which the relevant bit is set)
  10861. * are affected by the set operation. Configuration of any other port
  10862. * does not change.
  10863. * Access: Index
  10864. */
  10865. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
  10866. /* reg_sbsr_pg_buff_mask
  10867. * Bit vector for all switch priority groups.
  10868. * Indicates which of the priorities (for which the relevant bit is set)
  10869. * are affected by the set operation. Configuration of any other priority
  10870. * does not change.
  10871. * Range is 0..cap_max_pg_buffers - 1
  10872. * Access: Index
  10873. */
  10874. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
  10875. /* reg_sbsr_egress_port_mask
  10876. * Bit vector for all egress network ports.
  10877. * Indicates which of the ports (for which the relevant bit is set)
  10878. * are affected by the set operation. Configuration of any other port
  10879. * does not change.
  10880. * Access: Index
  10881. */
  10882. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
  10883. /* reg_sbsr_tclass_mask
  10884. * Bit vector for all traffic classes.
  10885. * Indicates which of the traffic classes (for which the relevant bit is
  10886. * set) are affected by the set operation. Configuration of any other
  10887. * traffic class does not change.
  10888. * Range is 0..cap_max_tclass - 1
  10889. * Access: Index
  10890. */
  10891. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
  10892. static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
  10893. {
  10894. MLXSW_REG_ZERO(sbsr, payload);
  10895. mlxsw_reg_sbsr_clr_set(payload, clr);
  10896. }
  10897. /* reg_sbsr_rec_buff_occupancy
  10898. * Current buffer occupancy in cells.
  10899. * Access: RO
  10900. */
  10901. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  10902. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
  10903. /* reg_sbsr_rec_max_buff_occupancy
  10904. * Maximum value of buffer occupancy in cells monitored. Cleared by
  10905. * writing to the clr field.
  10906. * Access: RO
  10907. */
  10908. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  10909. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
  10910. static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
  10911. u32 *p_buff_occupancy,
  10912. u32 *p_max_buff_occupancy)
  10913. {
  10914. *p_buff_occupancy =
  10915. mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
  10916. *p_max_buff_occupancy =
  10917. mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
  10918. }
  10919. /* SBIB - Shared Buffer Internal Buffer Register
  10920. * ---------------------------------------------
  10921. * The SBIB register configures per port buffers for internal use. The internal
  10922. * buffers consume memory on the port buffers (note that the port buffers are
  10923. * used also by PBMC).
  10924. *
  10925. * For Spectrum this is used for egress mirroring.
  10926. */
  10927. #define MLXSW_REG_SBIB_ID 0xB006
  10928. #define MLXSW_REG_SBIB_LEN 0x10
  10929. MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
  10930. /* reg_sbib_local_port
  10931. * Local port number
  10932. * Not supported for CPU port and router port
  10933. * Access: Index
  10934. */
  10935. MLXSW_ITEM32_LP(reg, sbib, 0x00, 16, 0x00, 12);
  10936. /* reg_sbib_buff_size
  10937. * Units represented in cells
  10938. * Allowed range is 0 to (cap_max_headroom_size - 1)
  10939. * Default is 0
  10940. * Access: RW
  10941. */
  10942. MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
  10943. static inline void mlxsw_reg_sbib_pack(char *payload, u16 local_port,
  10944. u32 buff_size)
  10945. {
  10946. MLXSW_REG_ZERO(sbib, payload);
  10947. mlxsw_reg_sbib_local_port_set(payload, local_port);
  10948. mlxsw_reg_sbib_buff_size_set(payload, buff_size);
  10949. }
  10950. static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
  10951. MLXSW_REG(sgcr),
  10952. MLXSW_REG(spad),
  10953. MLXSW_REG(sspr),
  10954. MLXSW_REG(sfdat),
  10955. MLXSW_REG(sfd),
  10956. MLXSW_REG(sfn),
  10957. MLXSW_REG(spms),
  10958. MLXSW_REG(spvid),
  10959. MLXSW_REG(spvm),
  10960. MLXSW_REG(spaft),
  10961. MLXSW_REG(sfgc),
  10962. MLXSW_REG(sfdf),
  10963. MLXSW_REG(sldr),
  10964. MLXSW_REG(slcr),
  10965. MLXSW_REG(slcor),
  10966. MLXSW_REG(spmlr),
  10967. MLXSW_REG(svfa),
  10968. MLXSW_REG(spvtr),
  10969. MLXSW_REG(svpe),
  10970. MLXSW_REG(sfmr),
  10971. MLXSW_REG(spvmlr),
  10972. MLXSW_REG(spvc),
  10973. MLXSW_REG(spevet),
  10974. MLXSW_REG(smpe),
  10975. MLXSW_REG(smid2),
  10976. MLXSW_REG(cwtp),
  10977. MLXSW_REG(cwtpm),
  10978. MLXSW_REG(pgcr),
  10979. MLXSW_REG(ppbt),
  10980. MLXSW_REG(pacl),
  10981. MLXSW_REG(pagt),
  10982. MLXSW_REG(ptar),
  10983. MLXSW_REG(ppbs),
  10984. MLXSW_REG(prcr),
  10985. MLXSW_REG(pefa),
  10986. MLXSW_REG(pemrbt),
  10987. MLXSW_REG(ptce2),
  10988. MLXSW_REG(perpt),
  10989. MLXSW_REG(peabfe),
  10990. MLXSW_REG(perar),
  10991. MLXSW_REG(ptce3),
  10992. MLXSW_REG(percr),
  10993. MLXSW_REG(pererp),
  10994. MLXSW_REG(iedr),
  10995. MLXSW_REG(qpts),
  10996. MLXSW_REG(qpcr),
  10997. MLXSW_REG(qtct),
  10998. MLXSW_REG(qeec),
  10999. MLXSW_REG(qrwe),
  11000. MLXSW_REG(qpdsm),
  11001. MLXSW_REG(qpdp),
  11002. MLXSW_REG(qpdpm),
  11003. MLXSW_REG(qtctm),
  11004. MLXSW_REG(qpsc),
  11005. MLXSW_REG(pmlp),
  11006. MLXSW_REG(pmtu),
  11007. MLXSW_REG(ptys),
  11008. MLXSW_REG(ppad),
  11009. MLXSW_REG(paos),
  11010. MLXSW_REG(pfcc),
  11011. MLXSW_REG(ppcnt),
  11012. MLXSW_REG(pptb),
  11013. MLXSW_REG(pbmc),
  11014. MLXSW_REG(pspa),
  11015. MLXSW_REG(pmaos),
  11016. MLXSW_REG(pplr),
  11017. MLXSW_REG(pmtdb),
  11018. MLXSW_REG(pmecr),
  11019. MLXSW_REG(pmpe),
  11020. MLXSW_REG(pddr),
  11021. MLXSW_REG(pmmp),
  11022. MLXSW_REG(pllp),
  11023. MLXSW_REG(pmtm),
  11024. MLXSW_REG(htgt),
  11025. MLXSW_REG(hpkt),
  11026. MLXSW_REG(rgcr),
  11027. MLXSW_REG(ritr),
  11028. MLXSW_REG(rtar),
  11029. MLXSW_REG(ratr),
  11030. MLXSW_REG(rtdp),
  11031. MLXSW_REG(rips),
  11032. MLXSW_REG(ratrad),
  11033. MLXSW_REG(rdpm),
  11034. MLXSW_REG(ricnt),
  11035. MLXSW_REG(rrcr),
  11036. MLXSW_REG(ralta),
  11037. MLXSW_REG(ralst),
  11038. MLXSW_REG(raltb),
  11039. MLXSW_REG(ralue),
  11040. MLXSW_REG(rauht),
  11041. MLXSW_REG(raleu),
  11042. MLXSW_REG(rauhtd),
  11043. MLXSW_REG(rigr2),
  11044. MLXSW_REG(recr2),
  11045. MLXSW_REG(rmft2),
  11046. MLXSW_REG(reiv),
  11047. MLXSW_REG(mfcr),
  11048. MLXSW_REG(mfsc),
  11049. MLXSW_REG(mfsm),
  11050. MLXSW_REG(mfsl),
  11051. MLXSW_REG(fore),
  11052. MLXSW_REG(mtcap),
  11053. MLXSW_REG(mtmp),
  11054. MLXSW_REG(mtwe),
  11055. MLXSW_REG(mtbr),
  11056. MLXSW_REG(mcia),
  11057. MLXSW_REG(mpat),
  11058. MLXSW_REG(mpar),
  11059. MLXSW_REG(mgir),
  11060. MLXSW_REG(mrsr),
  11061. MLXSW_REG(mlcr),
  11062. MLXSW_REG(mcion),
  11063. MLXSW_REG(mtpps),
  11064. MLXSW_REG(mtutc),
  11065. MLXSW_REG(mpsc),
  11066. MLXSW_REG(mcqi),
  11067. MLXSW_REG(mcc),
  11068. MLXSW_REG(mcda),
  11069. MLXSW_REG(mgpc),
  11070. MLXSW_REG(mprs),
  11071. MLXSW_REG(mogcr),
  11072. MLXSW_REG(mpagr),
  11073. MLXSW_REG(momte),
  11074. MLXSW_REG(mtpppc),
  11075. MLXSW_REG(mtpptr),
  11076. MLXSW_REG(mtptpt),
  11077. MLXSW_REG(mtpcpc),
  11078. MLXSW_REG(mfgd),
  11079. MLXSW_REG(mgpir),
  11080. MLXSW_REG(mbct),
  11081. MLXSW_REG(mddt),
  11082. MLXSW_REG(mddq),
  11083. MLXSW_REG(mddc),
  11084. MLXSW_REG(mfde),
  11085. MLXSW_REG(tngcr),
  11086. MLXSW_REG(tnumt),
  11087. MLXSW_REG(tnqcr),
  11088. MLXSW_REG(tnqdr),
  11089. MLXSW_REG(tneem),
  11090. MLXSW_REG(tndem),
  11091. MLXSW_REG(tnpc),
  11092. MLXSW_REG(tigcr),
  11093. MLXSW_REG(tieem),
  11094. MLXSW_REG(tidem),
  11095. MLXSW_REG(sbpr),
  11096. MLXSW_REG(sbcm),
  11097. MLXSW_REG(sbpm),
  11098. MLXSW_REG(sbmm),
  11099. MLXSW_REG(sbsr),
  11100. MLXSW_REG(sbib),
  11101. };
  11102. static inline const char *mlxsw_reg_id_str(u16 reg_id)
  11103. {
  11104. const struct mlxsw_reg_info *reg_info;
  11105. int i;
  11106. for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
  11107. reg_info = mlxsw_reg_infos[i];
  11108. if (reg_info->id == reg_id)
  11109. return reg_info->name;
  11110. }
  11111. return "*UNKNOWN*";
  11112. }
  11113. /* PUDE - Port Up / Down Event
  11114. * ---------------------------
  11115. * Reports the operational state change of a port.
  11116. */
  11117. #define MLXSW_REG_PUDE_LEN 0x10
  11118. /* reg_pude_swid
  11119. * Switch partition ID with which to associate the port.
  11120. * Access: Index
  11121. */
  11122. MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
  11123. /* reg_pude_local_port
  11124. * Local port number.
  11125. * Access: Index
  11126. */
  11127. MLXSW_ITEM32_LP(reg, pude, 0x00, 16, 0x00, 12);
  11128. /* reg_pude_admin_status
  11129. * Port administrative state (the desired state).
  11130. * 1 - Up.
  11131. * 2 - Down.
  11132. * 3 - Up once. This means that in case of link failure, the port won't go
  11133. * into polling mode, but will wait to be re-enabled by software.
  11134. * 4 - Disabled by system. Can only be set by hardware.
  11135. * Access: RO
  11136. */
  11137. MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
  11138. /* reg_pude_oper_status
  11139. * Port operatioanl state.
  11140. * 1 - Up.
  11141. * 2 - Down.
  11142. * 3 - Down by port failure. This means that the device will not let the
  11143. * port up again until explicitly specified by software.
  11144. * Access: RO
  11145. */
  11146. MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
  11147. #endif