reg.h 200 KB

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