reg.h 153 KB

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