reg.h 180 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285
  1. /*
  2. * drivers/net/ethernet/mellanox/mlxsw/reg.h
  3. * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2015-2016 Ido Schimmel <idosch@mellanox.com>
  5. * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
  6. * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
  7. * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the names of the copyright holders nor the names of its
  18. * contributors may be used to endorse or promote products derived from
  19. * this software without specific prior written permission.
  20. *
  21. * Alternatively, this software may be distributed under the terms of the
  22. * GNU General Public License ("GPL") version 2 as published by the Free
  23. * Software Foundation.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #ifndef _MLXSW_REG_H
  38. #define _MLXSW_REG_H
  39. #include <linux/string.h>
  40. #include <linux/bitops.h>
  41. #include <linux/if_vlan.h>
  42. #include "item.h"
  43. #include "port.h"
  44. struct mlxsw_reg_info {
  45. u16 id;
  46. u16 len; /* In u8 */
  47. const char *name;
  48. };
  49. #define MLXSW_REG_DEFINE(_name, _id, _len) \
  50. static const struct mlxsw_reg_info mlxsw_reg_##_name = { \
  51. .id = _id, \
  52. .len = _len, \
  53. .name = #_name, \
  54. }
  55. #define MLXSW_REG(type) (&mlxsw_reg_##type)
  56. #define MLXSW_REG_LEN(type) MLXSW_REG(type)->len
  57. #define MLXSW_REG_ZERO(type, payload) memset(payload, 0, MLXSW_REG(type)->len)
  58. /* SGCR - Switch General Configuration Register
  59. * --------------------------------------------
  60. * This register is used for configuration of the switch capabilities.
  61. */
  62. #define MLXSW_REG_SGCR_ID 0x2000
  63. #define MLXSW_REG_SGCR_LEN 0x10
  64. MLXSW_REG_DEFINE(sgcr, MLXSW_REG_SGCR_ID, MLXSW_REG_SGCR_LEN);
  65. /* reg_sgcr_llb
  66. * Link Local Broadcast (Default=0)
  67. * When set, all Link Local packets (224.0.0.X) will be treated as broadcast
  68. * packets and ignore the IGMP snooping entries.
  69. * Access: RW
  70. */
  71. MLXSW_ITEM32(reg, sgcr, llb, 0x04, 0, 1);
  72. static inline void mlxsw_reg_sgcr_pack(char *payload, bool llb)
  73. {
  74. MLXSW_REG_ZERO(sgcr, payload);
  75. mlxsw_reg_sgcr_llb_set(payload, !!llb);
  76. }
  77. /* SPAD - Switch Physical Address Register
  78. * ---------------------------------------
  79. * The SPAD register configures the switch physical MAC address.
  80. */
  81. #define MLXSW_REG_SPAD_ID 0x2002
  82. #define MLXSW_REG_SPAD_LEN 0x10
  83. MLXSW_REG_DEFINE(spad, MLXSW_REG_SPAD_ID, MLXSW_REG_SPAD_LEN);
  84. /* reg_spad_base_mac
  85. * Base MAC address for the switch partitions.
  86. * Per switch partition MAC address is equal to:
  87. * base_mac + swid
  88. * Access: RW
  89. */
  90. MLXSW_ITEM_BUF(reg, spad, base_mac, 0x02, 6);
  91. /* SMID - Switch Multicast ID
  92. * --------------------------
  93. * The MID record maps from a MID (Multicast ID), which is a unique identifier
  94. * of the multicast group within the stacking domain, into a list of local
  95. * ports into which the packet is replicated.
  96. */
  97. #define MLXSW_REG_SMID_ID 0x2007
  98. #define MLXSW_REG_SMID_LEN 0x240
  99. MLXSW_REG_DEFINE(smid, MLXSW_REG_SMID_ID, MLXSW_REG_SMID_LEN);
  100. /* reg_smid_swid
  101. * Switch partition ID.
  102. * Access: Index
  103. */
  104. MLXSW_ITEM32(reg, smid, swid, 0x00, 24, 8);
  105. /* reg_smid_mid
  106. * Multicast identifier - global identifier that represents the multicast group
  107. * across all devices.
  108. * Access: Index
  109. */
  110. MLXSW_ITEM32(reg, smid, mid, 0x00, 0, 16);
  111. /* reg_smid_port
  112. * Local port memebership (1 bit per port).
  113. * Access: RW
  114. */
  115. MLXSW_ITEM_BIT_ARRAY(reg, smid, port, 0x20, 0x20, 1);
  116. /* reg_smid_port_mask
  117. * Local port mask (1 bit per port).
  118. * Access: W
  119. */
  120. MLXSW_ITEM_BIT_ARRAY(reg, smid, port_mask, 0x220, 0x20, 1);
  121. static inline void mlxsw_reg_smid_pack(char *payload, u16 mid,
  122. u8 port, bool set)
  123. {
  124. MLXSW_REG_ZERO(smid, payload);
  125. mlxsw_reg_smid_swid_set(payload, 0);
  126. mlxsw_reg_smid_mid_set(payload, mid);
  127. mlxsw_reg_smid_port_set(payload, port, set);
  128. mlxsw_reg_smid_port_mask_set(payload, port, 1);
  129. }
  130. /* SSPR - Switch System Port Record Register
  131. * -----------------------------------------
  132. * Configures the system port to local port mapping.
  133. */
  134. #define MLXSW_REG_SSPR_ID 0x2008
  135. #define MLXSW_REG_SSPR_LEN 0x8
  136. MLXSW_REG_DEFINE(sspr, MLXSW_REG_SSPR_ID, MLXSW_REG_SSPR_LEN);
  137. /* reg_sspr_m
  138. * Master - if set, then the record describes the master system port.
  139. * This is needed in case a local port is mapped into several system ports
  140. * (for multipathing). That number will be reported as the source system
  141. * port when packets are forwarded to the CPU. Only one master port is allowed
  142. * per local port.
  143. *
  144. * Note: Must be set for Spectrum.
  145. * Access: RW
  146. */
  147. MLXSW_ITEM32(reg, sspr, m, 0x00, 31, 1);
  148. /* reg_sspr_local_port
  149. * Local port number.
  150. *
  151. * Access: RW
  152. */
  153. MLXSW_ITEM32(reg, sspr, local_port, 0x00, 16, 8);
  154. /* reg_sspr_sub_port
  155. * Virtual port within the physical port.
  156. * Should be set to 0 when virtual ports are not enabled on the port.
  157. *
  158. * Access: RW
  159. */
  160. MLXSW_ITEM32(reg, sspr, sub_port, 0x00, 8, 8);
  161. /* reg_sspr_system_port
  162. * Unique identifier within the stacking domain that represents all the ports
  163. * that are available in the system (external ports).
  164. *
  165. * Currently, only single-ASIC configurations are supported, so we default to
  166. * 1:1 mapping between system ports and local ports.
  167. * Access: Index
  168. */
  169. MLXSW_ITEM32(reg, sspr, system_port, 0x04, 0, 16);
  170. static inline void mlxsw_reg_sspr_pack(char *payload, u8 local_port)
  171. {
  172. MLXSW_REG_ZERO(sspr, payload);
  173. mlxsw_reg_sspr_m_set(payload, 1);
  174. mlxsw_reg_sspr_local_port_set(payload, local_port);
  175. mlxsw_reg_sspr_sub_port_set(payload, 0);
  176. mlxsw_reg_sspr_system_port_set(payload, local_port);
  177. }
  178. /* SFDAT - Switch Filtering Database Aging Time
  179. * --------------------------------------------
  180. * Controls the Switch aging time. Aging time is able to be set per Switch
  181. * Partition.
  182. */
  183. #define MLXSW_REG_SFDAT_ID 0x2009
  184. #define MLXSW_REG_SFDAT_LEN 0x8
  185. MLXSW_REG_DEFINE(sfdat, MLXSW_REG_SFDAT_ID, MLXSW_REG_SFDAT_LEN);
  186. /* reg_sfdat_swid
  187. * Switch partition ID.
  188. * Access: Index
  189. */
  190. MLXSW_ITEM32(reg, sfdat, swid, 0x00, 24, 8);
  191. /* reg_sfdat_age_time
  192. * Aging time in seconds
  193. * Min - 10 seconds
  194. * Max - 1,000,000 seconds
  195. * Default is 300 seconds.
  196. * Access: RW
  197. */
  198. MLXSW_ITEM32(reg, sfdat, age_time, 0x04, 0, 20);
  199. static inline void mlxsw_reg_sfdat_pack(char *payload, u32 age_time)
  200. {
  201. MLXSW_REG_ZERO(sfdat, payload);
  202. mlxsw_reg_sfdat_swid_set(payload, 0);
  203. mlxsw_reg_sfdat_age_time_set(payload, age_time);
  204. }
  205. /* SFD - Switch Filtering Database
  206. * -------------------------------
  207. * The following register defines the access to the filtering database.
  208. * The register supports querying, adding, removing and modifying the database.
  209. * The access is optimized for bulk updates in which case more than one
  210. * FDB record is present in the same command.
  211. */
  212. #define MLXSW_REG_SFD_ID 0x200A
  213. #define MLXSW_REG_SFD_BASE_LEN 0x10 /* base length, without records */
  214. #define MLXSW_REG_SFD_REC_LEN 0x10 /* record length */
  215. #define MLXSW_REG_SFD_REC_MAX_COUNT 64
  216. #define MLXSW_REG_SFD_LEN (MLXSW_REG_SFD_BASE_LEN + \
  217. MLXSW_REG_SFD_REC_LEN * MLXSW_REG_SFD_REC_MAX_COUNT)
  218. MLXSW_REG_DEFINE(sfd, MLXSW_REG_SFD_ID, MLXSW_REG_SFD_LEN);
  219. /* reg_sfd_swid
  220. * Switch partition ID for queries. Reserved on Write.
  221. * Access: Index
  222. */
  223. MLXSW_ITEM32(reg, sfd, swid, 0x00, 24, 8);
  224. enum mlxsw_reg_sfd_op {
  225. /* Dump entire FDB a (process according to record_locator) */
  226. MLXSW_REG_SFD_OP_QUERY_DUMP = 0,
  227. /* Query records by {MAC, VID/FID} value */
  228. MLXSW_REG_SFD_OP_QUERY_QUERY = 1,
  229. /* Query and clear activity. Query records by {MAC, VID/FID} value */
  230. MLXSW_REG_SFD_OP_QUERY_QUERY_AND_CLEAR_ACTIVITY = 2,
  231. /* Test. Response indicates if each of the records could be
  232. * added to the FDB.
  233. */
  234. MLXSW_REG_SFD_OP_WRITE_TEST = 0,
  235. /* Add/modify. Aged-out records cannot be added. This command removes
  236. * the learning notification of the {MAC, VID/FID}. Response includes
  237. * the entries that were added to the FDB.
  238. */
  239. MLXSW_REG_SFD_OP_WRITE_EDIT = 1,
  240. /* Remove record by {MAC, VID/FID}. This command also removes
  241. * the learning notification and aged-out notifications
  242. * of the {MAC, VID/FID}. The response provides current (pre-removal)
  243. * entries as non-aged-out.
  244. */
  245. MLXSW_REG_SFD_OP_WRITE_REMOVE = 2,
  246. /* Remove learned notification by {MAC, VID/FID}. The response provides
  247. * the removed learning notification.
  248. */
  249. MLXSW_REG_SFD_OP_WRITE_REMOVE_NOTIFICATION = 2,
  250. };
  251. /* reg_sfd_op
  252. * Operation.
  253. * Access: OP
  254. */
  255. MLXSW_ITEM32(reg, sfd, op, 0x04, 30, 2);
  256. /* reg_sfd_record_locator
  257. * Used for querying the FDB. Use record_locator=0 to initiate the
  258. * query. When a record is returned, a new record_locator is
  259. * returned to be used in the subsequent query.
  260. * Reserved for database update.
  261. * Access: Index
  262. */
  263. MLXSW_ITEM32(reg, sfd, record_locator, 0x04, 0, 30);
  264. /* reg_sfd_num_rec
  265. * Request: Number of records to read/add/modify/remove
  266. * Response: Number of records read/added/replaced/removed
  267. * See above description for more details.
  268. * Ranges 0..64
  269. * Access: RW
  270. */
  271. MLXSW_ITEM32(reg, sfd, num_rec, 0x08, 0, 8);
  272. static inline void mlxsw_reg_sfd_pack(char *payload, enum mlxsw_reg_sfd_op op,
  273. u32 record_locator)
  274. {
  275. MLXSW_REG_ZERO(sfd, payload);
  276. mlxsw_reg_sfd_op_set(payload, op);
  277. mlxsw_reg_sfd_record_locator_set(payload, record_locator);
  278. }
  279. /* reg_sfd_rec_swid
  280. * Switch partition ID.
  281. * Access: Index
  282. */
  283. MLXSW_ITEM32_INDEXED(reg, sfd, rec_swid, MLXSW_REG_SFD_BASE_LEN, 24, 8,
  284. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  285. enum mlxsw_reg_sfd_rec_type {
  286. MLXSW_REG_SFD_REC_TYPE_UNICAST = 0x0,
  287. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG = 0x1,
  288. MLXSW_REG_SFD_REC_TYPE_MULTICAST = 0x2,
  289. };
  290. /* reg_sfd_rec_type
  291. * FDB record type.
  292. * Access: RW
  293. */
  294. MLXSW_ITEM32_INDEXED(reg, sfd, rec_type, MLXSW_REG_SFD_BASE_LEN, 20, 4,
  295. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  296. enum mlxsw_reg_sfd_rec_policy {
  297. /* Replacement disabled, aging disabled. */
  298. MLXSW_REG_SFD_REC_POLICY_STATIC_ENTRY = 0,
  299. /* (mlag remote): Replacement enabled, aging disabled,
  300. * learning notification enabled on this port.
  301. */
  302. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_MLAG = 1,
  303. /* (ingress device): Replacement enabled, aging enabled. */
  304. MLXSW_REG_SFD_REC_POLICY_DYNAMIC_ENTRY_INGRESS = 3,
  305. };
  306. /* reg_sfd_rec_policy
  307. * Policy.
  308. * Access: RW
  309. */
  310. MLXSW_ITEM32_INDEXED(reg, sfd, rec_policy, MLXSW_REG_SFD_BASE_LEN, 18, 2,
  311. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  312. /* reg_sfd_rec_a
  313. * Activity. Set for new static entries. Set for static entries if a frame SMAC
  314. * lookup hits on the entry.
  315. * To clear the a bit, use "query and clear activity" op.
  316. * Access: RO
  317. */
  318. MLXSW_ITEM32_INDEXED(reg, sfd, rec_a, MLXSW_REG_SFD_BASE_LEN, 16, 1,
  319. MLXSW_REG_SFD_REC_LEN, 0x00, false);
  320. /* reg_sfd_rec_mac
  321. * MAC address.
  322. * Access: Index
  323. */
  324. MLXSW_ITEM_BUF_INDEXED(reg, sfd, rec_mac, MLXSW_REG_SFD_BASE_LEN, 6,
  325. MLXSW_REG_SFD_REC_LEN, 0x02);
  326. enum mlxsw_reg_sfd_rec_action {
  327. /* forward */
  328. MLXSW_REG_SFD_REC_ACTION_NOP = 0,
  329. /* forward and trap, trap_id is FDB_TRAP */
  330. MLXSW_REG_SFD_REC_ACTION_MIRROR_TO_CPU = 1,
  331. /* trap and do not forward, trap_id is FDB_TRAP */
  332. MLXSW_REG_SFD_REC_ACTION_TRAP = 2,
  333. /* forward to IP router */
  334. MLXSW_REG_SFD_REC_ACTION_FORWARD_IP_ROUTER = 3,
  335. MLXSW_REG_SFD_REC_ACTION_DISCARD_ERROR = 15,
  336. };
  337. /* reg_sfd_rec_action
  338. * Action to apply on the packet.
  339. * Note: Dynamic entries can only be configured with NOP action.
  340. * Access: RW
  341. */
  342. MLXSW_ITEM32_INDEXED(reg, sfd, rec_action, MLXSW_REG_SFD_BASE_LEN, 28, 4,
  343. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  344. /* reg_sfd_uc_sub_port
  345. * VEPA channel on local port.
  346. * Valid only if local port is a non-stacking port. Must be 0 if multichannel
  347. * VEPA is not enabled.
  348. * Access: RW
  349. */
  350. MLXSW_ITEM32_INDEXED(reg, sfd, uc_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  351. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  352. /* reg_sfd_uc_fid_vid
  353. * Filtering ID or VLAN ID
  354. * For SwitchX and SwitchX-2:
  355. * - Dynamic entries (policy 2,3) use FID
  356. * - Static entries (policy 0) use VID
  357. * - When independent learning is configured, VID=FID
  358. * For Spectrum: use FID for both Dynamic and Static entries.
  359. * VID should not be used.
  360. * Access: Index
  361. */
  362. MLXSW_ITEM32_INDEXED(reg, sfd, uc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  363. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  364. /* reg_sfd_uc_system_port
  365. * Unique port identifier for the final destination of the packet.
  366. * Access: RW
  367. */
  368. MLXSW_ITEM32_INDEXED(reg, sfd, uc_system_port, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  369. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  370. static inline void mlxsw_reg_sfd_rec_pack(char *payload, int rec_index,
  371. enum mlxsw_reg_sfd_rec_type rec_type,
  372. const char *mac,
  373. enum mlxsw_reg_sfd_rec_action action)
  374. {
  375. u8 num_rec = mlxsw_reg_sfd_num_rec_get(payload);
  376. if (rec_index >= num_rec)
  377. mlxsw_reg_sfd_num_rec_set(payload, rec_index + 1);
  378. mlxsw_reg_sfd_rec_swid_set(payload, rec_index, 0);
  379. mlxsw_reg_sfd_rec_type_set(payload, rec_index, rec_type);
  380. mlxsw_reg_sfd_rec_mac_memcpy_to(payload, rec_index, mac);
  381. mlxsw_reg_sfd_rec_action_set(payload, rec_index, action);
  382. }
  383. static inline void mlxsw_reg_sfd_uc_pack(char *payload, int rec_index,
  384. enum mlxsw_reg_sfd_rec_policy policy,
  385. const char *mac, u16 fid_vid,
  386. enum mlxsw_reg_sfd_rec_action action,
  387. u8 local_port)
  388. {
  389. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  390. MLXSW_REG_SFD_REC_TYPE_UNICAST, mac, action);
  391. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  392. mlxsw_reg_sfd_uc_sub_port_set(payload, rec_index, 0);
  393. mlxsw_reg_sfd_uc_fid_vid_set(payload, rec_index, fid_vid);
  394. mlxsw_reg_sfd_uc_system_port_set(payload, rec_index, local_port);
  395. }
  396. static inline void mlxsw_reg_sfd_uc_unpack(char *payload, int rec_index,
  397. char *mac, u16 *p_fid_vid,
  398. u8 *p_local_port)
  399. {
  400. mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
  401. *p_fid_vid = mlxsw_reg_sfd_uc_fid_vid_get(payload, rec_index);
  402. *p_local_port = mlxsw_reg_sfd_uc_system_port_get(payload, rec_index);
  403. }
  404. /* reg_sfd_uc_lag_sub_port
  405. * LAG sub port.
  406. * Must be 0 if multichannel VEPA is not enabled.
  407. * Access: RW
  408. */
  409. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_sub_port, MLXSW_REG_SFD_BASE_LEN, 16, 8,
  410. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  411. /* reg_sfd_uc_lag_fid_vid
  412. * Filtering ID or VLAN ID
  413. * For SwitchX and SwitchX-2:
  414. * - Dynamic entries (policy 2,3) use FID
  415. * - Static entries (policy 0) use VID
  416. * - When independent learning is configured, VID=FID
  417. * For Spectrum: use FID for both Dynamic and Static entries.
  418. * VID should not be used.
  419. * Access: Index
  420. */
  421. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  422. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  423. /* reg_sfd_uc_lag_lag_vid
  424. * Indicates VID in case of vFIDs. Reserved for FIDs.
  425. * Access: RW
  426. */
  427. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_vid, MLXSW_REG_SFD_BASE_LEN, 16, 12,
  428. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  429. /* reg_sfd_uc_lag_lag_id
  430. * LAG Identifier - pointer into the LAG descriptor table.
  431. * Access: RW
  432. */
  433. MLXSW_ITEM32_INDEXED(reg, sfd, uc_lag_lag_id, MLXSW_REG_SFD_BASE_LEN, 0, 10,
  434. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  435. static inline void
  436. mlxsw_reg_sfd_uc_lag_pack(char *payload, int rec_index,
  437. enum mlxsw_reg_sfd_rec_policy policy,
  438. const char *mac, u16 fid_vid,
  439. enum mlxsw_reg_sfd_rec_action action, u16 lag_vid,
  440. u16 lag_id)
  441. {
  442. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  443. MLXSW_REG_SFD_REC_TYPE_UNICAST_LAG,
  444. mac, action);
  445. mlxsw_reg_sfd_rec_policy_set(payload, rec_index, policy);
  446. mlxsw_reg_sfd_uc_lag_sub_port_set(payload, rec_index, 0);
  447. mlxsw_reg_sfd_uc_lag_fid_vid_set(payload, rec_index, fid_vid);
  448. mlxsw_reg_sfd_uc_lag_lag_vid_set(payload, rec_index, lag_vid);
  449. mlxsw_reg_sfd_uc_lag_lag_id_set(payload, rec_index, lag_id);
  450. }
  451. static inline void mlxsw_reg_sfd_uc_lag_unpack(char *payload, int rec_index,
  452. char *mac, u16 *p_vid,
  453. u16 *p_lag_id)
  454. {
  455. mlxsw_reg_sfd_rec_mac_memcpy_from(payload, rec_index, mac);
  456. *p_vid = mlxsw_reg_sfd_uc_lag_fid_vid_get(payload, rec_index);
  457. *p_lag_id = mlxsw_reg_sfd_uc_lag_lag_id_get(payload, rec_index);
  458. }
  459. /* reg_sfd_mc_pgi
  460. *
  461. * Multicast port group index - index into the port group table.
  462. * Value 0x1FFF indicates the pgi should point to the MID entry.
  463. * For Spectrum this value must be set to 0x1FFF
  464. * Access: RW
  465. */
  466. MLXSW_ITEM32_INDEXED(reg, sfd, mc_pgi, MLXSW_REG_SFD_BASE_LEN, 16, 13,
  467. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  468. /* reg_sfd_mc_fid_vid
  469. *
  470. * Filtering ID or VLAN ID
  471. * Access: Index
  472. */
  473. MLXSW_ITEM32_INDEXED(reg, sfd, mc_fid_vid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  474. MLXSW_REG_SFD_REC_LEN, 0x08, false);
  475. /* reg_sfd_mc_mid
  476. *
  477. * Multicast identifier - global identifier that represents the multicast
  478. * group across all devices.
  479. * Access: RW
  480. */
  481. MLXSW_ITEM32_INDEXED(reg, sfd, mc_mid, MLXSW_REG_SFD_BASE_LEN, 0, 16,
  482. MLXSW_REG_SFD_REC_LEN, 0x0C, false);
  483. static inline void
  484. mlxsw_reg_sfd_mc_pack(char *payload, int rec_index,
  485. const char *mac, u16 fid_vid,
  486. enum mlxsw_reg_sfd_rec_action action, u16 mid)
  487. {
  488. mlxsw_reg_sfd_rec_pack(payload, rec_index,
  489. MLXSW_REG_SFD_REC_TYPE_MULTICAST, mac, action);
  490. mlxsw_reg_sfd_mc_pgi_set(payload, rec_index, 0x1FFF);
  491. mlxsw_reg_sfd_mc_fid_vid_set(payload, rec_index, fid_vid);
  492. mlxsw_reg_sfd_mc_mid_set(payload, rec_index, mid);
  493. }
  494. /* SFN - Switch FDB Notification Register
  495. * -------------------------------------------
  496. * The switch provides notifications on newly learned FDB entries and
  497. * aged out entries. The notifications can be polled by software.
  498. */
  499. #define MLXSW_REG_SFN_ID 0x200B
  500. #define MLXSW_REG_SFN_BASE_LEN 0x10 /* base length, without records */
  501. #define MLXSW_REG_SFN_REC_LEN 0x10 /* record length */
  502. #define MLXSW_REG_SFN_REC_MAX_COUNT 64
  503. #define MLXSW_REG_SFN_LEN (MLXSW_REG_SFN_BASE_LEN + \
  504. MLXSW_REG_SFN_REC_LEN * MLXSW_REG_SFN_REC_MAX_COUNT)
  505. MLXSW_REG_DEFINE(sfn, MLXSW_REG_SFN_ID, MLXSW_REG_SFN_LEN);
  506. /* reg_sfn_swid
  507. * Switch partition ID.
  508. * Access: Index
  509. */
  510. MLXSW_ITEM32(reg, sfn, swid, 0x00, 24, 8);
  511. /* reg_sfn_end
  512. * Forces the current session to end.
  513. * Access: OP
  514. */
  515. MLXSW_ITEM32(reg, sfn, end, 0x04, 20, 1);
  516. /* reg_sfn_num_rec
  517. * Request: Number of learned notifications and aged-out notification
  518. * records requested.
  519. * Response: Number of notification records returned (must be smaller
  520. * than or equal to the value requested)
  521. * Ranges 0..64
  522. * Access: OP
  523. */
  524. MLXSW_ITEM32(reg, sfn, num_rec, 0x04, 0, 8);
  525. static inline void mlxsw_reg_sfn_pack(char *payload)
  526. {
  527. MLXSW_REG_ZERO(sfn, payload);
  528. mlxsw_reg_sfn_swid_set(payload, 0);
  529. mlxsw_reg_sfn_end_set(payload, 1);
  530. mlxsw_reg_sfn_num_rec_set(payload, MLXSW_REG_SFN_REC_MAX_COUNT);
  531. }
  532. /* reg_sfn_rec_swid
  533. * Switch partition ID.
  534. * Access: RO
  535. */
  536. MLXSW_ITEM32_INDEXED(reg, sfn, rec_swid, MLXSW_REG_SFN_BASE_LEN, 24, 8,
  537. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  538. enum mlxsw_reg_sfn_rec_type {
  539. /* MAC addresses learned on a regular port. */
  540. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC = 0x5,
  541. /* MAC addresses learned on a LAG port. */
  542. MLXSW_REG_SFN_REC_TYPE_LEARNED_MAC_LAG = 0x6,
  543. /* Aged-out MAC address on a regular port. */
  544. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC = 0x7,
  545. /* Aged-out MAC address on a LAG port. */
  546. MLXSW_REG_SFN_REC_TYPE_AGED_OUT_MAC_LAG = 0x8,
  547. };
  548. /* reg_sfn_rec_type
  549. * Notification record type.
  550. * Access: RO
  551. */
  552. MLXSW_ITEM32_INDEXED(reg, sfn, rec_type, MLXSW_REG_SFN_BASE_LEN, 20, 4,
  553. MLXSW_REG_SFN_REC_LEN, 0x00, false);
  554. /* reg_sfn_rec_mac
  555. * MAC address.
  556. * Access: RO
  557. */
  558. MLXSW_ITEM_BUF_INDEXED(reg, sfn, rec_mac, MLXSW_REG_SFN_BASE_LEN, 6,
  559. MLXSW_REG_SFN_REC_LEN, 0x02);
  560. /* reg_sfn_mac_sub_port
  561. * VEPA channel on the local port.
  562. * 0 if multichannel VEPA is not enabled.
  563. * Access: RO
  564. */
  565. MLXSW_ITEM32_INDEXED(reg, sfn, mac_sub_port, MLXSW_REG_SFN_BASE_LEN, 16, 8,
  566. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  567. /* reg_sfn_mac_fid
  568. * Filtering identifier.
  569. * Access: RO
  570. */
  571. MLXSW_ITEM32_INDEXED(reg, sfn, mac_fid, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  572. MLXSW_REG_SFN_REC_LEN, 0x08, false);
  573. /* reg_sfn_mac_system_port
  574. * Unique port identifier for the final destination of the packet.
  575. * Access: RO
  576. */
  577. MLXSW_ITEM32_INDEXED(reg, sfn, mac_system_port, MLXSW_REG_SFN_BASE_LEN, 0, 16,
  578. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  579. static inline void mlxsw_reg_sfn_mac_unpack(char *payload, int rec_index,
  580. char *mac, u16 *p_vid,
  581. u8 *p_local_port)
  582. {
  583. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  584. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  585. *p_local_port = mlxsw_reg_sfn_mac_system_port_get(payload, rec_index);
  586. }
  587. /* reg_sfn_mac_lag_lag_id
  588. * LAG ID (pointer into the LAG descriptor table).
  589. * Access: RO
  590. */
  591. MLXSW_ITEM32_INDEXED(reg, sfn, mac_lag_lag_id, MLXSW_REG_SFN_BASE_LEN, 0, 10,
  592. MLXSW_REG_SFN_REC_LEN, 0x0C, false);
  593. static inline void mlxsw_reg_sfn_mac_lag_unpack(char *payload, int rec_index,
  594. char *mac, u16 *p_vid,
  595. u16 *p_lag_id)
  596. {
  597. mlxsw_reg_sfn_rec_mac_memcpy_from(payload, rec_index, mac);
  598. *p_vid = mlxsw_reg_sfn_mac_fid_get(payload, rec_index);
  599. *p_lag_id = mlxsw_reg_sfn_mac_lag_lag_id_get(payload, rec_index);
  600. }
  601. /* SPMS - Switch Port MSTP/RSTP State Register
  602. * -------------------------------------------
  603. * Configures the spanning tree state of a physical port.
  604. */
  605. #define MLXSW_REG_SPMS_ID 0x200D
  606. #define MLXSW_REG_SPMS_LEN 0x404
  607. MLXSW_REG_DEFINE(spms, MLXSW_REG_SPMS_ID, MLXSW_REG_SPMS_LEN);
  608. /* reg_spms_local_port
  609. * Local port number.
  610. * Access: Index
  611. */
  612. MLXSW_ITEM32(reg, spms, local_port, 0x00, 16, 8);
  613. enum mlxsw_reg_spms_state {
  614. MLXSW_REG_SPMS_STATE_NO_CHANGE,
  615. MLXSW_REG_SPMS_STATE_DISCARDING,
  616. MLXSW_REG_SPMS_STATE_LEARNING,
  617. MLXSW_REG_SPMS_STATE_FORWARDING,
  618. };
  619. /* reg_spms_state
  620. * Spanning tree state of each VLAN ID (VID) of the local port.
  621. * 0 - Do not change spanning tree state (used only when writing).
  622. * 1 - Discarding. No learning or forwarding to/from this port (default).
  623. * 2 - Learning. Port is learning, but not forwarding.
  624. * 3 - Forwarding. Port is learning and forwarding.
  625. * Access: RW
  626. */
  627. MLXSW_ITEM_BIT_ARRAY(reg, spms, state, 0x04, 0x400, 2);
  628. static inline void mlxsw_reg_spms_pack(char *payload, u8 local_port)
  629. {
  630. MLXSW_REG_ZERO(spms, payload);
  631. mlxsw_reg_spms_local_port_set(payload, local_port);
  632. }
  633. static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
  634. enum mlxsw_reg_spms_state state)
  635. {
  636. mlxsw_reg_spms_state_set(payload, vid, state);
  637. }
  638. /* SPVID - Switch Port VID
  639. * -----------------------
  640. * The switch port VID configures the default VID for a port.
  641. */
  642. #define MLXSW_REG_SPVID_ID 0x200E
  643. #define MLXSW_REG_SPVID_LEN 0x08
  644. MLXSW_REG_DEFINE(spvid, MLXSW_REG_SPVID_ID, MLXSW_REG_SPVID_LEN);
  645. /* reg_spvid_local_port
  646. * Local port number.
  647. * Access: Index
  648. */
  649. MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
  650. /* reg_spvid_sub_port
  651. * Virtual port within the physical port.
  652. * Should be set to 0 when virtual ports are not enabled on the port.
  653. * Access: Index
  654. */
  655. MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
  656. /* reg_spvid_pvid
  657. * Port default VID
  658. * Access: RW
  659. */
  660. MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
  661. static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
  662. {
  663. MLXSW_REG_ZERO(spvid, payload);
  664. mlxsw_reg_spvid_local_port_set(payload, local_port);
  665. mlxsw_reg_spvid_pvid_set(payload, pvid);
  666. }
  667. /* SPVM - Switch Port VLAN Membership
  668. * ----------------------------------
  669. * The Switch Port VLAN Membership register configures the VLAN membership
  670. * of a port in a VLAN denoted by VID. VLAN membership is managed per
  671. * virtual port. The register can be used to add and remove VID(s) from a port.
  672. */
  673. #define MLXSW_REG_SPVM_ID 0x200F
  674. #define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
  675. #define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
  676. #define MLXSW_REG_SPVM_REC_MAX_COUNT 255
  677. #define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
  678. MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
  679. MLXSW_REG_DEFINE(spvm, MLXSW_REG_SPVM_ID, MLXSW_REG_SPVM_LEN);
  680. /* reg_spvm_pt
  681. * Priority tagged. If this bit is set, packets forwarded to the port with
  682. * untagged VLAN membership (u bit is set) will be tagged with priority tag
  683. * (VID=0)
  684. * Access: RW
  685. */
  686. MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
  687. /* reg_spvm_pte
  688. * Priority Tagged Update Enable. On Write operations, if this bit is cleared,
  689. * the pt bit will NOT be updated. To update the pt bit, pte must be set.
  690. * Access: WO
  691. */
  692. MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
  693. /* reg_spvm_local_port
  694. * Local port number.
  695. * Access: Index
  696. */
  697. MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
  698. /* reg_spvm_sub_port
  699. * Virtual port within the physical port.
  700. * Should be set to 0 when virtual ports are not enabled on the port.
  701. * Access: Index
  702. */
  703. MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
  704. /* reg_spvm_num_rec
  705. * Number of records to update. Each record contains: i, e, u, vid.
  706. * Access: OP
  707. */
  708. MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
  709. /* reg_spvm_rec_i
  710. * Ingress membership in VLAN ID.
  711. * Access: Index
  712. */
  713. MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
  714. MLXSW_REG_SPVM_BASE_LEN, 14, 1,
  715. MLXSW_REG_SPVM_REC_LEN, 0, false);
  716. /* reg_spvm_rec_e
  717. * Egress membership in VLAN ID.
  718. * Access: Index
  719. */
  720. MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
  721. MLXSW_REG_SPVM_BASE_LEN, 13, 1,
  722. MLXSW_REG_SPVM_REC_LEN, 0, false);
  723. /* reg_spvm_rec_u
  724. * Untagged - port is an untagged member - egress transmission uses untagged
  725. * frames on VID<n>
  726. * Access: Index
  727. */
  728. MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
  729. MLXSW_REG_SPVM_BASE_LEN, 12, 1,
  730. MLXSW_REG_SPVM_REC_LEN, 0, false);
  731. /* reg_spvm_rec_vid
  732. * Egress membership in VLAN ID.
  733. * Access: Index
  734. */
  735. MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
  736. MLXSW_REG_SPVM_BASE_LEN, 0, 12,
  737. MLXSW_REG_SPVM_REC_LEN, 0, false);
  738. static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
  739. u16 vid_begin, u16 vid_end,
  740. bool is_member, bool untagged)
  741. {
  742. int size = vid_end - vid_begin + 1;
  743. int i;
  744. MLXSW_REG_ZERO(spvm, payload);
  745. mlxsw_reg_spvm_local_port_set(payload, local_port);
  746. mlxsw_reg_spvm_num_rec_set(payload, size);
  747. for (i = 0; i < size; i++) {
  748. mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
  749. mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
  750. mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
  751. mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
  752. }
  753. }
  754. /* SPAFT - Switch Port Acceptable Frame Types
  755. * ------------------------------------------
  756. * The Switch Port Acceptable Frame Types register configures the frame
  757. * admittance of the port.
  758. */
  759. #define MLXSW_REG_SPAFT_ID 0x2010
  760. #define MLXSW_REG_SPAFT_LEN 0x08
  761. MLXSW_REG_DEFINE(spaft, MLXSW_REG_SPAFT_ID, MLXSW_REG_SPAFT_LEN);
  762. /* reg_spaft_local_port
  763. * Local port number.
  764. * Access: Index
  765. *
  766. * Note: CPU port is not supported (all tag types are allowed).
  767. */
  768. MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
  769. /* reg_spaft_sub_port
  770. * Virtual port within the physical port.
  771. * Should be set to 0 when virtual ports are not enabled on the port.
  772. * Access: RW
  773. */
  774. MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
  775. /* reg_spaft_allow_untagged
  776. * When set, untagged frames on the ingress are allowed (default).
  777. * Access: RW
  778. */
  779. MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
  780. /* reg_spaft_allow_prio_tagged
  781. * When set, priority tagged frames on the ingress are allowed (default).
  782. * Access: RW
  783. */
  784. MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
  785. /* reg_spaft_allow_tagged
  786. * When set, tagged frames on the ingress are allowed (default).
  787. * Access: RW
  788. */
  789. MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
  790. static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
  791. bool allow_untagged)
  792. {
  793. MLXSW_REG_ZERO(spaft, payload);
  794. mlxsw_reg_spaft_local_port_set(payload, local_port);
  795. mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
  796. mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
  797. mlxsw_reg_spaft_allow_tagged_set(payload, true);
  798. }
  799. /* SFGC - Switch Flooding Group Configuration
  800. * ------------------------------------------
  801. * The following register controls the association of flooding tables and MIDs
  802. * to packet types used for flooding.
  803. */
  804. #define MLXSW_REG_SFGC_ID 0x2011
  805. #define MLXSW_REG_SFGC_LEN 0x10
  806. MLXSW_REG_DEFINE(sfgc, MLXSW_REG_SFGC_ID, MLXSW_REG_SFGC_LEN);
  807. enum mlxsw_reg_sfgc_type {
  808. MLXSW_REG_SFGC_TYPE_BROADCAST,
  809. MLXSW_REG_SFGC_TYPE_UNKNOWN_UNICAST,
  810. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV4,
  811. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_IPV6,
  812. MLXSW_REG_SFGC_TYPE_RESERVED,
  813. MLXSW_REG_SFGC_TYPE_UNREGISTERED_MULTICAST_NON_IP,
  814. MLXSW_REG_SFGC_TYPE_IPV4_LINK_LOCAL,
  815. MLXSW_REG_SFGC_TYPE_IPV6_ALL_HOST,
  816. MLXSW_REG_SFGC_TYPE_MAX,
  817. };
  818. /* reg_sfgc_type
  819. * The traffic type to reach the flooding table.
  820. * Access: Index
  821. */
  822. MLXSW_ITEM32(reg, sfgc, type, 0x00, 0, 4);
  823. enum mlxsw_reg_sfgc_bridge_type {
  824. MLXSW_REG_SFGC_BRIDGE_TYPE_1Q_FID = 0,
  825. MLXSW_REG_SFGC_BRIDGE_TYPE_VFID = 1,
  826. };
  827. /* reg_sfgc_bridge_type
  828. * Access: Index
  829. *
  830. * Note: SwitchX-2 only supports 802.1Q mode.
  831. */
  832. MLXSW_ITEM32(reg, sfgc, bridge_type, 0x04, 24, 3);
  833. enum mlxsw_flood_table_type {
  834. MLXSW_REG_SFGC_TABLE_TYPE_VID = 1,
  835. MLXSW_REG_SFGC_TABLE_TYPE_SINGLE = 2,
  836. MLXSW_REG_SFGC_TABLE_TYPE_ANY = 0,
  837. MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST = 3,
  838. MLXSW_REG_SFGC_TABLE_TYPE_FID = 4,
  839. };
  840. /* reg_sfgc_table_type
  841. * See mlxsw_flood_table_type
  842. * Access: RW
  843. *
  844. * Note: FID offset and FID types are not supported in SwitchX-2.
  845. */
  846. MLXSW_ITEM32(reg, sfgc, table_type, 0x04, 16, 3);
  847. /* reg_sfgc_flood_table
  848. * Flooding table index to associate with the specific type on the specific
  849. * switch partition.
  850. * Access: RW
  851. */
  852. MLXSW_ITEM32(reg, sfgc, flood_table, 0x04, 0, 6);
  853. /* reg_sfgc_mid
  854. * The multicast ID for the swid. Not supported for Spectrum
  855. * Access: RW
  856. */
  857. MLXSW_ITEM32(reg, sfgc, mid, 0x08, 0, 16);
  858. /* reg_sfgc_counter_set_type
  859. * Counter Set Type for flow counters.
  860. * Access: RW
  861. */
  862. MLXSW_ITEM32(reg, sfgc, counter_set_type, 0x0C, 24, 8);
  863. /* reg_sfgc_counter_index
  864. * Counter Index for flow counters.
  865. * Access: RW
  866. */
  867. MLXSW_ITEM32(reg, sfgc, counter_index, 0x0C, 0, 24);
  868. static inline void
  869. mlxsw_reg_sfgc_pack(char *payload, enum mlxsw_reg_sfgc_type type,
  870. enum mlxsw_reg_sfgc_bridge_type bridge_type,
  871. enum mlxsw_flood_table_type table_type,
  872. unsigned int flood_table)
  873. {
  874. MLXSW_REG_ZERO(sfgc, payload);
  875. mlxsw_reg_sfgc_type_set(payload, type);
  876. mlxsw_reg_sfgc_bridge_type_set(payload, bridge_type);
  877. mlxsw_reg_sfgc_table_type_set(payload, table_type);
  878. mlxsw_reg_sfgc_flood_table_set(payload, flood_table);
  879. mlxsw_reg_sfgc_mid_set(payload, MLXSW_PORT_MID);
  880. }
  881. /* SFTR - Switch Flooding Table Register
  882. * -------------------------------------
  883. * The switch flooding table is used for flooding packet replication. The table
  884. * defines a bit mask of ports for packet replication.
  885. */
  886. #define MLXSW_REG_SFTR_ID 0x2012
  887. #define MLXSW_REG_SFTR_LEN 0x420
  888. MLXSW_REG_DEFINE(sftr, MLXSW_REG_SFTR_ID, MLXSW_REG_SFTR_LEN);
  889. /* reg_sftr_swid
  890. * Switch partition ID with which to associate the port.
  891. * Access: Index
  892. */
  893. MLXSW_ITEM32(reg, sftr, swid, 0x00, 24, 8);
  894. /* reg_sftr_flood_table
  895. * Flooding table index to associate with the specific type on the specific
  896. * switch partition.
  897. * Access: Index
  898. */
  899. MLXSW_ITEM32(reg, sftr, flood_table, 0x00, 16, 6);
  900. /* reg_sftr_index
  901. * Index. Used as an index into the Flooding Table in case the table is
  902. * configured to use VID / FID or FID Offset.
  903. * Access: Index
  904. */
  905. MLXSW_ITEM32(reg, sftr, index, 0x00, 0, 16);
  906. /* reg_sftr_table_type
  907. * See mlxsw_flood_table_type
  908. * Access: RW
  909. */
  910. MLXSW_ITEM32(reg, sftr, table_type, 0x04, 16, 3);
  911. /* reg_sftr_range
  912. * Range of entries to update
  913. * Access: Index
  914. */
  915. MLXSW_ITEM32(reg, sftr, range, 0x04, 0, 16);
  916. /* reg_sftr_port
  917. * Local port membership (1 bit per port).
  918. * Access: RW
  919. */
  920. MLXSW_ITEM_BIT_ARRAY(reg, sftr, port, 0x20, 0x20, 1);
  921. /* reg_sftr_cpu_port_mask
  922. * CPU port mask (1 bit per port).
  923. * Access: W
  924. */
  925. MLXSW_ITEM_BIT_ARRAY(reg, sftr, port_mask, 0x220, 0x20, 1);
  926. static inline void mlxsw_reg_sftr_pack(char *payload,
  927. unsigned int flood_table,
  928. unsigned int index,
  929. enum mlxsw_flood_table_type table_type,
  930. unsigned int range, u8 port, bool set)
  931. {
  932. MLXSW_REG_ZERO(sftr, payload);
  933. mlxsw_reg_sftr_swid_set(payload, 0);
  934. mlxsw_reg_sftr_flood_table_set(payload, flood_table);
  935. mlxsw_reg_sftr_index_set(payload, index);
  936. mlxsw_reg_sftr_table_type_set(payload, table_type);
  937. mlxsw_reg_sftr_range_set(payload, range);
  938. mlxsw_reg_sftr_port_set(payload, port, set);
  939. mlxsw_reg_sftr_port_mask_set(payload, port, 1);
  940. }
  941. /* SFDF - Switch Filtering DB Flush
  942. * --------------------------------
  943. * The switch filtering DB flush register is used to flush the FDB.
  944. * Note that FDB notifications are flushed as well.
  945. */
  946. #define MLXSW_REG_SFDF_ID 0x2013
  947. #define MLXSW_REG_SFDF_LEN 0x14
  948. MLXSW_REG_DEFINE(sfdf, MLXSW_REG_SFDF_ID, MLXSW_REG_SFDF_LEN);
  949. /* reg_sfdf_swid
  950. * Switch partition ID.
  951. * Access: Index
  952. */
  953. MLXSW_ITEM32(reg, sfdf, swid, 0x00, 24, 8);
  954. enum mlxsw_reg_sfdf_flush_type {
  955. MLXSW_REG_SFDF_FLUSH_PER_SWID,
  956. MLXSW_REG_SFDF_FLUSH_PER_FID,
  957. MLXSW_REG_SFDF_FLUSH_PER_PORT,
  958. MLXSW_REG_SFDF_FLUSH_PER_PORT_AND_FID,
  959. MLXSW_REG_SFDF_FLUSH_PER_LAG,
  960. MLXSW_REG_SFDF_FLUSH_PER_LAG_AND_FID,
  961. };
  962. /* reg_sfdf_flush_type
  963. * Flush type.
  964. * 0 - All SWID dynamic entries are flushed.
  965. * 1 - All FID dynamic entries are flushed.
  966. * 2 - All dynamic entries pointing to port are flushed.
  967. * 3 - All FID dynamic entries pointing to port are flushed.
  968. * 4 - All dynamic entries pointing to LAG are flushed.
  969. * 5 - All FID dynamic entries pointing to LAG are flushed.
  970. * Access: RW
  971. */
  972. MLXSW_ITEM32(reg, sfdf, flush_type, 0x04, 28, 4);
  973. /* reg_sfdf_flush_static
  974. * Static.
  975. * 0 - Flush only dynamic entries.
  976. * 1 - Flush both dynamic and static entries.
  977. * Access: RW
  978. */
  979. MLXSW_ITEM32(reg, sfdf, flush_static, 0x04, 24, 1);
  980. static inline void mlxsw_reg_sfdf_pack(char *payload,
  981. enum mlxsw_reg_sfdf_flush_type type)
  982. {
  983. MLXSW_REG_ZERO(sfdf, payload);
  984. mlxsw_reg_sfdf_flush_type_set(payload, type);
  985. mlxsw_reg_sfdf_flush_static_set(payload, true);
  986. }
  987. /* reg_sfdf_fid
  988. * FID to flush.
  989. * Access: RW
  990. */
  991. MLXSW_ITEM32(reg, sfdf, fid, 0x0C, 0, 16);
  992. /* reg_sfdf_system_port
  993. * Port to flush.
  994. * Access: RW
  995. */
  996. MLXSW_ITEM32(reg, sfdf, system_port, 0x0C, 0, 16);
  997. /* reg_sfdf_port_fid_system_port
  998. * Port to flush, pointed to by FID.
  999. * Access: RW
  1000. */
  1001. MLXSW_ITEM32(reg, sfdf, port_fid_system_port, 0x08, 0, 16);
  1002. /* reg_sfdf_lag_id
  1003. * LAG ID to flush.
  1004. * Access: RW
  1005. */
  1006. MLXSW_ITEM32(reg, sfdf, lag_id, 0x0C, 0, 10);
  1007. /* reg_sfdf_lag_fid_lag_id
  1008. * LAG ID to flush, pointed to by FID.
  1009. * Access: RW
  1010. */
  1011. MLXSW_ITEM32(reg, sfdf, lag_fid_lag_id, 0x08, 0, 10);
  1012. /* SLDR - Switch LAG Descriptor Register
  1013. * -----------------------------------------
  1014. * The switch LAG descriptor register is populated by LAG descriptors.
  1015. * Each LAG descriptor is indexed by lag_id. The LAG ID runs from 0 to
  1016. * max_lag-1.
  1017. */
  1018. #define MLXSW_REG_SLDR_ID 0x2014
  1019. #define MLXSW_REG_SLDR_LEN 0x0C /* counting in only one port in list */
  1020. MLXSW_REG_DEFINE(sldr, MLXSW_REG_SLDR_ID, MLXSW_REG_SLDR_LEN);
  1021. enum mlxsw_reg_sldr_op {
  1022. /* Indicates a creation of a new LAG-ID, lag_id must be valid */
  1023. MLXSW_REG_SLDR_OP_LAG_CREATE,
  1024. MLXSW_REG_SLDR_OP_LAG_DESTROY,
  1025. /* Ports that appear in the list have the Distributor enabled */
  1026. MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST,
  1027. /* Removes ports from the disributor list */
  1028. MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST,
  1029. };
  1030. /* reg_sldr_op
  1031. * Operation.
  1032. * Access: RW
  1033. */
  1034. MLXSW_ITEM32(reg, sldr, op, 0x00, 29, 3);
  1035. /* reg_sldr_lag_id
  1036. * LAG identifier. The lag_id is the index into the LAG descriptor table.
  1037. * Access: Index
  1038. */
  1039. MLXSW_ITEM32(reg, sldr, lag_id, 0x00, 0, 10);
  1040. static inline void mlxsw_reg_sldr_lag_create_pack(char *payload, u8 lag_id)
  1041. {
  1042. MLXSW_REG_ZERO(sldr, payload);
  1043. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_CREATE);
  1044. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1045. }
  1046. static inline void mlxsw_reg_sldr_lag_destroy_pack(char *payload, u8 lag_id)
  1047. {
  1048. MLXSW_REG_ZERO(sldr, payload);
  1049. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_DESTROY);
  1050. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1051. }
  1052. /* reg_sldr_num_ports
  1053. * The number of member ports of the LAG.
  1054. * Reserved for Create / Destroy operations
  1055. * For Add / Remove operations - indicates the number of ports in the list.
  1056. * Access: RW
  1057. */
  1058. MLXSW_ITEM32(reg, sldr, num_ports, 0x04, 24, 8);
  1059. /* reg_sldr_system_port
  1060. * System port.
  1061. * Access: RW
  1062. */
  1063. MLXSW_ITEM32_INDEXED(reg, sldr, system_port, 0x08, 0, 16, 4, 0, false);
  1064. static inline void mlxsw_reg_sldr_lag_add_port_pack(char *payload, u8 lag_id,
  1065. u8 local_port)
  1066. {
  1067. MLXSW_REG_ZERO(sldr, payload);
  1068. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_ADD_PORT_LIST);
  1069. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1070. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1071. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1072. }
  1073. static inline void mlxsw_reg_sldr_lag_remove_port_pack(char *payload, u8 lag_id,
  1074. u8 local_port)
  1075. {
  1076. MLXSW_REG_ZERO(sldr, payload);
  1077. mlxsw_reg_sldr_op_set(payload, MLXSW_REG_SLDR_OP_LAG_REMOVE_PORT_LIST);
  1078. mlxsw_reg_sldr_lag_id_set(payload, lag_id);
  1079. mlxsw_reg_sldr_num_ports_set(payload, 1);
  1080. mlxsw_reg_sldr_system_port_set(payload, 0, local_port);
  1081. }
  1082. /* SLCR - Switch LAG Configuration 2 Register
  1083. * -------------------------------------------
  1084. * The Switch LAG Configuration register is used for configuring the
  1085. * LAG properties of the switch.
  1086. */
  1087. #define MLXSW_REG_SLCR_ID 0x2015
  1088. #define MLXSW_REG_SLCR_LEN 0x10
  1089. MLXSW_REG_DEFINE(slcr, MLXSW_REG_SLCR_ID, MLXSW_REG_SLCR_LEN);
  1090. enum mlxsw_reg_slcr_pp {
  1091. /* Global Configuration (for all ports) */
  1092. MLXSW_REG_SLCR_PP_GLOBAL,
  1093. /* Per port configuration, based on local_port field */
  1094. MLXSW_REG_SLCR_PP_PER_PORT,
  1095. };
  1096. /* reg_slcr_pp
  1097. * Per Port Configuration
  1098. * Note: Reading at Global mode results in reading port 1 configuration.
  1099. * Access: Index
  1100. */
  1101. MLXSW_ITEM32(reg, slcr, pp, 0x00, 24, 1);
  1102. /* reg_slcr_local_port
  1103. * Local port number
  1104. * Supported from CPU port
  1105. * Not supported from router port
  1106. * Reserved when pp = Global Configuration
  1107. * Access: Index
  1108. */
  1109. MLXSW_ITEM32(reg, slcr, local_port, 0x00, 16, 8);
  1110. enum mlxsw_reg_slcr_type {
  1111. MLXSW_REG_SLCR_TYPE_CRC, /* default */
  1112. MLXSW_REG_SLCR_TYPE_XOR,
  1113. MLXSW_REG_SLCR_TYPE_RANDOM,
  1114. };
  1115. /* reg_slcr_type
  1116. * Hash type
  1117. * Access: RW
  1118. */
  1119. MLXSW_ITEM32(reg, slcr, type, 0x00, 0, 4);
  1120. /* Ingress port */
  1121. #define MLXSW_REG_SLCR_LAG_HASH_IN_PORT BIT(0)
  1122. /* SMAC - for IPv4 and IPv6 packets */
  1123. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_IP BIT(1)
  1124. /* SMAC - for non-IP packets */
  1125. #define MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP BIT(2)
  1126. #define MLXSW_REG_SLCR_LAG_HASH_SMAC \
  1127. (MLXSW_REG_SLCR_LAG_HASH_SMAC_IP | \
  1128. MLXSW_REG_SLCR_LAG_HASH_SMAC_NONIP)
  1129. /* DMAC - for IPv4 and IPv6 packets */
  1130. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_IP BIT(3)
  1131. /* DMAC - for non-IP packets */
  1132. #define MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP BIT(4)
  1133. #define MLXSW_REG_SLCR_LAG_HASH_DMAC \
  1134. (MLXSW_REG_SLCR_LAG_HASH_DMAC_IP | \
  1135. MLXSW_REG_SLCR_LAG_HASH_DMAC_NONIP)
  1136. /* Ethertype - for IPv4 and IPv6 packets */
  1137. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP BIT(5)
  1138. /* Ethertype - for non-IP packets */
  1139. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP BIT(6)
  1140. #define MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE \
  1141. (MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_IP | \
  1142. MLXSW_REG_SLCR_LAG_HASH_ETHERTYPE_NONIP)
  1143. /* VLAN ID - for IPv4 and IPv6 packets */
  1144. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_IP BIT(7)
  1145. /* VLAN ID - for non-IP packets */
  1146. #define MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP BIT(8)
  1147. #define MLXSW_REG_SLCR_LAG_HASH_VLANID \
  1148. (MLXSW_REG_SLCR_LAG_HASH_VLANID_IP | \
  1149. MLXSW_REG_SLCR_LAG_HASH_VLANID_NONIP)
  1150. /* Source IP address (can be IPv4 or IPv6) */
  1151. #define MLXSW_REG_SLCR_LAG_HASH_SIP BIT(9)
  1152. /* Destination IP address (can be IPv4 or IPv6) */
  1153. #define MLXSW_REG_SLCR_LAG_HASH_DIP BIT(10)
  1154. /* TCP/UDP source port */
  1155. #define MLXSW_REG_SLCR_LAG_HASH_SPORT BIT(11)
  1156. /* TCP/UDP destination port*/
  1157. #define MLXSW_REG_SLCR_LAG_HASH_DPORT BIT(12)
  1158. /* IPv4 Protocol/IPv6 Next Header */
  1159. #define MLXSW_REG_SLCR_LAG_HASH_IPPROTO BIT(13)
  1160. /* IPv6 Flow label */
  1161. #define MLXSW_REG_SLCR_LAG_HASH_FLOWLABEL BIT(14)
  1162. /* SID - FCoE source ID */
  1163. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_SID BIT(15)
  1164. /* DID - FCoE destination ID */
  1165. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_DID BIT(16)
  1166. /* OXID - FCoE originator exchange ID */
  1167. #define MLXSW_REG_SLCR_LAG_HASH_FCOE_OXID BIT(17)
  1168. /* Destination QP number - for RoCE packets */
  1169. #define MLXSW_REG_SLCR_LAG_HASH_ROCE_DQP BIT(19)
  1170. /* reg_slcr_lag_hash
  1171. * LAG hashing configuration. This is a bitmask, in which each set
  1172. * bit includes the corresponding item in the LAG hash calculation.
  1173. * The default lag_hash contains SMAC, DMAC, VLANID and
  1174. * Ethertype (for all packet types).
  1175. * Access: RW
  1176. */
  1177. MLXSW_ITEM32(reg, slcr, lag_hash, 0x04, 0, 20);
  1178. static inline void mlxsw_reg_slcr_pack(char *payload, u16 lag_hash)
  1179. {
  1180. MLXSW_REG_ZERO(slcr, payload);
  1181. mlxsw_reg_slcr_pp_set(payload, MLXSW_REG_SLCR_PP_GLOBAL);
  1182. mlxsw_reg_slcr_type_set(payload, MLXSW_REG_SLCR_TYPE_CRC);
  1183. mlxsw_reg_slcr_lag_hash_set(payload, lag_hash);
  1184. }
  1185. /* SLCOR - Switch LAG Collector Register
  1186. * -------------------------------------
  1187. * The Switch LAG Collector register controls the Local Port membership
  1188. * in a LAG and enablement of the collector.
  1189. */
  1190. #define MLXSW_REG_SLCOR_ID 0x2016
  1191. #define MLXSW_REG_SLCOR_LEN 0x10
  1192. MLXSW_REG_DEFINE(slcor, MLXSW_REG_SLCOR_ID, MLXSW_REG_SLCOR_LEN);
  1193. enum mlxsw_reg_slcor_col {
  1194. /* Port is added with collector disabled */
  1195. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT,
  1196. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED,
  1197. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_DISABLED,
  1198. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT,
  1199. };
  1200. /* reg_slcor_col
  1201. * Collector configuration
  1202. * Access: RW
  1203. */
  1204. MLXSW_ITEM32(reg, slcor, col, 0x00, 30, 2);
  1205. /* reg_slcor_local_port
  1206. * Local port number
  1207. * Not supported for CPU port
  1208. * Access: Index
  1209. */
  1210. MLXSW_ITEM32(reg, slcor, local_port, 0x00, 16, 8);
  1211. /* reg_slcor_lag_id
  1212. * LAG Identifier. Index into the LAG descriptor table.
  1213. * Access: Index
  1214. */
  1215. MLXSW_ITEM32(reg, slcor, lag_id, 0x00, 0, 10);
  1216. /* reg_slcor_port_index
  1217. * Port index in the LAG list. Only valid on Add Port to LAG col.
  1218. * Valid range is from 0 to cap_max_lag_members-1
  1219. * Access: RW
  1220. */
  1221. MLXSW_ITEM32(reg, slcor, port_index, 0x04, 0, 10);
  1222. static inline void mlxsw_reg_slcor_pack(char *payload,
  1223. u8 local_port, u16 lag_id,
  1224. enum mlxsw_reg_slcor_col col)
  1225. {
  1226. MLXSW_REG_ZERO(slcor, payload);
  1227. mlxsw_reg_slcor_col_set(payload, col);
  1228. mlxsw_reg_slcor_local_port_set(payload, local_port);
  1229. mlxsw_reg_slcor_lag_id_set(payload, lag_id);
  1230. }
  1231. static inline void mlxsw_reg_slcor_port_add_pack(char *payload,
  1232. u8 local_port, u16 lag_id,
  1233. u8 port_index)
  1234. {
  1235. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1236. MLXSW_REG_SLCOR_COL_LAG_ADD_PORT);
  1237. mlxsw_reg_slcor_port_index_set(payload, port_index);
  1238. }
  1239. static inline void mlxsw_reg_slcor_port_remove_pack(char *payload,
  1240. u8 local_port, u16 lag_id)
  1241. {
  1242. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1243. MLXSW_REG_SLCOR_COL_LAG_REMOVE_PORT);
  1244. }
  1245. static inline void mlxsw_reg_slcor_col_enable_pack(char *payload,
  1246. u8 local_port, u16 lag_id)
  1247. {
  1248. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1249. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1250. }
  1251. static inline void mlxsw_reg_slcor_col_disable_pack(char *payload,
  1252. u8 local_port, u16 lag_id)
  1253. {
  1254. mlxsw_reg_slcor_pack(payload, local_port, lag_id,
  1255. MLXSW_REG_SLCOR_COL_LAG_COLLECTOR_ENABLED);
  1256. }
  1257. /* SPMLR - Switch Port MAC Learning Register
  1258. * -----------------------------------------
  1259. * Controls the Switch MAC learning policy per port.
  1260. */
  1261. #define MLXSW_REG_SPMLR_ID 0x2018
  1262. #define MLXSW_REG_SPMLR_LEN 0x8
  1263. MLXSW_REG_DEFINE(spmlr, MLXSW_REG_SPMLR_ID, MLXSW_REG_SPMLR_LEN);
  1264. /* reg_spmlr_local_port
  1265. * Local port number.
  1266. * Access: Index
  1267. */
  1268. MLXSW_ITEM32(reg, spmlr, local_port, 0x00, 16, 8);
  1269. /* reg_spmlr_sub_port
  1270. * Virtual port within the physical port.
  1271. * Should be set to 0 when virtual ports are not enabled on the port.
  1272. * Access: Index
  1273. */
  1274. MLXSW_ITEM32(reg, spmlr, sub_port, 0x00, 8, 8);
  1275. enum mlxsw_reg_spmlr_learn_mode {
  1276. MLXSW_REG_SPMLR_LEARN_MODE_DISABLE = 0,
  1277. MLXSW_REG_SPMLR_LEARN_MODE_ENABLE = 2,
  1278. MLXSW_REG_SPMLR_LEARN_MODE_SEC = 3,
  1279. };
  1280. /* reg_spmlr_learn_mode
  1281. * Learning mode on the port.
  1282. * 0 - Learning disabled.
  1283. * 2 - Learning enabled.
  1284. * 3 - Security mode.
  1285. *
  1286. * In security mode the switch does not learn MACs on the port, but uses the
  1287. * SMAC to see if it exists on another ingress port. If so, the packet is
  1288. * classified as a bad packet and is discarded unless the software registers
  1289. * to receive port security error packets usign HPKT.
  1290. */
  1291. MLXSW_ITEM32(reg, spmlr, learn_mode, 0x04, 30, 2);
  1292. static inline void mlxsw_reg_spmlr_pack(char *payload, u8 local_port,
  1293. enum mlxsw_reg_spmlr_learn_mode mode)
  1294. {
  1295. MLXSW_REG_ZERO(spmlr, payload);
  1296. mlxsw_reg_spmlr_local_port_set(payload, local_port);
  1297. mlxsw_reg_spmlr_sub_port_set(payload, 0);
  1298. mlxsw_reg_spmlr_learn_mode_set(payload, mode);
  1299. }
  1300. /* SVFA - Switch VID to FID Allocation Register
  1301. * --------------------------------------------
  1302. * Controls the VID to FID mapping and {Port, VID} to FID mapping for
  1303. * virtualized ports.
  1304. */
  1305. #define MLXSW_REG_SVFA_ID 0x201C
  1306. #define MLXSW_REG_SVFA_LEN 0x10
  1307. MLXSW_REG_DEFINE(svfa, MLXSW_REG_SVFA_ID, MLXSW_REG_SVFA_LEN);
  1308. /* reg_svfa_swid
  1309. * Switch partition ID.
  1310. * Access: Index
  1311. */
  1312. MLXSW_ITEM32(reg, svfa, swid, 0x00, 24, 8);
  1313. /* reg_svfa_local_port
  1314. * Local port number.
  1315. * Access: Index
  1316. *
  1317. * Note: Reserved for 802.1Q FIDs.
  1318. */
  1319. MLXSW_ITEM32(reg, svfa, local_port, 0x00, 16, 8);
  1320. enum mlxsw_reg_svfa_mt {
  1321. MLXSW_REG_SVFA_MT_VID_TO_FID,
  1322. MLXSW_REG_SVFA_MT_PORT_VID_TO_FID,
  1323. };
  1324. /* reg_svfa_mapping_table
  1325. * Mapping table:
  1326. * 0 - VID to FID
  1327. * 1 - {Port, VID} to FID
  1328. * Access: Index
  1329. *
  1330. * Note: Reserved for SwitchX-2.
  1331. */
  1332. MLXSW_ITEM32(reg, svfa, mapping_table, 0x00, 8, 3);
  1333. /* reg_svfa_v
  1334. * Valid.
  1335. * Valid if set.
  1336. * Access: RW
  1337. *
  1338. * Note: Reserved for SwitchX-2.
  1339. */
  1340. MLXSW_ITEM32(reg, svfa, v, 0x00, 0, 1);
  1341. /* reg_svfa_fid
  1342. * Filtering ID.
  1343. * Access: RW
  1344. */
  1345. MLXSW_ITEM32(reg, svfa, fid, 0x04, 16, 16);
  1346. /* reg_svfa_vid
  1347. * VLAN ID.
  1348. * Access: Index
  1349. */
  1350. MLXSW_ITEM32(reg, svfa, vid, 0x04, 0, 12);
  1351. /* reg_svfa_counter_set_type
  1352. * Counter set type for flow counters.
  1353. * Access: RW
  1354. *
  1355. * Note: Reserved for SwitchX-2.
  1356. */
  1357. MLXSW_ITEM32(reg, svfa, counter_set_type, 0x08, 24, 8);
  1358. /* reg_svfa_counter_index
  1359. * Counter index for flow counters.
  1360. * Access: RW
  1361. *
  1362. * Note: Reserved for SwitchX-2.
  1363. */
  1364. MLXSW_ITEM32(reg, svfa, counter_index, 0x08, 0, 24);
  1365. static inline void mlxsw_reg_svfa_pack(char *payload, u8 local_port,
  1366. enum mlxsw_reg_svfa_mt mt, bool valid,
  1367. u16 fid, u16 vid)
  1368. {
  1369. MLXSW_REG_ZERO(svfa, payload);
  1370. local_port = mt == MLXSW_REG_SVFA_MT_VID_TO_FID ? 0 : local_port;
  1371. mlxsw_reg_svfa_swid_set(payload, 0);
  1372. mlxsw_reg_svfa_local_port_set(payload, local_port);
  1373. mlxsw_reg_svfa_mapping_table_set(payload, mt);
  1374. mlxsw_reg_svfa_v_set(payload, valid);
  1375. mlxsw_reg_svfa_fid_set(payload, fid);
  1376. mlxsw_reg_svfa_vid_set(payload, vid);
  1377. }
  1378. /* SVPE - Switch Virtual-Port Enabling Register
  1379. * --------------------------------------------
  1380. * Enables port virtualization.
  1381. */
  1382. #define MLXSW_REG_SVPE_ID 0x201E
  1383. #define MLXSW_REG_SVPE_LEN 0x4
  1384. MLXSW_REG_DEFINE(svpe, MLXSW_REG_SVPE_ID, MLXSW_REG_SVPE_LEN);
  1385. /* reg_svpe_local_port
  1386. * Local port number
  1387. * Access: Index
  1388. *
  1389. * Note: CPU port is not supported (uses VLAN mode only).
  1390. */
  1391. MLXSW_ITEM32(reg, svpe, local_port, 0x00, 16, 8);
  1392. /* reg_svpe_vp_en
  1393. * Virtual port enable.
  1394. * 0 - Disable, VLAN mode (VID to FID).
  1395. * 1 - Enable, Virtual port mode ({Port, VID} to FID).
  1396. * Access: RW
  1397. */
  1398. MLXSW_ITEM32(reg, svpe, vp_en, 0x00, 8, 1);
  1399. static inline void mlxsw_reg_svpe_pack(char *payload, u8 local_port,
  1400. bool enable)
  1401. {
  1402. MLXSW_REG_ZERO(svpe, payload);
  1403. mlxsw_reg_svpe_local_port_set(payload, local_port);
  1404. mlxsw_reg_svpe_vp_en_set(payload, enable);
  1405. }
  1406. /* SFMR - Switch FID Management Register
  1407. * -------------------------------------
  1408. * Creates and configures FIDs.
  1409. */
  1410. #define MLXSW_REG_SFMR_ID 0x201F
  1411. #define MLXSW_REG_SFMR_LEN 0x18
  1412. MLXSW_REG_DEFINE(sfmr, MLXSW_REG_SFMR_ID, MLXSW_REG_SFMR_LEN);
  1413. enum mlxsw_reg_sfmr_op {
  1414. MLXSW_REG_SFMR_OP_CREATE_FID,
  1415. MLXSW_REG_SFMR_OP_DESTROY_FID,
  1416. };
  1417. /* reg_sfmr_op
  1418. * Operation.
  1419. * 0 - Create or edit FID.
  1420. * 1 - Destroy FID.
  1421. * Access: WO
  1422. */
  1423. MLXSW_ITEM32(reg, sfmr, op, 0x00, 24, 4);
  1424. /* reg_sfmr_fid
  1425. * Filtering ID.
  1426. * Access: Index
  1427. */
  1428. MLXSW_ITEM32(reg, sfmr, fid, 0x00, 0, 16);
  1429. /* reg_sfmr_fid_offset
  1430. * FID offset.
  1431. * Used to point into the flooding table selected by SFGC register if
  1432. * the table is of type FID-Offset. Otherwise, this field is reserved.
  1433. * Access: RW
  1434. */
  1435. MLXSW_ITEM32(reg, sfmr, fid_offset, 0x08, 0, 16);
  1436. /* reg_sfmr_vtfp
  1437. * Valid Tunnel Flood Pointer.
  1438. * If not set, then nve_tunnel_flood_ptr is reserved and considered NULL.
  1439. * Access: RW
  1440. *
  1441. * Note: Reserved for 802.1Q FIDs.
  1442. */
  1443. MLXSW_ITEM32(reg, sfmr, vtfp, 0x0C, 31, 1);
  1444. /* reg_sfmr_nve_tunnel_flood_ptr
  1445. * Underlay Flooding and BC Pointer.
  1446. * Used as a pointer to the first entry of the group based link lists of
  1447. * flooding or BC entries (for NVE tunnels).
  1448. * Access: RW
  1449. */
  1450. MLXSW_ITEM32(reg, sfmr, nve_tunnel_flood_ptr, 0x0C, 0, 24);
  1451. /* reg_sfmr_vv
  1452. * VNI Valid.
  1453. * If not set, then vni is reserved.
  1454. * Access: RW
  1455. *
  1456. * Note: Reserved for 802.1Q FIDs.
  1457. */
  1458. MLXSW_ITEM32(reg, sfmr, vv, 0x10, 31, 1);
  1459. /* reg_sfmr_vni
  1460. * Virtual Network Identifier.
  1461. * Access: RW
  1462. *
  1463. * Note: A given VNI can only be assigned to one FID.
  1464. */
  1465. MLXSW_ITEM32(reg, sfmr, vni, 0x10, 0, 24);
  1466. static inline void mlxsw_reg_sfmr_pack(char *payload,
  1467. enum mlxsw_reg_sfmr_op op, u16 fid,
  1468. u16 fid_offset)
  1469. {
  1470. MLXSW_REG_ZERO(sfmr, payload);
  1471. mlxsw_reg_sfmr_op_set(payload, op);
  1472. mlxsw_reg_sfmr_fid_set(payload, fid);
  1473. mlxsw_reg_sfmr_fid_offset_set(payload, fid_offset);
  1474. mlxsw_reg_sfmr_vtfp_set(payload, false);
  1475. mlxsw_reg_sfmr_vv_set(payload, false);
  1476. }
  1477. /* SPVMLR - Switch Port VLAN MAC Learning Register
  1478. * -----------------------------------------------
  1479. * Controls the switch MAC learning policy per {Port, VID}.
  1480. */
  1481. #define MLXSW_REG_SPVMLR_ID 0x2020
  1482. #define MLXSW_REG_SPVMLR_BASE_LEN 0x04 /* base length, without records */
  1483. #define MLXSW_REG_SPVMLR_REC_LEN 0x04 /* record length */
  1484. #define MLXSW_REG_SPVMLR_REC_MAX_COUNT 255
  1485. #define MLXSW_REG_SPVMLR_LEN (MLXSW_REG_SPVMLR_BASE_LEN + \
  1486. MLXSW_REG_SPVMLR_REC_LEN * \
  1487. MLXSW_REG_SPVMLR_REC_MAX_COUNT)
  1488. MLXSW_REG_DEFINE(spvmlr, MLXSW_REG_SPVMLR_ID, MLXSW_REG_SPVMLR_LEN);
  1489. /* reg_spvmlr_local_port
  1490. * Local ingress port.
  1491. * Access: Index
  1492. *
  1493. * Note: CPU port is not supported.
  1494. */
  1495. MLXSW_ITEM32(reg, spvmlr, local_port, 0x00, 16, 8);
  1496. /* reg_spvmlr_num_rec
  1497. * Number of records to update.
  1498. * Access: OP
  1499. */
  1500. MLXSW_ITEM32(reg, spvmlr, num_rec, 0x00, 0, 8);
  1501. /* reg_spvmlr_rec_learn_enable
  1502. * 0 - Disable learning for {Port, VID}.
  1503. * 1 - Enable learning for {Port, VID}.
  1504. * Access: RW
  1505. */
  1506. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_learn_enable, MLXSW_REG_SPVMLR_BASE_LEN,
  1507. 31, 1, MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1508. /* reg_spvmlr_rec_vid
  1509. * VLAN ID to be added/removed from port or for querying.
  1510. * Access: Index
  1511. */
  1512. MLXSW_ITEM32_INDEXED(reg, spvmlr, rec_vid, MLXSW_REG_SPVMLR_BASE_LEN, 0, 12,
  1513. MLXSW_REG_SPVMLR_REC_LEN, 0x00, false);
  1514. static inline void mlxsw_reg_spvmlr_pack(char *payload, u8 local_port,
  1515. u16 vid_begin, u16 vid_end,
  1516. bool learn_enable)
  1517. {
  1518. int num_rec = vid_end - vid_begin + 1;
  1519. int i;
  1520. WARN_ON(num_rec < 1 || num_rec > MLXSW_REG_SPVMLR_REC_MAX_COUNT);
  1521. MLXSW_REG_ZERO(spvmlr, payload);
  1522. mlxsw_reg_spvmlr_local_port_set(payload, local_port);
  1523. mlxsw_reg_spvmlr_num_rec_set(payload, num_rec);
  1524. for (i = 0; i < num_rec; i++) {
  1525. mlxsw_reg_spvmlr_rec_learn_enable_set(payload, i, learn_enable);
  1526. mlxsw_reg_spvmlr_rec_vid_set(payload, i, vid_begin + i);
  1527. }
  1528. }
  1529. /* PPBT - Policy-Engine Port Binding Table
  1530. * ---------------------------------------
  1531. * This register is used for configuration of the Port Binding Table.
  1532. */
  1533. #define MLXSW_REG_PPBT_ID 0x3002
  1534. #define MLXSW_REG_PPBT_LEN 0x14
  1535. MLXSW_REG_DEFINE(ppbt, MLXSW_REG_PPBT_ID, MLXSW_REG_PPBT_LEN);
  1536. enum mlxsw_reg_pxbt_e {
  1537. MLXSW_REG_PXBT_E_IACL,
  1538. MLXSW_REG_PXBT_E_EACL,
  1539. };
  1540. /* reg_ppbt_e
  1541. * Access: Index
  1542. */
  1543. MLXSW_ITEM32(reg, ppbt, e, 0x00, 31, 1);
  1544. enum mlxsw_reg_pxbt_op {
  1545. MLXSW_REG_PXBT_OP_BIND,
  1546. MLXSW_REG_PXBT_OP_UNBIND,
  1547. };
  1548. /* reg_ppbt_op
  1549. * Access: RW
  1550. */
  1551. MLXSW_ITEM32(reg, ppbt, op, 0x00, 28, 3);
  1552. /* reg_ppbt_local_port
  1553. * Local port. Not including CPU port.
  1554. * Access: Index
  1555. */
  1556. MLXSW_ITEM32(reg, ppbt, local_port, 0x00, 16, 8);
  1557. /* reg_ppbt_g
  1558. * group - When set, the binding is of an ACL group. When cleared,
  1559. * the binding is of an ACL.
  1560. * Must be set to 1 for Spectrum.
  1561. * Access: RW
  1562. */
  1563. MLXSW_ITEM32(reg, ppbt, g, 0x10, 31, 1);
  1564. /* reg_ppbt_acl_info
  1565. * ACL/ACL group identifier. If the g bit is set, this field should hold
  1566. * the acl_group_id, else it should hold the acl_id.
  1567. * Access: RW
  1568. */
  1569. MLXSW_ITEM32(reg, ppbt, acl_info, 0x10, 0, 16);
  1570. static inline void mlxsw_reg_ppbt_pack(char *payload, enum mlxsw_reg_pxbt_e e,
  1571. enum mlxsw_reg_pxbt_op op,
  1572. u8 local_port, u16 acl_info)
  1573. {
  1574. MLXSW_REG_ZERO(ppbt, payload);
  1575. mlxsw_reg_ppbt_e_set(payload, e);
  1576. mlxsw_reg_ppbt_op_set(payload, op);
  1577. mlxsw_reg_ppbt_local_port_set(payload, local_port);
  1578. mlxsw_reg_ppbt_g_set(payload, true);
  1579. mlxsw_reg_ppbt_acl_info_set(payload, acl_info);
  1580. }
  1581. /* PACL - Policy-Engine ACL Register
  1582. * ---------------------------------
  1583. * This register is used for configuration of the ACL.
  1584. */
  1585. #define MLXSW_REG_PACL_ID 0x3004
  1586. #define MLXSW_REG_PACL_LEN 0x70
  1587. MLXSW_REG_DEFINE(pacl, MLXSW_REG_PACL_ID, MLXSW_REG_PACL_LEN);
  1588. /* reg_pacl_v
  1589. * Valid. Setting the v bit makes the ACL valid. It should not be cleared
  1590. * while the ACL is bounded to either a port, VLAN or ACL rule.
  1591. * Access: RW
  1592. */
  1593. MLXSW_ITEM32(reg, pacl, v, 0x00, 24, 1);
  1594. /* reg_pacl_acl_id
  1595. * An identifier representing the ACL (managed by software)
  1596. * Range 0 .. cap_max_acl_regions - 1
  1597. * Access: Index
  1598. */
  1599. MLXSW_ITEM32(reg, pacl, acl_id, 0x08, 0, 16);
  1600. #define MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN 16
  1601. /* reg_pacl_tcam_region_info
  1602. * Opaque object that represents a TCAM region.
  1603. * Obtained through PTAR register.
  1604. * Access: RW
  1605. */
  1606. MLXSW_ITEM_BUF(reg, pacl, tcam_region_info, 0x30,
  1607. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1608. static inline void mlxsw_reg_pacl_pack(char *payload, u16 acl_id,
  1609. bool valid, const char *tcam_region_info)
  1610. {
  1611. MLXSW_REG_ZERO(pacl, payload);
  1612. mlxsw_reg_pacl_acl_id_set(payload, acl_id);
  1613. mlxsw_reg_pacl_v_set(payload, valid);
  1614. mlxsw_reg_pacl_tcam_region_info_memcpy_to(payload, tcam_region_info);
  1615. }
  1616. /* PAGT - Policy-Engine ACL Group Table
  1617. * ------------------------------------
  1618. * This register is used for configuration of the ACL Group Table.
  1619. */
  1620. #define MLXSW_REG_PAGT_ID 0x3005
  1621. #define MLXSW_REG_PAGT_BASE_LEN 0x30
  1622. #define MLXSW_REG_PAGT_ACL_LEN 4
  1623. #define MLXSW_REG_PAGT_ACL_MAX_NUM 16
  1624. #define MLXSW_REG_PAGT_LEN (MLXSW_REG_PAGT_BASE_LEN + \
  1625. MLXSW_REG_PAGT_ACL_MAX_NUM * MLXSW_REG_PAGT_ACL_LEN)
  1626. MLXSW_REG_DEFINE(pagt, MLXSW_REG_PAGT_ID, MLXSW_REG_PAGT_LEN);
  1627. /* reg_pagt_size
  1628. * Number of ACLs in the group.
  1629. * Size 0 invalidates a group.
  1630. * Range 0 .. cap_max_acl_group_size (hard coded to 16 for now)
  1631. * Total number of ACLs in all groups must be lower or equal
  1632. * to cap_max_acl_tot_groups
  1633. * Note: a group which is binded must not be invalidated
  1634. * Access: Index
  1635. */
  1636. MLXSW_ITEM32(reg, pagt, size, 0x00, 0, 8);
  1637. /* reg_pagt_acl_group_id
  1638. * An identifier (numbered from 0..cap_max_acl_groups-1) representing
  1639. * the ACL Group identifier (managed by software).
  1640. * Access: Index
  1641. */
  1642. MLXSW_ITEM32(reg, pagt, acl_group_id, 0x08, 0, 16);
  1643. /* reg_pagt_acl_id
  1644. * ACL identifier
  1645. * Access: RW
  1646. */
  1647. MLXSW_ITEM32_INDEXED(reg, pagt, acl_id, 0x30, 0, 16, 0x04, 0x00, false);
  1648. static inline void mlxsw_reg_pagt_pack(char *payload, u16 acl_group_id)
  1649. {
  1650. MLXSW_REG_ZERO(pagt, payload);
  1651. mlxsw_reg_pagt_acl_group_id_set(payload, acl_group_id);
  1652. }
  1653. static inline void mlxsw_reg_pagt_acl_id_pack(char *payload, int index,
  1654. u16 acl_id)
  1655. {
  1656. u8 size = mlxsw_reg_pagt_size_get(payload);
  1657. if (index >= size)
  1658. mlxsw_reg_pagt_size_set(payload, index + 1);
  1659. mlxsw_reg_pagt_acl_id_set(payload, index, acl_id);
  1660. }
  1661. /* PTAR - Policy-Engine TCAM Allocation Register
  1662. * ---------------------------------------------
  1663. * This register is used for allocation of regions in the TCAM.
  1664. * Note: Query method is not supported on this register.
  1665. */
  1666. #define MLXSW_REG_PTAR_ID 0x3006
  1667. #define MLXSW_REG_PTAR_BASE_LEN 0x20
  1668. #define MLXSW_REG_PTAR_KEY_ID_LEN 1
  1669. #define MLXSW_REG_PTAR_KEY_ID_MAX_NUM 16
  1670. #define MLXSW_REG_PTAR_LEN (MLXSW_REG_PTAR_BASE_LEN + \
  1671. MLXSW_REG_PTAR_KEY_ID_MAX_NUM * MLXSW_REG_PTAR_KEY_ID_LEN)
  1672. MLXSW_REG_DEFINE(ptar, MLXSW_REG_PTAR_ID, MLXSW_REG_PTAR_LEN);
  1673. enum mlxsw_reg_ptar_op {
  1674. /* allocate a TCAM region */
  1675. MLXSW_REG_PTAR_OP_ALLOC,
  1676. /* resize a TCAM region */
  1677. MLXSW_REG_PTAR_OP_RESIZE,
  1678. /* deallocate TCAM region */
  1679. MLXSW_REG_PTAR_OP_FREE,
  1680. /* test allocation */
  1681. MLXSW_REG_PTAR_OP_TEST,
  1682. };
  1683. /* reg_ptar_op
  1684. * Access: OP
  1685. */
  1686. MLXSW_ITEM32(reg, ptar, op, 0x00, 28, 4);
  1687. /* reg_ptar_action_set_type
  1688. * Type of action set to be used on this region.
  1689. * For Spectrum, this is always type 2 - "flexible"
  1690. * Access: WO
  1691. */
  1692. MLXSW_ITEM32(reg, ptar, action_set_type, 0x00, 16, 8);
  1693. /* reg_ptar_key_type
  1694. * TCAM key type for the region.
  1695. * For Spectrum, this is always type 0x50 - "FLEX_KEY"
  1696. * Access: WO
  1697. */
  1698. MLXSW_ITEM32(reg, ptar, key_type, 0x00, 0, 8);
  1699. /* reg_ptar_region_size
  1700. * TCAM region size. When allocating/resizing this is the requested size,
  1701. * the response is the actual size. Note that actual size may be
  1702. * larger than requested.
  1703. * Allowed range 1 .. cap_max_rules-1
  1704. * Reserved during op deallocate.
  1705. * Access: WO
  1706. */
  1707. MLXSW_ITEM32(reg, ptar, region_size, 0x04, 0, 16);
  1708. /* reg_ptar_region_id
  1709. * Region identifier
  1710. * Range 0 .. cap_max_regions-1
  1711. * Access: Index
  1712. */
  1713. MLXSW_ITEM32(reg, ptar, region_id, 0x08, 0, 16);
  1714. /* reg_ptar_tcam_region_info
  1715. * Opaque object that represents the TCAM region.
  1716. * Returned when allocating a region.
  1717. * Provided by software for ACL generation and region deallocation and resize.
  1718. * Access: RW
  1719. */
  1720. MLXSW_ITEM_BUF(reg, ptar, tcam_region_info, 0x10,
  1721. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1722. /* reg_ptar_flexible_key_id
  1723. * Identifier of the Flexible Key.
  1724. * Only valid if key_type == "FLEX_KEY"
  1725. * The key size will be rounded up to one of the following values:
  1726. * 9B, 18B, 36B, 54B.
  1727. * This field is reserved for in resize operation.
  1728. * Access: WO
  1729. */
  1730. MLXSW_ITEM8_INDEXED(reg, ptar, flexible_key_id, 0x20, 0, 8,
  1731. MLXSW_REG_PTAR_KEY_ID_LEN, 0x00, false);
  1732. static inline void mlxsw_reg_ptar_pack(char *payload, enum mlxsw_reg_ptar_op op,
  1733. u16 region_size, u16 region_id,
  1734. const char *tcam_region_info)
  1735. {
  1736. MLXSW_REG_ZERO(ptar, payload);
  1737. mlxsw_reg_ptar_op_set(payload, op);
  1738. mlxsw_reg_ptar_action_set_type_set(payload, 2); /* "flexible" */
  1739. mlxsw_reg_ptar_key_type_set(payload, 0x50); /* "FLEX_KEY" */
  1740. mlxsw_reg_ptar_region_size_set(payload, region_size);
  1741. mlxsw_reg_ptar_region_id_set(payload, region_id);
  1742. mlxsw_reg_ptar_tcam_region_info_memcpy_to(payload, tcam_region_info);
  1743. }
  1744. static inline void mlxsw_reg_ptar_key_id_pack(char *payload, int index,
  1745. u16 key_id)
  1746. {
  1747. mlxsw_reg_ptar_flexible_key_id_set(payload, index, key_id);
  1748. }
  1749. static inline void mlxsw_reg_ptar_unpack(char *payload, char *tcam_region_info)
  1750. {
  1751. mlxsw_reg_ptar_tcam_region_info_memcpy_from(payload, tcam_region_info);
  1752. }
  1753. /* PPBS - Policy-Engine Policy Based Switching Register
  1754. * ----------------------------------------------------
  1755. * This register retrieves and sets Policy Based Switching Table entries.
  1756. */
  1757. #define MLXSW_REG_PPBS_ID 0x300C
  1758. #define MLXSW_REG_PPBS_LEN 0x14
  1759. MLXSW_REG_DEFINE(ppbs, MLXSW_REG_PPBS_ID, MLXSW_REG_PPBS_LEN);
  1760. /* reg_ppbs_pbs_ptr
  1761. * Index into the PBS table.
  1762. * For Spectrum, the index points to the KVD Linear.
  1763. * Access: Index
  1764. */
  1765. MLXSW_ITEM32(reg, ppbs, pbs_ptr, 0x08, 0, 24);
  1766. /* reg_ppbs_system_port
  1767. * Unique port identifier for the final destination of the packet.
  1768. * Access: RW
  1769. */
  1770. MLXSW_ITEM32(reg, ppbs, system_port, 0x10, 0, 16);
  1771. static inline void mlxsw_reg_ppbs_pack(char *payload, u32 pbs_ptr,
  1772. u16 system_port)
  1773. {
  1774. MLXSW_REG_ZERO(ppbs, payload);
  1775. mlxsw_reg_ppbs_pbs_ptr_set(payload, pbs_ptr);
  1776. mlxsw_reg_ppbs_system_port_set(payload, system_port);
  1777. }
  1778. /* PRCR - Policy-Engine Rules Copy Register
  1779. * ----------------------------------------
  1780. * This register is used for accessing rules within a TCAM region.
  1781. */
  1782. #define MLXSW_REG_PRCR_ID 0x300D
  1783. #define MLXSW_REG_PRCR_LEN 0x40
  1784. MLXSW_REG_DEFINE(prcr, MLXSW_REG_PRCR_ID, MLXSW_REG_PRCR_LEN);
  1785. enum mlxsw_reg_prcr_op {
  1786. /* Move rules. Moves the rules from "tcam_region_info" starting
  1787. * at offset "offset" to "dest_tcam_region_info"
  1788. * at offset "dest_offset."
  1789. */
  1790. MLXSW_REG_PRCR_OP_MOVE,
  1791. /* Copy rules. Copies the rules from "tcam_region_info" starting
  1792. * at offset "offset" to "dest_tcam_region_info"
  1793. * at offset "dest_offset."
  1794. */
  1795. MLXSW_REG_PRCR_OP_COPY,
  1796. };
  1797. /* reg_prcr_op
  1798. * Access: OP
  1799. */
  1800. MLXSW_ITEM32(reg, prcr, op, 0x00, 28, 4);
  1801. /* reg_prcr_offset
  1802. * Offset within the source region to copy/move from.
  1803. * Access: Index
  1804. */
  1805. MLXSW_ITEM32(reg, prcr, offset, 0x00, 0, 16);
  1806. /* reg_prcr_size
  1807. * The number of rules to copy/move.
  1808. * Access: WO
  1809. */
  1810. MLXSW_ITEM32(reg, prcr, size, 0x04, 0, 16);
  1811. /* reg_prcr_tcam_region_info
  1812. * Opaque object that represents the source TCAM region.
  1813. * Access: Index
  1814. */
  1815. MLXSW_ITEM_BUF(reg, prcr, tcam_region_info, 0x10,
  1816. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1817. /* reg_prcr_dest_offset
  1818. * Offset within the source region to copy/move to.
  1819. * Access: Index
  1820. */
  1821. MLXSW_ITEM32(reg, prcr, dest_offset, 0x20, 0, 16);
  1822. /* reg_prcr_dest_tcam_region_info
  1823. * Opaque object that represents the destination TCAM region.
  1824. * Access: Index
  1825. */
  1826. MLXSW_ITEM_BUF(reg, prcr, dest_tcam_region_info, 0x30,
  1827. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1828. static inline void mlxsw_reg_prcr_pack(char *payload, enum mlxsw_reg_prcr_op op,
  1829. const char *src_tcam_region_info,
  1830. u16 src_offset,
  1831. const char *dest_tcam_region_info,
  1832. u16 dest_offset, u16 size)
  1833. {
  1834. MLXSW_REG_ZERO(prcr, payload);
  1835. mlxsw_reg_prcr_op_set(payload, op);
  1836. mlxsw_reg_prcr_offset_set(payload, src_offset);
  1837. mlxsw_reg_prcr_size_set(payload, size);
  1838. mlxsw_reg_prcr_tcam_region_info_memcpy_to(payload,
  1839. src_tcam_region_info);
  1840. mlxsw_reg_prcr_dest_offset_set(payload, dest_offset);
  1841. mlxsw_reg_prcr_dest_tcam_region_info_memcpy_to(payload,
  1842. dest_tcam_region_info);
  1843. }
  1844. /* PEFA - Policy-Engine Extended Flexible Action Register
  1845. * ------------------------------------------------------
  1846. * This register is used for accessing an extended flexible action entry
  1847. * in the central KVD Linear Database.
  1848. */
  1849. #define MLXSW_REG_PEFA_ID 0x300F
  1850. #define MLXSW_REG_PEFA_LEN 0xB0
  1851. MLXSW_REG_DEFINE(pefa, MLXSW_REG_PEFA_ID, MLXSW_REG_PEFA_LEN);
  1852. /* reg_pefa_index
  1853. * Index in the KVD Linear Centralized Database.
  1854. * Access: Index
  1855. */
  1856. MLXSW_ITEM32(reg, pefa, index, 0x00, 0, 24);
  1857. #define MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN 0xA8
  1858. /* reg_pefa_flex_action_set
  1859. * Action-set to perform when rule is matched.
  1860. * Must be zero padded if action set is shorter.
  1861. * Access: RW
  1862. */
  1863. MLXSW_ITEM_BUF(reg, pefa, flex_action_set, 0x08,
  1864. MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN);
  1865. static inline void mlxsw_reg_pefa_pack(char *payload, u32 index,
  1866. const char *flex_action_set)
  1867. {
  1868. MLXSW_REG_ZERO(pefa, payload);
  1869. mlxsw_reg_pefa_index_set(payload, index);
  1870. mlxsw_reg_pefa_flex_action_set_memcpy_to(payload, flex_action_set);
  1871. }
  1872. /* PTCE-V2 - Policy-Engine TCAM Entry Register Version 2
  1873. * -----------------------------------------------------
  1874. * This register is used for accessing rules within a TCAM region.
  1875. * It is a new version of PTCE in order to support wider key,
  1876. * mask and action within a TCAM region. This register is not supported
  1877. * by SwitchX and SwitchX-2.
  1878. */
  1879. #define MLXSW_REG_PTCE2_ID 0x3017
  1880. #define MLXSW_REG_PTCE2_LEN 0x1D8
  1881. MLXSW_REG_DEFINE(ptce2, MLXSW_REG_PTCE2_ID, MLXSW_REG_PTCE2_LEN);
  1882. /* reg_ptce2_v
  1883. * Valid.
  1884. * Access: RW
  1885. */
  1886. MLXSW_ITEM32(reg, ptce2, v, 0x00, 31, 1);
  1887. /* reg_ptce2_a
  1888. * Activity. Set if a packet lookup has hit on the specific entry.
  1889. * To clear the "a" bit, use "clear activity" op or "clear on read" op.
  1890. * Access: RO
  1891. */
  1892. MLXSW_ITEM32(reg, ptce2, a, 0x00, 30, 1);
  1893. enum mlxsw_reg_ptce2_op {
  1894. /* Read operation. */
  1895. MLXSW_REG_PTCE2_OP_QUERY_READ = 0,
  1896. /* clear on read operation. Used to read entry
  1897. * and clear Activity bit.
  1898. */
  1899. MLXSW_REG_PTCE2_OP_QUERY_CLEAR_ON_READ = 1,
  1900. /* Write operation. Used to write a new entry to the table.
  1901. * All R/W fields are relevant for new entry. Activity bit is set
  1902. * for new entries - Note write with v = 0 will delete the entry.
  1903. */
  1904. MLXSW_REG_PTCE2_OP_WRITE_WRITE = 0,
  1905. /* Update action. Only action set will be updated. */
  1906. MLXSW_REG_PTCE2_OP_WRITE_UPDATE = 1,
  1907. /* Clear activity. A bit is cleared for the entry. */
  1908. MLXSW_REG_PTCE2_OP_WRITE_CLEAR_ACTIVITY = 2,
  1909. };
  1910. /* reg_ptce2_op
  1911. * Access: OP
  1912. */
  1913. MLXSW_ITEM32(reg, ptce2, op, 0x00, 20, 3);
  1914. /* reg_ptce2_offset
  1915. * Access: Index
  1916. */
  1917. MLXSW_ITEM32(reg, ptce2, offset, 0x00, 0, 16);
  1918. /* reg_ptce2_tcam_region_info
  1919. * Opaque object that represents the TCAM region.
  1920. * Access: Index
  1921. */
  1922. MLXSW_ITEM_BUF(reg, ptce2, tcam_region_info, 0x10,
  1923. MLXSW_REG_PXXX_TCAM_REGION_INFO_LEN);
  1924. #define MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN 96
  1925. /* reg_ptce2_flex_key_blocks
  1926. * ACL Key.
  1927. * Access: RW
  1928. */
  1929. MLXSW_ITEM_BUF(reg, ptce2, flex_key_blocks, 0x20,
  1930. MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN);
  1931. /* reg_ptce2_mask
  1932. * mask- in the same size as key. A bit that is set directs the TCAM
  1933. * to compare the corresponding bit in key. A bit that is clear directs
  1934. * the TCAM to ignore the corresponding bit in key.
  1935. * Access: RW
  1936. */
  1937. MLXSW_ITEM_BUF(reg, ptce2, mask, 0x80,
  1938. MLXSW_REG_PTCE2_FLEX_KEY_BLOCKS_LEN);
  1939. /* reg_ptce2_flex_action_set
  1940. * ACL action set.
  1941. * Access: RW
  1942. */
  1943. MLXSW_ITEM_BUF(reg, ptce2, flex_action_set, 0xE0,
  1944. MLXSW_REG_PXXX_FLEX_ACTION_SET_LEN);
  1945. static inline void mlxsw_reg_ptce2_pack(char *payload, bool valid,
  1946. enum mlxsw_reg_ptce2_op op,
  1947. const char *tcam_region_info,
  1948. u16 offset)
  1949. {
  1950. MLXSW_REG_ZERO(ptce2, payload);
  1951. mlxsw_reg_ptce2_v_set(payload, valid);
  1952. mlxsw_reg_ptce2_op_set(payload, op);
  1953. mlxsw_reg_ptce2_offset_set(payload, offset);
  1954. mlxsw_reg_ptce2_tcam_region_info_memcpy_to(payload, tcam_region_info);
  1955. }
  1956. /* QPCR - QoS Policer Configuration Register
  1957. * -----------------------------------------
  1958. * The QPCR register is used to create policers - that limit
  1959. * the rate of bytes or packets via some trap group.
  1960. */
  1961. #define MLXSW_REG_QPCR_ID 0x4004
  1962. #define MLXSW_REG_QPCR_LEN 0x28
  1963. MLXSW_REG_DEFINE(qpcr, MLXSW_REG_QPCR_ID, MLXSW_REG_QPCR_LEN);
  1964. enum mlxsw_reg_qpcr_g {
  1965. MLXSW_REG_QPCR_G_GLOBAL = 2,
  1966. MLXSW_REG_QPCR_G_STORM_CONTROL = 3,
  1967. };
  1968. /* reg_qpcr_g
  1969. * The policer type.
  1970. * Access: Index
  1971. */
  1972. MLXSW_ITEM32(reg, qpcr, g, 0x00, 14, 2);
  1973. /* reg_qpcr_pid
  1974. * Policer ID.
  1975. * Access: Index
  1976. */
  1977. MLXSW_ITEM32(reg, qpcr, pid, 0x00, 0, 14);
  1978. /* reg_qpcr_color_aware
  1979. * Is the policer aware of colors.
  1980. * Must be 0 (unaware) for cpu port.
  1981. * Access: RW for unbounded policer. RO for bounded policer.
  1982. */
  1983. MLXSW_ITEM32(reg, qpcr, color_aware, 0x04, 15, 1);
  1984. /* reg_qpcr_bytes
  1985. * Is policer limit is for bytes per sec or packets per sec.
  1986. * 0 - packets
  1987. * 1 - bytes
  1988. * Access: RW for unbounded policer. RO for bounded policer.
  1989. */
  1990. MLXSW_ITEM32(reg, qpcr, bytes, 0x04, 14, 1);
  1991. enum mlxsw_reg_qpcr_ir_units {
  1992. MLXSW_REG_QPCR_IR_UNITS_M,
  1993. MLXSW_REG_QPCR_IR_UNITS_K,
  1994. };
  1995. /* reg_qpcr_ir_units
  1996. * Policer's units for cir and eir fields (for bytes limits only)
  1997. * 1 - 10^3
  1998. * 0 - 10^6
  1999. * Access: OP
  2000. */
  2001. MLXSW_ITEM32(reg, qpcr, ir_units, 0x04, 12, 1);
  2002. enum mlxsw_reg_qpcr_rate_type {
  2003. MLXSW_REG_QPCR_RATE_TYPE_SINGLE = 1,
  2004. MLXSW_REG_QPCR_RATE_TYPE_DOUBLE = 2,
  2005. };
  2006. /* reg_qpcr_rate_type
  2007. * Policer can have one limit (single rate) or 2 limits with specific operation
  2008. * for packets that exceed the lower rate but not the upper one.
  2009. * (For cpu port must be single rate)
  2010. * Access: RW for unbounded policer. RO for bounded policer.
  2011. */
  2012. MLXSW_ITEM32(reg, qpcr, rate_type, 0x04, 8, 2);
  2013. /* reg_qpc_cbs
  2014. * Policer's committed burst size.
  2015. * The policer is working with time slices of 50 nano sec. By default every
  2016. * slice is granted the proportionate share of the committed rate. If we want to
  2017. * allow a slice to exceed that share (while still keeping the rate per sec) we
  2018. * can allow burst. The burst size is between the default proportionate share
  2019. * (and no lower than 8) to 32Gb. (Even though giving a number higher than the
  2020. * committed rate will result in exceeding the rate). The burst size must be a
  2021. * log of 2 and will be determined by 2^cbs.
  2022. * Access: RW
  2023. */
  2024. MLXSW_ITEM32(reg, qpcr, cbs, 0x08, 24, 6);
  2025. /* reg_qpcr_cir
  2026. * Policer's committed rate.
  2027. * The rate used for sungle rate, the lower rate for double rate.
  2028. * For bytes limits, the rate will be this value * the unit from ir_units.
  2029. * (Resolution error is up to 1%).
  2030. * Access: RW
  2031. */
  2032. MLXSW_ITEM32(reg, qpcr, cir, 0x0C, 0, 32);
  2033. /* reg_qpcr_eir
  2034. * Policer's exceed rate.
  2035. * The higher rate for double rate, reserved for single rate.
  2036. * Lower rate for double rate policer.
  2037. * For bytes limits, the rate will be this value * the unit from ir_units.
  2038. * (Resolution error is up to 1%).
  2039. * Access: RW
  2040. */
  2041. MLXSW_ITEM32(reg, qpcr, eir, 0x10, 0, 32);
  2042. #define MLXSW_REG_QPCR_DOUBLE_RATE_ACTION 2
  2043. /* reg_qpcr_exceed_action.
  2044. * What to do with packets between the 2 limits for double rate.
  2045. * Access: RW for unbounded policer. RO for bounded policer.
  2046. */
  2047. MLXSW_ITEM32(reg, qpcr, exceed_action, 0x14, 0, 4);
  2048. enum mlxsw_reg_qpcr_action {
  2049. /* Discard */
  2050. MLXSW_REG_QPCR_ACTION_DISCARD = 1,
  2051. /* Forward and set color to red.
  2052. * If the packet is intended to cpu port, it will be dropped.
  2053. */
  2054. MLXSW_REG_QPCR_ACTION_FORWARD = 2,
  2055. };
  2056. /* reg_qpcr_violate_action
  2057. * What to do with packets that cross the cir limit (for single rate) or the eir
  2058. * limit (for double rate).
  2059. * Access: RW for unbounded policer. RO for bounded policer.
  2060. */
  2061. MLXSW_ITEM32(reg, qpcr, violate_action, 0x18, 0, 4);
  2062. static inline void mlxsw_reg_qpcr_pack(char *payload, u16 pid,
  2063. enum mlxsw_reg_qpcr_ir_units ir_units,
  2064. bool bytes, u32 cir, u16 cbs)
  2065. {
  2066. MLXSW_REG_ZERO(qpcr, payload);
  2067. mlxsw_reg_qpcr_pid_set(payload, pid);
  2068. mlxsw_reg_qpcr_g_set(payload, MLXSW_REG_QPCR_G_GLOBAL);
  2069. mlxsw_reg_qpcr_rate_type_set(payload, MLXSW_REG_QPCR_RATE_TYPE_SINGLE);
  2070. mlxsw_reg_qpcr_violate_action_set(payload,
  2071. MLXSW_REG_QPCR_ACTION_DISCARD);
  2072. mlxsw_reg_qpcr_cir_set(payload, cir);
  2073. mlxsw_reg_qpcr_ir_units_set(payload, ir_units);
  2074. mlxsw_reg_qpcr_bytes_set(payload, bytes);
  2075. mlxsw_reg_qpcr_cbs_set(payload, cbs);
  2076. }
  2077. /* QTCT - QoS Switch Traffic Class Table
  2078. * -------------------------------------
  2079. * Configures the mapping between the packet switch priority and the
  2080. * traffic class on the transmit port.
  2081. */
  2082. #define MLXSW_REG_QTCT_ID 0x400A
  2083. #define MLXSW_REG_QTCT_LEN 0x08
  2084. MLXSW_REG_DEFINE(qtct, MLXSW_REG_QTCT_ID, MLXSW_REG_QTCT_LEN);
  2085. /* reg_qtct_local_port
  2086. * Local port number.
  2087. * Access: Index
  2088. *
  2089. * Note: CPU port is not supported.
  2090. */
  2091. MLXSW_ITEM32(reg, qtct, local_port, 0x00, 16, 8);
  2092. /* reg_qtct_sub_port
  2093. * Virtual port within the physical port.
  2094. * Should be set to 0 when virtual ports are not enabled on the port.
  2095. * Access: Index
  2096. */
  2097. MLXSW_ITEM32(reg, qtct, sub_port, 0x00, 8, 8);
  2098. /* reg_qtct_switch_prio
  2099. * Switch priority.
  2100. * Access: Index
  2101. */
  2102. MLXSW_ITEM32(reg, qtct, switch_prio, 0x00, 0, 4);
  2103. /* reg_qtct_tclass
  2104. * Traffic class.
  2105. * Default values:
  2106. * switch_prio 0 : tclass 1
  2107. * switch_prio 1 : tclass 0
  2108. * switch_prio i : tclass i, for i > 1
  2109. * Access: RW
  2110. */
  2111. MLXSW_ITEM32(reg, qtct, tclass, 0x04, 0, 4);
  2112. static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port,
  2113. u8 switch_prio, u8 tclass)
  2114. {
  2115. MLXSW_REG_ZERO(qtct, payload);
  2116. mlxsw_reg_qtct_local_port_set(payload, local_port);
  2117. mlxsw_reg_qtct_switch_prio_set(payload, switch_prio);
  2118. mlxsw_reg_qtct_tclass_set(payload, tclass);
  2119. }
  2120. /* QEEC - QoS ETS Element Configuration Register
  2121. * ---------------------------------------------
  2122. * Configures the ETS elements.
  2123. */
  2124. #define MLXSW_REG_QEEC_ID 0x400D
  2125. #define MLXSW_REG_QEEC_LEN 0x1C
  2126. MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN);
  2127. /* reg_qeec_local_port
  2128. * Local port number.
  2129. * Access: Index
  2130. *
  2131. * Note: CPU port is supported.
  2132. */
  2133. MLXSW_ITEM32(reg, qeec, local_port, 0x00, 16, 8);
  2134. enum mlxsw_reg_qeec_hr {
  2135. MLXSW_REG_QEEC_HIERARCY_PORT,
  2136. MLXSW_REG_QEEC_HIERARCY_GROUP,
  2137. MLXSW_REG_QEEC_HIERARCY_SUBGROUP,
  2138. MLXSW_REG_QEEC_HIERARCY_TC,
  2139. };
  2140. /* reg_qeec_element_hierarchy
  2141. * 0 - Port
  2142. * 1 - Group
  2143. * 2 - Subgroup
  2144. * 3 - Traffic Class
  2145. * Access: Index
  2146. */
  2147. MLXSW_ITEM32(reg, qeec, element_hierarchy, 0x04, 16, 4);
  2148. /* reg_qeec_element_index
  2149. * The index of the element in the hierarchy.
  2150. * Access: Index
  2151. */
  2152. MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8);
  2153. /* reg_qeec_next_element_index
  2154. * The index of the next (lower) element in the hierarchy.
  2155. * Access: RW
  2156. *
  2157. * Note: Reserved for element_hierarchy 0.
  2158. */
  2159. MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8);
  2160. enum {
  2161. MLXSW_REG_QEEC_BYTES_MODE,
  2162. MLXSW_REG_QEEC_PACKETS_MODE,
  2163. };
  2164. /* reg_qeec_pb
  2165. * Packets or bytes mode.
  2166. * 0 - Bytes mode
  2167. * 1 - Packets mode
  2168. * Access: RW
  2169. *
  2170. * Note: Used for max shaper configuration. For Spectrum, packets mode
  2171. * is supported only for traffic classes of CPU port.
  2172. */
  2173. MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1);
  2174. /* reg_qeec_mase
  2175. * Max shaper configuration enable. Enables configuration of the max
  2176. * shaper on this ETS element.
  2177. * 0 - Disable
  2178. * 1 - Enable
  2179. * Access: RW
  2180. */
  2181. MLXSW_ITEM32(reg, qeec, mase, 0x10, 31, 1);
  2182. /* A large max rate will disable the max shaper. */
  2183. #define MLXSW_REG_QEEC_MAS_DIS 200000000 /* Kbps */
  2184. /* reg_qeec_max_shaper_rate
  2185. * Max shaper information rate.
  2186. * For CPU port, can only be configured for port hierarchy.
  2187. * When in bytes mode, value is specified in units of 1000bps.
  2188. * Access: RW
  2189. */
  2190. MLXSW_ITEM32(reg, qeec, max_shaper_rate, 0x10, 0, 28);
  2191. /* reg_qeec_de
  2192. * DWRR configuration enable. Enables configuration of the dwrr and
  2193. * dwrr_weight.
  2194. * 0 - Disable
  2195. * 1 - Enable
  2196. * Access: RW
  2197. */
  2198. MLXSW_ITEM32(reg, qeec, de, 0x18, 31, 1);
  2199. /* reg_qeec_dwrr
  2200. * Transmission selection algorithm to use on the link going down from
  2201. * the ETS element.
  2202. * 0 - Strict priority
  2203. * 1 - DWRR
  2204. * Access: RW
  2205. */
  2206. MLXSW_ITEM32(reg, qeec, dwrr, 0x18, 15, 1);
  2207. /* reg_qeec_dwrr_weight
  2208. * DWRR weight on the link going down from the ETS element. The
  2209. * percentage of bandwidth guaranteed to an ETS element within
  2210. * its hierarchy. The sum of all weights across all ETS elements
  2211. * within one hierarchy should be equal to 100. Reserved when
  2212. * transmission selection algorithm is strict priority.
  2213. * Access: RW
  2214. */
  2215. MLXSW_ITEM32(reg, qeec, dwrr_weight, 0x18, 0, 8);
  2216. static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
  2217. enum mlxsw_reg_qeec_hr hr, u8 index,
  2218. u8 next_index)
  2219. {
  2220. MLXSW_REG_ZERO(qeec, payload);
  2221. mlxsw_reg_qeec_local_port_set(payload, local_port);
  2222. mlxsw_reg_qeec_element_hierarchy_set(payload, hr);
  2223. mlxsw_reg_qeec_element_index_set(payload, index);
  2224. mlxsw_reg_qeec_next_element_index_set(payload, next_index);
  2225. }
  2226. /* PMLP - Ports Module to Local Port Register
  2227. * ------------------------------------------
  2228. * Configures the assignment of modules to local ports.
  2229. */
  2230. #define MLXSW_REG_PMLP_ID 0x5002
  2231. #define MLXSW_REG_PMLP_LEN 0x40
  2232. MLXSW_REG_DEFINE(pmlp, MLXSW_REG_PMLP_ID, MLXSW_REG_PMLP_LEN);
  2233. /* reg_pmlp_rxtx
  2234. * 0 - Tx value is used for both Tx and Rx.
  2235. * 1 - Rx value is taken from a separte field.
  2236. * Access: RW
  2237. */
  2238. MLXSW_ITEM32(reg, pmlp, rxtx, 0x00, 31, 1);
  2239. /* reg_pmlp_local_port
  2240. * Local port number.
  2241. * Access: Index
  2242. */
  2243. MLXSW_ITEM32(reg, pmlp, local_port, 0x00, 16, 8);
  2244. /* reg_pmlp_width
  2245. * 0 - Unmap local port.
  2246. * 1 - Lane 0 is used.
  2247. * 2 - Lanes 0 and 1 are used.
  2248. * 4 - Lanes 0, 1, 2 and 3 are used.
  2249. * Access: RW
  2250. */
  2251. MLXSW_ITEM32(reg, pmlp, width, 0x00, 0, 8);
  2252. /* reg_pmlp_module
  2253. * Module number.
  2254. * Access: RW
  2255. */
  2256. MLXSW_ITEM32_INDEXED(reg, pmlp, module, 0x04, 0, 8, 0x04, 0x00, false);
  2257. /* reg_pmlp_tx_lane
  2258. * Tx Lane. When rxtx field is cleared, this field is used for Rx as well.
  2259. * Access: RW
  2260. */
  2261. MLXSW_ITEM32_INDEXED(reg, pmlp, tx_lane, 0x04, 16, 2, 0x04, 0x00, false);
  2262. /* reg_pmlp_rx_lane
  2263. * Rx Lane. When rxtx field is cleared, this field is ignored and Rx lane is
  2264. * equal to Tx lane.
  2265. * Access: RW
  2266. */
  2267. MLXSW_ITEM32_INDEXED(reg, pmlp, rx_lane, 0x04, 24, 2, 0x04, 0x00, false);
  2268. static inline void mlxsw_reg_pmlp_pack(char *payload, u8 local_port)
  2269. {
  2270. MLXSW_REG_ZERO(pmlp, payload);
  2271. mlxsw_reg_pmlp_local_port_set(payload, local_port);
  2272. }
  2273. /* PMTU - Port MTU Register
  2274. * ------------------------
  2275. * Configures and reports the port MTU.
  2276. */
  2277. #define MLXSW_REG_PMTU_ID 0x5003
  2278. #define MLXSW_REG_PMTU_LEN 0x10
  2279. MLXSW_REG_DEFINE(pmtu, MLXSW_REG_PMTU_ID, MLXSW_REG_PMTU_LEN);
  2280. /* reg_pmtu_local_port
  2281. * Local port number.
  2282. * Access: Index
  2283. */
  2284. MLXSW_ITEM32(reg, pmtu, local_port, 0x00, 16, 8);
  2285. /* reg_pmtu_max_mtu
  2286. * Maximum MTU.
  2287. * When port type (e.g. Ethernet) is configured, the relevant MTU is
  2288. * reported, otherwise the minimum between the max_mtu of the different
  2289. * types is reported.
  2290. * Access: RO
  2291. */
  2292. MLXSW_ITEM32(reg, pmtu, max_mtu, 0x04, 16, 16);
  2293. /* reg_pmtu_admin_mtu
  2294. * MTU value to set port to. Must be smaller or equal to max_mtu.
  2295. * Note: If port type is Infiniband, then port must be disabled, when its
  2296. * MTU is set.
  2297. * Access: RW
  2298. */
  2299. MLXSW_ITEM32(reg, pmtu, admin_mtu, 0x08, 16, 16);
  2300. /* reg_pmtu_oper_mtu
  2301. * The actual MTU configured on the port. Packets exceeding this size
  2302. * will be dropped.
  2303. * Note: In Ethernet and FC oper_mtu == admin_mtu, however, in Infiniband
  2304. * oper_mtu might be smaller than admin_mtu.
  2305. * Access: RO
  2306. */
  2307. MLXSW_ITEM32(reg, pmtu, oper_mtu, 0x0C, 16, 16);
  2308. static inline void mlxsw_reg_pmtu_pack(char *payload, u8 local_port,
  2309. u16 new_mtu)
  2310. {
  2311. MLXSW_REG_ZERO(pmtu, payload);
  2312. mlxsw_reg_pmtu_local_port_set(payload, local_port);
  2313. mlxsw_reg_pmtu_max_mtu_set(payload, 0);
  2314. mlxsw_reg_pmtu_admin_mtu_set(payload, new_mtu);
  2315. mlxsw_reg_pmtu_oper_mtu_set(payload, 0);
  2316. }
  2317. /* PTYS - Port Type and Speed Register
  2318. * -----------------------------------
  2319. * Configures and reports the port speed type.
  2320. *
  2321. * Note: When set while the link is up, the changes will not take effect
  2322. * until the port transitions from down to up state.
  2323. */
  2324. #define MLXSW_REG_PTYS_ID 0x5004
  2325. #define MLXSW_REG_PTYS_LEN 0x40
  2326. MLXSW_REG_DEFINE(ptys, MLXSW_REG_PTYS_ID, MLXSW_REG_PTYS_LEN);
  2327. /* reg_ptys_local_port
  2328. * Local port number.
  2329. * Access: Index
  2330. */
  2331. MLXSW_ITEM32(reg, ptys, local_port, 0x00, 16, 8);
  2332. #define MLXSW_REG_PTYS_PROTO_MASK_IB BIT(0)
  2333. #define MLXSW_REG_PTYS_PROTO_MASK_ETH BIT(2)
  2334. /* reg_ptys_proto_mask
  2335. * Protocol mask. Indicates which protocol is used.
  2336. * 0 - Infiniband.
  2337. * 1 - Fibre Channel.
  2338. * 2 - Ethernet.
  2339. * Access: Index
  2340. */
  2341. MLXSW_ITEM32(reg, ptys, proto_mask, 0x00, 0, 3);
  2342. enum {
  2343. MLXSW_REG_PTYS_AN_STATUS_NA,
  2344. MLXSW_REG_PTYS_AN_STATUS_OK,
  2345. MLXSW_REG_PTYS_AN_STATUS_FAIL,
  2346. };
  2347. /* reg_ptys_an_status
  2348. * Autonegotiation status.
  2349. * Access: RO
  2350. */
  2351. MLXSW_ITEM32(reg, ptys, an_status, 0x04, 28, 4);
  2352. #define MLXSW_REG_PTYS_ETH_SPEED_SGMII BIT(0)
  2353. #define MLXSW_REG_PTYS_ETH_SPEED_1000BASE_KX BIT(1)
  2354. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CX4 BIT(2)
  2355. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KX4 BIT(3)
  2356. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_KR BIT(4)
  2357. #define MLXSW_REG_PTYS_ETH_SPEED_20GBASE_KR2 BIT(5)
  2358. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_CR4 BIT(6)
  2359. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_KR4 BIT(7)
  2360. #define MLXSW_REG_PTYS_ETH_SPEED_56GBASE_R4 BIT(8)
  2361. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_CR BIT(12)
  2362. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_SR BIT(13)
  2363. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_ER_LR BIT(14)
  2364. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_SR4 BIT(15)
  2365. #define MLXSW_REG_PTYS_ETH_SPEED_40GBASE_LR4_ER4 BIT(16)
  2366. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_SR2 BIT(18)
  2367. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR4 BIT(19)
  2368. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_CR4 BIT(20)
  2369. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_SR4 BIT(21)
  2370. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_KR4 BIT(22)
  2371. #define MLXSW_REG_PTYS_ETH_SPEED_100GBASE_LR4_ER4 BIT(23)
  2372. #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_TX BIT(24)
  2373. #define MLXSW_REG_PTYS_ETH_SPEED_100BASE_T BIT(25)
  2374. #define MLXSW_REG_PTYS_ETH_SPEED_10GBASE_T BIT(26)
  2375. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_CR BIT(27)
  2376. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_KR BIT(28)
  2377. #define MLXSW_REG_PTYS_ETH_SPEED_25GBASE_SR BIT(29)
  2378. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_CR2 BIT(30)
  2379. #define MLXSW_REG_PTYS_ETH_SPEED_50GBASE_KR2 BIT(31)
  2380. /* reg_ptys_eth_proto_cap
  2381. * Ethernet port supported speeds and protocols.
  2382. * Access: RO
  2383. */
  2384. MLXSW_ITEM32(reg, ptys, eth_proto_cap, 0x0C, 0, 32);
  2385. /* reg_ptys_ib_link_width_cap
  2386. * IB port supported widths.
  2387. * Access: RO
  2388. */
  2389. MLXSW_ITEM32(reg, ptys, ib_link_width_cap, 0x10, 16, 16);
  2390. #define MLXSW_REG_PTYS_IB_SPEED_SDR BIT(0)
  2391. #define MLXSW_REG_PTYS_IB_SPEED_DDR BIT(1)
  2392. #define MLXSW_REG_PTYS_IB_SPEED_QDR BIT(2)
  2393. #define MLXSW_REG_PTYS_IB_SPEED_FDR10 BIT(3)
  2394. #define MLXSW_REG_PTYS_IB_SPEED_FDR BIT(4)
  2395. #define MLXSW_REG_PTYS_IB_SPEED_EDR BIT(5)
  2396. /* reg_ptys_ib_proto_cap
  2397. * IB port supported speeds and protocols.
  2398. * Access: RO
  2399. */
  2400. MLXSW_ITEM32(reg, ptys, ib_proto_cap, 0x10, 0, 16);
  2401. /* reg_ptys_eth_proto_admin
  2402. * Speed and protocol to set port to.
  2403. * Access: RW
  2404. */
  2405. MLXSW_ITEM32(reg, ptys, eth_proto_admin, 0x18, 0, 32);
  2406. /* reg_ptys_ib_link_width_admin
  2407. * IB width to set port to.
  2408. * Access: RW
  2409. */
  2410. MLXSW_ITEM32(reg, ptys, ib_link_width_admin, 0x1C, 16, 16);
  2411. /* reg_ptys_ib_proto_admin
  2412. * IB speeds and protocols to set port to.
  2413. * Access: RW
  2414. */
  2415. MLXSW_ITEM32(reg, ptys, ib_proto_admin, 0x1C, 0, 16);
  2416. /* reg_ptys_eth_proto_oper
  2417. * The current speed and protocol configured for the port.
  2418. * Access: RO
  2419. */
  2420. MLXSW_ITEM32(reg, ptys, eth_proto_oper, 0x24, 0, 32);
  2421. /* reg_ptys_ib_link_width_oper
  2422. * The current IB width to set port to.
  2423. * Access: RO
  2424. */
  2425. MLXSW_ITEM32(reg, ptys, ib_link_width_oper, 0x28, 16, 16);
  2426. /* reg_ptys_ib_proto_oper
  2427. * The current IB speed and protocol.
  2428. * Access: RO
  2429. */
  2430. MLXSW_ITEM32(reg, ptys, ib_proto_oper, 0x28, 0, 16);
  2431. /* reg_ptys_eth_proto_lp_advertise
  2432. * The protocols that were advertised by the link partner during
  2433. * autonegotiation.
  2434. * Access: RO
  2435. */
  2436. MLXSW_ITEM32(reg, ptys, eth_proto_lp_advertise, 0x30, 0, 32);
  2437. static inline void mlxsw_reg_ptys_eth_pack(char *payload, u8 local_port,
  2438. u32 proto_admin)
  2439. {
  2440. MLXSW_REG_ZERO(ptys, payload);
  2441. mlxsw_reg_ptys_local_port_set(payload, local_port);
  2442. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_ETH);
  2443. mlxsw_reg_ptys_eth_proto_admin_set(payload, proto_admin);
  2444. }
  2445. static inline void mlxsw_reg_ptys_eth_unpack(char *payload,
  2446. u32 *p_eth_proto_cap,
  2447. u32 *p_eth_proto_adm,
  2448. u32 *p_eth_proto_oper)
  2449. {
  2450. if (p_eth_proto_cap)
  2451. *p_eth_proto_cap = mlxsw_reg_ptys_eth_proto_cap_get(payload);
  2452. if (p_eth_proto_adm)
  2453. *p_eth_proto_adm = mlxsw_reg_ptys_eth_proto_admin_get(payload);
  2454. if (p_eth_proto_oper)
  2455. *p_eth_proto_oper = mlxsw_reg_ptys_eth_proto_oper_get(payload);
  2456. }
  2457. static inline void mlxsw_reg_ptys_ib_pack(char *payload, u8 local_port,
  2458. u16 proto_admin, u16 link_width)
  2459. {
  2460. MLXSW_REG_ZERO(ptys, payload);
  2461. mlxsw_reg_ptys_local_port_set(payload, local_port);
  2462. mlxsw_reg_ptys_proto_mask_set(payload, MLXSW_REG_PTYS_PROTO_MASK_IB);
  2463. mlxsw_reg_ptys_ib_proto_admin_set(payload, proto_admin);
  2464. mlxsw_reg_ptys_ib_link_width_admin_set(payload, link_width);
  2465. }
  2466. static inline void mlxsw_reg_ptys_ib_unpack(char *payload, u16 *p_ib_proto_cap,
  2467. u16 *p_ib_link_width_cap,
  2468. u16 *p_ib_proto_oper,
  2469. u16 *p_ib_link_width_oper)
  2470. {
  2471. if (p_ib_proto_cap)
  2472. *p_ib_proto_cap = mlxsw_reg_ptys_ib_proto_cap_get(payload);
  2473. if (p_ib_link_width_cap)
  2474. *p_ib_link_width_cap =
  2475. mlxsw_reg_ptys_ib_link_width_cap_get(payload);
  2476. if (p_ib_proto_oper)
  2477. *p_ib_proto_oper = mlxsw_reg_ptys_ib_proto_oper_get(payload);
  2478. if (p_ib_link_width_oper)
  2479. *p_ib_link_width_oper =
  2480. mlxsw_reg_ptys_ib_link_width_oper_get(payload);
  2481. }
  2482. /* PPAD - Port Physical Address Register
  2483. * -------------------------------------
  2484. * The PPAD register configures the per port physical MAC address.
  2485. */
  2486. #define MLXSW_REG_PPAD_ID 0x5005
  2487. #define MLXSW_REG_PPAD_LEN 0x10
  2488. MLXSW_REG_DEFINE(ppad, MLXSW_REG_PPAD_ID, MLXSW_REG_PPAD_LEN);
  2489. /* reg_ppad_single_base_mac
  2490. * 0: base_mac, local port should be 0 and mac[7:0] is
  2491. * reserved. HW will set incremental
  2492. * 1: single_mac - mac of the local_port
  2493. * Access: RW
  2494. */
  2495. MLXSW_ITEM32(reg, ppad, single_base_mac, 0x00, 28, 1);
  2496. /* reg_ppad_local_port
  2497. * port number, if single_base_mac = 0 then local_port is reserved
  2498. * Access: RW
  2499. */
  2500. MLXSW_ITEM32(reg, ppad, local_port, 0x00, 16, 8);
  2501. /* reg_ppad_mac
  2502. * If single_base_mac = 0 - base MAC address, mac[7:0] is reserved.
  2503. * If single_base_mac = 1 - the per port MAC address
  2504. * Access: RW
  2505. */
  2506. MLXSW_ITEM_BUF(reg, ppad, mac, 0x02, 6);
  2507. static inline void mlxsw_reg_ppad_pack(char *payload, bool single_base_mac,
  2508. u8 local_port)
  2509. {
  2510. MLXSW_REG_ZERO(ppad, payload);
  2511. mlxsw_reg_ppad_single_base_mac_set(payload, !!single_base_mac);
  2512. mlxsw_reg_ppad_local_port_set(payload, local_port);
  2513. }
  2514. /* PAOS - Ports Administrative and Operational Status Register
  2515. * -----------------------------------------------------------
  2516. * Configures and retrieves per port administrative and operational status.
  2517. */
  2518. #define MLXSW_REG_PAOS_ID 0x5006
  2519. #define MLXSW_REG_PAOS_LEN 0x10
  2520. MLXSW_REG_DEFINE(paos, MLXSW_REG_PAOS_ID, MLXSW_REG_PAOS_LEN);
  2521. /* reg_paos_swid
  2522. * Switch partition ID with which to associate the port.
  2523. * Note: while external ports uses unique local port numbers (and thus swid is
  2524. * redundant), router ports use the same local port number where swid is the
  2525. * only indication for the relevant port.
  2526. * Access: Index
  2527. */
  2528. MLXSW_ITEM32(reg, paos, swid, 0x00, 24, 8);
  2529. /* reg_paos_local_port
  2530. * Local port number.
  2531. * Access: Index
  2532. */
  2533. MLXSW_ITEM32(reg, paos, local_port, 0x00, 16, 8);
  2534. /* reg_paos_admin_status
  2535. * Port administrative state (the desired state of the port):
  2536. * 1 - Up.
  2537. * 2 - Down.
  2538. * 3 - Up once. This means that in case of link failure, the port won't go
  2539. * into polling mode, but will wait to be re-enabled by software.
  2540. * 4 - Disabled by system. Can only be set by hardware.
  2541. * Access: RW
  2542. */
  2543. MLXSW_ITEM32(reg, paos, admin_status, 0x00, 8, 4);
  2544. /* reg_paos_oper_status
  2545. * Port operational state (the current state):
  2546. * 1 - Up.
  2547. * 2 - Down.
  2548. * 3 - Down by port failure. This means that the device will not let the
  2549. * port up again until explicitly specified by software.
  2550. * Access: RO
  2551. */
  2552. MLXSW_ITEM32(reg, paos, oper_status, 0x00, 0, 4);
  2553. /* reg_paos_ase
  2554. * Admin state update enabled.
  2555. * Access: WO
  2556. */
  2557. MLXSW_ITEM32(reg, paos, ase, 0x04, 31, 1);
  2558. /* reg_paos_ee
  2559. * Event update enable. If this bit is set, event generation will be
  2560. * updated based on the e field.
  2561. * Access: WO
  2562. */
  2563. MLXSW_ITEM32(reg, paos, ee, 0x04, 30, 1);
  2564. /* reg_paos_e
  2565. * Event generation on operational state change:
  2566. * 0 - Do not generate event.
  2567. * 1 - Generate Event.
  2568. * 2 - Generate Single Event.
  2569. * Access: RW
  2570. */
  2571. MLXSW_ITEM32(reg, paos, e, 0x04, 0, 2);
  2572. static inline void mlxsw_reg_paos_pack(char *payload, u8 local_port,
  2573. enum mlxsw_port_admin_status status)
  2574. {
  2575. MLXSW_REG_ZERO(paos, payload);
  2576. mlxsw_reg_paos_swid_set(payload, 0);
  2577. mlxsw_reg_paos_local_port_set(payload, local_port);
  2578. mlxsw_reg_paos_admin_status_set(payload, status);
  2579. mlxsw_reg_paos_oper_status_set(payload, 0);
  2580. mlxsw_reg_paos_ase_set(payload, 1);
  2581. mlxsw_reg_paos_ee_set(payload, 1);
  2582. mlxsw_reg_paos_e_set(payload, 1);
  2583. }
  2584. /* PFCC - Ports Flow Control Configuration Register
  2585. * ------------------------------------------------
  2586. * Configures and retrieves the per port flow control configuration.
  2587. */
  2588. #define MLXSW_REG_PFCC_ID 0x5007
  2589. #define MLXSW_REG_PFCC_LEN 0x20
  2590. MLXSW_REG_DEFINE(pfcc, MLXSW_REG_PFCC_ID, MLXSW_REG_PFCC_LEN);
  2591. /* reg_pfcc_local_port
  2592. * Local port number.
  2593. * Access: Index
  2594. */
  2595. MLXSW_ITEM32(reg, pfcc, local_port, 0x00, 16, 8);
  2596. /* reg_pfcc_pnat
  2597. * Port number access type. Determines the way local_port is interpreted:
  2598. * 0 - Local port number.
  2599. * 1 - IB / label port number.
  2600. * Access: Index
  2601. */
  2602. MLXSW_ITEM32(reg, pfcc, pnat, 0x00, 14, 2);
  2603. /* reg_pfcc_shl_cap
  2604. * Send to higher layers capabilities:
  2605. * 0 - No capability of sending Pause and PFC frames to higher layers.
  2606. * 1 - Device has capability of sending Pause and PFC frames to higher
  2607. * layers.
  2608. * Access: RO
  2609. */
  2610. MLXSW_ITEM32(reg, pfcc, shl_cap, 0x00, 1, 1);
  2611. /* reg_pfcc_shl_opr
  2612. * Send to higher layers operation:
  2613. * 0 - Pause and PFC frames are handled by the port (default).
  2614. * 1 - Pause and PFC frames are handled by the port and also sent to
  2615. * higher layers. Only valid if shl_cap = 1.
  2616. * Access: RW
  2617. */
  2618. MLXSW_ITEM32(reg, pfcc, shl_opr, 0x00, 0, 1);
  2619. /* reg_pfcc_ppan
  2620. * Pause policy auto negotiation.
  2621. * 0 - Disabled. Generate / ignore Pause frames based on pptx / pprtx.
  2622. * 1 - Enabled. When auto-negotiation is performed, set the Pause policy
  2623. * based on the auto-negotiation resolution.
  2624. * Access: RW
  2625. *
  2626. * Note: The auto-negotiation advertisement is set according to pptx and
  2627. * pprtx. When PFC is set on Tx / Rx, ppan must be set to 0.
  2628. */
  2629. MLXSW_ITEM32(reg, pfcc, ppan, 0x04, 28, 4);
  2630. /* reg_pfcc_prio_mask_tx
  2631. * Bit per priority indicating if Tx flow control policy should be
  2632. * updated based on bit pfctx.
  2633. * Access: WO
  2634. */
  2635. MLXSW_ITEM32(reg, pfcc, prio_mask_tx, 0x04, 16, 8);
  2636. /* reg_pfcc_prio_mask_rx
  2637. * Bit per priority indicating if Rx flow control policy should be
  2638. * updated based on bit pfcrx.
  2639. * Access: WO
  2640. */
  2641. MLXSW_ITEM32(reg, pfcc, prio_mask_rx, 0x04, 0, 8);
  2642. /* reg_pfcc_pptx
  2643. * Admin Pause policy on Tx.
  2644. * 0 - Never generate Pause frames (default).
  2645. * 1 - Generate Pause frames according to Rx buffer threshold.
  2646. * Access: RW
  2647. */
  2648. MLXSW_ITEM32(reg, pfcc, pptx, 0x08, 31, 1);
  2649. /* reg_pfcc_aptx
  2650. * Active (operational) Pause policy on Tx.
  2651. * 0 - Never generate Pause frames.
  2652. * 1 - Generate Pause frames according to Rx buffer threshold.
  2653. * Access: RO
  2654. */
  2655. MLXSW_ITEM32(reg, pfcc, aptx, 0x08, 30, 1);
  2656. /* reg_pfcc_pfctx
  2657. * Priority based flow control policy on Tx[7:0]. Per-priority bit mask:
  2658. * 0 - Never generate priority Pause frames on the specified priority
  2659. * (default).
  2660. * 1 - Generate priority Pause frames according to Rx buffer threshold on
  2661. * the specified priority.
  2662. * Access: RW
  2663. *
  2664. * Note: pfctx and pptx must be mutually exclusive.
  2665. */
  2666. MLXSW_ITEM32(reg, pfcc, pfctx, 0x08, 16, 8);
  2667. /* reg_pfcc_pprx
  2668. * Admin Pause policy on Rx.
  2669. * 0 - Ignore received Pause frames (default).
  2670. * 1 - Respect received Pause frames.
  2671. * Access: RW
  2672. */
  2673. MLXSW_ITEM32(reg, pfcc, pprx, 0x0C, 31, 1);
  2674. /* reg_pfcc_aprx
  2675. * Active (operational) Pause policy on Rx.
  2676. * 0 - Ignore received Pause frames.
  2677. * 1 - Respect received Pause frames.
  2678. * Access: RO
  2679. */
  2680. MLXSW_ITEM32(reg, pfcc, aprx, 0x0C, 30, 1);
  2681. /* reg_pfcc_pfcrx
  2682. * Priority based flow control policy on Rx[7:0]. Per-priority bit mask:
  2683. * 0 - Ignore incoming priority Pause frames on the specified priority
  2684. * (default).
  2685. * 1 - Respect incoming priority Pause frames on the specified priority.
  2686. * Access: RW
  2687. */
  2688. MLXSW_ITEM32(reg, pfcc, pfcrx, 0x0C, 16, 8);
  2689. #define MLXSW_REG_PFCC_ALL_PRIO 0xFF
  2690. static inline void mlxsw_reg_pfcc_prio_pack(char *payload, u8 pfc_en)
  2691. {
  2692. mlxsw_reg_pfcc_prio_mask_tx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  2693. mlxsw_reg_pfcc_prio_mask_rx_set(payload, MLXSW_REG_PFCC_ALL_PRIO);
  2694. mlxsw_reg_pfcc_pfctx_set(payload, pfc_en);
  2695. mlxsw_reg_pfcc_pfcrx_set(payload, pfc_en);
  2696. }
  2697. static inline void mlxsw_reg_pfcc_pack(char *payload, u8 local_port)
  2698. {
  2699. MLXSW_REG_ZERO(pfcc, payload);
  2700. mlxsw_reg_pfcc_local_port_set(payload, local_port);
  2701. }
  2702. /* PPCNT - Ports Performance Counters Register
  2703. * -------------------------------------------
  2704. * The PPCNT register retrieves per port performance counters.
  2705. */
  2706. #define MLXSW_REG_PPCNT_ID 0x5008
  2707. #define MLXSW_REG_PPCNT_LEN 0x100
  2708. MLXSW_REG_DEFINE(ppcnt, MLXSW_REG_PPCNT_ID, MLXSW_REG_PPCNT_LEN);
  2709. /* reg_ppcnt_swid
  2710. * For HCA: must be always 0.
  2711. * Switch partition ID to associate port with.
  2712. * Switch partitions are numbered from 0 to 7 inclusively.
  2713. * Switch partition 254 indicates stacking ports.
  2714. * Switch partition 255 indicates all switch partitions.
  2715. * Only valid on Set() operation with local_port=255.
  2716. * Access: Index
  2717. */
  2718. MLXSW_ITEM32(reg, ppcnt, swid, 0x00, 24, 8);
  2719. /* reg_ppcnt_local_port
  2720. * Local port number.
  2721. * 255 indicates all ports on the device, and is only allowed
  2722. * for Set() operation.
  2723. * Access: Index
  2724. */
  2725. MLXSW_ITEM32(reg, ppcnt, local_port, 0x00, 16, 8);
  2726. /* reg_ppcnt_pnat
  2727. * Port number access type:
  2728. * 0 - Local port number
  2729. * 1 - IB port number
  2730. * Access: Index
  2731. */
  2732. MLXSW_ITEM32(reg, ppcnt, pnat, 0x00, 14, 2);
  2733. enum mlxsw_reg_ppcnt_grp {
  2734. MLXSW_REG_PPCNT_IEEE_8023_CNT = 0x0,
  2735. MLXSW_REG_PPCNT_PRIO_CNT = 0x10,
  2736. MLXSW_REG_PPCNT_TC_CNT = 0x11,
  2737. };
  2738. /* reg_ppcnt_grp
  2739. * Performance counter group.
  2740. * Group 63 indicates all groups. Only valid on Set() operation with
  2741. * clr bit set.
  2742. * 0x0: IEEE 802.3 Counters
  2743. * 0x1: RFC 2863 Counters
  2744. * 0x2: RFC 2819 Counters
  2745. * 0x3: RFC 3635 Counters
  2746. * 0x5: Ethernet Extended Counters
  2747. * 0x8: Link Level Retransmission Counters
  2748. * 0x10: Per Priority Counters
  2749. * 0x11: Per Traffic Class Counters
  2750. * 0x12: Physical Layer Counters
  2751. * Access: Index
  2752. */
  2753. MLXSW_ITEM32(reg, ppcnt, grp, 0x00, 0, 6);
  2754. /* reg_ppcnt_clr
  2755. * Clear counters. Setting the clr bit will reset the counter value
  2756. * for all counters in the counter group. This bit can be set
  2757. * for both Set() and Get() operation.
  2758. * Access: OP
  2759. */
  2760. MLXSW_ITEM32(reg, ppcnt, clr, 0x04, 31, 1);
  2761. /* reg_ppcnt_prio_tc
  2762. * Priority for counter set that support per priority, valid values: 0-7.
  2763. * Traffic class for counter set that support per traffic class,
  2764. * valid values: 0- cap_max_tclass-1 .
  2765. * For HCA: cap_max_tclass is always 8.
  2766. * Otherwise must be 0.
  2767. * Access: Index
  2768. */
  2769. MLXSW_ITEM32(reg, ppcnt, prio_tc, 0x04, 0, 5);
  2770. /* Ethernet IEEE 802.3 Counter Group */
  2771. /* reg_ppcnt_a_frames_transmitted_ok
  2772. * Access: RO
  2773. */
  2774. MLXSW_ITEM64(reg, ppcnt, a_frames_transmitted_ok,
  2775. 0x08 + 0x00, 0, 64);
  2776. /* reg_ppcnt_a_frames_received_ok
  2777. * Access: RO
  2778. */
  2779. MLXSW_ITEM64(reg, ppcnt, a_frames_received_ok,
  2780. 0x08 + 0x08, 0, 64);
  2781. /* reg_ppcnt_a_frame_check_sequence_errors
  2782. * Access: RO
  2783. */
  2784. MLXSW_ITEM64(reg, ppcnt, a_frame_check_sequence_errors,
  2785. 0x08 + 0x10, 0, 64);
  2786. /* reg_ppcnt_a_alignment_errors
  2787. * Access: RO
  2788. */
  2789. MLXSW_ITEM64(reg, ppcnt, a_alignment_errors,
  2790. 0x08 + 0x18, 0, 64);
  2791. /* reg_ppcnt_a_octets_transmitted_ok
  2792. * Access: RO
  2793. */
  2794. MLXSW_ITEM64(reg, ppcnt, a_octets_transmitted_ok,
  2795. 0x08 + 0x20, 0, 64);
  2796. /* reg_ppcnt_a_octets_received_ok
  2797. * Access: RO
  2798. */
  2799. MLXSW_ITEM64(reg, ppcnt, a_octets_received_ok,
  2800. 0x08 + 0x28, 0, 64);
  2801. /* reg_ppcnt_a_multicast_frames_xmitted_ok
  2802. * Access: RO
  2803. */
  2804. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_xmitted_ok,
  2805. 0x08 + 0x30, 0, 64);
  2806. /* reg_ppcnt_a_broadcast_frames_xmitted_ok
  2807. * Access: RO
  2808. */
  2809. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_xmitted_ok,
  2810. 0x08 + 0x38, 0, 64);
  2811. /* reg_ppcnt_a_multicast_frames_received_ok
  2812. * Access: RO
  2813. */
  2814. MLXSW_ITEM64(reg, ppcnt, a_multicast_frames_received_ok,
  2815. 0x08 + 0x40, 0, 64);
  2816. /* reg_ppcnt_a_broadcast_frames_received_ok
  2817. * Access: RO
  2818. */
  2819. MLXSW_ITEM64(reg, ppcnt, a_broadcast_frames_received_ok,
  2820. 0x08 + 0x48, 0, 64);
  2821. /* reg_ppcnt_a_in_range_length_errors
  2822. * Access: RO
  2823. */
  2824. MLXSW_ITEM64(reg, ppcnt, a_in_range_length_errors,
  2825. 0x08 + 0x50, 0, 64);
  2826. /* reg_ppcnt_a_out_of_range_length_field
  2827. * Access: RO
  2828. */
  2829. MLXSW_ITEM64(reg, ppcnt, a_out_of_range_length_field,
  2830. 0x08 + 0x58, 0, 64);
  2831. /* reg_ppcnt_a_frame_too_long_errors
  2832. * Access: RO
  2833. */
  2834. MLXSW_ITEM64(reg, ppcnt, a_frame_too_long_errors,
  2835. 0x08 + 0x60, 0, 64);
  2836. /* reg_ppcnt_a_symbol_error_during_carrier
  2837. * Access: RO
  2838. */
  2839. MLXSW_ITEM64(reg, ppcnt, a_symbol_error_during_carrier,
  2840. 0x08 + 0x68, 0, 64);
  2841. /* reg_ppcnt_a_mac_control_frames_transmitted
  2842. * Access: RO
  2843. */
  2844. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_transmitted,
  2845. 0x08 + 0x70, 0, 64);
  2846. /* reg_ppcnt_a_mac_control_frames_received
  2847. * Access: RO
  2848. */
  2849. MLXSW_ITEM64(reg, ppcnt, a_mac_control_frames_received,
  2850. 0x08 + 0x78, 0, 64);
  2851. /* reg_ppcnt_a_unsupported_opcodes_received
  2852. * Access: RO
  2853. */
  2854. MLXSW_ITEM64(reg, ppcnt, a_unsupported_opcodes_received,
  2855. 0x08 + 0x80, 0, 64);
  2856. /* reg_ppcnt_a_pause_mac_ctrl_frames_received
  2857. * Access: RO
  2858. */
  2859. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_received,
  2860. 0x08 + 0x88, 0, 64);
  2861. /* reg_ppcnt_a_pause_mac_ctrl_frames_transmitted
  2862. * Access: RO
  2863. */
  2864. MLXSW_ITEM64(reg, ppcnt, a_pause_mac_ctrl_frames_transmitted,
  2865. 0x08 + 0x90, 0, 64);
  2866. /* Ethernet Per Priority Group Counters */
  2867. /* reg_ppcnt_rx_octets
  2868. * Access: RO
  2869. */
  2870. MLXSW_ITEM64(reg, ppcnt, rx_octets, 0x08 + 0x00, 0, 64);
  2871. /* reg_ppcnt_rx_frames
  2872. * Access: RO
  2873. */
  2874. MLXSW_ITEM64(reg, ppcnt, rx_frames, 0x08 + 0x20, 0, 64);
  2875. /* reg_ppcnt_tx_octets
  2876. * Access: RO
  2877. */
  2878. MLXSW_ITEM64(reg, ppcnt, tx_octets, 0x08 + 0x28, 0, 64);
  2879. /* reg_ppcnt_tx_frames
  2880. * Access: RO
  2881. */
  2882. MLXSW_ITEM64(reg, ppcnt, tx_frames, 0x08 + 0x48, 0, 64);
  2883. /* reg_ppcnt_rx_pause
  2884. * Access: RO
  2885. */
  2886. MLXSW_ITEM64(reg, ppcnt, rx_pause, 0x08 + 0x50, 0, 64);
  2887. /* reg_ppcnt_rx_pause_duration
  2888. * Access: RO
  2889. */
  2890. MLXSW_ITEM64(reg, ppcnt, rx_pause_duration, 0x08 + 0x58, 0, 64);
  2891. /* reg_ppcnt_tx_pause
  2892. * Access: RO
  2893. */
  2894. MLXSW_ITEM64(reg, ppcnt, tx_pause, 0x08 + 0x60, 0, 64);
  2895. /* reg_ppcnt_tx_pause_duration
  2896. * Access: RO
  2897. */
  2898. MLXSW_ITEM64(reg, ppcnt, tx_pause_duration, 0x08 + 0x68, 0, 64);
  2899. /* reg_ppcnt_rx_pause_transition
  2900. * Access: RO
  2901. */
  2902. MLXSW_ITEM64(reg, ppcnt, tx_pause_transition, 0x08 + 0x70, 0, 64);
  2903. /* Ethernet Per Traffic Group Counters */
  2904. /* reg_ppcnt_tc_transmit_queue
  2905. * Contains the transmit queue depth in cells of traffic class
  2906. * selected by prio_tc and the port selected by local_port.
  2907. * The field cannot be cleared.
  2908. * Access: RO
  2909. */
  2910. MLXSW_ITEM64(reg, ppcnt, tc_transmit_queue, 0x08 + 0x00, 0, 64);
  2911. /* reg_ppcnt_tc_no_buffer_discard_uc
  2912. * The number of unicast packets dropped due to lack of shared
  2913. * buffer resources.
  2914. * Access: RO
  2915. */
  2916. MLXSW_ITEM64(reg, ppcnt, tc_no_buffer_discard_uc, 0x08 + 0x08, 0, 64);
  2917. static inline void mlxsw_reg_ppcnt_pack(char *payload, u8 local_port,
  2918. enum mlxsw_reg_ppcnt_grp grp,
  2919. u8 prio_tc)
  2920. {
  2921. MLXSW_REG_ZERO(ppcnt, payload);
  2922. mlxsw_reg_ppcnt_swid_set(payload, 0);
  2923. mlxsw_reg_ppcnt_local_port_set(payload, local_port);
  2924. mlxsw_reg_ppcnt_pnat_set(payload, 0);
  2925. mlxsw_reg_ppcnt_grp_set(payload, grp);
  2926. mlxsw_reg_ppcnt_clr_set(payload, 0);
  2927. mlxsw_reg_ppcnt_prio_tc_set(payload, prio_tc);
  2928. }
  2929. /* PLIB - Port Local to InfiniBand Port
  2930. * ------------------------------------
  2931. * The PLIB register performs mapping from Local Port into InfiniBand Port.
  2932. */
  2933. #define MLXSW_REG_PLIB_ID 0x500A
  2934. #define MLXSW_REG_PLIB_LEN 0x10
  2935. MLXSW_REG_DEFINE(plib, MLXSW_REG_PLIB_ID, MLXSW_REG_PLIB_LEN);
  2936. /* reg_plib_local_port
  2937. * Local port number.
  2938. * Access: Index
  2939. */
  2940. MLXSW_ITEM32(reg, plib, local_port, 0x00, 16, 8);
  2941. /* reg_plib_ib_port
  2942. * InfiniBand port remapping for local_port.
  2943. * Access: RW
  2944. */
  2945. MLXSW_ITEM32(reg, plib, ib_port, 0x00, 0, 8);
  2946. /* PPTB - Port Prio To Buffer Register
  2947. * -----------------------------------
  2948. * Configures the switch priority to buffer table.
  2949. */
  2950. #define MLXSW_REG_PPTB_ID 0x500B
  2951. #define MLXSW_REG_PPTB_LEN 0x10
  2952. MLXSW_REG_DEFINE(pptb, MLXSW_REG_PPTB_ID, MLXSW_REG_PPTB_LEN);
  2953. enum {
  2954. MLXSW_REG_PPTB_MM_UM,
  2955. MLXSW_REG_PPTB_MM_UNICAST,
  2956. MLXSW_REG_PPTB_MM_MULTICAST,
  2957. };
  2958. /* reg_pptb_mm
  2959. * Mapping mode.
  2960. * 0 - Map both unicast and multicast packets to the same buffer.
  2961. * 1 - Map only unicast packets.
  2962. * 2 - Map only multicast packets.
  2963. * Access: Index
  2964. *
  2965. * Note: SwitchX-2 only supports the first option.
  2966. */
  2967. MLXSW_ITEM32(reg, pptb, mm, 0x00, 28, 2);
  2968. /* reg_pptb_local_port
  2969. * Local port number.
  2970. * Access: Index
  2971. */
  2972. MLXSW_ITEM32(reg, pptb, local_port, 0x00, 16, 8);
  2973. /* reg_pptb_um
  2974. * Enables the update of the untagged_buf field.
  2975. * Access: RW
  2976. */
  2977. MLXSW_ITEM32(reg, pptb, um, 0x00, 8, 1);
  2978. /* reg_pptb_pm
  2979. * Enables the update of the prio_to_buff field.
  2980. * Bit <i> is a flag for updating the mapping for switch priority <i>.
  2981. * Access: RW
  2982. */
  2983. MLXSW_ITEM32(reg, pptb, pm, 0x00, 0, 8);
  2984. /* reg_pptb_prio_to_buff
  2985. * Mapping of switch priority <i> to one of the allocated receive port
  2986. * buffers.
  2987. * Access: RW
  2988. */
  2989. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff, 0x04, 0x04, 4);
  2990. /* reg_pptb_pm_msb
  2991. * Enables the update of the prio_to_buff field.
  2992. * Bit <i> is a flag for updating the mapping for switch priority <i+8>.
  2993. * Access: RW
  2994. */
  2995. MLXSW_ITEM32(reg, pptb, pm_msb, 0x08, 24, 8);
  2996. /* reg_pptb_untagged_buff
  2997. * Mapping of untagged frames to one of the allocated receive port buffers.
  2998. * Access: RW
  2999. *
  3000. * Note: In SwitchX-2 this field must be mapped to buffer 8. Reserved for
  3001. * Spectrum, as it maps untagged packets based on the default switch priority.
  3002. */
  3003. MLXSW_ITEM32(reg, pptb, untagged_buff, 0x08, 0, 4);
  3004. /* reg_pptb_prio_to_buff_msb
  3005. * Mapping of switch priority <i+8> to one of the allocated receive port
  3006. * buffers.
  3007. * Access: RW
  3008. */
  3009. MLXSW_ITEM_BIT_ARRAY(reg, pptb, prio_to_buff_msb, 0x0C, 0x04, 4);
  3010. #define MLXSW_REG_PPTB_ALL_PRIO 0xFF
  3011. static inline void mlxsw_reg_pptb_pack(char *payload, u8 local_port)
  3012. {
  3013. MLXSW_REG_ZERO(pptb, payload);
  3014. mlxsw_reg_pptb_mm_set(payload, MLXSW_REG_PPTB_MM_UM);
  3015. mlxsw_reg_pptb_local_port_set(payload, local_port);
  3016. mlxsw_reg_pptb_pm_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  3017. mlxsw_reg_pptb_pm_msb_set(payload, MLXSW_REG_PPTB_ALL_PRIO);
  3018. }
  3019. static inline void mlxsw_reg_pptb_prio_to_buff_pack(char *payload, u8 prio,
  3020. u8 buff)
  3021. {
  3022. mlxsw_reg_pptb_prio_to_buff_set(payload, prio, buff);
  3023. mlxsw_reg_pptb_prio_to_buff_msb_set(payload, prio, buff);
  3024. }
  3025. /* PBMC - Port Buffer Management Control Register
  3026. * ----------------------------------------------
  3027. * The PBMC register configures and retrieves the port packet buffer
  3028. * allocation for different Prios, and the Pause threshold management.
  3029. */
  3030. #define MLXSW_REG_PBMC_ID 0x500C
  3031. #define MLXSW_REG_PBMC_LEN 0x6C
  3032. MLXSW_REG_DEFINE(pbmc, MLXSW_REG_PBMC_ID, MLXSW_REG_PBMC_LEN);
  3033. /* reg_pbmc_local_port
  3034. * Local port number.
  3035. * Access: Index
  3036. */
  3037. MLXSW_ITEM32(reg, pbmc, local_port, 0x00, 16, 8);
  3038. /* reg_pbmc_xoff_timer_value
  3039. * When device generates a pause frame, it uses this value as the pause
  3040. * timer (time for the peer port to pause in quota-512 bit time).
  3041. * Access: RW
  3042. */
  3043. MLXSW_ITEM32(reg, pbmc, xoff_timer_value, 0x04, 16, 16);
  3044. /* reg_pbmc_xoff_refresh
  3045. * The time before a new pause frame should be sent to refresh the pause RW
  3046. * state. Using the same units as xoff_timer_value above (in quota-512 bit
  3047. * time).
  3048. * Access: RW
  3049. */
  3050. MLXSW_ITEM32(reg, pbmc, xoff_refresh, 0x04, 0, 16);
  3051. #define MLXSW_REG_PBMC_PORT_SHARED_BUF_IDX 11
  3052. /* reg_pbmc_buf_lossy
  3053. * The field indicates if the buffer is lossy.
  3054. * 0 - Lossless
  3055. * 1 - Lossy
  3056. * Access: RW
  3057. */
  3058. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_lossy, 0x0C, 25, 1, 0x08, 0x00, false);
  3059. /* reg_pbmc_buf_epsb
  3060. * Eligible for Port Shared buffer.
  3061. * If epsb is set, packets assigned to buffer are allowed to insert the port
  3062. * shared buffer.
  3063. * When buf_lossy is MLXSW_REG_PBMC_LOSSY_LOSSY this field is reserved.
  3064. * Access: RW
  3065. */
  3066. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_epsb, 0x0C, 24, 1, 0x08, 0x00, false);
  3067. /* reg_pbmc_buf_size
  3068. * The part of the packet buffer array is allocated for the specific buffer.
  3069. * Units are represented in cells.
  3070. * Access: RW
  3071. */
  3072. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_size, 0x0C, 0, 16, 0x08, 0x00, false);
  3073. /* reg_pbmc_buf_xoff_threshold
  3074. * Once the amount of data in the buffer goes above this value, device
  3075. * starts sending PFC frames for all priorities associated with the
  3076. * buffer. Units are represented in cells. Reserved in case of lossy
  3077. * buffer.
  3078. * Access: RW
  3079. *
  3080. * Note: In Spectrum, reserved for buffer[9].
  3081. */
  3082. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xoff_threshold, 0x0C, 16, 16,
  3083. 0x08, 0x04, false);
  3084. /* reg_pbmc_buf_xon_threshold
  3085. * When the amount of data in the buffer goes below this value, device
  3086. * stops sending PFC frames for the priorities associated with the
  3087. * buffer. Units are represented in cells. Reserved in case of lossy
  3088. * buffer.
  3089. * Access: RW
  3090. *
  3091. * Note: In Spectrum, reserved for buffer[9].
  3092. */
  3093. MLXSW_ITEM32_INDEXED(reg, pbmc, buf_xon_threshold, 0x0C, 0, 16,
  3094. 0x08, 0x04, false);
  3095. static inline void mlxsw_reg_pbmc_pack(char *payload, u8 local_port,
  3096. u16 xoff_timer_value, u16 xoff_refresh)
  3097. {
  3098. MLXSW_REG_ZERO(pbmc, payload);
  3099. mlxsw_reg_pbmc_local_port_set(payload, local_port);
  3100. mlxsw_reg_pbmc_xoff_timer_value_set(payload, xoff_timer_value);
  3101. mlxsw_reg_pbmc_xoff_refresh_set(payload, xoff_refresh);
  3102. }
  3103. static inline void mlxsw_reg_pbmc_lossy_buffer_pack(char *payload,
  3104. int buf_index,
  3105. u16 size)
  3106. {
  3107. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 1);
  3108. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  3109. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  3110. }
  3111. static inline void mlxsw_reg_pbmc_lossless_buffer_pack(char *payload,
  3112. int buf_index, u16 size,
  3113. u16 threshold)
  3114. {
  3115. mlxsw_reg_pbmc_buf_lossy_set(payload, buf_index, 0);
  3116. mlxsw_reg_pbmc_buf_epsb_set(payload, buf_index, 0);
  3117. mlxsw_reg_pbmc_buf_size_set(payload, buf_index, size);
  3118. mlxsw_reg_pbmc_buf_xoff_threshold_set(payload, buf_index, threshold);
  3119. mlxsw_reg_pbmc_buf_xon_threshold_set(payload, buf_index, threshold);
  3120. }
  3121. /* PSPA - Port Switch Partition Allocation
  3122. * ---------------------------------------
  3123. * Controls the association of a port with a switch partition and enables
  3124. * configuring ports as stacking ports.
  3125. */
  3126. #define MLXSW_REG_PSPA_ID 0x500D
  3127. #define MLXSW_REG_PSPA_LEN 0x8
  3128. MLXSW_REG_DEFINE(pspa, MLXSW_REG_PSPA_ID, MLXSW_REG_PSPA_LEN);
  3129. /* reg_pspa_swid
  3130. * Switch partition ID.
  3131. * Access: RW
  3132. */
  3133. MLXSW_ITEM32(reg, pspa, swid, 0x00, 24, 8);
  3134. /* reg_pspa_local_port
  3135. * Local port number.
  3136. * Access: Index
  3137. */
  3138. MLXSW_ITEM32(reg, pspa, local_port, 0x00, 16, 8);
  3139. /* reg_pspa_sub_port
  3140. * Virtual port within the local port. Set to 0 when virtual ports are
  3141. * disabled on the local port.
  3142. * Access: Index
  3143. */
  3144. MLXSW_ITEM32(reg, pspa, sub_port, 0x00, 8, 8);
  3145. static inline void mlxsw_reg_pspa_pack(char *payload, u8 swid, u8 local_port)
  3146. {
  3147. MLXSW_REG_ZERO(pspa, payload);
  3148. mlxsw_reg_pspa_swid_set(payload, swid);
  3149. mlxsw_reg_pspa_local_port_set(payload, local_port);
  3150. mlxsw_reg_pspa_sub_port_set(payload, 0);
  3151. }
  3152. /* HTGT - Host Trap Group Table
  3153. * ----------------------------
  3154. * Configures the properties for forwarding to CPU.
  3155. */
  3156. #define MLXSW_REG_HTGT_ID 0x7002
  3157. #define MLXSW_REG_HTGT_LEN 0x20
  3158. MLXSW_REG_DEFINE(htgt, MLXSW_REG_HTGT_ID, MLXSW_REG_HTGT_LEN);
  3159. /* reg_htgt_swid
  3160. * Switch partition ID.
  3161. * Access: Index
  3162. */
  3163. MLXSW_ITEM32(reg, htgt, swid, 0x00, 24, 8);
  3164. #define MLXSW_REG_HTGT_PATH_TYPE_LOCAL 0x0 /* For locally attached CPU */
  3165. /* reg_htgt_type
  3166. * CPU path type.
  3167. * Access: RW
  3168. */
  3169. MLXSW_ITEM32(reg, htgt, type, 0x00, 8, 4);
  3170. enum mlxsw_reg_htgt_trap_group {
  3171. MLXSW_REG_HTGT_TRAP_GROUP_EMAD,
  3172. MLXSW_REG_HTGT_TRAP_GROUP_SX2_RX,
  3173. MLXSW_REG_HTGT_TRAP_GROUP_SX2_CTRL,
  3174. MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
  3175. MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
  3176. MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
  3177. MLXSW_REG_HTGT_TRAP_GROUP_SP_IGMP,
  3178. MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP_IPV4,
  3179. MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
  3180. MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP,
  3181. MLXSW_REG_HTGT_TRAP_GROUP_SP_ARP_MISS,
  3182. MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
  3183. MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
  3184. MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
  3185. MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
  3186. MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
  3187. };
  3188. /* reg_htgt_trap_group
  3189. * Trap group number. User defined number specifying which trap groups
  3190. * should be forwarded to the CPU. The mapping between trap IDs and trap
  3191. * groups is configured using HPKT register.
  3192. * Access: Index
  3193. */
  3194. MLXSW_ITEM32(reg, htgt, trap_group, 0x00, 0, 8);
  3195. enum {
  3196. MLXSW_REG_HTGT_POLICER_DISABLE,
  3197. MLXSW_REG_HTGT_POLICER_ENABLE,
  3198. };
  3199. /* reg_htgt_pide
  3200. * Enable policer ID specified using 'pid' field.
  3201. * Access: RW
  3202. */
  3203. MLXSW_ITEM32(reg, htgt, pide, 0x04, 15, 1);
  3204. #define MLXSW_REG_HTGT_INVALID_POLICER 0xff
  3205. /* reg_htgt_pid
  3206. * Policer ID for the trap group.
  3207. * Access: RW
  3208. */
  3209. MLXSW_ITEM32(reg, htgt, pid, 0x04, 0, 8);
  3210. #define MLXSW_REG_HTGT_TRAP_TO_CPU 0x0
  3211. /* reg_htgt_mirror_action
  3212. * Mirror action to use.
  3213. * 0 - Trap to CPU.
  3214. * 1 - Trap to CPU and mirror to a mirroring agent.
  3215. * 2 - Mirror to a mirroring agent and do not trap to CPU.
  3216. * Access: RW
  3217. *
  3218. * Note: Mirroring to a mirroring agent is only supported in Spectrum.
  3219. */
  3220. MLXSW_ITEM32(reg, htgt, mirror_action, 0x08, 8, 2);
  3221. /* reg_htgt_mirroring_agent
  3222. * Mirroring agent.
  3223. * Access: RW
  3224. */
  3225. MLXSW_ITEM32(reg, htgt, mirroring_agent, 0x08, 0, 3);
  3226. #define MLXSW_REG_HTGT_DEFAULT_PRIORITY 0
  3227. /* reg_htgt_priority
  3228. * Trap group priority.
  3229. * In case a packet matches multiple classification rules, the packet will
  3230. * only be trapped once, based on the trap ID associated with the group (via
  3231. * register HPKT) with the highest priority.
  3232. * Supported values are 0-7, with 7 represnting the highest priority.
  3233. * Access: RW
  3234. *
  3235. * Note: In SwitchX-2 this field is ignored and the priority value is replaced
  3236. * by the 'trap_group' field.
  3237. */
  3238. MLXSW_ITEM32(reg, htgt, priority, 0x0C, 0, 4);
  3239. #define MLXSW_REG_HTGT_DEFAULT_TC 7
  3240. /* reg_htgt_local_path_cpu_tclass
  3241. * CPU ingress traffic class for the trap group.
  3242. * Access: RW
  3243. */
  3244. MLXSW_ITEM32(reg, htgt, local_path_cpu_tclass, 0x10, 16, 6);
  3245. enum mlxsw_reg_htgt_local_path_rdq {
  3246. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_CTRL = 0x13,
  3247. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_RX = 0x14,
  3248. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SX2_EMAD = 0x15,
  3249. MLXSW_REG_HTGT_LOCAL_PATH_RDQ_SIB_EMAD = 0x15,
  3250. };
  3251. /* reg_htgt_local_path_rdq
  3252. * Receive descriptor queue (RDQ) to use for the trap group.
  3253. * Access: RW
  3254. */
  3255. MLXSW_ITEM32(reg, htgt, local_path_rdq, 0x10, 0, 6);
  3256. static inline void mlxsw_reg_htgt_pack(char *payload, u8 group, u8 policer_id,
  3257. u8 priority, u8 tc)
  3258. {
  3259. MLXSW_REG_ZERO(htgt, payload);
  3260. if (policer_id == MLXSW_REG_HTGT_INVALID_POLICER) {
  3261. mlxsw_reg_htgt_pide_set(payload,
  3262. MLXSW_REG_HTGT_POLICER_DISABLE);
  3263. } else {
  3264. mlxsw_reg_htgt_pide_set(payload,
  3265. MLXSW_REG_HTGT_POLICER_ENABLE);
  3266. mlxsw_reg_htgt_pid_set(payload, policer_id);
  3267. }
  3268. mlxsw_reg_htgt_type_set(payload, MLXSW_REG_HTGT_PATH_TYPE_LOCAL);
  3269. mlxsw_reg_htgt_trap_group_set(payload, group);
  3270. mlxsw_reg_htgt_mirror_action_set(payload, MLXSW_REG_HTGT_TRAP_TO_CPU);
  3271. mlxsw_reg_htgt_mirroring_agent_set(payload, 0);
  3272. mlxsw_reg_htgt_priority_set(payload, priority);
  3273. mlxsw_reg_htgt_local_path_cpu_tclass_set(payload, tc);
  3274. mlxsw_reg_htgt_local_path_rdq_set(payload, group);
  3275. }
  3276. /* HPKT - Host Packet Trap
  3277. * -----------------------
  3278. * Configures trap IDs inside trap groups.
  3279. */
  3280. #define MLXSW_REG_HPKT_ID 0x7003
  3281. #define MLXSW_REG_HPKT_LEN 0x10
  3282. MLXSW_REG_DEFINE(hpkt, MLXSW_REG_HPKT_ID, MLXSW_REG_HPKT_LEN);
  3283. enum {
  3284. MLXSW_REG_HPKT_ACK_NOT_REQUIRED,
  3285. MLXSW_REG_HPKT_ACK_REQUIRED,
  3286. };
  3287. /* reg_hpkt_ack
  3288. * Require acknowledgements from the host for events.
  3289. * If set, then the device will wait for the event it sent to be acknowledged
  3290. * by the host. This option is only relevant for event trap IDs.
  3291. * Access: RW
  3292. *
  3293. * Note: Currently not supported by firmware.
  3294. */
  3295. MLXSW_ITEM32(reg, hpkt, ack, 0x00, 24, 1);
  3296. enum mlxsw_reg_hpkt_action {
  3297. MLXSW_REG_HPKT_ACTION_FORWARD,
  3298. MLXSW_REG_HPKT_ACTION_TRAP_TO_CPU,
  3299. MLXSW_REG_HPKT_ACTION_MIRROR_TO_CPU,
  3300. MLXSW_REG_HPKT_ACTION_DISCARD,
  3301. MLXSW_REG_HPKT_ACTION_SOFT_DISCARD,
  3302. MLXSW_REG_HPKT_ACTION_TRAP_AND_SOFT_DISCARD,
  3303. };
  3304. /* reg_hpkt_action
  3305. * Action to perform on packet when trapped.
  3306. * 0 - No action. Forward to CPU based on switching rules.
  3307. * 1 - Trap to CPU (CPU receives sole copy).
  3308. * 2 - Mirror to CPU (CPU receives a replica of the packet).
  3309. * 3 - Discard.
  3310. * 4 - Soft discard (allow other traps to act on the packet).
  3311. * 5 - Trap and soft discard (allow other traps to overwrite this trap).
  3312. * Access: RW
  3313. *
  3314. * Note: Must be set to 0 (forward) for event trap IDs, as they are already
  3315. * addressed to the CPU.
  3316. */
  3317. MLXSW_ITEM32(reg, hpkt, action, 0x00, 20, 3);
  3318. /* reg_hpkt_trap_group
  3319. * Trap group to associate the trap with.
  3320. * Access: RW
  3321. */
  3322. MLXSW_ITEM32(reg, hpkt, trap_group, 0x00, 12, 6);
  3323. /* reg_hpkt_trap_id
  3324. * Trap ID.
  3325. * Access: Index
  3326. *
  3327. * Note: A trap ID can only be associated with a single trap group. The device
  3328. * will associate the trap ID with the last trap group configured.
  3329. */
  3330. MLXSW_ITEM32(reg, hpkt, trap_id, 0x00, 0, 9);
  3331. enum {
  3332. MLXSW_REG_HPKT_CTRL_PACKET_DEFAULT,
  3333. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER,
  3334. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER,
  3335. };
  3336. /* reg_hpkt_ctrl
  3337. * Configure dedicated buffer resources for control packets.
  3338. * Ignored by SwitchX-2.
  3339. * 0 - Keep factory defaults.
  3340. * 1 - Do not use control buffer for this trap ID.
  3341. * 2 - Use control buffer for this trap ID.
  3342. * Access: RW
  3343. */
  3344. MLXSW_ITEM32(reg, hpkt, ctrl, 0x04, 16, 2);
  3345. static inline void mlxsw_reg_hpkt_pack(char *payload, u8 action, u16 trap_id,
  3346. enum mlxsw_reg_htgt_trap_group trap_group,
  3347. bool is_ctrl)
  3348. {
  3349. MLXSW_REG_ZERO(hpkt, payload);
  3350. mlxsw_reg_hpkt_ack_set(payload, MLXSW_REG_HPKT_ACK_NOT_REQUIRED);
  3351. mlxsw_reg_hpkt_action_set(payload, action);
  3352. mlxsw_reg_hpkt_trap_group_set(payload, trap_group);
  3353. mlxsw_reg_hpkt_trap_id_set(payload, trap_id);
  3354. mlxsw_reg_hpkt_ctrl_set(payload, is_ctrl ?
  3355. MLXSW_REG_HPKT_CTRL_PACKET_USE_BUFFER :
  3356. MLXSW_REG_HPKT_CTRL_PACKET_NO_BUFFER);
  3357. }
  3358. /* RGCR - Router General Configuration Register
  3359. * --------------------------------------------
  3360. * The register is used for setting up the router configuration.
  3361. */
  3362. #define MLXSW_REG_RGCR_ID 0x8001
  3363. #define MLXSW_REG_RGCR_LEN 0x28
  3364. MLXSW_REG_DEFINE(rgcr, MLXSW_REG_RGCR_ID, MLXSW_REG_RGCR_LEN);
  3365. /* reg_rgcr_ipv4_en
  3366. * IPv4 router enable.
  3367. * Access: RW
  3368. */
  3369. MLXSW_ITEM32(reg, rgcr, ipv4_en, 0x00, 31, 1);
  3370. /* reg_rgcr_ipv6_en
  3371. * IPv6 router enable.
  3372. * Access: RW
  3373. */
  3374. MLXSW_ITEM32(reg, rgcr, ipv6_en, 0x00, 30, 1);
  3375. /* reg_rgcr_max_router_interfaces
  3376. * Defines the maximum number of active router interfaces for all virtual
  3377. * routers.
  3378. * Access: RW
  3379. */
  3380. MLXSW_ITEM32(reg, rgcr, max_router_interfaces, 0x10, 0, 16);
  3381. /* reg_rgcr_usp
  3382. * Update switch priority and packet color.
  3383. * 0 - Preserve the value of Switch Priority and packet color.
  3384. * 1 - Recalculate the value of Switch Priority and packet color.
  3385. * Access: RW
  3386. *
  3387. * Note: Not supported by SwitchX and SwitchX-2.
  3388. */
  3389. MLXSW_ITEM32(reg, rgcr, usp, 0x18, 20, 1);
  3390. /* reg_rgcr_pcp_rw
  3391. * Indicates how to handle the pcp_rewrite_en value:
  3392. * 0 - Preserve the value of pcp_rewrite_en.
  3393. * 2 - Disable PCP rewrite.
  3394. * 3 - Enable PCP rewrite.
  3395. * Access: RW
  3396. *
  3397. * Note: Not supported by SwitchX and SwitchX-2.
  3398. */
  3399. MLXSW_ITEM32(reg, rgcr, pcp_rw, 0x18, 16, 2);
  3400. /* reg_rgcr_activity_dis
  3401. * Activity disable:
  3402. * 0 - Activity will be set when an entry is hit (default).
  3403. * 1 - Activity will not be set when an entry is hit.
  3404. *
  3405. * Bit 0 - Disable activity bit in Router Algorithmic LPM Unicast Entry
  3406. * (RALUE).
  3407. * Bit 1 - Disable activity bit in Router Algorithmic LPM Unicast Host
  3408. * Entry (RAUHT).
  3409. * Bits 2:7 are reserved.
  3410. * Access: RW
  3411. *
  3412. * Note: Not supported by SwitchX, SwitchX-2 and Switch-IB.
  3413. */
  3414. MLXSW_ITEM32(reg, rgcr, activity_dis, 0x20, 0, 8);
  3415. static inline void mlxsw_reg_rgcr_pack(char *payload, bool ipv4_en)
  3416. {
  3417. MLXSW_REG_ZERO(rgcr, payload);
  3418. mlxsw_reg_rgcr_ipv4_en_set(payload, ipv4_en);
  3419. }
  3420. /* RITR - Router Interface Table Register
  3421. * --------------------------------------
  3422. * The register is used to configure the router interface table.
  3423. */
  3424. #define MLXSW_REG_RITR_ID 0x8002
  3425. #define MLXSW_REG_RITR_LEN 0x40
  3426. MLXSW_REG_DEFINE(ritr, MLXSW_REG_RITR_ID, MLXSW_REG_RITR_LEN);
  3427. /* reg_ritr_enable
  3428. * Enables routing on the router interface.
  3429. * Access: RW
  3430. */
  3431. MLXSW_ITEM32(reg, ritr, enable, 0x00, 31, 1);
  3432. /* reg_ritr_ipv4
  3433. * IPv4 routing enable. Enables routing of IPv4 traffic on the router
  3434. * interface.
  3435. * Access: RW
  3436. */
  3437. MLXSW_ITEM32(reg, ritr, ipv4, 0x00, 29, 1);
  3438. /* reg_ritr_ipv6
  3439. * IPv6 routing enable. Enables routing of IPv6 traffic on the router
  3440. * interface.
  3441. * Access: RW
  3442. */
  3443. MLXSW_ITEM32(reg, ritr, ipv6, 0x00, 28, 1);
  3444. enum mlxsw_reg_ritr_if_type {
  3445. MLXSW_REG_RITR_VLAN_IF,
  3446. MLXSW_REG_RITR_FID_IF,
  3447. MLXSW_REG_RITR_SP_IF,
  3448. };
  3449. /* reg_ritr_type
  3450. * Router interface type.
  3451. * 0 - VLAN interface.
  3452. * 1 - FID interface.
  3453. * 2 - Sub-port interface.
  3454. * Access: RW
  3455. */
  3456. MLXSW_ITEM32(reg, ritr, type, 0x00, 23, 3);
  3457. enum {
  3458. MLXSW_REG_RITR_RIF_CREATE,
  3459. MLXSW_REG_RITR_RIF_DEL,
  3460. };
  3461. /* reg_ritr_op
  3462. * Opcode:
  3463. * 0 - Create or edit RIF.
  3464. * 1 - Delete RIF.
  3465. * Reserved for SwitchX-2. For Spectrum, editing of interface properties
  3466. * is not supported. An interface must be deleted and re-created in order
  3467. * to update properties.
  3468. * Access: WO
  3469. */
  3470. MLXSW_ITEM32(reg, ritr, op, 0x00, 20, 2);
  3471. /* reg_ritr_rif
  3472. * Router interface index. A pointer to the Router Interface Table.
  3473. * Access: Index
  3474. */
  3475. MLXSW_ITEM32(reg, ritr, rif, 0x00, 0, 16);
  3476. /* reg_ritr_ipv4_fe
  3477. * IPv4 Forwarding Enable.
  3478. * Enables routing of IPv4 traffic on the router interface. When disabled,
  3479. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  3480. * Not supported in SwitchX-2.
  3481. * Access: RW
  3482. */
  3483. MLXSW_ITEM32(reg, ritr, ipv4_fe, 0x04, 29, 1);
  3484. /* reg_ritr_ipv6_fe
  3485. * IPv6 Forwarding Enable.
  3486. * Enables routing of IPv6 traffic on the router interface. When disabled,
  3487. * forwarding is blocked but local traffic (traps and IP2ME) will be enabled.
  3488. * Not supported in SwitchX-2.
  3489. * Access: RW
  3490. */
  3491. MLXSW_ITEM32(reg, ritr, ipv6_fe, 0x04, 28, 1);
  3492. /* reg_ritr_lb_en
  3493. * Loop-back filter enable for unicast packets.
  3494. * If the flag is set then loop-back filter for unicast packets is
  3495. * implemented on the RIF. Multicast packets are always subject to
  3496. * loop-back filtering.
  3497. * Access: RW
  3498. */
  3499. MLXSW_ITEM32(reg, ritr, lb_en, 0x04, 24, 1);
  3500. /* reg_ritr_virtual_router
  3501. * Virtual router ID associated with the router interface.
  3502. * Access: RW
  3503. */
  3504. MLXSW_ITEM32(reg, ritr, virtual_router, 0x04, 0, 16);
  3505. /* reg_ritr_mtu
  3506. * Router interface MTU.
  3507. * Access: RW
  3508. */
  3509. MLXSW_ITEM32(reg, ritr, mtu, 0x34, 0, 16);
  3510. /* reg_ritr_if_swid
  3511. * Switch partition ID.
  3512. * Access: RW
  3513. */
  3514. MLXSW_ITEM32(reg, ritr, if_swid, 0x08, 24, 8);
  3515. /* reg_ritr_if_mac
  3516. * Router interface MAC address.
  3517. * In Spectrum, all MAC addresses must have the same 38 MSBits.
  3518. * Access: RW
  3519. */
  3520. MLXSW_ITEM_BUF(reg, ritr, if_mac, 0x12, 6);
  3521. /* VLAN Interface */
  3522. /* reg_ritr_vlan_if_vid
  3523. * VLAN ID.
  3524. * Access: RW
  3525. */
  3526. MLXSW_ITEM32(reg, ritr, vlan_if_vid, 0x08, 0, 12);
  3527. /* FID Interface */
  3528. /* reg_ritr_fid_if_fid
  3529. * Filtering ID. Used to connect a bridge to the router. Only FIDs from
  3530. * the vFID range are supported.
  3531. * Access: RW
  3532. */
  3533. MLXSW_ITEM32(reg, ritr, fid_if_fid, 0x08, 0, 16);
  3534. static inline void mlxsw_reg_ritr_fid_set(char *payload,
  3535. enum mlxsw_reg_ritr_if_type rif_type,
  3536. u16 fid)
  3537. {
  3538. if (rif_type == MLXSW_REG_RITR_FID_IF)
  3539. mlxsw_reg_ritr_fid_if_fid_set(payload, fid);
  3540. else
  3541. mlxsw_reg_ritr_vlan_if_vid_set(payload, fid);
  3542. }
  3543. /* Sub-port Interface */
  3544. /* reg_ritr_sp_if_lag
  3545. * LAG indication. When this bit is set the system_port field holds the
  3546. * LAG identifier.
  3547. * Access: RW
  3548. */
  3549. MLXSW_ITEM32(reg, ritr, sp_if_lag, 0x08, 24, 1);
  3550. /* reg_ritr_sp_system_port
  3551. * Port unique indentifier. When lag bit is set, this field holds the
  3552. * lag_id in bits 0:9.
  3553. * Access: RW
  3554. */
  3555. MLXSW_ITEM32(reg, ritr, sp_if_system_port, 0x08, 0, 16);
  3556. /* reg_ritr_sp_if_vid
  3557. * VLAN ID.
  3558. * Access: RW
  3559. */
  3560. MLXSW_ITEM32(reg, ritr, sp_if_vid, 0x18, 0, 12);
  3561. /* Shared between ingress/egress */
  3562. enum mlxsw_reg_ritr_counter_set_type {
  3563. /* No Count. */
  3564. MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT = 0x0,
  3565. /* Basic. Used for router interfaces, counting the following:
  3566. * - Error and Discard counters.
  3567. * - Unicast, Multicast and Broadcast counters. Sharing the
  3568. * same set of counters for the different type of traffic
  3569. * (IPv4, IPv6 and mpls).
  3570. */
  3571. MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC = 0x9,
  3572. };
  3573. /* reg_ritr_ingress_counter_index
  3574. * Counter Index for flow counter.
  3575. * Access: RW
  3576. */
  3577. MLXSW_ITEM32(reg, ritr, ingress_counter_index, 0x38, 0, 24);
  3578. /* reg_ritr_ingress_counter_set_type
  3579. * Igress Counter Set Type for router interface counter.
  3580. * Access: RW
  3581. */
  3582. MLXSW_ITEM32(reg, ritr, ingress_counter_set_type, 0x38, 24, 8);
  3583. /* reg_ritr_egress_counter_index
  3584. * Counter Index for flow counter.
  3585. * Access: RW
  3586. */
  3587. MLXSW_ITEM32(reg, ritr, egress_counter_index, 0x3C, 0, 24);
  3588. /* reg_ritr_egress_counter_set_type
  3589. * Egress Counter Set Type for router interface counter.
  3590. * Access: RW
  3591. */
  3592. MLXSW_ITEM32(reg, ritr, egress_counter_set_type, 0x3C, 24, 8);
  3593. static inline void mlxsw_reg_ritr_counter_pack(char *payload, u32 index,
  3594. bool enable, bool egress)
  3595. {
  3596. enum mlxsw_reg_ritr_counter_set_type set_type;
  3597. if (enable)
  3598. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_BASIC;
  3599. else
  3600. set_type = MLXSW_REG_RITR_COUNTER_SET_TYPE_NO_COUNT;
  3601. mlxsw_reg_ritr_egress_counter_set_type_set(payload, set_type);
  3602. if (egress)
  3603. mlxsw_reg_ritr_egress_counter_index_set(payload, index);
  3604. else
  3605. mlxsw_reg_ritr_ingress_counter_index_set(payload, index);
  3606. }
  3607. static inline void mlxsw_reg_ritr_rif_pack(char *payload, u16 rif)
  3608. {
  3609. MLXSW_REG_ZERO(ritr, payload);
  3610. mlxsw_reg_ritr_rif_set(payload, rif);
  3611. }
  3612. static inline void mlxsw_reg_ritr_sp_if_pack(char *payload, bool lag,
  3613. u16 system_port, u16 vid)
  3614. {
  3615. mlxsw_reg_ritr_sp_if_lag_set(payload, lag);
  3616. mlxsw_reg_ritr_sp_if_system_port_set(payload, system_port);
  3617. mlxsw_reg_ritr_sp_if_vid_set(payload, vid);
  3618. }
  3619. static inline void mlxsw_reg_ritr_pack(char *payload, bool enable,
  3620. enum mlxsw_reg_ritr_if_type type,
  3621. u16 rif, u16 vr_id, u16 mtu,
  3622. const char *mac)
  3623. {
  3624. bool op = enable ? MLXSW_REG_RITR_RIF_CREATE : MLXSW_REG_RITR_RIF_DEL;
  3625. MLXSW_REG_ZERO(ritr, payload);
  3626. mlxsw_reg_ritr_enable_set(payload, enable);
  3627. mlxsw_reg_ritr_ipv4_set(payload, 1);
  3628. mlxsw_reg_ritr_type_set(payload, type);
  3629. mlxsw_reg_ritr_op_set(payload, op);
  3630. mlxsw_reg_ritr_rif_set(payload, rif);
  3631. mlxsw_reg_ritr_ipv4_fe_set(payload, 1);
  3632. mlxsw_reg_ritr_lb_en_set(payload, 1);
  3633. mlxsw_reg_ritr_virtual_router_set(payload, vr_id);
  3634. mlxsw_reg_ritr_mtu_set(payload, mtu);
  3635. mlxsw_reg_ritr_if_mac_memcpy_to(payload, mac);
  3636. }
  3637. /* RATR - Router Adjacency Table Register
  3638. * --------------------------------------
  3639. * The RATR register is used to configure the Router Adjacency (next-hop)
  3640. * Table.
  3641. */
  3642. #define MLXSW_REG_RATR_ID 0x8008
  3643. #define MLXSW_REG_RATR_LEN 0x2C
  3644. MLXSW_REG_DEFINE(ratr, MLXSW_REG_RATR_ID, MLXSW_REG_RATR_LEN);
  3645. enum mlxsw_reg_ratr_op {
  3646. /* Read */
  3647. MLXSW_REG_RATR_OP_QUERY_READ = 0,
  3648. /* Read and clear activity */
  3649. MLXSW_REG_RATR_OP_QUERY_READ_CLEAR = 2,
  3650. /* Write Adjacency entry */
  3651. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY = 1,
  3652. /* Write Adjacency entry only if the activity is cleared.
  3653. * The write may not succeed if the activity is set. There is not
  3654. * direct feedback if the write has succeeded or not, however
  3655. * the get will reveal the actual entry (SW can compare the get
  3656. * response to the set command).
  3657. */
  3658. MLXSW_REG_RATR_OP_WRITE_WRITE_ENTRY_ON_ACTIVITY = 3,
  3659. };
  3660. /* reg_ratr_op
  3661. * Note that Write operation may also be used for updating
  3662. * counter_set_type and counter_index. In this case all other
  3663. * fields must not be updated.
  3664. * Access: OP
  3665. */
  3666. MLXSW_ITEM32(reg, ratr, op, 0x00, 28, 4);
  3667. /* reg_ratr_v
  3668. * Valid bit. Indicates if the adjacency entry is valid.
  3669. * Note: the device may need some time before reusing an invalidated
  3670. * entry. During this time the entry can not be reused. It is
  3671. * recommended to use another entry before reusing an invalidated
  3672. * entry (e.g. software can put it at the end of the list for
  3673. * reusing). Trying to access an invalidated entry not yet cleared
  3674. * by the device results with failure indicating "Try Again" status.
  3675. * When valid is '0' then egress_router_interface,trap_action,
  3676. * adjacency_parameters and counters are reserved
  3677. * Access: RW
  3678. */
  3679. MLXSW_ITEM32(reg, ratr, v, 0x00, 24, 1);
  3680. /* reg_ratr_a
  3681. * Activity. Set for new entries. Set if a packet lookup has hit on
  3682. * the specific entry. To clear the a bit, use "clear activity".
  3683. * Access: RO
  3684. */
  3685. MLXSW_ITEM32(reg, ratr, a, 0x00, 16, 1);
  3686. /* reg_ratr_adjacency_index_low
  3687. * Bits 15:0 of index into the adjacency table.
  3688. * For SwitchX and SwitchX-2, the adjacency table is linear and
  3689. * used for adjacency entries only.
  3690. * For Spectrum, the index is to the KVD linear.
  3691. * Access: Index
  3692. */
  3693. MLXSW_ITEM32(reg, ratr, adjacency_index_low, 0x04, 0, 16);
  3694. /* reg_ratr_egress_router_interface
  3695. * Range is 0 .. cap_max_router_interfaces - 1
  3696. * Access: RW
  3697. */
  3698. MLXSW_ITEM32(reg, ratr, egress_router_interface, 0x08, 0, 16);
  3699. enum mlxsw_reg_ratr_trap_action {
  3700. MLXSW_REG_RATR_TRAP_ACTION_NOP,
  3701. MLXSW_REG_RATR_TRAP_ACTION_TRAP,
  3702. MLXSW_REG_RATR_TRAP_ACTION_MIRROR_TO_CPU,
  3703. MLXSW_REG_RATR_TRAP_ACTION_MIRROR,
  3704. MLXSW_REG_RATR_TRAP_ACTION_DISCARD_ERRORS,
  3705. };
  3706. /* reg_ratr_trap_action
  3707. * see mlxsw_reg_ratr_trap_action
  3708. * Access: RW
  3709. */
  3710. MLXSW_ITEM32(reg, ratr, trap_action, 0x0C, 28, 4);
  3711. enum mlxsw_reg_ratr_trap_id {
  3712. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS0 = 0,
  3713. MLXSW_REG_RATR_TRAP_ID_RTR_EGRESS1 = 1,
  3714. };
  3715. /* reg_ratr_adjacency_index_high
  3716. * Bits 23:16 of the adjacency_index.
  3717. * Access: Index
  3718. */
  3719. MLXSW_ITEM32(reg, ratr, adjacency_index_high, 0x0C, 16, 8);
  3720. /* reg_ratr_trap_id
  3721. * Trap ID to be reported to CPU.
  3722. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  3723. * For trap_action of NOP, MIRROR and DISCARD_ERROR
  3724. * Access: RW
  3725. */
  3726. MLXSW_ITEM32(reg, ratr, trap_id, 0x0C, 0, 8);
  3727. /* reg_ratr_eth_destination_mac
  3728. * MAC address of the destination next-hop.
  3729. * Access: RW
  3730. */
  3731. MLXSW_ITEM_BUF(reg, ratr, eth_destination_mac, 0x12, 6);
  3732. static inline void
  3733. mlxsw_reg_ratr_pack(char *payload,
  3734. enum mlxsw_reg_ratr_op op, bool valid,
  3735. u32 adjacency_index, u16 egress_rif)
  3736. {
  3737. MLXSW_REG_ZERO(ratr, payload);
  3738. mlxsw_reg_ratr_op_set(payload, op);
  3739. mlxsw_reg_ratr_v_set(payload, valid);
  3740. mlxsw_reg_ratr_adjacency_index_low_set(payload, adjacency_index);
  3741. mlxsw_reg_ratr_adjacency_index_high_set(payload, adjacency_index >> 16);
  3742. mlxsw_reg_ratr_egress_router_interface_set(payload, egress_rif);
  3743. }
  3744. static inline void mlxsw_reg_ratr_eth_entry_pack(char *payload,
  3745. const char *dest_mac)
  3746. {
  3747. mlxsw_reg_ratr_eth_destination_mac_memcpy_to(payload, dest_mac);
  3748. }
  3749. /* RICNT - Router Interface Counter Register
  3750. * -----------------------------------------
  3751. * The RICNT register retrieves per port performance counters
  3752. */
  3753. #define MLXSW_REG_RICNT_ID 0x800B
  3754. #define MLXSW_REG_RICNT_LEN 0x100
  3755. MLXSW_REG_DEFINE(ricnt, MLXSW_REG_RICNT_ID, MLXSW_REG_RICNT_LEN);
  3756. /* reg_ricnt_counter_index
  3757. * Counter index
  3758. * Access: RW
  3759. */
  3760. MLXSW_ITEM32(reg, ricnt, counter_index, 0x04, 0, 24);
  3761. enum mlxsw_reg_ricnt_counter_set_type {
  3762. /* No Count. */
  3763. MLXSW_REG_RICNT_COUNTER_SET_TYPE_NO_COUNT = 0x00,
  3764. /* Basic. Used for router interfaces, counting the following:
  3765. * - Error and Discard counters.
  3766. * - Unicast, Multicast and Broadcast counters. Sharing the
  3767. * same set of counters for the different type of traffic
  3768. * (IPv4, IPv6 and mpls).
  3769. */
  3770. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC = 0x09,
  3771. };
  3772. /* reg_ricnt_counter_set_type
  3773. * Counter Set Type for router interface counter
  3774. * Access: RW
  3775. */
  3776. MLXSW_ITEM32(reg, ricnt, counter_set_type, 0x04, 24, 8);
  3777. enum mlxsw_reg_ricnt_opcode {
  3778. /* Nop. Supported only for read access*/
  3779. MLXSW_REG_RICNT_OPCODE_NOP = 0x00,
  3780. /* Clear. Setting the clr bit will reset the counter value for
  3781. * all counters of the specified Router Interface.
  3782. */
  3783. MLXSW_REG_RICNT_OPCODE_CLEAR = 0x08,
  3784. };
  3785. /* reg_ricnt_opcode
  3786. * Opcode
  3787. * Access: RW
  3788. */
  3789. MLXSW_ITEM32(reg, ricnt, op, 0x00, 28, 4);
  3790. /* reg_ricnt_good_unicast_packets
  3791. * good unicast packets.
  3792. * Access: RW
  3793. */
  3794. MLXSW_ITEM64(reg, ricnt, good_unicast_packets, 0x08, 0, 64);
  3795. /* reg_ricnt_good_multicast_packets
  3796. * good multicast packets.
  3797. * Access: RW
  3798. */
  3799. MLXSW_ITEM64(reg, ricnt, good_multicast_packets, 0x10, 0, 64);
  3800. /* reg_ricnt_good_broadcast_packets
  3801. * good broadcast packets
  3802. * Access: RW
  3803. */
  3804. MLXSW_ITEM64(reg, ricnt, good_broadcast_packets, 0x18, 0, 64);
  3805. /* reg_ricnt_good_unicast_bytes
  3806. * A count of L3 data and padding octets not including L2 headers
  3807. * for good unicast frames.
  3808. * Access: RW
  3809. */
  3810. MLXSW_ITEM64(reg, ricnt, good_unicast_bytes, 0x20, 0, 64);
  3811. /* reg_ricnt_good_multicast_bytes
  3812. * A count of L3 data and padding octets not including L2 headers
  3813. * for good multicast frames.
  3814. * Access: RW
  3815. */
  3816. MLXSW_ITEM64(reg, ricnt, good_multicast_bytes, 0x28, 0, 64);
  3817. /* reg_ritr_good_broadcast_bytes
  3818. * A count of L3 data and padding octets not including L2 headers
  3819. * for good broadcast frames.
  3820. * Access: RW
  3821. */
  3822. MLXSW_ITEM64(reg, ricnt, good_broadcast_bytes, 0x30, 0, 64);
  3823. /* reg_ricnt_error_packets
  3824. * A count of errored frames that do not pass the router checks.
  3825. * Access: RW
  3826. */
  3827. MLXSW_ITEM64(reg, ricnt, error_packets, 0x38, 0, 64);
  3828. /* reg_ricnt_discrad_packets
  3829. * A count of non-errored frames that do not pass the router checks.
  3830. * Access: RW
  3831. */
  3832. MLXSW_ITEM64(reg, ricnt, discard_packets, 0x40, 0, 64);
  3833. /* reg_ricnt_error_bytes
  3834. * A count of L3 data and padding octets not including L2 headers
  3835. * for errored frames.
  3836. * Access: RW
  3837. */
  3838. MLXSW_ITEM64(reg, ricnt, error_bytes, 0x48, 0, 64);
  3839. /* reg_ricnt_discard_bytes
  3840. * A count of L3 data and padding octets not including L2 headers
  3841. * for non-errored frames that do not pass the router checks.
  3842. * Access: RW
  3843. */
  3844. MLXSW_ITEM64(reg, ricnt, discard_bytes, 0x50, 0, 64);
  3845. static inline void mlxsw_reg_ricnt_pack(char *payload, u32 index,
  3846. enum mlxsw_reg_ricnt_opcode op)
  3847. {
  3848. MLXSW_REG_ZERO(ricnt, payload);
  3849. mlxsw_reg_ricnt_op_set(payload, op);
  3850. mlxsw_reg_ricnt_counter_index_set(payload, index);
  3851. mlxsw_reg_ricnt_counter_set_type_set(payload,
  3852. MLXSW_REG_RICNT_COUNTER_SET_TYPE_BASIC);
  3853. }
  3854. /* RALTA - Router Algorithmic LPM Tree Allocation Register
  3855. * -------------------------------------------------------
  3856. * RALTA is used to allocate the LPM trees of the SHSPM method.
  3857. */
  3858. #define MLXSW_REG_RALTA_ID 0x8010
  3859. #define MLXSW_REG_RALTA_LEN 0x04
  3860. MLXSW_REG_DEFINE(ralta, MLXSW_REG_RALTA_ID, MLXSW_REG_RALTA_LEN);
  3861. /* reg_ralta_op
  3862. * opcode (valid for Write, must be 0 on Read)
  3863. * 0 - allocate a tree
  3864. * 1 - deallocate a tree
  3865. * Access: OP
  3866. */
  3867. MLXSW_ITEM32(reg, ralta, op, 0x00, 28, 2);
  3868. enum mlxsw_reg_ralxx_protocol {
  3869. MLXSW_REG_RALXX_PROTOCOL_IPV4,
  3870. MLXSW_REG_RALXX_PROTOCOL_IPV6,
  3871. };
  3872. /* reg_ralta_protocol
  3873. * Protocol.
  3874. * Deallocation opcode: Reserved.
  3875. * Access: RW
  3876. */
  3877. MLXSW_ITEM32(reg, ralta, protocol, 0x00, 24, 4);
  3878. /* reg_ralta_tree_id
  3879. * An identifier (numbered from 1..cap_shspm_max_trees-1) representing
  3880. * the tree identifier (managed by software).
  3881. * Note that tree_id 0 is allocated for a default-route tree.
  3882. * Access: Index
  3883. */
  3884. MLXSW_ITEM32(reg, ralta, tree_id, 0x00, 0, 8);
  3885. static inline void mlxsw_reg_ralta_pack(char *payload, bool alloc,
  3886. enum mlxsw_reg_ralxx_protocol protocol,
  3887. u8 tree_id)
  3888. {
  3889. MLXSW_REG_ZERO(ralta, payload);
  3890. mlxsw_reg_ralta_op_set(payload, !alloc);
  3891. mlxsw_reg_ralta_protocol_set(payload, protocol);
  3892. mlxsw_reg_ralta_tree_id_set(payload, tree_id);
  3893. }
  3894. /* RALST - Router Algorithmic LPM Structure Tree Register
  3895. * ------------------------------------------------------
  3896. * RALST is used to set and query the structure of an LPM tree.
  3897. * The structure of the tree must be sorted as a sorted binary tree, while
  3898. * each node is a bin that is tagged as the length of the prefixes the lookup
  3899. * will refer to. Therefore, bin X refers to a set of entries with prefixes
  3900. * of X bits to match with the destination address. The bin 0 indicates
  3901. * the default action, when there is no match of any prefix.
  3902. */
  3903. #define MLXSW_REG_RALST_ID 0x8011
  3904. #define MLXSW_REG_RALST_LEN 0x104
  3905. MLXSW_REG_DEFINE(ralst, MLXSW_REG_RALST_ID, MLXSW_REG_RALST_LEN);
  3906. /* reg_ralst_root_bin
  3907. * The bin number of the root bin.
  3908. * 0<root_bin=<(length of IP address)
  3909. * For a default-route tree configure 0xff
  3910. * Access: RW
  3911. */
  3912. MLXSW_ITEM32(reg, ralst, root_bin, 0x00, 16, 8);
  3913. /* reg_ralst_tree_id
  3914. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  3915. * Access: Index
  3916. */
  3917. MLXSW_ITEM32(reg, ralst, tree_id, 0x00, 0, 8);
  3918. #define MLXSW_REG_RALST_BIN_NO_CHILD 0xff
  3919. #define MLXSW_REG_RALST_BIN_OFFSET 0x04
  3920. #define MLXSW_REG_RALST_BIN_COUNT 128
  3921. /* reg_ralst_left_child_bin
  3922. * Holding the children of the bin according to the stored tree's structure.
  3923. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  3924. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  3925. * Access: RW
  3926. */
  3927. MLXSW_ITEM16_INDEXED(reg, ralst, left_child_bin, 0x04, 8, 8, 0x02, 0x00, false);
  3928. /* reg_ralst_right_child_bin
  3929. * Holding the children of the bin according to the stored tree's structure.
  3930. * For trees composed of less than 4 blocks, the bins in excess are reserved.
  3931. * Note that tree_id 0 is allocated for a default-route tree, bins are 0xff
  3932. * Access: RW
  3933. */
  3934. MLXSW_ITEM16_INDEXED(reg, ralst, right_child_bin, 0x04, 0, 8, 0x02, 0x00,
  3935. false);
  3936. static inline void mlxsw_reg_ralst_pack(char *payload, u8 root_bin, u8 tree_id)
  3937. {
  3938. MLXSW_REG_ZERO(ralst, payload);
  3939. /* Initialize all bins to have no left or right child */
  3940. memset(payload + MLXSW_REG_RALST_BIN_OFFSET,
  3941. MLXSW_REG_RALST_BIN_NO_CHILD, MLXSW_REG_RALST_BIN_COUNT * 2);
  3942. mlxsw_reg_ralst_root_bin_set(payload, root_bin);
  3943. mlxsw_reg_ralst_tree_id_set(payload, tree_id);
  3944. }
  3945. static inline void mlxsw_reg_ralst_bin_pack(char *payload, u8 bin_number,
  3946. u8 left_child_bin,
  3947. u8 right_child_bin)
  3948. {
  3949. int bin_index = bin_number - 1;
  3950. mlxsw_reg_ralst_left_child_bin_set(payload, bin_index, left_child_bin);
  3951. mlxsw_reg_ralst_right_child_bin_set(payload, bin_index,
  3952. right_child_bin);
  3953. }
  3954. /* RALTB - Router Algorithmic LPM Tree Binding Register
  3955. * ----------------------------------------------------
  3956. * RALTB is used to bind virtual router and protocol to an allocated LPM tree.
  3957. */
  3958. #define MLXSW_REG_RALTB_ID 0x8012
  3959. #define MLXSW_REG_RALTB_LEN 0x04
  3960. MLXSW_REG_DEFINE(raltb, MLXSW_REG_RALTB_ID, MLXSW_REG_RALTB_LEN);
  3961. /* reg_raltb_virtual_router
  3962. * Virtual Router ID
  3963. * Range is 0..cap_max_virtual_routers-1
  3964. * Access: Index
  3965. */
  3966. MLXSW_ITEM32(reg, raltb, virtual_router, 0x00, 16, 16);
  3967. /* reg_raltb_protocol
  3968. * Protocol.
  3969. * Access: Index
  3970. */
  3971. MLXSW_ITEM32(reg, raltb, protocol, 0x00, 12, 4);
  3972. /* reg_raltb_tree_id
  3973. * Tree to be used for the {virtual_router, protocol}
  3974. * Tree identifier numbered from 1..(cap_shspm_max_trees-1).
  3975. * By default, all Unicast IPv4 and IPv6 are bound to tree_id 0.
  3976. * Access: RW
  3977. */
  3978. MLXSW_ITEM32(reg, raltb, tree_id, 0x00, 0, 8);
  3979. static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
  3980. enum mlxsw_reg_ralxx_protocol protocol,
  3981. u8 tree_id)
  3982. {
  3983. MLXSW_REG_ZERO(raltb, payload);
  3984. mlxsw_reg_raltb_virtual_router_set(payload, virtual_router);
  3985. mlxsw_reg_raltb_protocol_set(payload, protocol);
  3986. mlxsw_reg_raltb_tree_id_set(payload, tree_id);
  3987. }
  3988. /* RALUE - Router Algorithmic LPM Unicast Entry Register
  3989. * -----------------------------------------------------
  3990. * RALUE is used to configure and query LPM entries that serve
  3991. * the Unicast protocols.
  3992. */
  3993. #define MLXSW_REG_RALUE_ID 0x8013
  3994. #define MLXSW_REG_RALUE_LEN 0x38
  3995. MLXSW_REG_DEFINE(ralue, MLXSW_REG_RALUE_ID, MLXSW_REG_RALUE_LEN);
  3996. /* reg_ralue_protocol
  3997. * Protocol.
  3998. * Access: Index
  3999. */
  4000. MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
  4001. enum mlxsw_reg_ralue_op {
  4002. /* Read operation. If entry doesn't exist, the operation fails. */
  4003. MLXSW_REG_RALUE_OP_QUERY_READ = 0,
  4004. /* Clear on read operation. Used to read entry and
  4005. * clear Activity bit.
  4006. */
  4007. MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
  4008. /* Write operation. Used to write a new entry to the table. All RW
  4009. * fields are written for new entry. Activity bit is set
  4010. * for new entries.
  4011. */
  4012. MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
  4013. /* Update operation. Used to update an existing route entry and
  4014. * only update the RW fields that are detailed in the field
  4015. * op_u_mask. If entry doesn't exist, the operation fails.
  4016. */
  4017. MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
  4018. /* Clear activity. The Activity bit (the field a) is cleared
  4019. * for the entry.
  4020. */
  4021. MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
  4022. /* Delete operation. Used to delete an existing entry. If entry
  4023. * doesn't exist, the operation fails.
  4024. */
  4025. MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
  4026. };
  4027. /* reg_ralue_op
  4028. * Operation.
  4029. * Access: OP
  4030. */
  4031. MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
  4032. /* reg_ralue_a
  4033. * Activity. Set for new entries. Set if a packet lookup has hit on the
  4034. * specific entry, only if the entry is a route. To clear the a bit, use
  4035. * "clear activity" op.
  4036. * Enabled by activity_dis in RGCR
  4037. * Access: RO
  4038. */
  4039. MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
  4040. /* reg_ralue_virtual_router
  4041. * Virtual Router ID
  4042. * Range is 0..cap_max_virtual_routers-1
  4043. * Access: Index
  4044. */
  4045. MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
  4046. #define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
  4047. #define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
  4048. #define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
  4049. /* reg_ralue_op_u_mask
  4050. * opcode update mask.
  4051. * On read operation, this field is reserved.
  4052. * This field is valid for update opcode, otherwise - reserved.
  4053. * This field is a bitmask of the fields that should be updated.
  4054. * Access: WO
  4055. */
  4056. MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
  4057. /* reg_ralue_prefix_len
  4058. * Number of bits in the prefix of the LPM route.
  4059. * Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
  4060. * two entries in the physical HW table.
  4061. * Access: Index
  4062. */
  4063. MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
  4064. /* reg_ralue_dip*
  4065. * The prefix of the route or of the marker that the object of the LPM
  4066. * is compared with. The most significant bits of the dip are the prefix.
  4067. * The list significant bits must be '0' if the prefix_len is smaller
  4068. * than 128 for IPv6 or smaller than 32 for IPv4.
  4069. * IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
  4070. * Access: Index
  4071. */
  4072. MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
  4073. enum mlxsw_reg_ralue_entry_type {
  4074. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
  4075. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
  4076. MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
  4077. };
  4078. /* reg_ralue_entry_type
  4079. * Entry type.
  4080. * Note - for Marker entries, the action_type and action fields are reserved.
  4081. * Access: RW
  4082. */
  4083. MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
  4084. /* reg_ralue_bmp_len
  4085. * The best match prefix length in the case that there is no match for
  4086. * longer prefixes.
  4087. * If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
  4088. * Note for any update operation with entry_type modification this
  4089. * field must be set.
  4090. * Access: RW
  4091. */
  4092. MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
  4093. enum mlxsw_reg_ralue_action_type {
  4094. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
  4095. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
  4096. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
  4097. };
  4098. /* reg_ralue_action_type
  4099. * Action Type
  4100. * Indicates how the IP address is connected.
  4101. * It can be connected to a local subnet through local_erif or can be
  4102. * on a remote subnet connected through a next-hop router,
  4103. * or transmitted to the CPU.
  4104. * Reserved when entry_type = MARKER_ENTRY
  4105. * Access: RW
  4106. */
  4107. MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
  4108. enum mlxsw_reg_ralue_trap_action {
  4109. MLXSW_REG_RALUE_TRAP_ACTION_NOP,
  4110. MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
  4111. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
  4112. MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
  4113. MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
  4114. };
  4115. /* reg_ralue_trap_action
  4116. * Trap action.
  4117. * For IP2ME action, only NOP and MIRROR are possible.
  4118. * Access: RW
  4119. */
  4120. MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
  4121. /* reg_ralue_trap_id
  4122. * Trap ID to be reported to CPU.
  4123. * Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
  4124. * For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
  4125. * Access: RW
  4126. */
  4127. MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
  4128. /* reg_ralue_adjacency_index
  4129. * Points to the first entry of the group-based ECMP.
  4130. * Only relevant in case of REMOTE action.
  4131. * Access: RW
  4132. */
  4133. MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
  4134. /* reg_ralue_ecmp_size
  4135. * Amount of sequential entries starting
  4136. * from the adjacency_index (the number of ECMPs).
  4137. * The valid range is 1-64, 512, 1024, 2048 and 4096.
  4138. * Reserved when trap_action is TRAP or DISCARD_ERROR.
  4139. * Only relevant in case of REMOTE action.
  4140. * Access: RW
  4141. */
  4142. MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
  4143. /* reg_ralue_local_erif
  4144. * Egress Router Interface.
  4145. * Only relevant in case of LOCAL action.
  4146. * Access: RW
  4147. */
  4148. MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
  4149. /* reg_ralue_v
  4150. * Valid bit for the tunnel_ptr field.
  4151. * If valid = 0 then trap to CPU as IP2ME trap ID.
  4152. * If valid = 1 and the packet format allows NVE or IPinIP tunnel
  4153. * decapsulation then tunnel decapsulation is done.
  4154. * If valid = 1 and packet format does not allow NVE or IPinIP tunnel
  4155. * decapsulation then trap as IP2ME trap ID.
  4156. * Only relevant in case of IP2ME action.
  4157. * Access: RW
  4158. */
  4159. MLXSW_ITEM32(reg, ralue, v, 0x24, 31, 1);
  4160. /* reg_ralue_tunnel_ptr
  4161. * Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
  4162. * For Spectrum, pointer to KVD Linear.
  4163. * Only relevant in case of IP2ME action.
  4164. * Access: RW
  4165. */
  4166. MLXSW_ITEM32(reg, ralue, tunnel_ptr, 0x24, 0, 24);
  4167. static inline void mlxsw_reg_ralue_pack(char *payload,
  4168. enum mlxsw_reg_ralxx_protocol protocol,
  4169. enum mlxsw_reg_ralue_op op,
  4170. u16 virtual_router, u8 prefix_len)
  4171. {
  4172. MLXSW_REG_ZERO(ralue, payload);
  4173. mlxsw_reg_ralue_protocol_set(payload, protocol);
  4174. mlxsw_reg_ralue_op_set(payload, op);
  4175. mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
  4176. mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
  4177. mlxsw_reg_ralue_entry_type_set(payload,
  4178. MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
  4179. mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
  4180. }
  4181. static inline void mlxsw_reg_ralue_pack4(char *payload,
  4182. enum mlxsw_reg_ralxx_protocol protocol,
  4183. enum mlxsw_reg_ralue_op op,
  4184. u16 virtual_router, u8 prefix_len,
  4185. u32 dip)
  4186. {
  4187. mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
  4188. mlxsw_reg_ralue_dip4_set(payload, dip);
  4189. }
  4190. static inline void
  4191. mlxsw_reg_ralue_act_remote_pack(char *payload,
  4192. enum mlxsw_reg_ralue_trap_action trap_action,
  4193. u16 trap_id, u32 adjacency_index, u16 ecmp_size)
  4194. {
  4195. mlxsw_reg_ralue_action_type_set(payload,
  4196. MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
  4197. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  4198. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  4199. mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
  4200. mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
  4201. }
  4202. static inline void
  4203. mlxsw_reg_ralue_act_local_pack(char *payload,
  4204. enum mlxsw_reg_ralue_trap_action trap_action,
  4205. u16 trap_id, u16 local_erif)
  4206. {
  4207. mlxsw_reg_ralue_action_type_set(payload,
  4208. MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
  4209. mlxsw_reg_ralue_trap_action_set(payload, trap_action);
  4210. mlxsw_reg_ralue_trap_id_set(payload, trap_id);
  4211. mlxsw_reg_ralue_local_erif_set(payload, local_erif);
  4212. }
  4213. static inline void
  4214. mlxsw_reg_ralue_act_ip2me_pack(char *payload)
  4215. {
  4216. mlxsw_reg_ralue_action_type_set(payload,
  4217. MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
  4218. }
  4219. /* RAUHT - Router Algorithmic LPM Unicast Host Table Register
  4220. * ----------------------------------------------------------
  4221. * The RAUHT register is used to configure and query the Unicast Host table in
  4222. * devices that implement the Algorithmic LPM.
  4223. */
  4224. #define MLXSW_REG_RAUHT_ID 0x8014
  4225. #define MLXSW_REG_RAUHT_LEN 0x74
  4226. MLXSW_REG_DEFINE(rauht, MLXSW_REG_RAUHT_ID, MLXSW_REG_RAUHT_LEN);
  4227. enum mlxsw_reg_rauht_type {
  4228. MLXSW_REG_RAUHT_TYPE_IPV4,
  4229. MLXSW_REG_RAUHT_TYPE_IPV6,
  4230. };
  4231. /* reg_rauht_type
  4232. * Access: Index
  4233. */
  4234. MLXSW_ITEM32(reg, rauht, type, 0x00, 24, 2);
  4235. enum mlxsw_reg_rauht_op {
  4236. MLXSW_REG_RAUHT_OP_QUERY_READ = 0,
  4237. /* Read operation */
  4238. MLXSW_REG_RAUHT_OP_QUERY_CLEAR_ON_READ = 1,
  4239. /* Clear on read operation. Used to read entry and clear
  4240. * activity bit.
  4241. */
  4242. MLXSW_REG_RAUHT_OP_WRITE_ADD = 0,
  4243. /* Add. Used to write a new entry to the table. All R/W fields are
  4244. * relevant for new entry. Activity bit is set for new entries.
  4245. */
  4246. MLXSW_REG_RAUHT_OP_WRITE_UPDATE = 1,
  4247. /* Update action. Used to update an existing route entry and
  4248. * only update the following fields:
  4249. * trap_action, trap_id, mac, counter_set_type, counter_index
  4250. */
  4251. MLXSW_REG_RAUHT_OP_WRITE_CLEAR_ACTIVITY = 2,
  4252. /* Clear activity. A bit is cleared for the entry. */
  4253. MLXSW_REG_RAUHT_OP_WRITE_DELETE = 3,
  4254. /* Delete entry */
  4255. MLXSW_REG_RAUHT_OP_WRITE_DELETE_ALL = 4,
  4256. /* Delete all host entries on a RIF. In this command, dip
  4257. * field is reserved.
  4258. */
  4259. };
  4260. /* reg_rauht_op
  4261. * Access: OP
  4262. */
  4263. MLXSW_ITEM32(reg, rauht, op, 0x00, 20, 3);
  4264. /* reg_rauht_a
  4265. * Activity. Set for new entries. Set if a packet lookup has hit on
  4266. * the specific entry.
  4267. * To clear the a bit, use "clear activity" op.
  4268. * Enabled by activity_dis in RGCR
  4269. * Access: RO
  4270. */
  4271. MLXSW_ITEM32(reg, rauht, a, 0x00, 16, 1);
  4272. /* reg_rauht_rif
  4273. * Router Interface
  4274. * Access: Index
  4275. */
  4276. MLXSW_ITEM32(reg, rauht, rif, 0x00, 0, 16);
  4277. /* reg_rauht_dip*
  4278. * Destination address.
  4279. * Access: Index
  4280. */
  4281. MLXSW_ITEM32(reg, rauht, dip4, 0x1C, 0x0, 32);
  4282. enum mlxsw_reg_rauht_trap_action {
  4283. MLXSW_REG_RAUHT_TRAP_ACTION_NOP,
  4284. MLXSW_REG_RAUHT_TRAP_ACTION_TRAP,
  4285. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR_TO_CPU,
  4286. MLXSW_REG_RAUHT_TRAP_ACTION_MIRROR,
  4287. MLXSW_REG_RAUHT_TRAP_ACTION_DISCARD_ERRORS,
  4288. };
  4289. /* reg_rauht_trap_action
  4290. * Access: RW
  4291. */
  4292. MLXSW_ITEM32(reg, rauht, trap_action, 0x60, 28, 4);
  4293. enum mlxsw_reg_rauht_trap_id {
  4294. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS0,
  4295. MLXSW_REG_RAUHT_TRAP_ID_RTR_EGRESS1,
  4296. };
  4297. /* reg_rauht_trap_id
  4298. * Trap ID to be reported to CPU.
  4299. * Trap-ID is RTR_EGRESS0 or RTR_EGRESS1.
  4300. * For trap_action of NOP, MIRROR and DISCARD_ERROR,
  4301. * trap_id is reserved.
  4302. * Access: RW
  4303. */
  4304. MLXSW_ITEM32(reg, rauht, trap_id, 0x60, 0, 9);
  4305. /* reg_rauht_counter_set_type
  4306. * Counter set type for flow counters
  4307. * Access: RW
  4308. */
  4309. MLXSW_ITEM32(reg, rauht, counter_set_type, 0x68, 24, 8);
  4310. /* reg_rauht_counter_index
  4311. * Counter index for flow counters
  4312. * Access: RW
  4313. */
  4314. MLXSW_ITEM32(reg, rauht, counter_index, 0x68, 0, 24);
  4315. /* reg_rauht_mac
  4316. * MAC address.
  4317. * Access: RW
  4318. */
  4319. MLXSW_ITEM_BUF(reg, rauht, mac, 0x6E, 6);
  4320. static inline void mlxsw_reg_rauht_pack(char *payload,
  4321. enum mlxsw_reg_rauht_op op, u16 rif,
  4322. const char *mac)
  4323. {
  4324. MLXSW_REG_ZERO(rauht, payload);
  4325. mlxsw_reg_rauht_op_set(payload, op);
  4326. mlxsw_reg_rauht_rif_set(payload, rif);
  4327. mlxsw_reg_rauht_mac_memcpy_to(payload, mac);
  4328. }
  4329. static inline void mlxsw_reg_rauht_pack4(char *payload,
  4330. enum mlxsw_reg_rauht_op op, u16 rif,
  4331. const char *mac, u32 dip)
  4332. {
  4333. mlxsw_reg_rauht_pack(payload, op, rif, mac);
  4334. mlxsw_reg_rauht_dip4_set(payload, dip);
  4335. }
  4336. /* RALEU - Router Algorithmic LPM ECMP Update Register
  4337. * ---------------------------------------------------
  4338. * The register enables updating the ECMP section in the action for multiple
  4339. * LPM Unicast entries in a single operation. The update is executed to
  4340. * all entries of a {virtual router, protocol} tuple using the same ECMP group.
  4341. */
  4342. #define MLXSW_REG_RALEU_ID 0x8015
  4343. #define MLXSW_REG_RALEU_LEN 0x28
  4344. MLXSW_REG_DEFINE(raleu, MLXSW_REG_RALEU_ID, MLXSW_REG_RALEU_LEN);
  4345. /* reg_raleu_protocol
  4346. * Protocol.
  4347. * Access: Index
  4348. */
  4349. MLXSW_ITEM32(reg, raleu, protocol, 0x00, 24, 4);
  4350. /* reg_raleu_virtual_router
  4351. * Virtual Router ID
  4352. * Range is 0..cap_max_virtual_routers-1
  4353. * Access: Index
  4354. */
  4355. MLXSW_ITEM32(reg, raleu, virtual_router, 0x00, 0, 16);
  4356. /* reg_raleu_adjacency_index
  4357. * Adjacency Index used for matching on the existing entries.
  4358. * Access: Index
  4359. */
  4360. MLXSW_ITEM32(reg, raleu, adjacency_index, 0x10, 0, 24);
  4361. /* reg_raleu_ecmp_size
  4362. * ECMP Size used for matching on the existing entries.
  4363. * Access: Index
  4364. */
  4365. MLXSW_ITEM32(reg, raleu, ecmp_size, 0x14, 0, 13);
  4366. /* reg_raleu_new_adjacency_index
  4367. * New Adjacency Index.
  4368. * Access: WO
  4369. */
  4370. MLXSW_ITEM32(reg, raleu, new_adjacency_index, 0x20, 0, 24);
  4371. /* reg_raleu_new_ecmp_size
  4372. * New ECMP Size.
  4373. * Access: WO
  4374. */
  4375. MLXSW_ITEM32(reg, raleu, new_ecmp_size, 0x24, 0, 13);
  4376. static inline void mlxsw_reg_raleu_pack(char *payload,
  4377. enum mlxsw_reg_ralxx_protocol protocol,
  4378. u16 virtual_router,
  4379. u32 adjacency_index, u16 ecmp_size,
  4380. u32 new_adjacency_index,
  4381. u16 new_ecmp_size)
  4382. {
  4383. MLXSW_REG_ZERO(raleu, payload);
  4384. mlxsw_reg_raleu_protocol_set(payload, protocol);
  4385. mlxsw_reg_raleu_virtual_router_set(payload, virtual_router);
  4386. mlxsw_reg_raleu_adjacency_index_set(payload, adjacency_index);
  4387. mlxsw_reg_raleu_ecmp_size_set(payload, ecmp_size);
  4388. mlxsw_reg_raleu_new_adjacency_index_set(payload, new_adjacency_index);
  4389. mlxsw_reg_raleu_new_ecmp_size_set(payload, new_ecmp_size);
  4390. }
  4391. /* RAUHTD - Router Algorithmic LPM Unicast Host Table Dump Register
  4392. * ----------------------------------------------------------------
  4393. * The RAUHTD register allows dumping entries from the Router Unicast Host
  4394. * Table. For a given session an entry is dumped no more than one time. The
  4395. * first RAUHTD access after reset is a new session. A session ends when the
  4396. * num_rec response is smaller than num_rec request or for IPv4 when the
  4397. * num_entries is smaller than 4. The clear activity affect the current session
  4398. * or the last session if a new session has not started.
  4399. */
  4400. #define MLXSW_REG_RAUHTD_ID 0x8018
  4401. #define MLXSW_REG_RAUHTD_BASE_LEN 0x20
  4402. #define MLXSW_REG_RAUHTD_REC_LEN 0x20
  4403. #define MLXSW_REG_RAUHTD_REC_MAX_NUM 32
  4404. #define MLXSW_REG_RAUHTD_LEN (MLXSW_REG_RAUHTD_BASE_LEN + \
  4405. MLXSW_REG_RAUHTD_REC_MAX_NUM * MLXSW_REG_RAUHTD_REC_LEN)
  4406. #define MLXSW_REG_RAUHTD_IPV4_ENT_PER_REC 4
  4407. MLXSW_REG_DEFINE(rauhtd, MLXSW_REG_RAUHTD_ID, MLXSW_REG_RAUHTD_LEN);
  4408. #define MLXSW_REG_RAUHTD_FILTER_A BIT(0)
  4409. #define MLXSW_REG_RAUHTD_FILTER_RIF BIT(3)
  4410. /* reg_rauhtd_filter_fields
  4411. * if a bit is '0' then the relevant field is ignored and dump is done
  4412. * regardless of the field value
  4413. * Bit0 - filter by activity: entry_a
  4414. * Bit3 - filter by entry rip: entry_rif
  4415. * Access: Index
  4416. */
  4417. MLXSW_ITEM32(reg, rauhtd, filter_fields, 0x00, 0, 8);
  4418. enum mlxsw_reg_rauhtd_op {
  4419. MLXSW_REG_RAUHTD_OP_DUMP,
  4420. MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR,
  4421. };
  4422. /* reg_rauhtd_op
  4423. * Access: OP
  4424. */
  4425. MLXSW_ITEM32(reg, rauhtd, op, 0x04, 24, 2);
  4426. /* reg_rauhtd_num_rec
  4427. * At request: number of records requested
  4428. * At response: number of records dumped
  4429. * For IPv4, each record has 4 entries at request and up to 4 entries
  4430. * at response
  4431. * Range is 0..MLXSW_REG_RAUHTD_REC_MAX_NUM
  4432. * Access: Index
  4433. */
  4434. MLXSW_ITEM32(reg, rauhtd, num_rec, 0x04, 0, 8);
  4435. /* reg_rauhtd_entry_a
  4436. * Dump only if activity has value of entry_a
  4437. * Reserved if filter_fields bit0 is '0'
  4438. * Access: Index
  4439. */
  4440. MLXSW_ITEM32(reg, rauhtd, entry_a, 0x08, 16, 1);
  4441. enum mlxsw_reg_rauhtd_type {
  4442. MLXSW_REG_RAUHTD_TYPE_IPV4,
  4443. MLXSW_REG_RAUHTD_TYPE_IPV6,
  4444. };
  4445. /* reg_rauhtd_type
  4446. * Dump only if record type is:
  4447. * 0 - IPv4
  4448. * 1 - IPv6
  4449. * Access: Index
  4450. */
  4451. MLXSW_ITEM32(reg, rauhtd, type, 0x08, 0, 4);
  4452. /* reg_rauhtd_entry_rif
  4453. * Dump only if RIF has value of entry_rif
  4454. * Reserved if filter_fields bit3 is '0'
  4455. * Access: Index
  4456. */
  4457. MLXSW_ITEM32(reg, rauhtd, entry_rif, 0x0C, 0, 16);
  4458. static inline void mlxsw_reg_rauhtd_pack(char *payload,
  4459. enum mlxsw_reg_rauhtd_type type)
  4460. {
  4461. MLXSW_REG_ZERO(rauhtd, payload);
  4462. mlxsw_reg_rauhtd_filter_fields_set(payload, MLXSW_REG_RAUHTD_FILTER_A);
  4463. mlxsw_reg_rauhtd_op_set(payload, MLXSW_REG_RAUHTD_OP_DUMP_AND_CLEAR);
  4464. mlxsw_reg_rauhtd_num_rec_set(payload, MLXSW_REG_RAUHTD_REC_MAX_NUM);
  4465. mlxsw_reg_rauhtd_entry_a_set(payload, 1);
  4466. mlxsw_reg_rauhtd_type_set(payload, type);
  4467. }
  4468. /* reg_rauhtd_ipv4_rec_num_entries
  4469. * Number of valid entries in this record:
  4470. * 0 - 1 valid entry
  4471. * 1 - 2 valid entries
  4472. * 2 - 3 valid entries
  4473. * 3 - 4 valid entries
  4474. * Access: RO
  4475. */
  4476. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_rec_num_entries,
  4477. MLXSW_REG_RAUHTD_BASE_LEN, 28, 2,
  4478. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  4479. /* reg_rauhtd_rec_type
  4480. * Record type.
  4481. * 0 - IPv4
  4482. * 1 - IPv6
  4483. * Access: RO
  4484. */
  4485. MLXSW_ITEM32_INDEXED(reg, rauhtd, rec_type, MLXSW_REG_RAUHTD_BASE_LEN, 24, 2,
  4486. MLXSW_REG_RAUHTD_REC_LEN, 0x00, false);
  4487. #define MLXSW_REG_RAUHTD_IPV4_ENT_LEN 0x8
  4488. /* reg_rauhtd_ipv4_ent_a
  4489. * Activity. Set for new entries. Set if a packet lookup has hit on the
  4490. * specific entry.
  4491. * Access: RO
  4492. */
  4493. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_a, MLXSW_REG_RAUHTD_BASE_LEN, 16, 1,
  4494. MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  4495. /* reg_rauhtd_ipv4_ent_rif
  4496. * Router interface.
  4497. * Access: RO
  4498. */
  4499. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_rif, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  4500. 16, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x00, false);
  4501. /* reg_rauhtd_ipv4_ent_dip
  4502. * Destination IPv4 address.
  4503. * Access: RO
  4504. */
  4505. MLXSW_ITEM32_INDEXED(reg, rauhtd, ipv4_ent_dip, MLXSW_REG_RAUHTD_BASE_LEN, 0,
  4506. 32, MLXSW_REG_RAUHTD_IPV4_ENT_LEN, 0x04, false);
  4507. static inline void mlxsw_reg_rauhtd_ent_ipv4_unpack(char *payload,
  4508. int ent_index, u16 *p_rif,
  4509. u32 *p_dip)
  4510. {
  4511. *p_rif = mlxsw_reg_rauhtd_ipv4_ent_rif_get(payload, ent_index);
  4512. *p_dip = mlxsw_reg_rauhtd_ipv4_ent_dip_get(payload, ent_index);
  4513. }
  4514. /* MFCR - Management Fan Control Register
  4515. * --------------------------------------
  4516. * This register controls the settings of the Fan Speed PWM mechanism.
  4517. */
  4518. #define MLXSW_REG_MFCR_ID 0x9001
  4519. #define MLXSW_REG_MFCR_LEN 0x08
  4520. MLXSW_REG_DEFINE(mfcr, MLXSW_REG_MFCR_ID, MLXSW_REG_MFCR_LEN);
  4521. enum mlxsw_reg_mfcr_pwm_frequency {
  4522. MLXSW_REG_MFCR_PWM_FEQ_11HZ = 0x00,
  4523. MLXSW_REG_MFCR_PWM_FEQ_14_7HZ = 0x01,
  4524. MLXSW_REG_MFCR_PWM_FEQ_22_1HZ = 0x02,
  4525. MLXSW_REG_MFCR_PWM_FEQ_1_4KHZ = 0x40,
  4526. MLXSW_REG_MFCR_PWM_FEQ_5KHZ = 0x41,
  4527. MLXSW_REG_MFCR_PWM_FEQ_20KHZ = 0x42,
  4528. MLXSW_REG_MFCR_PWM_FEQ_22_5KHZ = 0x43,
  4529. MLXSW_REG_MFCR_PWM_FEQ_25KHZ = 0x44,
  4530. };
  4531. /* reg_mfcr_pwm_frequency
  4532. * Controls the frequency of the PWM signal.
  4533. * Access: RW
  4534. */
  4535. MLXSW_ITEM32(reg, mfcr, pwm_frequency, 0x00, 0, 7);
  4536. #define MLXSW_MFCR_TACHOS_MAX 10
  4537. /* reg_mfcr_tacho_active
  4538. * Indicates which of the tachometer is active (bit per tachometer).
  4539. * Access: RO
  4540. */
  4541. MLXSW_ITEM32(reg, mfcr, tacho_active, 0x04, 16, MLXSW_MFCR_TACHOS_MAX);
  4542. #define MLXSW_MFCR_PWMS_MAX 5
  4543. /* reg_mfcr_pwm_active
  4544. * Indicates which of the PWM control is active (bit per PWM).
  4545. * Access: RO
  4546. */
  4547. MLXSW_ITEM32(reg, mfcr, pwm_active, 0x04, 0, MLXSW_MFCR_PWMS_MAX);
  4548. static inline void
  4549. mlxsw_reg_mfcr_pack(char *payload,
  4550. enum mlxsw_reg_mfcr_pwm_frequency pwm_frequency)
  4551. {
  4552. MLXSW_REG_ZERO(mfcr, payload);
  4553. mlxsw_reg_mfcr_pwm_frequency_set(payload, pwm_frequency);
  4554. }
  4555. static inline void
  4556. mlxsw_reg_mfcr_unpack(char *payload,
  4557. enum mlxsw_reg_mfcr_pwm_frequency *p_pwm_frequency,
  4558. u16 *p_tacho_active, u8 *p_pwm_active)
  4559. {
  4560. *p_pwm_frequency = mlxsw_reg_mfcr_pwm_frequency_get(payload);
  4561. *p_tacho_active = mlxsw_reg_mfcr_tacho_active_get(payload);
  4562. *p_pwm_active = mlxsw_reg_mfcr_pwm_active_get(payload);
  4563. }
  4564. /* MFSC - Management Fan Speed Control Register
  4565. * --------------------------------------------
  4566. * This register controls the settings of the Fan Speed PWM mechanism.
  4567. */
  4568. #define MLXSW_REG_MFSC_ID 0x9002
  4569. #define MLXSW_REG_MFSC_LEN 0x08
  4570. MLXSW_REG_DEFINE(mfsc, MLXSW_REG_MFSC_ID, MLXSW_REG_MFSC_LEN);
  4571. /* reg_mfsc_pwm
  4572. * Fan pwm to control / monitor.
  4573. * Access: Index
  4574. */
  4575. MLXSW_ITEM32(reg, mfsc, pwm, 0x00, 24, 3);
  4576. /* reg_mfsc_pwm_duty_cycle
  4577. * Controls the duty cycle of the PWM. Value range from 0..255 to
  4578. * represent duty cycle of 0%...100%.
  4579. * Access: RW
  4580. */
  4581. MLXSW_ITEM32(reg, mfsc, pwm_duty_cycle, 0x04, 0, 8);
  4582. static inline void mlxsw_reg_mfsc_pack(char *payload, u8 pwm,
  4583. u8 pwm_duty_cycle)
  4584. {
  4585. MLXSW_REG_ZERO(mfsc, payload);
  4586. mlxsw_reg_mfsc_pwm_set(payload, pwm);
  4587. mlxsw_reg_mfsc_pwm_duty_cycle_set(payload, pwm_duty_cycle);
  4588. }
  4589. /* MFSM - Management Fan Speed Measurement
  4590. * ---------------------------------------
  4591. * This register controls the settings of the Tacho measurements and
  4592. * enables reading the Tachometer measurements.
  4593. */
  4594. #define MLXSW_REG_MFSM_ID 0x9003
  4595. #define MLXSW_REG_MFSM_LEN 0x08
  4596. MLXSW_REG_DEFINE(mfsm, MLXSW_REG_MFSM_ID, MLXSW_REG_MFSM_LEN);
  4597. /* reg_mfsm_tacho
  4598. * Fan tachometer index.
  4599. * Access: Index
  4600. */
  4601. MLXSW_ITEM32(reg, mfsm, tacho, 0x00, 24, 4);
  4602. /* reg_mfsm_rpm
  4603. * Fan speed (round per minute).
  4604. * Access: RO
  4605. */
  4606. MLXSW_ITEM32(reg, mfsm, rpm, 0x04, 0, 16);
  4607. static inline void mlxsw_reg_mfsm_pack(char *payload, u8 tacho)
  4608. {
  4609. MLXSW_REG_ZERO(mfsm, payload);
  4610. mlxsw_reg_mfsm_tacho_set(payload, tacho);
  4611. }
  4612. /* MFSL - Management Fan Speed Limit Register
  4613. * ------------------------------------------
  4614. * The Fan Speed Limit register is used to configure the fan speed
  4615. * event / interrupt notification mechanism. Fan speed threshold are
  4616. * defined for both under-speed and over-speed.
  4617. */
  4618. #define MLXSW_REG_MFSL_ID 0x9004
  4619. #define MLXSW_REG_MFSL_LEN 0x0C
  4620. MLXSW_REG_DEFINE(mfsl, MLXSW_REG_MFSL_ID, MLXSW_REG_MFSL_LEN);
  4621. /* reg_mfsl_tacho
  4622. * Fan tachometer index.
  4623. * Access: Index
  4624. */
  4625. MLXSW_ITEM32(reg, mfsl, tacho, 0x00, 24, 4);
  4626. /* reg_mfsl_tach_min
  4627. * Tachometer minimum value (minimum RPM).
  4628. * Access: RW
  4629. */
  4630. MLXSW_ITEM32(reg, mfsl, tach_min, 0x04, 0, 16);
  4631. /* reg_mfsl_tach_max
  4632. * Tachometer maximum value (maximum RPM).
  4633. * Access: RW
  4634. */
  4635. MLXSW_ITEM32(reg, mfsl, tach_max, 0x08, 0, 16);
  4636. static inline void mlxsw_reg_mfsl_pack(char *payload, u8 tacho,
  4637. u16 tach_min, u16 tach_max)
  4638. {
  4639. MLXSW_REG_ZERO(mfsl, payload);
  4640. mlxsw_reg_mfsl_tacho_set(payload, tacho);
  4641. mlxsw_reg_mfsl_tach_min_set(payload, tach_min);
  4642. mlxsw_reg_mfsl_tach_max_set(payload, tach_max);
  4643. }
  4644. static inline void mlxsw_reg_mfsl_unpack(char *payload, u8 tacho,
  4645. u16 *p_tach_min, u16 *p_tach_max)
  4646. {
  4647. if (p_tach_min)
  4648. *p_tach_min = mlxsw_reg_mfsl_tach_min_get(payload);
  4649. if (p_tach_max)
  4650. *p_tach_max = mlxsw_reg_mfsl_tach_max_get(payload);
  4651. }
  4652. /* MTCAP - Management Temperature Capabilities
  4653. * -------------------------------------------
  4654. * This register exposes the capabilities of the device and
  4655. * system temperature sensing.
  4656. */
  4657. #define MLXSW_REG_MTCAP_ID 0x9009
  4658. #define MLXSW_REG_MTCAP_LEN 0x08
  4659. MLXSW_REG_DEFINE(mtcap, MLXSW_REG_MTCAP_ID, MLXSW_REG_MTCAP_LEN);
  4660. /* reg_mtcap_sensor_count
  4661. * Number of sensors supported by the device.
  4662. * This includes the QSFP module sensors (if exists in the QSFP module).
  4663. * Access: RO
  4664. */
  4665. MLXSW_ITEM32(reg, mtcap, sensor_count, 0x00, 0, 7);
  4666. /* MTMP - Management Temperature
  4667. * -----------------------------
  4668. * This register controls the settings of the temperature measurements
  4669. * and enables reading the temperature measurements. Note that temperature
  4670. * is in 0.125 degrees Celsius.
  4671. */
  4672. #define MLXSW_REG_MTMP_ID 0x900A
  4673. #define MLXSW_REG_MTMP_LEN 0x20
  4674. MLXSW_REG_DEFINE(mtmp, MLXSW_REG_MTMP_ID, MLXSW_REG_MTMP_LEN);
  4675. /* reg_mtmp_sensor_index
  4676. * Sensors index to access.
  4677. * 64-127 of sensor_index are mapped to the SFP+/QSFP modules sequentially
  4678. * (module 0 is mapped to sensor_index 64).
  4679. * Access: Index
  4680. */
  4681. MLXSW_ITEM32(reg, mtmp, sensor_index, 0x00, 0, 7);
  4682. /* Convert to milli degrees Celsius */
  4683. #define MLXSW_REG_MTMP_TEMP_TO_MC(val) (val * 125)
  4684. /* reg_mtmp_temperature
  4685. * Temperature reading from the sensor. Reading is in 0.125 Celsius
  4686. * degrees units.
  4687. * Access: RO
  4688. */
  4689. MLXSW_ITEM32(reg, mtmp, temperature, 0x04, 0, 16);
  4690. /* reg_mtmp_mte
  4691. * Max Temperature Enable - enables measuring the max temperature on a sensor.
  4692. * Access: RW
  4693. */
  4694. MLXSW_ITEM32(reg, mtmp, mte, 0x08, 31, 1);
  4695. /* reg_mtmp_mtr
  4696. * Max Temperature Reset - clears the value of the max temperature register.
  4697. * Access: WO
  4698. */
  4699. MLXSW_ITEM32(reg, mtmp, mtr, 0x08, 30, 1);
  4700. /* reg_mtmp_max_temperature
  4701. * The highest measured temperature from the sensor.
  4702. * When the bit mte is cleared, the field max_temperature is reserved.
  4703. * Access: RO
  4704. */
  4705. MLXSW_ITEM32(reg, mtmp, max_temperature, 0x08, 0, 16);
  4706. #define MLXSW_REG_MTMP_SENSOR_NAME_SIZE 8
  4707. /* reg_mtmp_sensor_name
  4708. * Sensor Name
  4709. * Access: RO
  4710. */
  4711. MLXSW_ITEM_BUF(reg, mtmp, sensor_name, 0x18, MLXSW_REG_MTMP_SENSOR_NAME_SIZE);
  4712. static inline void mlxsw_reg_mtmp_pack(char *payload, u8 sensor_index,
  4713. bool max_temp_enable,
  4714. bool max_temp_reset)
  4715. {
  4716. MLXSW_REG_ZERO(mtmp, payload);
  4717. mlxsw_reg_mtmp_sensor_index_set(payload, sensor_index);
  4718. mlxsw_reg_mtmp_mte_set(payload, max_temp_enable);
  4719. mlxsw_reg_mtmp_mtr_set(payload, max_temp_reset);
  4720. }
  4721. static inline void mlxsw_reg_mtmp_unpack(char *payload, unsigned int *p_temp,
  4722. unsigned int *p_max_temp,
  4723. char *sensor_name)
  4724. {
  4725. u16 temp;
  4726. if (p_temp) {
  4727. temp = mlxsw_reg_mtmp_temperature_get(payload);
  4728. *p_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  4729. }
  4730. if (p_max_temp) {
  4731. temp = mlxsw_reg_mtmp_max_temperature_get(payload);
  4732. *p_max_temp = MLXSW_REG_MTMP_TEMP_TO_MC(temp);
  4733. }
  4734. if (sensor_name)
  4735. mlxsw_reg_mtmp_sensor_name_memcpy_from(payload, sensor_name);
  4736. }
  4737. /* MPAT - Monitoring Port Analyzer Table
  4738. * -------------------------------------
  4739. * MPAT Register is used to query and configure the Switch PortAnalyzer Table.
  4740. * For an enabled analyzer, all fields except e (enable) cannot be modified.
  4741. */
  4742. #define MLXSW_REG_MPAT_ID 0x901A
  4743. #define MLXSW_REG_MPAT_LEN 0x78
  4744. MLXSW_REG_DEFINE(mpat, MLXSW_REG_MPAT_ID, MLXSW_REG_MPAT_LEN);
  4745. /* reg_mpat_pa_id
  4746. * Port Analyzer ID.
  4747. * Access: Index
  4748. */
  4749. MLXSW_ITEM32(reg, mpat, pa_id, 0x00, 28, 4);
  4750. /* reg_mpat_system_port
  4751. * A unique port identifier for the final destination of the packet.
  4752. * Access: RW
  4753. */
  4754. MLXSW_ITEM32(reg, mpat, system_port, 0x00, 0, 16);
  4755. /* reg_mpat_e
  4756. * Enable. Indicating the Port Analyzer is enabled.
  4757. * Access: RW
  4758. */
  4759. MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
  4760. /* reg_mpat_qos
  4761. * Quality Of Service Mode.
  4762. * 0: CONFIGURED - QoS parameters (Switch Priority, and encapsulation
  4763. * PCP, DEI, DSCP or VL) are configured.
  4764. * 1: MAINTAIN - QoS parameters (Switch Priority, Color) are the
  4765. * same as in the original packet that has triggered the mirroring. For
  4766. * SPAN also the pcp,dei are maintained.
  4767. * Access: RW
  4768. */
  4769. MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
  4770. /* reg_mpat_be
  4771. * Best effort mode. Indicates mirroring traffic should not cause packet
  4772. * drop or back pressure, but will discard the mirrored packets. Mirrored
  4773. * packets will be forwarded on a best effort manner.
  4774. * 0: Do not discard mirrored packets
  4775. * 1: Discard mirrored packets if causing congestion
  4776. * Access: RW
  4777. */
  4778. MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
  4779. static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
  4780. u16 system_port, bool e)
  4781. {
  4782. MLXSW_REG_ZERO(mpat, payload);
  4783. mlxsw_reg_mpat_pa_id_set(payload, pa_id);
  4784. mlxsw_reg_mpat_system_port_set(payload, system_port);
  4785. mlxsw_reg_mpat_e_set(payload, e);
  4786. mlxsw_reg_mpat_qos_set(payload, 1);
  4787. mlxsw_reg_mpat_be_set(payload, 1);
  4788. }
  4789. /* MPAR - Monitoring Port Analyzer Register
  4790. * ----------------------------------------
  4791. * MPAR register is used to query and configure the port analyzer port mirroring
  4792. * properties.
  4793. */
  4794. #define MLXSW_REG_MPAR_ID 0x901B
  4795. #define MLXSW_REG_MPAR_LEN 0x08
  4796. MLXSW_REG_DEFINE(mpar, MLXSW_REG_MPAR_ID, MLXSW_REG_MPAR_LEN);
  4797. /* reg_mpar_local_port
  4798. * The local port to mirror the packets from.
  4799. * Access: Index
  4800. */
  4801. MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
  4802. enum mlxsw_reg_mpar_i_e {
  4803. MLXSW_REG_MPAR_TYPE_EGRESS,
  4804. MLXSW_REG_MPAR_TYPE_INGRESS,
  4805. };
  4806. /* reg_mpar_i_e
  4807. * Ingress/Egress
  4808. * Access: Index
  4809. */
  4810. MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
  4811. /* reg_mpar_enable
  4812. * Enable mirroring
  4813. * By default, port mirroring is disabled for all ports.
  4814. * Access: RW
  4815. */
  4816. MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
  4817. /* reg_mpar_pa_id
  4818. * Port Analyzer ID.
  4819. * Access: RW
  4820. */
  4821. MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
  4822. static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
  4823. enum mlxsw_reg_mpar_i_e i_e,
  4824. bool enable, u8 pa_id)
  4825. {
  4826. MLXSW_REG_ZERO(mpar, payload);
  4827. mlxsw_reg_mpar_local_port_set(payload, local_port);
  4828. mlxsw_reg_mpar_enable_set(payload, enable);
  4829. mlxsw_reg_mpar_i_e_set(payload, i_e);
  4830. mlxsw_reg_mpar_pa_id_set(payload, pa_id);
  4831. }
  4832. /* MLCR - Management LED Control Register
  4833. * --------------------------------------
  4834. * Controls the system LEDs.
  4835. */
  4836. #define MLXSW_REG_MLCR_ID 0x902B
  4837. #define MLXSW_REG_MLCR_LEN 0x0C
  4838. MLXSW_REG_DEFINE(mlcr, MLXSW_REG_MLCR_ID, MLXSW_REG_MLCR_LEN);
  4839. /* reg_mlcr_local_port
  4840. * Local port number.
  4841. * Access: RW
  4842. */
  4843. MLXSW_ITEM32(reg, mlcr, local_port, 0x00, 16, 8);
  4844. #define MLXSW_REG_MLCR_DURATION_MAX 0xFFFF
  4845. /* reg_mlcr_beacon_duration
  4846. * Duration of the beacon to be active, in seconds.
  4847. * 0x0 - Will turn off the beacon.
  4848. * 0xFFFF - Will turn on the beacon until explicitly turned off.
  4849. * Access: RW
  4850. */
  4851. MLXSW_ITEM32(reg, mlcr, beacon_duration, 0x04, 0, 16);
  4852. /* reg_mlcr_beacon_remain
  4853. * Remaining duration of the beacon, in seconds.
  4854. * 0xFFFF indicates an infinite amount of time.
  4855. * Access: RO
  4856. */
  4857. MLXSW_ITEM32(reg, mlcr, beacon_remain, 0x08, 0, 16);
  4858. static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
  4859. bool active)
  4860. {
  4861. MLXSW_REG_ZERO(mlcr, payload);
  4862. mlxsw_reg_mlcr_local_port_set(payload, local_port);
  4863. mlxsw_reg_mlcr_beacon_duration_set(payload, active ?
  4864. MLXSW_REG_MLCR_DURATION_MAX : 0);
  4865. }
  4866. /* MPSC - Monitoring Packet Sampling Configuration Register
  4867. * --------------------------------------------------------
  4868. * MPSC Register is used to configure the Packet Sampling mechanism.
  4869. */
  4870. #define MLXSW_REG_MPSC_ID 0x9080
  4871. #define MLXSW_REG_MPSC_LEN 0x1C
  4872. MLXSW_REG_DEFINE(mpsc, MLXSW_REG_MPSC_ID, MLXSW_REG_MPSC_LEN);
  4873. /* reg_mpsc_local_port
  4874. * Local port number
  4875. * Not supported for CPU port
  4876. * Access: Index
  4877. */
  4878. MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
  4879. /* reg_mpsc_e
  4880. * Enable sampling on port local_port
  4881. * Access: RW
  4882. */
  4883. MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
  4884. #define MLXSW_REG_MPSC_RATE_MAX 3500000000UL
  4885. /* reg_mpsc_rate
  4886. * Sampling rate = 1 out of rate packets (with randomization around
  4887. * the point). Valid values are: 1 to MLXSW_REG_MPSC_RATE_MAX
  4888. * Access: RW
  4889. */
  4890. MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
  4891. static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
  4892. u32 rate)
  4893. {
  4894. MLXSW_REG_ZERO(mpsc, payload);
  4895. mlxsw_reg_mpsc_local_port_set(payload, local_port);
  4896. mlxsw_reg_mpsc_e_set(payload, e);
  4897. mlxsw_reg_mpsc_rate_set(payload, rate);
  4898. }
  4899. /* MGPC - Monitoring General Purpose Counter Set Register
  4900. * The MGPC register retrieves and sets the General Purpose Counter Set.
  4901. */
  4902. #define MLXSW_REG_MGPC_ID 0x9081
  4903. #define MLXSW_REG_MGPC_LEN 0x18
  4904. MLXSW_REG_DEFINE(mgpc, MLXSW_REG_MGPC_ID, MLXSW_REG_MGPC_LEN);
  4905. enum mlxsw_reg_mgpc_counter_set_type {
  4906. /* No count */
  4907. MLXSW_REG_MGPC_COUNTER_SET_TYPE_NO_COUT = 0x00,
  4908. /* Count packets and bytes */
  4909. MLXSW_REG_MGPC_COUNTER_SET_TYPE_PACKETS_BYTES = 0x03,
  4910. /* Count only packets */
  4911. MLXSW_REG_MGPC_COUNTER_SET_TYPE_PACKETS = 0x05,
  4912. };
  4913. /* reg_mgpc_counter_set_type
  4914. * Counter set type.
  4915. * Access: OP
  4916. */
  4917. MLXSW_ITEM32(reg, mgpc, counter_set_type, 0x00, 24, 8);
  4918. /* reg_mgpc_counter_index
  4919. * Counter index.
  4920. * Access: Index
  4921. */
  4922. MLXSW_ITEM32(reg, mgpc, counter_index, 0x00, 0, 24);
  4923. enum mlxsw_reg_mgpc_opcode {
  4924. /* Nop */
  4925. MLXSW_REG_MGPC_OPCODE_NOP = 0x00,
  4926. /* Clear counters */
  4927. MLXSW_REG_MGPC_OPCODE_CLEAR = 0x08,
  4928. };
  4929. /* reg_mgpc_opcode
  4930. * Opcode.
  4931. * Access: OP
  4932. */
  4933. MLXSW_ITEM32(reg, mgpc, opcode, 0x04, 28, 4);
  4934. /* reg_mgpc_byte_counter
  4935. * Byte counter value.
  4936. * Access: RW
  4937. */
  4938. MLXSW_ITEM64(reg, mgpc, byte_counter, 0x08, 0, 64);
  4939. /* reg_mgpc_packet_counter
  4940. * Packet counter value.
  4941. * Access: RW
  4942. */
  4943. MLXSW_ITEM64(reg, mgpc, packet_counter, 0x10, 0, 64);
  4944. static inline void mlxsw_reg_mgpc_pack(char *payload, u32 counter_index,
  4945. enum mlxsw_reg_mgpc_opcode opcode,
  4946. enum mlxsw_reg_mgpc_counter_set_type set_type)
  4947. {
  4948. MLXSW_REG_ZERO(mgpc, payload);
  4949. mlxsw_reg_mgpc_counter_index_set(payload, counter_index);
  4950. mlxsw_reg_mgpc_counter_set_type_set(payload, set_type);
  4951. mlxsw_reg_mgpc_opcode_set(payload, opcode);
  4952. }
  4953. /* SBPR - Shared Buffer Pools Register
  4954. * -----------------------------------
  4955. * The SBPR configures and retrieves the shared buffer pools and configuration.
  4956. */
  4957. #define MLXSW_REG_SBPR_ID 0xB001
  4958. #define MLXSW_REG_SBPR_LEN 0x14
  4959. MLXSW_REG_DEFINE(sbpr, MLXSW_REG_SBPR_ID, MLXSW_REG_SBPR_LEN);
  4960. /* shared direstion enum for SBPR, SBCM, SBPM */
  4961. enum mlxsw_reg_sbxx_dir {
  4962. MLXSW_REG_SBXX_DIR_INGRESS,
  4963. MLXSW_REG_SBXX_DIR_EGRESS,
  4964. };
  4965. /* reg_sbpr_dir
  4966. * Direction.
  4967. * Access: Index
  4968. */
  4969. MLXSW_ITEM32(reg, sbpr, dir, 0x00, 24, 2);
  4970. /* reg_sbpr_pool
  4971. * Pool index.
  4972. * Access: Index
  4973. */
  4974. MLXSW_ITEM32(reg, sbpr, pool, 0x00, 0, 4);
  4975. /* reg_sbpr_size
  4976. * Pool size in buffer cells.
  4977. * Access: RW
  4978. */
  4979. MLXSW_ITEM32(reg, sbpr, size, 0x04, 0, 24);
  4980. enum mlxsw_reg_sbpr_mode {
  4981. MLXSW_REG_SBPR_MODE_STATIC,
  4982. MLXSW_REG_SBPR_MODE_DYNAMIC,
  4983. };
  4984. /* reg_sbpr_mode
  4985. * Pool quota calculation mode.
  4986. * Access: RW
  4987. */
  4988. MLXSW_ITEM32(reg, sbpr, mode, 0x08, 0, 4);
  4989. static inline void mlxsw_reg_sbpr_pack(char *payload, u8 pool,
  4990. enum mlxsw_reg_sbxx_dir dir,
  4991. enum mlxsw_reg_sbpr_mode mode, u32 size)
  4992. {
  4993. MLXSW_REG_ZERO(sbpr, payload);
  4994. mlxsw_reg_sbpr_pool_set(payload, pool);
  4995. mlxsw_reg_sbpr_dir_set(payload, dir);
  4996. mlxsw_reg_sbpr_mode_set(payload, mode);
  4997. mlxsw_reg_sbpr_size_set(payload, size);
  4998. }
  4999. /* SBCM - Shared Buffer Class Management Register
  5000. * ----------------------------------------------
  5001. * The SBCM register configures and retrieves the shared buffer allocation
  5002. * and configuration according to Port-PG, including the binding to pool
  5003. * and definition of the associated quota.
  5004. */
  5005. #define MLXSW_REG_SBCM_ID 0xB002
  5006. #define MLXSW_REG_SBCM_LEN 0x28
  5007. MLXSW_REG_DEFINE(sbcm, MLXSW_REG_SBCM_ID, MLXSW_REG_SBCM_LEN);
  5008. /* reg_sbcm_local_port
  5009. * Local port number.
  5010. * For Ingress: excludes CPU port and Router port
  5011. * For Egress: excludes IP Router
  5012. * Access: Index
  5013. */
  5014. MLXSW_ITEM32(reg, sbcm, local_port, 0x00, 16, 8);
  5015. /* reg_sbcm_pg_buff
  5016. * PG buffer - Port PG (dir=ingress) / traffic class (dir=egress)
  5017. * For PG buffer: range is 0..cap_max_pg_buffers - 1
  5018. * For traffic class: range is 0..cap_max_tclass - 1
  5019. * Note that when traffic class is in MC aware mode then the traffic
  5020. * classes which are MC aware cannot be configured.
  5021. * Access: Index
  5022. */
  5023. MLXSW_ITEM32(reg, sbcm, pg_buff, 0x00, 8, 6);
  5024. /* reg_sbcm_dir
  5025. * Direction.
  5026. * Access: Index
  5027. */
  5028. MLXSW_ITEM32(reg, sbcm, dir, 0x00, 0, 2);
  5029. /* reg_sbcm_min_buff
  5030. * Minimum buffer size for the limiter, in cells.
  5031. * Access: RW
  5032. */
  5033. MLXSW_ITEM32(reg, sbcm, min_buff, 0x18, 0, 24);
  5034. /* shared max_buff limits for dynamic threshold for SBCM, SBPM */
  5035. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MIN 1
  5036. #define MLXSW_REG_SBXX_DYN_MAX_BUFF_MAX 14
  5037. /* reg_sbcm_max_buff
  5038. * When the pool associated to the port-pg/tclass is configured to
  5039. * static, Maximum buffer size for the limiter configured in cells.
  5040. * When the pool associated to the port-pg/tclass is configured to
  5041. * dynamic, the max_buff holds the "alpha" parameter, supporting
  5042. * the following values:
  5043. * 0: 0
  5044. * i: (1/128)*2^(i-1), for i=1..14
  5045. * 0xFF: Infinity
  5046. * Access: RW
  5047. */
  5048. MLXSW_ITEM32(reg, sbcm, max_buff, 0x1C, 0, 24);
  5049. /* reg_sbcm_pool
  5050. * Association of the port-priority to a pool.
  5051. * Access: RW
  5052. */
  5053. MLXSW_ITEM32(reg, sbcm, pool, 0x24, 0, 4);
  5054. static inline void mlxsw_reg_sbcm_pack(char *payload, u8 local_port, u8 pg_buff,
  5055. enum mlxsw_reg_sbxx_dir dir,
  5056. u32 min_buff, u32 max_buff, u8 pool)
  5057. {
  5058. MLXSW_REG_ZERO(sbcm, payload);
  5059. mlxsw_reg_sbcm_local_port_set(payload, local_port);
  5060. mlxsw_reg_sbcm_pg_buff_set(payload, pg_buff);
  5061. mlxsw_reg_sbcm_dir_set(payload, dir);
  5062. mlxsw_reg_sbcm_min_buff_set(payload, min_buff);
  5063. mlxsw_reg_sbcm_max_buff_set(payload, max_buff);
  5064. mlxsw_reg_sbcm_pool_set(payload, pool);
  5065. }
  5066. /* SBPM - Shared Buffer Port Management Register
  5067. * ---------------------------------------------
  5068. * The SBPM register configures and retrieves the shared buffer allocation
  5069. * and configuration according to Port-Pool, including the definition
  5070. * of the associated quota.
  5071. */
  5072. #define MLXSW_REG_SBPM_ID 0xB003
  5073. #define MLXSW_REG_SBPM_LEN 0x28
  5074. MLXSW_REG_DEFINE(sbpm, MLXSW_REG_SBPM_ID, MLXSW_REG_SBPM_LEN);
  5075. /* reg_sbpm_local_port
  5076. * Local port number.
  5077. * For Ingress: excludes CPU port and Router port
  5078. * For Egress: excludes IP Router
  5079. * Access: Index
  5080. */
  5081. MLXSW_ITEM32(reg, sbpm, local_port, 0x00, 16, 8);
  5082. /* reg_sbpm_pool
  5083. * The pool associated to quota counting on the local_port.
  5084. * Access: Index
  5085. */
  5086. MLXSW_ITEM32(reg, sbpm, pool, 0x00, 8, 4);
  5087. /* reg_sbpm_dir
  5088. * Direction.
  5089. * Access: Index
  5090. */
  5091. MLXSW_ITEM32(reg, sbpm, dir, 0x00, 0, 2);
  5092. /* reg_sbpm_buff_occupancy
  5093. * Current buffer occupancy in cells.
  5094. * Access: RO
  5095. */
  5096. MLXSW_ITEM32(reg, sbpm, buff_occupancy, 0x10, 0, 24);
  5097. /* reg_sbpm_clr
  5098. * Clear Max Buffer Occupancy
  5099. * When this bit is set, max_buff_occupancy field is cleared (and a
  5100. * new max value is tracked from the time the clear was performed).
  5101. * Access: OP
  5102. */
  5103. MLXSW_ITEM32(reg, sbpm, clr, 0x14, 31, 1);
  5104. /* reg_sbpm_max_buff_occupancy
  5105. * Maximum value of buffer occupancy in cells monitored. Cleared by
  5106. * writing to the clr field.
  5107. * Access: RO
  5108. */
  5109. MLXSW_ITEM32(reg, sbpm, max_buff_occupancy, 0x14, 0, 24);
  5110. /* reg_sbpm_min_buff
  5111. * Minimum buffer size for the limiter, in cells.
  5112. * Access: RW
  5113. */
  5114. MLXSW_ITEM32(reg, sbpm, min_buff, 0x18, 0, 24);
  5115. /* reg_sbpm_max_buff
  5116. * When the pool associated to the port-pg/tclass is configured to
  5117. * static, Maximum buffer size for the limiter configured in cells.
  5118. * When the pool associated to the port-pg/tclass is configured to
  5119. * dynamic, the max_buff holds the "alpha" parameter, supporting
  5120. * the following values:
  5121. * 0: 0
  5122. * i: (1/128)*2^(i-1), for i=1..14
  5123. * 0xFF: Infinity
  5124. * Access: RW
  5125. */
  5126. MLXSW_ITEM32(reg, sbpm, max_buff, 0x1C, 0, 24);
  5127. static inline void mlxsw_reg_sbpm_pack(char *payload, u8 local_port, u8 pool,
  5128. enum mlxsw_reg_sbxx_dir dir, bool clr,
  5129. u32 min_buff, u32 max_buff)
  5130. {
  5131. MLXSW_REG_ZERO(sbpm, payload);
  5132. mlxsw_reg_sbpm_local_port_set(payload, local_port);
  5133. mlxsw_reg_sbpm_pool_set(payload, pool);
  5134. mlxsw_reg_sbpm_dir_set(payload, dir);
  5135. mlxsw_reg_sbpm_clr_set(payload, clr);
  5136. mlxsw_reg_sbpm_min_buff_set(payload, min_buff);
  5137. mlxsw_reg_sbpm_max_buff_set(payload, max_buff);
  5138. }
  5139. static inline void mlxsw_reg_sbpm_unpack(char *payload, u32 *p_buff_occupancy,
  5140. u32 *p_max_buff_occupancy)
  5141. {
  5142. *p_buff_occupancy = mlxsw_reg_sbpm_buff_occupancy_get(payload);
  5143. *p_max_buff_occupancy = mlxsw_reg_sbpm_max_buff_occupancy_get(payload);
  5144. }
  5145. /* SBMM - Shared Buffer Multicast Management Register
  5146. * --------------------------------------------------
  5147. * The SBMM register configures and retrieves the shared buffer allocation
  5148. * and configuration for MC packets according to Switch-Priority, including
  5149. * the binding to pool and definition of the associated quota.
  5150. */
  5151. #define MLXSW_REG_SBMM_ID 0xB004
  5152. #define MLXSW_REG_SBMM_LEN 0x28
  5153. MLXSW_REG_DEFINE(sbmm, MLXSW_REG_SBMM_ID, MLXSW_REG_SBMM_LEN);
  5154. /* reg_sbmm_prio
  5155. * Switch Priority.
  5156. * Access: Index
  5157. */
  5158. MLXSW_ITEM32(reg, sbmm, prio, 0x00, 8, 4);
  5159. /* reg_sbmm_min_buff
  5160. * Minimum buffer size for the limiter, in cells.
  5161. * Access: RW
  5162. */
  5163. MLXSW_ITEM32(reg, sbmm, min_buff, 0x18, 0, 24);
  5164. /* reg_sbmm_max_buff
  5165. * When the pool associated to the port-pg/tclass is configured to
  5166. * static, Maximum buffer size for the limiter configured in cells.
  5167. * When the pool associated to the port-pg/tclass is configured to
  5168. * dynamic, the max_buff holds the "alpha" parameter, supporting
  5169. * the following values:
  5170. * 0: 0
  5171. * i: (1/128)*2^(i-1), for i=1..14
  5172. * 0xFF: Infinity
  5173. * Access: RW
  5174. */
  5175. MLXSW_ITEM32(reg, sbmm, max_buff, 0x1C, 0, 24);
  5176. /* reg_sbmm_pool
  5177. * Association of the port-priority to a pool.
  5178. * Access: RW
  5179. */
  5180. MLXSW_ITEM32(reg, sbmm, pool, 0x24, 0, 4);
  5181. static inline void mlxsw_reg_sbmm_pack(char *payload, u8 prio, u32 min_buff,
  5182. u32 max_buff, u8 pool)
  5183. {
  5184. MLXSW_REG_ZERO(sbmm, payload);
  5185. mlxsw_reg_sbmm_prio_set(payload, prio);
  5186. mlxsw_reg_sbmm_min_buff_set(payload, min_buff);
  5187. mlxsw_reg_sbmm_max_buff_set(payload, max_buff);
  5188. mlxsw_reg_sbmm_pool_set(payload, pool);
  5189. }
  5190. /* SBSR - Shared Buffer Status Register
  5191. * ------------------------------------
  5192. * The SBSR register retrieves the shared buffer occupancy according to
  5193. * Port-Pool. Note that this register enables reading a large amount of data.
  5194. * It is the user's responsibility to limit the amount of data to ensure the
  5195. * response can match the maximum transfer unit. In case the response exceeds
  5196. * the maximum transport unit, it will be truncated with no special notice.
  5197. */
  5198. #define MLXSW_REG_SBSR_ID 0xB005
  5199. #define MLXSW_REG_SBSR_BASE_LEN 0x5C /* base length, without records */
  5200. #define MLXSW_REG_SBSR_REC_LEN 0x8 /* record length */
  5201. #define MLXSW_REG_SBSR_REC_MAX_COUNT 120
  5202. #define MLXSW_REG_SBSR_LEN (MLXSW_REG_SBSR_BASE_LEN + \
  5203. MLXSW_REG_SBSR_REC_LEN * \
  5204. MLXSW_REG_SBSR_REC_MAX_COUNT)
  5205. MLXSW_REG_DEFINE(sbsr, MLXSW_REG_SBSR_ID, MLXSW_REG_SBSR_LEN);
  5206. /* reg_sbsr_clr
  5207. * Clear Max Buffer Occupancy. When this bit is set, the max_buff_occupancy
  5208. * field is cleared (and a new max value is tracked from the time the clear
  5209. * was performed).
  5210. * Access: OP
  5211. */
  5212. MLXSW_ITEM32(reg, sbsr, clr, 0x00, 31, 1);
  5213. /* reg_sbsr_ingress_port_mask
  5214. * Bit vector for all ingress network ports.
  5215. * Indicates which of the ports (for which the relevant bit is set)
  5216. * are affected by the set operation. Configuration of any other port
  5217. * does not change.
  5218. * Access: Index
  5219. */
  5220. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, ingress_port_mask, 0x10, 0x20, 1);
  5221. /* reg_sbsr_pg_buff_mask
  5222. * Bit vector for all switch priority groups.
  5223. * Indicates which of the priorities (for which the relevant bit is set)
  5224. * are affected by the set operation. Configuration of any other priority
  5225. * does not change.
  5226. * Range is 0..cap_max_pg_buffers - 1
  5227. * Access: Index
  5228. */
  5229. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, pg_buff_mask, 0x30, 0x4, 1);
  5230. /* reg_sbsr_egress_port_mask
  5231. * Bit vector for all egress network ports.
  5232. * Indicates which of the ports (for which the relevant bit is set)
  5233. * are affected by the set operation. Configuration of any other port
  5234. * does not change.
  5235. * Access: Index
  5236. */
  5237. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, egress_port_mask, 0x34, 0x20, 1);
  5238. /* reg_sbsr_tclass_mask
  5239. * Bit vector for all traffic classes.
  5240. * Indicates which of the traffic classes (for which the relevant bit is
  5241. * set) are affected by the set operation. Configuration of any other
  5242. * traffic class does not change.
  5243. * Range is 0..cap_max_tclass - 1
  5244. * Access: Index
  5245. */
  5246. MLXSW_ITEM_BIT_ARRAY(reg, sbsr, tclass_mask, 0x54, 0x8, 1);
  5247. static inline void mlxsw_reg_sbsr_pack(char *payload, bool clr)
  5248. {
  5249. MLXSW_REG_ZERO(sbsr, payload);
  5250. mlxsw_reg_sbsr_clr_set(payload, clr);
  5251. }
  5252. /* reg_sbsr_rec_buff_occupancy
  5253. * Current buffer occupancy in cells.
  5254. * Access: RO
  5255. */
  5256. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  5257. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x00, false);
  5258. /* reg_sbsr_rec_max_buff_occupancy
  5259. * Maximum value of buffer occupancy in cells monitored. Cleared by
  5260. * writing to the clr field.
  5261. * Access: RO
  5262. */
  5263. MLXSW_ITEM32_INDEXED(reg, sbsr, rec_max_buff_occupancy, MLXSW_REG_SBSR_BASE_LEN,
  5264. 0, 24, MLXSW_REG_SBSR_REC_LEN, 0x04, false);
  5265. static inline void mlxsw_reg_sbsr_rec_unpack(char *payload, int rec_index,
  5266. u32 *p_buff_occupancy,
  5267. u32 *p_max_buff_occupancy)
  5268. {
  5269. *p_buff_occupancy =
  5270. mlxsw_reg_sbsr_rec_buff_occupancy_get(payload, rec_index);
  5271. *p_max_buff_occupancy =
  5272. mlxsw_reg_sbsr_rec_max_buff_occupancy_get(payload, rec_index);
  5273. }
  5274. /* SBIB - Shared Buffer Internal Buffer Register
  5275. * ---------------------------------------------
  5276. * The SBIB register configures per port buffers for internal use. The internal
  5277. * buffers consume memory on the port buffers (note that the port buffers are
  5278. * used also by PBMC).
  5279. *
  5280. * For Spectrum this is used for egress mirroring.
  5281. */
  5282. #define MLXSW_REG_SBIB_ID 0xB006
  5283. #define MLXSW_REG_SBIB_LEN 0x10
  5284. MLXSW_REG_DEFINE(sbib, MLXSW_REG_SBIB_ID, MLXSW_REG_SBIB_LEN);
  5285. /* reg_sbib_local_port
  5286. * Local port number
  5287. * Not supported for CPU port and router port
  5288. * Access: Index
  5289. */
  5290. MLXSW_ITEM32(reg, sbib, local_port, 0x00, 16, 8);
  5291. /* reg_sbib_buff_size
  5292. * Units represented in cells
  5293. * Allowed range is 0 to (cap_max_headroom_size - 1)
  5294. * Default is 0
  5295. * Access: RW
  5296. */
  5297. MLXSW_ITEM32(reg, sbib, buff_size, 0x08, 0, 24);
  5298. static inline void mlxsw_reg_sbib_pack(char *payload, u8 local_port,
  5299. u32 buff_size)
  5300. {
  5301. MLXSW_REG_ZERO(sbib, payload);
  5302. mlxsw_reg_sbib_local_port_set(payload, local_port);
  5303. mlxsw_reg_sbib_buff_size_set(payload, buff_size);
  5304. }
  5305. static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
  5306. MLXSW_REG(sgcr),
  5307. MLXSW_REG(spad),
  5308. MLXSW_REG(smid),
  5309. MLXSW_REG(sspr),
  5310. MLXSW_REG(sfdat),
  5311. MLXSW_REG(sfd),
  5312. MLXSW_REG(sfn),
  5313. MLXSW_REG(spms),
  5314. MLXSW_REG(spvid),
  5315. MLXSW_REG(spvm),
  5316. MLXSW_REG(spaft),
  5317. MLXSW_REG(sfgc),
  5318. MLXSW_REG(sftr),
  5319. MLXSW_REG(sfdf),
  5320. MLXSW_REG(sldr),
  5321. MLXSW_REG(slcr),
  5322. MLXSW_REG(slcor),
  5323. MLXSW_REG(spmlr),
  5324. MLXSW_REG(svfa),
  5325. MLXSW_REG(svpe),
  5326. MLXSW_REG(sfmr),
  5327. MLXSW_REG(spvmlr),
  5328. MLXSW_REG(ppbt),
  5329. MLXSW_REG(pacl),
  5330. MLXSW_REG(pagt),
  5331. MLXSW_REG(ptar),
  5332. MLXSW_REG(ppbs),
  5333. MLXSW_REG(prcr),
  5334. MLXSW_REG(pefa),
  5335. MLXSW_REG(ptce2),
  5336. MLXSW_REG(qpcr),
  5337. MLXSW_REG(qtct),
  5338. MLXSW_REG(qeec),
  5339. MLXSW_REG(pmlp),
  5340. MLXSW_REG(pmtu),
  5341. MLXSW_REG(ptys),
  5342. MLXSW_REG(ppad),
  5343. MLXSW_REG(paos),
  5344. MLXSW_REG(pfcc),
  5345. MLXSW_REG(ppcnt),
  5346. MLXSW_REG(plib),
  5347. MLXSW_REG(pptb),
  5348. MLXSW_REG(pbmc),
  5349. MLXSW_REG(pspa),
  5350. MLXSW_REG(htgt),
  5351. MLXSW_REG(hpkt),
  5352. MLXSW_REG(rgcr),
  5353. MLXSW_REG(ritr),
  5354. MLXSW_REG(ratr),
  5355. MLXSW_REG(ricnt),
  5356. MLXSW_REG(ralta),
  5357. MLXSW_REG(ralst),
  5358. MLXSW_REG(raltb),
  5359. MLXSW_REG(ralue),
  5360. MLXSW_REG(rauht),
  5361. MLXSW_REG(raleu),
  5362. MLXSW_REG(rauhtd),
  5363. MLXSW_REG(mfcr),
  5364. MLXSW_REG(mfsc),
  5365. MLXSW_REG(mfsm),
  5366. MLXSW_REG(mfsl),
  5367. MLXSW_REG(mtcap),
  5368. MLXSW_REG(mtmp),
  5369. MLXSW_REG(mpat),
  5370. MLXSW_REG(mpar),
  5371. MLXSW_REG(mlcr),
  5372. MLXSW_REG(mpsc),
  5373. MLXSW_REG(mgpc),
  5374. MLXSW_REG(sbpr),
  5375. MLXSW_REG(sbcm),
  5376. MLXSW_REG(sbpm),
  5377. MLXSW_REG(sbmm),
  5378. MLXSW_REG(sbsr),
  5379. MLXSW_REG(sbib),
  5380. };
  5381. static inline const char *mlxsw_reg_id_str(u16 reg_id)
  5382. {
  5383. const struct mlxsw_reg_info *reg_info;
  5384. int i;
  5385. for (i = 0; i < ARRAY_SIZE(mlxsw_reg_infos); i++) {
  5386. reg_info = mlxsw_reg_infos[i];
  5387. if (reg_info->id == reg_id)
  5388. return reg_info->name;
  5389. }
  5390. return "*UNKNOWN*";
  5391. }
  5392. /* PUDE - Port Up / Down Event
  5393. * ---------------------------
  5394. * Reports the operational state change of a port.
  5395. */
  5396. #define MLXSW_REG_PUDE_LEN 0x10
  5397. /* reg_pude_swid
  5398. * Switch partition ID with which to associate the port.
  5399. * Access: Index
  5400. */
  5401. MLXSW_ITEM32(reg, pude, swid, 0x00, 24, 8);
  5402. /* reg_pude_local_port
  5403. * Local port number.
  5404. * Access: Index
  5405. */
  5406. MLXSW_ITEM32(reg, pude, local_port, 0x00, 16, 8);
  5407. /* reg_pude_admin_status
  5408. * Port administrative state (the desired state).
  5409. * 1 - Up.
  5410. * 2 - Down.
  5411. * 3 - Up once. This means that in case of link failure, the port won't go
  5412. * into polling mode, but will wait to be re-enabled by software.
  5413. * 4 - Disabled by system. Can only be set by hardware.
  5414. * Access: RO
  5415. */
  5416. MLXSW_ITEM32(reg, pude, admin_status, 0x00, 8, 4);
  5417. /* reg_pude_oper_status
  5418. * Port operatioanl state.
  5419. * 1 - Up.
  5420. * 2 - Down.
  5421. * 3 - Down by port failure. This means that the device will not let the
  5422. * port up again until explicitly specified by software.
  5423. * Access: RO
  5424. */
  5425. MLXSW_ITEM32(reg, pude, oper_status, 0x00, 0, 4);
  5426. #endif