reg.h 255 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895
  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. /* SMID - Switch Multicast ID
  59. * --------------------------
  60. * The MID record maps from a MID (Multicast ID), which is a unique identifier
  61. * of the multicast group within the stacking domain, into a list of local
  62. * ports into which the packet is replicated.
  63. */
  64. #define MLXSW_REG_SMID_ID 0x2007
  65. #define MLXSW_REG_SMID_LEN 0x240
  66. MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
  67. /* reg_smid_swid
  68. * Switch partition ID.
  69. * Access: Index
  70. */
  71. MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
  72. /* reg_smid_mid
  73. * Multicast identifier - global identifier that represents the multicast group
  74. * across all devices.
  75. * Access: Index
  76. */
  77. MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
  78. /* reg_smid_port
  79. * Local port memebership (1 bit per port).
  80. * Access: RW
  81. */
  82. MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
  83. /* reg_smid_port_mask
  84. * Local port mask (1 bit per port).
  85. * Access: W
  86. */
  87. MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
  88. static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
  89. u8 port, bool set)
  90. {
  91. MLXSW_REG_ZERO(smid, payload);
  92. mlxsw_reg_smid_swid_set(payload, 0);
  93. mlxsw_reg_smid_mid_set(payload, mid);
  94. mlxsw_reg_smid_port_set(payload, port, set);
  95. mlxsw_reg_smid_port_mask_set(payload, port, 1);
  96. }
  97. /* SSPR - Switch System Port Record Register
  98. * -----------------------------------------
  99. * Configures the system port to local port mapping.
  100. */
  101. #define MLXSW_REG_SSPR_ID 0x2008
  102. #define MLXSW_REG_SSPR_LEN 0x8
  103. MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
  104. /* reg_sspr_m
  105. * Master - if set, then the record describes the master system port.
  106. * This is needed in case a local port is mapped into several system ports
  107. * (for multipathing). That number will be reported as the source system
  108. * port when packets are forwarded to the CPU. Only one master port is allowed
  109. * per local port.
  110. *
  111. * Note: Must be set for Spectrum.
  112. * Access: RW
  113. */
  114. MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
  115. /* reg_sspr_local_port
  116. * Local port number.
  117. *
  118. * Access: RW
  119. */
  120. MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
  121. /* reg_sspr_sub_port
  122. * Virtual port within the physical port.
  123. * Should be set to 0 when virtual ports are not enabled on the port.
  124. *
  125. * Access: RW
  126. */
  127. MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
  128. /* reg_sspr_system_port
  129. * Unique identifier within the stacking domain that represents all the ports
  130. * that are available in the system (external ports).
  131. *
  132. * Currently, only single-ASIC configurations are supported, so we default to
  133. * 1:1 mapping between system ports and local ports.
  134. * Access: Index
  135. */
  136. MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
  137. static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
  138. {
  139. MLXSW_REG_ZERO(sspr, payload);
  140. mlxsw_reg_sspr_m_set(payload, 1);
  141. mlxsw_reg_sspr_local_port_set(payload, local_port);
  142. mlxsw_reg_sspr_sub_port_set(payload, 0);
  143. mlxsw_reg_sspr_system_port_set(payload, local_port);
  144. }
  145. /* SFDAT - Switch Filtering Database Aging Time
  146. * --------------------------------------------
  147. * Controls the Switch aging time. Aging time is able to be set per Switch
  148. * Partition.
  149. */
  150. #define MLXSW_REG_SFDAT_ID 0x2009
  151. #define MLXSW_REG_SFDAT_LEN 0x8
  152. MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
  153. /* reg_sfdat_swid
  154. * Switch partition ID.
  155. * Access: Index
  156. */
  157. MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
  158. /* reg_sfdat_age_time
  159. * Aging time in seconds
  160. * Min - 10 seconds
  161. * Max - 1,000,000 seconds
  162. * Default is 300 seconds.
  163. * Access: RW
  164. */
  165. MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
  166. static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
  167. {
  168. MLXSW_REG_ZERO(sfdat, payload);
  169. mlxsw_reg_sfdat_swid_set(payload, 0);
  170. mlxsw_reg_sfdat_age_time_set(payload, age_time);
  171. }
  172. /* SFD - Switch Filtering Database
  173. * -------------------------------
  174. * The following register defines the access to the filtering database.
  175. * The register supports querying, adding, removing and modifying the database.
  176. * The access is optimized for bulk updates in which case more than one
  177. * FDB record is present in the same command.
  178. */
  179. #define MLXSW_REG_SFD_ID 0x200A
  180. #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
  181. #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
  182. #define MLXSW_REG_SFD_REC_MAX_COUNT 64
  183. #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
  184. MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
  185. MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
  186. /* reg_sfd_swid
  187. * Switch partition ID for queries. Reserved on Write.
  188. * Access: Index
  189. */
  190. MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
  191. enum mlxsw_reg_sfd_op {
  192. /* Dump entire FDB a (process according to record_locator) */
  193. MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
  194. /* Query records by {MAC, VID/FID} value */
  195. MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
  196. /* Query and clear activity. Query records by {MAC, VID/FID} value */
  197. MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
  198. /* Test. Response indicates if each of the records could be
  199. * added to the FDB.
  200. */
  201. MLXSW_REG_SFD_OP_WRITE_TEST = 0,
  202. /* Add/modify. Aged-out records cannot be added. This command removes
  203. * the learning notification of the {MAC, VID/FID}. Response includes
  204. * the entries that were added to the FDB.
  205. */
  206. MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
  207. /* Remove record by {MAC, VID/FID}. This command also removes
  208. * the learning notification and aged-out notifications
  209. * of the {MAC, VID/FID}. The response provides current (pre-removal)
  210. * entries as non-aged-out.
  211. */
  212. MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
  213. /* Remove learned notification by {MAC, VID/FID}. The response provides
  214. * the removed learning notification.
  215. */
  216. MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
  217. };
  218. /* reg_sfd_op
  219. * Operation.
  220. * Access: OP
  221. */
  222. MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
  223. /* reg_sfd_record_locator
  224. * Used for querying the FDB. Use record_locator=0 to initiate the
  225. * query. When a record is returned, a new record_locator is
  226. * returned to be used in the subsequent query.
  227. * Reserved for database update.
  228. * Access: Index
  229. */
  230. MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
  231. /* reg_sfd_num_rec
  232. * Request: Number of records to read/add/modify/remove
  233. * Response: Number of records read/added/replaced/removed
  234. * See above description for more details.
  235. * Ranges 0..64
  236. * Access: RW
  237. */
  238. MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
  239. static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
  240. u32 record_locator)
  241. {
  242. MLXSW_REG_ZERO(sfd, payload);
  243. mlxsw_reg_sfd_op_set(payload, op);
  244. mlxsw_reg_sfd_record_locator_set(payload, record_locator);
  245. }
  246. /* reg_sfd_rec_swid
  247. * Switch partition ID.
  248. * Access: Index
  249. */
  250. MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
  251. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  252. enum mlxsw_reg_sfd_rec_type {
  253. MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
  254. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
  255. MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
  256. };
  257. /* reg_sfd_rec_type
  258. * FDB record type.
  259. * Access: RW
  260. */
  261. MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
  262. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  263. enum mlxsw_reg_sfd_rec_policy {
  264. /* Replacement disabled, aging disabled. */
  265. MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
  266. /* (mlag remote): Replacement enabled, aging disabled,
  267. * learning notification enabled on this port.
  268. */
  269. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
  270. /* (ingress device): Replacement enabled, aging enabled. */
  271. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
  272. };
  273. /* reg_sfd_rec_policy
  274. * Policy.
  275. * Access: RW
  276. */
  277. MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
  278. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  279. /* reg_sfd_rec_a
  280. * Activity. Set for new static entries. Set for static entries if a frame SMAC
  281. * lookup hits on the entry.
  282. * To clear the a bit, use "query and clear activity" op.
  283. * Access: RO
  284. */
  285. MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
  286. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  287. /* reg_sfd_rec_mac
  288. * MAC address.
  289. * Access: Index
  290. */
  291. MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
  292. MLXSW_REG_SFD_REC_LEN, 0x02);
  293. enum mlxsw_reg_sfd_rec_action {
  294. /* forward */
  295. MLXSW_REG_SFD_REC_ACTION_NOP = 0,
  296. /* forward and trap, trap_id is FDB_TRAP */
  297. MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
  298. /* trap and do not forward, trap_id is FDB_TRAP */
  299. MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
  300. /* forward to IP router */
  301. MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
  302. MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
  303. };
  304. /* reg_sfd_rec_action
  305. * Action to apply on the packet.
  306. * Note: Dynamic entries can only be configured with NOP action.
  307. * Access: RW
  308. */
  309. MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
  310. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  311. /* reg_sfd_uc_sub_port
  312. * VEPA channel on local port.
  313. * Valid only if local port is a non-stacking port. Must be 0 if multichannel
  314. * VEPA is not enabled.
  315. * Access: RW
  316. */
  317. MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  318. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  319. /* reg_sfd_uc_fid_vid
  320. * Filtering ID or VLAN ID
  321. * For SwitchX and SwitchX-2:
  322. * - Dynamic entries (policy 2,3) use FID
  323. * - Static entries (policy 0) use VID
  324. * - When independent learning is configured, VID=FID
  325. * For Spectrum: use FID for both Dynamic and Static entries.
  326. * VID should not be used.
  327. * Access: Index
  328. */
  329. MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  330. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  331. /* reg_sfd_uc_system_port
  332. * Unique port identifier for the final destination of the packet.
  333. * Access: RW
  334. */
  335. MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  336. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  337. static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
  338. enum mlxsw_reg_sfd_rec_type rec_type,
  339. const char *mac,
  340. enum mlxsw_reg_sfd_rec_action action)
  341. {
  342. u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
  343. if (rec_index >= num_rec)
  344. mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
  345. mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
  346. mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
  347. mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
  348. mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
  349. }
  350. static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
  351. enum mlxsw_reg_sfd_rec_policy policy,
  352. const char *mac, u16 fid_vid,
  353. enum mlxsw_reg_sfd_rec_action action,
  354. u8 local_port)
  355. {
  356. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  357. MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
  358. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  359. mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
  360. mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
  361. mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
  362. }
  363. static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
  364. char *mac, u16 *p_fid_vid,
  365. u8 *p_local_port)
  366. {
  367. mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
  368. *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
  369. *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
  370. }
  371. /* reg_sfd_uc_lag_sub_port
  372. * LAG sub port.
  373. * Must be 0 if multichannel VEPA is not enabled.
  374. * Access: RW
  375. */
  376. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  377. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  378. /* reg_sfd_uc_lag_fid_vid
  379. * Filtering ID or VLAN ID
  380. * For SwitchX and SwitchX-2:
  381. * - Dynamic entries (policy 2,3) use FID
  382. * - Static entries (policy 0) use VID
  383. * - When independent learning is configured, VID=FID
  384. * For Spectrum: use FID for both Dynamic and Static entries.
  385. * VID should not be used.
  386. * Access: Index
  387. */
  388. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  389. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  390. /* reg_sfd_uc_lag_lag_vid
  391. * Indicates VID in case of vFIDs. Reserved for FIDs.
  392. * Access: RW
  393. */
  394. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
  395. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  396. /* reg_sfd_uc_lag_lag_id
  397. * LAG Identifier - pointer into the LAG descriptor table.
  398. * Access: RW
  399. */
  400. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
  401. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  402. static inline void
  403. mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
  404. enum mlxsw_reg_sfd_rec_policy policy,
  405. const char *mac, u16 fid_vid,
  406. enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
  407. u16 lag_id)
  408. {
  409. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  410. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
  411. mac, action);
  412. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  413. mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
  414. mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
  415. mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
  416. mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
  417. }
  418. static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
  419. char *mac, u16 *p_vid,
  420. u16 *p_lag_id)
  421. {
  422. mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
  423. *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
  424. *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
  425. }
  426. /* reg_sfd_mc_pgi
  427. *
  428. * Multicast port group index - index into the port group table.
  429. * Value 0x1FFF indicates the pgi should point to the MID entry.
  430. * For Spectrum this value must be set to 0x1FFF
  431. * Access: RW
  432. */
  433. MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
  434. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  435. /* reg_sfd_mc_fid_vid
  436. *
  437. * Filtering ID or VLAN ID
  438. * Access: Index
  439. */
  440. MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  441. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  442. /* reg_sfd_mc_mid
  443. *
  444. * Multicast identifier - global identifier that represents the multicast
  445. * group across all devices.
  446. * Access: RW
  447. */
  448. MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  449. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  450. static inline void
  451. mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
  452. const char *mac, u16 fid_vid,
  453. enum mlxsw_reg_sfd_rec_action action, u16 mid)
  454. {
  455. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  456. MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
  457. mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
  458. mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
  459. mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
  460. }
  461. /* SFN - Switch FDB Notification Register
  462. * -------------------------------------------
  463. * The switch provides notifications on newly learned FDB entries and
  464. * aged out entries. The notifications can be polled by software.
  465. */
  466. #define MLXSW_REG_SFN_ID 0x200B
  467. #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
  468. #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
  469. #define MLXSW_REG_SFN_REC_MAX_COUNT 64
  470. #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
  471. MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
  472. MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
  473. /* reg_sfn_swid
  474. * Switch partition ID.
  475. * Access: Index
  476. */
  477. MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
  478. /* reg_sfn_end
  479. * Forces the current session to end.
  480. * Access: OP
  481. */
  482. MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
  483. /* reg_sfn_num_rec
  484. * Request: Number of learned notifications and aged-out notification
  485. * records requested.
  486. * Response: Number of notification records returned (must be smaller
  487. * than or equal to the value requested)
  488. * Ranges 0..64
  489. * Access: OP
  490. */
  491. MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
  492. static inline void mlxsw_reg_sfn_pack(char *payload)
  493. {
  494. MLXSW_REG_ZERO(sfn, payload);
  495. mlxsw_reg_sfn_swid_set(payload, 0);
  496. mlxsw_reg_sfn_end_set(payload, 1);
  497. mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
  498. }
  499. /* reg_sfn_rec_swid
  500. * Switch partition ID.
  501. * Access: RO
  502. */
  503. MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
  504. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  505. enum mlxsw_reg_sfn_rec_type {
  506. /* MAC addresses learned on a regular port. */
  507. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
  508. /* MAC addresses learned on a LAG port. */
  509. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
  510. /* Aged-out MAC address on a regular port. */
  511. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
  512. /* Aged-out MAC address on a LAG port. */
  513. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
  514. };
  515. /* reg_sfn_rec_type
  516. * Notification record type.
  517. * Access: RO
  518. */
  519. MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
  520. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  521. /* reg_sfn_rec_mac
  522. * MAC address.
  523. * Access: RO
  524. */
  525. MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
  526. MLXSW_REG_SFN_REC_LEN, 0x02);
  527. /* reg_sfn_mac_sub_port
  528. * VEPA channel on the local port.
  529. * 0 if multichannel VEPA is not enabled.
  530. * Access: RO
  531. */
  532. MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
  533. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  534. /* reg_sfn_mac_fid
  535. * Filtering identifier.
  536. * Access: RO
  537. */
  538. MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  539. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  540. /* reg_sfn_mac_system_port
  541. * Unique port identifier for the final destination of the packet.
  542. * Access: RO
  543. */
  544. MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  545. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  546. static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
  547. char *mac, u16 *p_vid,
  548. u8 *p_local_port)
  549. {
  550. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  551. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  552. *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
  553. }
  554. /* reg_sfn_mac_lag_lag_id
  555. * LAG ID (pointer into the LAG descriptor table).
  556. * Access: RO
  557. */
  558. MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
  559. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  560. static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
  561. char *mac, u16 *p_vid,
  562. u16 *p_lag_id)
  563. {
  564. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  565. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  566. *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
  567. }
  568. /* SPMS - Switch Port MSTP/RSTP State Register
  569. * -------------------------------------------
  570. * Configures the spanning tree state of a physical port.
  571. */
  572. #define MLXSW_REG_SPMS_ID 0x200D
  573. #define MLXSW_REG_SPMS_LEN 0x404
  574. MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
  575. /* reg_spms_local_port
  576. * Local port number.
  577. * Access: Index
  578. */
  579. MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
  580. enum mlxsw_reg_spms_state {
  581. MLXSW_REG_SPMS_STATE_NO_CHANGE,
  582. MLXSW_REG_SPMS_STATE_DISCARDING,
  583. MLXSW_REG_SPMS_STATE_LEARNING,
  584. MLXSW_REG_SPMS_STATE_FORWARDING,
  585. };
  586. /* reg_spms_state
  587. * Spanning tree state of each VLAN ID (VID) of the local port.
  588. * 0 - Do not change spanning tree state (used only when writing).
  589. * 1 - Discarding. No learning or forwarding to/from this port (default).
  590. * 2 - Learning. Port is learning, but not forwarding.
  591. * 3 - Forwarding. Port is learning and forwarding.
  592. * Access: RW
  593. */
  594. MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
  595. static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
  596. {
  597. MLXSW_REG_ZERO(spms, payload);
  598. mlxsw_reg_spms_local_port_set(payload, local_port);
  599. }
  600. static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
  601. enum mlxsw_reg_spms_state state)
  602. {
  603. mlxsw_reg_spms_state_set(payload, vid, state);
  604. }
  605. /* SPVID - Switch Port VID
  606. * -----------------------
  607. * The switch port VID configures the default VID for a port.
  608. */
  609. #define MLXSW_REG_SPVID_ID 0x200E
  610. #define MLXSW_REG_SPVID_LEN 0x08
  611. MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
  612. /* reg_spvid_local_port
  613. * Local port number.
  614. * Access: Index
  615. */
  616. MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
  617. /* reg_spvid_sub_port
  618. * Virtual port within the physical port.
  619. * Should be set to 0 when virtual ports are not enabled on the port.
  620. * Access: Index
  621. */
  622. MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
  623. /* reg_spvid_pvid
  624. * Port default VID
  625. * Access: RW
  626. */
  627. MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
  628. static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
  629. {
  630. MLXSW_REG_ZERO(spvid, payload);
  631. mlxsw_reg_spvid_local_port_set(payload, local_port);
  632. mlxsw_reg_spvid_pvid_set(payload, pvid);
  633. }
  634. /* SPVM - Switch Port VLAN Membership
  635. * ----------------------------------
  636. * The Switch Port VLAN Membership register configures the VLAN membership
  637. * of a port in a VLAN denoted by VID. VLAN membership is managed per
  638. * virtual port. The register can be used to add and remove VID(s) from a port.
  639. */
  640. #define MLXSW_REG_SPVM_ID 0x200F
  641. #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
  642. #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
  643. #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
  644. #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
  645. MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
  646. MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
  647. /* reg_spvm_pt
  648. * Priority tagged. If this bit is set, packets forwarded to the port with
  649. * untagged VLAN membership (u bit is set) will be tagged with priority tag
  650. * (VID=0)
  651. * Access: RW
  652. */
  653. MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
  654. /* reg_spvm_pte
  655. * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
  656. * the pt bit will NOT be updated. To update the pt bit, pte must be set.
  657. * Access: WO
  658. */
  659. MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
  660. /* reg_spvm_local_port
  661. * Local port number.
  662. * Access: Index
  663. */
  664. MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
  665. /* reg_spvm_sub_port
  666. * Virtual port within the physical port.
  667. * Should be set to 0 when virtual ports are not enabled on the port.
  668. * Access: Index
  669. */
  670. MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
  671. /* reg_spvm_num_rec
  672. * Number of records to update. Each record contains: i, e, u, vid.
  673. * Access: OP
  674. */
  675. MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
  676. /* reg_spvm_rec_i
  677. * Ingress membership in VLAN ID.
  678. * Access: Index
  679. */
  680. MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
  681. MLXSW_REG_SPVM_BASE_LEN, 14, 1,
  682. MLXSW_REG_SPVM_REC_LEN, 0, false);
  683. /* reg_spvm_rec_e
  684. * Egress membership in VLAN ID.
  685. * Access: Index
  686. */
  687. MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
  688. MLXSW_REG_SPVM_BASE_LEN, 13, 1,
  689. MLXSW_REG_SPVM_REC_LEN, 0, false);
  690. /* reg_spvm_rec_u
  691. * Untagged - port is an untagged member - egress transmission uses untagged
  692. * frames on VID<n>
  693. * Access: Index
  694. */
  695. MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
  696. MLXSW_REG_SPVM_BASE_LEN, 12, 1,
  697. MLXSW_REG_SPVM_REC_LEN, 0, false);
  698. /* reg_spvm_rec_vid
  699. * Egress membership in VLAN ID.
  700. * Access: Index
  701. */
  702. MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
  703. MLXSW_REG_SPVM_BASE_LEN, 0, 12,
  704. MLXSW_REG_SPVM_REC_LEN, 0, false);
  705. static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
  706. u16 vid_begin, u16 vid_end,
  707. bool is_member, bool untagged)
  708. {
  709. int size = vid_end - vid_begin + 1;
  710. int i;
  711. MLXSW_REG_ZERO(spvm, payload);
  712. mlxsw_reg_spvm_local_port_set(payload, local_port);
  713. mlxsw_reg_spvm_num_rec_set(payload, size);
  714. for (i = 0; i < size; i++) {
  715. mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
  716. mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
  717. mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
  718. mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
  719. }
  720. }
  721. /* SPAFT - Switch Port Acceptable Frame Types
  722. * ------------------------------------------
  723. * The Switch Port Acceptable Frame Types register configures the frame
  724. * admittance of the port.
  725. */
  726. #define MLXSW_REG_SPAFT_ID 0x2010
  727. #define MLXSW_REG_SPAFT_LEN 0x08
  728. MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
  729. /* reg_spaft_local_port
  730. * Local port number.
  731. * Access: Index
  732. *
  733. * Note: CPU port is not supported (all tag types are allowed).
  734. */
  735. MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
  736. /* reg_spaft_sub_port
  737. * Virtual port within the physical port.
  738. * Should be set to 0 when virtual ports are not enabled on the port.
  739. * Access: RW
  740. */
  741. MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
  742. /* reg_spaft_allow_untagged
  743. * When set, untagged frames on the ingress are allowed (default).
  744. * Access: RW
  745. */
  746. MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
  747. /* reg_spaft_allow_prio_tagged
  748. * When set, priority tagged frames on the ingress are allowed (default).
  749. * Access: RW
  750. */
  751. MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
  752. /* reg_spaft_allow_tagged
  753. * When set, tagged frames on the ingress are allowed (default).
  754. * Access: RW
  755. */
  756. MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
  757. static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
  758. bool allow_untagged)
  759. {
  760. MLXSW_REG_ZERO(spaft, payload);
  761. mlxsw_reg_spaft_local_port_set(payload, local_port);
  762. mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
  763. mlxsw_reg_spaft_allow_prio_tagged_set(payload, allow_untagged);
  764. mlxsw_reg_spaft_allow_tagged_set(payload, true);
  765. }
  766. /* SFGC - Switch Flooding Group Configuration
  767. * ------------------------------------------
  768. * The following register controls the association of flooding tables and MIDs
  769. * to packet types used for flooding.
  770. */
  771. #define MLXSW_REG_SFGC_ID 0x2011
  772. #define MLXSW_REG_SFGC_LEN 0x10
  773. MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
  774. enum mlxsw_reg_sfgc_type {
  775. MLXSW_REG_SFGC_TYPE_BROADCAST,
  776. MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
  777. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
  778. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
  779. MLXSW_REG_SFGC_TYPE_RESERVED,
  780. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
  781. MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
  782. MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
  783. MLXSW_REG_SFGC_TYPE_MAX,
  784. };
  785. /* reg_sfgc_type
  786. * The traffic type to reach the flooding table.
  787. * Access: Index
  788. */
  789. MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
  790. enum mlxsw_reg_sfgc_bridge_type {
  791. MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
  792. MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
  793. };
  794. /* reg_sfgc_bridge_type
  795. * Access: Index
  796. *
  797. * Note: SwitchX-2 only supports 802.1Q mode.
  798. */
  799. MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
  800. enum mlxsw_flood_table_type {
  801. MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
  802. MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
  803. MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
  804. MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFSET = 3,
  805. MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
  806. };
  807. /* reg_sfgc_table_type
  808. * See mlxsw_flood_table_type
  809. * Access: RW
  810. *
  811. * Note: FID offset and FID types are not supported in SwitchX-2.
  812. */
  813. MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
  814. /* reg_sfgc_flood_table
  815. * Flooding table index to associate with the specific type on the specific
  816. * switch partition.
  817. * Access: RW
  818. */
  819. MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
  820. /* reg_sfgc_mid
  821. * The multicast ID for the swid. Not supported for Spectrum
  822. * Access: RW
  823. */
  824. MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
  825. /* reg_sfgc_counter_set_type
  826. * Counter Set Type for flow counters.
  827. * Access: RW
  828. */
  829. MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
  830. /* reg_sfgc_counter_index
  831. * Counter Index for flow counters.
  832. * Access: RW
  833. */
  834. MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
  835. static inline void
  836. mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
  837. enum mlxsw_reg_sfgc_bridge_type bridge_type,
  838. enum mlxsw_flood_table_type table_type,
  839. unsigned int flood_table)
  840. {
  841. MLXSW_REG_ZERO(sfgc, payload);
  842. mlxsw_reg_sfgc_type_set(payload, type);
  843. mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
  844. mlxsw_reg_sfgc_table_type_set(payload, table_type);
  845. mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
  846. mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
  847. }
  848. /* SFTR - Switch Flooding Table Register
  849. * -------------------------------------
  850. * The switch flooding table is used for flooding packet replication. The table
  851. * defines a bit mask of ports for packet replication.
  852. */
  853. #define MLXSW_REG_SFTR_ID 0x2012
  854. #define MLXSW_REG_SFTR_LEN 0x420
  855. MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
  856. /* reg_sftr_swid
  857. * Switch partition ID with which to associate the port.
  858. * Access: Index
  859. */
  860. MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
  861. /* reg_sftr_flood_table
  862. * Flooding table index to associate with the specific type on the specific
  863. * switch partition.
  864. * Access: Index
  865. */
  866. MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
  867. /* reg_sftr_index
  868. * Index. Used as an index into the Flooding Table in case the table is
  869. * configured to use VID / FID or FID Offset.
  870. * Access: Index
  871. */
  872. MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
  873. /* reg_sftr_table_type
  874. * See mlxsw_flood_table_type
  875. * Access: RW
  876. */
  877. MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
  878. /* reg_sftr_range
  879. * Range of entries to update
  880. * Access: Index
  881. */
  882. MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
  883. /* reg_sftr_port
  884. * Local port membership (1 bit per port).
  885. * Access: RW
  886. */
  887. MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
  888. /* reg_sftr_cpu_port_mask
  889. * CPU port mask (1 bit per port).
  890. * Access: W
  891. */
  892. MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
  893. static inline void mlxsw_reg_sftr_pack(char *payload,
  894. unsigned int flood_table,
  895. unsigned int index,
  896. enum mlxsw_flood_table_type table_type,
  897. unsigned int range, u8 port, bool set)
  898. {
  899. MLXSW_REG_ZERO(sftr, payload);
  900. mlxsw_reg_sftr_swid_set(payload, 0);
  901. mlxsw_reg_sftr_flood_table_set(payload, flood_table);
  902. mlxsw_reg_sftr_index_set(payload, index);
  903. mlxsw_reg_sftr_table_type_set(payload, table_type);
  904. mlxsw_reg_sftr_range_set(payload, range);
  905. mlxsw_reg_sftr_port_set(payload, port, set);
  906. mlxsw_reg_sftr_port_mask_set(payload, port, 1);
  907. }
  908. /* SFDF - Switch Filtering DB Flush
  909. * --------------------------------
  910. * The switch filtering DB flush register is used to flush the FDB.
  911. * Note that FDB notifications are flushed as well.
  912. */
  913. #define MLXSW_REG_SFDF_ID 0x2013
  914. #define MLXSW_REG_SFDF_LEN 0x14
  915. MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
  916. /* reg_sfdf_swid
  917. * Switch partition ID.
  918. * Access: Index
  919. */
  920. MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
  921. enum mlxsw_reg_sfdf_flush_type {
  922. MLXSW_REG_SFDF_FLUSH_PER_SWID,
  923. MLXSW_REG_SFDF_FLUSH_PER_FID,
  924. MLXSW_REG_SFDF_FLUSH_PER_PORT,
  925. MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
  926. MLXSW_REG_SFDF_FLUSH_PER_LAG,
  927. MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
  928. };
  929. /* reg_sfdf_flush_type
  930. * Flush type.
  931. * 0 - All SWID dynamic entries are flushed.
  932. * 1 - All FID dynamic entries are flushed.
  933. * 2 - All dynamic entries pointing to port are flushed.
  934. * 3 - All FID dynamic entries pointing to port are flushed.
  935. * 4 - All dynamic entries pointing to LAG are flushed.
  936. * 5 - All FID dynamic entries pointing to LAG are flushed.
  937. * Access: RW
  938. */
  939. MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
  940. /* reg_sfdf_flush_static
  941. * Static.
  942. * 0 - Flush only dynamic entries.
  943. * 1 - Flush both dynamic and static entries.
  944. * Access: RW
  945. */
  946. MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
  947. static inline void mlxsw_reg_sfdf_pack(char *payload,
  948. enum mlxsw_reg_sfdf_flush_type type)
  949. {
  950. MLXSW_REG_ZERO(sfdf, payload);
  951. mlxsw_reg_sfdf_flush_type_set(payload, type);
  952. mlxsw_reg_sfdf_flush_static_set(payload, true);
  953. }
  954. /* reg_sfdf_fid
  955. * FID to flush.
  956. * Access: RW
  957. */
  958. MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
  959. /* reg_sfdf_system_port
  960. * Port to flush.
  961. * Access: RW
  962. */
  963. MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
  964. /* reg_sfdf_port_fid_system_port
  965. * Port to flush, pointed to by FID.
  966. * Access: RW
  967. */
  968. MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
  969. /* reg_sfdf_lag_id
  970. * LAG ID to flush.
  971. * Access: RW
  972. */
  973. MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
  974. /* reg_sfdf_lag_fid_lag_id
  975. * LAG ID to flush, pointed to by FID.
  976. * Access: RW
  977. */
  978. MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
  979. /* SLDR - Switch LAG Descriptor Register
  980. * -----------------------------------------
  981. * The switch LAG descriptor register is populated by LAG descriptors.
  982. * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
  983. * max_lag-1.
  984. */
  985. #define MLXSW_REG_SLDR_ID 0x2014
  986. #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
  987. MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
  988. enum mlxsw_reg_sldr_op {
  989. /* Indicates a creation of a new LAG-ID, lag_id must be valid */
  990. MLXSW_REG_SLDR_OP_LAG_CREATE,
  991. MLXSW_REG_SLDR_OP_LAG_DESTROY,
  992. /* Ports that appear in the list have the Distributor enabled */
  993. MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
  994. /* Removes ports from the disributor list */
  995. MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
  996. };
  997. /* reg_sldr_op
  998. * Operation.
  999. * Access: RW
  1000. */
  1001. MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
  1002. /* reg_sldr_lag_id
  1003. * LAG identifier. The lag_id is the index into the LAG descriptor table.
  1004. * Access: Index
  1005. */
  1006. MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
  1007. static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
  1008. {
  1009. MLXSW_REG_ZERO(sldr, payload);
  1010. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
  1011. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1012. }
  1013. static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
  1014. {
  1015. MLXSW_REG_ZERO(sldr, payload);
  1016. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
  1017. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1018. }
  1019. /* reg_sldr_num_ports
  1020. * The number of member ports of the LAG.
  1021. * Reserved for Create / Destroy operations
  1022. * For Add / Remove operations - indicates the number of ports in the list.
  1023. * Access: RW
  1024. */
  1025. MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
  1026. /* reg_sldr_system_port
  1027. * System port.
  1028. * Access: RW
  1029. */
  1030. MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
  1031. static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
  1032. u8 local_port)
  1033. {
  1034. MLXSW_REG_ZERO(sldr, payload);
  1035. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
  1036. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1037. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1038. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1039. }
  1040. static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
  1041. u8 local_port)
  1042. {
  1043. MLXSW_REG_ZERO(sldr, payload);
  1044. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
  1045. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1046. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1047. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1048. }
  1049. /* SLCR - Switch LAG Configuration 2 Register
  1050. * -------------------------------------------
  1051. * The Switch LAG Configuration register is used for configuring the
  1052. * LAG properties of the switch.
  1053. */
  1054. #define MLXSW_REG_SLCR_ID 0x2015
  1055. #define MLXSW_REG_SLCR_LEN 0x10
  1056. MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
  1057. enum mlxsw_reg_slcr_pp {
  1058. /* Global Configuration (for all ports) */
  1059. MLXSW_REG_SLCR_PP_GLOBAL,
  1060. /* Per port configuration, based on local_port field */
  1061. MLXSW_REG_SLCR_PP_PER_PORT,
  1062. };
  1063. /* reg_slcr_pp
  1064. * Per Port Configuration
  1065. * Note: Reading at Global mode results in reading port 1 configuration.
  1066. * Access: Index
  1067. */
  1068. MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
  1069. /* reg_slcr_local_port
  1070. * Local port number
  1071. * Supported from CPU port
  1072. * Not supported from router port
  1073. * Reserved when pp = Global Configuration
  1074. * Access: Index
  1075. */
  1076. MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
  1077. enum mlxsw_reg_slcr_type {
  1078. MLXSW_REG_SLCR_TYPE_CRC, /* default */
  1079. MLXSW_REG_SLCR_TYPE_XOR,
  1080. MLXSW_REG_SLCR_TYPE_RANDOM,
  1081. };
  1082. /* reg_slcr_type
  1083. * Hash type
  1084. * Access: RW
  1085. */
  1086. MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
  1087. /* Ingress port */
  1088. #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
  1089. /* SMAC - for IPv4 and IPv6 packets */
  1090. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
  1091. /* SMAC - for non-IP packets */
  1092. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
  1093. #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
  1094. (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
  1095. MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
  1096. /* DMAC - for IPv4 and IPv6 packets */
  1097. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
  1098. /* DMAC - for non-IP packets */
  1099. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
  1100. #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
  1101. (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
  1102. MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
  1103. /* Ethertype - for IPv4 and IPv6 packets */
  1104. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
  1105. /* Ethertype - for non-IP packets */
  1106. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
  1107. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
  1108. (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
  1109. MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
  1110. /* VLAN ID - for IPv4 and IPv6 packets */
  1111. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
  1112. /* VLAN ID - for non-IP packets */
  1113. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
  1114. #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
  1115. (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
  1116. MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
  1117. /* Source IP address (can be IPv4 or IPv6) */
  1118. #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
  1119. /* Destination IP address (can be IPv4 or IPv6) */
  1120. #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
  1121. /* TCP/UDP source port */
  1122. #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
  1123. /* TCP/UDP destination port*/
  1124. #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
  1125. /* IPv4 Protocol/IPv6 Next Header */
  1126. #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
  1127. /* IPv6 Flow label */
  1128. #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
  1129. /* SID - FCoE source ID */
  1130. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
  1131. /* DID - FCoE destination ID */
  1132. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
  1133. /* OXID - FCoE originator exchange ID */
  1134. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
  1135. /* Destination QP number - for RoCE packets */
  1136. #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
  1137. /* reg_slcr_lag_hash
  1138. * LAG hashing configuration. This is a bitmask, in which each set
  1139. * bit includes the corresponding item in the LAG hash calculation.
  1140. * The default lag_hash contains SMAC, DMAC, VLANID and
  1141. * Ethertype (for all packet types).
  1142. * Access: RW
  1143. */
  1144. MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
  1145. static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash)
  1146. {
  1147. MLXSW_REG_ZERO(slcr, payload);
  1148. mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
  1149. mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
  1150. mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
  1151. }
  1152. /* SLCOR - Switch LAG Collector Register
  1153. * -------------------------------------
  1154. * The Switch LAG Collector register controls the Local Port membership
  1155. * in a LAG and enablement of the collector.
  1156. */
  1157. #define MLXSW_REG_SLCOR_ID 0x2016
  1158. #define MLXSW_REG_SLCOR_LEN 0x10
  1159. MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
  1160. enum mlxsw_reg_slcor_col {
  1161. /* Port is added with collector disabled */
  1162. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
  1163. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
  1164. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
  1165. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
  1166. };
  1167. /* reg_slcor_col
  1168. * Collector configuration
  1169. * Access: RW
  1170. */
  1171. MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
  1172. /* reg_slcor_local_port
  1173. * Local port number
  1174. * Not supported for CPU port
  1175. * Access: Index
  1176. */
  1177. MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
  1178. /* reg_slcor_lag_id
  1179. * LAG Identifier. Index into the LAG descriptor table.
  1180. * Access: Index
  1181. */
  1182. MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
  1183. /* reg_slcor_port_index
  1184. * Port index in the LAG list. Only valid on Add Port to LAG col.
  1185. * Valid range is from 0 to cap_max_lag_members-1
  1186. * Access: RW
  1187. */
  1188. MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
  1189. static inline void mlxsw_reg_slcor_pack(char *payload,
  1190. u8 local_port, u16 lag_id,
  1191. enum mlxsw_reg_slcor_col col)
  1192. {
  1193. MLXSW_REG_ZERO(slcor, payload);
  1194. mlxsw_reg_slcor_col_set(payload, col);
  1195. mlxsw_reg_slcor_local_port_set(payload, local_port);
  1196. mlxsw_reg_slcor_lag_id_set(payload, lag_id);
  1197. }
  1198. static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
  1199. u8 local_port, u16 lag_id,
  1200. u8 port_index)
  1201. {
  1202. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1203. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
  1204. mlxsw_reg_slcor_port_index_set(payload, port_index);
  1205. }
  1206. static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
  1207. u8 local_port, u16 lag_id)
  1208. {
  1209. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1210. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
  1211. }
  1212. static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
  1213. u8 local_port, u16 lag_id)
  1214. {
  1215. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1216. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1217. }
  1218. static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
  1219. u8 local_port, u16 lag_id)
  1220. {
  1221. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1222. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1223. }
  1224. /* SPMLR - Switch Port MAC Learning Register
  1225. * -----------------------------------------
  1226. * Controls the Switch MAC learning policy per port.
  1227. */
  1228. #define MLXSW_REG_SPMLR_ID 0x2018
  1229. #define MLXSW_REG_SPMLR_LEN 0x8
  1230. MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
  1231. /* reg_spmlr_local_port
  1232. * Local port number.
  1233. * Access: Index
  1234. */
  1235. MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
  1236. /* reg_spmlr_sub_port
  1237. * Virtual port within the physical port.
  1238. * Should be set to 0 when virtual ports are not enabled on the port.
  1239. * Access: Index
  1240. */
  1241. MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
  1242. enum mlxsw_reg_spmlr_learn_mode {
  1243. MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
  1244. MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
  1245. MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
  1246. };
  1247. /* reg_spmlr_learn_mode
  1248. * Learning mode on the port.
  1249. * 0 - Learning disabled.
  1250. * 2 - Learning enabled.
  1251. * 3 - Security mode.
  1252. *
  1253. * In security mode the switch does not learn MACs on the port, but uses the
  1254. * SMAC to see if it exists on another ingress port. If so, the packet is
  1255. * classified as a bad packet and is discarded unless the software registers
  1256. * to receive port security error packets usign HPKT.
  1257. */
  1258. MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
  1259. static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
  1260. enum mlxsw_reg_spmlr_learn_mode mode)
  1261. {
  1262. MLXSW_REG_ZERO(spmlr, payload);
  1263. mlxsw_reg_spmlr_local_port_set(payload, local_port);
  1264. mlxsw_reg_spmlr_sub_port_set(payload, 0);
  1265. mlxsw_reg_spmlr_learn_mode_set(payload, mode);
  1266. }
  1267. /* SVFA - Switch VID to FID Allocation Register
  1268. * --------------------------------------------
  1269. * Controls the VID to FID mapping and {Port, VID} to FID mapping for
  1270. * virtualized ports.
  1271. */
  1272. #define MLXSW_REG_SVFA_ID 0x201C
  1273. #define MLXSW_REG_SVFA_LEN 0x10
  1274. MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
  1275. /* reg_svfa_swid
  1276. * Switch partition ID.
  1277. * Access: Index
  1278. */
  1279. MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
  1280. /* reg_svfa_local_port
  1281. * Local port number.
  1282. * Access: Index
  1283. *
  1284. * Note: Reserved for 802.1Q FIDs.
  1285. */
  1286. MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
  1287. enum mlxsw_reg_svfa_mt {
  1288. MLXSW_REG_SVFA_MT_VID_TO_FID,
  1289. MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
  1290. };
  1291. /* reg_svfa_mapping_table
  1292. * Mapping table:
  1293. * 0 - VID to FID
  1294. * 1 - {Port, VID} to FID
  1295. * Access: Index
  1296. *
  1297. * Note: Reserved for SwitchX-2.
  1298. */
  1299. MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
  1300. /* reg_svfa_v
  1301. * Valid.
  1302. * Valid if set.
  1303. * Access: RW
  1304. *
  1305. * Note: Reserved for SwitchX-2.
  1306. */
  1307. MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
  1308. /* reg_svfa_fid
  1309. * Filtering ID.
  1310. * Access: RW
  1311. */
  1312. MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
  1313. /* reg_svfa_vid
  1314. * VLAN ID.
  1315. * Access: Index
  1316. */
  1317. MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
  1318. /* reg_svfa_counter_set_type
  1319. * Counter set type for flow counters.
  1320. * Access: RW
  1321. *
  1322. * Note: Reserved for SwitchX-2.
  1323. */
  1324. MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
  1325. /* reg_svfa_counter_index
  1326. * Counter index for flow counters.
  1327. * Access: RW
  1328. *
  1329. * Note: Reserved for SwitchX-2.
  1330. */
  1331. MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
  1332. static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
  1333. enum mlxsw_reg_svfa_mt mt, bool valid,
  1334. u16 fid, u16 vid)
  1335. {
  1336. MLXSW_REG_ZERO(svfa, payload);
  1337. local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
  1338. mlxsw_reg_svfa_swid_set(payload, 0);
  1339. mlxsw_reg_svfa_local_port_set(payload, local_port);
  1340. mlxsw_reg_svfa_mapping_table_set(payload, mt);
  1341. mlxsw_reg_svfa_v_set(payload, valid);
  1342. mlxsw_reg_svfa_fid_set(payload, fid);
  1343. mlxsw_reg_svfa_vid_set(payload, vid);
  1344. }
  1345. /* SVPE - Switch Virtual-Port Enabling Register
  1346. * --------------------------------------------
  1347. * Enables port virtualization.
  1348. */
  1349. #define MLXSW_REG_SVPE_ID 0x201E
  1350. #define MLXSW_REG_SVPE_LEN 0x4
  1351. MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
  1352. /* reg_svpe_local_port
  1353. * Local port number
  1354. * Access: Index
  1355. *
  1356. * Note: CPU port is not supported (uses VLAN mode only).
  1357. */
  1358. MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
  1359. /* reg_svpe_vp_en
  1360. * Virtual port enable.
  1361. * 0 - Disable, VLAN mode (VID to FID).
  1362. * 1 - Enable, Virtual port mode ({Port, VID} to FID).
  1363. * Access: RW
  1364. */
  1365. MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
  1366. static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
  1367. bool enable)
  1368. {
  1369. MLXSW_REG_ZERO(svpe, payload);
  1370. mlxsw_reg_svpe_local_port_set(payload, local_port);
  1371. mlxsw_reg_svpe_vp_en_set(payload, enable);
  1372. }
  1373. /* SFMR - Switch FID Management Register
  1374. * -------------------------------------
  1375. * Creates and configures FIDs.
  1376. */
  1377. #define MLXSW_REG_SFMR_ID 0x201F
  1378. #define MLXSW_REG_SFMR_LEN 0x18
  1379. MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
  1380. enum mlxsw_reg_sfmr_op {
  1381. MLXSW_REG_SFMR_OP_CREATE_FID,
  1382. MLXSW_REG_SFMR_OP_DESTROY_FID,
  1383. };
  1384. /* reg_sfmr_op
  1385. * Operation.
  1386. * 0 - Create or edit FID.
  1387. * 1 - Destroy FID.
  1388. * Access: WO
  1389. */
  1390. MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
  1391. /* reg_sfmr_fid
  1392. * Filtering ID.
  1393. * Access: Index
  1394. */
  1395. MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
  1396. /* reg_sfmr_fid_offset
  1397. * FID offset.
  1398. * Used to point into the flooding table selected by SFGC register if
  1399. * the table is of type FID-Offset. Otherwise, this field is reserved.
  1400. * Access: RW
  1401. */
  1402. MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
  1403. /* reg_sfmr_vtfp
  1404. * Valid Tunnel Flood Pointer.
  1405. * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
  1406. * Access: RW
  1407. *
  1408. * Note: Reserved for 802.1Q FIDs.
  1409. */
  1410. MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
  1411. /* reg_sfmr_nve_tunnel_flood_ptr
  1412. * Underlay Flooding and BC Pointer.
  1413. * Used as a pointer to the first entry of the group based link lists of
  1414. * flooding or BC entries (for NVE tunnels).
  1415. * Access: RW
  1416. */
  1417. MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
  1418. /* reg_sfmr_vv
  1419. * VNI Valid.
  1420. * If not set, then vni is reserved.
  1421. * Access: RW
  1422. *
  1423. * Note: Reserved for 802.1Q FIDs.
  1424. */
  1425. MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
  1426. /* reg_sfmr_vni
  1427. * Virtual Network Identifier.
  1428. * Access: RW
  1429. *
  1430. * Note: A given VNI can only be assigned to one FID.
  1431. */
  1432. MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
  1433. static inline void mlxsw_reg_sfmr_pack(char *payload,
  1434. enum mlxsw_reg_sfmr_op op, u16 fid,
  1435. u16 fid_offset)
  1436. {
  1437. MLXSW_REG_ZERO(sfmr, payload);
  1438. mlxsw_reg_sfmr_op_set(payload, op);
  1439. mlxsw_reg_sfmr_fid_set(payload, fid);
  1440. mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
  1441. mlxsw_reg_sfmr_vtfp_set(payload, false);
  1442. mlxsw_reg_sfmr_vv_set(payload, false);
  1443. }
  1444. /* SPVMLR - Switch Port VLAN MAC Learning Register
  1445. * -----------------------------------------------
  1446. * Controls the switch MAC learning policy per {Port, VID}.
  1447. */
  1448. #define MLXSW_REG_SPVMLR_ID 0x2020
  1449. #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
  1450. #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
  1451. #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
  1452. #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
  1453. MLXSW_REG_SPVMLR_REC_LEN * \
  1454. MLXSW_REG_SPVMLR_REC_MAX_COUNT)
  1455. MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
  1456. /* reg_spvmlr_local_port
  1457. * Local ingress port.
  1458. * Access: Index
  1459. *
  1460. * Note: CPU port is not supported.
  1461. */
  1462. MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
  1463. /* reg_spvmlr_num_rec
  1464. * Number of records to update.
  1465. * Access: OP
  1466. */
  1467. MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
  1468. /* reg_spvmlr_rec_learn_enable
  1469. * 0 - Disable learning for {Port, VID}.
  1470. * 1 - Enable learning for {Port, VID}.
  1471. * Access: RW
  1472. */
  1473. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
  1474. 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1475. /* reg_spvmlr_rec_vid
  1476. * VLAN ID to be added/removed from port or for querying.
  1477. * Access: Index
  1478. */
  1479. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
  1480. MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1481. static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
  1482. u16 vid_begin, u16 vid_end,
  1483. bool learn_enable)
  1484. {
  1485. int num_rec = vid_end - vid_begin + 1;
  1486. int i;
  1487. WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
  1488. MLXSW_REG_ZERO(spvmlr, payload);
  1489. mlxsw_reg_spvmlr_local_port_set(payload, local_port);
  1490. mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
  1491. for (i = 0; i < num_rec; i++) {
  1492. mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
  1493. mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
  1494. }
  1495. }
  1496. /* CWTP - Congetion WRED ECN TClass Profile
  1497. * ----------------------------------------
  1498. * Configures the profiles for queues of egress port and traffic class
  1499. */
  1500. #define MLXSW_REG_CWTP_ID 0x2802
  1501. #define MLXSW_REG_CWTP_BASE_LEN 0x28
  1502. #define MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN 0x08
  1503. #define MLXSW_REG_CWTP_LEN 0x40
  1504. MLXSW_REG_DEFINE(cwtp, MLXSW_REG_CWTP_ID, MLXSW_REG_CWTP_LEN);
  1505. /* reg_cwtp_local_port
  1506. * Local port number
  1507. * Not supported for CPU port
  1508. * Access: Index
  1509. */
  1510. MLXSW_ITEM32(reg, cwtp, local_port, 0, 16, 8);
  1511. /* reg_cwtp_traffic_class
  1512. * Traffic Class to configure
  1513. * Access: Index
  1514. */
  1515. MLXSW_ITEM32(reg, cwtp, traffic_class, 32, 0, 8);
  1516. /* reg_cwtp_profile_min
  1517. * Minimum Average Queue Size of the profile in cells.
  1518. * Access: RW
  1519. */
  1520. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_min, MLXSW_REG_CWTP_BASE_LEN,
  1521. 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 0, false);
  1522. /* reg_cwtp_profile_percent
  1523. * Percentage of WRED and ECN marking for maximum Average Queue size
  1524. * Range is 0 to 100, units of integer percentage
  1525. * Access: RW
  1526. */
  1527. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_percent, MLXSW_REG_CWTP_BASE_LEN,
  1528. 24, 7, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
  1529. /* reg_cwtp_profile_max
  1530. * Maximum Average Queue size of the profile in cells
  1531. * Access: RW
  1532. */
  1533. MLXSW_ITEM32_INDEXED(reg, cwtp, profile_max, MLXSW_REG_CWTP_BASE_LEN,
  1534. 0, 20, MLXSW_REG_CWTP_PROFILE_DATA_REC_LEN, 4, false);
  1535. #define MLXSW_REG_CWTP_MIN_VALUE 64
  1536. #define MLXSW_REG_CWTP_MAX_PROFILE 2
  1537. #define MLXSW_REG_CWTP_DEFAULT_PROFILE 1
  1538. static inline void mlxsw_reg_cwtp_pack(char *payload, u8 local_port,
  1539. u8 traffic_class)
  1540. {
  1541. int i;
  1542. MLXSW_REG_ZERO(cwtp, payload);
  1543. mlxsw_reg_cwtp_local_port_set(payload, local_port);
  1544. mlxsw_reg_cwtp_traffic_class_set(payload, traffic_class);
  1545. for (i = 0; i <= MLXSW_REG_CWTP_MAX_PROFILE; i++) {
  1546. mlxsw_reg_cwtp_profile_min_set(payload, i,
  1547. MLXSW_REG_CWTP_MIN_VALUE);
  1548. mlxsw_reg_cwtp_profile_max_set(payload, i,
  1549. MLXSW_REG_CWTP_MIN_VALUE);
  1550. }
  1551. }
  1552. #define MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile) (profile - 1)
  1553. static inline void
  1554. mlxsw_reg_cwtp_profile_pack(char *payload, u8 profile, u32 min, u32 max,
  1555. u32 probability)
  1556. {
  1557. u8 index = MLXSW_REG_CWTP_PROFILE_TO_INDEX(profile);
  1558. mlxsw_reg_cwtp_profile_min_set(payload, index, min);
  1559. mlxsw_reg_cwtp_profile_max_set(payload, index, max);
  1560. mlxsw_reg_cwtp_profile_percent_set(payload, index, probability);
  1561. }
  1562. /* CWTPM - Congestion WRED ECN TClass and Pool Mapping
  1563. * ---------------------------------------------------
  1564. * The CWTPM register maps each egress port and traffic class to profile num.
  1565. */
  1566. #define MLXSW_REG_CWTPM_ID 0x2803
  1567. #define MLXSW_REG_CWTPM_LEN 0x44
  1568. MLXSW_REG_DEFINE(cwtpm, MLXSW_REG_CWTPM_ID, MLXSW_REG_CWTPM_LEN);
  1569. /* reg_cwtpm_local_port
  1570. * Local port number
  1571. * Not supported for CPU port
  1572. * Access: Index
  1573. */
  1574. MLXSW_ITEM32(reg, cwtpm, local_port, 0, 16, 8);
  1575. /* reg_cwtpm_traffic_class
  1576. * Traffic Class to configure
  1577. * Access: Index
  1578. */
  1579. MLXSW_ITEM32(reg, cwtpm, traffic_class, 32, 0, 8);
  1580. /* reg_cwtpm_ew
  1581. * Control enablement of WRED for traffic class:
  1582. * 0 - Disable
  1583. * 1 - Enable
  1584. * Access: RW
  1585. */
  1586. MLXSW_ITEM32(reg, cwtpm, ew, 36, 1, 1);
  1587. /* reg_cwtpm_ee
  1588. * Control enablement of ECN for traffic class:
  1589. * 0 - Disable
  1590. * 1 - Enable
  1591. * Access: RW
  1592. */
  1593. MLXSW_ITEM32(reg, cwtpm, ee, 36, 0, 1);
  1594. /* reg_cwtpm_tcp_g
  1595. * TCP Green Profile.
  1596. * Index of the profile within {port, traffic class} to use.
  1597. * 0 for disabling both WRED and ECN for this type of traffic.
  1598. * Access: RW
  1599. */
  1600. MLXSW_ITEM32(reg, cwtpm, tcp_g, 52, 0, 2);
  1601. /* reg_cwtpm_tcp_y
  1602. * TCP Yellow Profile.
  1603. * Index of the profile within {port, traffic class} to use.
  1604. * 0 for disabling both WRED and ECN for this type of traffic.
  1605. * Access: RW
  1606. */
  1607. MLXSW_ITEM32(reg, cwtpm, tcp_y, 56, 16, 2);
  1608. /* reg_cwtpm_tcp_r
  1609. * TCP Red Profile.
  1610. * Index of the profile within {port, traffic class} to use.
  1611. * 0 for disabling both WRED and ECN for this type of traffic.
  1612. * Access: RW
  1613. */
  1614. MLXSW_ITEM32(reg, cwtpm, tcp_r, 56, 0, 2);
  1615. /* reg_cwtpm_ntcp_g
  1616. * Non-TCP Green Profile.
  1617. * Index of the profile within {port, traffic class} to use.
  1618. * 0 for disabling both WRED and ECN for this type of traffic.
  1619. * Access: RW
  1620. */
  1621. MLXSW_ITEM32(reg, cwtpm, ntcp_g, 60, 0, 2);
  1622. /* reg_cwtpm_ntcp_y
  1623. * Non-TCP Yellow Profile.
  1624. * Index of the profile within {port, traffic class} to use.
  1625. * 0 for disabling both WRED and ECN for this type of traffic.
  1626. * Access: RW
  1627. */
  1628. MLXSW_ITEM32(reg, cwtpm, ntcp_y, 64, 16, 2);
  1629. /* reg_cwtpm_ntcp_r
  1630. * Non-TCP Red Profile.
  1631. * Index of the profile within {port, traffic class} to use.
  1632. * 0 for disabling both WRED and ECN for this type of traffic.
  1633. * Access: RW
  1634. */
  1635. MLXSW_ITEM32(reg, cwtpm, ntcp_r, 64, 0, 2);
  1636. #define MLXSW_REG_CWTPM_RESET_PROFILE 0
  1637. static inline void mlxsw_reg_cwtpm_pack(char *payload, u8 local_port,
  1638. u8 traffic_class, u8 profile,
  1639. bool wred, bool ecn)
  1640. {
  1641. MLXSW_REG_ZERO(cwtpm, payload);
  1642. mlxsw_reg_cwtpm_local_port_set(payload, local_port);
  1643. mlxsw_reg_cwtpm_traffic_class_set(payload, traffic_class);
  1644. mlxsw_reg_cwtpm_ew_set(payload, wred);
  1645. mlxsw_reg_cwtpm_ee_set(payload, ecn);
  1646. mlxsw_reg_cwtpm_tcp_g_set(payload, profile);
  1647. mlxsw_reg_cwtpm_tcp_y_set(payload, profile);
  1648. mlxsw_reg_cwtpm_tcp_r_set(payload, profile);
  1649. mlxsw_reg_cwtpm_ntcp_g_set(payload, profile);
  1650. mlxsw_reg_cwtpm_ntcp_y_set(payload, profile);
  1651. mlxsw_reg_cwtpm_ntcp_r_set(payload, profile);
  1652. }
  1653. /* PGCR - Policy-Engine General Configuration Register
  1654. * ---------------------------------------------------
  1655. * This register configures general Policy-Engine settings.
  1656. */
  1657. #define MLXSW_REG_PGCR_ID 0x3001
  1658. #define MLXSW_REG_PGCR_LEN 0x20
  1659. MLXSW_REG_DEFINE(pgcr, MLXSW_REG_PGCR_ID, MLXSW_REG_PGCR_LEN);
  1660. /* reg_pgcr_default_action_pointer_base
  1661. * Default action pointer base. Each region has a default action pointer
  1662. * which is equal to default_action_pointer_base + region_id.
  1663. * Access: RW
  1664. */
  1665. MLXSW_ITEM32(reg, pgcr, default_action_pointer_base, 0x1C, 0, 24);
  1666. static inline void mlxsw_reg_pgcr_pack(char *payload, u32 pointer_base)
  1667. {
  1668. MLXSW_REG_ZERO(pgcr, payload);
  1669. mlxsw_reg_pgcr_default_action_pointer_base_set(payload, pointer_base);
  1670. }
  1671. /* PPBT - Policy-Engine Port Binding Table
  1672. * ---------------------------------------
  1673. * This register is used for configuration of the Port Binding Table.
  1674. */
  1675. #define MLXSW_REG_PPBT_ID 0x3002
  1676. #define MLXSW_REG_PPBT_LEN 0x14
  1677. MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
  1678. enum mlxsw_reg_pxbt_e {
  1679. MLXSW_REG_PXBT_E_IACL,
  1680. MLXSW_REG_PXBT_E_EACL,
  1681. };
  1682. /* reg_ppbt_e
  1683. * Access: Index
  1684. */
  1685. MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
  1686. enum mlxsw_reg_pxbt_op {
  1687. MLXSW_REG_PXBT_OP_BIND,
  1688. MLXSW_REG_PXBT_OP_UNBIND,
  1689. };
  1690. /* reg_ppbt_op
  1691. * Access: RW
  1692. */
  1693. MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
  1694. /* reg_ppbt_local_port
  1695. * Local port. Not including CPU port.
  1696. * Access: Index
  1697. */
  1698. MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
  1699. /* reg_ppbt_g
  1700. * group - When set, the binding is of an ACL group. When cleared,
  1701. * the binding is of an ACL.
  1702. * Must be set to 1 for Spectrum.
  1703. * Access: RW
  1704. */
  1705. MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
  1706. /* reg_ppbt_acl_info
  1707. * ACL/ACL group identifier. If the g bit is set, this field should hold
  1708. * the acl_group_id, else it should hold the acl_id.
  1709. * Access: RW
  1710. */
  1711. MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
  1712. static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
  1713. enum mlxsw_reg_pxbt_op op,
  1714. u8 local_port, u16 acl_info)
  1715. {
  1716. MLXSW_REG_ZERO(ppbt, payload);
  1717. mlxsw_reg_ppbt_e_set(payload, e);
  1718. mlxsw_reg_ppbt_op_set(payload, op);
  1719. mlxsw_reg_ppbt_local_port_set(payload, local_port);
  1720. mlxsw_reg_ppbt_g_set(payload, true);
  1721. mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
  1722. }
  1723. /* PACL - Policy-Engine ACL Register
  1724. * ---------------------------------
  1725. * This register is used for configuration of the ACL.
  1726. */
  1727. #define MLXSW_REG_PACL_ID 0x3004
  1728. #define MLXSW_REG_PACL_LEN 0x70
  1729. MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
  1730. /* reg_pacl_v
  1731. * Valid. Setting the v bit makes the ACL valid. It should not be cleared
  1732. * while the ACL is bounded to either a port, VLAN or ACL rule.
  1733. * Access: RW
  1734. */
  1735. MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
  1736. /* reg_pacl_acl_id
  1737. * An identifier representing the ACL (managed by software)
  1738. * Range 0 .. cap_max_acl_regions - 1
  1739. * Access: Index
  1740. */
  1741. MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
  1742. #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
  1743. /* reg_pacl_tcam_region_info
  1744. * Opaque object that represents a TCAM region.
  1745. * Obtained through PTAR register.
  1746. * Access: RW
  1747. */
  1748. MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
  1749. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1750. static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
  1751. bool valid, const char *tcam_region_info)
  1752. {
  1753. MLXSW_REG_ZERO(pacl, payload);
  1754. mlxsw_reg_pacl_acl_id_set(payload, acl_id);
  1755. mlxsw_reg_pacl_v_set(payload, valid);
  1756. mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
  1757. }
  1758. /* PAGT - Policy-Engine ACL Group Table
  1759. * ------------------------------------
  1760. * This register is used for configuration of the ACL Group Table.
  1761. */
  1762. #define MLXSW_REG_PAGT_ID 0x3005
  1763. #define MLXSW_REG_PAGT_BASE_LEN 0x30
  1764. #define MLXSW_REG_PAGT_ACL_LEN 4
  1765. #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
  1766. #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
  1767. MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
  1768. MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
  1769. /* reg_pagt_size
  1770. * Number of ACLs in the group.
  1771. * Size 0 invalidates a group.
  1772. * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
  1773. * Total number of ACLs in all groups must be lower or equal
  1774. * to cap_max_acl_tot_groups
  1775. * Note: a group which is binded must not be invalidated
  1776. * Access: Index
  1777. */
  1778. MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
  1779. /* reg_pagt_acl_group_id
  1780. * An identifier (numbered from 0..cap_max_acl_groups-1) representing
  1781. * the ACL Group identifier (managed by software).
  1782. * Access: Index
  1783. */
  1784. MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
  1785. /* reg_pagt_acl_id
  1786. * ACL identifier
  1787. * Access: RW
  1788. */
  1789. MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
  1790. static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
  1791. {
  1792. MLXSW_REG_ZERO(pagt, payload);
  1793. mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
  1794. }
  1795. static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
  1796. u16 acl_id)
  1797. {
  1798. u8 size = mlxsw_reg_pagt_size_get(payload);
  1799. if (index >= size)
  1800. mlxsw_reg_pagt_size_set(payload, index + 1);
  1801. mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
  1802. }
  1803. /* PTAR - Policy-Engine TCAM Allocation Register
  1804. * ---------------------------------------------
  1805. * This register is used for allocation of regions in the TCAM.
  1806. * Note: Query method is not supported on this register.
  1807. */
  1808. #define MLXSW_REG_PTAR_ID 0x3006
  1809. #define MLXSW_REG_PTAR_BASE_LEN 0x20
  1810. #define MLXSW_REG_PTAR_KEY_ID_LEN 1
  1811. #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
  1812. #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
  1813. MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
  1814. MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
  1815. enum mlxsw_reg_ptar_op {
  1816. /* allocate a TCAM region */
  1817. MLXSW_REG_PTAR_OP_ALLOC,
  1818. /* resize a TCAM region */
  1819. MLXSW_REG_PTAR_OP_RESIZE,
  1820. /* deallocate TCAM region */
  1821. MLXSW_REG_PTAR_OP_FREE,
  1822. /* test allocation */
  1823. MLXSW_REG_PTAR_OP_TEST,
  1824. };
  1825. /* reg_ptar_op
  1826. * Access: OP
  1827. */
  1828. MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
  1829. /* reg_ptar_action_set_type
  1830. * Type of action set to be used on this region.
  1831. * For Spectrum and Spectrum-2, this is always type 2 - "flexible"
  1832. * Access: WO
  1833. */
  1834. MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
  1835. enum mlxsw_reg_ptar_key_type {
  1836. MLXSW_REG_PTAR_KEY_TYPE_FLEX = 0x50, /* Spetrum */
  1837. MLXSW_REG_PTAR_KEY_TYPE_FLEX2 = 0x51, /* Spectrum-2 */
  1838. };
  1839. /* reg_ptar_key_type
  1840. * TCAM key type for the region.
  1841. * Access: WO
  1842. */
  1843. MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
  1844. /* reg_ptar_region_size
  1845. * TCAM region size. When allocating/resizing this is the requested size,
  1846. * the response is the actual size. Note that actual size may be
  1847. * larger than requested.
  1848. * Allowed range 1 .. cap_max_rules-1
  1849. * Reserved during op deallocate.
  1850. * Access: WO
  1851. */
  1852. MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
  1853. /* reg_ptar_region_id
  1854. * Region identifier
  1855. * Range 0 .. cap_max_regions-1
  1856. * Access: Index
  1857. */
  1858. MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
  1859. /* reg_ptar_tcam_region_info
  1860. * Opaque object that represents the TCAM region.
  1861. * Returned when allocating a region.
  1862. * Provided by software for ACL generation and region deallocation and resize.
  1863. * Access: RW
  1864. */
  1865. MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
  1866. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1867. /* reg_ptar_flexible_key_id
  1868. * Identifier of the Flexible Key.
  1869. * Only valid if key_type == "FLEX_KEY"
  1870. * The key size will be rounded up to one of the following values:
  1871. * 9B, 18B, 36B, 54B.
  1872. * This field is reserved for in resize operation.
  1873. * Access: WO
  1874. */
  1875. MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
  1876. MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
  1877. static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
  1878. enum mlxsw_reg_ptar_key_type key_type,
  1879. u16 region_size, u16 region_id,
  1880. const char *tcam_region_info)
  1881. {
  1882. MLXSW_REG_ZERO(ptar, payload);
  1883. mlxsw_reg_ptar_op_set(payload, op);
  1884. mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
  1885. mlxsw_reg_ptar_key_type_set(payload, key_type);
  1886. mlxsw_reg_ptar_region_size_set(payload, region_size);
  1887. mlxsw_reg_ptar_region_id_set(payload, region_id);
  1888. mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
  1889. }
  1890. static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
  1891. u16 key_id)
  1892. {
  1893. mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
  1894. }
  1895. static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
  1896. {
  1897. mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
  1898. }
  1899. /* PPBS - Policy-Engine Policy Based Switching Register
  1900. * ----------------------------------------------------
  1901. * This register retrieves and sets Policy Based Switching Table entries.
  1902. */
  1903. #define MLXSW_REG_PPBS_ID 0x300C
  1904. #define MLXSW_REG_PPBS_LEN 0x14
  1905. MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
  1906. /* reg_ppbs_pbs_ptr
  1907. * Index into the PBS table.
  1908. * For Spectrum, the index points to the KVD Linear.
  1909. * Access: Index
  1910. */
  1911. MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
  1912. /* reg_ppbs_system_port
  1913. * Unique port identifier for the final destination of the packet.
  1914. * Access: RW
  1915. */
  1916. MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
  1917. static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
  1918. u16 system_port)
  1919. {
  1920. MLXSW_REG_ZERO(ppbs, payload);
  1921. mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
  1922. mlxsw_reg_ppbs_system_port_set(payload, system_port);
  1923. }
  1924. /* PRCR - Policy-Engine Rules Copy Register
  1925. * ----------------------------------------
  1926. * This register is used for accessing rules within a TCAM region.
  1927. */
  1928. #define MLXSW_REG_PRCR_ID 0x300D
  1929. #define MLXSW_REG_PRCR_LEN 0x40
  1930. MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
  1931. enum mlxsw_reg_prcr_op {
  1932. /* Move rules. Moves the rules from "tcam_region_info" starting
  1933. * at offset "offset" to "dest_tcam_region_info"
  1934. * at offset "dest_offset."
  1935. */
  1936. MLXSW_REG_PRCR_OP_MOVE,
  1937. /* Copy rules. Copies the rules from "tcam_region_info" starting
  1938. * at offset "offset" to "dest_tcam_region_info"
  1939. * at offset "dest_offset."
  1940. */
  1941. MLXSW_REG_PRCR_OP_COPY,
  1942. };
  1943. /* reg_prcr_op
  1944. * Access: OP
  1945. */
  1946. MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
  1947. /* reg_prcr_offset
  1948. * Offset within the source region to copy/move from.
  1949. * Access: Index
  1950. */
  1951. MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
  1952. /* reg_prcr_size
  1953. * The number of rules to copy/move.
  1954. * Access: WO
  1955. */
  1956. MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
  1957. /* reg_prcr_tcam_region_info
  1958. * Opaque object that represents the source TCAM region.
  1959. * Access: Index
  1960. */
  1961. MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
  1962. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1963. /* reg_prcr_dest_offset
  1964. * Offset within the source region to copy/move to.
  1965. * Access: Index
  1966. */
  1967. MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
  1968. /* reg_prcr_dest_tcam_region_info
  1969. * Opaque object that represents the destination TCAM region.
  1970. * Access: Index
  1971. */
  1972. MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
  1973. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1974. static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
  1975. const char *src_tcam_region_info,
  1976. u16 src_offset,
  1977. const char *dest_tcam_region_info,
  1978. u16 dest_offset, u16 size)
  1979. {
  1980. MLXSW_REG_ZERO(prcr, payload);
  1981. mlxsw_reg_prcr_op_set(payload, op);
  1982. mlxsw_reg_prcr_offset_set(payload, src_offset);
  1983. mlxsw_reg_prcr_size_set(payload, size);
  1984. mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
  1985. src_tcam_region_info);
  1986. mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
  1987. mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
  1988. dest_tcam_region_info);
  1989. }
  1990. /* PEFA - Policy-Engine Extended Flexible Action Register
  1991. * ------------------------------------------------------
  1992. * This register is used for accessing an extended flexible action entry
  1993. * in the central KVD Linear Database.
  1994. */
  1995. #define MLXSW_REG_PEFA_ID 0x300F
  1996. #define MLXSW_REG_PEFA_LEN 0xB0
  1997. MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
  1998. /* reg_pefa_index
  1999. * Index in the KVD Linear Centralized Database.
  2000. * Access: Index
  2001. */
  2002. MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
  2003. /* reg_pefa_a
  2004. * Index in the KVD Linear Centralized Database.
  2005. * Activity
  2006. * For a new entry: set if ca=0, clear if ca=1
  2007. * Set if a packet lookup has hit on the specific entry
  2008. * Access: RO
  2009. */
  2010. MLXSW_ITEM32(reg, pefa, a, 0x04, 29, 1);
  2011. /* reg_pefa_ca
  2012. * Clear activity
  2013. * When write: activity is according to this field
  2014. * When read: after reading the activity is cleared according to ca
  2015. * Access: OP
  2016. */
  2017. MLXSW_ITEM32(reg, pefa, ca, 0x04, 24, 1);
  2018. #define MLXSW_REG_FLEX_ACTION_SET_LEN 0xA8
  2019. /* reg_pefa_flex_action_set
  2020. * Action-set to perform when rule is matched.
  2021. * Must be zero padded if action set is shorter.
  2022. * Access: RW
  2023. */
  2024. MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08, MLXSW_REG_FLEX_ACTION_SET_LEN);
  2025. static inline void mlxsw_reg_pefa_pack(char *payload, u32 index, bool ca,
  2026. const char *flex_action_set)
  2027. {
  2028. MLXSW_REG_ZERO(pefa, payload);
  2029. mlxsw_reg_pefa_index_set(payload, index);
  2030. mlxsw_reg_pefa_ca_set(payload, ca);
  2031. if (flex_action_set)
  2032. mlxsw_reg_pefa_flex_action_set_memcpy_to(payload,
  2033. flex_action_set);
  2034. }
  2035. static inline void mlxsw_reg_pefa_unpack(char *payload, bool *p_a)
  2036. {
  2037. *p_a = mlxsw_reg_pefa_a_get(payload);
  2038. }
  2039. /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
  2040. * -----------------------------------------------------
  2041. * This register is used for accessing rules within a TCAM region.
  2042. * It is a new version of PTCE in order to support wider key,
  2043. * mask and action within a TCAM region. This register is not supported
  2044. * by SwitchX and SwitchX-2.
  2045. */
  2046. #define MLXSW_REG_PTCE2_ID 0x3017
  2047. #define MLXSW_REG_PTCE2_LEN 0x1D8
  2048. MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
  2049. /* reg_ptce2_v
  2050. * Valid.
  2051. * Access: RW
  2052. */
  2053. MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
  2054. /* reg_ptce2_a
  2055. * Activity. Set if a packet lookup has hit on the specific entry.
  2056. * To clear the "a" bit, use "clear activity" op or "clear on read" op.
  2057. * Access: RO
  2058. */
  2059. MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
  2060. enum mlxsw_reg_ptce2_op {
  2061. /* Read operation. */
  2062. MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
  2063. /* clear on read operation. Used to read entry
  2064. * and clear Activity bit.
  2065. */
  2066. MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
  2067. /* Write operation. Used to write a new entry to the table.
  2068. * All R/W fields are relevant for new entry. Activity bit is set
  2069. * for new entries - Note write with v = 0 will delete the entry.
  2070. */
  2071. MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
  2072. /* Update action. Only action set will be updated. */
  2073. MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
  2074. /* Clear activity. A bit is cleared for the entry. */
  2075. MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
  2076. };
  2077. /* reg_ptce2_op
  2078. * Access: OP
  2079. */
  2080. MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
  2081. /* reg_ptce2_offset
  2082. * Access: Index
  2083. */
  2084. MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
  2085. /* reg_ptce2_priority
  2086. * Priority of the rule, higher values win. The range is 1..cap_kvd_size-1.
  2087. * Note: priority does not have to be unique per rule.
  2088. * Within a region, higher priority should have lower offset (no limitation
  2089. * between regions in a multi-region).
  2090. * Access: RW
  2091. */
  2092. MLXSW_ITEM32(reg, ptce2, priority, 0x04, 0, 24);
  2093. /* reg_ptce2_tcam_region_info
  2094. * Opaque object that represents the TCAM region.
  2095. * Access: Index
  2096. */
  2097. MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
  2098. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2099. #define MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN 96
  2100. /* reg_ptce2_flex_key_blocks
  2101. * ACL Key.
  2102. * Access: RW
  2103. */
  2104. MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
  2105. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2106. /* reg_ptce2_mask
  2107. * mask- in the same size as key. A bit that is set directs the TCAM
  2108. * to compare the corresponding bit in key. A bit that is clear directs
  2109. * the TCAM to ignore the corresponding bit in key.
  2110. * Access: RW
  2111. */
  2112. MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
  2113. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2114. /* reg_ptce2_flex_action_set
  2115. * ACL action set.
  2116. * Access: RW
  2117. */
  2118. MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
  2119. MLXSW_REG_FLEX_ACTION_SET_LEN);
  2120. static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
  2121. enum mlxsw_reg_ptce2_op op,
  2122. const char *tcam_region_info,
  2123. u16 offset, u32 priority)
  2124. {
  2125. MLXSW_REG_ZERO(ptce2, payload);
  2126. mlxsw_reg_ptce2_v_set(payload, valid);
  2127. mlxsw_reg_ptce2_op_set(payload, op);
  2128. mlxsw_reg_ptce2_offset_set(payload, offset);
  2129. mlxsw_reg_ptce2_priority_set(payload, priority);
  2130. mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2131. }
  2132. /* PERPT - Policy-Engine ERP Table Register
  2133. * ----------------------------------------
  2134. * This register adds and removes eRPs from the eRP table.
  2135. */
  2136. #define MLXSW_REG_PERPT_ID 0x3021
  2137. #define MLXSW_REG_PERPT_LEN 0x80
  2138. MLXSW_REG_DEFINE(perpt, MLXSW_REG_PERPT_ID, MLXSW_REG_PERPT_LEN);
  2139. /* reg_perpt_erpt_bank
  2140. * eRP table bank.
  2141. * Range 0 .. cap_max_erp_table_banks - 1
  2142. * Access: Index
  2143. */
  2144. MLXSW_ITEM32(reg, perpt, erpt_bank, 0x00, 16, 4);
  2145. /* reg_perpt_erpt_index
  2146. * Index to eRP table within the eRP bank.
  2147. * Range is 0 .. cap_max_erp_table_bank_size - 1
  2148. * Access: Index
  2149. */
  2150. MLXSW_ITEM32(reg, perpt, erpt_index, 0x00, 0, 8);
  2151. enum mlxsw_reg_perpt_key_size {
  2152. MLXSW_REG_PERPT_KEY_SIZE_2KB,
  2153. MLXSW_REG_PERPT_KEY_SIZE_4KB,
  2154. MLXSW_REG_PERPT_KEY_SIZE_8KB,
  2155. MLXSW_REG_PERPT_KEY_SIZE_12KB,
  2156. };
  2157. /* reg_perpt_key_size
  2158. * Access: OP
  2159. */
  2160. MLXSW_ITEM32(reg, perpt, key_size, 0x04, 0, 4);
  2161. /* reg_perpt_bf_bypass
  2162. * 0 - The eRP is used only if bloom filter state is set for the given
  2163. * rule.
  2164. * 1 - The eRP is used regardless of bloom filter state.
  2165. * The bypass is an OR condition of region_id or eRP. See PERCR.bf_bypass
  2166. * Access: RW
  2167. */
  2168. MLXSW_ITEM32(reg, perpt, bf_bypass, 0x08, 8, 1);
  2169. /* reg_perpt_erp_id
  2170. * eRP ID for use by the rules.
  2171. * Access: RW
  2172. */
  2173. MLXSW_ITEM32(reg, perpt, erp_id, 0x08, 0, 4);
  2174. /* reg_perpt_erpt_base_bank
  2175. * Base eRP table bank, points to head of erp_vector
  2176. * Range is 0 .. cap_max_erp_table_banks - 1
  2177. * Access: OP
  2178. */
  2179. MLXSW_ITEM32(reg, perpt, erpt_base_bank, 0x0C, 16, 4);
  2180. /* reg_perpt_erpt_base_index
  2181. * Base index to eRP table within the eRP bank
  2182. * Range is 0 .. cap_max_erp_table_bank_size - 1
  2183. * Access: OP
  2184. */
  2185. MLXSW_ITEM32(reg, perpt, erpt_base_index, 0x0C, 0, 8);
  2186. /* reg_perpt_erp_index_in_vector
  2187. * eRP index in the vector.
  2188. * Access: OP
  2189. */
  2190. MLXSW_ITEM32(reg, perpt, erp_index_in_vector, 0x10, 0, 4);
  2191. /* reg_perpt_erp_vector
  2192. * eRP vector.
  2193. * Access: OP
  2194. */
  2195. MLXSW_ITEM_BIT_ARRAY(reg, perpt, erp_vector, 0x14, 4, 1);
  2196. /* reg_perpt_mask
  2197. * Mask
  2198. * 0 - A-TCAM will ignore the bit in key
  2199. * 1 - A-TCAM will compare the bit in key
  2200. * Access: RW
  2201. */
  2202. MLXSW_ITEM_BUF(reg, perpt, mask, 0x20, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2203. static inline void mlxsw_reg_perpt_erp_vector_pack(char *payload,
  2204. unsigned long *erp_vector,
  2205. unsigned long size)
  2206. {
  2207. unsigned long bit;
  2208. for_each_set_bit(bit, erp_vector, size)
  2209. mlxsw_reg_perpt_erp_vector_set(payload, bit, true);
  2210. }
  2211. static inline void
  2212. mlxsw_reg_perpt_pack(char *payload, u8 erpt_bank, u8 erpt_index,
  2213. enum mlxsw_reg_perpt_key_size key_size, u8 erp_id,
  2214. u8 erpt_base_bank, u8 erpt_base_index, u8 erp_index,
  2215. char *mask)
  2216. {
  2217. MLXSW_REG_ZERO(perpt, payload);
  2218. mlxsw_reg_perpt_erpt_bank_set(payload, erpt_bank);
  2219. mlxsw_reg_perpt_erpt_index_set(payload, erpt_index);
  2220. mlxsw_reg_perpt_key_size_set(payload, key_size);
  2221. mlxsw_reg_perpt_bf_bypass_set(payload, true);
  2222. mlxsw_reg_perpt_erp_id_set(payload, erp_id);
  2223. mlxsw_reg_perpt_erpt_base_bank_set(payload, erpt_base_bank);
  2224. mlxsw_reg_perpt_erpt_base_index_set(payload, erpt_base_index);
  2225. mlxsw_reg_perpt_erp_index_in_vector_set(payload, erp_index);
  2226. mlxsw_reg_perpt_mask_memcpy_to(payload, mask);
  2227. }
  2228. /* PERAR - Policy-Engine Region Association Register
  2229. * -------------------------------------------------
  2230. * This register associates a hw region for region_id's. Changing on the fly
  2231. * is supported by the device.
  2232. */
  2233. #define MLXSW_REG_PERAR_ID 0x3026
  2234. #define MLXSW_REG_PERAR_LEN 0x08
  2235. MLXSW_REG_DEFINE(perar, MLXSW_REG_PERAR_ID, MLXSW_REG_PERAR_LEN);
  2236. /* reg_perar_region_id
  2237. * Region identifier
  2238. * Range 0 .. cap_max_regions-1
  2239. * Access: Index
  2240. */
  2241. MLXSW_ITEM32(reg, perar, region_id, 0x00, 0, 16);
  2242. static inline unsigned int
  2243. mlxsw_reg_perar_hw_regions_needed(unsigned int block_num)
  2244. {
  2245. return DIV_ROUND_UP(block_num, 4);
  2246. }
  2247. /* reg_perar_hw_region
  2248. * HW Region
  2249. * Range 0 .. cap_max_regions-1
  2250. * Default: hw_region = region_id
  2251. * For a 8 key block region, 2 consecutive regions are used
  2252. * For a 12 key block region, 3 consecutive regions are used
  2253. * Access: RW
  2254. */
  2255. MLXSW_ITEM32(reg, perar, hw_region, 0x04, 0, 16);
  2256. static inline void mlxsw_reg_perar_pack(char *payload, u16 region_id,
  2257. u16 hw_region)
  2258. {
  2259. MLXSW_REG_ZERO(perar, payload);
  2260. mlxsw_reg_perar_region_id_set(payload, region_id);
  2261. mlxsw_reg_perar_hw_region_set(payload, hw_region);
  2262. }
  2263. /* PTCE-V3 - Policy-Engine TCAM Entry Register Version 3
  2264. * -----------------------------------------------------
  2265. * This register is a new version of PTCE-V2 in order to support the
  2266. * A-TCAM. This register is not supported by SwitchX/-2 and Spectrum.
  2267. */
  2268. #define MLXSW_REG_PTCE3_ID 0x3027
  2269. #define MLXSW_REG_PTCE3_LEN 0xF0
  2270. MLXSW_REG_DEFINE(ptce3, MLXSW_REG_PTCE3_ID, MLXSW_REG_PTCE3_LEN);
  2271. /* reg_ptce3_v
  2272. * Valid.
  2273. * Access: RW
  2274. */
  2275. MLXSW_ITEM32(reg, ptce3, v, 0x00, 31, 1);
  2276. enum mlxsw_reg_ptce3_op {
  2277. /* Write operation. Used to write a new entry to the table.
  2278. * All R/W fields are relevant for new entry. Activity bit is set
  2279. * for new entries. Write with v = 0 will delete the entry. Must
  2280. * not be used if an entry exists.
  2281. */
  2282. MLXSW_REG_PTCE3_OP_WRITE_WRITE = 0,
  2283. /* Update operation */
  2284. MLXSW_REG_PTCE3_OP_WRITE_UPDATE = 1,
  2285. /* Read operation */
  2286. MLXSW_REG_PTCE3_OP_QUERY_READ = 0,
  2287. };
  2288. /* reg_ptce3_op
  2289. * Access: OP
  2290. */
  2291. MLXSW_ITEM32(reg, ptce3, op, 0x00, 20, 3);
  2292. /* reg_ptce3_priority
  2293. * Priority of the rule. Higher values win.
  2294. * For Spectrum-2 range is 1..cap_kvd_size - 1
  2295. * Note: Priority does not have to be unique per rule.
  2296. * Access: RW
  2297. */
  2298. MLXSW_ITEM32(reg, ptce3, priority, 0x04, 0, 24);
  2299. /* reg_ptce3_tcam_region_info
  2300. * Opaque object that represents the TCAM region.
  2301. * Access: Index
  2302. */
  2303. MLXSW_ITEM_BUF(reg, ptce3, tcam_region_info, 0x10,
  2304. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  2305. /* reg_ptce3_flex2_key_blocks
  2306. * ACL key. The key must be masked according to eRP (if exists) or
  2307. * according to master mask.
  2308. * Access: Index
  2309. */
  2310. MLXSW_ITEM_BUF(reg, ptce3, flex2_key_blocks, 0x20,
  2311. MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
  2312. /* reg_ptce3_erp_id
  2313. * eRP ID.
  2314. * Access: Index
  2315. */
  2316. MLXSW_ITEM32(reg, ptce3, erp_id, 0x80, 0, 4);
  2317. /* reg_ptce3_delta_start
  2318. * Start point of delta_value and delta_mask, in bits. Must not exceed
  2319. * num_key_blocks * 36 - 8. Reserved when delta_mask = 0.
  2320. * Access: Index
  2321. */
  2322. MLXSW_ITEM32(reg, ptce3, delta_start, 0x84, 0, 10);
  2323. /* reg_ptce3_delta_mask
  2324. * Delta mask.
  2325. * 0 - Ignore relevant bit in delta_value
  2326. * 1 - Compare relevant bit in delta_value
  2327. * Delta mask must not be set for reserved fields in the key blocks.
  2328. * Note: No delta when no eRPs. Thus, for regions with
  2329. * PERERP.erpt_pointer_valid = 0 the delta mask must be 0.
  2330. * Access: Index
  2331. */
  2332. MLXSW_ITEM32(reg, ptce3, delta_mask, 0x88, 16, 8);
  2333. /* reg_ptce3_delta_value
  2334. * Delta value.
  2335. * Bits which are masked by delta_mask must be 0.
  2336. * Access: Index
  2337. */
  2338. MLXSW_ITEM32(reg, ptce3, delta_value, 0x88, 0, 8);
  2339. /* reg_ptce3_prune_vector
  2340. * Pruning vector relative to the PERPT.erp_id.
  2341. * Used for reducing lookups.
  2342. * 0 - NEED: Do a lookup using the eRP.
  2343. * 1 - PRUNE: Do not perform a lookup using the eRP.
  2344. * Maybe be modified by PEAPBL and PEAPBM.
  2345. * Note: In Spectrum-2, a region of 8 key blocks must be set to either
  2346. * all 1's or all 0's.
  2347. * Access: RW
  2348. */
  2349. MLXSW_ITEM_BIT_ARRAY(reg, ptce3, prune_vector, 0x90, 4, 1);
  2350. /* reg_ptce3_prune_ctcam
  2351. * Pruning on C-TCAM. Used for reducing lookups.
  2352. * 0 - NEED: Do a lookup in the C-TCAM.
  2353. * 1 - PRUNE: Do not perform a lookup in the C-TCAM.
  2354. * Access: RW
  2355. */
  2356. MLXSW_ITEM32(reg, ptce3, prune_ctcam, 0x94, 31, 1);
  2357. /* reg_ptce3_large_exists
  2358. * Large entry key ID exists.
  2359. * Within the region:
  2360. * 0 - SINGLE: The large_entry_key_id is not currently in use.
  2361. * For rule insert: The MSB of the key (blocks 6..11) will be added.
  2362. * For rule delete: The MSB of the key will be removed.
  2363. * 1 - NON_SINGLE: The large_entry_key_id is currently in use.
  2364. * For rule insert: The MSB of the key (blocks 6..11) will not be added.
  2365. * For rule delete: The MSB of the key will not be removed.
  2366. * Access: WO
  2367. */
  2368. MLXSW_ITEM32(reg, ptce3, large_exists, 0x98, 31, 1);
  2369. /* reg_ptce3_large_entry_key_id
  2370. * Large entry key ID.
  2371. * A key for 12 key blocks rules. Reserved when region has less than 12 key
  2372. * blocks. Must be different for different keys which have the same common
  2373. * 6 key blocks (MSB, blocks 6..11) key within a region.
  2374. * Range is 0..cap_max_pe_large_key_id - 1
  2375. * Access: RW
  2376. */
  2377. MLXSW_ITEM32(reg, ptce3, large_entry_key_id, 0x98, 0, 24);
  2378. /* reg_ptce3_action_pointer
  2379. * Pointer to action.
  2380. * Range is 0..cap_max_kvd_action_sets - 1
  2381. * Access: RW
  2382. */
  2383. MLXSW_ITEM32(reg, ptce3, action_pointer, 0xA0, 0, 24);
  2384. static inline void mlxsw_reg_ptce3_pack(char *payload, bool valid,
  2385. enum mlxsw_reg_ptce3_op op,
  2386. u32 priority,
  2387. const char *tcam_region_info,
  2388. const char *key, u8 erp_id,
  2389. bool large_exists, u32 lkey_id,
  2390. u32 action_pointer)
  2391. {
  2392. MLXSW_REG_ZERO(ptce3, payload);
  2393. mlxsw_reg_ptce3_v_set(payload, valid);
  2394. mlxsw_reg_ptce3_op_set(payload, op);
  2395. mlxsw_reg_ptce3_priority_set(payload, priority);
  2396. mlxsw_reg_ptce3_tcam_region_info_memcpy_to(payload, tcam_region_info);
  2397. mlxsw_reg_ptce3_flex2_key_blocks_memcpy_to(payload, key);
  2398. mlxsw_reg_ptce3_erp_id_set(payload, erp_id);
  2399. mlxsw_reg_ptce3_large_exists_set(payload, large_exists);
  2400. mlxsw_reg_ptce3_large_entry_key_id_set(payload, lkey_id);
  2401. mlxsw_reg_ptce3_action_pointer_set(payload, action_pointer);
  2402. }
  2403. /* PERCR - Policy-Engine Region Configuration Register
  2404. * ---------------------------------------------------
  2405. * This register configures the region parameters. The region_id must be
  2406. * allocated.
  2407. */
  2408. #define MLXSW_REG_PERCR_ID 0x302A
  2409. #define MLXSW_REG_PERCR_LEN 0x80
  2410. MLXSW_REG_DEFINE(percr, MLXSW_REG_PERCR_ID, MLXSW_REG_PERCR_LEN);
  2411. /* reg_percr_region_id
  2412. * Region identifier.
  2413. * Range 0..cap_max_regions-1
  2414. * Access: Index
  2415. */
  2416. MLXSW_ITEM32(reg, percr, region_id, 0x00, 0, 16);
  2417. /* reg_percr_atcam_ignore_prune
  2418. * Ignore prune_vector by other A-TCAM rules. Used e.g., for a new rule.
  2419. * Access: RW
  2420. */
  2421. MLXSW_ITEM32(reg, percr, atcam_ignore_prune, 0x04, 25, 1);
  2422. /* reg_percr_ctcam_ignore_prune
  2423. * Ignore prune_ctcam by other A-TCAM rules. Used e.g., for a new rule.
  2424. * Access: RW
  2425. */
  2426. MLXSW_ITEM32(reg, percr, ctcam_ignore_prune, 0x04, 24, 1);
  2427. /* reg_percr_bf_bypass
  2428. * Bloom filter bypass.
  2429. * 0 - Bloom filter is used (default)
  2430. * 1 - Bloom filter is bypassed. The bypass is an OR condition of
  2431. * region_id or eRP. See PERPT.bf_bypass
  2432. * Access: RW
  2433. */
  2434. MLXSW_ITEM32(reg, percr, bf_bypass, 0x04, 16, 1);
  2435. /* reg_percr_master_mask
  2436. * Master mask. Logical OR mask of all masks of all rules of a region
  2437. * (both A-TCAM and C-TCAM). When there are no eRPs
  2438. * (erpt_pointer_valid = 0), then this provides the mask.
  2439. * Access: RW
  2440. */
  2441. MLXSW_ITEM_BUF(reg, percr, master_mask, 0x20, 96);
  2442. static inline void mlxsw_reg_percr_pack(char *payload, u16 region_id)
  2443. {
  2444. MLXSW_REG_ZERO(percr, payload);
  2445. mlxsw_reg_percr_region_id_set(payload, region_id);
  2446. mlxsw_reg_percr_atcam_ignore_prune_set(payload, false);
  2447. mlxsw_reg_percr_ctcam_ignore_prune_set(payload, false);
  2448. mlxsw_reg_percr_bf_bypass_set(payload, true);
  2449. }
  2450. /* PERERP - Policy-Engine Region eRP Register
  2451. * ------------------------------------------
  2452. * This register configures the region eRP. The region_id must be
  2453. * allocated.
  2454. */
  2455. #define MLXSW_REG_PERERP_ID 0x302B
  2456. #define MLXSW_REG_PERERP_LEN 0x1C
  2457. MLXSW_REG_DEFINE(pererp, MLXSW_REG_PERERP_ID, MLXSW_REG_PERERP_LEN);
  2458. /* reg_pererp_region_id
  2459. * Region identifier.
  2460. * Range 0..cap_max_regions-1
  2461. * Access: Index
  2462. */
  2463. MLXSW_ITEM32(reg, pererp, region_id, 0x00, 0, 16);
  2464. /* reg_pererp_ctcam_le
  2465. * C-TCAM lookup enable. Reserved when erpt_pointer_valid = 0.
  2466. * Access: RW
  2467. */
  2468. MLXSW_ITEM32(reg, pererp, ctcam_le, 0x04, 28, 1);
  2469. /* reg_pererp_erpt_pointer_valid
  2470. * erpt_pointer is valid.
  2471. * Access: RW
  2472. */
  2473. MLXSW_ITEM32(reg, pererp, erpt_pointer_valid, 0x10, 31, 1);
  2474. /* reg_pererp_erpt_bank_pointer
  2475. * Pointer to eRP table bank. May be modified at any time.
  2476. * Range 0..cap_max_erp_table_banks-1
  2477. * Reserved when erpt_pointer_valid = 0
  2478. */
  2479. MLXSW_ITEM32(reg, pererp, erpt_bank_pointer, 0x10, 16, 4);
  2480. /* reg_pererp_erpt_pointer
  2481. * Pointer to eRP table within the eRP bank. Can be changed for an
  2482. * existing region.
  2483. * Range 0..cap_max_erp_table_size-1
  2484. * Reserved when erpt_pointer_valid = 0
  2485. * Access: RW
  2486. */
  2487. MLXSW_ITEM32(reg, pererp, erpt_pointer, 0x10, 0, 8);
  2488. /* reg_pererp_erpt_vector
  2489. * Vector of allowed eRP indexes starting from erpt_pointer within the
  2490. * erpt_bank_pointer. Next entries will be in next bank.
  2491. * Note that eRP index is used and not eRP ID.
  2492. * Reserved when erpt_pointer_valid = 0
  2493. * Access: RW
  2494. */
  2495. MLXSW_ITEM_BIT_ARRAY(reg, pererp, erpt_vector, 0x14, 4, 1);
  2496. /* reg_pererp_master_rp_id
  2497. * Master RP ID. When there are no eRPs, then this provides the eRP ID
  2498. * for the lookup. Can be changed for an existing region.
  2499. * Reserved when erpt_pointer_valid = 1
  2500. * Access: RW
  2501. */
  2502. MLXSW_ITEM32(reg, pererp, master_rp_id, 0x18, 0, 4);
  2503. static inline void mlxsw_reg_pererp_erp_vector_pack(char *payload,
  2504. unsigned long *erp_vector,
  2505. unsigned long size)
  2506. {
  2507. unsigned long bit;
  2508. for_each_set_bit(bit, erp_vector, size)
  2509. mlxsw_reg_pererp_erpt_vector_set(payload, bit, true);
  2510. }
  2511. static inline void mlxsw_reg_pererp_pack(char *payload, u16 region_id,
  2512. bool ctcam_le, bool erpt_pointer_valid,
  2513. u8 erpt_bank_pointer, u8 erpt_pointer,
  2514. u8 master_rp_id)
  2515. {
  2516. MLXSW_REG_ZERO(pererp, payload);
  2517. mlxsw_reg_pererp_region_id_set(payload, region_id);
  2518. mlxsw_reg_pererp_ctcam_le_set(payload, ctcam_le);
  2519. mlxsw_reg_pererp_erpt_pointer_valid_set(payload, erpt_pointer_valid);
  2520. mlxsw_reg_pererp_erpt_bank_pointer_set(payload, erpt_bank_pointer);
  2521. mlxsw_reg_pererp_erpt_pointer_set(payload, erpt_pointer);
  2522. mlxsw_reg_pererp_master_rp_id_set(payload, master_rp_id);
  2523. }
  2524. /* IEDR - Infrastructure Entry Delete Register
  2525. * ----------------------------------------------------
  2526. * This register is used for deleting entries from the entry tables.
  2527. * It is legitimate to attempt to delete a nonexisting entry (the device will
  2528. * respond as a good flow).
  2529. */
  2530. #define MLXSW_REG_IEDR_ID 0x3804
  2531. #define MLXSW_REG_IEDR_BASE_LEN 0x10 /* base length, without records */
  2532. #define MLXSW_REG_IEDR_REC_LEN 0x8 /* record length */
  2533. #define MLXSW_REG_IEDR_REC_MAX_COUNT 64
  2534. #define MLXSW_REG_IEDR_LEN (MLXSW_REG_IEDR_BASE_LEN + \
  2535. MLXSW_REG_IEDR_REC_LEN * \
  2536. MLXSW_REG_IEDR_REC_MAX_COUNT)
  2537. MLXSW_REG_DEFINE(iedr, MLXSW_REG_IEDR_ID, MLXSW_REG_IEDR_LEN);
  2538. /* reg_iedr_num_rec
  2539. * Number of records.
  2540. * Access: OP
  2541. */
  2542. MLXSW_ITEM32(reg, iedr, num_rec, 0x00, 0, 8);
  2543. /* reg_iedr_rec_type
  2544. * Resource type.
  2545. * Access: OP
  2546. */
  2547. MLXSW_ITEM32_INDEXED(reg, iedr, rec_type, MLXSW_REG_IEDR_BASE_LEN, 24, 8,
  2548. MLXSW_REG_IEDR_REC_LEN, 0x00, false);
  2549. /* reg_iedr_rec_size
  2550. * Size of entries do be deleted. The unit is 1 entry, regardless of entry type.
  2551. * Access: OP
  2552. */
  2553. MLXSW_ITEM32_INDEXED(reg, iedr, rec_size, MLXSW_REG_IEDR_BASE_LEN, 0, 11,
  2554. MLXSW_REG_IEDR_REC_LEN, 0x00, false);
  2555. /* reg_iedr_rec_index_start
  2556. * Resource index start.
  2557. * Access: OP
  2558. */
  2559. MLXSW_ITEM32_INDEXED(reg, iedr, rec_index_start, MLXSW_REG_IEDR_BASE_LEN, 0, 24,
  2560. MLXSW_REG_IEDR_REC_LEN, 0x04, false);
  2561. static inline void mlxsw_reg_iedr_pack(char *payload)
  2562. {
  2563. MLXSW_REG_ZERO(iedr, payload);
  2564. }
  2565. static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
  2566. u8 rec_type, u16 rec_size,
  2567. u32 rec_index_start)
  2568. {
  2569. u8 num_rec = mlxsw_reg_iedr_num_rec_get(payload);
  2570. if (rec_index >= num_rec)
  2571. mlxsw_reg_iedr_num_rec_set(payload, rec_index + 1);
  2572. mlxsw_reg_iedr_rec_type_set(payload, rec_index, rec_type);
  2573. mlxsw_reg_iedr_rec_size_set(payload, rec_index, rec_size);
  2574. mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
  2575. }
  2576. /* QPTS - QoS Priority Trust State Register
  2577. * ----------------------------------------
  2578. * This register controls the port policy to calculate the switch priority and
  2579. * packet color based on incoming packet fields.
  2580. */
  2581. #define MLXSW_REG_QPTS_ID 0x4002
  2582. #define MLXSW_REG_QPTS_LEN 0x8
  2583. MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
  2584. /* reg_qpts_local_port
  2585. * Local port number.
  2586. * Access: Index
  2587. *
  2588. * Note: CPU port is supported.
  2589. */
  2590. MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
  2591. enum mlxsw_reg_qpts_trust_state {
  2592. MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
  2593. MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
  2594. };
  2595. /* reg_qpts_trust_state
  2596. * Trust state for a given port.
  2597. * Access: RW
  2598. */
  2599. MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
  2600. static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
  2601. enum mlxsw_reg_qpts_trust_state ts)
  2602. {
  2603. MLXSW_REG_ZERO(qpts, payload);
  2604. mlxsw_reg_qpts_local_port_set(payload, local_port);
  2605. mlxsw_reg_qpts_trust_state_set(payload, ts);
  2606. }
  2607. /* QPCR - QoS Policer Configuration Register
  2608. * -----------------------------------------
  2609. * The QPCR register is used to create policers - that limit
  2610. * the rate of bytes or packets via some trap group.
  2611. */
  2612. #define MLXSW_REG_QPCR_ID 0x4004
  2613. #define MLXSW_REG_QPCR_LEN 0x28
  2614. MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
  2615. enum mlxsw_reg_qpcr_g {
  2616. MLXSW_REG_QPCR_G_GLOBAL = 2,
  2617. MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
  2618. };
  2619. /* reg_qpcr_g
  2620. * The policer type.
  2621. * Access: Index
  2622. */
  2623. MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
  2624. /* reg_qpcr_pid
  2625. * Policer ID.
  2626. * Access: Index
  2627. */
  2628. MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
  2629. /* reg_qpcr_color_aware
  2630. * Is the policer aware of colors.
  2631. * Must be 0 (unaware) for cpu port.
  2632. * Access: RW for unbounded policer. RO for bounded policer.
  2633. */
  2634. MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
  2635. /* reg_qpcr_bytes
  2636. * Is policer limit is for bytes per sec or packets per sec.
  2637. * 0 - packets
  2638. * 1 - bytes
  2639. * Access: RW for unbounded policer. RO for bounded policer.
  2640. */
  2641. MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
  2642. enum mlxsw_reg_qpcr_ir_units {
  2643. MLXSW_REG_QPCR_IR_UNITS_M,
  2644. MLXSW_REG_QPCR_IR_UNITS_K,
  2645. };
  2646. /* reg_qpcr_ir_units
  2647. * Policer's units for cir and eir fields (for bytes limits only)
  2648. * 1 - 10^3
  2649. * 0 - 10^6
  2650. * Access: OP
  2651. */
  2652. MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
  2653. enum mlxsw_reg_qpcr_rate_type {
  2654. MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
  2655. MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
  2656. };
  2657. /* reg_qpcr_rate_type
  2658. * Policer can have one limit (single rate) or 2 limits with specific operation
  2659. * for packets that exceed the lower rate but not the upper one.
  2660. * (For cpu port must be single rate)
  2661. * Access: RW for unbounded policer. RO for bounded policer.
  2662. */
  2663. MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
  2664. /* reg_qpc_cbs
  2665. * Policer's committed burst size.
  2666. * The policer is working with time slices of 50 nano sec. By default every
  2667. * slice is granted the proportionate share of the committed rate. If we want to
  2668. * allow a slice to exceed that share (while still keeping the rate per sec) we
  2669. * can allow burst. The burst size is between the default proportionate share
  2670. * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
  2671. * committed rate will result in exceeding the rate). The burst size must be a
  2672. * log of 2 and will be determined by 2^cbs.
  2673. * Access: RW
  2674. */
  2675. MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
  2676. /* reg_qpcr_cir
  2677. * Policer's committed rate.
  2678. * The rate used for sungle rate, the lower rate for double rate.
  2679. * For bytes limits, the rate will be this value * the unit from ir_units.
  2680. * (Resolution error is up to 1%).
  2681. * Access: RW
  2682. */
  2683. MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
  2684. /* reg_qpcr_eir
  2685. * Policer's exceed rate.
  2686. * The higher rate for double rate, reserved for single rate.
  2687. * Lower rate for double rate policer.
  2688. * For bytes limits, the rate will be this value * the unit from ir_units.
  2689. * (Resolution error is up to 1%).
  2690. * Access: RW
  2691. */
  2692. MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
  2693. #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
  2694. /* reg_qpcr_exceed_action.
  2695. * What to do with packets between the 2 limits for double rate.
  2696. * Access: RW for unbounded policer. RO for bounded policer.
  2697. */
  2698. MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
  2699. enum mlxsw_reg_qpcr_action {
  2700. /* Discard */
  2701. MLXSW_REG_QPCR_ACTION_DISCARD = 1,
  2702. /* Forward and set color to red.
  2703. * If the packet is intended to cpu port, it will be dropped.
  2704. */
  2705. MLXSW_REG_QPCR_ACTION_FORWARD = 2,
  2706. };
  2707. /* reg_qpcr_violate_action
  2708. * What to do with packets that cross the cir limit (for single rate) or the eir
  2709. * limit (for double rate).
  2710. * Access: RW for unbounded policer. RO for bounded policer.
  2711. */
  2712. MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
  2713. static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
  2714. enum mlxsw_reg_qpcr_ir_units ir_units,
  2715. bool bytes, u32 cir, u16 cbs)
  2716. {
  2717. MLXSW_REG_ZERO(qpcr, payload);
  2718. mlxsw_reg_qpcr_pid_set(payload, pid);
  2719. mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
  2720. mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
  2721. mlxsw_reg_qpcr_violate_action_set(payload,
  2722. MLXSW_REG_QPCR_ACTION_DISCARD);
  2723. mlxsw_reg_qpcr_cir_set(payload, cir);
  2724. mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
  2725. mlxsw_reg_qpcr_bytes_set(payload, bytes);
  2726. mlxsw_reg_qpcr_cbs_set(payload, cbs);
  2727. }
  2728. /* QTCT - QoS Switch Traffic Class Table
  2729. * -------------------------------------
  2730. * Configures the mapping between the packet switch priority and the
  2731. * traffic class on the transmit port.
  2732. */
  2733. #define MLXSW_REG_QTCT_ID 0x400A
  2734. #define MLXSW_REG_QTCT_LEN 0x08
  2735. MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
  2736. /* reg_qtct_local_port
  2737. * Local port number.
  2738. * Access: Index
  2739. *
  2740. * Note: CPU port is not supported.
  2741. */
  2742. MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
  2743. /* reg_qtct_sub_port
  2744. * Virtual port within the physical port.
  2745. * Should be set to 0 when virtual ports are not enabled on the port.
  2746. * Access: Index
  2747. */
  2748. MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
  2749. /* reg_qtct_switch_prio
  2750. * Switch priority.
  2751. * Access: Index
  2752. */
  2753. MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
  2754. /* reg_qtct_tclass
  2755. * Traffic class.
  2756. * Default values:
  2757. * switch_prio 0 : tclass 1
  2758. * switch_prio 1 : tclass 0
  2759. * switch_prio i : tclass i, for i > 1
  2760. * Access: RW
  2761. */
  2762. MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
  2763. static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
  2764. u8 switch_prio, u8 tclass)
  2765. {
  2766. MLXSW_REG_ZERO(qtct, payload);
  2767. mlxsw_reg_qtct_local_port_set(payload, local_port);
  2768. mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
  2769. mlxsw_reg_qtct_tclass_set(payload, tclass);
  2770. }
  2771. /* QEEC - QoS ETS Element Configuration Register
  2772. * ---------------------------------------------
  2773. * Configures the ETS elements.
  2774. */
  2775. #define MLXSW_REG_QEEC_ID 0x400D
  2776. #define MLXSW_REG_QEEC_LEN 0x20
  2777. MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
  2778. /* reg_qeec_local_port
  2779. * Local port number.
  2780. * Access: Index
  2781. *
  2782. * Note: CPU port is supported.
  2783. */
  2784. MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
  2785. enum mlxsw_reg_qeec_hr {
  2786. MLXSW_REG_QEEC_HIERARCY_PORT,
  2787. MLXSW_REG_QEEC_HIERARCY_GROUP,
  2788. MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
  2789. MLXSW_REG_QEEC_HIERARCY_TC,
  2790. };
  2791. /* reg_qeec_element_hierarchy
  2792. * 0 - Port
  2793. * 1 - Group
  2794. * 2 - Subgroup
  2795. * 3 - Traffic Class
  2796. * Access: Index
  2797. */
  2798. MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
  2799. /* reg_qeec_element_index
  2800. * The index of the element in the hierarchy.
  2801. * Access: Index
  2802. */
  2803. MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
  2804. /* reg_qeec_next_element_index
  2805. * The index of the next (lower) element in the hierarchy.
  2806. * Access: RW
  2807. *
  2808. * Note: Reserved for element_hierarchy 0.
  2809. */
  2810. MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
  2811. /* reg_qeec_mise
  2812. * Min shaper configuration enable. Enables configuration of the min
  2813. * shaper on this ETS element
  2814. * 0 - Disable
  2815. * 1 - Enable
  2816. * Access: RW
  2817. */
  2818. MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1);
  2819. enum {
  2820. MLXSW_REG_QEEC_BYTES_MODE,
  2821. MLXSW_REG_QEEC_PACKETS_MODE,
  2822. };
  2823. /* reg_qeec_pb
  2824. * Packets or bytes mode.
  2825. * 0 - Bytes mode
  2826. * 1 - Packets mode
  2827. * Access: RW
  2828. *
  2829. * Note: Used for max shaper configuration. For Spectrum, packets mode
  2830. * is supported only for traffic classes of CPU port.
  2831. */
  2832. MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
  2833. /* The smallest permitted min shaper rate. */
  2834. #define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */
  2835. /* reg_qeec_min_shaper_rate
  2836. * Min shaper information rate.
  2837. * For CPU port, can only be configured for port hierarchy.
  2838. * When in bytes mode, value is specified in units of 1000bps.
  2839. * Access: RW
  2840. */
  2841. MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28);
  2842. /* reg_qeec_mase
  2843. * Max shaper configuration enable. Enables configuration of the max
  2844. * shaper on this ETS element.
  2845. * 0 - Disable
  2846. * 1 - Enable
  2847. * Access: RW
  2848. */
  2849. MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
  2850. /* A large max rate will disable the max shaper. */
  2851. #define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
  2852. /* reg_qeec_max_shaper_rate
  2853. * Max shaper information rate.
  2854. * For CPU port, can only be configured for port hierarchy.
  2855. * When in bytes mode, value is specified in units of 1000bps.
  2856. * Access: RW
  2857. */
  2858. MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
  2859. /* reg_qeec_de
  2860. * DWRR configuration enable. Enables configuration of the dwrr and
  2861. * dwrr_weight.
  2862. * 0 - Disable
  2863. * 1 - Enable
  2864. * Access: RW
  2865. */
  2866. MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
  2867. /* reg_qeec_dwrr
  2868. * Transmission selection algorithm to use on the link going down from
  2869. * the ETS element.
  2870. * 0 - Strict priority
  2871. * 1 - DWRR
  2872. * Access: RW
  2873. */
  2874. MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
  2875. /* reg_qeec_dwrr_weight
  2876. * DWRR weight on the link going down from the ETS element. The
  2877. * percentage of bandwidth guaranteed to an ETS element within
  2878. * its hierarchy. The sum of all weights across all ETS elements
  2879. * within one hierarchy should be equal to 100. Reserved when
  2880. * transmission selection algorithm is strict priority.
  2881. * Access: RW
  2882. */
  2883. MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
  2884. static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
  2885. enum mlxsw_reg_qeec_hr hr, u8 index,
  2886. u8 next_index)
  2887. {
  2888. MLXSW_REG_ZERO(qeec, payload);
  2889. mlxsw_reg_qeec_local_port_set(payload, local_port);
  2890. mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
  2891. mlxsw_reg_qeec_element_index_set(payload, index);
  2892. mlxsw_reg_qeec_next_element_index_set(payload, next_index);
  2893. }
  2894. /* QRWE - QoS ReWrite Enable
  2895. * -------------------------
  2896. * This register configures the rewrite enable per receive port.
  2897. */
  2898. #define MLXSW_REG_QRWE_ID 0x400F
  2899. #define MLXSW_REG_QRWE_LEN 0x08
  2900. MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
  2901. /* reg_qrwe_local_port
  2902. * Local port number.
  2903. * Access: Index
  2904. *
  2905. * Note: CPU port is supported. No support for router port.
  2906. */
  2907. MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
  2908. /* reg_qrwe_dscp
  2909. * Whether to enable DSCP rewrite (default is 0, don't rewrite).
  2910. * Access: RW
  2911. */
  2912. MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
  2913. /* reg_qrwe_pcp
  2914. * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
  2915. * Access: RW
  2916. */
  2917. MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
  2918. static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
  2919. bool rewrite_pcp, bool rewrite_dscp)
  2920. {
  2921. MLXSW_REG_ZERO(qrwe, payload);
  2922. mlxsw_reg_qrwe_local_port_set(payload, local_port);
  2923. mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
  2924. mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
  2925. }
  2926. /* QPDSM - QoS Priority to DSCP Mapping
  2927. * ------------------------------------
  2928. * QoS Priority to DSCP Mapping Register
  2929. */
  2930. #define MLXSW_REG_QPDSM_ID 0x4011
  2931. #define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
  2932. #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
  2933. #define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
  2934. #define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
  2935. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
  2936. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
  2937. MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
  2938. /* reg_qpdsm_local_port
  2939. * Local Port. Supported for data packets from CPU port.
  2940. * Access: Index
  2941. */
  2942. MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
  2943. /* reg_qpdsm_prio_entry_color0_e
  2944. * Enable update of the entry for color 0 and a given port.
  2945. * Access: WO
  2946. */
  2947. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
  2948. MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
  2949. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2950. /* reg_qpdsm_prio_entry_color0_dscp
  2951. * DSCP field in the outer label of the packet for color 0 and a given port.
  2952. * Reserved when e=0.
  2953. * Access: RW
  2954. */
  2955. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
  2956. MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
  2957. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2958. /* reg_qpdsm_prio_entry_color1_e
  2959. * Enable update of the entry for color 1 and a given port.
  2960. * Access: WO
  2961. */
  2962. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
  2963. MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
  2964. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2965. /* reg_qpdsm_prio_entry_color1_dscp
  2966. * DSCP field in the outer label of the packet for color 1 and a given port.
  2967. * Reserved when e=0.
  2968. * Access: RW
  2969. */
  2970. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
  2971. MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
  2972. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2973. /* reg_qpdsm_prio_entry_color2_e
  2974. * Enable update of the entry for color 2 and a given port.
  2975. * Access: WO
  2976. */
  2977. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
  2978. MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
  2979. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2980. /* reg_qpdsm_prio_entry_color2_dscp
  2981. * DSCP field in the outer label of the packet for color 2 and a given port.
  2982. * Reserved when e=0.
  2983. * Access: RW
  2984. */
  2985. MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
  2986. MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
  2987. MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
  2988. static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
  2989. {
  2990. MLXSW_REG_ZERO(qpdsm, payload);
  2991. mlxsw_reg_qpdsm_local_port_set(payload, local_port);
  2992. }
  2993. static inline void
  2994. mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
  2995. {
  2996. mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
  2997. mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
  2998. mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
  2999. mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
  3000. mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
  3001. mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
  3002. }
  3003. /* QPDPM - QoS Port DSCP to Priority Mapping Register
  3004. * --------------------------------------------------
  3005. * This register controls the mapping from DSCP field to
  3006. * Switch Priority for IP packets.
  3007. */
  3008. #define MLXSW_REG_QPDPM_ID 0x4013
  3009. #define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
  3010. #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
  3011. #define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
  3012. #define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
  3013. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
  3014. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
  3015. MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
  3016. /* reg_qpdpm_local_port
  3017. * Local Port. Supported for data packets from CPU port.
  3018. * Access: Index
  3019. */
  3020. MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
  3021. /* reg_qpdpm_dscp_e
  3022. * Enable update of the specific entry. When cleared, the switch_prio and color
  3023. * fields are ignored and the previous switch_prio and color values are
  3024. * preserved.
  3025. * Access: WO
  3026. */
  3027. MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
  3028. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  3029. /* reg_qpdpm_dscp_prio
  3030. * The new Switch Priority value for the relevant DSCP value.
  3031. * Access: RW
  3032. */
  3033. MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
  3034. MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
  3035. MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  3036. static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
  3037. {
  3038. MLXSW_REG_ZERO(qpdpm, payload);
  3039. mlxsw_reg_qpdpm_local_port_set(payload, local_port);
  3040. }
  3041. static inline void
  3042. mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
  3043. {
  3044. mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
  3045. mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
  3046. }
  3047. /* QTCTM - QoS Switch Traffic Class Table is Multicast-Aware Register
  3048. * ------------------------------------------------------------------
  3049. * This register configures if the Switch Priority to Traffic Class mapping is
  3050. * based on Multicast packet indication. If so, then multicast packets will get
  3051. * a Traffic Class that is plus (cap_max_tclass_data/2) the value configured by
  3052. * QTCT.
  3053. * By default, Switch Priority to Traffic Class mapping is not based on
  3054. * Multicast packet indication.
  3055. */
  3056. #define MLXSW_REG_QTCTM_ID 0x401A
  3057. #define MLXSW_REG_QTCTM_LEN 0x08
  3058. MLXSW_REG_DEFINE(qtctm, MLXSW_REG_QTCTM_ID, MLXSW_REG_QTCTM_LEN);
  3059. /* reg_qtctm_local_port
  3060. * Local port number.
  3061. * No support for CPU port.
  3062. * Access: Index
  3063. */
  3064. MLXSW_ITEM32(reg, qtctm, local_port, 0x00, 16, 8);
  3065. /* reg_qtctm_mc
  3066. * Multicast Mode
  3067. * Whether Switch Priority to Traffic Class mapping is based on Multicast packet
  3068. * indication (default is 0, not based on Multicast packet indication).
  3069. */
  3070. MLXSW_ITEM32(reg, qtctm, mc, 0x04, 0, 1);
  3071. static inline void
  3072. mlxsw_reg_qtctm_pack(char *payload, u8 local_port, bool mc)
  3073. {
  3074. MLXSW_REG_ZERO(qtctm, payload);
  3075. mlxsw_reg_qtctm_local_port_set(payload, local_port);
  3076. mlxsw_reg_qtctm_mc_set(payload, mc);
  3077. }
  3078. /* PMLP - Ports Module to Local Port Register
  3079. * ------------------------------------------
  3080. * Configures the assignment of modules to local ports.
  3081. */
  3082. #define MLXSW_REG_PMLP_ID 0x5002
  3083. #define MLXSW_REG_PMLP_LEN 0x40
  3084. MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
  3085. /* reg_pmlp_rxtx
  3086. * 0 - Tx value is used for both Tx and Rx.
  3087. * 1 - Rx value is taken from a separte field.
  3088. * Access: RW
  3089. */
  3090. MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
  3091. /* reg_pmlp_local_port
  3092. * Local port number.
  3093. * Access: Index
  3094. */
  3095. MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
  3096. /* reg_pmlp_width
  3097. * 0 - Unmap local port.
  3098. * 1 - Lane 0 is used.
  3099. * 2 - Lanes 0 and 1 are used.
  3100. * 4 - Lanes 0, 1, 2 and 3 are used.
  3101. * Access: RW
  3102. */
  3103. MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
  3104. /* reg_pmlp_module
  3105. * Module number.
  3106. * Access: RW
  3107. */
  3108. MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
  3109. /* reg_pmlp_tx_lane
  3110. * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
  3111. * Access: RW
  3112. */
  3113. MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
  3114. /* reg_pmlp_rx_lane
  3115. * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
  3116. * equal to Tx lane.
  3117. * Access: RW
  3118. */
  3119. MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
  3120. static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
  3121. {
  3122. MLXSW_REG_ZERO(pmlp, payload);
  3123. mlxsw_reg_pmlp_local_port_set(payload, local_port);
  3124. }
  3125. /* PMTU - Port MTU Register
  3126. * ------------------------
  3127. * Configures and reports the port MTU.
  3128. */
  3129. #define MLXSW_REG_PMTU_ID 0x5003
  3130. #define MLXSW_REG_PMTU_LEN 0x10
  3131. MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
  3132. /* reg_pmtu_local_port
  3133. * Local port number.
  3134. * Access: Index
  3135. */
  3136. MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
  3137. /* reg_pmtu_max_mtu
  3138. * Maximum MTU.
  3139. * When port type (e.g. Ethernet) is configured, the relevant MTU is
  3140. * reported, otherwise the minimum between the max_mtu of the different
  3141. * types is reported.
  3142. * Access: RO
  3143. */
  3144. MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
  3145. /* reg_pmtu_admin_mtu
  3146. * MTU value to set port to. Must be smaller or equal to max_mtu.
  3147. * Note: If port type is Infiniband, then port must be disabled, when its
  3148. * MTU is set.
  3149. * Access: RW
  3150. */
  3151. MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
  3152. /* reg_pmtu_oper_mtu
  3153. * The actual MTU configured on the port. Packets exceeding this size
  3154. * will be dropped.
  3155. * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
  3156. * oper_mtu might be smaller than admin_mtu.
  3157. * Access: RO
  3158. */
  3159. MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
  3160. static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
  3161. u16 new_mtu)
  3162. {
  3163. MLXSW_REG_ZERO(pmtu, payload);
  3164. mlxsw_reg_pmtu_local_port_set(payload, local_port);
  3165. mlxsw_reg_pmtu_max_mtu_set(payload, 0);
  3166. mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
  3167. mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
  3168. }
  3169. /* PTYS - Port Type and Speed Register
  3170. * -----------------------------------
  3171. * Configures and reports the port speed type.
  3172. *
  3173. * Note: When set while the link is up, the changes will not take effect
  3174. * until the port transitions from down to up state.
  3175. */
  3176. #define MLXSW_REG_PTYS_ID 0x5004
  3177. #define MLXSW_REG_PTYS_LEN 0x40
  3178. MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
  3179. /* an_disable_admin
  3180. * Auto negotiation disable administrative configuration
  3181. * 0 - Device doesn't support AN disable.
  3182. * 1 - Device supports AN disable.
  3183. * Access: RW
  3184. */
  3185. MLXSW_ITEM32(reg, ptys, an_disable_admin, 0x00, 30, 1);
  3186. /* reg_ptys_local_port
  3187. * Local port number.
  3188. * Access: Index
  3189. */
  3190. MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
  3191. #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
  3192. #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
  3193. /* reg_ptys_proto_mask
  3194. * Protocol mask. Indicates which protocol is used.
  3195. * 0 - Infiniband.
  3196. * 1 - Fibre Channel.
  3197. * 2 - Ethernet.
  3198. * Access: Index
  3199. */
  3200. MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
  3201. enum {
  3202. MLXSW_REG_PTYS_AN_STATUS_NA,
  3203. MLXSW_REG_PTYS_AN_STATUS_OK,
  3204. MLXSW_REG_PTYS_AN_STATUS_FAIL,
  3205. };
  3206. /* reg_ptys_an_status
  3207. * Autonegotiation status.
  3208. * Access: RO
  3209. */
  3210. MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
  3211. #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
  3212. #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
  3213. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
  3214. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
  3215. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
  3216. #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
  3217. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
  3218. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
  3219. #define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
  3220. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
  3221. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
  3222. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
  3223. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
  3224. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
  3225. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
  3226. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
  3227. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
  3228. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
  3229. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
  3230. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
  3231. #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
  3232. #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
  3233. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
  3234. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
  3235. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
  3236. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
  3237. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
  3238. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
  3239. /* reg_ptys_eth_proto_cap
  3240. * Ethernet port supported speeds and protocols.
  3241. * Access: RO
  3242. */
  3243. MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
  3244. /* reg_ptys_ib_link_width_cap
  3245. * IB port supported widths.
  3246. * Access: RO
  3247. */
  3248. MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
  3249. #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
  3250. #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
  3251. #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
  3252. #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
  3253. #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
  3254. #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
  3255. /* reg_ptys_ib_proto_cap
  3256. * IB port supported speeds and protocols.
  3257. * Access: RO
  3258. */
  3259. MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
  3260. /* reg_ptys_eth_proto_admin
  3261. * Speed and protocol to set port to.
  3262. * Access: RW
  3263. */
  3264. MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
  3265. /* reg_ptys_ib_link_width_admin
  3266. * IB width to set port to.
  3267. * Access: RW
  3268. */
  3269. MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
  3270. /* reg_ptys_ib_proto_admin
  3271. * IB speeds and protocols to set port to.
  3272. * Access: RW
  3273. */
  3274. MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
  3275. /* reg_ptys_eth_proto_oper
  3276. * The current speed and protocol configured for the port.
  3277. * Access: RO
  3278. */
  3279. MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
  3280. /* reg_ptys_ib_link_width_oper
  3281. * The current IB width to set port to.
  3282. * Access: RO
  3283. */
  3284. MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
  3285. /* reg_ptys_ib_proto_oper
  3286. * The current IB speed and protocol.
  3287. * Access: RO
  3288. */
  3289. MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
  3290. /* reg_ptys_eth_proto_lp_advertise
  3291. * The protocols that were advertised by the link partner during
  3292. * autonegotiation.
  3293. * Access: RO
  3294. */
  3295. MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
  3296. static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
  3297. u32 proto_admin, bool autoneg)
  3298. {
  3299. MLXSW_REG_ZERO(ptys, payload);
  3300. mlxsw_reg_ptys_local_port_set(payload, local_port);
  3301. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
  3302. mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
  3303. mlxsw_reg_ptys_an_disable_admin_set(payload, !autoneg);
  3304. }
  3305. static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
  3306. u32 *p_eth_proto_cap,
  3307. u32 *p_eth_proto_adm,
  3308. u32 *p_eth_proto_oper)
  3309. {
  3310. if (p_eth_proto_cap)
  3311. *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
  3312. if (p_eth_proto_adm)
  3313. *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
  3314. if (p_eth_proto_oper)
  3315. *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
  3316. }
  3317. static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
  3318. u16 proto_admin, u16 link_width)
  3319. {
  3320. MLXSW_REG_ZERO(ptys, payload);
  3321. mlxsw_reg_ptys_local_port_set(payload, local_port);
  3322. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
  3323. mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
  3324. mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
  3325. }
  3326. static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
  3327. u16 *p_ib_link_width_cap,
  3328. u16 *p_ib_proto_oper,
  3329. u16 *p_ib_link_width_oper)
  3330. {
  3331. if (p_ib_proto_cap)
  3332. *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
  3333. if (p_ib_link_width_cap)
  3334. *p_ib_link_width_cap =
  3335. mlxsw_reg_ptys_ib_link_width_cap_get(payload);
  3336. if (p_ib_proto_oper)
  3337. *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
  3338. if (p_ib_link_width_oper)
  3339. *p_ib_link_width_oper =
  3340. mlxsw_reg_ptys_ib_link_width_oper_get(payload);
  3341. }
  3342. /* PPAD - Port Physical Address Register
  3343. * -------------------------------------
  3344. * The PPAD register configures the per port physical MAC address.
  3345. */
  3346. #define MLXSW_REG_PPAD_ID 0x5005
  3347. #define MLXSW_REG_PPAD_LEN 0x10
  3348. MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
  3349. /* reg_ppad_single_base_mac
  3350. * 0: base_mac, local port should be 0 and mac[7:0] is
  3351. * reserved. HW will set incremental
  3352. * 1: single_mac - mac of the local_port
  3353. * Access: RW
  3354. */
  3355. MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
  3356. /* reg_ppad_local_port
  3357. * port number, if single_base_mac = 0 then local_port is reserved
  3358. * Access: RW
  3359. */
  3360. MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
  3361. /* reg_ppad_mac
  3362. * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
  3363. * If single_base_mac = 1 - the per port MAC address
  3364. * Access: RW
  3365. */
  3366. MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
  3367. static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
  3368. u8 local_port)
  3369. {
  3370. MLXSW_REG_ZERO(ppad, payload);
  3371. mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
  3372. mlxsw_reg_ppad_local_port_set(payload, local_port);
  3373. }
  3374. /* PAOS - Ports Administrative and Operational Status Register
  3375. * -----------------------------------------------------------
  3376. * Configures and retrieves per port administrative and operational status.
  3377. */
  3378. #define MLXSW_REG_PAOS_ID 0x5006
  3379. #define MLXSW_REG_PAOS_LEN 0x10
  3380. MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
  3381. /* reg_paos_swid
  3382. * Switch partition ID with which to associate the port.
  3383. * Note: while external ports uses unique local port numbers (and thus swid is
  3384. * redundant), router ports use the same local port number where swid is the
  3385. * only indication for the relevant port.
  3386. * Access: Index
  3387. */
  3388. MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
  3389. /* reg_paos_local_port
  3390. * Local port number.
  3391. * Access: Index
  3392. */
  3393. MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
  3394. /* reg_paos_admin_status
  3395. * Port administrative state (the desired state of the port):
  3396. * 1 - Up.
  3397. * 2 - Down.
  3398. * 3 - Up once. This means that in case of link failure, the port won't go
  3399. * into polling mode, but will wait to be re-enabled by software.
  3400. * 4 - Disabled by system. Can only be set by hardware.
  3401. * Access: RW
  3402. */
  3403. MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
  3404. /* reg_paos_oper_status
  3405. * Port operational state (the current state):
  3406. * 1 - Up.
  3407. * 2 - Down.
  3408. * 3 - Down by port failure. This means that the device will not let the
  3409. * port up again until explicitly specified by software.
  3410. * Access: RO
  3411. */
  3412. MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
  3413. /* reg_paos_ase
  3414. * Admin state update enabled.
  3415. * Access: WO
  3416. */
  3417. MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
  3418. /* reg_paos_ee
  3419. * Event update enable. If this bit is set, event generation will be
  3420. * updated based on the e field.
  3421. * Access: WO
  3422. */
  3423. MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
  3424. /* reg_paos_e
  3425. * Event generation on operational state change:
  3426. * 0 - Do not generate event.
  3427. * 1 - Generate Event.
  3428. * 2 - Generate Single Event.
  3429. * Access: RW
  3430. */
  3431. MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
  3432. static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
  3433. enum mlxsw_port_admin_status status)
  3434. {
  3435. MLXSW_REG_ZERO(paos, payload);
  3436. mlxsw_reg_paos_swid_set(payload, 0);
  3437. mlxsw_reg_paos_local_port_set(payload, local_port);
  3438. mlxsw_reg_paos_admin_status_set(payload, status);
  3439. mlxsw_reg_paos_oper_status_set(payload, 0);
  3440. mlxsw_reg_paos_ase_set(payload, 1);
  3441. mlxsw_reg_paos_ee_set(payload, 1);
  3442. mlxsw_reg_paos_e_set(payload, 1);
  3443. }
  3444. /* PFCC - Ports Flow Control Configuration Register
  3445. * ------------------------------------------------
  3446. * Configures and retrieves the per port flow control configuration.
  3447. */
  3448. #define MLXSW_REG_PFCC_ID 0x5007
  3449. #define MLXSW_REG_PFCC_LEN 0x20
  3450. MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
  3451. /* reg_pfcc_local_port
  3452. * Local port number.
  3453. * Access: Index
  3454. */
  3455. MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
  3456. /* reg_pfcc_pnat
  3457. * Port number access type. Determines the way local_port is interpreted:
  3458. * 0 - Local port number.
  3459. * 1 - IB / label port number.
  3460. * Access: Index
  3461. */
  3462. MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
  3463. /* reg_pfcc_shl_cap
  3464. * Send to higher layers capabilities:
  3465. * 0 - No capability of sending Pause and PFC frames to higher layers.
  3466. * 1 - Device has capability of sending Pause and PFC frames to higher
  3467. * layers.
  3468. * Access: RO
  3469. */
  3470. MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
  3471. /* reg_pfcc_shl_opr
  3472. * Send to higher layers operation:
  3473. * 0 - Pause and PFC frames are handled by the port (default).
  3474. * 1 - Pause and PFC frames are handled by the port and also sent to
  3475. * higher layers. Only valid if shl_cap = 1.
  3476. * Access: RW
  3477. */
  3478. MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
  3479. /* reg_pfcc_ppan
  3480. * Pause policy auto negotiation.
  3481. * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
  3482. * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
  3483. * based on the auto-negotiation resolution.
  3484. * Access: RW
  3485. *
  3486. * Note: The auto-negotiation advertisement is set according to pptx and
  3487. * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
  3488. */
  3489. MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
  3490. /* reg_pfcc_prio_mask_tx
  3491. * Bit per priority indicating if Tx flow control policy should be
  3492. * updated based on bit pfctx.
  3493. * Access: WO
  3494. */
  3495. MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
  3496. /* reg_pfcc_prio_mask_rx
  3497. * Bit per priority indicating if Rx flow control policy should be
  3498. * updated based on bit pfcrx.
  3499. * Access: WO
  3500. */
  3501. MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
  3502. /* reg_pfcc_pptx
  3503. * Admin Pause policy on Tx.
  3504. * 0 - Never generate Pause frames (default).
  3505. * 1 - Generate Pause frames according to Rx buffer threshold.
  3506. * Access: RW
  3507. */
  3508. MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
  3509. /* reg_pfcc_aptx
  3510. * Active (operational) Pause policy on Tx.
  3511. * 0 - Never generate Pause frames.
  3512. * 1 - Generate Pause frames according to Rx buffer threshold.
  3513. * Access: RO
  3514. */
  3515. MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
  3516. /* reg_pfcc_pfctx
  3517. * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
  3518. * 0 - Never generate priority Pause frames on the specified priority
  3519. * (default).
  3520. * 1 - Generate priority Pause frames according to Rx buffer threshold on
  3521. * the specified priority.
  3522. * Access: RW
  3523. *
  3524. * Note: pfctx and pptx must be mutually exclusive.
  3525. */
  3526. MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
  3527. /* reg_pfcc_pprx
  3528. * Admin Pause policy on Rx.
  3529. * 0 - Ignore received Pause frames (default).
  3530. * 1 - Respect received Pause frames.
  3531. * Access: RW
  3532. */
  3533. MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
  3534. /* reg_pfcc_aprx
  3535. * Active (operational) Pause policy on Rx.
  3536. * 0 - Ignore received Pause frames.
  3537. * 1 - Respect received Pause frames.
  3538. * Access: RO
  3539. */
  3540. MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
  3541. /* reg_pfcc_pfcrx
  3542. * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
  3543. * 0 - Ignore incoming priority Pause frames on the specified priority
  3544. * (default).
  3545. * 1 - Respect incoming priority Pause frames on the specified priority.
  3546. * Access: RW
  3547. */
  3548. MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
  3549. #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
  3550. static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
  3551. {
  3552. mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  3553. mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  3554. mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
  3555. mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
  3556. }
  3557. static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
  3558. {
  3559. MLXSW_REG_ZERO(pfcc, payload);
  3560. mlxsw_reg_pfcc_local_port_set(payload, local_port);
  3561. }
  3562. /* PPCNT - Ports Performance Counters Register
  3563. * -------------------------------------------
  3564. * The PPCNT register retrieves per port performance counters.
  3565. */
  3566. #define MLXSW_REG_PPCNT_ID 0x5008
  3567. #define MLXSW_REG_PPCNT_LEN 0x100
  3568. #define MLXSW_REG_PPCNT_COUNTERS_OFFSET 0x08
  3569. MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
  3570. /* reg_ppcnt_swid
  3571. * For HCA: must be always 0.
  3572. * Switch partition ID to associate port with.
  3573. * Switch partitions are numbered from 0 to 7 inclusively.
  3574. * Switch partition 254 indicates stacking ports.
  3575. * Switch partition 255 indicates all switch partitions.
  3576. * Only valid on Set() operation with local_port=255.
  3577. * Access: Index
  3578. */
  3579. MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
  3580. /* reg_ppcnt_local_port
  3581. * Local port number.
  3582. * 255 indicates all ports on the device, and is only allowed
  3583. * for Set() operation.
  3584. * Access: Index
  3585. */
  3586. MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
  3587. /* reg_ppcnt_pnat
  3588. * Port number access type:
  3589. * 0 - Local port number
  3590. * 1 - IB port number
  3591. * Access: Index
  3592. */
  3593. MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
  3594. enum mlxsw_reg_ppcnt_grp {
  3595. MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
  3596. MLXSW_REG_PPCNT_RFC_2819_CNT = 0x2,
  3597. MLXSW_REG_PPCNT_EXT_CNT = 0x5,
  3598. MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
  3599. MLXSW_REG_PPCNT_TC_CNT = 0x11,
  3600. MLXSW_REG_PPCNT_TC_CONG_TC = 0x13,
  3601. };
  3602. /* reg_ppcnt_grp
  3603. * Performance counter group.
  3604. * Group 63 indicates all groups. Only valid on Set() operation with
  3605. * clr bit set.
  3606. * 0x0: IEEE 802.3 Counters
  3607. * 0x1: RFC 2863 Counters
  3608. * 0x2: RFC 2819 Counters
  3609. * 0x3: RFC 3635 Counters
  3610. * 0x5: Ethernet Extended Counters
  3611. * 0x8: Link Level Retransmission Counters
  3612. * 0x10: Per Priority Counters
  3613. * 0x11: Per Traffic Class Counters
  3614. * 0x12: Physical Layer Counters
  3615. * 0x13: Per Traffic Class Congestion Counters
  3616. * Access: Index
  3617. */
  3618. MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
  3619. /* reg_ppcnt_clr
  3620. * Clear counters. Setting the clr bit will reset the counter value
  3621. * for all counters in the counter group. This bit can be set
  3622. * for both Set() and Get() operation.
  3623. * Access: OP
  3624. */
  3625. MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
  3626. /* reg_ppcnt_prio_tc
  3627. * Priority for counter set that support per priority, valid values: 0-7.
  3628. * Traffic class for counter set that support per traffic class,
  3629. * valid values: 0- cap_max_tclass-1 .
  3630. * For HCA: cap_max_tclass is always 8.
  3631. * Otherwise must be 0.
  3632. * Access: Index
  3633. */
  3634. MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
  3635. /* Ethernet IEEE 802.3 Counter Group */
  3636. /* reg_ppcnt_a_frames_transmitted_ok
  3637. * Access: RO
  3638. */
  3639. MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
  3640. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  3641. /* reg_ppcnt_a_frames_received_ok
  3642. * Access: RO
  3643. */
  3644. MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
  3645. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  3646. /* reg_ppcnt_a_frame_check_sequence_errors
  3647. * Access: RO
  3648. */
  3649. MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
  3650. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x10, 0, 64);
  3651. /* reg_ppcnt_a_alignment_errors
  3652. * Access: RO
  3653. */
  3654. MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
  3655. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x18, 0, 64);
  3656. /* reg_ppcnt_a_octets_transmitted_ok
  3657. * Access: RO
  3658. */
  3659. MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
  3660. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
  3661. /* reg_ppcnt_a_octets_received_ok
  3662. * Access: RO
  3663. */
  3664. MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
  3665. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
  3666. /* reg_ppcnt_a_multicast_frames_xmitted_ok
  3667. * Access: RO
  3668. */
  3669. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
  3670. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x30, 0, 64);
  3671. /* reg_ppcnt_a_broadcast_frames_xmitted_ok
  3672. * Access: RO
  3673. */
  3674. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
  3675. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x38, 0, 64);
  3676. /* reg_ppcnt_a_multicast_frames_received_ok
  3677. * Access: RO
  3678. */
  3679. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
  3680. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x40, 0, 64);
  3681. /* reg_ppcnt_a_broadcast_frames_received_ok
  3682. * Access: RO
  3683. */
  3684. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
  3685. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
  3686. /* reg_ppcnt_a_in_range_length_errors
  3687. * Access: RO
  3688. */
  3689. MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
  3690. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
  3691. /* reg_ppcnt_a_out_of_range_length_field
  3692. * Access: RO
  3693. */
  3694. MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
  3695. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  3696. /* reg_ppcnt_a_frame_too_long_errors
  3697. * Access: RO
  3698. */
  3699. MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
  3700. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  3701. /* reg_ppcnt_a_symbol_error_during_carrier
  3702. * Access: RO
  3703. */
  3704. MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
  3705. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  3706. /* reg_ppcnt_a_mac_control_frames_transmitted
  3707. * Access: RO
  3708. */
  3709. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
  3710. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  3711. /* reg_ppcnt_a_mac_control_frames_received
  3712. * Access: RO
  3713. */
  3714. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
  3715. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
  3716. /* reg_ppcnt_a_unsupported_opcodes_received
  3717. * Access: RO
  3718. */
  3719. MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
  3720. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
  3721. /* reg_ppcnt_a_pause_mac_ctrl_frames_received
  3722. * Access: RO
  3723. */
  3724. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
  3725. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
  3726. /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
  3727. * Access: RO
  3728. */
  3729. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
  3730. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
  3731. /* Ethernet RFC 2819 Counter Group */
  3732. /* reg_ppcnt_ether_stats_pkts64octets
  3733. * Access: RO
  3734. */
  3735. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts64octets,
  3736. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  3737. /* reg_ppcnt_ether_stats_pkts65to127octets
  3738. * Access: RO
  3739. */
  3740. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts65to127octets,
  3741. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  3742. /* reg_ppcnt_ether_stats_pkts128to255octets
  3743. * Access: RO
  3744. */
  3745. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts128to255octets,
  3746. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  3747. /* reg_ppcnt_ether_stats_pkts256to511octets
  3748. * Access: RO
  3749. */
  3750. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts256to511octets,
  3751. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  3752. /* reg_ppcnt_ether_stats_pkts512to1023octets
  3753. * Access: RO
  3754. */
  3755. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts512to1023octets,
  3756. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x78, 0, 64);
  3757. /* reg_ppcnt_ether_stats_pkts1024to1518octets
  3758. * Access: RO
  3759. */
  3760. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1024to1518octets,
  3761. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x80, 0, 64);
  3762. /* reg_ppcnt_ether_stats_pkts1519to2047octets
  3763. * Access: RO
  3764. */
  3765. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts1519to2047octets,
  3766. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x88, 0, 64);
  3767. /* reg_ppcnt_ether_stats_pkts2048to4095octets
  3768. * Access: RO
  3769. */
  3770. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts2048to4095octets,
  3771. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x90, 0, 64);
  3772. /* reg_ppcnt_ether_stats_pkts4096to8191octets
  3773. * Access: RO
  3774. */
  3775. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts4096to8191octets,
  3776. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x98, 0, 64);
  3777. /* reg_ppcnt_ether_stats_pkts8192to10239octets
  3778. * Access: RO
  3779. */
  3780. MLXSW_ITEM64(reg, ppcnt, ether_stats_pkts8192to10239octets,
  3781. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0xA0, 0, 64);
  3782. /* Ethernet Extended Counter Group Counters */
  3783. /* reg_ppcnt_ecn_marked
  3784. * Access: RO
  3785. */
  3786. MLXSW_ITEM64(reg, ppcnt, ecn_marked,
  3787. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  3788. /* Ethernet Per Priority Group Counters */
  3789. /* reg_ppcnt_rx_octets
  3790. * Access: RO
  3791. */
  3792. MLXSW_ITEM64(reg, ppcnt, rx_octets,
  3793. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  3794. /* reg_ppcnt_rx_frames
  3795. * Access: RO
  3796. */
  3797. MLXSW_ITEM64(reg, ppcnt, rx_frames,
  3798. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x20, 0, 64);
  3799. /* reg_ppcnt_tx_octets
  3800. * Access: RO
  3801. */
  3802. MLXSW_ITEM64(reg, ppcnt, tx_octets,
  3803. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x28, 0, 64);
  3804. /* reg_ppcnt_tx_frames
  3805. * Access: RO
  3806. */
  3807. MLXSW_ITEM64(reg, ppcnt, tx_frames,
  3808. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x48, 0, 64);
  3809. /* reg_ppcnt_rx_pause
  3810. * Access: RO
  3811. */
  3812. MLXSW_ITEM64(reg, ppcnt, rx_pause,
  3813. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x50, 0, 64);
  3814. /* reg_ppcnt_rx_pause_duration
  3815. * Access: RO
  3816. */
  3817. MLXSW_ITEM64(reg, ppcnt, rx_pause_duration,
  3818. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x58, 0, 64);
  3819. /* reg_ppcnt_tx_pause
  3820. * Access: RO
  3821. */
  3822. MLXSW_ITEM64(reg, ppcnt, tx_pause,
  3823. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x60, 0, 64);
  3824. /* reg_ppcnt_tx_pause_duration
  3825. * Access: RO
  3826. */
  3827. MLXSW_ITEM64(reg, ppcnt, tx_pause_duration,
  3828. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x68, 0, 64);
  3829. /* reg_ppcnt_rx_pause_transition
  3830. * Access: RO
  3831. */
  3832. MLXSW_ITEM64(reg, ppcnt, tx_pause_transition,
  3833. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x70, 0, 64);
  3834. /* Ethernet Per Traffic Group Counters */
  3835. /* reg_ppcnt_tc_transmit_queue
  3836. * Contains the transmit queue depth in cells of traffic class
  3837. * selected by prio_tc and the port selected by local_port.
  3838. * The field cannot be cleared.
  3839. * Access: RO
  3840. */
  3841. MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue,
  3842. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  3843. /* reg_ppcnt_tc_no_buffer_discard_uc
  3844. * The number of unicast packets dropped due to lack of shared
  3845. * buffer resources.
  3846. * Access: RO
  3847. */
  3848. MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc,
  3849. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x08, 0, 64);
  3850. /* Ethernet Per Traffic Class Congestion Group Counters */
  3851. /* reg_ppcnt_wred_discard
  3852. * Access: RO
  3853. */
  3854. MLXSW_ITEM64(reg, ppcnt, wred_discard,
  3855. MLXSW_REG_PPCNT_COUNTERS_OFFSET + 0x00, 0, 64);
  3856. static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
  3857. enum mlxsw_reg_ppcnt_grp grp,
  3858. u8 prio_tc)
  3859. {
  3860. MLXSW_REG_ZERO(ppcnt, payload);
  3861. mlxsw_reg_ppcnt_swid_set(payload, 0);
  3862. mlxsw_reg_ppcnt_local_port_set(payload, local_port);
  3863. mlxsw_reg_ppcnt_pnat_set(payload, 0);
  3864. mlxsw_reg_ppcnt_grp_set(payload, grp);
  3865. mlxsw_reg_ppcnt_clr_set(payload, 0);
  3866. mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
  3867. }
  3868. /* PLIB - Port Local to InfiniBand Port
  3869. * ------------------------------------
  3870. * The PLIB register performs mapping from Local Port into InfiniBand Port.
  3871. */
  3872. #define MLXSW_REG_PLIB_ID 0x500A
  3873. #define MLXSW_REG_PLIB_LEN 0x10
  3874. MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
  3875. /* reg_plib_local_port
  3876. * Local port number.
  3877. * Access: Index
  3878. */
  3879. MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
  3880. /* reg_plib_ib_port
  3881. * InfiniBand port remapping for local_port.
  3882. * Access: RW
  3883. */
  3884. MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
  3885. /* PPTB - Port Prio To Buffer Register
  3886. * -----------------------------------
  3887. * Configures the switch priority to buffer table.
  3888. */
  3889. #define MLXSW_REG_PPTB_ID 0x500B
  3890. #define MLXSW_REG_PPTB_LEN 0x10
  3891. MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
  3892. enum {
  3893. MLXSW_REG_PPTB_MM_UM,
  3894. MLXSW_REG_PPTB_MM_UNICAST,
  3895. MLXSW_REG_PPTB_MM_MULTICAST,
  3896. };
  3897. /* reg_pptb_mm
  3898. * Mapping mode.
  3899. * 0 - Map both unicast and multicast packets to the same buffer.
  3900. * 1 - Map only unicast packets.
  3901. * 2 - Map only multicast packets.
  3902. * Access: Index
  3903. *
  3904. * Note: SwitchX-2 only supports the first option.
  3905. */
  3906. MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
  3907. /* reg_pptb_local_port
  3908. * Local port number.
  3909. * Access: Index
  3910. */
  3911. MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
  3912. /* reg_pptb_um
  3913. * Enables the update of the untagged_buf field.
  3914. * Access: RW
  3915. */
  3916. MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
  3917. /* reg_pptb_pm
  3918. * Enables the update of the prio_to_buff field.
  3919. * Bit <i> is a flag for updating the mapping for switch priority <i>.
  3920. * Access: RW
  3921. */
  3922. MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
  3923. /* reg_pptb_prio_to_buff
  3924. * Mapping of switch priority <i> to one of the allocated receive port
  3925. * buffers.
  3926. * Access: RW
  3927. */
  3928. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
  3929. /* reg_pptb_pm_msb
  3930. * Enables the update of the prio_to_buff field.
  3931. * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
  3932. * Access: RW
  3933. */
  3934. MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
  3935. /* reg_pptb_untagged_buff
  3936. * Mapping of untagged frames to one of the allocated receive port buffers.
  3937. * Access: RW
  3938. *
  3939. * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
  3940. * Spectrum, as it maps untagged packets based on the default switch priority.
  3941. */
  3942. MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
  3943. /* reg_pptb_prio_to_buff_msb
  3944. * Mapping of switch priority <i+8> to one of the allocated receive port
  3945. * buffers.
  3946. * Access: RW
  3947. */
  3948. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
  3949. #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
  3950. static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
  3951. {
  3952. MLXSW_REG_ZERO(pptb, payload);
  3953. mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
  3954. mlxsw_reg_pptb_local_port_set(payload, local_port);
  3955. mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  3956. mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  3957. }
  3958. static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
  3959. u8 buff)
  3960. {
  3961. mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
  3962. mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
  3963. }
  3964. /* PBMC - Port Buffer Management Control Register
  3965. * ----------------------------------------------
  3966. * The PBMC register configures and retrieves the port packet buffer
  3967. * allocation for different Prios, and the Pause threshold management.
  3968. */
  3969. #define MLXSW_REG_PBMC_ID 0x500C
  3970. #define MLXSW_REG_PBMC_LEN 0x6C
  3971. MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
  3972. /* reg_pbmc_local_port
  3973. * Local port number.
  3974. * Access: Index
  3975. */
  3976. MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
  3977. /* reg_pbmc_xoff_timer_value
  3978. * When device generates a pause frame, it uses this value as the pause
  3979. * timer (time for the peer port to pause in quota-512 bit time).
  3980. * Access: RW
  3981. */
  3982. MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
  3983. /* reg_pbmc_xoff_refresh
  3984. * The time before a new pause frame should be sent to refresh the pause RW
  3985. * state. Using the same units as xoff_timer_value above (in quota-512 bit
  3986. * time).
  3987. * Access: RW
  3988. */
  3989. MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
  3990. #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
  3991. /* reg_pbmc_buf_lossy
  3992. * The field indicates if the buffer is lossy.
  3993. * 0 - Lossless
  3994. * 1 - Lossy
  3995. * Access: RW
  3996. */
  3997. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
  3998. /* reg_pbmc_buf_epsb
  3999. * Eligible for Port Shared buffer.
  4000. * If epsb is set, packets assigned to buffer are allowed to insert the port
  4001. * shared buffer.
  4002. * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
  4003. * Access: RW
  4004. */
  4005. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
  4006. /* reg_pbmc_buf_size
  4007. * The part of the packet buffer array is allocated for the specific buffer.
  4008. * Units are represented in cells.
  4009. * Access: RW
  4010. */
  4011. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
  4012. /* reg_pbmc_buf_xoff_threshold
  4013. * Once the amount of data in the buffer goes above this value, device
  4014. * starts sending PFC frames for all priorities associated with the
  4015. * buffer. Units are represented in cells. Reserved in case of lossy
  4016. * buffer.
  4017. * Access: RW
  4018. *
  4019. * Note: In Spectrum, reserved for buffer[9].
  4020. */
  4021. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
  4022. 0x08, 0x04, false);
  4023. /* reg_pbmc_buf_xon_threshold
  4024. * When the amount of data in the buffer goes below this value, device
  4025. * stops sending PFC frames for the priorities associated with the
  4026. * buffer. Units are represented in cells. Reserved in case of lossy
  4027. * buffer.
  4028. * Access: RW
  4029. *
  4030. * Note: In Spectrum, reserved for buffer[9].
  4031. */
  4032. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
  4033. 0x08, 0x04, false);
  4034. static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
  4035. u16 xoff_timer_value, u16 xoff_refresh)
  4036. {
  4037. MLXSW_REG_ZERO(pbmc, payload);
  4038. mlxsw_reg_pbmc_local_port_set(payload, local_port);
  4039. mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
  4040. mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
  4041. }
  4042. static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
  4043. int buf_index,
  4044. u16 size)
  4045. {
  4046. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
  4047. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  4048. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  4049. }
  4050. static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
  4051. int buf_index, u16 size,
  4052. u16 threshold)
  4053. {
  4054. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
  4055. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  4056. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  4057. mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
  4058. mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
  4059. }
  4060. /* PSPA - Port Switch Partition Allocation
  4061. * ---------------------------------------
  4062. * Controls the association of a port with a switch partition and enables
  4063. * configuring ports as stacking ports.
  4064. */
  4065. #define MLXSW_REG_PSPA_ID 0x500D
  4066. #define MLXSW_REG_PSPA_LEN 0x8
  4067. MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
  4068. /* reg_pspa_swid
  4069. * Switch partition ID.
  4070. * Access: RW
  4071. */
  4072. MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
  4073. /* reg_pspa_local_port
  4074. * Local port number.
  4075. * Access: Index
  4076. */
  4077. MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
  4078. /* reg_pspa_sub_port
  4079. * Virtual port within the local port. Set to 0 when virtual ports are
  4080. * disabled on the local port.
  4081. * Access: Index
  4082. */
  4083. MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
  4084. static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
  4085. {
  4086. MLXSW_REG_ZERO(pspa, payload);
  4087. mlxsw_reg_pspa_swid_set(payload, swid);
  4088. mlxsw_reg_pspa_local_port_set(payload, local_port);
  4089. mlxsw_reg_pspa_sub_port_set(payload, 0);
  4090. }
  4091. /* HTGT - Host Trap Group Table
  4092. * ----------------------------
  4093. * Configures the properties for forwarding to CPU.
  4094. */
  4095. #define MLXSW_REG_HTGT_ID 0x7002
  4096. #define MLXSW_REG_HTGT_LEN 0x20
  4097. MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
  4098. /* reg_htgt_swid
  4099. * Switch partition ID.
  4100. * Access: Index
  4101. */
  4102. MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
  4103. #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
  4104. /* reg_htgt_type
  4105. * CPU path type.
  4106. * Access: RW
  4107. */
  4108. MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
  4109. enum mlxsw_reg_htgt_trap_group {
  4110. MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
  4111. MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
  4112. MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
  4113. MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
  4114. MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
  4115. MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
  4116. MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
  4117. MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
  4118. MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
  4119. MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
  4120. MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
  4121. MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
  4122. MLXSW_REG_HTGT_TRAP_GROUP_SP_HOST_MISS,
  4123. MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
  4124. MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
  4125. MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
  4126. MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
  4127. MLXSW_REG_HTGT_TRAP_GROUP_SP_RPF,
  4128. MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
  4129. MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_MLD,
  4130. MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6_ND,
  4131. };
  4132. /* reg_htgt_trap_group
  4133. * Trap group number. User defined number specifying which trap groups
  4134. * should be forwarded to the CPU. The mapping between trap IDs and trap
  4135. * groups is configured using HPKT register.
  4136. * Access: Index
  4137. */
  4138. MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
  4139. enum {
  4140. MLXSW_REG_HTGT_POLICER_DISABLE,
  4141. MLXSW_REG_HTGT_POLICER_ENABLE,
  4142. };
  4143. /* reg_htgt_pide
  4144. * Enable policer ID specified using 'pid' field.
  4145. * Access: RW
  4146. */
  4147. MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
  4148. #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
  4149. /* reg_htgt_pid
  4150. * Policer ID for the trap group.
  4151. * Access: RW
  4152. */
  4153. MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
  4154. #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
  4155. /* reg_htgt_mirror_action
  4156. * Mirror action to use.
  4157. * 0 - Trap to CPU.
  4158. * 1 - Trap to CPU and mirror to a mirroring agent.
  4159. * 2 - Mirror to a mirroring agent and do not trap to CPU.
  4160. * Access: RW
  4161. *
  4162. * Note: Mirroring to a mirroring agent is only supported in Spectrum.
  4163. */
  4164. MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
  4165. /* reg_htgt_mirroring_agent
  4166. * Mirroring agent.
  4167. * Access: RW
  4168. */
  4169. MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
  4170. #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
  4171. /* reg_htgt_priority
  4172. * Trap group priority.
  4173. * In case a packet matches multiple classification rules, the packet will
  4174. * only be trapped once, based on the trap ID associated with the group (via
  4175. * register HPKT) with the highest priority.
  4176. * Supported values are 0-7, with 7 represnting the highest priority.
  4177. * Access: RW
  4178. *
  4179. * Note: In SwitchX-2 this field is ignored and the priority value is replaced
  4180. * by the 'trap_group' field.
  4181. */
  4182. MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
  4183. #define MLXSW_REG_HTGT_DEFAULT_TC 7
  4184. /* reg_htgt_local_path_cpu_tclass
  4185. * CPU ingress traffic class for the trap group.
  4186. * Access: RW
  4187. */
  4188. MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
  4189. enum mlxsw_reg_htgt_local_path_rdq {
  4190. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
  4191. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
  4192. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
  4193. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
  4194. };
  4195. /* reg_htgt_local_path_rdq
  4196. * Receive descriptor queue (RDQ) to use for the trap group.
  4197. * Access: RW
  4198. */
  4199. MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
  4200. static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
  4201. u8 priority, u8 tc)
  4202. {
  4203. MLXSW_REG_ZERO(htgt, payload);
  4204. if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
  4205. mlxsw_reg_htgt_pide_set(payload,
  4206. MLXSW_REG_HTGT_POLICER_DISABLE);
  4207. } else {
  4208. mlxsw_reg_htgt_pide_set(payload,
  4209. MLXSW_REG_HTGT_POLICER_ENABLE);
  4210. mlxsw_reg_htgt_pid_set(payload, policer_id);
  4211. }
  4212. mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
  4213. mlxsw_reg_htgt_trap_group_set(payload, group);
  4214. mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
  4215. mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
  4216. mlxsw_reg_htgt_priority_set(payload, priority);
  4217. mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
  4218. mlxsw_reg_htgt_local_path_rdq_set(payload, group);
  4219. }
  4220. /* HPKT - Host Packet Trap
  4221. * -----------------------
  4222. * Configures trap IDs inside trap groups.
  4223. */
  4224. #define MLXSW_REG_HPKT_ID 0x7003
  4225. #define MLXSW_REG_HPKT_LEN 0x10
  4226. MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
  4227. enum {
  4228. MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
  4229. MLXSW_REG_HPKT_ACK_REQUIRED,
  4230. };
  4231. /* reg_hpkt_ack
  4232. * Require acknowledgements from the host for events.
  4233. * If set, then the device will wait for the event it sent to be acknowledged
  4234. * by the host. This option is only relevant for event trap IDs.
  4235. * Access: RW
  4236. *
  4237. * Note: Currently not supported by firmware.
  4238. */
  4239. MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
  4240. enum mlxsw_reg_hpkt_action {
  4241. MLXSW_REG_HPKT_ACTION_FORWARD,
  4242. MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
  4243. MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
  4244. MLXSW_REG_HPKT_ACTION_DISCARD,
  4245. MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
  4246. MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
  4247. };
  4248. /* reg_hpkt_action
  4249. * Action to perform on packet when trapped.
  4250. * 0 - No action. Forward to CPU based on switching rules.
  4251. * 1 - Trap to CPU (CPU receives sole copy).
  4252. * 2 - Mirror to CPU (CPU receives a replica of the packet).
  4253. * 3 - Discard.
  4254. * 4 - Soft discard (allow other traps to act on the packet).
  4255. * 5 - Trap and soft discard (allow other traps to overwrite this trap).
  4256. * Access: RW
  4257. *
  4258. * Note: Must be set to 0 (forward) for event trap IDs, as they are already
  4259. * addressed to the CPU.
  4260. */
  4261. MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
  4262. /* reg_hpkt_trap_group
  4263. * Trap group to associate the trap with.
  4264. * Access: RW
  4265. */
  4266. MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
  4267. /* reg_hpkt_trap_id
  4268. * Trap ID.
  4269. * Access: Index
  4270. *
  4271. * Note: A trap ID can only be associated with a single trap group. The device
  4272. * will associate the trap ID with the last trap group configured.
  4273. */
  4274. MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
  4275. enum {
  4276. MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
  4277. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
  4278. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
  4279. };
  4280. /* reg_hpkt_ctrl
  4281. * Configure dedicated buffer resources for control packets.
  4282. * Ignored by SwitchX-2.
  4283. * 0 - Keep factory defaults.
  4284. * 1 - Do not use control buffer for this trap ID.
  4285. * 2 - Use control buffer for this trap ID.
  4286. * Access: RW
  4287. */
  4288. MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
  4289. static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
  4290. enum mlxsw_reg_htgt_trap_group trap_group,
  4291. bool is_ctrl)
  4292. {
  4293. MLXSW_REG_ZERO(hpkt, payload);
  4294. mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
  4295. mlxsw_reg_hpkt_action_set(payload, action);
  4296. mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
  4297. mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
  4298. mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
  4299. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
  4300. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
  4301. }
  4302. /* RGCR - Router General Configuration Register
  4303. * --------------------------------------------
  4304. * The register is used for setting up the router configuration.
  4305. */
  4306. #define MLXSW_REG_RGCR_ID 0x8001
  4307. #define MLXSW_REG_RGCR_LEN 0x28
  4308. MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
  4309. /* reg_rgcr_ipv4_en
  4310. * IPv4 router enable.
  4311. * Access: RW
  4312. */
  4313. MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
  4314. /* reg_rgcr_ipv6_en
  4315. * IPv6 router enable.
  4316. * Access: RW
  4317. */
  4318. MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
  4319. /* reg_rgcr_max_router_interfaces
  4320. * Defines the maximum number of active router interfaces for all virtual
  4321. * routers.
  4322. * Access: RW
  4323. */
  4324. MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
  4325. /* reg_rgcr_usp
  4326. * Update switch priority and packet color.
  4327. * 0 - Preserve the value of Switch Priority and packet color.
  4328. * 1 - Recalculate the value of Switch Priority and packet color.
  4329. * Access: RW
  4330. *
  4331. * Note: Not supported by SwitchX and SwitchX-2.
  4332. */
  4333. MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
  4334. /* reg_rgcr_pcp_rw
  4335. * Indicates how to handle the pcp_rewrite_en value:
  4336. * 0 - Preserve the value of pcp_rewrite_en.
  4337. * 2 - Disable PCP rewrite.
  4338. * 3 - Enable PCP rewrite.
  4339. * Access: RW
  4340. *
  4341. * Note: Not supported by SwitchX and SwitchX-2.
  4342. */
  4343. MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
  4344. /* reg_rgcr_activity_dis
  4345. * Activity disable:
  4346. * 0 - Activity will be set when an entry is hit (default).
  4347. * 1 - Activity will not be set when an entry is hit.
  4348. *
  4349. * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
  4350. * (RALUE).
  4351. * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
  4352. * Entry (RAUHT).
  4353. * Bits 2:7 are reserved.
  4354. * Access: RW
  4355. *
  4356. * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
  4357. */
  4358. MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
  4359. static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en,
  4360. bool ipv6_en)
  4361. {
  4362. MLXSW_REG_ZERO(rgcr, payload);
  4363. mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
  4364. mlxsw_reg_rgcr_ipv6_en_set(payload, ipv6_en);
  4365. }
  4366. /* RITR - Router Interface Table Register
  4367. * --------------------------------------
  4368. * The register is used to configure the router interface table.
  4369. */
  4370. #define MLXSW_REG_RITR_ID 0x8002
  4371. #define MLXSW_REG_RITR_LEN 0x40
  4372. MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
  4373. /* reg_ritr_enable
  4374. * Enables routing on the router interface.
  4375. * Access: RW
  4376. */
  4377. MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
  4378. /* reg_ritr_ipv4
  4379. * IPv4 routing enable. Enables routing of IPv4 traffic on the router
  4380. * interface.
  4381. * Access: RW
  4382. */
  4383. MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
  4384. /* reg_ritr_ipv6
  4385. * IPv6 routing enable. Enables routing of IPv6 traffic on the router
  4386. * interface.
  4387. * Access: RW
  4388. */
  4389. MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
  4390. /* reg_ritr_ipv4_mc
  4391. * IPv4 multicast routing enable.
  4392. * Access: RW
  4393. */
  4394. MLXSW_ITEM32(reg, ritr, ipv4_mc, 0x00, 27, 1);
  4395. /* reg_ritr_ipv6_mc
  4396. * IPv6 multicast routing enable.
  4397. * Access: RW
  4398. */
  4399. MLXSW_ITEM32(reg, ritr, ipv6_mc, 0x00, 26, 1);
  4400. enum mlxsw_reg_ritr_if_type {
  4401. /* VLAN interface. */
  4402. MLXSW_REG_RITR_VLAN_IF,
  4403. /* FID interface. */
  4404. MLXSW_REG_RITR_FID_IF,
  4405. /* Sub-port interface. */
  4406. MLXSW_REG_RITR_SP_IF,
  4407. /* Loopback Interface. */
  4408. MLXSW_REG_RITR_LOOPBACK_IF,
  4409. };
  4410. /* reg_ritr_type
  4411. * Router interface type as per enum mlxsw_reg_ritr_if_type.
  4412. * Access: RW
  4413. */
  4414. MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
  4415. enum {
  4416. MLXSW_REG_RITR_RIF_CREATE,
  4417. MLXSW_REG_RITR_RIF_DEL,
  4418. };
  4419. /* reg_ritr_op
  4420. * Opcode:
  4421. * 0 - Create or edit RIF.
  4422. * 1 - Delete RIF.
  4423. * Reserved for SwitchX-2. For Spectrum, editing of interface properties
  4424. * is not supported. An interface must be deleted and re-created in order
  4425. * to update properties.
  4426. * Access: WO
  4427. */
  4428. MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
  4429. /* reg_ritr_rif
  4430. * Router interface index. A pointer to the Router Interface Table.
  4431. * Access: Index
  4432. */
  4433. MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
  4434. /* reg_ritr_ipv4_fe
  4435. * IPv4 Forwarding Enable.
  4436. * Enables routing of IPv4 traffic on the router interface. When disabled,
  4437. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  4438. * Not supported in SwitchX-2.
  4439. * Access: RW
  4440. */
  4441. MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
  4442. /* reg_ritr_ipv6_fe
  4443. * IPv6 Forwarding Enable.
  4444. * Enables routing of IPv6 traffic on the router interface. When disabled,
  4445. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  4446. * Not supported in SwitchX-2.
  4447. * Access: RW
  4448. */
  4449. MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
  4450. /* reg_ritr_ipv4_mc_fe
  4451. * IPv4 Multicast Forwarding Enable.
  4452. * When disabled, forwarding is blocked but local traffic (traps and IP to me)
  4453. * will be enabled.
  4454. * Access: RW
  4455. */
  4456. MLXSW_ITEM32(reg, ritr, ipv4_mc_fe, 0x04, 27, 1);
  4457. /* reg_ritr_ipv6_mc_fe
  4458. * IPv6 Multicast Forwarding Enable.
  4459. * When disabled, forwarding is blocked but local traffic (traps and IP to me)
  4460. * will be enabled.
  4461. * Access: RW
  4462. */
  4463. MLXSW_ITEM32(reg, ritr, ipv6_mc_fe, 0x04, 26, 1);
  4464. /* reg_ritr_lb_en
  4465. * Loop-back filter enable for unicast packets.
  4466. * If the flag is set then loop-back filter for unicast packets is
  4467. * implemented on the RIF. Multicast packets are always subject to
  4468. * loop-back filtering.
  4469. * Access: RW
  4470. */
  4471. MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
  4472. /* reg_ritr_virtual_router
  4473. * Virtual router ID associated with the router interface.
  4474. * Access: RW
  4475. */
  4476. MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
  4477. /* reg_ritr_mtu
  4478. * Router interface MTU.
  4479. * Access: RW
  4480. */
  4481. MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
  4482. /* reg_ritr_if_swid
  4483. * Switch partition ID.
  4484. * Access: RW
  4485. */
  4486. MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
  4487. /* reg_ritr_if_mac
  4488. * Router interface MAC address.
  4489. * In Spectrum, all MAC addresses must have the same 38 MSBits.
  4490. * Access: RW
  4491. */
  4492. MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
  4493. /* reg_ritr_if_vrrp_id_ipv6
  4494. * VRRP ID for IPv6
  4495. * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
  4496. * Access: RW
  4497. */
  4498. MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv6, 0x1C, 8, 8);
  4499. /* reg_ritr_if_vrrp_id_ipv4
  4500. * VRRP ID for IPv4
  4501. * Note: Reserved for RIF types other than VLAN, FID and Sub-port.
  4502. * Access: RW
  4503. */
  4504. MLXSW_ITEM32(reg, ritr, if_vrrp_id_ipv4, 0x1C, 0, 8);
  4505. /* VLAN Interface */
  4506. /* reg_ritr_vlan_if_vid
  4507. * VLAN ID.
  4508. * Access: RW
  4509. */
  4510. MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
  4511. /* FID Interface */
  4512. /* reg_ritr_fid_if_fid
  4513. * Filtering ID. Used to connect a bridge to the router. Only FIDs from
  4514. * the vFID range are supported.
  4515. * Access: RW
  4516. */
  4517. MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
  4518. static inline void mlxsw_reg_ritr_fid_set(char *payload,
  4519. enum mlxsw_reg_ritr_if_type rif_type,
  4520. u16 fid)
  4521. {
  4522. if (rif_type == MLXSW_REG_RITR_FID_IF)
  4523. mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
  4524. else
  4525. mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
  4526. }
  4527. /* Sub-port Interface */
  4528. /* reg_ritr_sp_if_lag
  4529. * LAG indication. When this bit is set the system_port field holds the
  4530. * LAG identifier.
  4531. * Access: RW
  4532. */
  4533. MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
  4534. /* reg_ritr_sp_system_port
  4535. * Port unique indentifier. When lag bit is set, this field holds the
  4536. * lag_id in bits 0:9.
  4537. * Access: RW
  4538. */
  4539. MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
  4540. /* reg_ritr_sp_if_vid
  4541. * VLAN ID.
  4542. * Access: RW
  4543. */
  4544. MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
  4545. /* Loopback Interface */
  4546. enum mlxsw_reg_ritr_loopback_protocol {
  4547. /* IPinIP IPv4 underlay Unicast */
  4548. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4,
  4549. /* IPinIP IPv6 underlay Unicast */
  4550. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV6,
  4551. };
  4552. /* reg_ritr_loopback_protocol
  4553. * Access: RW
  4554. */
  4555. MLXSW_ITEM32(reg, ritr, loopback_protocol, 0x08, 28, 4);
  4556. enum mlxsw_reg_ritr_loopback_ipip_type {
  4557. /* Tunnel is IPinIP. */
  4558. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_IP,
  4559. /* Tunnel is GRE, no key. */
  4560. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_IN_IP,
  4561. /* Tunnel is GRE, with a key. */
  4562. MLXSW_REG_RITR_LOOPBACK_IPIP_TYPE_IP_IN_GRE_KEY_IN_IP,
  4563. };
  4564. /* reg_ritr_loopback_ipip_type
  4565. * Encapsulation type.
  4566. * Access: RW
  4567. */
  4568. MLXSW_ITEM32(reg, ritr, loopback_ipip_type, 0x10, 24, 4);
  4569. enum mlxsw_reg_ritr_loopback_ipip_options {
  4570. /* The key is defined by gre_key. */
  4571. MLXSW_REG_RITR_LOOPBACK_IPIP_OPTIONS_GRE_KEY_PRESET,
  4572. };
  4573. /* reg_ritr_loopback_ipip_options
  4574. * Access: RW
  4575. */
  4576. MLXSW_ITEM32(reg, ritr, loopback_ipip_options, 0x10, 20, 4);
  4577. /* reg_ritr_loopback_ipip_uvr
  4578. * Underlay Virtual Router ID.
  4579. * Range is 0..cap_max_virtual_routers-1.
  4580. * Reserved for Spectrum-2.
  4581. * Access: RW
  4582. */
  4583. MLXSW_ITEM32(reg, ritr, loopback_ipip_uvr, 0x10, 0, 16);
  4584. /* reg_ritr_loopback_ipip_usip*
  4585. * Encapsulation Underlay source IP.
  4586. * Access: RW
  4587. */
  4588. MLXSW_ITEM_BUF(reg, ritr, loopback_ipip_usip6, 0x18, 16);
  4589. MLXSW_ITEM32(reg, ritr, loopback_ipip_usip4, 0x24, 0, 32);
  4590. /* reg_ritr_loopback_ipip_gre_key
  4591. * GRE Key.
  4592. * Reserved when ipip_type is not IP_IN_GRE_KEY_IN_IP.
  4593. * Access: RW
  4594. */
  4595. MLXSW_ITEM32(reg, ritr, loopback_ipip_gre_key, 0x28, 0, 32);
  4596. /* Shared between ingress/egress */
  4597. enum mlxsw_reg_ritr_counter_set_type {
  4598. /* No Count. */
  4599. MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
  4600. /* Basic. Used for router interfaces, counting the following:
  4601. * - Error and Discard counters.
  4602. * - Unicast, Multicast and Broadcast counters. Sharing the
  4603. * same set of counters for the different type of traffic
  4604. * (IPv4, IPv6 and mpls).
  4605. */
  4606. MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
  4607. };
  4608. /* reg_ritr_ingress_counter_index
  4609. * Counter Index for flow counter.
  4610. * Access: RW
  4611. */
  4612. MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
  4613. /* reg_ritr_ingress_counter_set_type
  4614. * Igress Counter Set Type for router interface counter.
  4615. * Access: RW
  4616. */
  4617. MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
  4618. /* reg_ritr_egress_counter_index
  4619. * Counter Index for flow counter.
  4620. * Access: RW
  4621. */
  4622. MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
  4623. /* reg_ritr_egress_counter_set_type
  4624. * Egress Counter Set Type for router interface counter.
  4625. * Access: RW
  4626. */
  4627. MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
  4628. static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
  4629. bool enable, bool egress)
  4630. {
  4631. enum mlxsw_reg_ritr_counter_set_type set_type;
  4632. if (enable)
  4633. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
  4634. else
  4635. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
  4636. mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
  4637. if (egress)
  4638. mlxsw_reg_ritr_egress_counter_index_set(payload, index);
  4639. else
  4640. mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
  4641. }
  4642. static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
  4643. {
  4644. MLXSW_REG_ZERO(ritr, payload);
  4645. mlxsw_reg_ritr_rif_set(payload, rif);
  4646. }
  4647. static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
  4648. u16 system_port, u16 vid)
  4649. {
  4650. mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
  4651. mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
  4652. mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
  4653. }
  4654. static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
  4655. enum mlxsw_reg_ritr_if_type type,
  4656. u16 rif, u16 vr_id, u16 mtu)
  4657. {
  4658. bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
  4659. MLXSW_REG_ZERO(ritr, payload);
  4660. mlxsw_reg_ritr_enable_set(payload, enable);
  4661. mlxsw_reg_ritr_ipv4_set(payload, 1);
  4662. mlxsw_reg_ritr_ipv6_set(payload, 1);
  4663. mlxsw_reg_ritr_ipv4_mc_set(payload, 1);
  4664. mlxsw_reg_ritr_ipv6_mc_set(payload, 1);
  4665. mlxsw_reg_ritr_type_set(payload, type);
  4666. mlxsw_reg_ritr_op_set(payload, op);
  4667. mlxsw_reg_ritr_rif_set(payload, rif);
  4668. mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
  4669. mlxsw_reg_ritr_ipv6_fe_set(payload, 1);
  4670. mlxsw_reg_ritr_ipv4_mc_fe_set(payload, 1);
  4671. mlxsw_reg_ritr_ipv6_mc_fe_set(payload, 1);
  4672. mlxsw_reg_ritr_lb_en_set(payload, 1);
  4673. mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
  4674. mlxsw_reg_ritr_mtu_set(payload, mtu);
  4675. }
  4676. static inline void mlxsw_reg_ritr_mac_pack(char *payload, const char *mac)
  4677. {
  4678. mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
  4679. }
  4680. static inline void
  4681. mlxsw_reg_ritr_loopback_ipip_common_pack(char *payload,
  4682. enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
  4683. enum mlxsw_reg_ritr_loopback_ipip_options options,
  4684. u16 uvr_id, u32 gre_key)
  4685. {
  4686. mlxsw_reg_ritr_loopback_ipip_type_set(payload, ipip_type);
  4687. mlxsw_reg_ritr_loopback_ipip_options_set(payload, options);
  4688. mlxsw_reg_ritr_loopback_ipip_uvr_set(payload, uvr_id);
  4689. mlxsw_reg_ritr_loopback_ipip_gre_key_set(payload, gre_key);
  4690. }
  4691. static inline void
  4692. mlxsw_reg_ritr_loopback_ipip4_pack(char *payload,
  4693. enum mlxsw_reg_ritr_loopback_ipip_type ipip_type,
  4694. enum mlxsw_reg_ritr_loopback_ipip_options options,
  4695. u16 uvr_id, u32 usip, u32 gre_key)
  4696. {
  4697. mlxsw_reg_ritr_loopback_protocol_set(payload,
  4698. MLXSW_REG_RITR_LOOPBACK_PROTOCOL_IPIP_IPV4);
  4699. mlxsw_reg_ritr_loopback_ipip_common_pack(payload, ipip_type, options,
  4700. uvr_id, gre_key);
  4701. mlxsw_reg_ritr_loopback_ipip_usip4_set(payload, usip);
  4702. }
  4703. /* RTAR - Router TCAM Allocation Register
  4704. * --------------------------------------
  4705. * This register is used for allocation of regions in the TCAM table.
  4706. */
  4707. #define MLXSW_REG_RTAR_ID 0x8004
  4708. #define MLXSW_REG_RTAR_LEN 0x20
  4709. MLXSW_REG_DEFINE(rtar, MLXSW_REG_RTAR_ID, MLXSW_REG_RTAR_LEN);
  4710. enum mlxsw_reg_rtar_op {
  4711. MLXSW_REG_RTAR_OP_ALLOCATE,
  4712. MLXSW_REG_RTAR_OP_RESIZE,
  4713. MLXSW_REG_RTAR_OP_DEALLOCATE,
  4714. };
  4715. /* reg_rtar_op
  4716. * Access: WO
  4717. */
  4718. MLXSW_ITEM32(reg, rtar, op, 0x00, 28, 4);
  4719. enum mlxsw_reg_rtar_key_type {
  4720. MLXSW_REG_RTAR_KEY_TYPE_IPV4_MULTICAST = 1,
  4721. MLXSW_REG_RTAR_KEY_TYPE_IPV6_MULTICAST = 3
  4722. };
  4723. /* reg_rtar_key_type
  4724. * TCAM key type for the region.
  4725. * Access: WO
  4726. */
  4727. MLXSW_ITEM32(reg, rtar, key_type, 0x00, 0, 8);
  4728. /* reg_rtar_region_size
  4729. * TCAM region size. When allocating/resizing this is the requested
  4730. * size, the response is the actual size.
  4731. * Note: Actual size may be larger than requested.
  4732. * Reserved for op = Deallocate
  4733. * Access: WO
  4734. */
  4735. MLXSW_ITEM32(reg, rtar, region_size, 0x04, 0, 16);
  4736. static inline void mlxsw_reg_rtar_pack(char *payload,
  4737. enum mlxsw_reg_rtar_op op,
  4738. enum mlxsw_reg_rtar_key_type key_type,
  4739. u16 region_size)
  4740. {
  4741. MLXSW_REG_ZERO(rtar, payload);
  4742. mlxsw_reg_rtar_op_set(payload, op);
  4743. mlxsw_reg_rtar_key_type_set(payload, key_type);
  4744. mlxsw_reg_rtar_region_size_set(payload, region_size);
  4745. }
  4746. /* RATR - Router Adjacency Table Register
  4747. * --------------------------------------
  4748. * The RATR register is used to configure the Router Adjacency (next-hop)
  4749. * Table.
  4750. */
  4751. #define MLXSW_REG_RATR_ID 0x8008
  4752. #define MLXSW_REG_RATR_LEN 0x2C
  4753. MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
  4754. enum mlxsw_reg_ratr_op {
  4755. /* Read */
  4756. MLXSW_REG_RATR_OP_QUERY_READ = 0,
  4757. /* Read and clear activity */
  4758. MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
  4759. /* Write Adjacency entry */
  4760. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
  4761. /* Write Adjacency entry only if the activity is cleared.
  4762. * The write may not succeed if the activity is set. There is not
  4763. * direct feedback if the write has succeeded or not, however
  4764. * the get will reveal the actual entry (SW can compare the get
  4765. * response to the set command).
  4766. */
  4767. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
  4768. };
  4769. /* reg_ratr_op
  4770. * Note that Write operation may also be used for updating
  4771. * counter_set_type and counter_index. In this case all other
  4772. * fields must not be updated.
  4773. * Access: OP
  4774. */
  4775. MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
  4776. /* reg_ratr_v
  4777. * Valid bit. Indicates if the adjacency entry is valid.
  4778. * Note: the device may need some time before reusing an invalidated
  4779. * entry. During this time the entry can not be reused. It is
  4780. * recommended to use another entry before reusing an invalidated
  4781. * entry (e.g. software can put it at the end of the list for
  4782. * reusing). Trying to access an invalidated entry not yet cleared
  4783. * by the device results with failure indicating "Try Again" status.
  4784. * When valid is '0' then egress_router_interface,trap_action,
  4785. * adjacency_parameters and counters are reserved
  4786. * Access: RW
  4787. */
  4788. MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
  4789. /* reg_ratr_a
  4790. * Activity. Set for new entries. Set if a packet lookup has hit on
  4791. * the specific entry. To clear the a bit, use "clear activity".
  4792. * Access: RO
  4793. */
  4794. MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
  4795. enum mlxsw_reg_ratr_type {
  4796. /* Ethernet */
  4797. MLXSW_REG_RATR_TYPE_ETHERNET,
  4798. /* IPoIB Unicast without GRH.
  4799. * Reserved for Spectrum.
  4800. */
  4801. MLXSW_REG_RATR_TYPE_IPOIB_UC,
  4802. /* IPoIB Unicast with GRH. Supported only in table 0 (Ethernet unicast
  4803. * adjacency).
  4804. * Reserved for Spectrum.
  4805. */
  4806. MLXSW_REG_RATR_TYPE_IPOIB_UC_W_GRH,
  4807. /* IPoIB Multicast.
  4808. * Reserved for Spectrum.
  4809. */
  4810. MLXSW_REG_RATR_TYPE_IPOIB_MC,
  4811. /* MPLS.
  4812. * Reserved for SwitchX/-2.
  4813. */
  4814. MLXSW_REG_RATR_TYPE_MPLS,
  4815. /* IPinIP Encap.
  4816. * Reserved for SwitchX/-2.
  4817. */
  4818. MLXSW_REG_RATR_TYPE_IPIP,
  4819. };
  4820. /* reg_ratr_type
  4821. * Adjacency entry type.
  4822. * Access: RW
  4823. */
  4824. MLXSW_ITEM32(reg, ratr, type, 0x04, 28, 4);
  4825. /* reg_ratr_adjacency_index_low
  4826. * Bits 15:0 of index into the adjacency table.
  4827. * For SwitchX and SwitchX-2, the adjacency table is linear and
  4828. * used for adjacency entries only.
  4829. * For Spectrum, the index is to the KVD linear.
  4830. * Access: Index
  4831. */
  4832. MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
  4833. /* reg_ratr_egress_router_interface
  4834. * Range is 0 .. cap_max_router_interfaces - 1
  4835. * Access: RW
  4836. */
  4837. MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
  4838. enum mlxsw_reg_ratr_trap_action {
  4839. MLXSW_REG_RATR_TRAP_ACTION_NOP,
  4840. MLXSW_REG_RATR_TRAP_ACTION_TRAP,
  4841. MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
  4842. MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
  4843. MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
  4844. };
  4845. /* reg_ratr_trap_action
  4846. * see mlxsw_reg_ratr_trap_action
  4847. * Access: RW
  4848. */
  4849. MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
  4850. /* reg_ratr_adjacency_index_high
  4851. * Bits 23:16 of the adjacency_index.
  4852. * Access: Index
  4853. */
  4854. MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
  4855. enum mlxsw_reg_ratr_trap_id {
  4856. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0,
  4857. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1,
  4858. };
  4859. /* reg_ratr_trap_id
  4860. * Trap ID to be reported to CPU.
  4861. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  4862. * For trap_action of NOP, MIRROR and DISCARD_ERROR
  4863. * Access: RW
  4864. */
  4865. MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
  4866. /* reg_ratr_eth_destination_mac
  4867. * MAC address of the destination next-hop.
  4868. * Access: RW
  4869. */
  4870. MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
  4871. enum mlxsw_reg_ratr_ipip_type {
  4872. /* IPv4, address set by mlxsw_reg_ratr_ipip_ipv4_udip. */
  4873. MLXSW_REG_RATR_IPIP_TYPE_IPV4,
  4874. /* IPv6, address set by mlxsw_reg_ratr_ipip_ipv6_ptr. */
  4875. MLXSW_REG_RATR_IPIP_TYPE_IPV6,
  4876. };
  4877. /* reg_ratr_ipip_type
  4878. * Underlay destination ip type.
  4879. * Note: the type field must match the protocol of the router interface.
  4880. * Access: RW
  4881. */
  4882. MLXSW_ITEM32(reg, ratr, ipip_type, 0x10, 16, 4);
  4883. /* reg_ratr_ipip_ipv4_udip
  4884. * Underlay ipv4 dip.
  4885. * Reserved when ipip_type is IPv6.
  4886. * Access: RW
  4887. */
  4888. MLXSW_ITEM32(reg, ratr, ipip_ipv4_udip, 0x18, 0, 32);
  4889. /* reg_ratr_ipip_ipv6_ptr
  4890. * Pointer to IPv6 underlay destination ip address.
  4891. * For Spectrum: Pointer to KVD linear space.
  4892. * Access: RW
  4893. */
  4894. MLXSW_ITEM32(reg, ratr, ipip_ipv6_ptr, 0x1C, 0, 24);
  4895. enum mlxsw_reg_flow_counter_set_type {
  4896. /* No count */
  4897. MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT = 0x00,
  4898. /* Count packets and bytes */
  4899. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
  4900. /* Count only packets */
  4901. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS = 0x05,
  4902. };
  4903. /* reg_ratr_counter_set_type
  4904. * Counter set type for flow counters
  4905. * Access: RW
  4906. */
  4907. MLXSW_ITEM32(reg, ratr, counter_set_type, 0x28, 24, 8);
  4908. /* reg_ratr_counter_index
  4909. * Counter index for flow counters
  4910. * Access: RW
  4911. */
  4912. MLXSW_ITEM32(reg, ratr, counter_index, 0x28, 0, 24);
  4913. static inline void
  4914. mlxsw_reg_ratr_pack(char *payload,
  4915. enum mlxsw_reg_ratr_op op, bool valid,
  4916. enum mlxsw_reg_ratr_type type,
  4917. u32 adjacency_index, u16 egress_rif)
  4918. {
  4919. MLXSW_REG_ZERO(ratr, payload);
  4920. mlxsw_reg_ratr_op_set(payload, op);
  4921. mlxsw_reg_ratr_v_set(payload, valid);
  4922. mlxsw_reg_ratr_type_set(payload, type);
  4923. mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
  4924. mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
  4925. mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
  4926. }
  4927. static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
  4928. const char *dest_mac)
  4929. {
  4930. mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
  4931. }
  4932. static inline void mlxsw_reg_ratr_ipip4_entry_pack(char *payload, u32 ipv4_udip)
  4933. {
  4934. mlxsw_reg_ratr_ipip_type_set(payload, MLXSW_REG_RATR_IPIP_TYPE_IPV4);
  4935. mlxsw_reg_ratr_ipip_ipv4_udip_set(payload, ipv4_udip);
  4936. }
  4937. static inline void mlxsw_reg_ratr_counter_pack(char *payload, u64 counter_index,
  4938. bool counter_enable)
  4939. {
  4940. enum mlxsw_reg_flow_counter_set_type set_type;
  4941. if (counter_enable)
  4942. set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES;
  4943. else
  4944. set_type = MLXSW_REG_FLOW_COUNTER_SET_TYPE_NO_COUNT;
  4945. mlxsw_reg_ratr_counter_index_set(payload, counter_index);
  4946. mlxsw_reg_ratr_counter_set_type_set(payload, set_type);
  4947. }
  4948. /* RDPM - Router DSCP to Priority Mapping
  4949. * --------------------------------------
  4950. * Controls the mapping from DSCP field to switch priority on routed packets
  4951. */
  4952. #define MLXSW_REG_RDPM_ID 0x8009
  4953. #define MLXSW_REG_RDPM_BASE_LEN 0x00
  4954. #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN 0x01
  4955. #define MLXSW_REG_RDPM_DSCP_ENTRY_REC_MAX_COUNT 64
  4956. #define MLXSW_REG_RDPM_LEN 0x40
  4957. #define MLXSW_REG_RDPM_LAST_ENTRY (MLXSW_REG_RDPM_BASE_LEN + \
  4958. MLXSW_REG_RDPM_LEN - \
  4959. MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN)
  4960. MLXSW_REG_DEFINE(rdpm, MLXSW_REG_RDPM_ID, MLXSW_REG_RDPM_LEN);
  4961. /* reg_dscp_entry_e
  4962. * Enable update of the specific entry
  4963. * Access: Index
  4964. */
  4965. MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_e, MLXSW_REG_RDPM_LAST_ENTRY, 7, 1,
  4966. -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  4967. /* reg_dscp_entry_prio
  4968. * Switch Priority
  4969. * Access: RW
  4970. */
  4971. MLXSW_ITEM8_INDEXED(reg, rdpm, dscp_entry_prio, MLXSW_REG_RDPM_LAST_ENTRY, 0, 4,
  4972. -MLXSW_REG_RDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
  4973. static inline void mlxsw_reg_rdpm_pack(char *payload, unsigned short index,
  4974. u8 prio)
  4975. {
  4976. mlxsw_reg_rdpm_dscp_entry_e_set(payload, index, 1);
  4977. mlxsw_reg_rdpm_dscp_entry_prio_set(payload, index, prio);
  4978. }
  4979. /* RICNT - Router Interface Counter Register
  4980. * -----------------------------------------
  4981. * The RICNT register retrieves per port performance counters
  4982. */
  4983. #define MLXSW_REG_RICNT_ID 0x800B
  4984. #define MLXSW_REG_RICNT_LEN 0x100
  4985. MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
  4986. /* reg_ricnt_counter_index
  4987. * Counter index
  4988. * Access: RW
  4989. */
  4990. MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
  4991. enum mlxsw_reg_ricnt_counter_set_type {
  4992. /* No Count. */
  4993. MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
  4994. /* Basic. Used for router interfaces, counting the following:
  4995. * - Error and Discard counters.
  4996. * - Unicast, Multicast and Broadcast counters. Sharing the
  4997. * same set of counters for the different type of traffic
  4998. * (IPv4, IPv6 and mpls).
  4999. */
  5000. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
  5001. };
  5002. /* reg_ricnt_counter_set_type
  5003. * Counter Set Type for router interface counter
  5004. * Access: RW
  5005. */
  5006. MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
  5007. enum mlxsw_reg_ricnt_opcode {
  5008. /* Nop. Supported only for read access*/
  5009. MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
  5010. /* Clear. Setting the clr bit will reset the counter value for
  5011. * all counters of the specified Router Interface.
  5012. */
  5013. MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
  5014. };
  5015. /* reg_ricnt_opcode
  5016. * Opcode
  5017. * Access: RW
  5018. */
  5019. MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
  5020. /* reg_ricnt_good_unicast_packets
  5021. * good unicast packets.
  5022. * Access: RW
  5023. */
  5024. MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
  5025. /* reg_ricnt_good_multicast_packets
  5026. * good multicast packets.
  5027. * Access: RW
  5028. */
  5029. MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
  5030. /* reg_ricnt_good_broadcast_packets
  5031. * good broadcast packets
  5032. * Access: RW
  5033. */
  5034. MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
  5035. /* reg_ricnt_good_unicast_bytes
  5036. * A count of L3 data and padding octets not including L2 headers
  5037. * for good unicast frames.
  5038. * Access: RW
  5039. */
  5040. MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
  5041. /* reg_ricnt_good_multicast_bytes
  5042. * A count of L3 data and padding octets not including L2 headers
  5043. * for good multicast frames.
  5044. * Access: RW
  5045. */
  5046. MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
  5047. /* reg_ritr_good_broadcast_bytes
  5048. * A count of L3 data and padding octets not including L2 headers
  5049. * for good broadcast frames.
  5050. * Access: RW
  5051. */
  5052. MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
  5053. /* reg_ricnt_error_packets
  5054. * A count of errored frames that do not pass the router checks.
  5055. * Access: RW
  5056. */
  5057. MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
  5058. /* reg_ricnt_discrad_packets
  5059. * A count of non-errored frames that do not pass the router checks.
  5060. * Access: RW
  5061. */
  5062. MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
  5063. /* reg_ricnt_error_bytes
  5064. * A count of L3 data and padding octets not including L2 headers
  5065. * for errored frames.
  5066. * Access: RW
  5067. */
  5068. MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
  5069. /* reg_ricnt_discard_bytes
  5070. * A count of L3 data and padding octets not including L2 headers
  5071. * for non-errored frames that do not pass the router checks.
  5072. * Access: RW
  5073. */
  5074. MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
  5075. static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
  5076. enum mlxsw_reg_ricnt_opcode op)
  5077. {
  5078. MLXSW_REG_ZERO(ricnt, payload);
  5079. mlxsw_reg_ricnt_op_set(payload, op);
  5080. mlxsw_reg_ricnt_counter_index_set(payload, index);
  5081. mlxsw_reg_ricnt_counter_set_type_set(payload,
  5082. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
  5083. }
  5084. /* RRCR - Router Rules Copy Register Layout
  5085. * ----------------------------------------
  5086. * This register is used for moving and copying route entry rules.
  5087. */
  5088. #define MLXSW_REG_RRCR_ID 0x800F
  5089. #define MLXSW_REG_RRCR_LEN 0x24
  5090. MLXSW_REG_DEFINE(rrcr, MLXSW_REG_RRCR_ID, MLXSW_REG_RRCR_LEN);
  5091. enum mlxsw_reg_rrcr_op {
  5092. /* Move rules */
  5093. MLXSW_REG_RRCR_OP_MOVE,
  5094. /* Copy rules */
  5095. MLXSW_REG_RRCR_OP_COPY,
  5096. };
  5097. /* reg_rrcr_op
  5098. * Access: WO
  5099. */
  5100. MLXSW_ITEM32(reg, rrcr, op, 0x00, 28, 4);
  5101. /* reg_rrcr_offset
  5102. * Offset within the region from which to copy/move.
  5103. * Access: Index
  5104. */
  5105. MLXSW_ITEM32(reg, rrcr, offset, 0x00, 0, 16);
  5106. /* reg_rrcr_size
  5107. * The number of rules to copy/move.
  5108. * Access: WO
  5109. */
  5110. MLXSW_ITEM32(reg, rrcr, size, 0x04, 0, 16);
  5111. /* reg_rrcr_table_id
  5112. * Identifier of the table on which to perform the operation. Encoding is the
  5113. * same as in RTAR.key_type
  5114. * Access: Index
  5115. */
  5116. MLXSW_ITEM32(reg, rrcr, table_id, 0x10, 0, 4);
  5117. /* reg_rrcr_dest_offset
  5118. * Offset within the region to which to copy/move
  5119. * Access: Index
  5120. */
  5121. MLXSW_ITEM32(reg, rrcr, dest_offset, 0x20, 0, 16);
  5122. static inline void mlxsw_reg_rrcr_pack(char *payload, enum mlxsw_reg_rrcr_op op,
  5123. u16 offset, u16 size,
  5124. enum mlxsw_reg_rtar_key_type table_id,
  5125. u16 dest_offset)
  5126. {
  5127. MLXSW_REG_ZERO(rrcr, payload);
  5128. mlxsw_reg_rrcr_op_set(payload, op);
  5129. mlxsw_reg_rrcr_offset_set(payload, offset);
  5130. mlxsw_reg_rrcr_size_set(payload, size);
  5131. mlxsw_reg_rrcr_table_id_set(payload, table_id);
  5132. mlxsw_reg_rrcr_dest_offset_set(payload, dest_offset);
  5133. }
  5134. /* RALTA - Router Algorithmic LPM Tree Allocation Register
  5135. * -------------------------------------------------------
  5136. * RALTA is used to allocate the LPM trees of the SHSPM method.
  5137. */
  5138. #define MLXSW_REG_RALTA_ID 0x8010
  5139. #define MLXSW_REG_RALTA_LEN 0x04
  5140. MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
  5141. /* reg_ralta_op
  5142. * opcode (valid for Write, must be 0 on Read)
  5143. * 0 - allocate a tree
  5144. * 1 - deallocate a tree
  5145. * Access: OP
  5146. */
  5147. MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
  5148. enum mlxsw_reg_ralxx_protocol {
  5149. MLXSW_REG_RALXX_PROTOCOL_IPV4,
  5150. MLXSW_REG_RALXX_PROTOCOL_IPV6,
  5151. };
  5152. /* reg_ralta_protocol
  5153. * Protocol.
  5154. * Deallocation opcode: Reserved.
  5155. * Access: RW
  5156. */
  5157. MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
  5158. /* reg_ralta_tree_id
  5159. * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
  5160. * the tree identifier (managed by software).
  5161. * Note that tree_id 0 is allocated for a default-route tree.
  5162. * Access: Index
  5163. */
  5164. MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
  5165. static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
  5166. enum mlxsw_reg_ralxx_protocol protocol,
  5167. u8 tree_id)
  5168. {
  5169. MLXSW_REG_ZERO(ralta, payload);
  5170. mlxsw_reg_ralta_op_set(payload, !alloc);
  5171. mlxsw_reg_ralta_protocol_set(payload, protocol);
  5172. mlxsw_reg_ralta_tree_id_set(payload, tree_id);
  5173. }
  5174. /* RALST - Router Algorithmic LPM Structure Tree Register
  5175. * ------------------------------------------------------
  5176. * RALST is used to set and query the structure of an LPM tree.
  5177. * The structure of the tree must be sorted as a sorted binary tree, while
  5178. * each node is a bin that is tagged as the length of the prefixes the lookup
  5179. * will refer to. Therefore, bin X refers to a set of entries with prefixes
  5180. * of X bits to match with the destination address. The bin 0 indicates
  5181. * the default action, when there is no match of any prefix.
  5182. */
  5183. #define MLXSW_REG_RALST_ID 0x8011
  5184. #define MLXSW_REG_RALST_LEN 0x104
  5185. MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
  5186. /* reg_ralst_root_bin
  5187. * The bin number of the root bin.
  5188. * 0<root_bin=<(length of IP address)
  5189. * For a default-route tree configure 0xff
  5190. * Access: RW
  5191. */
  5192. MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
  5193. /* reg_ralst_tree_id
  5194. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  5195. * Access: Index
  5196. */
  5197. MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
  5198. #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
  5199. #define MLXSW_REG_RALST_BIN_OFFSET 0x04
  5200. #define MLXSW_REG_RALST_BIN_COUNT 128
  5201. /* reg_ralst_left_child_bin
  5202. * Holding the children of the bin according to the stored tree's structure.
  5203. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  5204. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  5205. * Access: RW
  5206. */
  5207. MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
  5208. /* reg_ralst_right_child_bin
  5209. * Holding the children of the bin according to the stored tree's structure.
  5210. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  5211. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  5212. * Access: RW
  5213. */
  5214. MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
  5215. false);
  5216. static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
  5217. {
  5218. MLXSW_REG_ZERO(ralst, payload);
  5219. /* Initialize all bins to have no left or right child */
  5220. memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
  5221. MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
  5222. mlxsw_reg_ralst_root_bin_set(payload, root_bin);
  5223. mlxsw_reg_ralst_tree_id_set(payload, tree_id);
  5224. }
  5225. static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
  5226. u8 left_child_bin,
  5227. u8 right_child_bin)
  5228. {
  5229. int bin_index = bin_number - 1;
  5230. mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
  5231. mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
  5232. right_child_bin);
  5233. }
  5234. /* RALTB - Router Algorithmic LPM Tree Binding Register
  5235. * ----------------------------------------------------
  5236. * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
  5237. */
  5238. #define MLXSW_REG_RALTB_ID 0x8012
  5239. #define MLXSW_REG_RALTB_LEN 0x04
  5240. MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
  5241. /* reg_raltb_virtual_router
  5242. * Virtual Router ID
  5243. * Range is 0..cap_max_virtual_routers-1
  5244. * Access: Index
  5245. */
  5246. MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
  5247. /* reg_raltb_protocol
  5248. * Protocol.
  5249. * Access: Index
  5250. */
  5251. MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
  5252. /* reg_raltb_tree_id
  5253. * Tree to be used for the {virtual_router, protocol}
  5254. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  5255. * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
  5256. * Access: RW
  5257. */
  5258. MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
  5259. static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
  5260. enum mlxsw_reg_ralxx_protocol protocol,
  5261. u8 tree_id)
  5262. {
  5263. MLXSW_REG_ZERO(raltb, payload);
  5264. mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
  5265. mlxsw_reg_raltb_protocol_set(payload, protocol);
  5266. mlxsw_reg_raltb_tree_id_set(payload, tree_id);
  5267. }
  5268. /* RALUE - Router Algorithmic LPM Unicast Entry Register
  5269. * -----------------------------------------------------
  5270. * RALUE is used to configure and query LPM entries that serve
  5271. * the Unicast protocols.
  5272. */
  5273. #define MLXSW_REG_RALUE_ID 0x8013
  5274. #define MLXSW_REG_RALUE_LEN 0x38
  5275. MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
  5276. /* reg_ralue_protocol
  5277. * Protocol.
  5278. * Access: Index
  5279. */
  5280. MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
  5281. enum mlxsw_reg_ralue_op {
  5282. /* Read operation. If entry doesn't exist, the operation fails. */
  5283. MLXSW_REG_RALUE_OP_QUERY_READ = 0,
  5284. /* Clear on read operation. Used to read entry and
  5285. * clear Activity bit.
  5286. */
  5287. MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
  5288. /* Write operation. Used to write a new entry to the table. All RW
  5289. * fields are written for new entry. Activity bit is set
  5290. * for new entries.
  5291. */
  5292. MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
  5293. /* Update operation. Used to update an existing route entry and
  5294. * only update the RW fields that are detailed in the field
  5295. * op_u_mask. If entry doesn't exist, the operation fails.
  5296. */
  5297. MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
  5298. /* Clear activity. The Activity bit (the field a) is cleared
  5299. * for the entry.
  5300. */
  5301. MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
  5302. /* Delete operation. Used to delete an existing entry. If entry
  5303. * doesn't exist, the operation fails.
  5304. */
  5305. MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
  5306. };
  5307. /* reg_ralue_op
  5308. * Operation.
  5309. * Access: OP
  5310. */
  5311. MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
  5312. /* reg_ralue_a
  5313. * Activity. Set for new entries. Set if a packet lookup has hit on the
  5314. * specific entry, only if the entry is a route. To clear the a bit, use
  5315. * "clear activity" op.
  5316. * Enabled by activity_dis in RGCR
  5317. * Access: RO
  5318. */
  5319. MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
  5320. /* reg_ralue_virtual_router
  5321. * Virtual Router ID
  5322. * Range is 0..cap_max_virtual_routers-1
  5323. * Access: Index
  5324. */
  5325. MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
  5326. #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
  5327. #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
  5328. #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
  5329. /* reg_ralue_op_u_mask
  5330. * opcode update mask.
  5331. * On read operation, this field is reserved.
  5332. * This field is valid for update opcode, otherwise - reserved.
  5333. * This field is a bitmask of the fields that should be updated.
  5334. * Access: WO
  5335. */
  5336. MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
  5337. /* reg_ralue_prefix_len
  5338. * Number of bits in the prefix of the LPM route.
  5339. * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
  5340. * two entries in the physical HW table.
  5341. * Access: Index
  5342. */
  5343. MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
  5344. /* reg_ralue_dip*
  5345. * The prefix of the route or of the marker that the object of the LPM
  5346. * is compared with. The most significant bits of the dip are the prefix.
  5347. * The least significant bits must be '0' if the prefix_len is smaller
  5348. * than 128 for IPv6 or smaller than 32 for IPv4.
  5349. * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
  5350. * Access: Index
  5351. */
  5352. MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
  5353. MLXSW_ITEM_BUF(reg, ralue, dip6, 0x0C, 16);
  5354. enum mlxsw_reg_ralue_entry_type {
  5355. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
  5356. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
  5357. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
  5358. };
  5359. /* reg_ralue_entry_type
  5360. * Entry type.
  5361. * Note - for Marker entries, the action_type and action fields are reserved.
  5362. * Access: RW
  5363. */
  5364. MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
  5365. /* reg_ralue_bmp_len
  5366. * The best match prefix length in the case that there is no match for
  5367. * longer prefixes.
  5368. * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
  5369. * Note for any update operation with entry_type modification this
  5370. * field must be set.
  5371. * Access: RW
  5372. */
  5373. MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
  5374. enum mlxsw_reg_ralue_action_type {
  5375. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
  5376. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
  5377. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
  5378. };
  5379. /* reg_ralue_action_type
  5380. * Action Type
  5381. * Indicates how the IP address is connected.
  5382. * It can be connected to a local subnet through local_erif or can be
  5383. * on a remote subnet connected through a next-hop router,
  5384. * or transmitted to the CPU.
  5385. * Reserved when entry_type = MARKER_ENTRY
  5386. * Access: RW
  5387. */
  5388. MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
  5389. enum mlxsw_reg_ralue_trap_action {
  5390. MLXSW_REG_RALUE_TRAP_ACTION_NOP,
  5391. MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
  5392. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
  5393. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
  5394. MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
  5395. };
  5396. /* reg_ralue_trap_action
  5397. * Trap action.
  5398. * For IP2ME action, only NOP and MIRROR are possible.
  5399. * Access: RW
  5400. */
  5401. MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
  5402. /* reg_ralue_trap_id
  5403. * Trap ID to be reported to CPU.
  5404. * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
  5405. * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
  5406. * Access: RW
  5407. */
  5408. MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
  5409. /* reg_ralue_adjacency_index
  5410. * Points to the first entry of the group-based ECMP.
  5411. * Only relevant in case of REMOTE action.
  5412. * Access: RW
  5413. */
  5414. MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
  5415. /* reg_ralue_ecmp_size
  5416. * Amount of sequential entries starting
  5417. * from the adjacency_index (the number of ECMPs).
  5418. * The valid range is 1-64, 512, 1024, 2048 and 4096.
  5419. * Reserved when trap_action is TRAP or DISCARD_ERROR.
  5420. * Only relevant in case of REMOTE action.
  5421. * Access: RW
  5422. */
  5423. MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
  5424. /* reg_ralue_local_erif
  5425. * Egress Router Interface.
  5426. * Only relevant in case of LOCAL action.
  5427. * Access: RW
  5428. */
  5429. MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
  5430. /* reg_ralue_ip2me_v
  5431. * Valid bit for the tunnel_ptr field.
  5432. * If valid = 0 then trap to CPU as IP2ME trap ID.
  5433. * If valid = 1 and the packet format allows NVE or IPinIP tunnel
  5434. * decapsulation then tunnel decapsulation is done.
  5435. * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
  5436. * decapsulation then trap as IP2ME trap ID.
  5437. * Only relevant in case of IP2ME action.
  5438. * Access: RW
  5439. */
  5440. MLXSW_ITEM32(reg, ralue, ip2me_v, 0x24, 31, 1);
  5441. /* reg_ralue_ip2me_tunnel_ptr
  5442. * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
  5443. * For Spectrum, pointer to KVD Linear.
  5444. * Only relevant in case of IP2ME action.
  5445. * Access: RW
  5446. */
  5447. MLXSW_ITEM32(reg, ralue, ip2me_tunnel_ptr, 0x24, 0, 24);
  5448. static inline void mlxsw_reg_ralue_pack(char *payload,
  5449. enum mlxsw_reg_ralxx_protocol protocol,
  5450. enum mlxsw_reg_ralue_op op,
  5451. u16 virtual_router, u8 prefix_len)
  5452. {
  5453. MLXSW_REG_ZERO(ralue, payload);
  5454. mlxsw_reg_ralue_protocol_set(payload, protocol);
  5455. mlxsw_reg_ralue_op_set(payload, op);
  5456. mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
  5457. mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
  5458. mlxsw_reg_ralue_entry_type_set(payload,
  5459. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
  5460. mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
  5461. }
  5462. static inline void mlxsw_reg_ralue_pack4(char *payload,
  5463. enum mlxsw_reg_ralxx_protocol protocol,
  5464. enum mlxsw_reg_ralue_op op,
  5465. u16 virtual_router, u8 prefix_len,
  5466. u32 dip)
  5467. {
  5468. mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
  5469. mlxsw_reg_ralue_dip4_set(payload, dip);
  5470. }
  5471. static inline void mlxsw_reg_ralue_pack6(char *payload,
  5472. enum mlxsw_reg_ralxx_protocol protocol,
  5473. enum mlxsw_reg_ralue_op op,
  5474. u16 virtual_router, u8 prefix_len,
  5475. const void *dip)
  5476. {
  5477. mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
  5478. mlxsw_reg_ralue_dip6_memcpy_to(payload, dip);
  5479. }
  5480. static inline void
  5481. mlxsw_reg_ralue_act_remote_pack(char *payload,
  5482. enum mlxsw_reg_ralue_trap_action trap_action,
  5483. u16 trap_id, u32 adjacency_index, u16 ecmp_size)
  5484. {
  5485. mlxsw_reg_ralue_action_type_set(payload,
  5486. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
  5487. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  5488. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  5489. mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
  5490. mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
  5491. }
  5492. static inline void
  5493. mlxsw_reg_ralue_act_local_pack(char *payload,
  5494. enum mlxsw_reg_ralue_trap_action trap_action,
  5495. u16 trap_id, u16 local_erif)
  5496. {
  5497. mlxsw_reg_ralue_action_type_set(payload,
  5498. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
  5499. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  5500. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  5501. mlxsw_reg_ralue_local_erif_set(payload, local_erif);
  5502. }
  5503. static inline void
  5504. mlxsw_reg_ralue_act_ip2me_pack(char *payload)
  5505. {
  5506. mlxsw_reg_ralue_action_type_set(payload,
  5507. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
  5508. }
  5509. static inline void
  5510. mlxsw_reg_ralue_act_ip2me_tun_pack(char *payload, u32 tunnel_ptr)
  5511. {
  5512. mlxsw_reg_ralue_action_type_set(payload,
  5513. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
  5514. mlxsw_reg_ralue_ip2me_v_set(payload, 1);
  5515. mlxsw_reg_ralue_ip2me_tunnel_ptr_set(payload, tunnel_ptr);
  5516. }
  5517. /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
  5518. * ----------------------------------------------------------
  5519. * The RAUHT register is used to configure and query the Unicast Host table in
  5520. * devices that implement the Algorithmic LPM.
  5521. */
  5522. #define MLXSW_REG_RAUHT_ID 0x8014
  5523. #define MLXSW_REG_RAUHT_LEN 0x74
  5524. MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
  5525. enum mlxsw_reg_rauht_type {
  5526. MLXSW_REG_RAUHT_TYPE_IPV4,
  5527. MLXSW_REG_RAUHT_TYPE_IPV6,
  5528. };
  5529. /* reg_rauht_type
  5530. * Access: Index
  5531. */
  5532. MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
  5533. enum mlxsw_reg_rauht_op {
  5534. MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
  5535. /* Read operation */
  5536. MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
  5537. /* Clear on read operation. Used to read entry and clear
  5538. * activity bit.
  5539. */
  5540. MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
  5541. /* Add. Used to write a new entry to the table. All R/W fields are
  5542. * relevant for new entry. Activity bit is set for new entries.
  5543. */
  5544. MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
  5545. /* Update action. Used to update an existing route entry and
  5546. * only update the following fields:
  5547. * trap_action, trap_id, mac, counter_set_type, counter_index
  5548. */
  5549. MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
  5550. /* Clear activity. A bit is cleared for the entry. */
  5551. MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
  5552. /* Delete entry */
  5553. MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
  5554. /* Delete all host entries on a RIF. In this command, dip
  5555. * field is reserved.
  5556. */
  5557. };
  5558. /* reg_rauht_op
  5559. * Access: OP
  5560. */
  5561. MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
  5562. /* reg_rauht_a
  5563. * Activity. Set for new entries. Set if a packet lookup has hit on
  5564. * the specific entry.
  5565. * To clear the a bit, use "clear activity" op.
  5566. * Enabled by activity_dis in RGCR
  5567. * Access: RO
  5568. */
  5569. MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
  5570. /* reg_rauht_rif
  5571. * Router Interface
  5572. * Access: Index
  5573. */
  5574. MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
  5575. /* reg_rauht_dip*
  5576. * Destination address.
  5577. * Access: Index
  5578. */
  5579. MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
  5580. MLXSW_ITEM_BUF(reg, rauht, dip6, 0x10, 16);
  5581. enum mlxsw_reg_rauht_trap_action {
  5582. MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
  5583. MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
  5584. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
  5585. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
  5586. MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
  5587. };
  5588. /* reg_rauht_trap_action
  5589. * Access: RW
  5590. */
  5591. MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
  5592. enum mlxsw_reg_rauht_trap_id {
  5593. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
  5594. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
  5595. };
  5596. /* reg_rauht_trap_id
  5597. * Trap ID to be reported to CPU.
  5598. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  5599. * For trap_action of NOP, MIRROR and DISCARD_ERROR,
  5600. * trap_id is reserved.
  5601. * Access: RW
  5602. */
  5603. MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
  5604. /* reg_rauht_counter_set_type
  5605. * Counter set type for flow counters
  5606. * Access: RW
  5607. */
  5608. MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
  5609. /* reg_rauht_counter_index
  5610. * Counter index for flow counters
  5611. * Access: RW
  5612. */
  5613. MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
  5614. /* reg_rauht_mac
  5615. * MAC address.
  5616. * Access: RW
  5617. */
  5618. MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
  5619. static inline void mlxsw_reg_rauht_pack(char *payload,
  5620. enum mlxsw_reg_rauht_op op, u16 rif,
  5621. const char *mac)
  5622. {
  5623. MLXSW_REG_ZERO(rauht, payload);
  5624. mlxsw_reg_rauht_op_set(payload, op);
  5625. mlxsw_reg_rauht_rif_set(payload, rif);
  5626. mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
  5627. }
  5628. static inline void mlxsw_reg_rauht_pack4(char *payload,
  5629. enum mlxsw_reg_rauht_op op, u16 rif,
  5630. const char *mac, u32 dip)
  5631. {
  5632. mlxsw_reg_rauht_pack(payload, op, rif, mac);
  5633. mlxsw_reg_rauht_dip4_set(payload, dip);
  5634. }
  5635. static inline void mlxsw_reg_rauht_pack6(char *payload,
  5636. enum mlxsw_reg_rauht_op op, u16 rif,
  5637. const char *mac, const char *dip)
  5638. {
  5639. mlxsw_reg_rauht_pack(payload, op, rif, mac);
  5640. mlxsw_reg_rauht_type_set(payload, MLXSW_REG_RAUHT_TYPE_IPV6);
  5641. mlxsw_reg_rauht_dip6_memcpy_to(payload, dip);
  5642. }
  5643. static inline void mlxsw_reg_rauht_pack_counter(char *payload,
  5644. u64 counter_index)
  5645. {
  5646. mlxsw_reg_rauht_counter_index_set(payload, counter_index);
  5647. mlxsw_reg_rauht_counter_set_type_set(payload,
  5648. MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
  5649. }
  5650. /* RALEU - Router Algorithmic LPM ECMP Update Register
  5651. * ---------------------------------------------------
  5652. * The register enables updating the ECMP section in the action for multiple
  5653. * LPM Unicast entries in a single operation. The update is executed to
  5654. * all entries of a {virtual router, protocol} tuple using the same ECMP group.
  5655. */
  5656. #define MLXSW_REG_RALEU_ID 0x8015
  5657. #define MLXSW_REG_RALEU_LEN 0x28
  5658. MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
  5659. /* reg_raleu_protocol
  5660. * Protocol.
  5661. * Access: Index
  5662. */
  5663. MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
  5664. /* reg_raleu_virtual_router
  5665. * Virtual Router ID
  5666. * Range is 0..cap_max_virtual_routers-1
  5667. * Access: Index
  5668. */
  5669. MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
  5670. /* reg_raleu_adjacency_index
  5671. * Adjacency Index used for matching on the existing entries.
  5672. * Access: Index
  5673. */
  5674. MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
  5675. /* reg_raleu_ecmp_size
  5676. * ECMP Size used for matching on the existing entries.
  5677. * Access: Index
  5678. */
  5679. MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
  5680. /* reg_raleu_new_adjacency_index
  5681. * New Adjacency Index.
  5682. * Access: WO
  5683. */
  5684. MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
  5685. /* reg_raleu_new_ecmp_size
  5686. * New ECMP Size.
  5687. * Access: WO
  5688. */
  5689. MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
  5690. static inline void mlxsw_reg_raleu_pack(char *payload,
  5691. enum mlxsw_reg_ralxx_protocol protocol,
  5692. u16 virtual_router,
  5693. u32 adjacency_index, u16 ecmp_size,
  5694. u32 new_adjacency_index,
  5695. u16 new_ecmp_size)
  5696. {
  5697. MLXSW_REG_ZERO(raleu, payload);
  5698. mlxsw_reg_raleu_protocol_set(payload, protocol);
  5699. mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
  5700. mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
  5701. mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
  5702. mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
  5703. mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
  5704. }
  5705. /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
  5706. * ----------------------------------------------------------------
  5707. * The RAUHTD register allows dumping entries from the Router Unicast Host
  5708. * Table. For a given session an entry is dumped no more than one time. The
  5709. * first RAUHTD access after reset is a new session. A session ends when the
  5710. * num_rec response is smaller than num_rec request or for IPv4 when the
  5711. * num_entries is smaller than 4. The clear activity affect the current session
  5712. * or the last session if a new session has not started.
  5713. */
  5714. #define MLXSW_REG_RAUHTD_ID 0x8018
  5715. #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
  5716. #define MLXSW_REG_RAUHTD_REC_LEN 0x20
  5717. #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
  5718. #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
  5719. MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
  5720. #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
  5721. MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
  5722. #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
  5723. #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
  5724. /* reg_rauhtd_filter_fields
  5725. * if a bit is '0' then the relevant field is ignored and dump is done
  5726. * regardless of the field value
  5727. * Bit0 - filter by activity: entry_a
  5728. * Bit3 - filter by entry rip: entry_rif
  5729. * Access: Index
  5730. */
  5731. MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
  5732. enum mlxsw_reg_rauhtd_op {
  5733. MLXSW_REG_RAUHTD_OP_DUMP,
  5734. MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
  5735. };
  5736. /* reg_rauhtd_op
  5737. * Access: OP
  5738. */
  5739. MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
  5740. /* reg_rauhtd_num_rec
  5741. * At request: number of records requested
  5742. * At response: number of records dumped
  5743. * For IPv4, each record has 4 entries at request and up to 4 entries
  5744. * at response
  5745. * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
  5746. * Access: Index
  5747. */
  5748. MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
  5749. /* reg_rauhtd_entry_a
  5750. * Dump only if activity has value of entry_a
  5751. * Reserved if filter_fields bit0 is '0'
  5752. * Access: Index
  5753. */
  5754. MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
  5755. enum mlxsw_reg_rauhtd_type {
  5756. MLXSW_REG_RAUHTD_TYPE_IPV4,
  5757. MLXSW_REG_RAUHTD_TYPE_IPV6,
  5758. };
  5759. /* reg_rauhtd_type
  5760. * Dump only if record type is:
  5761. * 0 - IPv4
  5762. * 1 - IPv6
  5763. * Access: Index
  5764. */
  5765. MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
  5766. /* reg_rauhtd_entry_rif
  5767. * Dump only if RIF has value of entry_rif
  5768. * Reserved if filter_fields bit3 is '0'
  5769. * Access: Index
  5770. */
  5771. MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
  5772. static inline void mlxsw_reg_rauhtd_pack(char *payload,
  5773. enum mlxsw_reg_rauhtd_type type)
  5774. {
  5775. MLXSW_REG_ZERO(rauhtd, payload);
  5776. mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
  5777. mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
  5778. mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
  5779. mlxsw_reg_rauhtd_entry_a_set(payload, 1);
  5780. mlxsw_reg_rauhtd_type_set(payload, type);
  5781. }
  5782. /* reg_rauhtd_ipv4_rec_num_entries
  5783. * Number of valid entries in this record:
  5784. * 0 - 1 valid entry
  5785. * 1 - 2 valid entries
  5786. * 2 - 3 valid entries
  5787. * 3 - 4 valid entries
  5788. * Access: RO
  5789. */
  5790. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
  5791. MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
  5792. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  5793. /* reg_rauhtd_rec_type
  5794. * Record type.
  5795. * 0 - IPv4
  5796. * 1 - IPv6
  5797. * Access: RO
  5798. */
  5799. MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
  5800. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  5801. #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
  5802. /* reg_rauhtd_ipv4_ent_a
  5803. * Activity. Set for new entries. Set if a packet lookup has hit on the
  5804. * specific entry.
  5805. * Access: RO
  5806. */
  5807. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
  5808. MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  5809. /* reg_rauhtd_ipv4_ent_rif
  5810. * Router interface.
  5811. * Access: RO
  5812. */
  5813. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  5814. 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  5815. /* reg_rauhtd_ipv4_ent_dip
  5816. * Destination IPv4 address.
  5817. * Access: RO
  5818. */
  5819. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  5820. 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
  5821. #define MLXSW_REG_RAUHTD_IPV6_ENT_LEN 0x20
  5822. /* reg_rauhtd_ipv6_ent_a
  5823. * Activity. Set for new entries. Set if a packet lookup has hit on the
  5824. * specific entry.
  5825. * Access: RO
  5826. */
  5827. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
  5828. MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
  5829. /* reg_rauhtd_ipv6_ent_rif
  5830. * Router interface.
  5831. * Access: RO
  5832. */
  5833. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv6_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  5834. 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x00, false);
  5835. /* reg_rauhtd_ipv6_ent_dip
  5836. * Destination IPv6 address.
  5837. * Access: RO
  5838. */
  5839. MLXSW_ITEM_BUF_INDEXED(reg, rauhtd, ipv6_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN,
  5840. 16, MLXSW_REG_RAUHTD_IPV6_ENT_LEN, 0x10);
  5841. static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
  5842. int ent_index, u16 *p_rif,
  5843. u32 *p_dip)
  5844. {
  5845. *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
  5846. *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
  5847. }
  5848. static inline void mlxsw_reg_rauhtd_ent_ipv6_unpack(char *payload,
  5849. int rec_index, u16 *p_rif,
  5850. char *p_dip)
  5851. {
  5852. *p_rif = mlxsw_reg_rauhtd_ipv6_ent_rif_get(payload, rec_index);
  5853. mlxsw_reg_rauhtd_ipv6_ent_dip_memcpy_from(payload, rec_index, p_dip);
  5854. }
  5855. /* RTDP - Routing Tunnel Decap Properties Register
  5856. * -----------------------------------------------
  5857. * The RTDP register is used for configuring the tunnel decap properties of NVE
  5858. * and IPinIP.
  5859. */
  5860. #define MLXSW_REG_RTDP_ID 0x8020
  5861. #define MLXSW_REG_RTDP_LEN 0x44
  5862. MLXSW_REG_DEFINE(rtdp, MLXSW_REG_RTDP_ID, MLXSW_REG_RTDP_LEN);
  5863. enum mlxsw_reg_rtdp_type {
  5864. MLXSW_REG_RTDP_TYPE_NVE,
  5865. MLXSW_REG_RTDP_TYPE_IPIP,
  5866. };
  5867. /* reg_rtdp_type
  5868. * Type of the RTDP entry as per enum mlxsw_reg_rtdp_type.
  5869. * Access: RW
  5870. */
  5871. MLXSW_ITEM32(reg, rtdp, type, 0x00, 28, 4);
  5872. /* reg_rtdp_tunnel_index
  5873. * Index to the Decap entry.
  5874. * For Spectrum, Index to KVD Linear.
  5875. * Access: Index
  5876. */
  5877. MLXSW_ITEM32(reg, rtdp, tunnel_index, 0x00, 0, 24);
  5878. /* IPinIP */
  5879. /* reg_rtdp_ipip_irif
  5880. * Ingress Router Interface for the overlay router
  5881. * Access: RW
  5882. */
  5883. MLXSW_ITEM32(reg, rtdp, ipip_irif, 0x04, 16, 16);
  5884. enum mlxsw_reg_rtdp_ipip_sip_check {
  5885. /* No sip checks. */
  5886. MLXSW_REG_RTDP_IPIP_SIP_CHECK_NO,
  5887. /* Filter packet if underlay is not IPv4 or if underlay SIP does not
  5888. * equal ipv4_usip.
  5889. */
  5890. MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV4,
  5891. /* Filter packet if underlay is not IPv6 or if underlay SIP does not
  5892. * equal ipv6_usip.
  5893. */
  5894. MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6 = 3,
  5895. };
  5896. /* reg_rtdp_ipip_sip_check
  5897. * SIP check to perform. If decapsulation failed due to these configurations
  5898. * then trap_id is IPIP_DECAP_ERROR.
  5899. * Access: RW
  5900. */
  5901. MLXSW_ITEM32(reg, rtdp, ipip_sip_check, 0x04, 0, 3);
  5902. /* If set, allow decapsulation of IPinIP (without GRE). */
  5903. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_IPIP BIT(0)
  5904. /* If set, allow decapsulation of IPinGREinIP without a key. */
  5905. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE BIT(1)
  5906. /* If set, allow decapsulation of IPinGREinIP with a key. */
  5907. #define MLXSW_REG_RTDP_IPIP_TYPE_CHECK_ALLOW_GRE_KEY BIT(2)
  5908. /* reg_rtdp_ipip_type_check
  5909. * Flags as per MLXSW_REG_RTDP_IPIP_TYPE_CHECK_*. If decapsulation failed due to
  5910. * these configurations then trap_id is IPIP_DECAP_ERROR.
  5911. * Access: RW
  5912. */
  5913. MLXSW_ITEM32(reg, rtdp, ipip_type_check, 0x08, 24, 3);
  5914. /* reg_rtdp_ipip_gre_key_check
  5915. * Whether GRE key should be checked. When check is enabled:
  5916. * - A packet received as IPinIP (without GRE) will always pass.
  5917. * - A packet received as IPinGREinIP without a key will not pass the check.
  5918. * - A packet received as IPinGREinIP with a key will pass the check only if the
  5919. * key in the packet is equal to expected_gre_key.
  5920. * If decapsulation failed due to GRE key then trap_id is IPIP_DECAP_ERROR.
  5921. * Access: RW
  5922. */
  5923. MLXSW_ITEM32(reg, rtdp, ipip_gre_key_check, 0x08, 23, 1);
  5924. /* reg_rtdp_ipip_ipv4_usip
  5925. * Underlay IPv4 address for ipv4 source address check.
  5926. * Reserved when sip_check is not '1'.
  5927. * Access: RW
  5928. */
  5929. MLXSW_ITEM32(reg, rtdp, ipip_ipv4_usip, 0x0C, 0, 32);
  5930. /* reg_rtdp_ipip_ipv6_usip_ptr
  5931. * This field is valid when sip_check is "sipv6 check explicitly". This is a
  5932. * pointer to the IPv6 DIP which is configured by RIPS. For Spectrum, the index
  5933. * is to the KVD linear.
  5934. * Reserved when sip_check is not MLXSW_REG_RTDP_IPIP_SIP_CHECK_FILTER_IPV6.
  5935. * Access: RW
  5936. */
  5937. MLXSW_ITEM32(reg, rtdp, ipip_ipv6_usip_ptr, 0x10, 0, 24);
  5938. /* reg_rtdp_ipip_expected_gre_key
  5939. * GRE key for checking.
  5940. * Reserved when gre_key_check is '0'.
  5941. * Access: RW
  5942. */
  5943. MLXSW_ITEM32(reg, rtdp, ipip_expected_gre_key, 0x14, 0, 32);
  5944. static inline void mlxsw_reg_rtdp_pack(char *payload,
  5945. enum mlxsw_reg_rtdp_type type,
  5946. u32 tunnel_index)
  5947. {
  5948. MLXSW_REG_ZERO(rtdp, payload);
  5949. mlxsw_reg_rtdp_type_set(payload, type);
  5950. mlxsw_reg_rtdp_tunnel_index_set(payload, tunnel_index);
  5951. }
  5952. static inline void
  5953. mlxsw_reg_rtdp_ipip4_pack(char *payload, u16 irif,
  5954. enum mlxsw_reg_rtdp_ipip_sip_check sip_check,
  5955. unsigned int type_check, bool gre_key_check,
  5956. u32 ipv4_usip, u32 expected_gre_key)
  5957. {
  5958. mlxsw_reg_rtdp_ipip_irif_set(payload, irif);
  5959. mlxsw_reg_rtdp_ipip_sip_check_set(payload, sip_check);
  5960. mlxsw_reg_rtdp_ipip_type_check_set(payload, type_check);
  5961. mlxsw_reg_rtdp_ipip_gre_key_check_set(payload, gre_key_check);
  5962. mlxsw_reg_rtdp_ipip_ipv4_usip_set(payload, ipv4_usip);
  5963. mlxsw_reg_rtdp_ipip_expected_gre_key_set(payload, expected_gre_key);
  5964. }
  5965. /* RIGR-V2 - Router Interface Group Register Version 2
  5966. * ---------------------------------------------------
  5967. * The RIGR_V2 register is used to add, remove and query egress interface list
  5968. * of a multicast forwarding entry.
  5969. */
  5970. #define MLXSW_REG_RIGR2_ID 0x8023
  5971. #define MLXSW_REG_RIGR2_LEN 0xB0
  5972. #define MLXSW_REG_RIGR2_MAX_ERIFS 32
  5973. MLXSW_REG_DEFINE(rigr2, MLXSW_REG_RIGR2_ID, MLXSW_REG_RIGR2_LEN);
  5974. /* reg_rigr2_rigr_index
  5975. * KVD Linear index.
  5976. * Access: Index
  5977. */
  5978. MLXSW_ITEM32(reg, rigr2, rigr_index, 0x04, 0, 24);
  5979. /* reg_rigr2_vnext
  5980. * Next RIGR Index is valid.
  5981. * Access: RW
  5982. */
  5983. MLXSW_ITEM32(reg, rigr2, vnext, 0x08, 31, 1);
  5984. /* reg_rigr2_next_rigr_index
  5985. * Next RIGR Index. The index is to the KVD linear.
  5986. * Reserved when vnxet = '0'.
  5987. * Access: RW
  5988. */
  5989. MLXSW_ITEM32(reg, rigr2, next_rigr_index, 0x08, 0, 24);
  5990. /* reg_rigr2_vrmid
  5991. * RMID Index is valid.
  5992. * Access: RW
  5993. */
  5994. MLXSW_ITEM32(reg, rigr2, vrmid, 0x20, 31, 1);
  5995. /* reg_rigr2_rmid_index
  5996. * RMID Index.
  5997. * Range 0 .. max_mid - 1
  5998. * Reserved when vrmid = '0'.
  5999. * The index is to the Port Group Table (PGT)
  6000. * Access: RW
  6001. */
  6002. MLXSW_ITEM32(reg, rigr2, rmid_index, 0x20, 0, 16);
  6003. /* reg_rigr2_erif_entry_v
  6004. * Egress Router Interface is valid.
  6005. * Note that low-entries must be set if high-entries are set. For
  6006. * example: if erif_entry[2].v is set then erif_entry[1].v and
  6007. * erif_entry[0].v must be set.
  6008. * Index can be from 0 to cap_mc_erif_list_entries-1
  6009. * Access: RW
  6010. */
  6011. MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_v, 0x24, 31, 1, 4, 0, false);
  6012. /* reg_rigr2_erif_entry_erif
  6013. * Egress Router Interface.
  6014. * Valid range is from 0 to cap_max_router_interfaces - 1
  6015. * Index can be from 0 to MLXSW_REG_RIGR2_MAX_ERIFS - 1
  6016. * Access: RW
  6017. */
  6018. MLXSW_ITEM32_INDEXED(reg, rigr2, erif_entry_erif, 0x24, 0, 16, 4, 0, false);
  6019. static inline void mlxsw_reg_rigr2_pack(char *payload, u32 rigr_index,
  6020. bool vnext, u32 next_rigr_index)
  6021. {
  6022. MLXSW_REG_ZERO(rigr2, payload);
  6023. mlxsw_reg_rigr2_rigr_index_set(payload, rigr_index);
  6024. mlxsw_reg_rigr2_vnext_set(payload, vnext);
  6025. mlxsw_reg_rigr2_next_rigr_index_set(payload, next_rigr_index);
  6026. mlxsw_reg_rigr2_vrmid_set(payload, 0);
  6027. mlxsw_reg_rigr2_rmid_index_set(payload, 0);
  6028. }
  6029. static inline void mlxsw_reg_rigr2_erif_entry_pack(char *payload, int index,
  6030. bool v, u16 erif)
  6031. {
  6032. mlxsw_reg_rigr2_erif_entry_v_set(payload, index, v);
  6033. mlxsw_reg_rigr2_erif_entry_erif_set(payload, index, erif);
  6034. }
  6035. /* RECR-V2 - Router ECMP Configuration Version 2 Register
  6036. * ------------------------------------------------------
  6037. */
  6038. #define MLXSW_REG_RECR2_ID 0x8025
  6039. #define MLXSW_REG_RECR2_LEN 0x38
  6040. MLXSW_REG_DEFINE(recr2, MLXSW_REG_RECR2_ID, MLXSW_REG_RECR2_LEN);
  6041. /* reg_recr2_pp
  6042. * Per-port configuration
  6043. * Access: Index
  6044. */
  6045. MLXSW_ITEM32(reg, recr2, pp, 0x00, 24, 1);
  6046. /* reg_recr2_sh
  6047. * Symmetric hash
  6048. * Access: RW
  6049. */
  6050. MLXSW_ITEM32(reg, recr2, sh, 0x00, 8, 1);
  6051. /* reg_recr2_seed
  6052. * Seed
  6053. * Access: RW
  6054. */
  6055. MLXSW_ITEM32(reg, recr2, seed, 0x08, 0, 32);
  6056. enum {
  6057. /* Enable IPv4 fields if packet is not TCP and not UDP */
  6058. MLXSW_REG_RECR2_IPV4_EN_NOT_TCP_NOT_UDP = 3,
  6059. /* Enable IPv4 fields if packet is TCP or UDP */
  6060. MLXSW_REG_RECR2_IPV4_EN_TCP_UDP = 4,
  6061. /* Enable IPv6 fields if packet is not TCP and not UDP */
  6062. MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP = 5,
  6063. /* Enable IPv6 fields if packet is TCP or UDP */
  6064. MLXSW_REG_RECR2_IPV6_EN_TCP_UDP = 6,
  6065. /* Enable TCP/UDP header fields if packet is IPv4 */
  6066. MLXSW_REG_RECR2_TCP_UDP_EN_IPV4 = 7,
  6067. /* Enable TCP/UDP header fields if packet is IPv6 */
  6068. MLXSW_REG_RECR2_TCP_UDP_EN_IPV6 = 8,
  6069. };
  6070. /* reg_recr2_outer_header_enables
  6071. * Bit mask where each bit enables a specific layer to be included in
  6072. * the hash calculation.
  6073. * Access: RW
  6074. */
  6075. MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_enables, 0x10, 0x04, 1);
  6076. enum {
  6077. /* IPv4 Source IP */
  6078. MLXSW_REG_RECR2_IPV4_SIP0 = 9,
  6079. MLXSW_REG_RECR2_IPV4_SIP3 = 12,
  6080. /* IPv4 Destination IP */
  6081. MLXSW_REG_RECR2_IPV4_DIP0 = 13,
  6082. MLXSW_REG_RECR2_IPV4_DIP3 = 16,
  6083. /* IP Protocol */
  6084. MLXSW_REG_RECR2_IPV4_PROTOCOL = 17,
  6085. /* IPv6 Source IP */
  6086. MLXSW_REG_RECR2_IPV6_SIP0_7 = 21,
  6087. MLXSW_REG_RECR2_IPV6_SIP8 = 29,
  6088. MLXSW_REG_RECR2_IPV6_SIP15 = 36,
  6089. /* IPv6 Destination IP */
  6090. MLXSW_REG_RECR2_IPV6_DIP0_7 = 37,
  6091. MLXSW_REG_RECR2_IPV6_DIP8 = 45,
  6092. MLXSW_REG_RECR2_IPV6_DIP15 = 52,
  6093. /* IPv6 Next Header */
  6094. MLXSW_REG_RECR2_IPV6_NEXT_HEADER = 53,
  6095. /* IPv6 Flow Label */
  6096. MLXSW_REG_RECR2_IPV6_FLOW_LABEL = 57,
  6097. /* TCP/UDP Source Port */
  6098. MLXSW_REG_RECR2_TCP_UDP_SPORT = 74,
  6099. /* TCP/UDP Destination Port */
  6100. MLXSW_REG_RECR2_TCP_UDP_DPORT = 75,
  6101. };
  6102. /* reg_recr2_outer_header_fields_enable
  6103. * Packet fields to enable for ECMP hash subject to outer_header_enable.
  6104. * Access: RW
  6105. */
  6106. MLXSW_ITEM_BIT_ARRAY(reg, recr2, outer_header_fields_enable, 0x14, 0x14, 1);
  6107. static inline void mlxsw_reg_recr2_ipv4_sip_enable(char *payload)
  6108. {
  6109. int i;
  6110. for (i = MLXSW_REG_RECR2_IPV4_SIP0; i <= MLXSW_REG_RECR2_IPV4_SIP3; i++)
  6111. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
  6112. true);
  6113. }
  6114. static inline void mlxsw_reg_recr2_ipv4_dip_enable(char *payload)
  6115. {
  6116. int i;
  6117. for (i = MLXSW_REG_RECR2_IPV4_DIP0; i <= MLXSW_REG_RECR2_IPV4_DIP3; i++)
  6118. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
  6119. true);
  6120. }
  6121. static inline void mlxsw_reg_recr2_ipv6_sip_enable(char *payload)
  6122. {
  6123. int i = MLXSW_REG_RECR2_IPV6_SIP0_7;
  6124. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
  6125. i = MLXSW_REG_RECR2_IPV6_SIP8;
  6126. for (; i <= MLXSW_REG_RECR2_IPV6_SIP15; i++)
  6127. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
  6128. true);
  6129. }
  6130. static inline void mlxsw_reg_recr2_ipv6_dip_enable(char *payload)
  6131. {
  6132. int i = MLXSW_REG_RECR2_IPV6_DIP0_7;
  6133. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i, true);
  6134. i = MLXSW_REG_RECR2_IPV6_DIP8;
  6135. for (; i <= MLXSW_REG_RECR2_IPV6_DIP15; i++)
  6136. mlxsw_reg_recr2_outer_header_fields_enable_set(payload, i,
  6137. true);
  6138. }
  6139. static inline void mlxsw_reg_recr2_pack(char *payload, u32 seed)
  6140. {
  6141. MLXSW_REG_ZERO(recr2, payload);
  6142. mlxsw_reg_recr2_pp_set(payload, false);
  6143. mlxsw_reg_recr2_sh_set(payload, true);
  6144. mlxsw_reg_recr2_seed_set(payload, seed);
  6145. }
  6146. /* RMFT-V2 - Router Multicast Forwarding Table Version 2 Register
  6147. * --------------------------------------------------------------
  6148. * The RMFT_V2 register is used to configure and query the multicast table.
  6149. */
  6150. #define MLXSW_REG_RMFT2_ID 0x8027
  6151. #define MLXSW_REG_RMFT2_LEN 0x174
  6152. MLXSW_REG_DEFINE(rmft2, MLXSW_REG_RMFT2_ID, MLXSW_REG_RMFT2_LEN);
  6153. /* reg_rmft2_v
  6154. * Valid
  6155. * Access: RW
  6156. */
  6157. MLXSW_ITEM32(reg, rmft2, v, 0x00, 31, 1);
  6158. enum mlxsw_reg_rmft2_type {
  6159. MLXSW_REG_RMFT2_TYPE_IPV4,
  6160. MLXSW_REG_RMFT2_TYPE_IPV6
  6161. };
  6162. /* reg_rmft2_type
  6163. * Access: Index
  6164. */
  6165. MLXSW_ITEM32(reg, rmft2, type, 0x00, 28, 2);
  6166. enum mlxsw_sp_reg_rmft2_op {
  6167. /* For Write:
  6168. * Write operation. Used to write a new entry to the table. All RW
  6169. * fields are relevant for new entry. Activity bit is set for new
  6170. * entries - Note write with v (Valid) 0 will delete the entry.
  6171. * For Query:
  6172. * Read operation
  6173. */
  6174. MLXSW_REG_RMFT2_OP_READ_WRITE,
  6175. };
  6176. /* reg_rmft2_op
  6177. * Operation.
  6178. * Access: OP
  6179. */
  6180. MLXSW_ITEM32(reg, rmft2, op, 0x00, 20, 2);
  6181. /* reg_rmft2_a
  6182. * Activity. Set for new entries. Set if a packet lookup has hit on the specific
  6183. * entry.
  6184. * Access: RO
  6185. */
  6186. MLXSW_ITEM32(reg, rmft2, a, 0x00, 16, 1);
  6187. /* reg_rmft2_offset
  6188. * Offset within the multicast forwarding table to write to.
  6189. * Access: Index
  6190. */
  6191. MLXSW_ITEM32(reg, rmft2, offset, 0x00, 0, 16);
  6192. /* reg_rmft2_virtual_router
  6193. * Virtual Router ID. Range from 0..cap_max_virtual_routers-1
  6194. * Access: RW
  6195. */
  6196. MLXSW_ITEM32(reg, rmft2, virtual_router, 0x04, 0, 16);
  6197. enum mlxsw_reg_rmft2_irif_mask {
  6198. MLXSW_REG_RMFT2_IRIF_MASK_IGNORE,
  6199. MLXSW_REG_RMFT2_IRIF_MASK_COMPARE
  6200. };
  6201. /* reg_rmft2_irif_mask
  6202. * Ingress RIF mask.
  6203. * Access: RW
  6204. */
  6205. MLXSW_ITEM32(reg, rmft2, irif_mask, 0x08, 24, 1);
  6206. /* reg_rmft2_irif
  6207. * Ingress RIF index.
  6208. * Access: RW
  6209. */
  6210. MLXSW_ITEM32(reg, rmft2, irif, 0x08, 0, 16);
  6211. /* reg_rmft2_dip{4,6}
  6212. * Destination IPv4/6 address
  6213. * Access: RW
  6214. */
  6215. MLXSW_ITEM_BUF(reg, rmft2, dip6, 0x10, 16);
  6216. MLXSW_ITEM32(reg, rmft2, dip4, 0x1C, 0, 32);
  6217. /* reg_rmft2_dip{4,6}_mask
  6218. * A bit that is set directs the TCAM to compare the corresponding bit in key. A
  6219. * bit that is clear directs the TCAM to ignore the corresponding bit in key.
  6220. * Access: RW
  6221. */
  6222. MLXSW_ITEM_BUF(reg, rmft2, dip6_mask, 0x20, 16);
  6223. MLXSW_ITEM32(reg, rmft2, dip4_mask, 0x2C, 0, 32);
  6224. /* reg_rmft2_sip{4,6}
  6225. * Source IPv4/6 address
  6226. * Access: RW
  6227. */
  6228. MLXSW_ITEM_BUF(reg, rmft2, sip6, 0x30, 16);
  6229. MLXSW_ITEM32(reg, rmft2, sip4, 0x3C, 0, 32);
  6230. /* reg_rmft2_sip{4,6}_mask
  6231. * A bit that is set directs the TCAM to compare the corresponding bit in key. A
  6232. * bit that is clear directs the TCAM to ignore the corresponding bit in key.
  6233. * Access: RW
  6234. */
  6235. MLXSW_ITEM_BUF(reg, rmft2, sip6_mask, 0x40, 16);
  6236. MLXSW_ITEM32(reg, rmft2, sip4_mask, 0x4C, 0, 32);
  6237. /* reg_rmft2_flexible_action_set
  6238. * ACL action set. The only supported action types in this field and in any
  6239. * action-set pointed from here are as follows:
  6240. * 00h: ACTION_NULL
  6241. * 01h: ACTION_MAC_TTL, only TTL configuration is supported.
  6242. * 03h: ACTION_TRAP
  6243. * 06h: ACTION_QOS
  6244. * 08h: ACTION_POLICING_MONITORING
  6245. * 10h: ACTION_ROUTER_MC
  6246. * Access: RW
  6247. */
  6248. MLXSW_ITEM_BUF(reg, rmft2, flexible_action_set, 0x80,
  6249. MLXSW_REG_FLEX_ACTION_SET_LEN);
  6250. static inline void
  6251. mlxsw_reg_rmft2_common_pack(char *payload, bool v, u16 offset,
  6252. u16 virtual_router,
  6253. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  6254. const char *flex_action_set)
  6255. {
  6256. MLXSW_REG_ZERO(rmft2, payload);
  6257. mlxsw_reg_rmft2_v_set(payload, v);
  6258. mlxsw_reg_rmft2_op_set(payload, MLXSW_REG_RMFT2_OP_READ_WRITE);
  6259. mlxsw_reg_rmft2_offset_set(payload, offset);
  6260. mlxsw_reg_rmft2_virtual_router_set(payload, virtual_router);
  6261. mlxsw_reg_rmft2_irif_mask_set(payload, irif_mask);
  6262. mlxsw_reg_rmft2_irif_set(payload, irif);
  6263. if (flex_action_set)
  6264. mlxsw_reg_rmft2_flexible_action_set_memcpy_to(payload,
  6265. flex_action_set);
  6266. }
  6267. static inline void
  6268. mlxsw_reg_rmft2_ipv4_pack(char *payload, bool v, u16 offset, u16 virtual_router,
  6269. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  6270. u32 dip4, u32 dip4_mask, u32 sip4, u32 sip4_mask,
  6271. const char *flexible_action_set)
  6272. {
  6273. mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
  6274. irif_mask, irif, flexible_action_set);
  6275. mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV4);
  6276. mlxsw_reg_rmft2_dip4_set(payload, dip4);
  6277. mlxsw_reg_rmft2_dip4_mask_set(payload, dip4_mask);
  6278. mlxsw_reg_rmft2_sip4_set(payload, sip4);
  6279. mlxsw_reg_rmft2_sip4_mask_set(payload, sip4_mask);
  6280. }
  6281. static inline void
  6282. mlxsw_reg_rmft2_ipv6_pack(char *payload, bool v, u16 offset, u16 virtual_router,
  6283. enum mlxsw_reg_rmft2_irif_mask irif_mask, u16 irif,
  6284. struct in6_addr dip6, struct in6_addr dip6_mask,
  6285. struct in6_addr sip6, struct in6_addr sip6_mask,
  6286. const char *flexible_action_set)
  6287. {
  6288. mlxsw_reg_rmft2_common_pack(payload, v, offset, virtual_router,
  6289. irif_mask, irif, flexible_action_set);
  6290. mlxsw_reg_rmft2_type_set(payload, MLXSW_REG_RMFT2_TYPE_IPV6);
  6291. mlxsw_reg_rmft2_dip6_memcpy_to(payload, (void *)&dip6);
  6292. mlxsw_reg_rmft2_dip6_mask_memcpy_to(payload, (void *)&dip6_mask);
  6293. mlxsw_reg_rmft2_sip6_memcpy_to(payload, (void *)&sip6);
  6294. mlxsw_reg_rmft2_sip6_mask_memcpy_to(payload, (void *)&sip6_mask);
  6295. }
  6296. /* MFCR - Management Fan Control Register
  6297. * --------------------------------------
  6298. * This register controls the settings of the Fan Speed PWM mechanism.
  6299. */
  6300. #define MLXSW_REG_MFCR_ID 0x9001
  6301. #define MLXSW_REG_MFCR_LEN 0x08
  6302. MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
  6303. enum mlxsw_reg_mfcr_pwm_frequency {
  6304. MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
  6305. MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
  6306. MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
  6307. MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
  6308. MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
  6309. MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
  6310. MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
  6311. MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
  6312. };
  6313. /* reg_mfcr_pwm_frequency
  6314. * Controls the frequency of the PWM signal.
  6315. * Access: RW
  6316. */
  6317. MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
  6318. #define MLXSW_MFCR_TACHOS_MAX 10
  6319. /* reg_mfcr_tacho_active
  6320. * Indicates which of the tachometer is active (bit per tachometer).
  6321. * Access: RO
  6322. */
  6323. MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
  6324. #define MLXSW_MFCR_PWMS_MAX 5
  6325. /* reg_mfcr_pwm_active
  6326. * Indicates which of the PWM control is active (bit per PWM).
  6327. * Access: RO
  6328. */
  6329. MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
  6330. static inline void
  6331. mlxsw_reg_mfcr_pack(char *payload,
  6332. enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
  6333. {
  6334. MLXSW_REG_ZERO(mfcr, payload);
  6335. mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
  6336. }
  6337. static inline void
  6338. mlxsw_reg_mfcr_unpack(char *payload,
  6339. enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
  6340. u16 *p_tacho_active, u8 *p_pwm_active)
  6341. {
  6342. *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
  6343. *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
  6344. *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
  6345. }
  6346. /* MFSC - Management Fan Speed Control Register
  6347. * --------------------------------------------
  6348. * This register controls the settings of the Fan Speed PWM mechanism.
  6349. */
  6350. #define MLXSW_REG_MFSC_ID 0x9002
  6351. #define MLXSW_REG_MFSC_LEN 0x08
  6352. MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
  6353. /* reg_mfsc_pwm
  6354. * Fan pwm to control / monitor.
  6355. * Access: Index
  6356. */
  6357. MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
  6358. /* reg_mfsc_pwm_duty_cycle
  6359. * Controls the duty cycle of the PWM. Value range from 0..255 to
  6360. * represent duty cycle of 0%...100%.
  6361. * Access: RW
  6362. */
  6363. MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
  6364. static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
  6365. u8 pwm_duty_cycle)
  6366. {
  6367. MLXSW_REG_ZERO(mfsc, payload);
  6368. mlxsw_reg_mfsc_pwm_set(payload, pwm);
  6369. mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
  6370. }
  6371. /* MFSM - Management Fan Speed Measurement
  6372. * ---------------------------------------
  6373. * This register controls the settings of the Tacho measurements and
  6374. * enables reading the Tachometer measurements.
  6375. */
  6376. #define MLXSW_REG_MFSM_ID 0x9003
  6377. #define MLXSW_REG_MFSM_LEN 0x08
  6378. MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
  6379. /* reg_mfsm_tacho
  6380. * Fan tachometer index.
  6381. * Access: Index
  6382. */
  6383. MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
  6384. /* reg_mfsm_rpm
  6385. * Fan speed (round per minute).
  6386. * Access: RO
  6387. */
  6388. MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
  6389. static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
  6390. {
  6391. MLXSW_REG_ZERO(mfsm, payload);
  6392. mlxsw_reg_mfsm_tacho_set(payload, tacho);
  6393. }
  6394. /* MFSL - Management Fan Speed Limit Register
  6395. * ------------------------------------------
  6396. * The Fan Speed Limit register is used to configure the fan speed
  6397. * event / interrupt notification mechanism. Fan speed threshold are
  6398. * defined for both under-speed and over-speed.
  6399. */
  6400. #define MLXSW_REG_MFSL_ID 0x9004
  6401. #define MLXSW_REG_MFSL_LEN 0x0C
  6402. MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
  6403. /* reg_mfsl_tacho
  6404. * Fan tachometer index.
  6405. * Access: Index
  6406. */
  6407. MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
  6408. /* reg_mfsl_tach_min
  6409. * Tachometer minimum value (minimum RPM).
  6410. * Access: RW
  6411. */
  6412. MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
  6413. /* reg_mfsl_tach_max
  6414. * Tachometer maximum value (maximum RPM).
  6415. * Access: RW
  6416. */
  6417. MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
  6418. static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
  6419. u16 tach_min, u16 tach_max)
  6420. {
  6421. MLXSW_REG_ZERO(mfsl, payload);
  6422. mlxsw_reg_mfsl_tacho_set(payload, tacho);
  6423. mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
  6424. mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
  6425. }
  6426. static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
  6427. u16 *p_tach_min, u16 *p_tach_max)
  6428. {
  6429. if (p_tach_min)
  6430. *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
  6431. if (p_tach_max)
  6432. *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
  6433. }
  6434. /* MTCAP - Management Temperature Capabilities
  6435. * -------------------------------------------
  6436. * This register exposes the capabilities of the device and
  6437. * system temperature sensing.
  6438. */
  6439. #define MLXSW_REG_MTCAP_ID 0x9009
  6440. #define MLXSW_REG_MTCAP_LEN 0x08
  6441. MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
  6442. /* reg_mtcap_sensor_count
  6443. * Number of sensors supported by the device.
  6444. * This includes the QSFP module sensors (if exists in the QSFP module).
  6445. * Access: RO
  6446. */
  6447. MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
  6448. /* MTMP - Management Temperature
  6449. * -----------------------------
  6450. * This register controls the settings of the temperature measurements
  6451. * and enables reading the temperature measurements. Note that temperature
  6452. * is in 0.125 degrees Celsius.
  6453. */
  6454. #define MLXSW_REG_MTMP_ID 0x900A
  6455. #define MLXSW_REG_MTMP_LEN 0x20
  6456. MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
  6457. /* reg_mtmp_sensor_index
  6458. * Sensors index to access.
  6459. * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
  6460. * (module 0 is mapped to sensor_index 64).
  6461. * Access: Index
  6462. */
  6463. MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
  6464. /* Convert to milli degrees Celsius */
  6465. #define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
  6466. /* reg_mtmp_temperature
  6467. * Temperature reading from the sensor. Reading is in 0.125 Celsius
  6468. * degrees units.
  6469. * Access: RO
  6470. */
  6471. MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
  6472. /* reg_mtmp_mte
  6473. * Max Temperature Enable - enables measuring the max temperature on a sensor.
  6474. * Access: RW
  6475. */
  6476. MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
  6477. /* reg_mtmp_mtr
  6478. * Max Temperature Reset - clears the value of the max temperature register.
  6479. * Access: WO
  6480. */
  6481. MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
  6482. /* reg_mtmp_max_temperature
  6483. * The highest measured temperature from the sensor.
  6484. * When the bit mte is cleared, the field max_temperature is reserved.
  6485. * Access: RO
  6486. */
  6487. MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
  6488. /* reg_mtmp_tee
  6489. * Temperature Event Enable.
  6490. * 0 - Do not generate event
  6491. * 1 - Generate event
  6492. * 2 - Generate single event
  6493. * Access: RW
  6494. */
  6495. MLXSW_ITEM32(reg, mtmp, tee, 0x0C, 30, 2);
  6496. #define MLXSW_REG_MTMP_THRESH_HI 0x348 /* 105 Celsius */
  6497. /* reg_mtmp_temperature_threshold_hi
  6498. * High threshold for Temperature Warning Event. In 0.125 Celsius.
  6499. * Access: RW
  6500. */
  6501. MLXSW_ITEM32(reg, mtmp, temperature_threshold_hi, 0x0C, 0, 16);
  6502. /* reg_mtmp_temperature_threshold_lo
  6503. * Low threshold for Temperature Warning Event. In 0.125 Celsius.
  6504. * Access: RW
  6505. */
  6506. MLXSW_ITEM32(reg, mtmp, temperature_threshold_lo, 0x10, 0, 16);
  6507. #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
  6508. /* reg_mtmp_sensor_name
  6509. * Sensor Name
  6510. * Access: RO
  6511. */
  6512. MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
  6513. static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
  6514. bool max_temp_enable,
  6515. bool max_temp_reset)
  6516. {
  6517. MLXSW_REG_ZERO(mtmp, payload);
  6518. mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
  6519. mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
  6520. mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
  6521. mlxsw_reg_mtmp_temperature_threshold_hi_set(payload,
  6522. MLXSW_REG_MTMP_THRESH_HI);
  6523. }
  6524. static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
  6525. unsigned int *p_max_temp,
  6526. char *sensor_name)
  6527. {
  6528. u16 temp;
  6529. if (p_temp) {
  6530. temp = mlxsw_reg_mtmp_temperature_get(payload);
  6531. *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  6532. }
  6533. if (p_max_temp) {
  6534. temp = mlxsw_reg_mtmp_max_temperature_get(payload);
  6535. *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  6536. }
  6537. if (sensor_name)
  6538. mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
  6539. }
  6540. /* MCIA - Management Cable Info Access
  6541. * -----------------------------------
  6542. * MCIA register is used to access the SFP+ and QSFP connector's EPROM.
  6543. */
  6544. #define MLXSW_REG_MCIA_ID 0x9014
  6545. #define MLXSW_REG_MCIA_LEN 0x40
  6546. MLXSW_REG_DEFINE(mcia, MLXSW_REG_MCIA_ID, MLXSW_REG_MCIA_LEN);
  6547. /* reg_mcia_l
  6548. * Lock bit. Setting this bit will lock the access to the specific
  6549. * cable. Used for updating a full page in a cable EPROM. Any access
  6550. * other then subsequence writes will fail while the port is locked.
  6551. * Access: RW
  6552. */
  6553. MLXSW_ITEM32(reg, mcia, l, 0x00, 31, 1);
  6554. /* reg_mcia_module
  6555. * Module number.
  6556. * Access: Index
  6557. */
  6558. MLXSW_ITEM32(reg, mcia, module, 0x00, 16, 8);
  6559. /* reg_mcia_status
  6560. * Module status.
  6561. * Access: RO
  6562. */
  6563. MLXSW_ITEM32(reg, mcia, status, 0x00, 0, 8);
  6564. /* reg_mcia_i2c_device_address
  6565. * I2C device address.
  6566. * Access: RW
  6567. */
  6568. MLXSW_ITEM32(reg, mcia, i2c_device_address, 0x04, 24, 8);
  6569. /* reg_mcia_page_number
  6570. * Page number.
  6571. * Access: RW
  6572. */
  6573. MLXSW_ITEM32(reg, mcia, page_number, 0x04, 16, 8);
  6574. /* reg_mcia_device_address
  6575. * Device address.
  6576. * Access: RW
  6577. */
  6578. MLXSW_ITEM32(reg, mcia, device_address, 0x04, 0, 16);
  6579. /* reg_mcia_size
  6580. * Number of bytes to read/write (up to 48 bytes).
  6581. * Access: RW
  6582. */
  6583. MLXSW_ITEM32(reg, mcia, size, 0x08, 0, 16);
  6584. #define MLXSW_SP_REG_MCIA_EEPROM_SIZE 48
  6585. /* reg_mcia_eeprom
  6586. * Bytes to read/write.
  6587. * Access: RW
  6588. */
  6589. MLXSW_ITEM_BUF(reg, mcia, eeprom, 0x10, MLXSW_SP_REG_MCIA_EEPROM_SIZE);
  6590. static inline void mlxsw_reg_mcia_pack(char *payload, u8 module, u8 lock,
  6591. u8 page_number, u16 device_addr,
  6592. u8 size, u8 i2c_device_addr)
  6593. {
  6594. MLXSW_REG_ZERO(mcia, payload);
  6595. mlxsw_reg_mcia_module_set(payload, module);
  6596. mlxsw_reg_mcia_l_set(payload, lock);
  6597. mlxsw_reg_mcia_page_number_set(payload, page_number);
  6598. mlxsw_reg_mcia_device_address_set(payload, device_addr);
  6599. mlxsw_reg_mcia_size_set(payload, size);
  6600. mlxsw_reg_mcia_i2c_device_address_set(payload, i2c_device_addr);
  6601. }
  6602. /* MPAT - Monitoring Port Analyzer Table
  6603. * -------------------------------------
  6604. * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
  6605. * For an enabled analyzer, all fields except e (enable) cannot be modified.
  6606. */
  6607. #define MLXSW_REG_MPAT_ID 0x901A
  6608. #define MLXSW_REG_MPAT_LEN 0x78
  6609. MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
  6610. /* reg_mpat_pa_id
  6611. * Port Analyzer ID.
  6612. * Access: Index
  6613. */
  6614. MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
  6615. /* reg_mpat_system_port
  6616. * A unique port identifier for the final destination of the packet.
  6617. * Access: RW
  6618. */
  6619. MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
  6620. /* reg_mpat_e
  6621. * Enable. Indicating the Port Analyzer is enabled.
  6622. * Access: RW
  6623. */
  6624. MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
  6625. /* reg_mpat_qos
  6626. * Quality Of Service Mode.
  6627. * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
  6628. * PCP, DEI, DSCP or VL) are configured.
  6629. * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
  6630. * same as in the original packet that has triggered the mirroring. For
  6631. * SPAN also the pcp,dei are maintained.
  6632. * Access: RW
  6633. */
  6634. MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
  6635. /* reg_mpat_be
  6636. * Best effort mode. Indicates mirroring traffic should not cause packet
  6637. * drop or back pressure, but will discard the mirrored packets. Mirrored
  6638. * packets will be forwarded on a best effort manner.
  6639. * 0: Do not discard mirrored packets
  6640. * 1: Discard mirrored packets if causing congestion
  6641. * Access: RW
  6642. */
  6643. MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
  6644. enum mlxsw_reg_mpat_span_type {
  6645. /* Local SPAN Ethernet.
  6646. * The original packet is not encapsulated.
  6647. */
  6648. MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
  6649. /* Remote SPAN Ethernet VLAN.
  6650. * The packet is forwarded to the monitoring port on the monitoring
  6651. * VLAN.
  6652. */
  6653. MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH = 0x1,
  6654. /* Encapsulated Remote SPAN Ethernet L3 GRE.
  6655. * The packet is encapsulated with GRE header.
  6656. */
  6657. MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
  6658. };
  6659. /* reg_mpat_span_type
  6660. * SPAN type.
  6661. * Access: RW
  6662. */
  6663. MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
  6664. /* Remote SPAN - Ethernet VLAN
  6665. * - - - - - - - - - - - - - -
  6666. */
  6667. /* reg_mpat_eth_rspan_vid
  6668. * Encapsulation header VLAN ID.
  6669. * Access: RW
  6670. */
  6671. MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
  6672. /* Encapsulated Remote SPAN - Ethernet L2
  6673. * - - - - - - - - - - - - - - - - - - -
  6674. */
  6675. enum mlxsw_reg_mpat_eth_rspan_version {
  6676. MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
  6677. };
  6678. /* reg_mpat_eth_rspan_version
  6679. * RSPAN mirror header version.
  6680. * Access: RW
  6681. */
  6682. MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
  6683. /* reg_mpat_eth_rspan_mac
  6684. * Destination MAC address.
  6685. * Access: RW
  6686. */
  6687. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
  6688. /* reg_mpat_eth_rspan_tp
  6689. * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
  6690. * Access: RW
  6691. */
  6692. MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
  6693. /* Encapsulated Remote SPAN - Ethernet L3
  6694. * - - - - - - - - - - - - - - - - - - -
  6695. */
  6696. enum mlxsw_reg_mpat_eth_rspan_protocol {
  6697. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
  6698. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
  6699. };
  6700. /* reg_mpat_eth_rspan_protocol
  6701. * SPAN encapsulation protocol.
  6702. * Access: RW
  6703. */
  6704. MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
  6705. /* reg_mpat_eth_rspan_ttl
  6706. * Encapsulation header Time-to-Live/HopLimit.
  6707. * Access: RW
  6708. */
  6709. MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
  6710. /* reg_mpat_eth_rspan_smac
  6711. * Source MAC address
  6712. * Access: RW
  6713. */
  6714. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
  6715. /* reg_mpat_eth_rspan_dip*
  6716. * Destination IP address. The IP version is configured by protocol.
  6717. * Access: RW
  6718. */
  6719. MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
  6720. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
  6721. /* reg_mpat_eth_rspan_sip*
  6722. * Source IP address. The IP version is configured by protocol.
  6723. * Access: RW
  6724. */
  6725. MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
  6726. MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
  6727. static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
  6728. u16 system_port, bool e,
  6729. enum mlxsw_reg_mpat_span_type span_type)
  6730. {
  6731. MLXSW_REG_ZERO(mpat, payload);
  6732. mlxsw_reg_mpat_pa_id_set(payload, pa_id);
  6733. mlxsw_reg_mpat_system_port_set(payload, system_port);
  6734. mlxsw_reg_mpat_e_set(payload, e);
  6735. mlxsw_reg_mpat_qos_set(payload, 1);
  6736. mlxsw_reg_mpat_be_set(payload, 1);
  6737. mlxsw_reg_mpat_span_type_set(payload, span_type);
  6738. }
  6739. static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
  6740. {
  6741. mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
  6742. }
  6743. static inline void
  6744. mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
  6745. enum mlxsw_reg_mpat_eth_rspan_version version,
  6746. const char *mac,
  6747. bool tp)
  6748. {
  6749. mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
  6750. mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
  6751. mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
  6752. }
  6753. static inline void
  6754. mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
  6755. const char *smac,
  6756. u32 sip, u32 dip)
  6757. {
  6758. mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
  6759. mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
  6760. mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
  6761. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
  6762. mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
  6763. mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
  6764. }
  6765. static inline void
  6766. mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
  6767. const char *smac,
  6768. struct in6_addr sip, struct in6_addr dip)
  6769. {
  6770. mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
  6771. mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
  6772. mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
  6773. MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
  6774. mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
  6775. mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
  6776. }
  6777. /* MPAR - Monitoring Port Analyzer Register
  6778. * ----------------------------------------
  6779. * MPAR register is used to query and configure the port analyzer port mirroring
  6780. * properties.
  6781. */
  6782. #define MLXSW_REG_MPAR_ID 0x901B
  6783. #define MLXSW_REG_MPAR_LEN 0x08
  6784. MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
  6785. /* reg_mpar_local_port
  6786. * The local port to mirror the packets from.
  6787. * Access: Index
  6788. */
  6789. MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
  6790. enum mlxsw_reg_mpar_i_e {
  6791. MLXSW_REG_MPAR_TYPE_EGRESS,
  6792. MLXSW_REG_MPAR_TYPE_INGRESS,
  6793. };
  6794. /* reg_mpar_i_e
  6795. * Ingress/Egress
  6796. * Access: Index
  6797. */
  6798. MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
  6799. /* reg_mpar_enable
  6800. * Enable mirroring
  6801. * By default, port mirroring is disabled for all ports.
  6802. * Access: RW
  6803. */
  6804. MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
  6805. /* reg_mpar_pa_id
  6806. * Port Analyzer ID.
  6807. * Access: RW
  6808. */
  6809. MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
  6810. static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
  6811. enum mlxsw_reg_mpar_i_e i_e,
  6812. bool enable, u8 pa_id)
  6813. {
  6814. MLXSW_REG_ZERO(mpar, payload);
  6815. mlxsw_reg_mpar_local_port_set(payload, local_port);
  6816. mlxsw_reg_mpar_enable_set(payload, enable);
  6817. mlxsw_reg_mpar_i_e_set(payload, i_e);
  6818. mlxsw_reg_mpar_pa_id_set(payload, pa_id);
  6819. }
  6820. /* MRSR - Management Reset and Shutdown Register
  6821. * ---------------------------------------------
  6822. * MRSR register is used to reset or shutdown the switch or
  6823. * the entire system (when applicable).
  6824. */
  6825. #define MLXSW_REG_MRSR_ID 0x9023
  6826. #define MLXSW_REG_MRSR_LEN 0x08
  6827. MLXSW_REG_DEFINE(mrsr, MLXSW_REG_MRSR_ID, MLXSW_REG_MRSR_LEN);
  6828. /* reg_mrsr_command
  6829. * Reset/shutdown command
  6830. * 0 - do nothing
  6831. * 1 - software reset
  6832. * Access: WO
  6833. */
  6834. MLXSW_ITEM32(reg, mrsr, command, 0x00, 0, 4);
  6835. static inline void mlxsw_reg_mrsr_pack(char *payload)
  6836. {
  6837. MLXSW_REG_ZERO(mrsr, payload);
  6838. mlxsw_reg_mrsr_command_set(payload, 1);
  6839. }
  6840. /* MLCR - Management LED Control Register
  6841. * --------------------------------------
  6842. * Controls the system LEDs.
  6843. */
  6844. #define MLXSW_REG_MLCR_ID 0x902B
  6845. #define MLXSW_REG_MLCR_LEN 0x0C
  6846. MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
  6847. /* reg_mlcr_local_port
  6848. * Local port number.
  6849. * Access: RW
  6850. */
  6851. MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
  6852. #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
  6853. /* reg_mlcr_beacon_duration
  6854. * Duration of the beacon to be active, in seconds.
  6855. * 0x0 - Will turn off the beacon.
  6856. * 0xFFFF - Will turn on the beacon until explicitly turned off.
  6857. * Access: RW
  6858. */
  6859. MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
  6860. /* reg_mlcr_beacon_remain
  6861. * Remaining duration of the beacon, in seconds.
  6862. * 0xFFFF indicates an infinite amount of time.
  6863. * Access: RO
  6864. */
  6865. MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
  6866. static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
  6867. bool active)
  6868. {
  6869. MLXSW_REG_ZERO(mlcr, payload);
  6870. mlxsw_reg_mlcr_local_port_set(payload, local_port);
  6871. mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
  6872. MLXSW_REG_MLCR_DURATION_MAX : 0);
  6873. }
  6874. /* MCQI - Management Component Query Information
  6875. * ---------------------------------------------
  6876. * This register allows querying information about firmware components.
  6877. */
  6878. #define MLXSW_REG_MCQI_ID 0x9061
  6879. #define MLXSW_REG_MCQI_BASE_LEN 0x18
  6880. #define MLXSW_REG_MCQI_CAP_LEN 0x14
  6881. #define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
  6882. MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
  6883. /* reg_mcqi_component_index
  6884. * Index of the accessed component.
  6885. * Access: Index
  6886. */
  6887. MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
  6888. enum mlxfw_reg_mcqi_info_type {
  6889. MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
  6890. };
  6891. /* reg_mcqi_info_type
  6892. * Component properties set.
  6893. * Access: RW
  6894. */
  6895. MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
  6896. /* reg_mcqi_offset
  6897. * The requested/returned data offset from the section start, given in bytes.
  6898. * Must be DWORD aligned.
  6899. * Access: RW
  6900. */
  6901. MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
  6902. /* reg_mcqi_data_size
  6903. * The requested/returned data size, given in bytes. If data_size is not DWORD
  6904. * aligned, the last bytes are zero padded.
  6905. * Access: RW
  6906. */
  6907. MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
  6908. /* reg_mcqi_cap_max_component_size
  6909. * Maximum size for this component, given in bytes.
  6910. * Access: RO
  6911. */
  6912. MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
  6913. /* reg_mcqi_cap_log_mcda_word_size
  6914. * Log 2 of the access word size in bytes. Read and write access must be aligned
  6915. * to the word size. Write access must be done for an integer number of words.
  6916. * Access: RO
  6917. */
  6918. MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
  6919. /* reg_mcqi_cap_mcda_max_write_size
  6920. * Maximal write size for MCDA register
  6921. * Access: RO
  6922. */
  6923. MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
  6924. static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
  6925. {
  6926. MLXSW_REG_ZERO(mcqi, payload);
  6927. mlxsw_reg_mcqi_component_index_set(payload, component_index);
  6928. mlxsw_reg_mcqi_info_type_set(payload,
  6929. MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
  6930. mlxsw_reg_mcqi_offset_set(payload, 0);
  6931. mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
  6932. }
  6933. static inline void mlxsw_reg_mcqi_unpack(char *payload,
  6934. u32 *p_cap_max_component_size,
  6935. u8 *p_cap_log_mcda_word_size,
  6936. u16 *p_cap_mcda_max_write_size)
  6937. {
  6938. *p_cap_max_component_size =
  6939. mlxsw_reg_mcqi_cap_max_component_size_get(payload);
  6940. *p_cap_log_mcda_word_size =
  6941. mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
  6942. *p_cap_mcda_max_write_size =
  6943. mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
  6944. }
  6945. /* MCC - Management Component Control
  6946. * ----------------------------------
  6947. * Controls the firmware component and updates the FSM.
  6948. */
  6949. #define MLXSW_REG_MCC_ID 0x9062
  6950. #define MLXSW_REG_MCC_LEN 0x1C
  6951. MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
  6952. enum mlxsw_reg_mcc_instruction {
  6953. MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
  6954. MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
  6955. MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
  6956. MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
  6957. MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
  6958. MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
  6959. };
  6960. /* reg_mcc_instruction
  6961. * Command to be executed by the FSM.
  6962. * Applicable for write operation only.
  6963. * Access: RW
  6964. */
  6965. MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
  6966. /* reg_mcc_component_index
  6967. * Index of the accessed component. Applicable only for commands that
  6968. * refer to components. Otherwise, this field is reserved.
  6969. * Access: Index
  6970. */
  6971. MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
  6972. /* reg_mcc_update_handle
  6973. * Token representing the current flow executed by the FSM.
  6974. * Access: WO
  6975. */
  6976. MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
  6977. /* reg_mcc_error_code
  6978. * Indicates the successful completion of the instruction, or the reason it
  6979. * failed
  6980. * Access: RO
  6981. */
  6982. MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
  6983. /* reg_mcc_control_state
  6984. * Current FSM state
  6985. * Access: RO
  6986. */
  6987. MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
  6988. /* reg_mcc_component_size
  6989. * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
  6990. * the size may shorten the update time. Value 0x0 means that size is
  6991. * unspecified.
  6992. * Access: WO
  6993. */
  6994. MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
  6995. static inline void mlxsw_reg_mcc_pack(char *payload,
  6996. enum mlxsw_reg_mcc_instruction instr,
  6997. u16 component_index, u32 update_handle,
  6998. u32 component_size)
  6999. {
  7000. MLXSW_REG_ZERO(mcc, payload);
  7001. mlxsw_reg_mcc_instruction_set(payload, instr);
  7002. mlxsw_reg_mcc_component_index_set(payload, component_index);
  7003. mlxsw_reg_mcc_update_handle_set(payload, update_handle);
  7004. mlxsw_reg_mcc_component_size_set(payload, component_size);
  7005. }
  7006. static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
  7007. u8 *p_error_code, u8 *p_control_state)
  7008. {
  7009. if (p_update_handle)
  7010. *p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
  7011. if (p_error_code)
  7012. *p_error_code = mlxsw_reg_mcc_error_code_get(payload);
  7013. if (p_control_state)
  7014. *p_control_state = mlxsw_reg_mcc_control_state_get(payload);
  7015. }
  7016. /* MCDA - Management Component Data Access
  7017. * ---------------------------------------
  7018. * This register allows reading and writing a firmware component.
  7019. */
  7020. #define MLXSW_REG_MCDA_ID 0x9063
  7021. #define MLXSW_REG_MCDA_BASE_LEN 0x10
  7022. #define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
  7023. #define MLXSW_REG_MCDA_LEN \
  7024. (MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
  7025. MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
  7026. /* reg_mcda_update_handle
  7027. * Token representing the current flow executed by the FSM.
  7028. * Access: RW
  7029. */
  7030. MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
  7031. /* reg_mcda_offset
  7032. * Offset of accessed address relative to component start. Accesses must be in
  7033. * accordance to log_mcda_word_size in MCQI reg.
  7034. * Access: RW
  7035. */
  7036. MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
  7037. /* reg_mcda_size
  7038. * Size of the data accessed, given in bytes.
  7039. * Access: RW
  7040. */
  7041. MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
  7042. /* reg_mcda_data
  7043. * Data block accessed.
  7044. * Access: RW
  7045. */
  7046. MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
  7047. static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
  7048. u32 offset, u16 size, u8 *data)
  7049. {
  7050. int i;
  7051. MLXSW_REG_ZERO(mcda, payload);
  7052. mlxsw_reg_mcda_update_handle_set(payload, update_handle);
  7053. mlxsw_reg_mcda_offset_set(payload, offset);
  7054. mlxsw_reg_mcda_size_set(payload, size);
  7055. for (i = 0; i < size / 4; i++)
  7056. mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
  7057. }
  7058. /* MPSC - Monitoring Packet Sampling Configuration Register
  7059. * --------------------------------------------------------
  7060. * MPSC Register is used to configure the Packet Sampling mechanism.
  7061. */
  7062. #define MLXSW_REG_MPSC_ID 0x9080
  7063. #define MLXSW_REG_MPSC_LEN 0x1C
  7064. MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
  7065. /* reg_mpsc_local_port
  7066. * Local port number
  7067. * Not supported for CPU port
  7068. * Access: Index
  7069. */
  7070. MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
  7071. /* reg_mpsc_e
  7072. * Enable sampling on port local_port
  7073. * Access: RW
  7074. */
  7075. MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
  7076. #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
  7077. /* reg_mpsc_rate
  7078. * Sampling rate = 1 out of rate packets (with randomization around
  7079. * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
  7080. * Access: RW
  7081. */
  7082. MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
  7083. static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
  7084. u32 rate)
  7085. {
  7086. MLXSW_REG_ZERO(mpsc, payload);
  7087. mlxsw_reg_mpsc_local_port_set(payload, local_port);
  7088. mlxsw_reg_mpsc_e_set(payload, e);
  7089. mlxsw_reg_mpsc_rate_set(payload, rate);
  7090. }
  7091. /* MGPC - Monitoring General Purpose Counter Set Register
  7092. * The MGPC register retrieves and sets the General Purpose Counter Set.
  7093. */
  7094. #define MLXSW_REG_MGPC_ID 0x9081
  7095. #define MLXSW_REG_MGPC_LEN 0x18
  7096. MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
  7097. /* reg_mgpc_counter_set_type
  7098. * Counter set type.
  7099. * Access: OP
  7100. */
  7101. MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
  7102. /* reg_mgpc_counter_index
  7103. * Counter index.
  7104. * Access: Index
  7105. */
  7106. MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
  7107. enum mlxsw_reg_mgpc_opcode {
  7108. /* Nop */
  7109. MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
  7110. /* Clear counters */
  7111. MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
  7112. };
  7113. /* reg_mgpc_opcode
  7114. * Opcode.
  7115. * Access: OP
  7116. */
  7117. MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
  7118. /* reg_mgpc_byte_counter
  7119. * Byte counter value.
  7120. * Access: RW
  7121. */
  7122. MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
  7123. /* reg_mgpc_packet_counter
  7124. * Packet counter value.
  7125. * Access: RW
  7126. */
  7127. MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
  7128. static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
  7129. enum mlxsw_reg_mgpc_opcode opcode,
  7130. enum mlxsw_reg_flow_counter_set_type set_type)
  7131. {
  7132. MLXSW_REG_ZERO(mgpc, payload);
  7133. mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
  7134. mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
  7135. mlxsw_reg_mgpc_opcode_set(payload, opcode);
  7136. }
  7137. /* TIGCR - Tunneling IPinIP General Configuration Register
  7138. * -------------------------------------------------------
  7139. * The TIGCR register is used for setting up the IPinIP Tunnel configuration.
  7140. */
  7141. #define MLXSW_REG_TIGCR_ID 0xA801
  7142. #define MLXSW_REG_TIGCR_LEN 0x10
  7143. MLXSW_REG_DEFINE(tigcr, MLXSW_REG_TIGCR_ID, MLXSW_REG_TIGCR_LEN);
  7144. /* reg_tigcr_ipip_ttlc
  7145. * For IPinIP Tunnel encapsulation: whether to copy the ttl from the packet
  7146. * header.
  7147. * Access: RW
  7148. */
  7149. MLXSW_ITEM32(reg, tigcr, ttlc, 0x04, 8, 1);
  7150. /* reg_tigcr_ipip_ttl_uc
  7151. * The TTL for IPinIP Tunnel encapsulation of unicast packets if
  7152. * reg_tigcr_ipip_ttlc is unset.
  7153. * Access: RW
  7154. */
  7155. MLXSW_ITEM32(reg, tigcr, ttl_uc, 0x04, 0, 8);
  7156. static inline void mlxsw_reg_tigcr_pack(char *payload, bool ttlc, u8 ttl_uc)
  7157. {
  7158. MLXSW_REG_ZERO(tigcr, payload);
  7159. mlxsw_reg_tigcr_ttlc_set(payload, ttlc);
  7160. mlxsw_reg_tigcr_ttl_uc_set(payload, ttl_uc);
  7161. }
  7162. /* SBPR - Shared Buffer Pools Register
  7163. * -----------------------------------
  7164. * The SBPR configures and retrieves the shared buffer pools and configuration.
  7165. */
  7166. #define MLXSW_REG_SBPR_ID 0xB001
  7167. #define MLXSW_REG_SBPR_LEN 0x14
  7168. MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
  7169. /* shared direstion enum for SBPR, SBCM, SBPM */
  7170. enum mlxsw_reg_sbxx_dir {
  7171. MLXSW_REG_SBXX_DIR_INGRESS,
  7172. MLXSW_REG_SBXX_DIR_EGRESS,
  7173. };
  7174. /* reg_sbpr_dir
  7175. * Direction.
  7176. * Access: Index
  7177. */
  7178. MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
  7179. /* reg_sbpr_pool
  7180. * Pool index.
  7181. * Access: Index
  7182. */
  7183. MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
  7184. /* reg_sbpr_size
  7185. * Pool size in buffer cells.
  7186. * Access: RW
  7187. */
  7188. MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
  7189. enum mlxsw_reg_sbpr_mode {
  7190. MLXSW_REG_SBPR_MODE_STATIC,
  7191. MLXSW_REG_SBPR_MODE_DYNAMIC,
  7192. };
  7193. /* reg_sbpr_mode
  7194. * Pool quota calculation mode.
  7195. * Access: RW
  7196. */
  7197. MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
  7198. static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
  7199. enum mlxsw_reg_sbxx_dir dir,
  7200. enum mlxsw_reg_sbpr_mode mode, u32 size)
  7201. {
  7202. MLXSW_REG_ZERO(sbpr, payload);
  7203. mlxsw_reg_sbpr_pool_set(payload, pool);
  7204. mlxsw_reg_sbpr_dir_set(payload, dir);
  7205. mlxsw_reg_sbpr_mode_set(payload, mode);
  7206. mlxsw_reg_sbpr_size_set(payload, size);
  7207. }
  7208. /* SBCM - Shared Buffer Class Management Register
  7209. * ----------------------------------------------
  7210. * The SBCM register configures and retrieves the shared buffer allocation
  7211. * and configuration according to Port-PG, including the binding to pool
  7212. * and definition of the associated quota.
  7213. */
  7214. #define MLXSW_REG_SBCM_ID 0xB002
  7215. #define MLXSW_REG_SBCM_LEN 0x28
  7216. MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
  7217. /* reg_sbcm_local_port
  7218. * Local port number.
  7219. * For Ingress: excludes CPU port and Router port
  7220. * For Egress: excludes IP Router
  7221. * Access: Index
  7222. */
  7223. MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
  7224. /* reg_sbcm_pg_buff
  7225. * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
  7226. * For PG buffer: range is 0..cap_max_pg_buffers - 1
  7227. * For traffic class: range is 0..cap_max_tclass - 1
  7228. * Note that when traffic class is in MC aware mode then the traffic
  7229. * classes which are MC aware cannot be configured.
  7230. * Access: Index
  7231. */
  7232. MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
  7233. /* reg_sbcm_dir
  7234. * Direction.
  7235. * Access: Index
  7236. */
  7237. MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
  7238. /* reg_sbcm_min_buff
  7239. * Minimum buffer size for the limiter, in cells.
  7240. * Access: RW
  7241. */
  7242. MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
  7243. /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
  7244. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
  7245. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
  7246. /* reg_sbcm_max_buff
  7247. * When the pool associated to the port-pg/tclass is configured to
  7248. * static, Maximum buffer size for the limiter configured in cells.
  7249. * When the pool associated to the port-pg/tclass is configured to
  7250. * dynamic, the max_buff holds the "alpha" parameter, supporting
  7251. * the following values:
  7252. * 0: 0
  7253. * i: (1/128)*2^(i-1), for i=1..14
  7254. * 0xFF: Infinity
  7255. * Access: RW
  7256. */
  7257. MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
  7258. /* reg_sbcm_pool
  7259. * Association of the port-priority to a pool.
  7260. * Access: RW
  7261. */
  7262. MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
  7263. static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
  7264. enum mlxsw_reg_sbxx_dir dir,
  7265. u32 min_buff, u32 max_buff, u8 pool)
  7266. {
  7267. MLXSW_REG_ZERO(sbcm, payload);
  7268. mlxsw_reg_sbcm_local_port_set(payload, local_port);
  7269. mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
  7270. mlxsw_reg_sbcm_dir_set(payload, dir);
  7271. mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
  7272. mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
  7273. mlxsw_reg_sbcm_pool_set(payload, pool);
  7274. }
  7275. /* SBPM - Shared Buffer Port Management Register
  7276. * ---------------------------------------------
  7277. * The SBPM register configures and retrieves the shared buffer allocation
  7278. * and configuration according to Port-Pool, including the definition
  7279. * of the associated quota.
  7280. */
  7281. #define MLXSW_REG_SBPM_ID 0xB003
  7282. #define MLXSW_REG_SBPM_LEN 0x28
  7283. MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
  7284. /* reg_sbpm_local_port
  7285. * Local port number.
  7286. * For Ingress: excludes CPU port and Router port
  7287. * For Egress: excludes IP Router
  7288. * Access: Index
  7289. */
  7290. MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
  7291. /* reg_sbpm_pool
  7292. * The pool associated to quota counting on the local_port.
  7293. * Access: Index
  7294. */
  7295. MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
  7296. /* reg_sbpm_dir
  7297. * Direction.
  7298. * Access: Index
  7299. */
  7300. MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
  7301. /* reg_sbpm_buff_occupancy
  7302. * Current buffer occupancy in cells.
  7303. * Access: RO
  7304. */
  7305. MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
  7306. /* reg_sbpm_clr
  7307. * Clear Max Buffer Occupancy
  7308. * When this bit is set, max_buff_occupancy field is cleared (and a
  7309. * new max value is tracked from the time the clear was performed).
  7310. * Access: OP
  7311. */
  7312. MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
  7313. /* reg_sbpm_max_buff_occupancy
  7314. * Maximum value of buffer occupancy in cells monitored. Cleared by
  7315. * writing to the clr field.
  7316. * Access: RO
  7317. */
  7318. MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
  7319. /* reg_sbpm_min_buff
  7320. * Minimum buffer size for the limiter, in cells.
  7321. * Access: RW
  7322. */
  7323. MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
  7324. /* reg_sbpm_max_buff
  7325. * When the pool associated to the port-pg/tclass is configured to
  7326. * static, Maximum buffer size for the limiter configured in cells.
  7327. * When the pool associated to the port-pg/tclass is configured to
  7328. * dynamic, the max_buff holds the "alpha" parameter, supporting
  7329. * the following values:
  7330. * 0: 0
  7331. * i: (1/128)*2^(i-1), for i=1..14
  7332. * 0xFF: Infinity
  7333. * Access: RW
  7334. */
  7335. MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
  7336. static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
  7337. enum mlxsw_reg_sbxx_dir dir, bool clr,
  7338. u32 min_buff, u32 max_buff)
  7339. {
  7340. MLXSW_REG_ZERO(sbpm, payload);
  7341. mlxsw_reg_sbpm_local_port_set(payload, local_port);
  7342. mlxsw_reg_sbpm_pool_set(payload, pool);
  7343. mlxsw_reg_sbpm_dir_set(payload, dir);
  7344. mlxsw_reg_sbpm_clr_set(payload, clr);
  7345. mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
  7346. mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
  7347. }
  7348. static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
  7349. u32 *p_max_buff_occupancy)
  7350. {
  7351. *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
  7352. *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
  7353. }
  7354. /* SBMM - Shared Buffer Multicast Management Register
  7355. * --------------------------------------------------
  7356. * The SBMM register configures and retrieves the shared buffer allocation
  7357. * and configuration for MC packets according to Switch-Priority, including
  7358. * the binding to pool and definition of the associated quota.
  7359. */
  7360. #define MLXSW_REG_SBMM_ID 0xB004
  7361. #define MLXSW_REG_SBMM_LEN 0x28
  7362. MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
  7363. /* reg_sbmm_prio
  7364. * Switch Priority.
  7365. * Access: Index
  7366. */
  7367. MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
  7368. /* reg_sbmm_min_buff
  7369. * Minimum buffer size for the limiter, in cells.
  7370. * Access: RW
  7371. */
  7372. MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
  7373. /* reg_sbmm_max_buff
  7374. * When the pool associated to the port-pg/tclass is configured to
  7375. * static, Maximum buffer size for the limiter configured in cells.
  7376. * When the pool associated to the port-pg/tclass is configured to
  7377. * dynamic, the max_buff holds the "alpha" parameter, supporting
  7378. * the following values:
  7379. * 0: 0
  7380. * i: (1/128)*2^(i-1), for i=1..14
  7381. * 0xFF: Infinity
  7382. * Access: RW
  7383. */
  7384. MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
  7385. /* reg_sbmm_pool
  7386. * Association of the port-priority to a pool.
  7387. * Access: RW
  7388. */
  7389. MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
  7390. static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
  7391. u32 max_buff, u8 pool)
  7392. {
  7393. MLXSW_REG_ZERO(sbmm, payload);
  7394. mlxsw_reg_sbmm_prio_set(payload, prio);
  7395. mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
  7396. mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
  7397. mlxsw_reg_sbmm_pool_set(payload, pool);
  7398. }
  7399. /* SBSR - Shared Buffer Status Register
  7400. * ------------------------------------
  7401. * The SBSR register retrieves the shared buffer occupancy according to
  7402. * Port-Pool. Note that this register enables reading a large amount of data.
  7403. * It is the user's responsibility to limit the amount of data to ensure the
  7404. * response can match the maximum transfer unit. In case the response exceeds
  7405. * the maximum transport unit, it will be truncated with no special notice.
  7406. */
  7407. #define MLXSW_REG_SBSR_ID 0xB005
  7408. #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
  7409. #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
  7410. #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
  7411. #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
  7412. MLXSW_REG_SBSR_REC_LEN * \
  7413. MLXSW_REG_SBSR_REC_MAX_COUNT)
  7414. MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
  7415. /* reg_sbsr_clr
  7416. * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
  7417. * field is cleared (and a new max value is tracked from the time the clear
  7418. * was performed).
  7419. * Access: OP
  7420. */
  7421. MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
  7422. /* reg_sbsr_ingress_port_mask
  7423. * Bit vector for all ingress network ports.
  7424. * Indicates which of the ports (for which the relevant bit is set)
  7425. * are affected by the set operation. Configuration of any other port
  7426. * does not change.
  7427. * Access: Index
  7428. */
  7429. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
  7430. /* reg_sbsr_pg_buff_mask
  7431. * Bit vector for all switch priority groups.
  7432. * Indicates which of the priorities (for which the relevant bit is set)
  7433. * are affected by the set operation. Configuration of any other priority
  7434. * does not change.
  7435. * Range is 0..cap_max_pg_buffers - 1
  7436. * Access: Index
  7437. */
  7438. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
  7439. /* reg_sbsr_egress_port_mask
  7440. * Bit vector for all egress network ports.
  7441. * Indicates which of the ports (for which the relevant bit is set)
  7442. * are affected by the set operation. Configuration of any other port
  7443. * does not change.
  7444. * Access: Index
  7445. */
  7446. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
  7447. /* reg_sbsr_tclass_mask
  7448. * Bit vector for all traffic classes.
  7449. * Indicates which of the traffic classes (for which the relevant bit is
  7450. * set) are affected by the set operation. Configuration of any other
  7451. * traffic class does not change.
  7452. * Range is 0..cap_max_tclass - 1
  7453. * Access: Index
  7454. */
  7455. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
  7456. static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
  7457. {
  7458. MLXSW_REG_ZERO(sbsr, payload);
  7459. mlxsw_reg_sbsr_clr_set(payload, clr);
  7460. }
  7461. /* reg_sbsr_rec_buff_occupancy
  7462. * Current buffer occupancy in cells.
  7463. * Access: RO
  7464. */
  7465. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  7466. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
  7467. /* reg_sbsr_rec_max_buff_occupancy
  7468. * Maximum value of buffer occupancy in cells monitored. Cleared by
  7469. * writing to the clr field.
  7470. * Access: RO
  7471. */
  7472. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  7473. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
  7474. static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
  7475. u32 *p_buff_occupancy,
  7476. u32 *p_max_buff_occupancy)
  7477. {
  7478. *p_buff_occupancy =
  7479. mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
  7480. *p_max_buff_occupancy =
  7481. mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
  7482. }
  7483. /* SBIB - Shared Buffer Internal Buffer Register
  7484. * ---------------------------------------------
  7485. * The SBIB register configures per port buffers for internal use. The internal
  7486. * buffers consume memory on the port buffers (note that the port buffers are
  7487. * used also by PBMC).
  7488. *
  7489. * For Spectrum this is used for egress mirroring.
  7490. */
  7491. #define MLXSW_REG_SBIB_ID 0xB006
  7492. #define MLXSW_REG_SBIB_LEN 0x10
  7493. MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
  7494. /* reg_sbib_local_port
  7495. * Local port number
  7496. * Not supported for CPU port and router port
  7497. * Access: Index
  7498. */
  7499. MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
  7500. /* reg_sbib_buff_size
  7501. * Units represented in cells
  7502. * Allowed range is 0 to (cap_max_headroom_size - 1)
  7503. * Default is 0
  7504. * Access: RW
  7505. */
  7506. MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
  7507. static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
  7508. u32 buff_size)
  7509. {
  7510. MLXSW_REG_ZERO(sbib, payload);
  7511. mlxsw_reg_sbib_local_port_set(payload, local_port);
  7512. mlxsw_reg_sbib_buff_size_set(payload, buff_size);
  7513. }
  7514. static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
  7515. MLXSW_REG(sgcr),
  7516. MLXSW_REG(spad),
  7517. MLXSW_REG(smid),
  7518. MLXSW_REG(sspr),
  7519. MLXSW_REG(sfdat),
  7520. MLXSW_REG(sfd),
  7521. MLXSW_REG(sfn),
  7522. MLXSW_REG(spms),
  7523. MLXSW_REG(spvid),
  7524. MLXSW_REG(spvm),
  7525. MLXSW_REG(spaft),
  7526. MLXSW_REG(sfgc),
  7527. MLXSW_REG(sftr),
  7528. MLXSW_REG(sfdf),
  7529. MLXSW_REG(sldr),
  7530. MLXSW_REG(slcr),
  7531. MLXSW_REG(slcor),
  7532. MLXSW_REG(spmlr),
  7533. MLXSW_REG(svfa),
  7534. MLXSW_REG(svpe),
  7535. MLXSW_REG(sfmr),
  7536. MLXSW_REG(spvmlr),
  7537. MLXSW_REG(cwtp),
  7538. MLXSW_REG(cwtpm),
  7539. MLXSW_REG(pgcr),
  7540. MLXSW_REG(ppbt),
  7541. MLXSW_REG(pacl),
  7542. MLXSW_REG(pagt),
  7543. MLXSW_REG(ptar),
  7544. MLXSW_REG(ppbs),
  7545. MLXSW_REG(prcr),
  7546. MLXSW_REG(pefa),
  7547. MLXSW_REG(ptce2),
  7548. MLXSW_REG(perpt),
  7549. MLXSW_REG(perar),
  7550. MLXSW_REG(ptce3),
  7551. MLXSW_REG(percr),
  7552. MLXSW_REG(pererp),
  7553. MLXSW_REG(iedr),
  7554. MLXSW_REG(qpts),
  7555. MLXSW_REG(qpcr),
  7556. MLXSW_REG(qtct),
  7557. MLXSW_REG(qeec),
  7558. MLXSW_REG(qrwe),
  7559. MLXSW_REG(qpdsm),
  7560. MLXSW_REG(qpdpm),
  7561. MLXSW_REG(qtctm),
  7562. MLXSW_REG(pmlp),
  7563. MLXSW_REG(pmtu),
  7564. MLXSW_REG(ptys),
  7565. MLXSW_REG(ppad),
  7566. MLXSW_REG(paos),
  7567. MLXSW_REG(pfcc),
  7568. MLXSW_REG(ppcnt),
  7569. MLXSW_REG(plib),
  7570. MLXSW_REG(pptb),
  7571. MLXSW_REG(pbmc),
  7572. MLXSW_REG(pspa),
  7573. MLXSW_REG(htgt),
  7574. MLXSW_REG(hpkt),
  7575. MLXSW_REG(rgcr),
  7576. MLXSW_REG(ritr),
  7577. MLXSW_REG(rtar),
  7578. MLXSW_REG(ratr),
  7579. MLXSW_REG(rtdp),
  7580. MLXSW_REG(rdpm),
  7581. MLXSW_REG(ricnt),
  7582. MLXSW_REG(rrcr),
  7583. MLXSW_REG(ralta),
  7584. MLXSW_REG(ralst),
  7585. MLXSW_REG(raltb),
  7586. MLXSW_REG(ralue),
  7587. MLXSW_REG(rauht),
  7588. MLXSW_REG(raleu),
  7589. MLXSW_REG(rauhtd),
  7590. MLXSW_REG(rigr2),
  7591. MLXSW_REG(recr2),
  7592. MLXSW_REG(rmft2),
  7593. MLXSW_REG(mfcr),
  7594. MLXSW_REG(mfsc),
  7595. MLXSW_REG(mfsm),
  7596. MLXSW_REG(mfsl),
  7597. MLXSW_REG(mtcap),
  7598. MLXSW_REG(mtmp),
  7599. MLXSW_REG(mcia),
  7600. MLXSW_REG(mpat),
  7601. MLXSW_REG(mpar),
  7602. MLXSW_REG(mrsr),
  7603. MLXSW_REG(mlcr),
  7604. MLXSW_REG(mpsc),
  7605. MLXSW_REG(mcqi),
  7606. MLXSW_REG(mcc),
  7607. MLXSW_REG(mcda),
  7608. MLXSW_REG(mgpc),
  7609. MLXSW_REG(tigcr),
  7610. MLXSW_REG(sbpr),
  7611. MLXSW_REG(sbcm),
  7612. MLXSW_REG(sbpm),
  7613. MLXSW_REG(sbmm),
  7614. MLXSW_REG(sbsr),
  7615. MLXSW_REG(sbib),
  7616. };
  7617. static inline const char *mlxsw_reg_id_str(u16 reg_id)
  7618. {
  7619. const struct mlxsw_reg_info *reg_info;
  7620. int i;
  7621. for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
  7622. reg_info = mlxsw_reg_infos[i];
  7623. if (reg_info->id == reg_id)
  7624. return reg_info->name;
  7625. }
  7626. return "*UNKNOWN*";
  7627. }
  7628. /* PUDE - Port Up / Down Event
  7629. * ---------------------------
  7630. * Reports the operational state change of a port.
  7631. */
  7632. #define MLXSW_REG_PUDE_LEN 0x10
  7633. /* reg_pude_swid
  7634. * Switch partition ID with which to associate the port.
  7635. * Access: Index
  7636. */
  7637. MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
  7638. /* reg_pude_local_port
  7639. * Local port number.
  7640. * Access: Index
  7641. */
  7642. MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
  7643. /* reg_pude_admin_status
  7644. * Port administrative state (the desired state).
  7645. * 1 - Up.
  7646. * 2 - Down.
  7647. * 3 - Up once. This means that in case of link failure, the port won't go
  7648. * into polling mode, but will wait to be re-enabled by software.
  7649. * 4 - Disabled by system. Can only be set by hardware.
  7650. * Access: RO
  7651. */
  7652. MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
  7653. /* reg_pude_oper_status
  7654. * Port operatioanl state.
  7655. * 1 - Up.
  7656. * 2 - Down.
  7657. * 3 - Down by port failure. This means that the device will not let the
  7658. * port up again until explicitly specified by software.
  7659. * Access: RO
  7660. */
  7661. MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
  7662. #endif